From 3eb9473ea9a949badfe06ae61d2d3fcfa53651c7 Mon Sep 17 00:00:00 2001 From: qwang12 Date: Thu, 28 Jun 2007 07:00:39 +0000 Subject: [PATCH] Add in the 1st version of ECP. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2832 6f19259b-4bc3-4df7-8a09-765794883524 --- EdkCompatibilityPkg/EDK_Snapshot.txt | 6 + EdkCompatibilityPkg/EdkCompatibilityPkg.dec | 49 + .../Core/Dxe/ArchProtocol/ArchProtocolLib.inf | 65 + .../Core/Dxe/ArchProtocol/Bds/Bds.c | 27 + .../Core/Dxe/ArchProtocol/Bds/Bds.h | 100 + .../Core/Dxe/ArchProtocol/Capsule/Capsule.c | 27 + .../Core/Dxe/ArchProtocol/Capsule/Capsule.h | 33 + .../Core/Dxe/ArchProtocol/Cpu/Cpu.c | 28 + .../Core/Dxe/ArchProtocol/Cpu/Cpu.h | 361 + .../Dxe/ArchProtocol/Metronome/Metronome.c | 27 + .../Dxe/ArchProtocol/Metronome/Metronome.h | 109 + .../MonotonicCounter/MonotonicCounter.c | 27 + .../MonotonicCounter/MonotonicCounter.h | 35 + .../RealTimeClock/RealTimeClock.c | 27 + .../RealTimeClock/RealTimeClock.h | 43 + .../Core/Dxe/ArchProtocol/Reset/Reset.c | 27 + .../Core/Dxe/ArchProtocol/Reset/Reset.h | 40 + .../Core/Dxe/ArchProtocol/Runtime/Runtime.c | 29 + .../Core/Dxe/ArchProtocol/Runtime/Runtime.h | 114 + .../Core/Dxe/ArchProtocol/Security/Security.c | 28 + .../Core/Dxe/ArchProtocol/Security/Security.h | 146 + .../Dxe/ArchProtocol/StatusCode/StatusCode.c | 29 + .../Dxe/ArchProtocol/StatusCode/StatusCode.h | 100 + .../Core/Dxe/ArchProtocol/Timer/Timer.c | 27 + .../Core/Dxe/ArchProtocol/Timer/Timer.h | 260 + .../Core/Dxe/ArchProtocol/Variable/Variable.c | 29 + .../Core/Dxe/ArchProtocol/Variable/Variable.h | 41 + .../VariableWrite/VariableWrite.c | 30 + .../VariableWrite/VariableWrite.h | 41 + .../WatchdogTimer/WatchdogTimer.c | 27 + .../WatchdogTimer/WatchdogTimer.h | 206 + .../Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf | 37 + .../Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s | 33 + .../Foundation/Cpu/Itanium/Include/CpuIa64.h | 39 + .../Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf | 42 + .../Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c | 73 + .../Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c | 179 + .../Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm | 215 + .../Foundation/Cpu/Pentium/Include/CpuIA32.h | 372 ++ .../Foundation/Efi/Guid/Acpi/Acpi.c | 35 + .../Foundation/Efi/Guid/Acpi/Acpi.h | 44 + .../DebugImageInfoTable/DebugImageInfoTable.c | 28 + .../DebugImageInfoTable/DebugImageInfoTable.h | 63 + .../Foundation/Efi/Guid/EfiGuidLib.inf | 59 + .../Efi/Guid/EventGroup/EventGroup.c | 30 + .../Efi/Guid/EventGroup/EventGroup.h | 45 + .../Efi/Guid/GlobalVariable/GlobalVariable.c | 27 + .../Efi/Guid/GlobalVariable/GlobalVariable.h | 32 + .../Foundation/Efi/Guid/Gpt/Gpt.c | 38 + .../Foundation/Efi/Guid/Gpt/Gpt.h | 47 + .../HardwareErrorVariable.c | 27 + .../HardwareErrorVariable.h | 32 + .../Foundation/Efi/Guid/Mps/Mps.c | 33 + .../Foundation/Efi/Guid/Mps/Mps.h | 38 + .../Efi/Guid/SalSystemTable/SalSystemTable.c | 30 + .../Efi/Guid/SalSystemTable/SalSystemTable.h | 34 + .../Foundation/Efi/Guid/Smbios/SmBios.c | 31 + .../Foundation/Efi/Guid/Smbios/SmBios.h | 70 + .../Foundation/Efi/Guid/pcansi/PcAnsi.c | 34 + .../Foundation/Efi/Guid/pcansi/PcAnsi.h | 50 + .../Foundation/Efi/Include/EfiApi.h | 1114 ++++ .../Foundation/Efi/Include/EfiDevicePath.h | 555 ++ .../Foundation/Efi/Include/EfiError.h | 67 + .../Foundation/Efi/Include/EfiImage.h | 661 ++ .../Foundation/Efi/Include/EfiTypes.h | 292 + .../Foundation/Efi/Include/Pxe.h | 58 + .../Efi/Protocol/AcpiTable/AcpiTable.c | 29 + .../Efi/Protocol/AcpiTable/AcpiTable.h | 112 + .../Foundation/Efi/Protocol/Arp/Arp.c | 29 + .../Foundation/Efi/Protocol/Arp/Arp.h | 136 + .../Foundation/Efi/Protocol/Bis/Bis.c | 27 + .../Foundation/Efi/Protocol/Bis/Bis.h | 233 + .../Foundation/Efi/Protocol/BlockIO/BlockIO.c | 31 + .../Foundation/Efi/Protocol/BlockIO/BlockIO.h | 206 + .../BusSpecificDriverOverride.c | 31 + .../BusSpecificDriverOverride.h | 54 + .../Protocol/ComponentName/ComponentName.c | 29 + .../Protocol/ComponentName/ComponentName.h | 137 + .../Protocol/ComponentName2/ComponentName2.c | 29 + .../Protocol/ComponentName2/ComponentName2.h | 136 + .../Efi/Protocol/DebugPort/DebugPort.c | 27 + .../Efi/Protocol/DebugPort/DebugPort.h | 98 + .../Efi/Protocol/DebugSupport/DebugSupport.c | 27 + .../Efi/Protocol/DebugSupport/DebugSupport.h | 594 ++ .../Efi/Protocol/Decompress/Decompress.c | 27 + .../Efi/Protocol/Decompress/Decompress.h | 140 + .../Efi/Protocol/DeviceIO/DeviceIO.c | 31 + .../Efi/Protocol/DeviceIO/DeviceIO.h | 132 + .../Efi/Protocol/DevicePath/DevicePath.c | 32 + .../Efi/Protocol/DevicePath/DevicePath.h | 67 + .../DevicePathFromText/DevicePathFromText.c | 27 + .../DevicePathFromText/DevicePathFromText.h | 82 + .../DevicePathToText/DevicePathToText.c | 27 + .../DevicePathToText/DevicePathToText.h | 95 + .../DevicePathUtilities/DevicePathUtilities.c | 27 + .../DevicePathUtilities/DevicePathUtilities.h | 225 + .../Foundation/Efi/Protocol/Dhcp4/Dhcp4.c | 41 + .../Foundation/Efi/Protocol/Dhcp4/Dhcp4.h | 237 + .../Foundation/Efi/Protocol/DiskIO/DiskIo.c | 31 + .../Foundation/Efi/Protocol/DiskIO/DiskIo.h | 111 + .../Protocol/DriverBinding/DriverBinding.c | 29 + .../Protocol/DriverBinding/DriverBinding.h | 130 + .../DriverConfiguration/DriverConfiguration.c | 30 + .../DriverConfiguration/DriverConfiguration.h | 211 + .../DriverDiagnostics/DriverDiagnostics.c | 30 + .../DriverDiagnostics/DriverDiagnostics.h | 138 + .../Foundation/Efi/Protocol/Ebc/Ebc.c | 28 + .../Foundation/Efi/Protocol/Ebc/Ebc.h | 183 + .../Efi/Protocol/EdidActive/EdidActive.c | 29 + .../Efi/Protocol/EdidActive/EdidActive.h | 39 + .../Protocol/EdidDiscovered/EdidDiscovered.c | 30 + .../Protocol/EdidDiscovered/EdidDiscovered.h | 40 + .../Efi/Protocol/EdidOverride/EdidOverride.c | 30 + .../Efi/Protocol/EdidOverride/EdidOverride.h | 78 + .../EfiNetworkInterfaceIdentifier.c | 40 + .../EfiNetworkInterfaceIdentifier.h | 102 + .../Efi/Protocol/EfiProtocolLib.inf | 158 + .../Efi/Protocol/FileInfo/FileInfo.c | 27 + .../Efi/Protocol/FileInfo/FileInfo.h | 58 + .../Protocol/FileSystemInfo/FileSystemInfo.c | 27 + .../Protocol/FileSystemInfo/FileSystemInfo.h | 51 + .../FileSystemVolumeLabelInfo.c | 34 + .../FileSystemVolumeLabelInfo.h | 38 + .../Protocol/GraphicsOutput/GraphicsOutput.c | 29 + .../Protocol/GraphicsOutput/GraphicsOutput.h | 206 + .../Foundation/Efi/Protocol/Hash/Hash.c | 40 + .../Foundation/Efi/Protocol/Hash/Hash.h | 161 + .../IScsiInitiatorName/IScsiInitiatorName.c | 27 + .../IScsiInitiatorName/IScsiInitiatorName.h | 98 + .../Foundation/Efi/Protocol/Ip4/Ip4.c | 41 + .../Foundation/Efi/Protocol/Ip4/Ip4.h | 241 + .../Efi/Protocol/Ip4Config/Ip4Config.c | 29 + .../Efi/Protocol/Ip4Config/Ip4Config.h | 73 + .../Efi/Protocol/LoadFile/LoadFile.c | 33 + .../Efi/Protocol/LoadFile/LoadFile.h | 87 + .../Efi/Protocol/LoadedImage/LoadedImage.c | 30 + .../Efi/Protocol/LoadedImage/LoadedImage.h | 73 + .../Protocol/ManagedNetwork/ManagedNetwork.c | 29 + .../Protocol/ManagedNetwork/ManagedNetwork.h | 164 + .../Foundation/Efi/Protocol/Mtftp4/Mtftp4.c | 39 + .../Foundation/Efi/Protocol/Mtftp4/Mtftp4.h | 308 + .../Foundation/Efi/Protocol/PciIo/PciIo.c | 30 + .../Foundation/Efi/Protocol/PciIo/PciIo.h | 275 + .../PciRootBridgeIo/PciRootBridgeIo.c | 32 + .../PciRootBridgeIo/PciRootBridgeIo.h | 220 + .../PlatformDriverOverride.c | 31 + .../PlatformDriverOverride.h | 74 + .../Efi/Protocol/PxeBaseCode/PxeBaseCode.c | 27 + .../Efi/Protocol/PxeBaseCode/PxeBaseCode.h | 386 ++ .../PxeBaseCodeCallBack/PxeBaseCodeCallBack.c | 29 + .../PxeBaseCodeCallBack/PxeBaseCodeCallBack.h | 82 + .../Foundation/Efi/Protocol/ScsiIo/ScsiIo.c | 26 + .../Foundation/Efi/Protocol/ScsiIo/ScsiIo.h | 256 + .../Efi/Protocol/ScsiPassThru/ScsiPassThru.c | 27 + .../Efi/Protocol/ScsiPassThru/ScsiPassThru.h | 332 + .../ScsiPassThruExt/ScsiPassThruExt.c | 28 + .../ScsiPassThruExt/ScsiPassThruExt.h | 365 + .../Efi/Protocol/SerialIO/SerialIo.c | 30 + .../Efi/Protocol/SerialIO/SerialIo.h | 296 + .../Protocol/ServiceBinding/ServiceBinding.h | 88 + .../SimpleFileSystem/SimpleFileSystem.c | 33 + .../SimpleFileSystem/SimpleFileSystem.h | 376 ++ .../Protocol/SimpleNetwork/SimpleNetwork.c | 34 + .../Protocol/SimpleNetwork/SimpleNetwork.h | 639 ++ .../Protocol/SimplePointer/SimplePointer.c | 29 + .../Protocol/SimplePointer/SimplePointer.h | 76 + .../Efi/Protocol/SimpleTextIn/SimpleTextIn.c | 30 + .../Efi/Protocol/SimpleTextIn/SimpleTextIn.h | 136 + .../Protocol/SimpleTextOut/SimpleTextOut.c | 30 + .../Protocol/SimpleTextOut/SimpleTextOut.h | 423 ++ .../Foundation/Efi/Protocol/TapeIo/TapeIo.c | 28 + .../Foundation/Efi/Protocol/TapeIo/TapeIo.h | 263 + .../Foundation/Efi/Protocol/Tcp4/Tcp4.c | 30 + .../Foundation/Efi/Protocol/Tcp4/Tcp4.h | 247 + .../Foundation/Efi/Protocol/Udp4/Udp4.c | 29 + .../Foundation/Efi/Protocol/Udp4/Udp4.h | 214 + .../Foundation/Efi/Protocol/UgaDraw/UgaDraw.c | 29 + .../Foundation/Efi/Protocol/UgaDraw/UgaDraw.h | 181 + .../Foundation/Efi/Protocol/UgaIo/UgaIo.c | 29 + .../Foundation/Efi/Protocol/UgaIo/UgaIo.h | 236 + .../UnicodeCollation/UnicodeCollation.c | 27 + .../UnicodeCollation/UnicodeCollation.h | 211 + .../UsbHostController/UsbHostController.c | 30 + .../UsbHostController/UsbHostController.h | 411 ++ .../Foundation/Efi/Protocol/UsbIo/UsbIo.c | 30 + .../Foundation/Efi/Protocol/UsbIo/UsbIo.h | 205 + .../Guid/AcpiTableStorage/AcpiTableStorage.c | 28 + .../Guid/AcpiTableStorage/AcpiTableStorage.h | 32 + .../Framework/Guid/Apriori/Apriori.c | 29 + .../Framework/Guid/Apriori/Apriori.h | 34 + .../Guid/DataHubRecords/DataHubRecords.c | 51 + .../Guid/DataHubRecords/DataHubRecords.h | 109 + .../Guid/DataHubRecords/DataHubSubClass.h | 73 + .../DataHubRecords/DataHubSubClassCache.h | 151 + .../DataHubRecords/DataHubSubClassMemory.h | 408 ++ .../Guid/DataHubRecords/DataHubSubClassMisc.h | 1130 ++++ .../DataHubRecords/DataHubSubClassProcessor.h | 360 + .../Framework/Guid/DxeServices/DxeServices.c | 27 + .../Framework/Guid/DxeServices/DxeServices.h | 32 + .../Framework/Guid/EdkFrameworkGuidLib.inf | 63 + .../FirmwareFileSystem/FirmwareFileSystem.c | 30 + .../FirmwareFileSystem/FirmwareFileSystem.h | 34 + .../FirmwareFileSystem2/FirmwareFileSystem2.c | 27 + .../FirmwareFileSystem2/FirmwareFileSystem2.h | 33 + .../FrameworkDevicePath/FrameworkDevicePath.c | 27 + .../FrameworkDevicePath/FrameworkDevicePath.h | 29 + .../Foundation/Framework/Guid/Hob/Hob.c | 29 + .../Foundation/Framework/Guid/Hob/Hob.h | 34 + .../MemoryAllocationHob/MemoryAllocationHob.c | 31 + .../MemoryAllocationHob/MemoryAllocationHob.h | 38 + .../Framework/Guid/PeiApriori/PeiApriori.c | 26 + .../Framework/Guid/PeiApriori/PeiApriori.h | 36 + .../SmramMemoryReserve/SmramMemoryReserve.c | 28 + .../SmramMemoryReserve/SmramMemoryReserve.h | 70 + .../StatusCodeDataTypeId.c | 47 + .../StatusCodeDataTypeId.h | 385 ++ .../Foundation/Framework/Include/BootMode.h | 38 + .../Framework/Include/EfiBootScript.h | 210 + .../Foundation/Framework/Include/EfiCapsule.h | 136 + .../Framework/Include/EfiDependency.h | 52 + .../Framework/Include/EfiFirmwareFileSystem.h | 128 + .../Framework/Include/EfiFirmwareVolume.h | 46 + .../Include/EfiFirmwareVolumeHeader.h | 213 + .../Framework/Include/EfiImageFormat.h | 279 + .../Include/EfiInternalFormRepresentation.h | 431 ++ .../Foundation/Framework/Include/EfiPciCfg.h | 82 + .../Foundation/Framework/Include/EfiSmbus.h | 69 + .../Framework/Include/EfiStatusCode.h | 954 +++ .../Framework/Include/EfiVariable.h | 34 + .../Foundation/Framework/Include/PeiApi.h | 615 ++ .../Foundation/Framework/Include/PeiHob.h | 251 + .../Framework/Include/TianoSpecApi.h | 589 ++ .../Framework/Include/TianoSpecDevicePath.h | 73 + .../Framework/Include/TianoSpecError.h | 41 + .../Framework/Include/TianoSpecTypes.h | 75 + .../Framework/Ppi/BlockIo/BlockIo.c | 29 + .../Framework/Ppi/BlockIo/BlockIo.h | 88 + .../BootInRecoveryMode/BootInRecoveryMode.c | 29 + .../BootInRecoveryMode/BootInRecoveryMode.h | 34 + .../Framework/Ppi/BootMode/BootMode.c | 29 + .../Framework/Ppi/BootMode/BootMode.h | 34 + .../BootScriptExecuter/BootScriptExecuter.c | 29 + .../BootScriptExecuter/BootScriptExecuter.h | 50 + .../Foundation/Framework/Ppi/CpuIo/CpuIo.c | 29 + .../Foundation/Framework/Ppi/CpuIo/CpuIo.h | 250 + .../Framework/Ppi/Decompress/Decompress.c | 28 + .../Framework/Ppi/Decompress/Decompress.h | 49 + .../DeviceRecoveryModule.c | 30 + .../DeviceRecoveryModule.h | 68 + .../Foundation/Framework/Ppi/DxeIpl/DxeIpl.c | 29 + .../Foundation/Framework/Ppi/DxeIpl/DxeIpl.h | 51 + .../Framework/Ppi/EdkFrameworkPpiLib.inf | 102 + .../Ppi/EndOfPeiSignal/EndOfPeiSignal.c | 29 + .../Ppi/EndOfPeiSignal/EndOfPeiSignal.h | 35 + .../Foundation/Framework/Ppi/FindFv/FindFv.c | 29 + .../Foundation/Framework/Ppi/FindFv/FindFv.h | 51 + .../Ppi/FirmwareVolume/FirmwareVolume.c | 30 + .../Ppi/FirmwareVolume/FirmwareVolume.h | 112 + .../FirmwareVolumeInfo/FirmwareVolumeInfo.c | 28 + .../FirmwareVolumeInfo/FirmwareVolumeInfo.h | 46 + .../GuidedSectionExtraction.c | 29 + .../GuidedSectionExtraction.h | 42 + .../Framework/Ppi/LoadFile/LoadFile.c | 29 + .../Framework/Ppi/LoadFile/LoadFile.h | 48 + .../Framework/Ppi/LoadFile2/LoadFile2.c | 29 + .../Framework/Ppi/LoadFile2/LoadFile2.h | 49 + .../Ppi/MemoryDiscovered/MemoryDiscovered.c | 29 + .../Ppi/MemoryDiscovered/MemoryDiscovered.h | 34 + .../Foundation/Framework/Ppi/PciCfg/PciCfg.c | 28 + .../Foundation/Framework/Ppi/PciCfg/PciCfg.h | 65 + .../Framework/Ppi/PciCfg2/PciCfg2.c | 28 + .../Framework/Ppi/PciCfg2/PciCfg2.h | 66 + .../Ppi/RecoveryModule/RecoveryModule.c | 29 + .../Ppi/RecoveryModule/RecoveryModule.h | 45 + .../Foundation/Framework/Ppi/Reset/Reset.c | 28 + .../Foundation/Framework/Ppi/Reset/Reset.h | 54 + .../Framework/Ppi/S3Resume/S3Resume.c | 29 + .../Framework/Ppi/S3Resume/S3Resume.h | 44 + .../SecPlatformInformation.c | 29 + .../SecPlatformInformation.h | 71 + .../Ppi/SectionExtraction/SectionExtraction.c | 28 + .../Ppi/SectionExtraction/SectionExtraction.h | 59 + .../Framework/Ppi/Security/Security.c | 28 + .../Framework/Ppi/Security/Security.h | 48 + .../Framework/Ppi/Security2/Security2.c | 28 + .../Framework/Ppi/Security2/Security2.h | 50 + .../Foundation/Framework/Ppi/Smbus/Smbus.c | 29 + .../Foundation/Framework/Ppi/Smbus/Smbus.h | 101 + .../Foundation/Framework/Ppi/Smbus2/Smbus2.c | 29 + .../Foundation/Framework/Ppi/Smbus2/Smbus2.h | 96 + .../Foundation/Framework/Ppi/Stall/Stall.c | 28 + .../Foundation/Framework/Ppi/Stall/Stall.h | 47 + .../Framework/Ppi/StatusCode/StatusCode.c | 29 + .../Framework/Ppi/StatusCode/StatusCode.h | 49 + .../Framework/Ppi/Variable/Variable.c | 29 + .../Framework/Ppi/Variable/Variable.h | 62 + .../Framework/Ppi/Variable2/Variable2.c | 29 + .../Framework/Ppi/Variable2/Variable2.h | 61 + .../Protocol/AcpiS3Save/AcpiS3Save.c | 28 + .../Protocol/AcpiS3Save/AcpiS3Save.h | 68 + .../Protocol/AcpiSupport/AcpiSupport.c | 29 + .../Protocol/AcpiSupport/AcpiSupport.h | 128 + .../Protocol/BootScriptSave/BootScriptSave.c | 28 + .../Protocol/BootScriptSave/BootScriptSave.h | 75 + .../Framework/Protocol/CpuIo/CpuIo.c | 28 + .../Framework/Protocol/CpuIo/CpuIo.h | 93 + .../Framework/Protocol/DataHub/DataHub.c | 32 + .../Framework/Protocol/DataHub/DataHub.h | 125 + .../Protocol/EdkFrameworkProtocolLib.inf | 116 + .../Protocol/FirmwareVolume/FirmwareVolume.c | 31 + .../Protocol/FirmwareVolume/FirmwareVolume.h | 301 + .../FirmwareVolume2/FirmwareVolume2.c | 29 + .../FirmwareVolume2/FirmwareVolume2.h | 195 + .../FirmwareVolumeBlock/FirmwareVolumeBlock.c | 31 + .../FirmwareVolumeBlock/FirmwareVolumeBlock.h | 251 + .../Protocol/FormBrowser/FormBrowser.c | 31 + .../Protocol/FormBrowser/FormBrowser.h | 97 + .../Protocol/FormCallback/FormCallback.c | 31 + .../Protocol/FormCallback/FormCallback.h | 120 + .../Foundation/Framework/Protocol/Hii/Hii.c | 30 + .../Foundation/Framework/Protocol/Hii/Hii.h | 613 ++ .../IdeControllerInit/IdeControllerInit.c | 30 + .../IdeControllerInit/IdeControllerInit.h | 348 + .../IncompatiblePciDeviceSupport.c | 34 + .../IncompatiblePciDeviceSupport.h | 55 + .../Protocol/Legacy8259/Legacy8259.c | 31 + .../Protocol/Legacy8259/Legacy8259.h | 317 + .../Protocol/LegacyBios/LegacyBios.c | 30 + .../Protocol/LegacyBios/LegacyBios.h | 701 ++ .../LegacyBiosPlatform/LegacyBiosPlatform.c | 31 + .../LegacyBiosPlatform/LegacyBiosPlatform.h | 328 + .../LegacyInterrupt/LegacyInterrupt.c | 31 + .../LegacyInterrupt/LegacyInterrupt.h | 136 + .../Protocol/LegacyRegion/LegacyRegion.c | 31 + .../Protocol/LegacyRegion/LegacyRegion.h | 82 + .../PciHostBridgeResourceAllocation.c | 31 + .../PciHostBridgeResourceAllocation.h | 364 + .../Protocol/PciHotPlugInit/PciHotPlugInit.c | 30 + .../Protocol/PciHotPlugInit/PciHotPlugInit.h | 97 + .../Protocol/PciPlatform/PciPlatform.c | 26 + .../Protocol/PciPlatform/PciPlatform.h | 211 + .../SectionExtraction/SectionExtraction.c | 28 + .../SectionExtraction/SectionExtraction.h | 83 + .../Protocol/SecurityPolicy/SecurityPolicy.c | 28 + .../Protocol/SecurityPolicy/SecurityPolicy.h | 33 + .../Framework/Protocol/Smbus/Smbus.c | 31 + .../Framework/Protocol/Smbus/Smbus.h | 93 + .../Framework/Protocol/SmmAccess/SmmAccess.c | 30 + .../Framework/Protocol/SmmAccess/SmmAccess.h | 79 + .../Framework/Protocol/SmmBase/SmmBase.c | 38 + .../Framework/Protocol/SmmBase/SmmBase.h | 797 +++ .../Protocol/SmmControl/SmmControl.c | 30 + .../Protocol/SmmControl/SmmControl.h | 79 + .../Protocol/SmmCpuState/CpuSaveState.h | 150 + .../Protocol/SmmCpuState/SmmCpuState.c | 30 + .../Protocol/SmmCpuState/SmmCpuState.h | 43 + .../Protocol/SmmGpiDispatch/SmmGpiDispatch.c | 31 + .../Protocol/SmmGpiDispatch/SmmGpiDispatch.h | 152 + .../SmmIchnDispatch/SmmIchnDispatch.c | 31 + .../SmmIchnDispatch/SmmIchnDispatch.h | 204 + .../SmmPeriodicTimerDispatch.c | 34 + .../SmmPeriodicTimerDispatch.h | 205 + .../SmmPowerButtonDispatch.c | 34 + .../SmmPowerButtonDispatch.h | 153 + .../SmmStandbyButtonDispatch.c | 34 + .../SmmStandbyButtonDispatch.h | 153 + .../Protocol/SmmStatusCode/SmmStatusCode.c | 30 + .../Protocol/SmmStatusCode/SmmStatusCode.h | 58 + .../Protocol/SmmSwDispatch/SmmSwDispatch.c | 30 + .../Protocol/SmmSwDispatch/SmmSwDispatch.h | 151 + .../Protocol/SmmSxDispatch/SmmSxDispatch.c | 30 + .../Protocol/SmmSxDispatch/SmmSxDispatch.h | 170 + .../Protocol/SmmUsbDispatch/SmmUsbDispatch.c | 31 + .../Protocol/SmmUsbDispatch/SmmUsbDispatch.h | 149 + .../Guid/AcpiDescription/AcpiDescription.c | 28 + .../Guid/AcpiDescription/AcpiDescription.h | 127 + .../Guid/AlternateFvBlock/AlternateFvBlock.c | 28 + .../Guid/AlternateFvBlock/AlternateFvBlock.h | 32 + EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c | 29 + EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h | 62 + .../Foundation/Guid/BootState/BootState.c | 30 + .../Foundation/Guid/BootState/BootState.h | 38 + .../Foundation/Guid/Capsule/Capsule.c | 29 + .../Foundation/Guid/Capsule/Capsule.h | 35 + .../CompatibleMemoryTested.c | 28 + .../CompatibleMemoryTested.h | 32 + .../Guid/ConsoleInDevice/ConsoleInDevice.c | 27 + .../Guid/ConsoleInDevice/ConsoleInDevice.h | 29 + .../Guid/ConsoleOutDevice/ConsoleOutDevice.c | 27 + .../Guid/ConsoleOutDevice/ConsoleOutDevice.h | 29 + .../Foundation/Guid/EdkGuidLib.inf | 98 + .../Foundation/Guid/EfiShell/EfiShell.c | 31 + .../Foundation/Guid/EfiShell/EfiShell.h | 34 + .../Guid/EventLegacyBios/EventLegacyBios.c | 23 + .../Guid/EventLegacyBios/EventLegacyBios.h | 28 + .../Foundation/Guid/FlashMapHob/FlashMapHob.c | 29 + .../Foundation/Guid/FlashMapHob/FlashMapHob.h | 33 + .../Guid/GenericVariable/GenericVariable.c | 27 + .../Guid/GenericVariable/GenericVariable.h | 32 + .../Guid/HotPlugDevice/HotPlugDevice.c | 27 + .../Guid/HotPlugDevice/HotPlugDevice.h | 28 + .../Foundation/Guid/IoBaseHob/IoBaseHob.c | 29 + .../Foundation/Guid/IoBaseHob/IoBaseHob.h | 30 + .../MemoryTypeInformation.c | 29 + .../MemoryTypeInformation.h | 37 + .../PciExpressBaseAddress.c | 28 + .../PciExpressBaseAddress.h | 46 + .../Guid/PciHotPlugDevice/PciHotplugDevice.c | 29 + .../Guid/PciHotPlugDevice/PciHotplugDevice.h | 30 + .../PciOptionRomTable/PciOptionRomTable.c | 27 + .../PciOptionRomTable/PciOptionRomTable.h | 46 + .../PeiFlushInstructionCache.c | 29 + .../PeiFlushInstructionCache.h | 44 + .../Guid/PeiPeCoffLoader/PeiPeCoffLoader.c | 28 + .../Guid/PeiPeCoffLoader/PeiPeCoffLoader.h | 116 + .../PeiPerformanceHob/PeiPerformanceHob.c | 29 + .../PeiPerformanceHob/PeiPerformanceHob.h | 45 + .../PeiTransferControl/PeiTransferControl.c | 28 + .../PeiTransferControl/PeiTransferControl.h | 53 + .../PrimaryConsoleInDevice.c | 28 + .../PrimaryConsoleInDevice.h | 29 + .../PrimaryConsoleOutDevice.c | 26 + .../PrimaryConsoleOutDevice.h | 28 + .../PrimaryStandardErrorDevice.c | 26 + .../PrimaryStandardErrorDevice.h | 28 + .../StandardErrorDevice/StandardErrorDevice.c | 27 + .../StandardErrorDevice/StandardErrorDevice.h | 29 + .../Foundation/Guid/StatusCode/StatusCode.c | 28 + .../Foundation/Guid/StatusCode/StatusCode.h | 33 + .../StatusCodeCallerId/StatusCodeCallerId.c | 27 + .../StatusCodeCallerId/StatusCodeCallerId.h | 37 + .../Guid/SystemNvDataGuid/SystemNvDataGuid.c | 32 + .../Guid/SystemNvDataGuid/SystemNvDataGuid.h | 45 + .../Foundation/Include/Ebc/EfiBind.h | 129 + .../Include/Ebc/EfiPeOptionalHeader.h | 46 + .../Foundation/Include/Ebc/TianoBind.h | 30 + .../Foundation/Include/EfiCommon.h | 53 + .../Foundation/Include/EfiDebug.h | 170 + .../Foundation/Include/EfiDepex.h | 54 + .../Foundation/Include/EfiFlashMap.h | 128 + .../Foundation/Include/EfiPci.h | 64 + .../Foundation/Include/EfiPerf.h | 158 + .../Foundation/Include/EfiPxe.h | 1816 +++++ .../Foundation/Include/EfiSpec.h | 51 + .../Foundation/Include/EfiStdArg.h | 75 + .../Foundation/Include/EfiTpm.h | 144 + .../Foundation/Include/EfiVariable.h | 85 + .../Include/EfiWorkingBlockHeader.h | 47 + .../Foundation/Include/Ia32/EfiBind.h | 269 + .../Include/Ia32/EfiPeOptionalHeader.h | 38 + .../Foundation/Include/Ia32/TianoBind.h | 102 + .../Include/IndustryStandard/Acpi.h | 31 + .../Include/IndustryStandard/Acpi1_0.h | 299 + .../Include/IndustryStandard/Acpi2_0.h | 513 ++ .../Include/IndustryStandard/Acpi3_0.h | 681 ++ .../Include/IndustryStandard/AcpiCommon.h | 98 + .../AlertStandardFormatTable.h | 123 + .../DMARemappingReportingTable.h | 202 + .../HighPrecisionEventTimerTable.h | 62 + .../IndustryStandard/LegacyBiosMpTable.h | 283 + ...emoryMappedConfigurationSpaceAccessTable.h | 56 + .../Include/IndustryStandard/SdramSpd.h | 73 + .../ServerProcessorManagementInterfaceTable.h | 80 + .../Include/IndustryStandard/Smbios.h | 576 ++ .../Include/IndustryStandard/Tpm12.h | 1847 ++++++ .../WatchdogDescriptionTable.h | 94 + .../Include/IndustryStandard/atapi.h | 331 + .../Foundation/Include/IndustryStandard/pci.h | 31 + .../Include/IndustryStandard/pci22.h | 555 ++ .../Include/IndustryStandard/pci23.h | 31 + .../Include/IndustryStandard/pci30.h | 52 + .../Include/IndustryStandard/scsi.h | 292 + .../Foundation/Include/IndustryStandard/usb.h | 293 + .../Foundation/Include/Ipf/EfiBind.h | 247 + .../Include/Ipf/EfiPeOptionalHeader.h | 37 + .../Foundation/Include/Ipf/IpfDefines.h | 556 ++ .../Foundation/Include/Ipf/IpfMacro.i | 66 + .../Foundation/Include/Ipf/PalApi.h | 133 + .../Foundation/Include/Ipf/SalApi.h | 724 ++ .../Foundation/Include/Ipf/TianoBind.h | 30 + .../Foundation/Include/Pei/Pei.h | 58 + .../Foundation/Include/Pei/PeiBind.h | 160 + .../Foundation/Include/Pei/PeiDebug.h | 104 + .../Foundation/Include/Tiano.h | 56 + .../Foundation/Include/TianoApi.h | 46 + .../Foundation/Include/TianoCommon.h | 51 + .../Foundation/Include/TianoDevicePath.h | 130 + .../Foundation/Include/TianoError.h | 30 + .../Foundation/Include/TianoTypes.h | 48 + .../Foundation/Include/x64/EfiBind.h | 222 + .../Include/x64/EfiPeOptionalHeader.h | 42 + .../Foundation/Include/x64/TianoBind.h | 30 + .../Library/CompilerStub/CompilerStubLib.inf | 61 + .../Library/CompilerStub/Ia32/memcpy.asm | 81 + .../Library/CompilerStub/Ia32/memcpySSE2.asm | 86 + .../Library/CompilerStub/Ia32/memset.asm | 72 + .../Library/CompilerStub/Ia32/memsetSSE2.asm | 74 + .../Foundation/Library/CompilerStub/memcpy.c | 46 + .../Foundation/Library/CompilerStub/memset.c | 45 + .../Library/CompilerStub/x64/memcpy.asm | 73 + .../Library/CompilerStub/x64/memcpySSE2.asm | 80 + .../Library/CompilerStub/x64/memset.asm | 62 + .../Library/CompilerStub/x64/memsetSSE2.asm | 74 + .../CustomizedDecompress.c | 122 + .../CustomizedDecompress.h | 113 + .../CustomizedDecompress.inf | 39 + .../Library/Dxe/EfiDriverLib/Debug.c | 172 + .../Library/Dxe/EfiDriverLib/DevicePath.c | 607 ++ .../Library/Dxe/EfiDriverLib/DxeDriverLib.c | 56 + .../EfiDriverLib/Ebc/PerformancePrimitives.c | 52 + .../Library/Dxe/EfiDriverLib/EfiDriverLib.c | 429 ++ .../Library/Dxe/EfiDriverLib/EfiDriverLib.inf | 88 + .../Dxe/EfiDriverLib/EfiDriverModelLib.c | 289 + .../Dxe/EfiDriverLib/EfiGetConfigTable.c | 61 + .../Library/Dxe/EfiDriverLib/EfiLibAllocate.c | 233 + .../Library/Dxe/EfiDriverLib/Event.c | 371 ++ .../Library/Dxe/EfiDriverLib/GetImage.c | 220 + .../Library/Dxe/EfiDriverLib/Handle.c | 176 + .../EfiDriverLib/Ipf/PerformancePrimitives.s | 61 + .../Library/Dxe/EfiDriverLib/LibGlobalDs.c | 32 + .../Dxe/EfiDriverLib/LibGlobalErrorLevel.c | 34 + .../Library/Dxe/EfiDriverLib/LibGlobalSt.c | 34 + .../Library/Dxe/EfiDriverLib/Lock.c | 159 + .../Library/Dxe/EfiDriverLib/Perf.c | 861 +++ .../Dxe/EfiDriverLib/ReportStatusCode.c | 141 + .../EfiDriverLib/ia32/PerformancePrimitives.c | 47 + .../EfiDriverLib/x64/PerformancePrimitives.c | 47 + .../Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf | 51 + .../Library/Dxe/EfiIfrSupportLib/IfrCommon.c | 1031 +++ .../Library/Dxe/EfiIfrSupportLib/IfrLibrary.h | 1299 ++++ .../Dxe/EfiIfrSupportLib/IfrOnTheFly.c | 974 +++ .../Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c | 615 ++ .../Dxe/EfiIfrSupportLib/IfrVariable.c | 488 ++ .../Library/Dxe/EfiScriptLib/EfiScriptLib.c | 597 ++ .../Library/Dxe/EfiScriptLib/EfiScriptLib.inf | 46 + .../Library/Dxe/EfiUiLib/EfiUiLib.c | 492 ++ .../Library/Dxe/EfiUiLib/EfiUiLib.inf | 43 + .../Library/Dxe/Graphics/Ascii/PrintWidth.h | 88 + .../Library/Dxe/Graphics/Ascii/Sprint.c | 144 + .../Library/Dxe/Graphics/Graphics.c | 619 ++ .../Library/Dxe/Graphics/Graphics.inf | 50 + .../Foundation/Library/Dxe/Graphics/Print.c | 889 +++ .../Foundation/Library/Dxe/Graphics/Print.h | 37 + .../Library/Dxe/Graphics/Unicode/PrintWidth.h | 34 + .../Library/Dxe/Graphics/Unicode/Sprint.c | 144 + .../Dxe/GraphicsLite/Ascii/PrintWidth.h | 88 + .../Library/Dxe/GraphicsLite/Ascii/Sprint.c | 144 + .../Library/Dxe/GraphicsLite/Graphics.c | 618 ++ .../Library/Dxe/GraphicsLite/Graphics.inf | 50 + .../Library/Dxe/GraphicsLite/Print.c | 436 ++ .../Library/Dxe/GraphicsLite/Print.h | 37 + .../Dxe/GraphicsLite/Unicode/PrintWidth.h | 35 + .../Library/Dxe/GraphicsLite/Unicode/Sprint.c | 144 + .../Foundation/Library/Dxe/Hob/HobLib.inf | 46 + .../Foundation/Library/Dxe/Hob/hob.c | 521 ++ .../Library/Dxe/Include/Ebc/ProcDep.h | 26 + .../Library/Dxe/Include/EfiCombinationLib.h | 294 + .../Library/Dxe/Include/EfiCommonLib.h | 1359 ++++ .../Library/Dxe/Include/EfiDriverLib.h | 1203 ++++ .../Library/Dxe/Include/EfiHobLib.h | 298 + .../Dxe/Include/EfiMgmtModeRuntimeLib.h | 429 ++ .../Library/Dxe/Include/EfiPrintLib.h | 326 + .../Library/Dxe/Include/EfiRegTableLib.h | 205 + .../Library/Dxe/Include/EfiRuntimeLib.h | 1693 +++++ .../Library/Dxe/Include/EfiScriptLib.h | 517 ++ .../Library/Dxe/Include/EfiSmmDriverLib.h | 220 + .../Foundation/Library/Dxe/Include/EfiUiLib.h | 205 + .../Library/Dxe/Include/EfiWinNtLib.h | 75 + .../Foundation/Library/Dxe/Include/GetImage.h | 104 + .../Library/Dxe/Include/GraphicsLib.h | 250 + .../Library/Dxe/Include/Ia32/CpuFuncs.h | 260 + .../Library/Dxe/Include/Ia32/ProcDep.h | 26 + .../Dxe/Include/Ia32EfiRuntimeDriverLib.h | 111 + .../Library/Dxe/Include/Ipf/CpuFuncs.h | 93 + .../Library/Dxe/Include/Ipf/EsalRuntimeLib.h | 1305 ++++ .../Library/Dxe/Include/Ipf/ProcDep.h | 119 + .../Library/Dxe/Include/Ipf/SalDriverLib.h | 1454 ++++ .../Library/Dxe/Include/LinkedList.h | 310 + .../Library/Dxe/Include/RtDevicePath.h | 231 + .../Library/Dxe/Include/SmmRuntimeLib.h | 75 + .../Library/Dxe/Include/x64/CpuFuncs.h | 262 + .../Library/Dxe/Include/x64/ProcDep.h | 29 + .../Library/Dxe/Print/Ascii/PrintWidth.h | 88 + .../Library/Dxe/Print/Ascii/Sprint.c | 144 + .../Foundation/Library/Dxe/Print/BoxDraw.c | 212 + .../Foundation/Library/Dxe/Print/Print.c | 585 ++ .../Foundation/Library/Dxe/Print/Print.h | 37 + .../Foundation/Library/Dxe/Print/PrintLib.inf | 49 + .../Foundation/Library/Dxe/Print/StdErr.c | 284 + .../Library/Dxe/Print/Unicode/PrintWidth.h | 35 + .../Library/Dxe/Print/Unicode/Sprint.c | 144 + .../Library/Dxe/PrintLite/Ascii/PrintWidth.h | 88 + .../Library/Dxe/PrintLite/Ascii/Sprint.c | 142 + .../Library/Dxe/PrintLite/BoxDraw.c | 212 + .../Foundation/Library/Dxe/PrintLite/Print.c | 153 + .../Foundation/Library/Dxe/PrintLite/Print.h | 37 + .../Library/Dxe/PrintLite/PrintLib.inf | 50 + .../Foundation/Library/Dxe/PrintLite/StdErr.c | 284 + .../Dxe/PrintLite/Unicode/PrintWidth.h | 35 + .../Library/Dxe/PrintLite/Unicode/Sprint.c | 144 + .../EdkIIGlueDxeDriverEntryPoint.c | 556 ++ .../EntryPoints/EdkIIGluePeimEntryPoint.c | 183 + .../EdkIIGlueSmmDriverEntryPoint.c | 480 ++ .../Library/EdkIIGlueLib/Include/AutoGen.h | 50 + .../Include/Common/EdkIIGlueBaseTypes.h | 90 + .../Common/EdkIIGlueDefinitionChangesBase.h | 113 + .../Common/EdkIIGlueDefinitionChangesDxe.h | 87 + .../Common/EdkIIGlueDefinitionChangesPeim.h | 158 + .../Include/Common/EdkIIGlueDependencies.h | 777 +++ .../Library/EdkIIGlueLib/Include/DxeDepex.h | 34 + .../Include/Ebc/EdkIIGlueProcessorBind.h | 41 + .../EdkIIGlueLib/Include/EdkIIGlueBase.h | 93 + .../EdkIIGlueLib/Include/EdkIIGlueConfig.h | 144 + .../EdkIIGlueLib/Include/EdkIIGlueDxe.h | 251 + .../EdkIIGlueLib/Include/EdkIIGluePeim.h | 113 + .../EdkIIGlueLib/Include/EdkIIGlueUefi.h | 174 + .../Include/Ia32/EdkIIGlueProcessorBind.h | 41 + .../Include/Ipf/EdkIIGlueProcessorBind.h | 41 + .../Include/Library/EdkIIGlueBaseLib.h | 5842 +++++++++++++++++ .../Include/Library/EdkIIGlueBaseMemoryLib.h | 391 ++ .../Library/EdkIIGlueCacheMaintenanceLib.h | 224 + .../Include/Library/EdkIIGlueDebugLib.h | 571 ++ .../Include/Library/EdkIIGlueDevicePathLib.h | 269 + .../Library/EdkIIGlueDxeRuntimeDriverLib.h | 454 ++ .../Library/EdkIIGlueDxeServicesTableLib.h | 32 + .../Library/EdkIIGlueDxeSmmDriverEntryPoint.h | 147 + .../Include/Library/EdkIIGlueEdkDxeSalLib.h | 144 + .../Include/Library/EdkIIGlueHiiLib.h | 54 + .../Include/Library/EdkIIGlueHobLib.h | 384 ++ .../Include/Library/EdkIIGlueIoLib.h | 2563 ++++++++ .../Library/EdkIIGlueMemoryAllocationLib.h | 637 ++ .../Include/Library/EdkIIGluePciCf8Lib.h | 1055 +++ .../Include/Library/EdkIIGluePciExpressLib.h | 1023 +++ .../Include/Library/EdkIIGluePciLib.h | 1019 +++ .../Library/EdkIIGluePeCoffGetEntryPointLib.h | 93 + .../Include/Library/EdkIIGluePeCoffLib.h | 226 + .../Include/Library/EdkIIGluePeiServicesLib.h | 306 + .../EdkIIGluePeiServicesTablePointerLib.h | 42 + .../Include/Library/EdkIIGluePeimEntryPoint.h | 111 + .../Include/Library/EdkIIGluePostCodeLib.h | 165 + .../Include/Library/EdkIIGluePrintLib.h | 481 ++ .../Library/EdkIIGlueReportStatusCodeLib.h | 659 ++ .../Library/EdkIIGlueResourcePublicationLib.h | 50 + .../Include/Library/EdkIIGlueSmbusLib.h | 394 ++ .../Include/Library/EdkIIGlueTimerLib.h | 106 + .../EdkIIGlueUefiBootServicesTableLib.h | 41 + .../Library/EdkIIGlueUefiDecompressLib.h | 113 + .../Library/EdkIIGlueUefiDriverEntryPoint.h | 162 + .../Library/EdkIIGlueUefiDriverModelLib.h | 53 + .../Include/Library/EdkIIGlueUefiLib.h | 722 ++ .../EdkIIGlueUefiRuntimeServicesTableLib.h | 31 + .../EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h | 42 + .../Include/Pcd/EdkIIGluePcdBaseLib.h | 52 + .../Include/Pcd/EdkIIGluePcdDebugLib.h | 50 + .../Include/Pcd/EdkIIGluePcdIoLib.h | 42 + .../Include/Pcd/EdkIIGluePcdPciExpressLib.h | 40 + .../Include/Pcd/EdkIIGluePcdPostCodeLib.h | 40 + .../Pcd/EdkIIGluePcdReportStatusCodeLib.h | 40 + .../Include/Pcd/EdkIIGluePcdTimerLib.h | 40 + .../Library/EdkIIGlueLib/Include/PeimDepex.h | 34 + .../Include/x64/EdkIIGlueProcessorBind.h | 41 + .../BaseCacheMaintenanceLib.inf | 81 + .../BaseCacheMaintenanceLib/EbcCache.c | 241 + .../BaseCacheMaintenanceLib/IpfCache.c | 245 + .../BaseCacheMaintenanceLib/x86Cache.c | 262 + .../BaseDebugLibNull/BaseDebugLibNull.inf | 79 + .../Library/BaseDebugLibNull/DebugLib.c | 193 + .../BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf | 85 + .../Library/BaseIoLibIntrinsic/IoHighLevel.c | 2280 +++++++ .../Library/BaseIoLibIntrinsic/IoLib.c | 74 + .../Library/BaseIoLibIntrinsic/IoLibIpf.c | 490 ++ .../Library/BaseIoLibIntrinsic/IoLibMsc.c | 436 ++ .../EdkIIGlueLib/Library/BaseLib/ARShiftU64.c | 49 + .../EdkIIGlueLib/Library/BaseLib/BaseLib.inf | 361 + .../Library/BaseLib/BaseLibInternal.h | 813 +++ .../EdkIIGlueLib/Library/BaseLib/BitField.c | 873 +++ .../EdkIIGlueLib/Library/BaseLib/Cpu.c | 75 + .../Library/BaseLib/CpuDeadLoop.c | 42 + .../Library/BaseLib/DivS64x64Remainder.c | 54 + .../EdkIIGlueLib/Library/BaseLib/DivU64x32.c | 50 + .../Library/BaseLib/DivU64x32Remainder.c | 54 + .../Library/BaseLib/DivU64x64Remainder.c | 53 + .../Library/BaseLib/Ebc/CpuBreakpoint.c | 173 + .../Library/BaseLib/Ebc/SetJumpLongJump.c | 85 + .../Library/BaseLib/Ebc/SwitchStack.c | 59 + .../Library/BaseLib/Ebc/Synchronization.c | 106 + .../Library/BaseLib/GetPowerOfTwo32.c | 48 + .../Library/BaseLib/GetPowerOfTwo64.c | 49 + .../Library/BaseLib/HighBitSet32.c | 52 + .../Library/BaseLib/HighBitSet64.c | 60 + .../Library/BaseLib/Ia32/ARShiftU64.asm | 44 + .../Library/BaseLib/Ia32/CpuBreakpoint.asm | 39 + .../Library/BaseLib/Ia32/CpuFlushTlb.asm | 39 + .../Library/BaseLib/Ia32/CpuId.asm | 64 + .../Library/BaseLib/Ia32/CpuIdEx.asm | 66 + .../Library/BaseLib/Ia32/CpuPause.asm | 39 + .../Library/BaseLib/Ia32/CpuSleep.asm | 38 + .../BaseLib/Ia32/DisableInterrupts.asm | 38 + .../Library/BaseLib/Ia32/DisablePaging32.asm | 55 + .../Library/BaseLib/Ia32/DivS64x64Remainder.c | 60 + .../Library/BaseLib/Ia32/DivU64x32.asm | 44 + .../BaseLib/Ia32/DivU64x32Remainder.asm | 49 + .../BaseLib/Ia32/DivU64x64Remainder.asm | 90 + .../BaseLib/Ia32/EnableDisableInterrupts.asm | 39 + .../Library/BaseLib/Ia32/EnableInterrupts.asm | 38 + .../Library/BaseLib/Ia32/EnablePaging32.asm | 55 + .../Library/BaseLib/Ia32/EnablePaging64.asm | 66 + .../Library/BaseLib/Ia32/FlushCacheLine.asm | 40 + .../Library/BaseLib/Ia32/FxRestore.asm | 40 + .../Library/BaseLib/Ia32/FxSave.asm | 40 + .../Ia32/InterlockedCompareExchange32.asm | 43 + .../Ia32/InterlockedCompareExchange64.asm | 45 + .../BaseLib/Ia32/InterlockedDecrement.asm | 40 + .../BaseLib/Ia32/InterlockedIncrement.asm | 40 + .../BaseLib/Ia32/InternalSwitchStack.c | 60 + .../Library/BaseLib/Ia32/Invd.asm | 38 + .../Library/BaseLib/Ia32/LRotU64.asm | 47 + .../Library/BaseLib/Ia32/LShiftU64.asm | 44 + .../Library/BaseLib/Ia32/LongJump.asm | 44 + .../Library/BaseLib/Ia32/ModU64x32.asm | 43 + .../Library/BaseLib/Ia32/Monitor.asm | 43 + .../Library/BaseLib/Ia32/MultU64x32.asm | 41 + .../Library/BaseLib/Ia32/MultU64x64.asm | 45 + .../Library/BaseLib/Ia32/Mwait.asm | 41 + .../Library/BaseLib/Ia32/Non-existing.c | 66 + .../Library/BaseLib/Ia32/RRotU64.asm | 47 + .../Library/BaseLib/Ia32/RShiftU64.asm | 44 + .../Library/BaseLib/Ia32/ReadCr0.asm | 38 + .../Library/BaseLib/Ia32/ReadCr2.asm | 38 + .../Library/BaseLib/Ia32/ReadCr3.asm | 38 + .../Library/BaseLib/Ia32/ReadCr4.asm | 38 + .../Library/BaseLib/Ia32/ReadCs.asm | 38 + .../Library/BaseLib/Ia32/ReadDr0.asm | 38 + .../Library/BaseLib/Ia32/ReadDr1.asm | 38 + .../Library/BaseLib/Ia32/ReadDr2.asm | 38 + .../Library/BaseLib/Ia32/ReadDr3.asm | 38 + .../Library/BaseLib/Ia32/ReadDr4.asm | 45 + .../Library/BaseLib/Ia32/ReadDr5.asm | 45 + .../Library/BaseLib/Ia32/ReadDr6.asm | 38 + .../Library/BaseLib/Ia32/ReadDr7.asm | 38 + .../Library/BaseLib/Ia32/ReadDs.asm | 38 + .../Library/BaseLib/Ia32/ReadEflags.asm | 39 + .../Library/BaseLib/Ia32/ReadEs.asm | 38 + .../Library/BaseLib/Ia32/ReadFs.asm | 38 + .../Library/BaseLib/Ia32/ReadGdtr.asm | 39 + .../Library/BaseLib/Ia32/ReadGs.asm | 38 + .../Library/BaseLib/Ia32/ReadIdtr.asm | 39 + .../Library/BaseLib/Ia32/ReadLdtr.asm | 38 + .../Library/BaseLib/Ia32/ReadMm0.asm | 43 + .../Library/BaseLib/Ia32/ReadMm1.asm | 43 + .../Library/BaseLib/Ia32/ReadMm2.asm | 43 + .../Library/BaseLib/Ia32/ReadMm3.asm | 43 + .../Library/BaseLib/Ia32/ReadMm4.asm | 43 + .../Library/BaseLib/Ia32/ReadMm5.asm | 43 + .../Library/BaseLib/Ia32/ReadMm6.asm | 43 + .../Library/BaseLib/Ia32/ReadMm7.asm | 43 + .../Library/BaseLib/Ia32/ReadMsr64.asm | 39 + .../Library/BaseLib/Ia32/ReadPmc.asm | 39 + .../Library/BaseLib/Ia32/ReadSs.asm | 38 + .../Library/BaseLib/Ia32/ReadTr.asm | 38 + .../Library/BaseLib/Ia32/ReadTsc.asm | 38 + .../Library/BaseLib/Ia32/SetJump.asm | 49 + .../Library/BaseLib/Ia32/SwapBytes64.asm | 41 + .../Library/BaseLib/Ia32/Thunk16.asm | 250 + .../Library/BaseLib/Ia32/Wbinvd.asm | 38 + .../Library/BaseLib/Ia32/WriteCr0.asm | 39 + .../Library/BaseLib/Ia32/WriteCr2.asm | 39 + .../Library/BaseLib/Ia32/WriteCr3.asm | 39 + .../Library/BaseLib/Ia32/WriteCr4.asm | 39 + .../Library/BaseLib/Ia32/WriteDr0.asm | 39 + .../Library/BaseLib/Ia32/WriteDr1.asm | 39 + .../Library/BaseLib/Ia32/WriteDr2.asm | 39 + .../Library/BaseLib/Ia32/WriteDr3.asm | 39 + .../Library/BaseLib/Ia32/WriteDr4.asm | 46 + .../Library/BaseLib/Ia32/WriteDr5.asm | 46 + .../Library/BaseLib/Ia32/WriteDr6.asm | 39 + .../Library/BaseLib/Ia32/WriteDr7.asm | 39 + .../Library/BaseLib/Ia32/WriteGdtr.asm | 39 + .../Library/BaseLib/Ia32/WriteIdtr.asm | 39 + .../Library/BaseLib/Ia32/WriteLdtr.asm | 39 + .../Library/BaseLib/Ia32/WriteMm0.asm | 39 + .../Library/BaseLib/Ia32/WriteMm1.asm | 39 + .../Library/BaseLib/Ia32/WriteMm2.asm | 39 + .../Library/BaseLib/Ia32/WriteMm3.asm | 39 + .../Library/BaseLib/Ia32/WriteMm4.asm | 39 + .../Library/BaseLib/Ia32/WriteMm5.asm | 39 + .../Library/BaseLib/Ia32/WriteMm6.asm | 39 + .../Library/BaseLib/Ia32/WriteMm7.asm | 39 + .../Library/BaseLib/Ia32/WriteMsr64.asm | 42 + .../Library/BaseLib/Ipf/CpuBreakpoint.c | 126 + .../Library/BaseLib/Ipf/CpuFlushTlb.s | 59 + .../Library/BaseLib/Ipf/CpuPause.s | 26 + .../Library/BaseLib/Ipf/FlushCacheRange.s | 94 + .../Library/BaseLib/Ipf/GetInterruptState.s | 27 + .../Ipf/InterlockedCompareExchange32.s | 29 + .../Ipf/InterlockedCompareExchange64.s | 28 + .../Library/BaseLib/Ipf/Non-existing.c | 58 + .../Library/BaseLib/Ipf/PalCallStatic.s | 48 + .../Library/BaseLib/Ipf/ReadItc.s | 26 + .../Library/BaseLib/Ipf/SwitchStack.s | 51 + .../Library/BaseLib/Ipf/Synchronization.c | 83 + .../Library/BaseLib/Ipf/Unaligned.c | 249 + .../EdkIIGlueLib/Library/BaseLib/Ipf/asm.h | 33 + .../Library/BaseLib/Ipf/ia_64gen.h | 211 + .../Library/BaseLib/Ipf/longjmp.s | 122 + .../EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s | 109 + .../EdkIIGlueLib/Library/BaseLib/LRotU32.c | 50 + .../EdkIIGlueLib/Library/BaseLib/LRotU64.c | 50 + .../EdkIIGlueLib/Library/BaseLib/LShiftU64.c | 49 + .../EdkIIGlueLib/Library/BaseLib/LinkedList.c | 471 ++ .../EdkIIGlueLib/Library/BaseLib/LongJump.c | 51 + .../Library/BaseLib/LowBitSet32.c | 52 + .../Library/BaseLib/LowBitSet64.c | 54 + .../EdkIIGlueLib/Library/BaseLib/Math64.c | 377 ++ .../EdkIIGlueLib/Library/BaseLib/ModU64x32.c | 50 + .../EdkIIGlueLib/Library/BaseLib/MultS64x64.c | 49 + .../EdkIIGlueLib/Library/BaseLib/MultU64x32.c | 51 + .../EdkIIGlueLib/Library/BaseLib/MultU64x64.c | 51 + .../EdkIIGlueLib/Library/BaseLib/RRotU32.c | 50 + .../EdkIIGlueLib/Library/BaseLib/RRotU64.c | 50 + .../EdkIIGlueLib/Library/BaseLib/RShiftU64.c | 49 + .../EdkIIGlueLib/Library/BaseLib/SetJump.c | 46 + .../EdkIIGlueLib/Library/BaseLib/String.c | 2077 ++++++ .../Library/BaseLib/SwapBytes16.c | 44 + .../Library/BaseLib/SwapBytes32.c | 50 + .../Library/BaseLib/SwapBytes64.c | 44 + .../Library/BaseLib/SwitchStack.c | 62 + .../Library/BaseLib/Synchronization.c | 364 + .../EdkIIGlueLib/Library/BaseLib/Unaligned.c | 228 + .../Library/BaseLib/X64/CpuBreakpoint.asm | 36 + .../Library/BaseLib/X64/CpuFlushTlb.asm | 37 + .../Library/BaseLib/X64/CpuId.asm | 60 + .../Library/BaseLib/X64/CpuIdEx.asm | 62 + .../Library/BaseLib/X64/CpuPause.asm | 36 + .../Library/BaseLib/X64/CpuSleep.asm | 36 + .../Library/BaseLib/X64/DisableInterrupts.asm | 36 + .../Library/BaseLib/X64/DisablePaging64.asm | 63 + .../BaseLib/X64/EnableDisableInterrupts.asm | 37 + .../Library/BaseLib/X64/EnableInterrupts.asm | 36 + .../Library/BaseLib/X64/EnablePaging64.asm | 62 + .../Library/BaseLib/X64/FlushCacheLine.asm | 37 + .../Library/BaseLib/X64/FxRestore.asm | 36 + .../Library/BaseLib/X64/FxSave.asm | 36 + .../X64/InterlockedCompareExchange32.asm | 39 + .../X64/InterlockedCompareExchange64.asm | 39 + .../BaseLib/X64/InterlockedDecrement.asm | 37 + .../BaseLib/X64/InterlockedIncrement.asm | 37 + .../EdkIIGlueLib/Library/BaseLib/X64/Invd.asm | 36 + .../Library/BaseLib/X64/LongJump.asm | 44 + .../Library/BaseLib/X64/Monitor.asm | 41 + .../Library/BaseLib/X64/Mwait.asm | 39 + .../Library/BaseLib/X64/Non-existing.c | 116 + .../Library/BaseLib/X64/ReadCr0.asm | 36 + .../Library/BaseLib/X64/ReadCr2.asm | 36 + .../Library/BaseLib/X64/ReadCr3.asm | 36 + .../Library/BaseLib/X64/ReadCr4.asm | 36 + .../Library/BaseLib/X64/ReadCs.asm | 36 + .../Library/BaseLib/X64/ReadDr0.asm | 36 + .../Library/BaseLib/X64/ReadDr1.asm | 36 + .../Library/BaseLib/X64/ReadDr2.asm | 36 + .../Library/BaseLib/X64/ReadDr3.asm | 36 + .../Library/BaseLib/X64/ReadDr4.asm | 40 + .../Library/BaseLib/X64/ReadDr5.asm | 40 + .../Library/BaseLib/X64/ReadDr6.asm | 36 + .../Library/BaseLib/X64/ReadDr7.asm | 36 + .../Library/BaseLib/X64/ReadDs.asm | 36 + .../Library/BaseLib/X64/ReadEflags.asm | 37 + .../Library/BaseLib/X64/ReadEs.asm | 36 + .../Library/BaseLib/X64/ReadFs.asm | 36 + .../Library/BaseLib/X64/ReadGdtr.asm | 36 + .../Library/BaseLib/X64/ReadGs.asm | 36 + .../Library/BaseLib/X64/ReadIdtr.asm | 36 + .../Library/BaseLib/X64/ReadLdtr.asm | 36 + .../Library/BaseLib/X64/ReadMm0.asm | 39 + .../Library/BaseLib/X64/ReadMm1.asm | 39 + .../Library/BaseLib/X64/ReadMm2.asm | 39 + .../Library/BaseLib/X64/ReadMm3.asm | 39 + .../Library/BaseLib/X64/ReadMm4.asm | 39 + .../Library/BaseLib/X64/ReadMm5.asm | 39 + .../Library/BaseLib/X64/ReadMm6.asm | 39 + .../Library/BaseLib/X64/ReadMm7.asm | 39 + .../Library/BaseLib/X64/ReadMsr64.asm | 38 + .../Library/BaseLib/X64/ReadPmc.asm | 38 + .../Library/BaseLib/X64/ReadSs.asm | 36 + .../Library/BaseLib/X64/ReadTr.asm | 36 + .../Library/BaseLib/X64/ReadTsc.asm | 38 + .../Library/BaseLib/X64/SetJump.asm | 52 + .../Library/BaseLib/X64/SwitchStack.asm | 45 + .../Library/BaseLib/X64/Thunk16.asm | 285 + .../Library/BaseLib/X64/Wbinvd.asm | 36 + .../Library/BaseLib/X64/WriteCr0.asm | 37 + .../Library/BaseLib/X64/WriteCr2.asm | 37 + .../Library/BaseLib/X64/WriteCr3.asm | 37 + .../Library/BaseLib/X64/WriteCr4.asm | 37 + .../Library/BaseLib/X64/WriteDr0.asm | 37 + .../Library/BaseLib/X64/WriteDr1.asm | 37 + .../Library/BaseLib/X64/WriteDr2.asm | 37 + .../Library/BaseLib/X64/WriteDr3.asm | 37 + .../Library/BaseLib/X64/WriteDr4.asm | 41 + .../Library/BaseLib/X64/WriteDr5.asm | 41 + .../Library/BaseLib/X64/WriteDr6.asm | 37 + .../Library/BaseLib/X64/WriteDr7.asm | 37 + .../Library/BaseLib/X64/WriteGdtr.asm | 36 + .../Library/BaseLib/X64/WriteIdtr.asm | 36 + .../Library/BaseLib/X64/WriteLdtr.asm | 36 + .../Library/BaseLib/X64/WriteMm0.asm | 39 + .../Library/BaseLib/X64/WriteMm1.asm | 39 + .../Library/BaseLib/X64/WriteMm2.asm | 39 + .../Library/BaseLib/X64/WriteMm3.asm | 39 + .../Library/BaseLib/X64/WriteMm4.asm | 39 + .../Library/BaseLib/X64/WriteMm5.asm | 39 + .../Library/BaseLib/X64/WriteMm6.asm | 39 + .../Library/BaseLib/X64/WriteMm7.asm | 39 + .../Library/BaseLib/X64/WriteMsr64.asm | 39 + .../Library/BaseLib/x86DisablePaging32.c | 71 + .../Library/BaseLib/x86DisablePaging64.c | 68 + .../Library/BaseLib/x86EnablePaging32.c | 74 + .../Library/BaseLib/x86EnablePaging64.c | 70 + .../Library/BaseLib/x86FxRestore.c | 54 + .../EdkIIGlueLib/Library/BaseLib/x86FxSave.c | 53 + .../Library/BaseLib/x86GetInterruptState.c | 47 + .../Library/BaseLib/x86MemoryFence.c | 39 + .../EdkIIGlueLib/Library/BaseLib/x86Msr.c | 657 ++ .../Library/BaseLib/x86ReadGdtr.c | 44 + .../Library/BaseLib/x86ReadIdtr.c | 44 + .../EdkIIGlueLib/Library/BaseLib/x86Thunk.c | 250 + .../Library/BaseLib/x86WriteGdtr.c | 44 + .../Library/BaseLib/x86WriteIdtr.c | 44 + .../Library/BaseMemoryLib/BaseMemoryLib.inf | 91 + .../BaseMemoryLib/BaseMemoryLibInternal.h | 227 + .../Library/BaseMemoryLib/CompareMemWrapper.c | 63 + .../Library/BaseMemoryLib/CopyMem.c | 65 + .../Library/BaseMemoryLib/CopyMemWrapper.c | 58 + .../Library/BaseMemoryLib/MemLibGeneric.c | 261 + .../Library/BaseMemoryLib/MemLibGuid.c | 135 + .../Library/BaseMemoryLib/ScanMem16Wrapper.c | 63 + .../Library/BaseMemoryLib/ScanMem32Wrapper.c | 63 + .../Library/BaseMemoryLib/ScanMem64Wrapper.c | 62 + .../Library/BaseMemoryLib/ScanMem8Wrapper.c | 57 + .../Library/BaseMemoryLib/SetMem.c | 55 + .../Library/BaseMemoryLib/SetMem16Wrapper.c | 61 + .../Library/BaseMemoryLib/SetMem32Wrapper.c | 61 + .../Library/BaseMemoryLib/SetMem64Wrapper.c | 62 + .../Library/BaseMemoryLib/SetMemWrapper.c | 52 + .../Library/BaseMemoryLib/ZeroMemWrapper.c | 47 + .../Library/BasePciCf8Lib/BasePciCf8Lib.inf | 84 + .../Library/BasePciCf8Lib/PciLib.c | 1468 +++++ .../BasePciExpressLib/BasePciExpressLib.inf | 83 + .../Library/BasePciExpressLib/PciLib.c | 1373 ++++ .../Library/BasePciLibCf8/BasePciLibCf8.inf | 81 + .../Library/BasePciLibCf8/PciLib.c | 1076 +++ .../BasePciLibPciExpress.inf | 81 + .../Library/BasePciLibPciExpress/PciLib.c | 1076 +++ .../BasePeCoffGetEntryPointLib.inf | 83 + .../PeCoffGetEntryPoint.c | 222 + .../Library/BasePeCoffLib/BasePeCoff.c | 1336 ++++ .../Library/BasePeCoffLib/BasePeCoffLib.inf | 83 + .../BasePeCoffLib/BasePeCoffLibInternals.h | 131 + .../BasePeCoffLib/Ebc/PeCoffLoaderEx.c | 98 + .../BasePeCoffLib/Ia32/PeCoffLoaderEx.c | 98 + .../BasePeCoffLib/Ipf/PeCoffLoaderEx.c | 430 ++ .../BasePeCoffLib/x64/PeCoffLoaderEx.c | 99 + .../BasePostCodeLibDebug.inf | 81 + .../Library/BasePostCodeLibDebug/PostCode.c | 131 + .../BasePostCodeLibPort80.inf | 84 + .../Library/BasePostCodeLibPort80/PostCode.c | 131 + .../Library/BasePrintLib/BasePrintLib.inf | 82 + .../Library/BasePrintLib/PrintLib.c | 1086 +++ .../Library/BasePrintLib/PrintLibInternal.c | 215 + .../Library/BasePrintLib/PrintLibInternal.h | 209 + .../BaseTimerLibLocalApic.inf | 84 + .../BaseTimerLibLocalApic/Ebc/EbcTimerLib.c | 135 + .../BaseTimerLibLocalApic/Ipf/IpfTimerLib.c | 178 + .../BaseTimerLibLocalApic/x86TimerLib.c | 258 + .../BaseUefiDecompressLib.c | 801 +++ .../BaseUefiDecompressLib.inf | 78 + .../BaseUefiDecompressLibInternals.h | 222 + .../Library/DxeHobLib/DxeHobLib.inf | 84 + .../EdkIIGlueLib/Library/DxeHobLib/HobLib.c | 501 ++ .../DxeIoLibCpuIo/DxeCpuIoLibInternal.h | 115 + .../Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf | 80 + .../Library/DxeIoLibCpuIo/IoHighLevel.c | 2271 +++++++ .../Library/DxeIoLibCpuIo/IoLib.c | 600 ++ .../DxeMemoryAllocationLib.inf | 81 + .../MemoryAllocationLib.c | 1079 +++ .../DxeReportStatusCodeLib.inf | 97 + .../ReportStatusCodeLib.c | 605 ++ .../DxeServicesTableLib/DxeServicesTableLib.c | 61 + .../DxeServicesTableLib.inf | 79 + .../Library/DxeSmbusLib/DxeSmbusLib.c | 107 + .../Library/DxeSmbusLib/DxeSmbusLib.inf | 82 + .../Library/DxeSmbusLib/DxeSmbusLibInternal.h | 67 + .../Library/DxeSmbusLib/SmbusLib.c | 475 ++ .../Common/RuntimeLib.c | 181 + .../Common/RuntimeService.c | 471 ++ .../EdkDxeRuntimeDriverLib.inf | 96 + .../EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c | 235 + .../Ipf/RuntimeService.c | 527 ++ .../RuntimeLibInternal.h | 30 + .../Library/EdkDxeSalLib/EdkDxeSalLib.inf | 83 + .../EdkDxeSalLib/Ipf/AsmEsalServiceLib.s | 149 + .../Library/EdkDxeSalLib/Ipf/EsalServiceLib.c | 288 + .../EdkIIGlueLib/Library/HiiLib/HiiLib.c | 70 + .../EdkIIGlueLib/Library/HiiLib/HiiLib.inf | 79 + .../PeiDxeDebugLibReportStatusCode/DebugLib.c | 296 + .../PeiDxeDebugLibReportStatusCode.inf | 89 + .../PeiDxePostCodeLibReportStatusCode.inf | 83 + .../PostCode.c | 160 + .../EdkIIGlueLib/Library/PeiHobLib/HobLib.c | 573 ++ .../Library/PeiHobLib/PeiHobLib.inf | 83 + .../MemoryAllocationLib.c | 1080 +++ .../PeiMemoryAllocationLib.inf | 87 + .../PeiReportStatusCodeLib.inf | 108 + .../ReportStatusCodeLib.c | 527 ++ .../PeiResourcePublicationLib.c | 57 + .../PeiResourcePublicationLib.inf | 81 + .../Library/PeiServicesLib/PeiServicesLib.c | 393 ++ .../Library/PeiServicesLib/PeiServicesLib.inf | 86 + .../PeiServicesTablePointer.c | 67 + .../PeiServicesTablePointerLib.inf | 79 + .../Ipf/ReadKr1.s | 44 + .../Ipf/WriteKr1.s | 45 + .../PeiServicesTablePointer.c | 68 + .../PeiServicesTablePointerLibInternals.h | 52 + .../PeiServicesTablePointerLibKr1.inf | 74 + .../PeiServicesTablePointer.c | 68 + .../PeiServicesTablePointerLibMm7.inf | 79 + .../Library/PeiSmbusLib/PeiSmbusLib.c | 104 + .../Library/PeiSmbusLib/PeiSmbusLib.inf | 86 + .../Library/PeiSmbusLib/PeiSmbusLibInternal.h | 84 + .../Library/PeiSmbusLib/SmbusLib.c | 475 ++ .../UefiBootServicesTableLib.c | 68 + .../UefiBootServicesTableLib.inf | 77 + .../UefiDevicePathLib/UefiDevicePathLib.c | 533 ++ .../UefiDevicePathLib/UefiDevicePathLib.inf | 84 + .../UefiDriverModelLib/UefiDriverModelLib.c | 355 + .../UefiDriverModelLib/UefiDriverModelLib.inf | 67 + .../EdkIIGlueLib/Library/UefiLib/Console.c | 288 + .../EdkIIGlueLib/Library/UefiLib/UefiLib.c | 813 +++ .../EdkIIGlueLib/Library/UefiLib/UefiLib.inf | 89 + .../Library/UefiLib/UefiNotTiano.c | 382 ++ .../UefiRuntimeServicesTableLib.c | 53 + .../UefiRuntimeServicesTableLib.inf | 78 + .../Library/EfiCommonLib/EfiCommonLib.inf | 84 + .../Library/EfiCommonLib/EfiCompareGuid.c | 59 + .../Library/EfiCommonLib/EfiCompareMem.c | 76 + .../Library/EfiCommonLib/EfiCopyMem.c | 69 + .../Library/EfiCommonLib/EfiSetMem.c | 65 + .../Library/EfiCommonLib/EfiZeroMem.c | 57 + .../Library/EfiCommonLib/Ia32/DivU64x32.c | 75 + .../Library/EfiCommonLib/Ia32/EfiCopyMem.c | 184 + .../EfiCommonLib/Ia32/EfiCopyMemSSE2.c | 169 + .../Library/EfiCommonLib/Ia32/EfiSetMem.c | 139 + .../Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c | 141 + .../Library/EfiCommonLib/Ia32/EfiZeroMem.c | 122 + .../EfiCommonLib/Ia32/EfiZeroMemSSE2.c | 111 + .../Library/EfiCommonLib/Ia32/GetPowerOfTwo.c | 62 + .../Library/EfiCommonLib/Ia32/LShiftU64.c | 74 + .../Library/EfiCommonLib/Ia32/Log2.c | 74 + .../Library/EfiCommonLib/Ia32/MultU64x32.c | 64 + .../Library/EfiCommonLib/Ia32/Power10U64.c | 67 + .../Library/EfiCommonLib/Ia32/RShiftU64.c | 71 + .../Foundation/Library/EfiCommonLib/Math.c | 216 + .../Foundation/Library/EfiCommonLib/Misc.c | 384 ++ .../Library/EfiCommonLib/PostCode.c | 62 + .../Library/EfiCommonLib/ReportStatusCode.c | 338 + .../Foundation/Library/EfiCommonLib/String.c | 802 +++ .../Library/EfiCommonLib/ValueToString.c | 213 + .../Library/EfiCommonLib/linkedlist.c | 356 + .../Library/EfiCommonLib/x64/EfiCopyMem.asm | 74 + .../EfiCommonLib/x64/EfiCopyMemSSE2.asm | 80 + .../Library/EfiCommonLib/x64/EfiSetMem.asm | 60 + .../EfiCommonLib/x64/EfiSetMemSSE2.asm | 67 + .../Library/EfiCommonLib/x64/EfiZeroMem.asm | 53 + .../EfiCommonLib/x64/EfiZeroMemSSE2.asm | 60 + .../Foundation/Library/Pei/Hob/PeiHobLib.c | 603 ++ .../Foundation/Library/Pei/Hob/PeiHobLib.inf | 49 + .../Foundation/Library/Pei/Include/PeiLib.h | 1341 ++++ .../Library/Pei/Include/peihoblib.h | 345 + .../Foundation/Library/Pei/PeiLib/Debug.c | 131 + .../Library/Pei/PeiLib/Decompress.c | 1104 ++++ .../Foundation/Library/Pei/PeiLib/FindFv.c | 179 + .../Foundation/Library/Pei/PeiLib/Hob/Hob.c | 521 ++ .../Library/Pei/PeiLib/Ipf/HwAccess.s | 77 + .../Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c | 268 + .../Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h | 87 + .../Pei/PeiLib/Ipf/PeiServicePointer.c | 108 + .../Pei/PeiLib/Ipf/PerformancePrimitives.s | 61 + .../Library/Pei/PeiLib/Ipf/SwitchStack.s | 122 + .../Foundation/Library/Pei/PeiLib/Ipf/asm.h | 35 + .../Library/Pei/PeiLib/Ipf/efijump.h | 112 + .../Library/Pei/PeiLib/Ipf/ia_64gen.h | 214 + .../Foundation/Library/Pei/PeiLib/Ipf/math.c | 139 + .../Library/Pei/PeiLib/Ipf/pioflush.s | 106 + .../Library/Pei/PeiLib/Ipf/processor.c | 118 + .../Library/Pei/PeiLib/Ipf/setjmp.s | 325 + .../Library/Pei/PeiLib/PeCoffLoader.c | 1387 ++++ .../Foundation/Library/Pei/PeiLib/PeiLib.c | 648 ++ .../Foundation/Library/Pei/PeiLib/PeiLib.inf | 104 + .../Foundation/Library/Pei/PeiLib/Perf.c | 233 + .../Library/Pei/PeiLib/Print/Print.c | 795 +++ .../Library/Pei/PeiLib/Print/Print.h | 38 + .../Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c | 93 + .../Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h | 85 + .../Pei/PeiLib/ia32/PeiServicePointer.c | 152 + .../Pei/PeiLib/ia32/PerformancePrimitives.c | 47 + .../Library/Pei/PeiLib/ia32/Processor.c | 140 + .../Library/Pei/PeiLib/ia32/ProcessorAsms.Asm | 223 + .../Library/Pei/PeiLib/ia32/ReadIdt.asm | 60 + .../Pei/PeiLib/ia32/SupportItpDebug.asm | 69 + .../Library/Pei/PeiLib/ia32/WriteIdt.asm | 49 + .../Library/Pei/PeiLib/ia32/efijump.h | 34 + .../Library/Pei/PeiLib/x64/EfiJump.h | 40 + .../Library/Pei/PeiLib/x64/IdtDumb.c | 41 + .../Foundation/Library/Pei/PeiLib/x64/Math.c | 117 + .../Library/Pei/PeiLib/x64/PeCoffLoaderEx.c | 87 + .../Library/Pei/PeiLib/x64/PeCoffLoaderEx.h | 85 + .../Pei/PeiLib/x64/PeiServicePointer.c | 98 + .../Pei/PeiLib/x64/PerformancePrimitives.c | 34 + .../Library/Pei/PeiLib/x64/Processor.c | 149 + .../Library/Pei/PeiLib/x64/ProcessorAsms.Asm | 158 + .../Pei/PeiLib/x64/SupportItpDebug.asm | 76 + .../Library/RuntimeDxe/EfiRuntimeLib/Debug.c | 154 + .../RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c | 316 + .../EfiRuntimeLib/EfiRuntimeLib.inf | 79 + .../Library/RuntimeDxe/EfiRuntimeLib/Event.c | 353 + .../RuntimeDxe/EfiRuntimeLib/GetImage.c | 221 + .../Library/RuntimeDxe/EfiRuntimeLib/Io.c | 339 + .../RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s | 149 + .../RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c | 334 + .../EfiRuntimeLib/Ipf/IpfCpuCache.s | 88 + .../RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c | 170 + .../RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c | 1317 ++++ .../RuntimeDxe/EfiRuntimeLib/LibGlobals.c | 37 + .../RuntimeDxe/EfiRuntimeLib/RtDevicePath.c | 705 ++ .../RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c | 617 ++ .../RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c | 130 + .../RuntimeDxe/EfiRuntimeLib/ia32/Lock.c | 177 + .../EfiRuntimeLib/ia32/PlatformIoLib.c | 407 ++ .../EfiRuntimeLib/ia32/RuntimeLib.c | 842 +++ .../RuntimeDxe/EfiRuntimeLib/x64/Fvb.c | 620 ++ .../RuntimeDxe/EfiRuntimeLib/x64/IoLib.c | 130 + .../RuntimeDxe/EfiRuntimeLib/x64/Lock.c | 177 + .../EfiRuntimeLib/x64/PlatformIoLib.c | 409 ++ .../RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c | 843 +++ .../Foundation/Library/Thunk16/Ia32/Fx.asm | 51 + .../Library/Thunk16/Ia32/Thunk16.asm | 199 + .../Foundation/Library/Thunk16/Thunk16Lib.h | 348 + .../Foundation/Library/Thunk16/Thunk16Lib.inf | 49 + .../Foundation/Library/Thunk16/X64/Fx.asm | 46 + .../Library/Thunk16/X64/Thunk16.asm | 216 + .../Foundation/Library/Thunk16/x86Thunk.c | 320 + .../Ppi/BaseMemoryTest/BaseMemoryTest.c | 28 + .../Ppi/BaseMemoryTest/BaseMemoryTest.h | 58 + .../Foundation/Ppi/EdkPpiLib.inf | 51 + .../Foundation/Ppi/FlashMap/FlashMap.c | 28 + .../Foundation/Ppi/FlashMap/FlashMap.h | 59 + .../Ppi/OperatorPresence/OperatorPresence.c | 28 + .../Ppi/OperatorPresence/OperatorPresence.h | 34 + .../Foundation/Ppi/PeiInMemory/PeiInMemory.c | 33 + .../Foundation/Ppi/PeiInMemory/PeiInMemory.h | 29 + .../Ppi/StatusCodeMemory/StatusCodeMemory.c | 28 + .../Ppi/StatusCodeMemory/StatusCodeMemory.h | 53 + .../Protocol/ConsoleControl/ConsoleControl.c | 29 + .../Protocol/ConsoleControl/ConsoleControl.h | 122 + .../CustomizedDecompress.c | 28 + .../CustomizedDecompress.h | 139 + .../Protocol/DebugAssert/DebugAssert.c | 30 + .../Protocol/DebugAssert/DebugAssert.h | 89 + .../Foundation/Protocol/DebugMask/DebugMask.c | 30 + .../Foundation/Protocol/DebugMask/DebugMask.h | 68 + .../Protocol/DebugSerialIO/DebugSerialIo.c | 30 + .../Protocol/DebugSerialIO/DebugSerialIo.h | 37 + .../Foundation/Protocol/DiskInfo/DiskInfo.c | 30 + .../Foundation/Protocol/DiskInfo/DiskInfo.h | 174 + .../Foundation/Protocol/EdkProtocolLib.inf | 111 + .../Protocol/EfiOEMBadging/EfiOEMBadging.c | 30 + .../Protocol/EfiOEMBadging/EfiOEMBadging.h | 79 + .../ExtendedSalBootService.c | 27 + .../ExtendedSalBootService.h | 118 + .../ExtendedSalGuid/ExtendedSalGuid.c | 74 + .../ExtendedSalGuid/ExtendedSalGuid.h | 283 + .../FaultTolerantWriteLite.c | 29 + .../FaultTolerantWriteLite.h | 88 + .../FirmwareVolumeDispatch.c | 32 + .../FirmwareVolumeDispatch.h | 35 + .../Protocol/FvbExtension/FvbExtension.c | 29 + .../Protocol/FvbExtension/FvbExtension.h | 53 + .../GenericMemoryTest/GenericMemoryTest.c | 29 + .../GenericMemoryTest/GenericMemoryTest.h | 154 + .../GuidedSectionExtraction.c | 35 + .../GuidedSectionExtraction.h | 73 + .../Foundation/Protocol/IsaAcpi/IsaAcpi.c | 30 + .../Foundation/Protocol/IsaAcpi/IsaAcpi.h | 177 + .../Foundation/Protocol/IsaIo/IsaIo.c | 42 + .../Foundation/Protocol/IsaIo/IsaIo.h | 362 + .../LegacyBiosThunk/LegacyBiosThunk.c | 30 + .../LegacyBiosThunk/LegacyBiosThunk.h | 120 + .../Protocol/LoadPe32Image/LoadPe32Image.c | 27 + .../Protocol/LoadPe32Image/LoadPe32Image.h | 64 + .../Protocol/NicIp4Config/NicIp4Config.c | 37 + .../Protocol/NicIp4Config/NicIp4Config.h | 118 + .../PciHotPlugRequest/PciHotPlugRequest.c | 27 + .../PciHotPlugRequest/PciHotPlugRequest.h | 55 + .../Protocol/Performance/Performance.c | 27 + .../Protocol/Performance/Performance.h | 103 + .../PlatformMemTest/PlatformMemTest.c | 30 + .../PlatformMemTest/PlatformMemTest.h | 258 + .../Foundation/Protocol/Print/Print.c | 29 + .../Foundation/Protocol/Print/Print.h | 51 + .../Foundation/Protocol/Ps2Policy/Ps2Policy.c | 28 + .../Foundation/Protocol/Ps2Policy/Ps2Policy.h | 50 + .../Foundation/Protocol/PxeDhcp4/PxeDhcp4.c | 28 + .../Foundation/Protocol/PxeDhcp4/PxeDhcp4.h | 350 + .../PxeDhcp4Callback/PxeDhcp4CallBack.c | 28 + .../PxeDhcp4Callback/PxeDhcp4CallBack.h | 86 + .../Protocol/TcgService/TcgService.c | 30 + .../Protocol/TcgService/TcgService.h | 128 + .../Foundation/Protocol/Tcp/Tcp.c | 29 + .../Foundation/Protocol/Tcp/Tcp.h | 110 + .../TianoDecompress/TianoDecompress.c | 28 + .../TianoDecompress/TianoDecompress.h | 139 + .../Foundation/Protocol/UgaSplash/UgaSplash.c | 29 + .../Foundation/Protocol/UgaSplash/UgaSplash.h | 45 + .../Foundation/Protocol/UsbAtapi/usbatapi.c | 31 + .../Foundation/Protocol/UsbAtapi/usbatapi.h | 83 + .../Protocol/VariableStore/VariableStore.c | 36 + .../Protocol/VariableStore/VariableStore.h | 105 + .../Protocol/VgaMiniPort/VgaMiniPort.c | 28 + .../Protocol/VgaMiniPort/VgaMiniPort.h | 70 + .../VirtualMemoryAccess/VirtualMemoryAccess.c | 27 + .../VirtualMemoryAccess/VirtualMemoryAccess.h | 64 + EdkCompatibilityPkg/License.txt | 30 + .../Tools/Pccts/CHANGES_FROM_133.txt | 1766 +++++ .../Pccts/CHANGES_FROM_133_before_mr13.txt | 3666 +++++++++++ .../Tools/Pccts/CHANGES_SUMMARY.txt | 2049 ++++++ .../Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt | 184 + .../Other/Maintained/Tools/Pccts/README | 171 + .../Maintained/Tools/Pccts/bin/Antlr.exe | Bin 0 -> 286720 bytes .../Other/Maintained/Tools/Pccts/bin/Dlg.exe | Bin 0 -> 73728 bytes .../Maintained/Tools/Pccts/bin/Sorcerer.exe | Bin 0 -> 135168 bytes .../Maintained/Tools/Pccts/h/AParser.cpp | 815 +++ .../Other/Maintained/Tools/Pccts/h/AParser.h | 358 + .../Maintained/Tools/Pccts/h/ASTBase.cpp | 244 + .../Other/Maintained/Tools/Pccts/h/ASTBase.h | 119 + .../Maintained/Tools/Pccts/h/ATokPtr.cpp | 82 + .../Other/Maintained/Tools/Pccts/h/ATokPtr.h | 88 + .../Other/Maintained/Tools/Pccts/h/AToken.h | 305 + .../Maintained/Tools/Pccts/h/ATokenBuffer.cpp | 345 + .../Maintained/Tools/Pccts/h/ATokenBuffer.h | 106 + .../Maintained/Tools/Pccts/h/ATokenStream.h | 51 + .../Tools/Pccts/h/AToken_traditional.h | 215 + .../Maintained/Tools/Pccts/h/BufFileInput.cpp | 100 + .../Maintained/Tools/Pccts/h/BufFileInput.h | 53 + .../Tools/Pccts/h/DLG_stream_input.h | 98 + .../Other/Maintained/Tools/Pccts/h/DLexer.cpp | 188 + .../Maintained/Tools/Pccts/h/DLexerBase.cpp | 268 + .../Maintained/Tools/Pccts/h/DLexerBase.h | 197 + .../Maintained/Tools/Pccts/h/PBlackBox.h | 104 + .../Maintained/Tools/Pccts/h/PCCTSAST.cpp | 662 ++ .../Other/Maintained/Tools/Pccts/h/PCCTSAST.h | 142 + .../Other/Maintained/Tools/Pccts/h/SList.h | 71 + .../Other/Maintained/Tools/Pccts/h/antlr.h | 788 +++ .../Other/Maintained/Tools/Pccts/h/ast.c | 345 + .../Other/Maintained/Tools/Pccts/h/ast.h | 115 + .../Other/Maintained/Tools/Pccts/h/charbuf.h | 46 + .../Other/Maintained/Tools/Pccts/h/charptr.c | 58 + .../Other/Maintained/Tools/Pccts/h/charptr.h | 48 + .../Other/Maintained/Tools/Pccts/h/config.h | 1 + .../Other/Maintained/Tools/Pccts/h/dlgauto.h | 499 ++ .../Other/Maintained/Tools/Pccts/h/dlgdef.h | 128 + .../Other/Maintained/Tools/Pccts/h/err.h | 1168 ++++ .../Other/Maintained/Tools/Pccts/h/int.h | 37 + .../Maintained/Tools/Pccts/h/pccts_assert.h | 10 + .../Maintained/Tools/Pccts/h/pccts_debug.lib | Bin 0 -> 158702 bytes .../Maintained/Tools/Pccts/h/pccts_iostream.h | 10 + .../Maintained/Tools/Pccts/h/pccts_istream.h | 10 + .../Tools/Pccts/h/pccts_release.lib | Bin 0 -> 83612 bytes .../Maintained/Tools/Pccts/h/pccts_setjmp.h | 10 + .../Maintained/Tools/Pccts/h/pccts_stdarg.h | 10 + .../Maintained/Tools/Pccts/h/pccts_stdio.h | 10 + .../Maintained/Tools/Pccts/h/pccts_stdlib.h | 10 + .../Maintained/Tools/Pccts/h/pccts_string.h | 10 + .../Other/Maintained/Tools/Pccts/h/pcctscfg.h | 350 + .../Maintained/Tools/Pccts/h/pcctslib50.dsp | 118 + .../Maintained/Tools/Pccts/h/pcctslib50.dsw | 29 + .../Maintained/Tools/Pccts/h/pcctslib60.dsp | 124 + .../Maintained/Tools/Pccts/h/pcctslib60.dsw | 29 + .../Maintained/Tools/Pccts/h/pcnames.bat | 11 + .../Other/Maintained/Tools/Pccts/h/slist.cpp | 105 + .../Tools/Pccts/lib/pccts_debug.lib | Bin 0 -> 158702 bytes .../Tools/Pccts/lib/pccts_release.lib | Bin 0 -> 83612 bytes .../Tools/Pccts/sorcerer/h/SASTBase.h | 8 + .../Tools/Pccts/sorcerer/h/SCommonAST.h | 26 + .../Tools/Pccts/sorcerer/h/STreeParser.h | 110 + .../Tools/Pccts/sorcerer/h/astlib.h | 72 + .../Tools/Pccts/sorcerer/h/sintstack.h | 61 + .../Tools/Pccts/sorcerer/h/sorcerer.h | 172 + .../Tools/Pccts/sorcerer/h/sorlist.h | 52 + .../Tools/Pccts/sorcerer/h/sstack.h | 46 + .../Tools/Pccts/sorcerer/lib/CASTBase.h | 45 + .../Tools/Pccts/sorcerer/lib/STreeParser.cpp | 151 + .../Tools/Pccts/sorcerer/lib/astlib.c | 834 +++ .../Tools/Pccts/sorcerer/lib/errsupport.c | 100 + .../Tools/Pccts/sorcerer/lib/makefile | 21 + .../Tools/Pccts/sorcerer/lib/msvc.dsp | 130 + .../Tools/Pccts/sorcerer/lib/sintstack.c | 140 + .../Tools/Pccts/sorcerer/lib/sorcerer.c | 169 + .../Tools/Pccts/sorcerer/lib/sorlist.c | 123 + .../Tools/Pccts/sorcerer/lib/sstack.c | 78 + EdkCompatibilityPkg/Sample/CommonTools.env | 672 ++ .../Sample/Include/Efi2WinNT.h | 59 + .../Sample/Include/EfiCompNameSupport.h | 58 + EdkCompatibilityPkg/Sample/Include/EfiWinNt.h | 46 + .../Sample/Library/Dxe/WinNt/WinNtLib.c | 75 + .../Sample/Library/Dxe/WinNt/WinNtLib.inf | 49 + EdkCompatibilityPkg/Sample/LocalTools.env | 95 + .../Sample/Platform/Common.dsc | 1522 +++++ .../Sample/Platform/CommonIa32.dsc | 558 ++ .../Sample/Platform/CommonIpf.dsc | 391 ++ .../Sample/Platform/CommonX64.dsc | 558 ++ .../Sample/Platform/EdkIIGlueLib32.dsc | 39 + .../Sample/Platform/EdkIIGlueLibAll.dsc | 54 + .../Sample/Platform/EdkLib32.dsc | 36 + .../Sample/Platform/EdkLibAll.dsc | 63 + .../Nt32/Protocol/EdkNt32ProtocolLib.inf | 46 + .../Platform/Nt32/Protocol/WinNtIo/WinNtIo.c | 40 + .../Platform/Nt32/Protocol/WinNtIo/WinNtIo.h | 163 + .../Nt32/Protocol/WinNtThunk/WinNtThunk.c | 28 + .../Nt32/Protocol/WinNtThunk/WinNtThunk.h | 1276 ++++ .../Tools/Source/BootsectImage/Makefile | 97 + .../Source/BootsectImage/bootsectimage.c | 881 +++ .../Sample/Tools/Source/BootsectImage/fat.h | 158 + .../Sample/Tools/Source/BootsectImage/mbr.h | 64 + .../Sample/Tools/Source/Common/CommonLib.c | 497 ++ .../Sample/Tools/Source/Common/CommonLib.h | 120 + .../Sample/Tools/Source/Common/Compress.h | 90 + .../Sample/Tools/Source/Common/Crc32.c | 327 + .../Sample/Tools/Source/Common/Crc32.h | 51 + .../Sample/Tools/Source/Common/Decompress.c | 995 +++ .../Sample/Tools/Source/Common/Decompress.h | 174 + .../Sample/Tools/Source/Common/EfiCompress.c | 1600 +++++ .../Source/Common/EfiCustomizedCompress.h | 138 + .../Tools/Source/Common/EfiUtilityMsgs.c | 756 +++ .../Tools/Source/Common/EfiUtilityMsgs.h | 135 + .../Sample/Tools/Source/Common/FvLib.c | 786 +++ .../Sample/Tools/Source/Common/FvLib.h | 177 + .../Sample/Tools/Source/Common/Makefile | 145 + .../Sample/Tools/Source/Common/MyAlloc.c | 516 ++ .../Sample/Tools/Source/Common/MyAlloc.h | 222 + .../Sample/Tools/Source/Common/ParseInf.c | 625 ++ .../Sample/Tools/Source/Common/ParseInf.h | 233 + .../Tools/Source/Common/SimpleFileParsing.c | 1456 ++++ .../Tools/Source/Common/SimpleFileParsing.h | 118 + .../Tools/Source/Common/TianoCompress.c | 1765 +++++ .../CustomizedCompress/CustomizedCompress.c | 146 + .../Tools/Source/CustomizedCompress/makefile | 82 + .../Source/EfiCompress/EfiCompressMain.c | 386 ++ .../Sample/Tools/Source/EfiCompress/makefile | 89 + .../Sample/Tools/Source/EfiRom/EfiRom.c | 1545 +++++ .../Sample/Tools/Source/EfiRom/Makefile | 85 + .../Sample/Tools/Source/EfildrImage/Makefile | 96 + .../Tools/Source/EfildrImage/efildrimage.c | 188 + .../Sample/Tools/Source/FwImage/Makefile | 86 + .../Sample/Tools/Source/FwImage/fwimage.c | 587 ++ .../Source/GenAprioriFile/GenAprioriFile.c | 467 ++ .../Tools/Source/GenAprioriFile/Makefile | 78 + .../Source/GenBootsector/GetDrvNumOffset.c | 58 + .../Sample/Tools/Source/GenBootsector/fat.h | 158 + .../Source/GenBootsector/genbootsector.c | 652 ++ .../Tools/Source/GenBootsector/makefile | 99 + .../Source/GenCRC32Section/GenCRC32Section.c | 299 + .../Source/GenCRC32Section/GenCRC32Section.h | 43 + .../Tools/Source/GenCRC32Section/makefile | 85 + .../Tools/Source/GenDepex/DepexParser.c | 890 +++ .../Tools/Source/GenDepex/DepexParser.h | 26 + .../Sample/Tools/Source/GenDepex/GenDepex.c | 912 +++ .../Sample/Tools/Source/GenDepex/GenDepex.h | 67 + .../Sample/Tools/Source/GenDepex/makefile | 100 + .../Tools/Source/GenFfsFile/GenFfsFile.c | 2681 ++++++++ .../Tools/Source/GenFfsFile/GenFfsFile.h | 35 + .../Sample/Tools/Source/GenFfsFile/makefile | 88 + .../Tools/Source/GenFvImage/GenFvImageExe.c | 299 + .../Tools/Source/GenFvImage/GenFvImageExe.h | 98 + .../Tools/Source/GenFvImage/GenFvImageLib.c | 3054 +++++++++ .../Tools/Source/GenFvImage/GenFvImageLib.h | 140 + .../Source/GenFvImage/GenFvImageLibInternal.h | 212 + .../Sample/Tools/Source/GenFvImage/Makefile | 109 + .../Sample/Tools/Source/GenPage/Makefile | 95 + .../Tools/Source/GenPage/VirtualMemory.h | 127 + .../Sample/Tools/Source/GenPage/genpage.c | 344 + .../Tools/Source/GenSection/GenSection.c | 1000 +++ .../Tools/Source/GenSection/GenSection.h | 42 + .../Sample/Tools/Source/GenSection/makefile | 82 + .../Sample/Tools/Source/GuidChk/CommonUtils.h | 57 + .../Sample/Tools/Source/GuidChk/FileSearch.c | 285 + .../Sample/Tools/Source/GuidChk/FileSearch.h | 108 + .../Sample/Tools/Source/GuidChk/GuidChk.c | 2417 +++++++ .../Sample/Tools/Source/GuidChk/GuidList.c | 188 + .../Sample/Tools/Source/GuidChk/Makefile | 96 + .../Sample/Tools/Source/GuidChk/UtilsMsgs.c | 489 ++ .../Sample/Tools/Source/GuidChk/UtilsMsgs.h | 106 + .../Sample/Tools/Source/MakeDeps/MakeDeps.c | 1316 ++++ .../Sample/Tools/Source/MakeDeps/Makefile | 69 + .../Sample/Tools/Source/Makefile | 79 + .../Sample/Tools/Source/ModifyInf/Makefile | 82 + .../Sample/Tools/Source/ModifyInf/ModifyInf.c | 322 + .../Sample/Tools/Source/ProcessDsc/Common.h | 123 + .../Sample/Tools/Source/ProcessDsc/DscFile.c | 534 ++ .../Sample/Tools/Source/ProcessDsc/DscFile.h | 109 + .../Tools/Source/ProcessDsc/Exceptions.c | 141 + .../Tools/Source/ProcessDsc/Exceptions.h | 57 + .../Sample/Tools/Source/ProcessDsc/FWVolume.c | 1566 +++++ .../Sample/Tools/Source/ProcessDsc/FWVolume.h | 76 + .../Sample/Tools/Source/ProcessDsc/Makefile | 102 + .../Tools/Source/ProcessDsc/ProcessDsc.c | 4726 +++++++++++++ .../Sample/Tools/Source/SetStamp/Makefile | 88 + .../Sample/Tools/Source/SetStamp/SetStamp.c | 475 ++ .../Sample/Tools/Source/SplitFile/Makefile | 94 + .../Sample/Tools/Source/SplitFile/splitfile.c | 136 + .../Sample/Tools/Source/StrGather/Makefile | 89 + .../Sample/Tools/Source/StrGather/StrGather.c | 2574 ++++++++ .../Sample/Tools/Source/StrGather/StrGather.h | 84 + .../Sample/Tools/Source/StrGather/StringDB.c | 2808 ++++++++ .../Sample/Tools/Source/StrGather/StringDB.h | 136 + .../Sample/Tools/Source/VcCheck/VcCheck.c | 121 + .../Sample/Tools/Source/VcCheck/makefile | 92 + .../Sample/Tools/Source/VfrCompile/EfiVfr.h | 178 + .../Tools/Source/VfrCompile/VfrCompile.g | 3463 ++++++++++ .../Tools/Source/VfrCompile/VfrServices.cpp | 754 +++ .../Tools/Source/VfrCompile/VfrServices.h | 227 + .../Sample/Tools/Source/VfrCompile/makefile | 172 + EdkCompatibilityPkg/Sample/Version.env | 34 + 1433 files changed, 266617 insertions(+) create mode 100644 EdkCompatibilityPkg/EDK_Snapshot.txt create mode 100644 EdkCompatibilityPkg/EdkCompatibilityPkg.dec create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c create mode 100644 EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Itanium/Include/CpuIa64.h create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm create mode 100644 EdkCompatibilityPkg/Foundation/Cpu/Pentium/Include/CpuIA32.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/EfiGuidLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Include/EfiApi.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Include/Pxe.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/BootMode.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiBootScript.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiDependency.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareFileSystem.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolume.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiImageFormat.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiInternalFormRepresentation.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiSmbus.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiStatusCode.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/EfiVariable.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/PeiHob.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecApi.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecError.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecTypes.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/EdkGuidLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h create mode 100644 EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c create mode 100644 EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ebc/EfiPeOptionalHeader.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ebc/TianoBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiCommon.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiDebug.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiDepex.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiFlashMap.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiPci.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiPerf.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiPxe.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiSpec.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiTpm.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiVariable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/EfiWorkingBlockHeader.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ia32/EfiPeOptionalHeader.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ia32/TianoBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi1_0.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi2_0.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi3_0.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AcpiCommon.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/SdramSpd.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/atapi.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci22.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci30.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ipf/EfiBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ipf/EfiPeOptionalHeader.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ipf/IpfDefines.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ipf/IpfMacro.i create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ipf/PalApi.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ipf/SalApi.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Ipf/TianoBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Pei/Pei.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Pei/PeiBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Pei/PeiDebug.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/Tiano.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/TianoApi.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/TianoCommon.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/TianoDevicePath.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/TianoError.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/TianoTypes.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/x64/EfiBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/x64/EfiPeOptionalHeader.h create mode 100644 EdkCompatibilityPkg/Foundation/Include/x64/TianoBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memsetSSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/memcpy.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/memset.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpy.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpySSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memset.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memsetSSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Event.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/GetImage.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Lock.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ia32/PerformancePrimitives.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/HobLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/hob.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ebc/ProcDep.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCombinationLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCommonLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiHobLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiPrintLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRegTableLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiScriptLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiWinNtLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GetImage.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GraphicsLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/ProcDep.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/ProcDep.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/RtDevicePath.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/SmmRuntimeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/CpuFuncs.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/ProcDep.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/BoxDraw.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/StdErr.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/BoxDraw.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/StdErr.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ebc/EdkIIGlueProcessorBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ipf/EdkIIGlueProcessorBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueEdkDxeSalLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EbcCache.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/IpfCache.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIpf.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/CpuBreakpoint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SetJumpLongJump.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SwitchStack.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/Synchronization.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuBreakpoint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuFlushTlb.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuPause.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/FlushCacheRange.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/GetInterruptState.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange32.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange64.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Non-existing.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/PalCallStatic.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ReadItc.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/SwitchStack.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Synchronization.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Unaligned.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/asm.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ia_64gen.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/longjmp.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ebc/PeCoffLoaderEx.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/x64/PeCoffLoaderEx.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ipf/IpfTimerLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoHighLevel.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/EdkDxeSalLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/ReadKr1.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/WriteKr1.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareGuid.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiSetMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiZeroMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/PostCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/String.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/linkedlist.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/Include/peihoblib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Debug.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/FindFv.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Hob/Hob.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/HwAccess.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/asm.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/efijump.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/math.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/processor.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Perf.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/Processor.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ReadIdt.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/SupportItpDebug.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/WriteIdt.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/efijump.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/EfiJump.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/IdtDumb.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Math.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Processor.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c create mode 100644 EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h create mode 100644 EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/Thunk16/x86Thunk.c create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/EdkPpiLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.c create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.h create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.c create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.h create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.c create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.h create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c create mode 100644 EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/EdkProtocolLib.inf create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Print/Print.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Print/Print.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c create mode 100644 EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h create mode 100644 EdkCompatibilityPkg/License.txt create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgdef.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/err.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_iostream.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_setjmp.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_release.lib create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SASTBase.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/SCommonAST.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c create mode 100644 EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c create mode 100644 EdkCompatibilityPkg/Sample/CommonTools.env create mode 100644 EdkCompatibilityPkg/Sample/Include/Efi2WinNT.h create mode 100644 EdkCompatibilityPkg/Sample/Include/EfiCompNameSupport.h create mode 100644 EdkCompatibilityPkg/Sample/Include/EfiWinNt.h create mode 100644 EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.c create mode 100644 EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.inf create mode 100644 EdkCompatibilityPkg/Sample/LocalTools.env create mode 100644 EdkCompatibilityPkg/Sample/Platform/Common.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/CommonIa32.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/CommonIpf.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/CommonX64.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLib32.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/EdkLib32.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/EdkLibAll.dsc create mode 100644 EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/EdkNt32ProtocolLib.inf create mode 100644 EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.c create mode 100644 EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.h create mode 100644 EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.c create mode 100644 EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/bootsectimage.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/fat.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/mbr.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/Compress.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCompress.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCustomizedCompress.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Common/TianoCompress.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/CustomizedCompress.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/efildrimage.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/FwImage/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/GetDrvNumOffset.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/fat.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/genbootsector.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenPage/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenPage/VirtualMemory.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenPage/genpage.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GenSection/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/CommonUtils.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidList.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Common.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/StrGather/Makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/makefile create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h create mode 100644 EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile create mode 100644 EdkCompatibilityPkg/Sample/Version.env diff --git a/EdkCompatibilityPkg/EDK_Snapshot.txt b/EdkCompatibilityPkg/EDK_Snapshot.txt new file mode 100644 index 0000000000..231c73e89b --- /dev/null +++ b/EdkCompatibilityPkg/EDK_Snapshot.txt @@ -0,0 +1,6 @@ +Notes: + This EDK Compatibility Package is based on the EDK 1.03 release found at http://edk.tianocore.org. + It is compatibile with EDK 1.01 with the following exception: + + + \ No newline at end of file diff --git a/EdkCompatibilityPkg/EdkCompatibilityPkg.dec b/EdkCompatibilityPkg/EdkCompatibilityPkg.dec new file mode 100644 index 0000000000..8a6d4db6fd --- /dev/null +++ b/EdkCompatibilityPkg/EdkCompatibilityPkg.dec @@ -0,0 +1,49 @@ +#/** @file +# EDK Compatibility Package +# +# This Package provides headers and libraries that allow a EDK Module (https://edk.tianocore.org) +# to be used in the context of EDK II environment. +# +# All rights reserved. +# This program and the accompanying materials are licensed and made available under +# the terms and conditions of the BSD License which accompanies this distribution. +# The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +################################################################################ +# +# Defines Section - statements that will be processed to create a Makefile. +# +################################################################################ + +[Defines] + DEC_SPECIFICATION = 0x00010005 + PACKAGE_NAME = EdkCompatibilityPkg + PACKAGE_GUID = 98EDD7B0-2A6C-4b4a-AC72-4AAE0F95A3F8 + PACKAGE_VERSION = 0.1 + + +################################################################################ +# +# Include Section - list of Include Paths that are provided by this package. +# Comments are used for Keywords and Module Types. +# +# Supported Module Types: +# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION +# +################################################################################ +[Includes.common] + + +################################################################################ +# +# Library Class Header section - list of Library Class header files that are +# provided by this package. +# +################################################################################ +[LibraryClasses.common] diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf new file mode 100644 index 0000000000..84b0afd2c6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf @@ -0,0 +1,65 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# ArchProtocolLib.inf +# +# Abstract: +# +# Component description file for the Architectural Protocol Library. +# +#--*/ + +[defines] +BASE_NAME = ArchProtocolLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + Bds\Bds.c + Bds\Bds.h + Capsule\Capsule.c + Capsule\Capsule.h + Cpu\Cpu.c + Cpu\Cpu.h + Metronome\Metronome.c + Metronome\Metronome.h + MonotonicCounter\MonotonicCounter.c + MonotonicCounter\MonotonicCounter.h + RealTimeClock\RealTimeClock.c + RealTimeClock\RealTimeClock.h + Reset\Reset.c + Reset\Reset.h + Runtime\Runtime.c + Runtime\Runtime.h + Security\Security.c + Security\Security.h + StatusCode\StatusCode.c + StatusCode\StatusCode.h + Timer\Timer.c + Timer\Timer.h + Variable\Variable.c + Variable\Variable.h + VariableWrite\VariableWrite.c + VariableWrite\VariableWrite.h + WatchdogTimer\WatchdogTimer.c + WatchdogTimer\WatchdogTimer.h + +[includes.common] + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c new file mode 100644 index 0000000000..adb5682ee7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Bds.c + +Abstract: + + Boot Device Selection Architectural Protocol GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Bds) + +EFI_GUID gEfiBdsArchProtocolGuid = EFI_BDS_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiBdsArchProtocolGuid, "BDS", "BDS Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h new file mode 100644 index 0000000000..ac8560aec9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h @@ -0,0 +1,100 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Bds.h + +Abstract: + + Boot Device Selection Architectural Protocol as defined in Tiano + + When the DXE core is done it calls the BDS via this protocol. + +--*/ + +#ifndef _ARCH_PROTOCOL_BDS_H_ +#define _ARCH_PROTOCOL_BDS_H_ + +// +// Global ID for the BDS Architectural Protocol +// +#define EFI_BDS_ARCH_PROTOCOL_GUID \ + { 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } + +// +// Declare forward reference for the BDS Architectural Protocol +// +EFI_FORWARD_DECLARATION (EFI_BDS_ARCH_PROTOCOL); + +typedef +VOID +(EFIAPI *EFI_BDS_ENTRY) ( + IN EFI_BDS_ARCH_PROTOCOL * This + ); +/*++ + +Routine Description: + + This function uses policy data from the platform to determine what operating + system or system utility should be loaded and invoked. This function call + also optionally make the use of user input to determine the operating system + or system utility to be loaded and invoked. When the DXE Core has dispatched + all the drivers on the dispatch queue, this function is called. This + function will attempt to connect the boot devices required to load and invoke + the selected operating system or system utility. During this process, + additional firmware volumes may be discovered that may contain addition DXE + drivers that can be dispatched by the DXE Core. If a boot device cannot be + fully connected, this function calls the DXE Service Dispatch() to allow the + DXE drivers from any newly discovered firmware volumes to be dispatched. + Then the boot device connection can be attempted again. If the same boot + device connection operation fails twice in a row, then that boot device has + failed, and should be skipped. This function should never return. + +Arguments: + + This - The EFI_BDS_ARCH_PROTOCOL instance. + +Returns: + + None. + +--*/ + +// +// Interface stucture for the BDS Architectural Protocol +// +typedef struct _EFI_BDS_ARCH_PROTOCOL { + EFI_BDS_ENTRY Entry; +} EFI_BDS_ARCH_PROTOCOL; + +/*++ + + Protocol Description: + The EFI_BDS_ARCH_PROTOCOL transfers control from DXE to an operating + system or a system utility. If there are not enough drivers initialized + when this protocol is used to access the required boot device(s), then + this protocol should add drivers to the dispatch queue and return control + back to the dispatcher. Once the required boot devices are available, then + the boot device can be used to load and invoke an OS or a system utility. + + Parameters: + + Entry - The entry point to BDS. This call does not take any parameters, + and the return value can be ignored. If it returns, then the + dispatcher must be invoked again, if it never returns, then an + operating system or a system utility have been invoked. + +--*/ + +extern EFI_GUID gEfiBdsArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c new file mode 100644 index 0000000000..b9aa9f64f8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Capsule.c + +Abstract: + + Capsule Architectural Protocol is used to produce the UEFI 2.0 capsule runtime services + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Capsule) + +EFI_GUID gEfiCapsuleArchProtocolGuid = EFI_CAPSULE_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiCapsuleArchProtocolGuid, "Capsule", "Capsule Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h new file mode 100644 index 0000000000..043a1b3ac0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Capsule.h + +Abstract: + + Capsule Architectural Protocol is newly added to produce UEFI2.0 capsule runtime services. + +--*/ + +#ifndef _ARCH_PROTOCOL_CAPSULE_ARCH_H_ +#define _ARCH_PROTOCOL_CAPSULE_ARCH_H_ + +// +// Global ID for the Capsule Architectural Protocol +// +#define EFI_CAPSULE_ARCH_PROTOCOL_GUID \ + { 0x5053697e, 0x2cbc, 0x4819, 0x90, 0xd9, 0x5, 0x80, 0xde, 0xee, 0x57, 0x54 } + +extern EFI_GUID gEfiCapsuleArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c new file mode 100644 index 0000000000..3eca19bbfb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Cpu.c + +Abstract: + + CPU Architectural Protocol GUID as defined in Tiano + + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu) + +EFI_GUID gEfiCpuArchProtocolGuid = EFI_CPU_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiCpuArchProtocolGuid, "CPU", "CPU Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h new file mode 100644 index 0000000000..7b17969e5e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h @@ -0,0 +1,361 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Cpu.h + +Abstract: + + CPU Architectural Protocol as defined in Tiano + + This code abstracts the DXE core from processor implementation details. + +--*/ + +#ifndef _ARCH_PROTOCOL_CPU_H_ +#define _ARCH_PROTOCOL_CPU_H_ + +#include EFI_PROTOCOL_DEFINITION (DebugSupport) + +#define EFI_CPU_ARCH_PROTOCOL_GUID \ + { 0x26baccb1, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } + +EFI_FORWARD_DECLARATION (EFI_CPU_ARCH_PROTOCOL); + +typedef enum { + EfiCpuFlushTypeWriteBackInvalidate, + EfiCpuFlushTypeWriteBack, + EfiCpuFlushTypeInvalidate, + EfiCpuMaxFlushType +} EFI_CPU_FLUSH_TYPE; + +typedef enum { + EfiCpuInit, + EfiCpuMaxInitType +} EFI_CPU_INIT_TYPE; + +typedef +VOID +(*EFI_CPU_INTERRUPT_HANDLER) ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_SYSTEM_CONTEXT SystemContext + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_FLUSH_DATA_CACHE) ( + IN EFI_CPU_ARCH_PROTOCOL * This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length, + IN EFI_CPU_FLUSH_TYPE FlushType + ); + +/*++ + +Routine Description: + + This function flushes the range of addresses from Start to Start+Length + from the processor's data cache. If Start is not aligned to a cache line + boundary, then the bytes before Start to the preceding cache line boundary + are also flushed. If Start+Length is not aligned to a cache line boundary, + then the bytes past Start+Length to the end of the next cache line boundary + are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate must be + supported. If the data cache is fully coherent with all DMA operations, then + this function can just return EFI_SUCCESS. If the processor does not support + flushing a range of the data cache, then the entire data cache can be flushed. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + Start - The beginning physical address to flush from the processor's data + cache. + Length - The number of bytes to flush from the processor's data cache. This + function may flush more bytes than Length specifies depending upon + the granularity of the flush operation that the processor supports. + FlushType - Specifies the type of flush operation to perform. + +Returns: + + EFI_SUCCESS - The address range from Start to Start+Length was flushed from + the processor's data cache. + EFI_UNSUPPORTEDT - The processor does not support the cache flush type specified + by FlushType. + EFI_DEVICE_ERROR - The address range from Start to Start+Length could not be flushed + from the processor's data cache. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_ENABLE_INTERRUPT) ( + IN EFI_CPU_ARCH_PROTOCOL * This + ); + +/*++ + +Routine Description: + + This function enables interrupt processing by the processor. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + +Returns: + + EFI_SUCCESS - Interrupts are enabled on the processor. + EFI_DEVICE_ERROR - Interrupts could not be enabled on the processor. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_DISABLE_INTERRUPT) ( + IN EFI_CPU_ARCH_PROTOCOL * This + ); + +/*++ + +Routine Description: + + This function disables interrupt processing by the processor. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + +Returns: + + EFI_SUCCESS - Interrupts are disabled on the processor. + EFI_DEVICE_ERROR - Interrupts could not be disabled on the processor. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_GET_INTERRUPT_STATE) ( + IN EFI_CPU_ARCH_PROTOCOL * This, + OUT BOOLEAN *State + ); + +/*++ + +Routine Description: + + This function retrieves the processor's current interrupt state a returns it in + State. If interrupts are currently enabled, then TRUE is returned. If interrupts + are currently disabled, then FALSE is returned. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + State - A pointer to the processor's current interrupt state. Set to TRUE if + interrupts are enabled and FALSE if interrupts are disabled. +Returns: + + EFI_SUCCESS - The processor's current interrupt state was returned in State. + EFI_INVALID_PARAMETER - State is NULL. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_INIT) ( + IN EFI_CPU_ARCH_PROTOCOL * This, + IN EFI_CPU_INIT_TYPE InitType + ); + +/*++ + +Routine Description: + + This function generates an INIT on the processor. If this function succeeds, then the + processor will be reset, and control will not be returned to the caller. If InitType is + not supported by this processor, or the processor cannot programmatically generate an + INIT without help from external hardware, then EFI_UNSUPPORTED is returned. If an error + occurs attempting to generate an INIT, then EFI_DEVICE_ERROR is returned. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + InitType - The type of processor INIT to perform. + +Returns: + + EFI_SUCCESS - The processor INIT was performed. This return code should never be seen. + EFI_UNSUPPORTED - The processor INIT operation specified by InitType is not supported + by this processor. + EFI_DEVICE_ERROR - The processor INIT failed. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_REGISTER_INTERRUPT_HANDLER) ( + IN EFI_CPU_ARCH_PROTOCOL * This, + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ); + +/*++ + +Routine Description: + + This function registers and enables the handler specified by InterruptHandler for a processor + interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the + handler for the processor interrupt or exception type specified by InterruptType is uninstalled. + The installed handler is called once for each processor interrupt or exception. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + InterruptType - A pointer to the processor's current interrupt state. Set to TRUE if interrupts + are enabled and FALSE if interrupts are disabled. + InterruptHandler - A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled. +Returns: + + EFI_SUCCESS - The handler for the processor interrupt was successfully installed or uninstalled. + EFI_ALREADY_STARTED - InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + EFI_INVALID_PARAMETER - InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + EFI_UNSUPPORTED - The interrupt specified by InterruptType is not supported. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_GET_TIMER_VALUE) ( + IN EFI_CPU_ARCH_PROTOCOL * This, + IN UINT32 TimerIndex, + OUT UINT64 *TimerValue, + OUT UINT64 *TimerPeriod OPTIONAL + ); + +/*++ + +Routine Description: + + This function reads the processor timer specified by TimerIndex and returns it in TimerValue. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + TimerIndex - Specifies which processor timer is to be returned in TimerValue. This parameter + must be between 0 and NumberOfTimers-1. + TimerValue - Pointer to the returned timer value. + TimerPeriod - A pointer to the amount of time that passes in femtoseconds for each increment + of TimerValue. +Returns: + + EFI_SUCCESS - The processor timer value specified by TimerIndex was returned in TimerValue. + EFI_DEVICE_ERROR - An error occurred attempting to read one of the processor's timers. + EFI_INVALID_PARAMETER - TimerValue is NULL or TimerIndex is not valid. + EFI_UNSUPPORTED - The processor does not have any readable timers. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES) ( + IN EFI_CPU_ARCH_PROTOCOL * This, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ); + +/*++ + +Routine Description: + + This function modifies the attributes for the memory region specified by BaseAddress and + Length from their current attributes to the attributes specified by Attributes. + +Arguments: + + This - The EFI_CPU_ARCH_PROTOCOL instance. + BaseAddress - The physical address that is the start address of a memory region. + Length - The size in bytes of the memory region. + Attributes - The bit mask of attributes to set for the memory region. + +Returns: + + EFI_SUCCESS - The attributes were set for the memory region. + EFI_ACCESS_DENIED - The attributes for the memory resource range specified by + BaseAddress and Length cannot be modified. + EFI_INVALID_PARAMETER - Length is zero. + EFI_OUT_OF_RESOURCES - There are not enough system resources to modify the attributes of + the memory resource range. + EFI_UNSUPPORTED - The processor does not support one or more bytes of the memory + resource range specified by BaseAddress and Length. + The bit mask of attributes is not support for the memory resource + range specified by BaseAddress and Length. + +--*/ + +typedef struct _EFI_CPU_ARCH_PROTOCOL { + EFI_CPU_FLUSH_DATA_CACHE FlushDataCache; + EFI_CPU_ENABLE_INTERRUPT EnableInterrupt; + EFI_CPU_DISABLE_INTERRUPT DisableInterrupt; + EFI_CPU_GET_INTERRUPT_STATE GetInterruptState; + EFI_CPU_INIT Init; + EFI_CPU_REGISTER_INTERRUPT_HANDLER RegisterInterruptHandler; + EFI_CPU_GET_TIMER_VALUE GetTimerValue; + EFI_CPU_SET_MEMORY_ATTRIBUTES SetMemoryAttributes; + UINT32 NumberOfTimers; + UINT32 DmaBufferAlignment; +} EFI_CPU_ARCH_PROTOCOL; + +/*++ + +Protocol Description: + + The EFI_CPU_ARCH_PROTOCOL is used to abstract processor-specific functions from the DXE + Foundation. This includes flushing caches, enabling and disabling interrupts, hooking interrupt + vectors and exception vectors, reading internal processor timers, resetting the processor, and + determining the processor frequency. + +Parameters: + + FlushDataCache - Flushes a range of the processor's data cache. If the processor does + not contain a data cache, or the data cache is fully coherent, then this + function can just return EFI_SUCCESS. If the processor does not support + flushing a range of addresses from the data cache, then the entire data + cache must be flushed. + EnableInterrupt - Enables interrupt processing by the processor. + DisableInterrupt - Disables interrupt processing by the processor. + GetInterruptState - Retrieves the processor's current interrupt state. + Init - Generates an INIT on the processor. If a processor cannot programmatically + generate an INIT without help from external hardware, then this function + returns EFI_UNSUPPORTED. + RegisterInterruptHandler - Associates an interrupt service routine with one of the processor's interrupt + vectors. This function is typically used by the EFI_TIMER_ARCH_PROTOCOL to + hook the timer interrupt in a system. It can also be used by the debugger to + hook exception vectors. + GetTimerValue - Returns the value of one of the processor's internal timers. + SetMemoryAttributes - Attempts to set the attributes of a memory region. + NumberOfTimers - The number of timers that are available in a processor. The value in this + field is a constant that must not be modified after the CPU Architectural + Protocol is installed. All consumers must treat this as a read-only field. + DmaBufferAlignment - The size, in bytes, of the alignment required for DMA buffer allocations. + This is typically the size of the largest data cache line in the platform. + The value in this field is a constant that must not be modified after the + CPU Architectural Protocol is installed. All consumers must treat this as + a read-only field. + +--*/ + +extern EFI_GUID gEfiCpuArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c new file mode 100644 index 0000000000..27b286cf35 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Metronome.c + +Abstract: + + Metronome Architectural Protocol as defined in Tiano + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome) + +EFI_GUID gEfiMetronomeArchProtocolGuid = EFI_METRONOME_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiMetronomeArchProtocolGuid, "Metronome", "Metronome Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h new file mode 100644 index 0000000000..88de406d0e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h @@ -0,0 +1,109 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Metronome.h + +Abstract: + + Metronome Architectural Protocol as defined in DXE CIS + + This code abstracts the DXE core to provide delay services. + +--*/ + +#ifndef _ARCH_PROTOCOL_METRONOME_H_ +#define _ARCH_PROTOCOL_METRONOME_H_ + +// +// Global ID for the Metronome Architectural Protocol +// +#define EFI_METRONOME_ARCH_PROTOCOL_GUID \ + { 0x26baccb2, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } + +// +// Declare forward reference for the Metronome Architectural Protocol +// +EFI_FORWARD_DECLARATION (EFI_METRONOME_ARCH_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_METRONOME_WAIT_FOR_TICK) ( + IN EFI_METRONOME_ARCH_PROTOCOL *This, + IN UINT32 TickNumber + ); +/*++ + +Routine Description: + + The WaitForTick() function waits for the number of ticks specified by + TickNumber from a known time source in the platform. If TickNumber of + ticks are detected, then EFI_SUCCESS is returned. The actual time passed + between entry of this function and the first tick is between 0 and + TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod + time has elapsed, wait for two ticks. This function waits for a hardware + event to determine when a tick occurs. It is possible for interrupt + processing, or exception processing to interrupt the execution of the + WaitForTick() function. Depending on the hardware source for the ticks, it + is possible for a tick to be missed. This function cannot guarantee that + ticks will not be missed. If a timeout occurs waiting for the specified + number of ticks, then EFI_TIMEOUT is returned. + +Arguments: + + This - The EFI_METRONOME_ARCH_PROTOCOL instance. + + TickNumber - Number of ticks to wait. + +Returns: + + EFI_SUCCESS - The wait for the number of ticks specified by TickNumber + succeeded. + + EFI_TIMEOUT - A timeout occurred waiting for the specified number of ticks. + +--*/ + +// +// Interface stucture for the Metronome Architectural Protocol +// +typedef struct _EFI_METRONOME_ARCH_PROTOCOL { + EFI_METRONOME_WAIT_FOR_TICK WaitForTick; + UINT32 TickPeriod; +} EFI_METRONOME_ARCH_PROTOCOL; + +/*++ + + Protocol Description: + This protocol provides access to a known time source in the platform to the + core. The core uses this known time source to produce core services that + require calibrated delays. + + Parameters: + + WaitForTick - Waits for a specified number of ticks from a known time source + in the platform. The actual time passed between entry of this + function and the first tick is between 0 and TickPeriod 100 nS + units. If you want to guarantee that at least TickPeriod time + has elapsed, wait for two ticks. + + TickPeriod - The period of platform's known time source in 100 nS units. + This value on any platform must be at least 10 uS, and must not + exceed 200 uS. The value in this field is a constant that must + not be modified after the Metronome architectural protocol is + installed. All consumers must treat this as a read-only field. + +--*/ + +extern EFI_GUID gEfiMetronomeArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c new file mode 100644 index 0000000000..633db95f6e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MonotonicCounter.c + +Abstract: + + Monotonic Counter Architectural Protocol GUID as defined in the DXE CIS + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION(MonotonicCounter) + +EFI_GUID gEfiMonotonicCounterArchProtocolGuid = EFI_MONTONIC_COUNTER_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiMonotonicCounterArchProtocolGuid, "Monotonic Counter", "Monotonic Counter Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h new file mode 100644 index 0000000000..d4b87e61df --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MonotonicCounter.h + +Abstract: + + Monotonic Counter Architectural Protocol as defined in DXE CIS + + This code provides the services required to access the systems monotonic counter + +--*/ + +#ifndef _ARCH_PROTOCOL_MONTONIC_COUNTER_H_ +#define _ARCH_PROTOCOL_MONTONIC_COUNTER_H_ + +// +// Global ID for the Monotonic Counter Architectural Protocol +// +#define EFI_MONTONIC_COUNTER_ARCH_PROTOCOL_GUID \ + {0x1da97072, 0xbddc, 0x4b30, 0x99, 0xf1, 0x72, 0xa0, 0xb5, 0x6f, 0xff, 0x2a} + +extern EFI_GUID gEfiMonotonicCounterArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c new file mode 100644 index 0000000000..74846e3565 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RealTimeClock.c + +Abstract: + + Real Time clock Architectural Protocol GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock) + +EFI_GUID gEfiRealTimeClockArchProtocolGuid = EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiRealTimeClockArchProtocolGuid, "RTC", "Real Time Clock Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h new file mode 100644 index 0000000000..c17eaf69de --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h @@ -0,0 +1,43 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RealTimeClock.h + +Abstract: + + Real Time clock Architectural Protocol as defined in Tiano + + This code abstracts time and data functions. Used to provide + Time and date related EFI runtime services. + + The GetTime (), SetTime (), GetWakeupTime (), and SetWakeupTime () EFI 1.0 + services are added to the EFI system table and the + EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID protocol is registered with a NULL + pointer. + + No CRC of the EFI system table is required, as it is done in the DXE core. + +--*/ + +#ifndef _ARCH_PROTOCOL_REAL_TIME_CLOCK_H_ +#define _ARCH_PROTOCOL_REAL_TIME_CLOCK_H_ + +// +// Global ID for the Real Time Clock Architectural Protocol +// +#define EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID \ + { 0x27CFAC87, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } + +extern EFI_GUID gEfiRealTimeClockArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c new file mode 100644 index 0000000000..74569bb27c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Reset.c + +Abstract: + + Reset Architectural Protocol GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Reset) + +EFI_GUID gEfiResetArchProtocolGuid = EFI_RESET_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiResetArchProtocolGuid, "Reset", "Reset Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h new file mode 100644 index 0000000000..0854b03884 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Reset.h + +Abstract: + + Reset Architectural Protocol as defined in the DXE CIS + + Used to provide ResetSystem runtime services + + The ResetSystem () EFI 1.0 service is added to the EFI system table and the + EFI_RESET_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer. + + No CRC of the EFI system table is required, as it is done in the DXE core. + +--*/ + +#ifndef _ARCH_PROTOCOL_RESET_H_ +#define _ARCH_PROTOCOL_RESET_H_ + +// +// Global ID for the Reset Architectural Protocol +// +#define EFI_RESET_ARCH_PROTOCOL_GUID \ + { 0x27CFAC88, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } + +extern EFI_GUID gEfiResetArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c new file mode 100644 index 0000000000..655e784bdf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Runtime.c + +Abstract: + + Runtime Architectural Protocol as defined in Tiano + + This code is used to produce the EFI 1.0 runtime virtual switch over + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime) + +EFI_GUID gEfiRuntimeArchProtocolGuid = EFI_RUNTIME_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiRuntimeArchProtocolGuid, "Runtime", "Runtime Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h new file mode 100644 index 0000000000..62ea8b364a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h @@ -0,0 +1,114 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Runtime.h + +Abstract: + + Runtime Architectural Protocol as defined in DXE CIS. + + + This code is used to produce the EFI runtime services that are callable + only in physical mode. + + This driver must add SetVirtualAddressMap () and ConvertPointer () to + the EFI system table. This driver is not responcible for CRCing the + EFI system table. + + This driver will add EFI_RUNTIME_ARCH_PROTOCOL_GUID protocol with a + pointer to the Runtime Arch Protocol instance structure. The protocol + member functions are used by the DXE core to export information needed + by this driver to produce the runtime transition of runtime drivers from + physical mode calling to virtual mode calling. + +--*/ + +#ifndef _ARCH_PROTOCOL_RUNTIME_H_ +#define _ARCH_PROTOCOL_RUNTIME_H_ + +#include "LinkedList.h" + +// +// Global ID for the Runtime Architectural Protocol +// +#define EFI_RUNTIME_ARCH_PROTOCOL_GUID \ + { 0xb7dfb4e1, 0x52f, 0x449f, 0x87, 0xbe, 0x98, 0x18, 0xfc, 0x91, 0xb7, 0x33 } + +EFI_FORWARD_DECLARATION (EFI_RUNTIME_ARCH_PROTOCOL); + +typedef struct _EFI_RUNTIME_IMAGE_ENTRY { + VOID *ImageBase; + UINT64 ImageSize; + VOID *RelocationData; + EFI_HANDLE Handle; + EFI_LIST_ENTRY Link; +} EFI_RUNTIME_IMAGE_ENTRY; + +typedef struct _EFI_RUNTIME_EVENT_ENTRY { + UINT32 Type; + EFI_TPL NotifyTpl; + EFI_EVENT_NOTIFY NotifyFunction; + VOID *NotifyContext; + EFI_EVENT *Event; + EFI_LIST_ENTRY Link; +} EFI_RUNTIME_EVENT_ENTRY; + +// +// Interface stucture for the Runtime Architectural Protocol +// +typedef struct _EFI_RUNTIME_ARCH_PROTOCOL { + EFI_LIST_ENTRY ImageHead; + EFI_LIST_ENTRY EventHead; + UINTN MemoryDescriptorSize; + UINT32 MemoryDesciptorVersion; + UINTN MemoryMapSize; + EFI_MEMORY_DESCRIPTOR *MemoryMapPhysical; + EFI_MEMORY_DESCRIPTOR *MemoryMapVirtual; + BOOLEAN VirtualMode; + BOOLEAN AtRuntime; +} EFI_RUNTIME_ARCH_PROTOCOL; +/*++ + +Protocol Description: + + Allows the runtime functionality of the DXE Foundation to be contained in a + separate driver. It also provides hooks for the DXE Foundation to export + information that is needed at runtime. As such, this protocol allows the DXE + Foundation to manage runtime drivers and events. This protocol also implies + that the runtime services required to transition to virtual mode, + SetVirtualAddressMap() and ConvertPointer(), have been registered into the + EFI Runtime Table in the EFI System Partition. This protocol must be produced + by a runtime DXE driver and may only be consumed by the DXE Foundation. + +Parameters: + + ImageHead - A list of type EFI_RUNTIME_IMAGE_ENTRY. + EventHead - A list of type EFI_RUNTIME_EVENT_ENTRY. + MemoryDescriptorSize - Size of a memory descriptor that is return by + GetMemoryMap(). + MemoryDescriptorVersion - Version of a memory descriptor that is return by + GetMemoryMap(). + MemoryMapSize - Size of the memory map in bytes contained in + MemoryMapPhysical and MemoryMapVirtual. + MemoryMapPhysical - Pointer to a runtime buffer that contains a copy of the + memory map returned via GetMemoryMap(). + MemoryMapVirtual - Pointer to MemoryMapPhysical that is updated to virtual mode + after SetVirtualAddressMap(). + VirtualMode - Boolean that is TRUE if SetVirtualAddressMap() has been called. + AtRuntime - Boolean that is TRUE if ExitBootServices () has been called. + +--*/ + +extern EFI_GUID gEfiRuntimeArchProtocolGuid; + +#endif \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.c new file mode 100644 index 0000000000..70026c173f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Security.c + +Abstract: + + Security Architectural Protocol GUID as defined in DXE CIS + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION(Security) + +EFI_GUID gEfiSecurityArchProtocolGuid = EFI_SECURITY_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSecurityArchProtocolGuid, "Security", "Security Arch Protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.h new file mode 100644 index 0000000000..483bc53377 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Security/Security.h @@ -0,0 +1,146 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Security.h + +Abstract: + + Security Architectural Protocol as defined in the DXE CIS + + Used to provide Security services. Specifically, dependening upon the + authentication state of a discovered driver in a Firmware Volume, the + portable DXE Core Dispatcher will call into the Security Architectural + Protocol (SAP) with the authentication state of the driver. + + This call-out allows for OEM-specific policy decisions to be made, such + as event logging for attested boots, locking flash in response to discovering + an unsigned driver or failed signature check, or other exception response. + + The SAP can also change system behavior by having the DXE core put a driver + in the Schedule-On-Request (SOR) state. This will allow for later disposition + of the driver by platform agent, such as Platform BDS. + +--*/ + +#ifndef _ARCH_PROTOCOL_SECURITY_H_ +#define _ARCH_PROTOCOL_SECURITY_H_ + +// +// Global ID for the Security Code Architectural Protocol +// +#define EFI_SECURITY_ARCH_PROTOCOL_GUID \ + { 0xA46423E3, 0x4617, 0x49f1, 0xB9, 0xFF, 0xD1, 0xBF, 0xA9, 0x11, 0x58, 0x39 } + +EFI_FORWARD_DECLARATION (EFI_SECURITY_ARCH_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_SECURITY_FILE_AUTHENTICATION_STATE) ( + IN EFI_SECURITY_ARCH_PROTOCOL *This, + IN UINT32 AuthenticationStatus, + IN EFI_DEVICE_PATH_PROTOCOL *File + ) +/*++ + +Routine Description: + + The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific + policy from the DXE core response to an attempt to use a file that returns a + given status for the authentication check from the section extraction protocol. + + The possible responses in a given SAP implementation may include locking + flash upon failure to authenticate, attestation logging for all signed drivers, + and other exception operations. The File parameter allows for possible logging + within the SAP of the driver. + + If File is NULL, then EFI_INVALID_PARAMETER is returned. + + If the file specified by File with an authentication status specified by + AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned. + + If the file specified by File with an authentication status specified by + AuthenticationStatus is not safe for the DXE Core to use under any circumstances, + then EFI_ACCESS_DENIED is returned. + + If the file specified by File with an authentication status specified by + AuthenticationStatus is not safe for the DXE Core to use right now, but it + might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is + returned. + +Arguments: + + This - The EFI_SECURITY_ARCH_PROTOCOL instance. + + AuthenticationStatus - This is the authentication type returned from the Section + Extraction protocol. See the Section Extraction Protocol + Specification for details on this type. + + File - This is a pointer to the device path of the file that is + being dispatched. This will optionally be used for logging. + +Returns: + + EFI_SUCCESS - The file specified by File did authenticate, and the + platform policy dictates that the DXE Core may use File. + + EFI_INVALID_PARAMETER - Driver is NULL. + + EFI_SECURITY_VIOLATION - The file specified by File did not authenticate, and + the platform policy dictates that File should be placed + in the untrusted state. A file may be promoted from + the untrusted to the trusted state at a future time + with a call to the Trust() DXE Service. + + EFI_ACCESS_DENIED - The file specified by File did not authenticate, and + the platform policy dictates that File should not be + used for any purpose. + +--*/ +; + +// +// Interface stucture for the Timer Architectural Protocol +// +typedef struct _EFI_SECURITY_ARCH_PROTOCOL { + EFI_SECURITY_FILE_AUTHENTICATION_STATE FileAuthenticationState; +} EFI_SECURITY_ARCH_PROTOCOL; +/*++ + + Protocol Description: + + The EFI_SECURITY_ARCH_PROTOCOL is used to abstract platform-specific policy + from the DXE core. This includes locking flash upon failure to authenticate, + attestation logging, and other exception operations. + + The driver that produces the EFI_SECURITY_ARCH_PROTOCOL may also optionally + install the EFI_SECURITY_POLICY_PROTOCOL_GUID onto a new handle with a NULL + interface. The existence of this GUID in the protocol database means that + the GUIDed Section Extraction Protocol should authenticate the contents of + an Authentication Section. The expectation is that the GUIDed Section + Extraction protocol will look for the existence of the EFI_SECURITY_POLICY_ + PROTOCOL_GUID in the protocol database. If it exists, then the publication + thereof is taken as an injunction to attempt an authentication of any section + wrapped in an Authentication Section. See the Firmware File System + Specification for details on the GUIDed Section Extraction Protocol and + Authentication Sections. + + Parameters: + + FileAuthenticationState - This service is called upon fault with respect to + the authentication of a section of a file. + +--*/ + +extern EFI_GUID gEfiSecurityArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c new file mode 100644 index 0000000000..ad32cfeddf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCode.c + +Abstract: + + Status code Architectural Protocol as defined in Tiano + + This code abstracts Status Code reporting. + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) + +EFI_GUID gEfiStatusCodeRuntimeProtocolGuid = EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiStatusCodeRuntimeProtocolGuid, "Status Code", "Status Code Arch Protocol"); \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h new file mode 100644 index 0000000000..86b7c66cbf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h @@ -0,0 +1,100 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCode.h + +Abstract: + + Status code Architectural Protocol as defined in the DXE CIS + + This code abstracts Status Code reporting. + + The StatusCode () Tiano service is added to the EFI system table and the + EFI_STATUS_CODE_ARCH_PROTOCOL_GUID protocol is registered with a NULL + pointer. + + No CRC of the EFI system table is required, as it is done in the DXE core. + +--*/ + +#ifndef __STATUS_CODE_RUNTIME_PROTOCOL_H__ +#define __STATUS_CODE_RUNTIME_PROTOCOL_H__ + +#define EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID \ + { 0xd2b2b828, 0x826, 0x48a7, 0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0} + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +typedef +EFI_STATUS +(EFIAPI *EFI_REPORT_STATUS_CODE) ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +/*++ +Routine Description: + + Provides an interface that a software module can call to report a status code. + +Arguments: + + Type - Indicates the type of status code being reported. + + Value - Describes the current status of a hardware or software entity. + This included information about the class and subclass that is + used to classify the entity as well as an operation. + + Instance - The enumeration of a hardware or software entity within + the system. Valid instance numbers start with 1. + + CallerId - This optional parameter may be used to identify the caller. + This parameter allows the status code driver to apply different + rules to different callers. + + Data - This optional parameter may be used to pass additional data. + +Returns: + + EFI_SUCCESS - The function completed successfully + + EFI_DEVICE_ERROR - The function should not be completed due to a device error. + +--*/ +; +#endif + +// +// Interface stucture for the STATUS CODE Architectural Protocol +// +typedef struct _EFI_STATUS_CODE_PROTOCOL { + EFI_REPORT_STATUS_CODE ReportStatusCode; +} EFI_STATUS_CODE_PROTOCOL; + +/*++ +// Protocol Description: +// +// Provides the service required to report a status code to the platform firmware. +// This protocol must be produced by a runtime DXE driver and may be consumed +// only by the DXE Foundation. +// +// Parameter: +// +// ReportStatusCode - Emit a status code. +--*/ + + +extern EFI_GUID gEfiStatusCodeRuntimeProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c new file mode 100644 index 0000000000..0d1d2ec81e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Timer.c + +Abstract: + + Timer Architectural Protocol GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Timer) + +EFI_GUID gEfiTimerArchProtocolGuid = EFI_TIMER_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiTimerArchProtocolGuid, "Timer", "Timer Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h new file mode 100644 index 0000000000..76ec85a7fe --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h @@ -0,0 +1,260 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Timer.h + +Abstract: + + Timer Architectural Protocol as defined in the DXE CIS + + This code is used to provide the timer tick for the DXE core. + +--*/ + +#ifndef _ARCH_PROTOCOL_TIMER_H_ +#define _ARCH_PROTOCOL_TIMER_H_ + +// +// Global ID for the Timer Architectural Protocol +// +#define EFI_TIMER_ARCH_PROTOCOL_GUID \ + { 0x26baccb3, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } + +// +// Declare forward reference for the Timer Architectural Protocol +// +EFI_FORWARD_DECLARATION (EFI_TIMER_ARCH_PROTOCOL); + +typedef +VOID +(EFIAPI *EFI_TIMER_NOTIFY) ( + IN UINT64 Time + ); +/*++ + +Routine Description: + + This function of this type is called when a timer interrupt fires. This + function executes at TPL_HIGH_LEVEL. The DXE Core will register a funtion + of tyis type to be called for the timer interrupt, so it can know how much + time has passed. This information is used to signal timer based events. + +Arguments: + + Time - Time since the last timer interrupt in 100 ns units. This will + typically be TimerPeriod, but if a timer interrupt is missed, and the + EFI_TIMER_ARCH_PROTOCOL driver can detect missed interrupts, then Time + will contain the actual amount of time since the last interrupt. + +Returns: + + None. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_TIMER_REGISTER_HANDLER) ( + IN EFI_TIMER_ARCH_PROTOCOL *This, + IN EFI_TIMER_NOTIFY NotifyFunction +); +/*++ + +Routine Description: + + This function registers the handler NotifyFunction so it is called every time + the timer interrupt fires. It also passes the amount of time since the last + handler call to the NotifyFunction. If NotifyFunction is NULL, then the + handler is unregistered. If the handler is registered, then EFI_SUCCESS is + returned. If the CPU does not support registering a timer interrupt handler, + then EFI_UNSUPPORTED is returned. If an attempt is made to register a handler + when a handler is already registered, then EFI_ALREADY_STARTED is returned. + If an attempt is made to unregister a handler when a handler is not registered, + then EFI_INVALID_PARAMETER is returned. If an error occurs attempting to + register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR + is returned. + +Arguments: + + This - The EFI_TIMER_ARCH_PROTOCOL instance. + + NotifyFunction - The function to call when a timer interrupt fires. This + function executes at TPL_HIGH_LEVEL. The DXE Core will + register a handler for the timer interrupt, so it can know + how much time has passed. This information is used to + signal timer based events. NULL will unregister the handler. + +Returns: + + EFI_SUCCESS - The timer handler was registered. + + EFI_UNSUPPORTED - The platform does not support timer interrupts. + + EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already + registered. + + EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not + previously registered. + + EFI_DEVICE_ERROR - The timer handler could not be registered. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_TIMER_SET_TIMER_PERIOD) ( + IN EFI_TIMER_ARCH_PROTOCOL *This, + IN UINT64 TimerPeriod + ); +/*++ + +Routine Description: + + This function adjusts the period of timer interrupts to the value specified + by TimerPeriod. If the timer period is updated, then the selected timer + period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If + the timer hardware is not programmable, then EFI_UNSUPPORTED is returned. + If an error occurs while attempting to update the timer period, then the + timer hardware will be put back in its state prior to this call, and + EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt + is disabled. This is not the same as disabling the CPU's interrupts. + Instead, it must either turn off the timer hardware, or it must adjust the + interrupt controller so that a CPU interrupt is not generated when the timer + interrupt fires. + +Arguments: + + This - The EFI_TIMER_ARCH_PROTOCOL instance. + + TimerPeriod - The rate to program the timer interrupt in 100 nS units. If + the timer hardware is not programmable, then EFI_UNSUPPORTED is + returned. If the timer is programmable, then the timer period + will be rounded up to the nearest timer period that is supported + by the timer hardware. If TimerPeriod is set to 0, then the + timer interrupts will be disabled. + +Returns: + + EFI_SUCCESS - The timer period was changed. + + EFI_UNSUPPORTED - The platform cannot change the period of the timer interrupt. + + EFI_DEVICE_ERROR - The timer period could not be changed due to a device error. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_TIMER_GET_TIMER_PERIOD) ( + IN EFI_TIMER_ARCH_PROTOCOL *This, + OUT UINT64 *TimerPeriod + ); +/*++ + +Routine Description: + + This function retrieves the period of timer interrupts in 100 ns units, + returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod + is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is + returned, then the timer is currently disabled. + +Arguments: + + This - The EFI_TIMER_ARCH_PROTOCOL instance. + + TimerPeriod - A pointer to the timer period to retrieve in 100 ns units. If + 0 is returned, then the timer is currently disabled. + +Returns: + + EFI_SUCCESS - The timer period was returned in TimerPeriod. + + EFI_INVALID_PARAMETER - TimerPeriod is NULL. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_TIMER_GENERATE_SOFT_INTERRUPT) ( + IN EFI_TIMER_ARCH_PROTOCOL *This + ); +/*++ + +Routine Description: + + This function generates a soft timer interrupt. If the platform does not support soft + timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned. + If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler() + service, then a soft timer interrupt will be generated. If the timer interrupt is + enabled when this service is called, then the registered handler will be invoked. The + registered handler should not be able to distinguish a hardware-generated timer + interrupt from a software-generated timer interrupt. + +Arguments: + + This - The EFI_TIMER_ARCH_PROTOCOL instance. + +Returns: + + EFI_SUCCESS - The soft timer interrupt was generated. + + EFI_UNSUPPORTEDT - The platform does not support the generation of soft timer interrupts. + +--*/ + +// +// Interface stucture for the Timer Architectural Protocol +// +typedef struct _EFI_TIMER_ARCH_PROTOCOL { + EFI_TIMER_REGISTER_HANDLER RegisterHandler; + EFI_TIMER_SET_TIMER_PERIOD SetTimerPeriod; + EFI_TIMER_GET_TIMER_PERIOD GetTimerPeriod; + EFI_TIMER_GENERATE_SOFT_INTERRUPT GenerateSoftInterrupt; +} EFI_TIMER_ARCH_PROTOCOL; + +/*++ + + Protocol Description: + This protocol provides the services to initialize a periodic timer + interrupt, and to register a handler that is called each time the timer + interrupt fires. It may also provide a service to adjust the rate of the + periodic timer interrupt. When a timer interrupt occurs, the handler is + passed the amount of time that has passed since the previous timer + interrupt. + + Parameters: + + RegisterHandler - Registers a handler that will be called each time the + timer interrupt fires. TimerPeriod defines the minimum + time between timer interrupts, so TimerPeriod will also + be the minimum time between calls to the registered + handler. + + SetTimerPeriod - Sets the period of the timer interrupt in 100 nS units. + This function is optional, and may return EFI_UNSUPPORTED. + If this function is supported, then the timer period will + be rounded up to the nearest supported timer period. + + GetTimerPeriod - Retrieves the period of the timer interrupt in 100 nS units. + + GenerateSoftInterrupt - + Generates a soft timer interrupt that simulates the firing of + the timer interrupt. This service can be used to invoke the + registered handler if the timer interrupt has been masked for + a period of time. + +--*/ + +extern EFI_GUID gEfiTimerArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c new file mode 100644 index 0000000000..eb6ddb0405 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Variable.c + +Abstract: + + Variable Architectural Protocol as defined in Tiano + + This code is used to produce the EFI 1.0 runtime variable services + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (Variable) + +EFI_GUID gEfiVariableArchProtocolGuid = EFI_VARIABLE_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiVariableArchProtocolGuid, "Variable", "Variable Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h new file mode 100644 index 0000000000..bee321d7d7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Variable.h + +Abstract: + + Variable Architectural Protocol as defined in the DXE CIS + + This code is used to produce the EFI 1.0 runtime variable services + + The GetVariable (), GetNextVariableName (), and SetVariable () EFI 1.0 + services are added to the EFI system table and the + EFI_VARIABLE_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer. + + No CRC of the EFI system table is required, as it is done in the DXE core. + +--*/ + +#ifndef _ARCH_PROTOCOL_VARIABLE_ARCH_H_ +#define _ARCH_PROTOCOL_VARIABLE_ARCH_H_ + +// +// Global ID for the Variable Architectural Protocol +// +#define EFI_VARIABLE_ARCH_PROTOCOL_GUID \ + { 0x1e5668e2, 0x8481, 0x11d4, 0xbc, 0xf1, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } + +extern EFI_GUID gEfiVariableArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c new file mode 100644 index 0000000000..449b205524 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VariableWrite.c + +Abstract: + + Variable Write Architectural Protocol as defined in DXE CIS + + This code is used to indicate the EFI 1.0 runtime variable services + support writting to variables. + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (VariableWrite) + +EFI_GUID gEfiVariableWriteArchProtocolGuid = EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiVariableWriteArchProtocolGuid, "VariableWrite", "Variable Write Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h new file mode 100644 index 0000000000..2a1237de7a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VariableWrite.h + +Abstract: + + Variable Write Architectural Protocol as defined in the DXE CIS + + This code is used to produce the EFI 1.0 runtime variable services + + The GetVariable (), GetNextVariableName (), and SetVariable () EFI 1.0 + services are added to the EFI system table and the + EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer. + + No CRC of the EFI system table is required, as it is done in the DXE core. + +--*/ + +#ifndef _ARCH_PROTOCOL_VARIABLE_WRITE_ARCH_H_ +#define _ARCH_PROTOCOL_VARIABLE_WRITE_ARCH_H_ + +// +// Global ID for the Variable Write Architectural Protocol +// +#define EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID \ + { 0x6441f818, 0x6362, 0x4e44, 0xb5, 0x70, 0x7d, 0xba, 0x31, 0xdd, 0x24, 0x53 } + +extern EFI_GUID gEfiVariableWriteArchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c new file mode 100644 index 0000000000..9560847e07 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WatchdogTimer.c + +Abstract: + + Watchdog Timer Architectural Protocol GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer) + +EFI_GUID gEfiWatchdogTimerArchProtocolGuid = EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiWatchdogTimerArchProtocolGuid, "Watchdog Timer", "Watchdog Timer Arch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h new file mode 100644 index 0000000000..4ebecfa369 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h @@ -0,0 +1,206 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WatchdogTimer.h + +Abstract: + + Watchdog Timer Architectural Protocol as defined in the DXE CIS + + Used to provide system watchdog timer services + +--*/ + +#ifndef _ARCH_PROTOCOL_WATCHDOG_TIMER_H_ +#define _ARCH_PROTOCOL_WATCHDOG_TIMER_H_ + +// +// Global ID for the Watchdog Timer Architectural Protocol +// +#define EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID \ + { 0x665E3FF5, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } + +// +// Declare forward reference for the Timer Architectural Protocol +// +EFI_FORWARD_DECLARATION (EFI_WATCHDOG_TIMER_ARCH_PROTOCOL); + +typedef +VOID +(EFIAPI *EFI_WATCHDOG_TIMER_NOTIFY) ( + IN UINT64 Time + ); +/*++ + +Routine Description: + + A function of this type is called when the watchdog timer fires if a + handler has been registered. + +Arguments: + + Time - The time in 100 ns units that has passed since the watchdog + timer was armed. For the notify function to be called, this + must be greater than TimerPeriod. + +Returns: + + None. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_WATCHDOG_TIMER_REGISTER_HANDLER) ( + IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, + IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction + ); +/*++ + +Routine Description: + + This function registers a handler that is to be invoked when the watchdog + timer fires. By default, the EFI_WATCHDOG_TIMER protocol will call the + Runtime Service ResetSystem() when the watchdog timer fires. If a + NotifyFunction is registered, then the NotifyFunction will be called before + the Runtime Service ResetSystem() is called. If NotifyFunction is NULL, then + the watchdog handler is unregistered. If a watchdog handler is registered, + then EFI_SUCCESS is returned. If an attempt is made to register a handler + when a handler is already registered, then EFI_ALREADY_STARTED is returned. + If an attempt is made to uninstall a handler when a handler is not installed, + then return EFI_INVALID_PARAMETER. + +Arguments: + + This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance. + + NotifyFunction - The function to call when the watchdog timer fires. If this + is NULL, then the handler will be unregistered. + +Returns: + + EFI_SUCCESS - The watchdog timer handler was registered or + unregistered. + + EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already + registered. + + EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not + previously registered. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD) ( + IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, + IN UINT64 TimerPeriod + ); +/*++ + +Routine Description: + + This function sets the amount of time to wait before firing the watchdog + timer to TimerPeriod 100 nS units. If TimerPeriod is 0, then the watchdog + timer is disabled. + +Arguments: + + This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance. + + TimerPeriod - The amount of time in 100 nS units to wait before the watchdog + timer is fired. If TimerPeriod is zero, then the watchdog + timer is disabled. + +Returns: + + EFI_SUCCESS - The watchdog timer has been programmed to fire in Time + 100 nS units. + + EFI_DEVICE_ERROR - A watchdog timer could not be programmed due to a device + error. + +--*/ + +typedef +EFI_STATUS +(EFIAPI *EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD) ( + IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, + OUT UINT64 *TimerPeriod + ); +/*++ + +Routine Description: + + This function retrieves the amount of time the system will wait before firing + the watchdog timer. This period is returned in TimerPeriod, and EFI_SUCCESS + is returned. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned. + +Arguments: + + This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance. + + TimerPeriod - A pointer to the amount of time in 100 nS units that the system + will wait before the watchdog timer is fired. If TimerPeriod of + zero is returned, then the watchdog timer is disabled. + +Returns: + + EFI_SUCCESS - The amount of time that the system will wait before + firing the watchdog timer was returned in TimerPeriod. + + EFI_INVALID_PARAMETER - TimerPeriod is NULL. + +--*/ + +// +// Interface stucture for the Watchdog Timer Architectural Protocol +// +typedef struct _EFI_WATCHDOG_TIMER_ARCH_PROTOCOL { + EFI_WATCHDOG_TIMER_REGISTER_HANDLER RegisterHandler; + EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD SetTimerPeriod; + EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD GetTimerPeriod; +} EFI_WATCHDOG_TIMER_ARCH_PROTOCOL; + +/*++ + + Protocol Description: + This protocol provides the services required to implement the Boot Service + SetWatchdogTimer(). It provides a service to set the amount of time to wait + before firing the watchdog timer, and it also provides a service to register + a handler that is invoked when the watchdog timer fires. This protocol can + implement the watchdog timer by using the event and timer Boot Services, or + it can make use of custom hardware. When the watchdog timer fires, control + will be passed to a handler if one has been registered. If no handler has + been registered, or the registered handler returns, then the system will be + reset by calling the Runtime Service ResetSystem(). + + Parameters: + + RegisterHandler - Registers a handler that is invoked when the watchdog + timer fires. + + SetTimerPeriod - Sets the amount of time in 100 ns units to wait before the + watchdog timer is fired. If this function is supported, + then the watchdog timer period will be rounded up to the + nearest supported watchdog timer period. + + GetTimerPeriod - Retrieves the amount of time in 100 ns units that the + system will wait before the watchdog timer is fired. + +--*/ + +extern EFI_GUID gEfiWatchdogTimerArchProtocolGuid; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf new file mode 100644 index 0000000000..62a3c49b0e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf @@ -0,0 +1,37 @@ +#/*++ +# +# Copyright (c) 2004 - 2005, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CpuIA64Lib.inf +# +# Abstract: +# +# Component description file for the Cpu IA64 library. +# +#--*/ + +[defines] +BASE_NAME = CpuIA64Lib +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ipf] + Ipf\CpuIA64.s + +[includes.common] + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Cpu\Itanium\Include + $(EDK_SOURCE)\Foundation\include + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s new file mode 100644 index 0000000000..ddf5984e1a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/Ipf/CpuIa64.s @@ -0,0 +1,33 @@ +//**************************************************************************** +// +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// CpuIA64.s +// +// Abstract: +// +// Contains basic assembly procedures to support IPF CPU. +// +//**************************************************************************** + +.file "CpuIA64.s" + +#include "IpfMacro.i" +#include "IpfDefines.h" + + +PROCEDURE_ENTRY (EfiReadTsc) + + mov r8 = ar.itc + br.ret.dpnt b0;; + +PROCEDURE_EXIT (EfiReadTsc) \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Itanium/Include/CpuIa64.h b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/Include/CpuIa64.h new file mode 100644 index 0000000000..c90cfe70c3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Itanium/Include/CpuIa64.h @@ -0,0 +1,39 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuIA64.h + +Abstract: + +--*/ + +#ifndef _CPU_IA64_H +#define _CPU_IA64_H + +#include "Tiano.h" + +UINT64 +EfiReadTsc ( + VOID + ) +/*++ +Routine Description: + Read Time stamp +Arguments: + None +Returns: + Return the read data +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf new file mode 100644 index 0000000000..09a464b941 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf @@ -0,0 +1,42 @@ +#/*++ +# +# Copyright (c) 2004 - 2005, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CpuIA32Lib.inf +# +# Abstract: +# +# Component description file for the Cpu IA32 library. +# +#--*/ + +[defines] +BASE_NAME = CpuIA32Lib +COMPONENT_TYPE = LIBRARY + +[sources.common] + EfiCpuVersion.c + +[sources.ia32] + Ia32\CpuIA32.c + +[sources.x64] + x64\Cpu.asm +[includes.common] + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + . + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Include + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c new file mode 100644 index 0000000000..192469fecf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c @@ -0,0 +1,73 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCpuVersion.c + +Abstract: + + Provide cpu version extract considering extended family & model ID. +--*/ + +#include "CpuIA32.h" + +VOID +EfiCpuVersion ( + IN OUT UINT16 *FamilyId, OPTIONAL + IN OUT UINT8 *Model, OPTIONAL + IN OUT UINT8 *SteppingId, OPTIONAL + IN OUT UINT8 *Processor OPTIONAL + ) +/*++ + +Routine Description: + Extract CPU detail version infomation + +Arguments: + FamilyId - FamilyId, including ExtendedFamilyId + Model - Model, including ExtendedModel + SteppingId - SteppingId + Processor - Processor + +--*/ +{ + EFI_CPUID_REGISTER Register; + UINT8 TempFamilyId; + + EfiCpuid (EFI_CPUID_VERSION_INFO, &Register); + + if (SteppingId != NULL) { + *SteppingId = (UINT8) (Register.RegEax & 0xF); + } + + if (Processor != NULL) { + *Processor = (UINT8) ((Register.RegEax >> 12) & 0x3); + } + + if (Model != NULL || FamilyId != NULL) { + TempFamilyId = (UINT8) ((Register.RegEax >> 8) & 0xF); + + if (Model != NULL) { + *Model = (UINT8) ((Register.RegEax >> 4) & 0xF); + if (TempFamilyId == 0x6 || TempFamilyId == 0xF) { + *Model |= (Register.RegEax >> 12) & 0xF0; + } + } + + if (FamilyId != NULL) { + *FamilyId = TempFamilyId; + if (TempFamilyId == 0xF) { + *FamilyId = *FamilyId + (UINT16) ((Register.RegEax >> 20) & 0xFF); + } + } + } +} diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c new file mode 100644 index 0000000000..4956179bab --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c @@ -0,0 +1,179 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuIA32.c + +Abstract: + +--*/ + +#include "CpuIA32.h" + +VOID +EfiHalt (VOID) +{ + __asm { + hlt + } +} + +VOID +EfiWbinvd (VOID) +{ + __asm { + wbinvd + } +} + +VOID +EfiInvd (VOID) +{ + __asm { + invd + } +} + +VOID +EfiCpuid (IN UINT32 RegisterInEax, + OUT EFI_CPUID_REGISTER *Reg OPTIONAL) +{ + __asm { + pushad + + mov eax, RegisterInEax + cpuid + cmp Reg, 0 + je _Exit + mov edi, DWORD PTR Reg + + mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax + mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx + mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx + mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx + +_Exit: + popad + } +} + +UINT64 +EfiReadMsr (IN UINT32 Index) +{ + __asm { + mov ecx, Index + rdmsr + } +} + +VOID +EfiWriteMsr ( + IN UINT32 Index, + IN UINT64 Value + ) +{ + __asm { + mov ecx, Index + mov eax, DWORD PTR Value[0] + mov edx, DWORD PTR Value[4] + wrmsr + } +} + +UINT64 +EfiReadTsc (VOID) +{ + __asm { + rdtsc + } +} + +VOID +EfiDisableCache (VOID) +{ + __asm { + mov eax, cr0 + bswap eax + and al, 60h + cmp al, 60h + je Exit + wbinvd + mov eax, cr0 + or eax, 060000000h + mov cr0, eax +Exit: + } +} + +VOID +EfiEnableCache (VOID) +{ + __asm { + invd + mov eax, cr0 + and eax, 09fffffffh + mov cr0, eax + } +} + +UINT32 +EfiGetEflags ( + VOID + ) +{ + __asm { + pushfd + pop eax + } +} + +VOID +EfiDisableInterrupts (VOID) +{ + __asm { + cli + } +} + +VOID +EfiEnableInterrupts ( + VOID + ) +{ + __asm { + sti + } +} + +VOID +EfiCpuidExt ( + IN UINT32 RegisterInEax, + IN UINT32 CacheLevel, + OUT EFI_CPUID_REGISTER *Regs + ) +{ + __asm { + pushad + + mov eax, RegisterInEax + mov ecx, CacheLevel + cpuid + mov edi, DWORD PTR Regs + + mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax + mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx + mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx + mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx + + popad + } +} diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm new file mode 100644 index 0000000000..8e46f9b69f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm @@ -0,0 +1,215 @@ +TITLE Cpu.asm: Assembly code for the x64 resources + +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2005 - 2007, Intel Corporation +;* All rights reserved. This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* Module Name: +;* +;* Cpu.asm +;* +;* Abstract: +;* +;------------------------------------------------------------------------------ + +text SEGMENT + + +;------------------------------------------------------------------------------ +; VOID +; EfiHalt ( +; VOID +; ) +;------------------------------------------------------------------------------ +EfiHalt PROC PUBLIC + hlt + ret +EfiHalt ENDP + + +;------------------------------------------------------------------------------ +; VOID +; EfiWbinvd ( +; VOID +; ) +;------------------------------------------------------------------------------ +EfiWbinvd PROC PUBLIC + wbinvd + ret +EfiWbinvd ENDP + + +;------------------------------------------------------------------------------ +; VOID +; EfiInvd ( +; VOID +; ) +;------------------------------------------------------------------------------ +EfiInvd PROC PUBLIC + invd + ret +EfiInvd ENDP + +;------------------------------------------------------------------------------ +; VOID +; EfiCpuid ( +; IN UINT32 RegisterInEax, // rcx +; OUT EFI_CPUID_REGISTER *Reg OPTIONAL // rdx +; ) +;------------------------------------------------------------------------------ +EfiCpuid PROC PUBLIC + push rbx + + mov r8, rdx ; r8 = *Reg + mov rax, rcx ; RegisterInEax + cpuid + cmp r8, 0 + je _Exit + mov [r8 + 0], eax ; Reg->RegEax + mov [r8 + 4], ebx ; Reg->RegEbx + mov [r8 + 8], ecx ; Reg->RegEcx + mov [r8 + 12], edx ; Reg->RegEdx + +_Exit: + pop rbx + ret +EfiCpuid ENDP + +;------------------------------------------------------------------------------ +; UINT64 +; EfiReadMsr ( +; IN UINT32 Index, // rcx +; ) +;------------------------------------------------------------------------------ +EfiReadMsr PROC PUBLIC + rdmsr + sal rdx, 32 ; edx:eax -> rax + or rax, rdx ; rax = edx:eax + ret +EfiReadMsr ENDP + +;------------------------------------------------------------------------------ +; VOID +; EfiWriteMsr ( +; IN UINT32 Index, // rcx +; IN UINT64 Value // rdx +; ) +;------------------------------------------------------------------------------ +EfiWriteMsr PROC PUBLIC + mov rax, rdx ; rdx = Value + sar rdx, 32 ; convert rdx to edx upper 32-bits + wrmsr ; wrmsr[ecx] result = edx:eax + ret +EfiWriteMsr ENDP + + +;------------------------------------------------------------------------------ +; UINT64 +; EfiReadTsc ( +; VOID +; ); +;------------------------------------------------------------------------------ +EfiReadTsc PROC PUBLIC + rdtsc + shl rax, 32 + shrd rax, rdx, 32 + ret +EfiReadTsc ENDP + +;------------------------------------------------------------------------------ +; VOID +; EfiDisableCache ( +; VOID +; ); +;------------------------------------------------------------------------------ +EfiDisableCache PROC PUBLIC +; added a check to see if cache is already disabled. If it is, then skip. + mov rax, cr0 + and rax, 060000000h + cmp rax, 0 + jne @f + wbinvd + mov rax, cr0 + or rax, 060000000h + mov cr0, rax +@@: + ret +EfiDisableCache ENDP + +;------------------------------------------------------------------------------ +; VOID +; EfiEnableCache ( +; VOID +; ); +;------------------------------------------------------------------------------ +EfiEnableCache PROC PUBLIC + invd + mov rax, cr0 + and rax, 09fffffffh + mov cr0, rax + ret +EfiEnableCache ENDP + +;------------------------------------------------------------------------------ +; UINTN +; EfiGetEflags ( +; VOID +; ); +;------------------------------------------------------------------------------ +EfiGetEflags PROC PUBLIC + pushfq + pop rax + ret +EfiGetEflags ENDP + +;------------------------------------------------------------------------------ +; VOID +; EfiDisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +EfiDisableInterrupts PROC PUBLIC + cli + ret +EfiDisableInterrupts ENDP + +;------------------------------------------------------------------------------ +; VOID +; EfiEnableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +EfiEnableInterrupts PROC PUBLIC + sti + ret +EfiEnableInterrupts ENDP +;------------------------------------------------------------------------------ +; VOID +; EfiCpuidExt ( +; IN UINT32 RegisterInEax, +; IN UINT32 CacheLevel, +; OUT EFI_CPUID_REGISTER *Regs +; ) +;------------------------------------------------------------------------------ +EfiCpuidExt PROC PUBLIC + push rbx + mov rax, rcx ; rax = RegisterInEax + mov rcx, rdx ; rcx = CacheLevel + + cpuid + mov [r8 + 0 ], eax ; Reg->RegEax + mov [r8 + 4 ], ebx ; Reg->RegEbx + mov [r8 + 8 ], ecx ; Reg->RegEcx + mov [r8 + 12], edx ; Reg->RegEdx + + pop rbx + ret +EfiCpuidExt ENDP +END diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/Include/CpuIA32.h b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/Include/CpuIA32.h new file mode 100644 index 0000000000..a7fe8b0005 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/Include/CpuIA32.h @@ -0,0 +1,372 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuIA32.h + +Abstract: + +--*/ + +#ifndef _CPU_IA32_H +#define _CPU_IA32_H + +#include "Tiano.h" + +#define IA32API __cdecl + +typedef struct { + UINT32 RegEax; + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; +} EFI_CPUID_REGISTER; + +typedef struct { + UINT32 HeaderVersion; + UINT32 UpdateRevision; + UINT32 Date; + UINT32 ProcessorId; + UINT32 Checksum; + UINT32 LoaderRevision; + UINT32 ProcessorFlags; + UINT32 DataSize; + UINT32 TotalSize; + UINT8 Reserved[12]; +} EFI_CPU_MICROCODE_HEADER; + +typedef struct { + UINT32 ExtendedSignatureCount; + UINT32 ExtendedTableChecksum; + UINT8 Reserved[12]; +} EFI_CPU_MICROCODE_EXTENDED_TABLE_HEADER; + +typedef struct { + UINT32 ProcessorSignature; + UINT32 ProcessorFlag; + UINT32 ProcessorChecksum; +} EFI_CPU_MICROCODE_EXTENDED_TABLE; + +typedef struct { + UINT32 Stepping : 4; + UINT32 Model : 4; + UINT32 Family : 4; + UINT32 Type : 2; + UINT32 Reserved1 : 2; + UINT32 ExtendedModel : 4; + UINT32 ExtendedFamily : 8; + UINT32 Reserved2 : 4; +} EFI_CPU_VERSION; + +#define EFI_CPUID_SIGNATURE 0x0 +#define EFI_CPUID_VERSION_INFO 0x1 +#define EFI_CPUID_CACHE_INFO 0x2 +#define EFI_CPUID_SERIAL_NUMBER 0x3 +#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000 +#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001 +#define EFI_CPUID_BRAND_STRING1 0x80000002 +#define EFI_CPUID_BRAND_STRING2 0x80000003 +#define EFI_CPUID_BRAND_STRING3 0x80000004 + +#define EFI_MSR_IA32_PLATFORM_ID 0x17 +#define EFI_MSR_IA32_APIC_BASE 0x1B +#define EFI_MSR_EBC_HARD_POWERON 0x2A +#define EFI_MSR_EBC_SOFT_POWERON 0x2B +#define BINIT_DRIVER_DISABLE 0x40 +#define INTERNAL_MCERR_DISABLE 0x20 +#define INITIATOR_MCERR_DISABLE 0x10 +#define EFI_MSR_EBC_FREQUENCY_ID 0x2C +#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79 +#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B +#define EFI_MSR_PSB_CLOCK_STATUS 0xCD +#define EFI_APIC_GLOBAL_ENABLE 0x800 +#define EFI_MSR_IA32_MISC_ENABLE 0x1A0 +#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000 +#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008 +#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004 +#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002 +#define FAST_STRING_ENABLE_BIT 0x00000001 + +#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200 +#define EFI_CACHE_VARIABLE_MTRR_END 0x20F +#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF +#define EFI_CACHE_MTRR_VALID 0x800 +#define EFI_CACHE_FIXED_MTRR_VALID 0x400 +#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000 +#define EFI_MSR_VALID_MASK 0xFFFFFFFFF +#define EFI_CACHE_VALID_EXTENDED_ADDRESS 0xFFFFFFFFFF000 +#define EFI_MSR_VALID_EXTENDED_MASK 0xFFFFFFFFFFFFF + +#define EFI_IA32_MTRR_FIX64K_00000 0x250 +#define EFI_IA32_MTRR_FIX16K_80000 0x258 +#define EFI_IA32_MTRR_FIX16K_A0000 0x259 +#define EFI_IA32_MTRR_FIX4K_C0000 0x268 +#define EFI_IA32_MTRR_FIX4K_C8000 0x269 +#define EFI_IA32_MTRR_FIX4K_D0000 0x26A +#define EFI_IA32_MTRR_FIX4K_D8000 0x26B +#define EFI_IA32_MTRR_FIX4K_E0000 0x26C +#define EFI_IA32_MTRR_FIX4K_E8000 0x26D +#define EFI_IA32_MTRR_FIX4K_F0000 0x26E +#define EFI_IA32_MTRR_FIX4K_F8000 0x26F + +#define EFI_IA32_MCG_CAP 0x179 +#define EFI_IA32_MCG_CTL 0x17B +#define EFI_IA32_MC0_CTL 0x400 +#define EFI_IA32_MC0_STATUS 0x401 + +#define EFI_IA32_PERF_STATUS 0x198 +#define EFI_IA32_PERF_CTL 0x199 + +#define EFI_CACHE_UNCACHEABLE 0 +#define EFI_CACHE_WRITECOMBINING 1 +#define EFI_CACHE_WRITETHROUGH 4 +#define EFI_CACHE_WRITEPROTECTED 5 +#define EFI_CACHE_WRITEBACK 6 + +// +// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number +// +#define EfiMakeCpuVersion(f, m, s) \ + (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s))) + +VOID +IA32API +EfiHalt ( + VOID + ) +; + +/*++ +Routine Description: + Halt the Cpu +Arguments: + None +Returns: + None +--*/ +VOID +IA32API +EfiWbinvd ( + VOID + ) +; + +/*++ +Routine Description: + Write back and invalidate the Cpu cache +Arguments: + None +Returns: + None +--*/ +VOID +IA32API +EfiInvd ( + VOID + ) +; + +/*++ +Routine Description: + Invalidate the Cpu cache +Arguments: + None +Returns: + None +--*/ +VOID +IA32API +EfiCpuid ( + IN UINT32 RegisterInEax, + OUT EFI_CPUID_REGISTER *Regs + ) +; + +/*++ +Routine Description: + Get the Cpu info by excute the CPUID instruction +Arguments: + RegisterInEax: -The input value to put into register EAX + Regs: -The Output value +Returns: + None +--*/ + +VOID +IA32API +EfiCpuidExt ( + IN UINT32 RegisterInEax, + IN UINT32 CacheLevel, + OUT EFI_CPUID_REGISTER *Regs + ) +/*++ +Routine Description: + When RegisterInEax != 4, the functionality is the same as EfiCpuid. + When RegisterInEax == 4, the function return the deterministic cache + parameters by excuting the CPUID instruction +Arguments: + RegisterInEax: - The input value to put into register EAX + CacheLevel: - The deterministic cache level + Regs: - The Output value +Returns: + None +--*/ +; + +UINT64 +IA32API +EfiReadMsr ( + IN UINT32 Index + ) +; + +/*++ +Routine Description: + Read Cpu MSR +Arguments: + Index: -The index value to select the register + +Returns: + Return the read data +--*/ +VOID +IA32API +EfiWriteMsr ( + IN UINT32 Index, + IN UINT64 Value + ) +; + +/*++ +Routine Description: + Write Cpu MSR +Arguments: + Index: -The index value to select the register + Value: -The value to write to the selected register +Returns: + None +--*/ +UINT64 +IA32API +EfiReadTsc ( + VOID + ) +; + +/*++ +Routine Description: + Read Time stamp +Arguments: + None +Returns: + Return the read data +--*/ +VOID +IA32API +EfiDisableCache ( + VOID + ) +; + +/*++ +Routine Description: + Writing back and invalidate the cache,then diable it +Arguments: + None +Returns: + None +--*/ +VOID +IA32API +EfiEnableCache ( + VOID + ) +; + +/*++ +Routine Description: + Invalidate the cache,then Enable it +Arguments: + None +Returns: + None +--*/ +UINT32 +IA32API +EfiGetEflags ( + VOID + ) +; + +/*++ +Routine Description: + Get Eflags +Arguments: + None +Returns: + Return the Eflags value +--*/ +VOID +IA32API +EfiDisableInterrupts ( + VOID + ) +; + +/*++ +Routine Description: + Disable Interrupts +Arguments: + None +Returns: + None +--*/ +VOID +IA32API +EfiEnableInterrupts ( + VOID + ) +; + +/*++ +Routine Description: + Enable Interrupts +Arguments: + None +Returns: + None +--*/ + + +VOID +IA32API +EfiCpuVersion ( + IN UINT16 *FamilyId, OPTIONAL + IN UINT8 *Model, OPTIONAL + IN UINT8 *SteppingId, OPTIONAL + IN UINT8 *Processor OPTIONAL + ) +/*++ + +Routine Description: + Extract CPU detail version infomation + +Arguments: + FamilyId - FamilyId, including ExtendedFamilyId + Model - Model, including ExtendedModel + SteppingId - SteppingId + Processor - Processor + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.c new file mode 100644 index 0000000000..b39a173c65 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.c @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Acpi.c + +Abstract: + + GUIDs used for ACPI entries in the EFI 1.0 system table + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (Acpi) + +EFI_GUID gEfiAcpiTableGuid = EFI_ACPI_TABLE_GUID; + +EFI_GUID_STRING(&gEfiAcpiTableGuid, "ACPI Table", "ACPI 1.0 Table GUID in EFI System Table"); + +EFI_GUID gEfiAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; + +EFI_GUID_STRING(&gEfiAcpi20TableGuid, "ACPI 2.0 Table", "ACPI 2.0 Table GUID in EFI System Table"); + +EFI_GUID gEfiAcpi30TableGuid = EFI_ACPI_30_TABLE_GUID; + +EFI_GUID_STRING(&gEfiAcpi30TableGuid, "ACPI 3.0 Table", "ACPI 3.0 Table GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.h new file mode 100644 index 0000000000..866ad63915 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Acpi/Acpi.h @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Acpi.h + +Abstract: + + GUIDs used for ACPI entries in the in the EFI 1.0 system table + + These GUIDs point the ACPI tables as defined in the ACPI specifications. + ACPI 2.0 specification defines the ACPI 2.0 GUID. EFI 1.0 defines the + ACPI 1.0 GUID. + +--*/ + +#ifndef _ACPI_GUID_H_ +#define _ACPI_GUID_H_ + +#define EFI_ACPI_TABLE_GUID \ + { \ + 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +#define EFI_ACPI_20_TABLE_GUID \ + { \ + 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define EFI_ACPI_30_TABLE_GUID EFI_ACPI_20_TABLE_GUID + +extern EFI_GUID gEfiAcpiTableGuid; +extern EFI_GUID gEfiAcpi20TableGuid; +extern EFI_GUID gEfiAcpi30TableGuid; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c new file mode 100644 index 0000000000..2afb8348f1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugImageInfoTable.c + +Abstract: + + GUID used to locate the Debug Image Info table in the EFI 1.0 system table. + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (DebugImageInfoTable) + +EFI_GUID gEfiDebugImageInfoTableGuid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID; + +EFI_GUID_STRING + (&gEfiDebugImageInfoTableGuid, "Debug Image Info Table", "Debug Image Info Table GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h new file mode 100644 index 0000000000..e81ebb0ae9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h @@ -0,0 +1,63 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugImageInfoTable.h + +Abstract: + + GUID and related data structures used with the Debug Image Info Table. + +--*/ + +#ifndef _DEBUG_IMAGE_INFO_GUID_H_ +#define _DEBUG_IMAGE_INFO_GUID_H_ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (LoadedImage) + +#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \ + { \ + 0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b \ + } + +extern EFI_GUID gEfiDebugImageInfoTableGuid; + +#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01 +#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02 +#define EFI_DEBUG_IMAGE_INFO_INITIAL_SIZE (EFI_PAGE_SIZE / sizeof (UINTN)) +#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01 + +typedef struct { + UINT64 Signature; + EFI_PHYSICAL_ADDRESS EfiSystemTableBase; + UINT32 Crc32; +} EFI_SYSTEM_TABLE_POINTER; + +typedef struct { + UINT32 ImageInfoType; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance; + EFI_HANDLE *ImageHandle; +} EFI_DEBUG_IMAGE_INFO_NORMAL; + +typedef union { + UINT32 *ImageInfoType; + EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; +} EFI_DEBUG_IMAGE_INFO; + +typedef struct { + volatile UINT32 UpdateStatus; + UINT32 TableSize; + EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable; +} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/EfiGuidLib.inf b/EdkCompatibilityPkg/Foundation/Efi/Guid/EfiGuidLib.inf new file mode 100644 index 0000000000..cd43d9d6a5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/EfiGuidLib.inf @@ -0,0 +1,59 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiGuidLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME= EfiGuidLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + +[nmake.common] + +[sources.common] + Acpi\Acpi.h + Acpi\Acpi.c + DebugImageInfoTable\DebugImageInfoTable.h + DebugImageInfoTable\DebugImageInfoTable.c + EventGroup\EventGroup.h + EventGroup\EventGroup.c + GlobalVariable\GlobalVariable.h + GlobalVariable\GlobalVariable.c + Gpt\Gpt.h + Gpt\Gpt.c + HardwareErrorVariable\HardwareErrorVariable.h + HardwareErrorVariable\HardwareErrorVariable.c + Mps\Mps.h + Mps\Mps.c + PcAnsi\PcAnsi.h + PcAnsi\PcAnsi.c + SmBios\SmBios.h + SmBios\SmBios.c +[sources.ipf] + SalSystemTable\SalSystemTable.h + SalSystemTable\SalSystemTable.c diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.c new file mode 100644 index 0000000000..fe8a53c892 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiGroup.c + +--*/ +#include "Tiano.h" + +#include EFI_GUID_DEFINITION (EventGroup) + +EFI_GUID gEfiEventExitBootServicesGuid = EFI_EVENT_GROUP_EXIT_BOOT_SERVICES; +EFI_GUID gEfiEventVirtualAddressChangeGuid = EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE; +EFI_GUID gEfiEventMemoryMapChangeGuid = EFI_EVENT_GROUP_MEMORY_MAP_CHANGE; +EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT; + +EFI_GUID_STRING (&gEfiEventExitBootServicesGuid, "EventExitBS", "Event Exit Boot Service GUID"); +EFI_GUID_STRING (&gEfiEventVirtualAddressChangeGuid, "EventVirtualAddrChange", "Event Virtual Addr Change GUID"); +EFI_GUID_STRING (&gEfiEventMemoryMapChangeGuid, "EventMemMapChange", "Event Memory Map Change GUID"); +EFI_GUID_STRING (&gEfiEventReadyToBootGuid, "EventReadyToBoot", "Efi Ready To Boot GUID"); + diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.h new file mode 100644 index 0000000000..ac034a46fa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/EventGroup/EventGroup.h @@ -0,0 +1,45 @@ +/** @file + GUIDs for gBS->CreateEventEx Event Groups. Defined in UEFI 2.0. + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: EventGroup.h + +**/ + +#ifndef __EVENT_GROUP_GUID__ +#define __EVENT_GROUP_GUID__ + + +#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \ + { 0x27abf055, 0xb1b8, 0x4c26, { 0x80, 0x48, 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf } } + +extern EFI_GUID gEfiEventExitBootServicesGuid; + + +#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \ + { 0x13fa7698, 0xc831, 0x49c7, { 0x87, 0xea, 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96 } } + +extern EFI_GUID gEfiEventVirtualAddressChangeGuid; + + +#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \ + { 0x78bee926, 0x692f, 0x48fd, { 0x9e, 0xdb, 0x1, 0x42, 0x2e, 0xf0, 0xd7, 0xab } } + +extern EFI_GUID gEfiEventMemoryMapChangeGuid; + + +#define EFI_EVENT_GROUP_READY_TO_BOOT \ + { 0x7ce88fb3, 0x4bd7, 0x4679, { 0x87, 0xa8, 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b } } + +extern EFI_GUID gEfiEventReadyToBootGuid; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c new file mode 100644 index 0000000000..1f492c79de --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GlobalVariable.c + +Abstract: + + GUID for EFI (NVRAM) Variables. Defined in EFI 1.0. + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (GlobalVariable) + +EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE_GUID; + +EFI_GUID_STRING(&gEfiGlobalVariableGuid, "Efi", "Efi Variable GUID") diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h new file mode 100644 index 0000000000..c97a51f09b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GlobalVariable.h + +Abstract: + + GUID for EFI (NVRAM) Variables. Defined in EFI 1.0. + +--*/ + +#ifndef _GLOBAL_VARIABLE_GUID_H_ +#define _GLOBAL_VARIABLE_GUID_H_ + +#define EFI_GLOBAL_VARIABLE_GUID \ + { \ + 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C \ + } + +extern EFI_GUID gEfiGlobalVariableGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.c new file mode 100644 index 0000000000..ffd432fe55 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.c @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Gpt.c + +Abstract: + + Guids used for the GPT as defined in EFI 1.0 + + GPT defines a new disk partitioning scheme and also describes + usage of the legacy Master Boot Record (MBR) partitioning scheme. + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (Gpt) + +EFI_GUID gEfiPartTypeUnusedGuid = EFI_PART_TYPE_UNUSED_GUID; + +EFI_GUID_STRING(&gEfiPartTypeUnusedGuid, "G0", "Null Partition Type GUID"); + +EFI_GUID gEfiPartTypeSystemPartGuid = EFI_PART_TYPE_EFI_SYSTEM_PART_GUID; + +EFI_GUID_STRING(&gEfiPartTypeSystemPartGuid, "ESP", "EFI System Partition GUID"); + +EFI_GUID gEfiPartTypeLegacyMbrGuid = EFI_PART_TYPE_LEGACY_MBR_GUID; + +EFI_GUID_STRING(&gEfiPartTypeLegacyMbrGuid, "Legacy MBR", "Legacy Master Boot Record Partition GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.h new file mode 100644 index 0000000000..7733067e40 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Gpt/Gpt.h @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Gpt.h + +Abstract: + + Guids used for the GPT as defined in EFI 1.0 + + GPT defines a new disk partitioning scheme and also describes + usage of the legacy Master Boot Record (MBR) partitioning scheme. + +--*/ + +#ifndef _GPT_GUID_H_ +#define _GPT_GUID_H_ + +#define EFI_PART_TYPE_UNUSED_GUID \ + { \ + 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \ + } + +#define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \ + { \ + 0xc12a7328, 0xf81f, 0x11d2, 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b \ + } + +#define EFI_PART_TYPE_LEGACY_MBR_GUID \ + { \ + 0x024dee41, 0x33e7, 0x11d3, 0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f \ + } + +extern EFI_GUID gEfiPartTypeUnusedGuid; +extern EFI_GUID gEfiPartTypeSystemPartGuid; +extern EFI_GUID gEfiPartTypeLegacyMbrGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c new file mode 100644 index 0000000000..57dbb839d0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + HardwareErrorVariable.c + +Abstract: + + GUID for hardware error record variables. Defined in UEFI 2.1. + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (HardwareErrorVariable) + +EFI_GUID gEfiHardwareErrorVariableGuid = EFI_HARDWARE_ERROR_VARIABLE_GUID; + +EFI_GUID_STRING(&gEfiHardwareErrorVariableGuid, "HwErr", "Hardware Error Variable GUID") \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h new file mode 100644 index 0000000000..fae3fd1a37 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + HardwareErrorVariable.h + +Abstract: + + GUID for hardware error record variables. Defined in UEFI 2.1. + +--*/ + +#ifndef _HARDWARE_ERROR_VARIABLE_GUID_H_ +#define _HARDWARE_ERROR_VARIABLE_GUID_H_ + +#define EFI_HARDWARE_ERROR_VARIABLE_GUID \ + { \ + 0x414E6BDD, 0xE47B, 0x47cc, {0xB2, 0x44, 0xBB, 0x61, 0x02, 0x0C, 0xF5, 0x16} \ + } + +extern EFI_GUID gEfiHardwareErrorVariableGuid; + +#endif \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.c new file mode 100644 index 0000000000..b645562c9c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.c @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Mps.c + +Abstract: + + GUIDs used for MPS entries in the in the EFI 1.0 system table + + These GUIDs point the MPS tables as defined in the MPS 1.4 specifications. + + ACPI is the primary means of exporting MP information to the OS. MPS obly was + included to support Itanium-based platform power on. So don't use it if you don't have too. + + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (Mps) + +EFI_GUID gEfiMpsTableGuid = EFI_MPS_TABLE_GUID; + +EFI_GUID_STRING(&gEfiMpsTableGuid, "MPS Table", "MPS Table GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.h new file mode 100644 index 0000000000..3417c69723 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Mps/Mps.h @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Mps.h + +Abstract: + + GUIDs used for MPS entries in the in the EFI 1.0 system table + + These GUIDs point the MPS tables as defined in the MPS 1.4 specifications. + + ACPI is the primary means of exporting MP information to the OS. MPS obly was + included to support Itanium-based platform power on. So don't use it if you don't have too. + + +--*/ + +#ifndef _MPS_GUID_H_ +#define _MPS_GUID_H_ + +#define EFI_MPS_TABLE_GUID \ + { \ + 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +extern EFI_GUID gEfiMpsTableGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c new file mode 100644 index 0000000000..76132fb55f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SalSystemTable.c + +Abstract: + + GUIDs used for SAL system table entries in the in the EFI 1.0 system table. + + SAL System Table contains Itanium-based processor centric information about + the system. + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (SalSystemTable) + +EFI_GUID gEfiSalSystemTableGuid = EFI_SAL_SYSTEM_TABLE_GUID; + +EFI_GUID_STRING(&gEfiSalSystemTableGuid, "SAL System Table", "SAL System Table GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h new file mode 100644 index 0000000000..1bc0c72402 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SalSystemTable.h + +Abstract: + + GUIDs used for SAL system table entries in the in the EFI 1.0 system table. + + SAL System Table contains Itanium-based processor centric information about + the system. + +--*/ + +#ifndef _SAL_SYSTEM_TABLE_GUID_H_ + +#define EFI_SAL_SYSTEM_TABLE_GUID \ + { \ + 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +extern EFI_GUID gEfiSalSystemTableGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.c new file mode 100644 index 0000000000..a7db5a206d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SmBios.c + +Abstract: + + GUIDs used to locate the SMBIOS tables in the EFI 1.0 system table. + + This GUID in the system table is the only legal way to search for and + locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS + tables. + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (Smbios) + +EFI_GUID gEfiSmbiosTableGuid = EFI_SMBIOS_TABLE_GUID; + +EFI_GUID_STRING(&gEfiSmbiosTableGuid, "SMBIOS Table", "SMBIOS Table GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.h new file mode 100644 index 0000000000..4d53bb3f47 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/Smbios/SmBios.h @@ -0,0 +1,70 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SmBios.h + +Abstract: + + GUIDs used to locate the SMBIOS tables in the EFI 1.0 system table. + + This GUID in the system table is the only legal way to search for and + locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS + tables. + +--*/ + +#ifndef _SMBIOS_GUID_H_ +#define _SMBIOS_GUID_H_ + +#define EFI_SMBIOS_TABLE_GUID \ + { \ + 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +extern EFI_GUID gEfiSmbiosTableGuid; + +// +// Smbios Table Entry Point Structure +// +#pragma pack(1) +typedef struct { + UINT8 AnchorString[4]; + UINT8 EntryPointStructureChecksum; + UINT8 EntryPointLength; + UINT8 MajorVersion; + UINT8 MinorVersion; + UINT16 MaxStructureSize; + UINT8 EntryPointRevision; + UINT8 FormattedArea[5]; + UINT8 IntermediateAnchorString[5]; + UINT8 IntermediateChecksum; + UINT16 TableLength; + UINT32 TableAddress; + UINT16 NumberOfSmbiosStructures; + UINT8 SmbiosBcdRevision; +} SMBIOS_TABLE_ENTRY_POINT; +#pragma pack() +// +// The Smbios structure header +// +#pragma pack(1) +typedef struct { + + UINT8 Type; + UINT8 Length; + UINT16 Handle; + +} SMBIOS_STRUCTURE; +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.c b/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.c new file mode 100644 index 0000000000..b3fe35fa9b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PcAnsi.c + +Abstract: + + Terminal Device Path Vendor Guid. Defined in EFI 1.0. + +--*/ + +#include "EfiSpec.h" + +#include EFI_GUID_DEFINITION (PcAnsi) + +EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID; +EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID; +EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID; +EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID; + +EFI_GUID_STRING(&gEfiPcAnsiGuid, "Efi", "Efi PC ANSI Device Path Vendor GUID") +EFI_GUID_STRING(&gEfiVT100Guid, "Efi", "Efi VT100 Device Path Vendor GUID") +EFI_GUID_STRING(&gEfiVT100PlusGuid, "Efi", "Efi VT100Plus Device Path Vendor GUID") +EFI_GUID_STRING(&gEfiVTUTF8Guid, "Efi", "Efi VTUTF8 Device Path Vendor GUID") diff --git a/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.h b/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.h new file mode 100644 index 0000000000..6113690ac2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Guid/pcansi/PcAnsi.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PcAnsi.h + +Abstract: + + Terminal Device Path Vendor Guid. Defined in EFI 1.0. + +--*/ + +#ifndef _PC_ANSI_H_ +#define _PC_ANSI_H_ + +#define EFI_PC_ANSI_GUID \ + { \ + 0xe0c14753, 0xf9be, 0x11d2, 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +#define EFI_VT_100_GUID \ + { \ + 0xdfa66065, 0xb419, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +#define EFI_VT_100_PLUS_GUID \ + { \ + 0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 \ + } + +#define EFI_VT_UTF8_GUID \ + { \ + 0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 \ + } + +extern EFI_GUID gEfiPcAnsiGuid; +extern EFI_GUID gEfiVT100Guid; +extern EFI_GUID gEfiVT100PlusGuid; +extern EFI_GUID gEfiVTUTF8Guid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiApi.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiApi.h new file mode 100644 index 0000000000..87ecd7b22e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiApi.h @@ -0,0 +1,1114 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiApi.h + +Abstract: + + EFI intrinsic definitions. This includes all EFI 1.0 boot and runtime + services APIs. + + Drivers and applications are passed in a pointer to the EFI system table. + The EFI system table contains pointers to the boot and runtime services + tables. + +--*/ + +#ifndef _EFI_API_H_ +#define _EFI_API_H_ + +#include EFI_PROTOCOL_DEFINITION (DevicePath) +#include EFI_PROTOCOL_DEFINITION (SimpleTextIn) +#include EFI_PROTOCOL_DEFINITION (SimpleTextOut) + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#include "EfiCapsule.h" +#else +#include "EfiStatusCode.h" +#endif + +// +// Declare forward referenced data structures +// +EFI_FORWARD_DECLARATION (EFI_SYSTEM_TABLE); + +// +// EFI Memory +// +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_PAGES) ( + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN NoPages, + OUT EFI_PHYSICAL_ADDRESS * Memory + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_FREE_PAGES) ( + IN EFI_PHYSICAL_ADDRESS Memory, + IN UINTN NoPages + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_GET_MEMORY_MAP) ( + IN OUT UINTN *MemoryMapSize, + IN OUT EFI_MEMORY_DESCRIPTOR * MemoryMap, + OUT UINTN *MapKey, + OUT UINTN *DescriptorSize, + OUT UINT32 *DescriptorVersion + ); + +#define NextMemoryDescriptor(_Ptr, _Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) (_Ptr)) + (_Size))) +#define NEXT_MEMORY_DESCRIPTOR(_Ptr, _Size) NextMemoryDescriptor (_Ptr, _Size) + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_POOL) ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN Size, + OUT VOID **Buffer + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_FREE_POOL) ( + IN VOID *Buffer + ); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) ( + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize, + IN UINT32 DescriptorVersion, + IN EFI_MEMORY_DESCRIPTOR * VirtualMap + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_CONNECT_CONTROLLER) ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE * DriverImageHandle OPTIONAL, + IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL, + IN BOOLEAN Recursive + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_DISCONNECT_CONTROLLER) ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE DriverImageHandle, OPTIONAL + IN EFI_HANDLE ChildHandle OPTIONAL + ); + +// +// ConvertPointer DebugDisposition type. +// +#define EFI_OPTIONAL_POINTER 0x00000001 + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_CONVERT_POINTER) ( + IN UINTN DebugDisposition, + IN OUT VOID **Address + ); + +// +// EFI Event Types +// +#define EFI_EVENT_TIMER 0x80000000 +#define EFI_EVENT_RUNTIME 0x40000000 +#define EFI_EVENT_RUNTIME_CONTEXT 0x20000000 + +#define EFI_EVENT_NOTIFY_WAIT 0x00000100 +#define EFI_EVENT_NOTIFY_SIGNAL 0x00000200 + +#define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 +#define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 + +#define EFI_EVENT_EFI_SIGNAL_MASK 0x000000FF +#define EFI_EVENT_EFI_SIGNAL_MAX 4 + +typedef +VOID +(EFIAPI *EFI_EVENT_NOTIFY) ( + IN EFI_EVENT Event, + IN VOID *Context + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_CREATE_EVENT) ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT * Event + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_CREATE_EVENT_EX) ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl OPTIONAL, + IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, + IN CONST VOID *NotifyContext OPTIONAL, + IN CONST EFI_GUID *EventGroup OPTIONAL, + OUT EFI_EVENT *Event + ); + +typedef enum { + TimerCancel, + TimerPeriodic, + TimerRelative, + TimerTypeMax +} EFI_TIMER_DELAY; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_SET_TIMER) ( + IN EFI_EVENT Event, + IN EFI_TIMER_DELAY Type, + IN UINT64 TriggerTime + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_SIGNAL_EVENT) ( + IN EFI_EVENT Event + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_WAIT_FOR_EVENT) ( + IN UINTN NumberOfEvents, + IN EFI_EVENT * Event, + OUT UINTN *Index + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_CLOSE_EVENT) ( + IN EFI_EVENT Event + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_CHECK_EVENT) ( + IN EFI_EVENT Event + ); + +// +// Task priority level +// +#define EFI_TPL_APPLICATION 4 +#define EFI_TPL_CALLBACK 8 +#define EFI_TPL_NOTIFY 16 +#define EFI_TPL_HIGH_LEVEL 31 + +typedef +EFI_BOOTSERVICE +EFI_TPL +(EFIAPI *EFI_RAISE_TPL) ( + IN EFI_TPL NewTpl + ); + +typedef +EFI_BOOTSERVICE +VOID +(EFIAPI *EFI_RESTORE_TPL) ( + IN EFI_TPL OldTpl + ); + +// +// Variable attributes +// +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 + +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 +#endif + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_GET_VARIABLE) ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID * VendorGuid + ); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_SET_VARIABLE) ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ); + +// +// EFI Time +// +typedef struct { + UINT32 Resolution; + UINT32 Accuracy; + BOOLEAN SetsToZero; +} EFI_TIME_CAPABILITIES; + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_GET_TIME) ( + OUT EFI_TIME * Time, + OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL + ); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_SET_TIME) ( + IN EFI_TIME * Time + ); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_GET_WAKEUP_TIME) ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME * Time + ); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_SET_WAKEUP_TIME) ( + IN BOOLEAN Enable, + IN EFI_TIME * Time OPTIONAL + ); + +// +// Image Entry prototype +// +typedef +EFI_STATUS +(EFIAPI *EFI_IMAGE_ENTRY_POINT) ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE * SystemTable + ); + +// +// Image functions +// +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_IMAGE_LOAD) ( + IN BOOLEAN BootPolicy, + IN EFI_HANDLE ParentImageHandle, + IN EFI_DEVICE_PATH_PROTOCOL * FilePath, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + OUT EFI_HANDLE * ImageHandle + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_IMAGE_START) ( + IN EFI_HANDLE ImageHandle, + OUT UINTN *ExitDataSize, + OUT CHAR16 **ExitData OPTIONAL + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_EXIT) ( + IN EFI_HANDLE ImageHandle, + IN EFI_STATUS ExitStatus, + IN UINTN ExitDataSize, + IN CHAR16 *ExitData OPTIONAL + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_IMAGE_UNLOAD) ( + IN EFI_HANDLE ImageHandle + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_EXIT_BOOT_SERVICES) ( + IN EFI_HANDLE ImageHandle, + IN UINTN MapKey + ); + +// +// Misc +// +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_STALL) ( + IN UINTN Microseconds + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_SET_WATCHDOG_TIMER) ( + IN UINTN Timeout, + IN UINT64 WatchdogCode, + IN UINTN DataSize, + IN CHAR16 *WatchdogData OPTIONAL + ); + +typedef enum { + EfiResetCold, + EfiResetWarm, + EfiResetShutdown, + +#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000)) + EfiResetUpdate +#endif + +} EFI_RESET_TYPE; + +typedef +EFI_RUNTIMESERVICE +VOID +(EFIAPI *EFI_RESET_SYSTEM) ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData OPTIONAL + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) ( + OUT UINT64 *Count + ); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) ( + OUT UINT32 *HighCount + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_CALCULATE_CRC32) ( + IN VOID *Data, + IN UINTN DataSize, + OUT UINT32 *Crc32 + ); + +typedef +EFI_BOOTSERVICE +VOID +(EFIAPI *EFI_COPY_MEM) ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ); + +typedef +EFI_BOOTSERVICE +VOID +(EFIAPI *EFI_SET_MEM) ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ); + +// +// Protocol handler functions +// +typedef enum { + EFI_NATIVE_INTERFACE +} EFI_INTERFACE_TYPE; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) ( + IN OUT EFI_HANDLE * Handle, + IN EFI_GUID * Protocol, + IN EFI_INTERFACE_TYPE InterfaceType, + IN VOID *Interface + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + IN OUT EFI_HANDLE * Handle, + ... + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) ( + IN EFI_HANDLE Handle, + IN EFI_GUID * Protocol, + IN VOID *OldInterface, + IN VOID *NewInterface + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) ( + IN EFI_HANDLE Handle, + IN EFI_GUID * Protocol, + IN VOID *Interface + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( + IN EFI_HANDLE Handle, + ... + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_HANDLE_PROTOCOL) ( + IN EFI_HANDLE Handle, + IN EFI_GUID * Protocol, + OUT VOID **Interface + ); + +#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 +#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 +#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 +#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 +#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 +#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 + +// +// /////////////////////////////////////////////////////////////////////////////////////////////// +// OpenProtocol() Attribute Values +///////////////////////////////////////////////////////////////////////////////////////////////// +// BY_HANDLE_PROTOCOL - Used by EFI 1.0 Drivers and Applications +// May not actually add an elemnt to the open list in a production build +// +// GET_PROTOCOL - Used by EFI 1.1 Drivers to get a protocol interface +// May not actually add an elemnt to the open list in a production build +// +// TEST_PROTOCOL - Used by EFI 1.1 Drivers to test for the existence of a protocol interface +// The interface is not returned, and it is an optional parameter tham may be NULL. +// May not actually add an elemnt to the open list in a production build +// +// BY_DRIVER - Used by EFI 1.1 Drivers that are able to share a protocol with other +// agents other than its children. A driver is always able to share +// a protocol with its children, since the driver is in control of the +// parent controller's and the child controller's use of the protocol. +// +// BY_DRIVER | EXCLUSIVE - Used by EFI 1.1 Drivers that will not share a protocol with any other +// agents except its children. A driver is always able to share +// a protocol with its children, since the driver is in control of the +// parent controller's and the child controller's use of the protocol. +// This attribute will force all other drivers to disconnect from the protocol +// before this driver attaches. When this driver closes the handle, the other +// drivers will reconnect to the protocol. +// +// +// BY_CHILD_CONTROLLER - Used by EFI 1.1 Driver to show that a protocol is consumed by a child +// of the driver. This is information used by DisconnectController() to +// determine the list of children that a protocol has. It has +// no affect on the OpenProtocol()/ClosePrototocol() behavior. +// +// EXCLUSIVE - Used by EFI 1.1 Applications to gain exclusive access to a protocol. +// All drivers are disconnected from the handle while the application has +// the handle open. These drivers are reconnected when the application +// closes the handle. +// +///////////////////////////////////////////////////////////////////////////////////////////////// +// OpenProtocol() behavior based on Attribute values +///////////////////////////////////////////////////////////////////////////////////////////////// +// +// OpenProtocol (Handle, Protocol, Interface, ImageHandle, DeviceHandle, Attributes) +// * EFI_UNSUPPORTED if Protocol does not exist on Handle +// * EFI_INVALID_PARAMETER if Handle is not a valid handle. +// * EFI_INVALID_PARAMETER if Protocol is NULL or not a valid GUID +// * EFI_INVALID_PARAMETER if Interface is NULL +// * EFI_INVALID_PARAMETER if Attributes is not one of the following values: +// BY_HANDLE_PROTOCOL +// GET_PROTOCOL +// TEST_PROTOCOL +// BY_CHILD_CONTROLLER +// BY_DRIVER +// BY_DRIVER | EXCLUSIVE +// EXCLUSIVE +// * EFI_INVALID_PARAMETER if Attributes BY_CHILD_CONTROLLER and ImageHandle is not a valid handle +// * EFI_INVALID_PARAMETER if Attributes BY_CHILD_CONTROLLER and DeviceHandle is not a valid handle +// * EFI_INVALID_PARAMETER if Attributes BY_CHILD_CONTROLLER and Handle == DeviceHandle +// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER and ImageHandle is not a valid handle +// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER and DeviceHandle is not a valid handle +// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER | EXCLUSIVE and ImageHandle is not a valid handle +// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER | EXCLUSIVE and DeviceHandle is not a valid handle +// * EFI_INVALID_PARAMETER if Attributes EXCLUSIVE and ImageHandle is not a valid handle +// +// OpenProtocol() Attributes = BY_HANDLE_PROTOCOL, GET_PROTOCOL, TEST_PROTOCOL, BY_CHILD_CONTROLLER +// * EFI_SUCCESS if Protocol exists on the Handle +// +// OpenProtocol() Attributes = BY_DRIVER +// * EFI_SUCCESS if there are no items in the Open List for (Handle, Protocol) +// * EFI_SUCCESS if there are only items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_HANDLE_PROTOCOL +// GET_PROTOCOL +// TEST_PROTOCOL +// BY_CHILD_CONTROLLER +// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER +// AND ImageHandle != OpenListItem.IH +// * EFI_ALREADY_STARTED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER +// AND ImageHandle == OpenListItem.IH +// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER | EXCLUSIVE +// EXCLUSIVE +// +// OpenProtocol() Attributes = BY_DRIVER | EXCLUSIVE +// * EFI_SUCCESS if there are no items in the Open List for (Handle, Protocol) +// * EFI_SUCCESS if there are only items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_HANDLE_PROTOCOL +// GET_PROTOCOL +// TEST_PROTOCOL +// BY_CHILD_CONTROLLER +// * EFI_SUCCESS if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER +// AND the driver is removed by DisconnectController(IH,DH) +// * EFI_ALREADY_STARTED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER | EXCLUSIVE +// AND ImageHandle == OpenListItem.IH +// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER +// AND the driver can not be removed by DisconnectController(IH,DH) +// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER | EXCLUSIVE +// EXCLUSIVE +// +// OpenProtocol() Attributes = EXCLUSIVE +// * EFI_SUCCESS if there are no items in the Open List for (Handle, Protocol) +// * EFI_SUCCESS if there are only items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_HANDLE_PROTOCOL +// GET_PROTOCOL +// TEST_PROTOCOL +// BY_CHILD_CONTROLLER +// * EFI_SUCCESS if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER +// AND the driver is removed by DisconnectController(IH,DH) +// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER +// AND the driver can not be removed by DisconnectController(IH,DH) +// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol) +// that have the one of the following Attributes +// BY_DRIVER | EXCLUSIVE +// EXCLUSIVE +// +///////////////////////////////////////////////////////////////////////////////////////////////// +// CloseProtocol() Behavior based on the Attributes of the item being closed and the items +// remaining on the Open List +///////////////////////////////////////////////////////////////////////////////////////////////// +// CloseProtocol(Handle, Protocol, ImageHandle, DeviceHandle) +// CloseProtocol() Attributes of item = BY_HANDLE_PROTOCOL, +// GET_PROTOCOL +// TEST_PROTOCOL +// BY_CHILD_CONTROLLER, +// BY_DRIVER +// BY_DRIVER | EXCLUSIVE +// EXCLUSIVE +// EFI_NOT_FOUND if Protocol does not exist on Handle +// EFI_INVALID_PARAMETER if Handle is not a valid handle. +// EFI_INVALID_PARAMETER if Protocol is NULL or not a valid GUID +// EFI_INVALID_PARAMETER if ImageHandle is not a valid handle +// EFI_INVALID_PARAMETER if DeviceHandle is not a valid handle +// EFI_NOT_FOUND if (ImageHandle, DeviceHandle) is not present in the Open List +// for (Handle, Protocol) +// EFI_ACCESS_DENIED if (ImageHandle, DeviceHandle) is present in the Open List +// for (Handle, Protocol), but the item can not be removed. +// EFI_SUCCESS if (ImageHandle, DeviceHandle) is present in the Open List +// for (Handle, Protocol), and the item can be removed. +// +///////////////////////////////////////////////////////////////////////////////////////////////// +// UninstallProtocolInterface() behavior +///////////////////////////////////////////////////////////////////////////////////////////////// +// +// UninstallProtocolInterface (Handle, Protocol, Interface) +// +// EFI_INVALID_PARAMETER if Handle is not a valid handle. +// EFI_INVALID_PARAMETER if Protocol is not a vlaid GUID +// EFI_NOT_FOUND if Handle doe not support Protocol +// EFI_NOT_FOUND if the interface for (Handle, Protocol) does not match Interface +// EFI_ACCESS_DENIED if the list of Open Items for (Handle, Protocol) can not be removed +// EFI_SUCCESS if the list of Open Items is empty, and Protocol is removed from Handle +// +// Algorithm to remove Open Item List: +// +// Loop through all Open Item List entries +// if (OpenItem.Attributes & BY_DRIVER) then +// DisconnectController (OpenItem.IH, OpenItem.DH) +// end if +// end loop +// Loop through all Open Item List entries +// if (OpenItem.Attributes & BY_HANDLE_PROTOCOL or GET_PROTOCOL or TEST_PROTOCOL) then +// CloseProtocol (Handle, Protocol, OpenItem.IH, OpenItem.DH) +// end if +// end loop +// if Open Item List is empty then remove Protocol from Handle and return EFI_SUCCESS +// if Open Item List is not empty then return EFI_ACCESS_DENIED +// +///////////////////////////////////////////////////////////////////////////////////////////////// +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_OPEN_PROTOCOL) ( + IN EFI_HANDLE Handle, + IN EFI_GUID * Protocol, + OUT VOID **Interface, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE ControllerHandle, OPTIONAL + IN UINT32 Attributes + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_CLOSE_PROTOCOL) ( + IN EFI_HANDLE Handle, + IN EFI_GUID * Protocol, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE DeviceHandle + ); + +typedef struct { + EFI_HANDLE AgentHandle; + EFI_HANDLE ControllerHandle; + UINT32 Attributes; + UINT32 OpenCount; +} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) ( + IN EFI_HANDLE UserHandle, + IN EFI_GUID * Protocol, + IN EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, + OUT UINTN *EntryCount + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) ( + IN EFI_HANDLE UserHandle, + OUT EFI_GUID ***ProtocolBuffer, + OUT UINTN *ProtocolBufferCount + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) ( + IN EFI_GUID * Protocol, + IN EFI_EVENT Event, + OUT VOID **Registration + ); + +typedef enum { + AllHandles, + ByRegisterNotify, + ByProtocol +} EFI_LOCATE_SEARCH_TYPE; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE) ( + IN EFI_LOCATE_SEARCH_TYPE SearchType, + IN EFI_GUID * Protocol OPTIONAL, + IN VOID *SearchKey OPTIONAL, + IN OUT UINTN *BufferSize, + OUT EFI_HANDLE * Buffer + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_LOCATE_DEVICE_PATH) ( + IN EFI_GUID * Protocol, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT EFI_HANDLE * Device + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) ( + IN EFI_GUID * Guid, + IN VOID *Table + ); + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_RESERVED_SERVICE) ( + VOID + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) ( + IN EFI_LOCATE_SEARCH_TYPE SearchType, + IN EFI_GUID * Protocol OPTIONAL, + IN VOID *SearchKey OPTIONAL, + IN OUT UINTN *NumberHandles, + OUT EFI_HANDLE **Buffer + ); + +typedef +EFI_BOOTSERVICE11 +EFI_STATUS +(EFIAPI *EFI_LOCATE_PROTOCOL) ( + EFI_GUID * Protocol, + VOID *Registration, OPTIONAL + VOID **Interface + ); + +// +// Definition of Status Code extended data header +// +// HeaderSize The size of the architecture. This is specified to enable +// the future expansion +// +// Size The size of the data in bytes. This does not include the size +// of the header structure. +// +// Type A GUID defining the type of the data +// +// +#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000)) + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_REPORT_STATUS_CODE) ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ); + +#endif + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_UPDATE_CAPSULE) ( + IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL + ); + + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) ( + IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + OUT UINT64 *MaxiumCapsuleSize, + OUT EFI_RESET_TYPE *ResetType +); + +typedef +EFI_RUNTIMESERVICE +EFI_STATUS +(EFIAPI *EFI_QUERY_VARIABLE_INFO) ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ); + +#endif + +// +// EFI Runtime Services Table +// +#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 +#define EFI_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_VERSION + +typedef struct { + EFI_TABLE_HEADER Hdr; + + // + // Time services + // + EFI_GET_TIME GetTime; + EFI_SET_TIME SetTime; + EFI_GET_WAKEUP_TIME GetWakeupTime; + EFI_SET_WAKEUP_TIME SetWakeupTime; + + // + // Virtual memory services + // + EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; + EFI_CONVERT_POINTER ConvertPointer; + + // + // Variable services + // + EFI_GET_VARIABLE GetVariable; + EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; + EFI_SET_VARIABLE SetVariable; + + // + // Misc + // + EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; + EFI_RESET_SYSTEM ResetSystem; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + // + // New Boot Service added by UEFI 2.0 + // + EFI_UPDATE_CAPSULE UpdateCapsule; + EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities; + EFI_QUERY_VARIABLE_INFO QueryVariableInfo; +#elif (TIANO_RELEASE_VERSION != 0) + // + // Tiano extension to EFI 1.10 runtime table + // It was moved to a protocol to not conflict with UEFI 2.0 + // If Tiano is disabled, this item is not enabled for EFI1.10 + // + EFI_REPORT_STATUS_CODE ReportStatusCode; +#endif + +} EFI_RUNTIME_SERVICES; + +// +// EFI Boot Services Table +// +#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 +#define EFI_BOOT_SERVICES_REVISION EFI_SPECIFICATION_VERSION + +typedef struct { + EFI_TABLE_HEADER Hdr; + + // + // Task priority functions + // + EFI_RAISE_TPL RaiseTPL; + EFI_RESTORE_TPL RestoreTPL; + + // + // Memory functions + // + EFI_ALLOCATE_PAGES AllocatePages; + EFI_FREE_PAGES FreePages; + EFI_GET_MEMORY_MAP GetMemoryMap; + EFI_ALLOCATE_POOL AllocatePool; + EFI_FREE_POOL FreePool; + + // + // Event & timer functions + // + EFI_CREATE_EVENT CreateEvent; + EFI_SET_TIMER SetTimer; + EFI_WAIT_FOR_EVENT WaitForEvent; + EFI_SIGNAL_EVENT SignalEvent; + EFI_CLOSE_EVENT CloseEvent; + EFI_CHECK_EVENT CheckEvent; + + // + // Protocol handler functions + // + EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface; + EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface; + EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface; + EFI_HANDLE_PROTOCOL HandleProtocol; + VOID *Reserved; + EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify; + EFI_LOCATE_HANDLE LocateHandle; + EFI_LOCATE_DEVICE_PATH LocateDevicePath; + EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable; + + // + // Image functions + // + EFI_IMAGE_LOAD LoadImage; + EFI_IMAGE_START StartImage; + EFI_EXIT Exit; + EFI_IMAGE_UNLOAD UnloadImage; + EFI_EXIT_BOOT_SERVICES ExitBootServices; + + // + // Misc functions + // + EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; + EFI_STALL Stall; + EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; + + // + // //////////////////////////////////////////////////// + // EFI 1.1 Services + ////////////////////////////////////////////////////// + // + // DriverSupport Services + // + EFI_CONNECT_CONTROLLER ConnectController; + EFI_DISCONNECT_CONTROLLER DisconnectController; + + // + // Added Open and Close protocol for the new driver model + // + EFI_OPEN_PROTOCOL OpenProtocol; + EFI_CLOSE_PROTOCOL CloseProtocol; + EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation; + + // + // Added new services to EFI 1.1 as Lib to reduce code size. + // + EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle; + EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer; + EFI_LOCATE_PROTOCOL LocateProtocol; + + EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces; + EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces; + + // + // CRC32 services + // + EFI_CALCULATE_CRC32 CalculateCrc32; + + // + // Memory Utility Services + // + EFI_COPY_MEM CopyMem; + EFI_SET_MEM SetMem; +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + // + // UEFI 2.0 Extension to the table + // + EFI_CREATE_EVENT_EX CreateEventEx; +#endif + +} EFI_BOOT_SERVICES; + +// +// EFI Configuration Table +// +typedef struct { + EFI_GUID VendorGuid; + VOID *VendorTable; +} EFI_CONFIGURATION_TABLE; + +// +// EFI System Table +// +#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 +#define EFI_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_VERSION +#define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | 02) +#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | 10) +#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | 00) +#define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | 10) + +typedef struct _EFI_SYSTEM_TABLE { + EFI_TABLE_HEADER Hdr; + + CHAR16 *FirmwareVendor; + UINT32 FirmwareRevision; + + EFI_HANDLE ConsoleInHandle; + EFI_SIMPLE_TEXT_IN_PROTOCOL *ConIn; + + EFI_HANDLE ConsoleOutHandle; + EFI_SIMPLE_TEXT_OUT_PROTOCOL *ConOut; + + EFI_HANDLE StandardErrorHandle; + EFI_SIMPLE_TEXT_OUT_PROTOCOL *StdErr; + + EFI_RUNTIME_SERVICES *RuntimeServices; + EFI_BOOT_SERVICES *BootServices; + + UINTN NumberOfTableEntries; + EFI_CONFIGURATION_TABLE *ConfigurationTable; + +} EFI_SYSTEM_TABLE; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h new file mode 100644 index 0000000000..bab0d4ea42 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h @@ -0,0 +1,555 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiDevicePath.h + +Abstract: + + EFI Device Path definitions + +--*/ + +#ifndef _EFI_DEVICE_PATH_H +#define _EFI_DEVICE_PATH_H + + + +#pragma pack(1) + + +// +// Device Path defines and macros +// +#define EFI_DP_TYPE_MASK 0x7F +#define EFI_DP_TYPE_UNPACKED 0x80 +#define END_DEVICE_PATH_TYPE 0x7f +#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff +#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01 +#define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH_PROTOCOL)) + +#define DP_IS_END_TYPE(a) +#define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) + +#define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK ) +#define DevicePathSubType(a) ( (a)->SubType ) +#define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) ) +#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a))) +#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE ) +#define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) +#define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) ) +#define IsDevicePathUnpacked(a) ( (a)->Type & EFI_DP_TYPE_UNPACKED ) + + +#define SetDevicePathNodeLength(a,l) { \ + (a)->Length[0] = (UINT8) (l); \ + (a)->Length[1] = (UINT8) ((l) >> 8); \ + } + +#define SetDevicePathEndNode(a) { \ + (a)->Type = END_DEVICE_PATH_TYPE; \ + (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \ + (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \ + (a)->Length[1] = 0; \ + } + +// +// Hardware Device Paths +// +#define HARDWARE_DEVICE_PATH 0x01 + +#define HW_PCI_DP 0x01 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 Function; + UINT8 Device; +} PCI_DEVICE_PATH; + +#define HW_PCCARD_DP 0x02 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 FunctionNumber; +} PCCARD_DEVICE_PATH; + +#define HW_MEMMAP_DP 0x03 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 MemoryType; + EFI_PHYSICAL_ADDRESS StartingAddress; + EFI_PHYSICAL_ADDRESS EndingAddress; +} MEMMAP_DEVICE_PATH; + +#define HW_VENDOR_DP 0x04 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Guid; +} VENDOR_DEVICE_PATH; + +#define HW_CONTROLLER_DP 0x05 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Controller; +} CONTROLLER_DEVICE_PATH; + +// +// ACPI Device Paths +// +#define ACPI_DEVICE_PATH 0x02 + +#define ACPI_DP 0x01 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 HID; + UINT32 UID; +} ACPI_HID_DEVICE_PATH; + +#define ACPI_EXTENDED_DP 0x02 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 HID; + UINT32 UID; + UINT32 CID; + // + // Optional variable length _HIDSTR + // Optional variable length _UIDSTR + // +} ACPI_EXTENDED_HID_DEVICE_PATH; + +#define ACPI_ADR_DP 0x03 + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 ADR; +} ACPI_ADR_DEVICE_PATH; + +#define ACPI_ADR_DISPLAY_TYPE_OTHER 0 +#define ACPI_ADR_DISPLAY_TYPE_VGA 1 +#define ACPI_ADR_DISPLAY_TYPE_TV 2 +#define ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL 3 +#define ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL 4 + +#define ACPI_DISPLAY_ADR(_DeviceIdScheme, _HeadId, _NonVgaOutput, _BiosCanDetect, _VendorInfo, _Type, _Port, _Index) \ + ((UINT32) ( (((_DeviceIdScheme) & 0x1) << 31) | \ + (((_HeadId) & 0x7) << 18) | \ + (((_NonVgaOutput) & 0x1) << 17) | \ + (((_BiosCanDetect) & 0x1) << 16) | \ + (((_VendorInfo) & 0xf) << 12) | \ + (((_Type) & 0xf) << 8) | \ + (((_Port) & 0xf) << 4) | \ + ((_Index) & 0xf) )) + +// +// EISA ID Macro +// EISA ID Definition 32-bits +// bits[15:0] - three character compressed ASCII EISA ID. +// bits[31:16] - binary number +// Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z' +// +#define PNP_EISA_ID_CONST 0x41d0 +#define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16)) +#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) +#define EFI_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) + +#define PNP_EISA_ID_MASK 0xffff +#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16) + +// +// Messaging Device Paths +// +#define MESSAGING_DEVICE_PATH 0x03 + +#define MSG_ATAPI_DP 0x01 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 PrimarySecondary; + UINT8 SlaveMaster; + UINT16 Lun; +} ATAPI_DEVICE_PATH; + +#define MSG_SCSI_DP 0x02 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 Pun; + UINT16 Lun; +} SCSI_DEVICE_PATH; + +#define MSG_FIBRECHANNEL_DP 0x03 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Reserved; + UINT64 WWN; + UINT64 Lun; +} FIBRECHANNEL_DEVICE_PATH; + +#define MSG_1394_DP 0x04 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Reserved; + UINT64 Guid; +} F1394_DEVICE_PATH; + +#define MSG_USB_DP 0x05 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 ParentPortNumber; + UINT8 InterfaceNumber; +} USB_DEVICE_PATH; + +#define MSG_USB_CLASS_DP 0x0f +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 VendorId; + UINT16 ProductId; + UINT8 DeviceClass; + UINT8 DeviceSubClass; + UINT8 DeviceProtocol; +} USB_CLASS_DEVICE_PATH; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#define MSG_USB_WWID_DP 0x10 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 InterfaceNumber; + UINT16 VendorId; + UINT16 ProductId; + // + // CHAR16 SerialNumber[]; + // +} USB_WWID_DEVICE_PATH; + +#define MSG_DEVICE_LOGICAL_UNIT_DP 0x11 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT8 Lun; +} DEVICE_LOGICAL_UNIT_DEVICE_PATH; +#endif + +#define MSG_SATA_DP 0x12 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 HBAPortNumber; + UINT16 PortMultiplierPortNumber; + UINT16 Lun; +} SATA_DEVICE_PATH; + +#define MSG_I2O_DP 0x06 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Tid; +} I2O_DEVICE_PATH; + +#define MSG_MAC_ADDR_DP 0x0b +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_MAC_ADDRESS MacAddress; + UINT8 IfType; +} MAC_ADDR_DEVICE_PATH; + +#define MSG_IPv4_DP 0x0c +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_IPv4_ADDRESS LocalIpAddress; + EFI_IPv4_ADDRESS RemoteIpAddress; + UINT16 LocalPort; + UINT16 RemotePort; + UINT16 Protocol; + BOOLEAN StaticIpAddress; +} IPv4_DEVICE_PATH; + +#define MSG_IPv6_DP 0x0d +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_IPv6_ADDRESS LocalIpAddress; + EFI_IPv6_ADDRESS RemoteIpAddress; + UINT16 LocalPort; + UINT16 RemotePort; + UINT16 Protocol; + BOOLEAN StaticIpAddress; +} IPv6_DEVICE_PATH; + +#define MSG_INFINIBAND_DP 0x09 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 ResourceFlags; + UINT8 PortGid[16]; + UINT64 ServiceId; + UINT64 TargetPortId; + UINT64 DeviceId; +} INFINIBAND_DEVICE_PATH; + +#define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE 0x01 +#define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT 0x02 +#define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL 0x04 +#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL 0x08 +#define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL 0x10 + +#define MSG_UART_DP 0x0e +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Reserved; + UINT64 BaudRate; + UINT8 DataBits; + UINT8 Parity; + UINT8 StopBits; +} UART_DEVICE_PATH; + +// +// Use VENDOR_DEVICE_PATH struct +// +#define MSG_VENDOR_DP 0x0a + +#define DEVICE_PATH_MESSAGING_PC_ANSI \ + { 0xe0c14753, 0xf9be, 0x11d2, 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +#define DEVICE_PATH_MESSAGING_VT_100 \ + { 0xdfa66065, 0xb419, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +#define DEVICE_PATH_MESSAGING_VT_100_PLUS \ + { 0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 } + +#define DEVICE_PATH_MESSAGING_VT_UTF8 \ + { 0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 } + +#define DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL \ + { 0x37499a9d, 0x542f, 0x4c89, 0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 } + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Guid; + UINT32 FlowControlMap; +} UART_FLOW_CONTROL_DEVICE_PATH; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +#define DEVICE_PATH_MESSAGING_SAS \ + { 0xd487ddb4, 0x008b, 0x11d9, 0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Guid; + UINT32 Reserved; + UINT64 SasAddress; + UINT64 Lun; + UINT16 DeviceTopology; + UINT16 RelativeTargetPort; +} SAS_DEVICE_PATH; + +#define MSG_ISCSI_DP 0x13 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 NetworkProtocol; + UINT16 LoginOption; + UINT64 Lun; + UINT16 TargetPortalGroupTag; + // CHAR8 iSCSI Target Name +} ISCSI_DEVICE_PATH; + +#define ISCSI_LOGIN_OPTION_NO_HEADER_DIGEST 0x0000 +#define ISCSI_LOGIN_OPTION_HEADER_DIGEST_USING_CRC32C 0x0002 +#define ISCSI_LOGIN_OPTION_NO_DATA_DIGEST 0x0000 +#define ISCSI_LOGIN_OPTION_DATA_DIGEST_USING_CRC32C 0x0008 +#define ISCSI_LOGIN_OPTION_AUTHMETHOD_CHAP 0x0000 +#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON 0x1000 +#define ISCSI_LOGIN_OPTION_CHAP_BI 0x0000 +#define ISCSI_LOGIN_OPTION_CHAP_UNI 0x2000 + +#endif + +// +// Media Device Path +// +#define MEDIA_DEVICE_PATH 0x04 + +#define MEDIA_HARDDRIVE_DP 0x01 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 PartitionNumber; + UINT64 PartitionStart; + UINT64 PartitionSize; + UINT8 Signature[16]; + UINT8 MBRType; + UINT8 SignatureType; +} HARDDRIVE_DEVICE_PATH; + +#define MBR_TYPE_PCAT 0x01 +#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02 + +#define SIGNATURE_TYPE_MBR 0x01 +#define SIGNATURE_TYPE_GUID 0x02 + +#define MEDIA_CDROM_DP 0x02 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 BootEntry; + UINT64 PartitionStart; + UINT64 PartitionSize; +} CDROM_DEVICE_PATH; + +// +// Use VENDOR_DEVICE_PATH struct +// +#define MEDIA_VENDOR_DP 0x03 + +#define MEDIA_FILEPATH_DP 0x04 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + CHAR16 PathName[1]; +} FILEPATH_DEVICE_PATH; + +#define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName) + +#define MEDIA_PROTOCOL_DP 0x05 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Protocol; +} MEDIA_PROTOCOL_DEVICE_PATH; + +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) + +#define MEDIA_FV_DP 0x06 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID NameGuid; +} MEDIA_FW_VOL_DEVICE_PATH; + +#define MEDIA_FV_FILEPATH_DP 0x07 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID NameGuid; +} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH; + +#endif + +// +// BBS Device Path +// +#define BBS_DEVICE_PATH 0x05 +#define BBS_BBS_DP 0x01 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT16 DeviceType; + UINT16 StatusFlag; + CHAR8 String[1]; +} BBS_BBS_DEVICE_PATH; + +// +// DeviceType definitions - from BBS specification +// +#define BBS_TYPE_FLOPPY 0x01 +#define BBS_TYPE_HARDDRIVE 0x02 +#define BBS_TYPE_CDROM 0x03 +#define BBS_TYPE_PCMCIA 0x04 +#define BBS_TYPE_USB 0x05 +#define BBS_TYPE_EMBEDDED_NETWORK 0x06 +#define BBS_TYPE_BEV 0x80 +#define BBS_TYPE_UNKNOWN 0xFF + +#define UNKNOWN_DEVICE_GUID \ + { 0xcf31fac5, 0xc24e, 0x11d2, 0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b } + +typedef struct { + VENDOR_DEVICE_PATH DevicePath; + UINT8 LegacyDriveLetter; +} UNKNOWN_DEVICE_VENDOR_DEVICE_PATH; + + +// +// Union of all possible Device Paths and pointers to Device Paths +// + +typedef union { + EFI_DEVICE_PATH_PROTOCOL DevPath; + PCI_DEVICE_PATH Pci; + PCCARD_DEVICE_PATH PcCard; + MEMMAP_DEVICE_PATH MemMap; + VENDOR_DEVICE_PATH Vendor; + + UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; + + CONTROLLER_DEVICE_PATH Controller; + ACPI_HID_DEVICE_PATH Acpi; + + ATAPI_DEVICE_PATH Atapi; + SCSI_DEVICE_PATH Scsi; + FIBRECHANNEL_DEVICE_PATH FibreChannel; + SATA_DEVICE_PATH Sata; + + F1394_DEVICE_PATH F1394; + USB_DEVICE_PATH Usb; + USB_CLASS_DEVICE_PATH UsbClass; + #if (EFI_SPECIFICATION_VERSION >= 0x00020000) + USB_WWID_DEVICE_PATH UsbWwid; + #endif + I2O_DEVICE_PATH I2O; + MAC_ADDR_DEVICE_PATH MacAddr; + IPv4_DEVICE_PATH Ipv4; + IPv6_DEVICE_PATH Ipv6; + INFINIBAND_DEVICE_PATH InfiniBand; + UART_DEVICE_PATH Uart; + UART_FLOW_CONTROL_DEVICE_PATH UartFlowControl; + #if (EFI_SPECIFICATION_VERSION >= 0x00020000) + SAS_DEVICE_PATH Sas; + ISCSI_DEVICE_PATH Iscsi; + #endif + HARDDRIVE_DEVICE_PATH HardDrive; + CDROM_DEVICE_PATH CD; + + FILEPATH_DEVICE_PATH FilePath; + MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol; + + BBS_BBS_DEVICE_PATH Bbs; +} EFI_DEV_PATH; + + + +typedef union { + EFI_DEVICE_PATH_PROTOCOL *DevPath; + PCI_DEVICE_PATH *Pci; + PCCARD_DEVICE_PATH *PcCard; + MEMMAP_DEVICE_PATH *MemMap; + VENDOR_DEVICE_PATH *Vendor; + + UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; + + CONTROLLER_DEVICE_PATH *Controller; + ACPI_HID_DEVICE_PATH *Acpi; + ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi; + + ATAPI_DEVICE_PATH *Atapi; + SCSI_DEVICE_PATH *Scsi; + FIBRECHANNEL_DEVICE_PATH *FibreChannel; + SATA_DEVICE_PATH *Sata; + + F1394_DEVICE_PATH *F1394; + USB_DEVICE_PATH *Usb; + USB_CLASS_DEVICE_PATH *UsbClass; + I2O_DEVICE_PATH *I2O; + MAC_ADDR_DEVICE_PATH *MacAddr; + IPv4_DEVICE_PATH *Ipv4; + IPv6_DEVICE_PATH *Ipv6; + INFINIBAND_DEVICE_PATH *InfiniBand; + UART_DEVICE_PATH *Uart; + + HARDDRIVE_DEVICE_PATH *HardDrive; + CDROM_DEVICE_PATH *CD; + + FILEPATH_DEVICE_PATH *FilePath; + MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol; + + BBS_BBS_DEVICE_PATH *Bbs; + UINT8 *Raw; +} EFI_DEV_PATH_PTR; + +#pragma pack() + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h new file mode 100644 index 0000000000..be2b628b60 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h @@ -0,0 +1,67 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiError.h + +Abstract: + + EFI error levels and thier associated defines + +--*/ + +#ifndef _EFI_ERROR_H_ +#define _EFI_ERROR_H_ + +// +// Set the upper bit to indicate EFI Error. +// +#define EFIERR(a) (EFI_MAX_BIT | (a)) + +#define EFIWARN(a) (a) +#define EFI_ERROR(a) (((INTN) (a)) < 0) + +#define EFI_SUCCESS 0 +#define EFI_LOAD_ERROR EFIERR (1) +#define EFI_INVALID_PARAMETER EFIERR (2) +#define EFI_UNSUPPORTED EFIERR (3) +#define EFI_BAD_BUFFER_SIZE EFIERR (4) +#define EFI_BUFFER_TOO_SMALL EFIERR (5) +#define EFI_NOT_READY EFIERR (6) +#define EFI_DEVICE_ERROR EFIERR (7) +#define EFI_WRITE_PROTECTED EFIERR (8) +#define EFI_OUT_OF_RESOURCES EFIERR (9) +#define EFI_VOLUME_CORRUPTED EFIERR (10) +#define EFI_VOLUME_FULL EFIERR (11) +#define EFI_NO_MEDIA EFIERR (12) +#define EFI_MEDIA_CHANGED EFIERR (13) +#define EFI_NOT_FOUND EFIERR (14) +#define EFI_ACCESS_DENIED EFIERR (15) +#define EFI_NO_RESPONSE EFIERR (16) +#define EFI_NO_MAPPING EFIERR (17) +#define EFI_TIMEOUT EFIERR (18) +#define EFI_NOT_STARTED EFIERR (19) +#define EFI_ALREADY_STARTED EFIERR (20) +#define EFI_ABORTED EFIERR (21) +#define EFI_ICMP_ERROR EFIERR (22) +#define EFI_TFTP_ERROR EFIERR (23) +#define EFI_PROTOCOL_ERROR EFIERR (24) +#define EFI_INCOMPATIBLE_VERSION EFIERR (25) +#define EFI_SECURITY_VIOLATION EFIERR (26) +#define EFI_CRC_ERROR EFIERR (27) + +#define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1) +#define EFI_WARN_DELETE_FAILURE EFIWARN (2) +#define EFI_WARN_WRITE_FAILURE EFIWARN (3) +#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h new file mode 100644 index 0000000000..e151697ac9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h @@ -0,0 +1,661 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiImage.h + +Abstract: + + EFI image format for PE32+. Please note some data structures are different + for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64 + + BugBug: Fix text - doc as defined in MSFT EFI specification + +--*/ + +#ifndef _EFI_IMAGE_H_ +#define _EFI_IMAGE_H_ + +// +// PE32+ Subsystem type for EFI images +// +#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10 +#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 +#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 + +// +// BugBug: Need to get a real answer for this problem. This is not in the +// PE specification. +// +// A SAL runtime driver does not get fixed up when a transition to +// virtual mode is made. In all other cases it should be treated +// like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image +// +#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13 + +// +// PE32+ Machine type for EFI images +// +#define EFI_IMAGE_MACHINE_IA32 0x014c +#define EFI_IMAGE_MACHINE_IA64 0x0200 +#define EFI_IMAGE_MACHINE_X64 0x8664 +// +// #define EFI_IMAGE_MACHINE_FCODE 0xfc0d +// +#define EFI_IMAGE_MACHINE_EBC 0x0EBC + +#define EFI_IMAGE_DOS_SIGNATURE 0x5A4D // MZ +#define EFI_IMAGE_OS2_SIGNATURE 0x454E // NE +#define EFI_IMAGE_OS2_SIGNATURE_LE 0x454C // LE +#define EFI_IMAGE_NT_SIGNATURE 0x00004550 // PE00 +#define EFI_IMAGE_EDOS_SIGNATURE 0x44454550 // PEED +// +// PE images can start with an optional DOS header, so if an image is run +// under DOS it can print an error message. +// +typedef struct { + UINT16 e_magic; // Magic number + UINT16 e_cblp; // Bytes on last page of file + UINT16 e_cp; // Pages in file + UINT16 e_crlc; // Relocations + UINT16 e_cparhdr; // Size of header in paragraphs + UINT16 e_minalloc; // Minimum extra paragraphs needed + UINT16 e_maxalloc; // Maximum extra paragraphs needed + UINT16 e_ss; // Initial (relative) SS value + UINT16 e_sp; // Initial SP value + UINT16 e_csum; // Checksum + UINT16 e_ip; // Initial IP value + UINT16 e_cs; // Initial (relative) CS value + UINT16 e_lfarlc; // File address of relocation table + UINT16 e_ovno; // Overlay number + UINT16 e_res[4]; // Reserved words + UINT16 e_oemid; // OEM identifier (for e_oeminfo) + UINT16 e_oeminfo; // OEM information; e_oemid specific + UINT16 e_res2[10]; // Reserved words + UINT32 e_lfanew; // File address of new exe header +} EFI_IMAGE_DOS_HEADER; + +// +// File header format. +// +typedef struct { + UINT16 Machine; + UINT16 NumberOfSections; + UINT32 TimeDateStamp; + UINT32 PointerToSymbolTable; + UINT32 NumberOfSymbols; + UINT16 SizeOfOptionalHeader; + UINT16 Characteristics; +} EFI_IMAGE_FILE_HEADER; + +#define EFI_IMAGE_SIZEOF_FILE_HEADER 20 + +#define EFI_IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file. +#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references). +#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file. +#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file. +#define EFI_IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed. +#define EFI_IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine. +#define EFI_IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file +#define EFI_IMAGE_FILE_SYSTEM 0x1000 // System File. +#define EFI_IMAGE_FILE_DLL 0x2000 // File is a DLL. +#define EFI_IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed. +#define EFI_IMAGE_FILE_MACHINE_UNKNOWN 0 +#define EFI_IMAGE_FILE_MACHINE_I386 0x14c // Intel 386. +#define EFI_IMAGE_FILE_MACHINE_R3000 0x162 // MIPS* little-endian, 0540 big-endian +#define EFI_IMAGE_FILE_MACHINE_R4000 0x166 // MIPS* little-endian +#define EFI_IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP* +#define EFI_IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM* PowerPC Little-Endian +#define EFI_IMAGE_FILE_MACHINE_TAHOE 0x7cc // Intel EM machine +// +// * Other names and brands may be claimed as the property of others. +// +// +// Directory format. +// +typedef struct { + UINT32 VirtualAddress; + UINT32 Size; +} EFI_IMAGE_DATA_DIRECTORY; + +#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16 + +typedef struct { + UINT16 Magic; + UINT8 MajorLinkerVersion; + UINT8 MinorLinkerVersion; + UINT32 SizeOfCode; + UINT32 SizeOfInitializedData; + UINT32 SizeOfUninitializedData; + UINT32 AddressOfEntryPoint; + UINT32 BaseOfCode; + UINT32 BaseOfData; + UINT32 BaseOfBss; + UINT32 GprMask; + UINT32 CprMask[4]; + UINT32 GpValue; +} EFI_IMAGE_ROM_OPTIONAL_HEADER; + +#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107 +#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER) + +typedef struct { + EFI_IMAGE_FILE_HEADER FileHeader; + EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader; +} EFI_IMAGE_ROM_HEADERS; + +// +// ATTENTION!!! EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64 +// are for use ONLY by tools. All proper EFI code MUST use +// EFI_IMAGE_OPTIONAL_HEADER ONLY!!! +// +#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b + +typedef struct { + // + // Standard fields. + // + UINT16 Magic; + UINT8 MajorLinkerVersion; + UINT8 MinorLinkerVersion; + UINT32 SizeOfCode; + UINT32 SizeOfInitializedData; + UINT32 SizeOfUninitializedData; + UINT32 AddressOfEntryPoint; + UINT32 BaseOfCode; + UINT32 BaseOfData; + // + // NT additional fields. + // + UINT32 ImageBase; + UINT32 SectionAlignment; + UINT32 FileAlignment; + UINT16 MajorOperatingSystemVersion; + UINT16 MinorOperatingSystemVersion; + UINT16 MajorImageVersion; + UINT16 MinorImageVersion; + UINT16 MajorSubsystemVersion; + UINT16 MinorSubsystemVersion; + UINT32 Win32VersionValue; + UINT32 SizeOfImage; + UINT32 SizeOfHeaders; + UINT32 CheckSum; + UINT16 Subsystem; + UINT16 DllCharacteristics; + UINT32 SizeOfStackReserve; + UINT32 SizeOfStackCommit; + UINT32 SizeOfHeapReserve; + UINT32 SizeOfHeapCommit; + UINT32 LoaderFlags; + UINT32 NumberOfRvaAndSizes; + EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; +} EFI_IMAGE_OPTIONAL_HEADER32; + +// +// ATTENTION!!! EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64 +// are for use ONLY by tools. All proper EFI code MUST use +// EFI_IMAGE_OPTIONAL_HEADER ONLY!!! +// +#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b + +typedef struct { + // + // Standard fields. + // + UINT16 Magic; + UINT8 MajorLinkerVersion; + UINT8 MinorLinkerVersion; + UINT32 SizeOfCode; + UINT32 SizeOfInitializedData; + UINT32 SizeOfUninitializedData; + UINT32 AddressOfEntryPoint; + UINT32 BaseOfCode; + // + // NT additional fields. + // + UINT64 ImageBase; + UINT32 SectionAlignment; + UINT32 FileAlignment; + UINT16 MajorOperatingSystemVersion; + UINT16 MinorOperatingSystemVersion; + UINT16 MajorImageVersion; + UINT16 MinorImageVersion; + UINT16 MajorSubsystemVersion; + UINT16 MinorSubsystemVersion; + UINT32 Win32VersionValue; + UINT32 SizeOfImage; + UINT32 SizeOfHeaders; + UINT32 CheckSum; + UINT16 Subsystem; + UINT16 DllCharacteristics; + UINT64 SizeOfStackReserve; + UINT64 SizeOfStackCommit; + UINT64 SizeOfHeapReserve; + UINT64 SizeOfHeapCommit; + UINT32 LoaderFlags; + UINT32 NumberOfRvaAndSizes; + EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; +} EFI_IMAGE_OPTIONAL_HEADER64; + +// +// ATTENTION!!! EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY +// by tools. All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!! +// +typedef struct { + UINT32 Signature; + EFI_IMAGE_FILE_HEADER FileHeader; + EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader; +} EFI_IMAGE_NT_HEADERS32; + +#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32) + +typedef struct { + UINT32 Signature; + EFI_IMAGE_FILE_HEADER FileHeader; + EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader; +} EFI_IMAGE_NT_HEADERS64; + +#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64) + +// +// Include processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the +// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build. Same for +// EFI_IMAGE_NT_HEADERS. These definitions MUST be used by ALL EFI code. +// +#include "EfiPeOptionalHeader.h" + +#define EFI_IMAGE_FIRST_SECTION(ntheader) \ + ( \ + (EFI_IMAGE_SECTION_HEADER *) \ + ( \ + (UINT32) ntheader + \ + FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \ + ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \ + ) \ + ) + +// +// Subsystem Values +// +#define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0 +#define EFI_IMAGE_SUBSYSTEM_NATIVE 1 +#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2 +#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3. +#define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5 +#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7 + +// +// Directory Entries +// +#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0 +#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1 +#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2 +#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 +#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4 +#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5 +#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6 +#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 +#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 +#define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9 +#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 + +// +// Section header format. +// +#define EFI_IMAGE_SIZEOF_SHORT_NAME 8 + +typedef struct { + UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME]; + union { + UINT32 PhysicalAddress; + UINT32 VirtualSize; + } Misc; + UINT32 VirtualAddress; + UINT32 SizeOfRawData; + UINT32 PointerToRawData; + UINT32 PointerToRelocations; + UINT32 PointerToLinenumbers; + UINT16 NumberOfRelocations; + UINT16 NumberOfLinenumbers; + UINT32 Characteristics; +} EFI_IMAGE_SECTION_HEADER; + +#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40 + +#define EFI_IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved. +#define EFI_IMAGE_SCN_CNT_CODE 0x00000020 +#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 +#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 + +#define EFI_IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved. +#define EFI_IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information. +#define EFI_IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image. +#define EFI_IMAGE_SCN_LNK_COMDAT 0x00001000 + +#define EFI_IMAGE_SCN_ALIGN_1BYTES 0x00100000 +#define EFI_IMAGE_SCN_ALIGN_2BYTES 0x00200000 +#define EFI_IMAGE_SCN_ALIGN_4BYTES 0x00300000 +#define EFI_IMAGE_SCN_ALIGN_8BYTES 0x00400000 +#define EFI_IMAGE_SCN_ALIGN_16BYTES 0x00500000 +#define EFI_IMAGE_SCN_ALIGN_32BYTES 0x00600000 +#define EFI_IMAGE_SCN_ALIGN_64BYTES 0x00700000 + +#define EFI_IMAGE_SCN_MEM_DISCARDABLE 0x02000000 +#define EFI_IMAGE_SCN_MEM_NOT_CACHED 0x04000000 +#define EFI_IMAGE_SCN_MEM_NOT_PAGED 0x08000000 +#define EFI_IMAGE_SCN_MEM_SHARED 0x10000000 +#define EFI_IMAGE_SCN_MEM_EXECUTE 0x20000000 +#define EFI_IMAGE_SCN_MEM_READ 0x40000000 +#define EFI_IMAGE_SCN_MEM_WRITE 0x80000000 + +// +// Symbol format. +// +#define EFI_IMAGE_SIZEOF_SYMBOL 18 + +// +// Section values. +// +// Symbols have a section number of the section in which they are +// defined. Otherwise, section numbers have the following meanings: +// +#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 // Symbol is undefined or is common. +#define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 // Symbol is an absolute value. +#define EFI_IMAGE_SYM_DEBUG (UINT16) -2 // Symbol is a special debug item. +// +// Type (fundamental) values. +// +#define EFI_IMAGE_SYM_TYPE_NULL 0 // no type. +#define EFI_IMAGE_SYM_TYPE_VOID 1 // +#define EFI_IMAGE_SYM_TYPE_CHAR 2 // type character. +#define EFI_IMAGE_SYM_TYPE_SHORT 3 // type short integer. +#define EFI_IMAGE_SYM_TYPE_INT 4 +#define EFI_IMAGE_SYM_TYPE_LONG 5 +#define EFI_IMAGE_SYM_TYPE_FLOAT 6 +#define EFI_IMAGE_SYM_TYPE_DOUBLE 7 +#define EFI_IMAGE_SYM_TYPE_STRUCT 8 +#define EFI_IMAGE_SYM_TYPE_UNION 9 +#define EFI_IMAGE_SYM_TYPE_ENUM 10 // enumeration. +#define EFI_IMAGE_SYM_TYPE_MOE 11 // member of enumeration. +#define EFI_IMAGE_SYM_TYPE_BYTE 12 +#define EFI_IMAGE_SYM_TYPE_WORD 13 +#define EFI_IMAGE_SYM_TYPE_UINT 14 +#define EFI_IMAGE_SYM_TYPE_DWORD 15 + +// +// Type (derived) values. +// +#define EFI_IMAGE_SYM_DTYPE_NULL 0 // no derived type. +#define EFI_IMAGE_SYM_DTYPE_POINTER 1 +#define EFI_IMAGE_SYM_DTYPE_FUNCTION 2 +#define EFI_IMAGE_SYM_DTYPE_ARRAY 3 + +// +// Storage classes. +// +#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION (UINT8) -1 +#define EFI_IMAGE_SYM_CLASS_NULL 0 +#define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1 +#define EFI_IMAGE_SYM_CLASS_EXTERNAL 2 +#define EFI_IMAGE_SYM_CLASS_STATIC 3 +#define EFI_IMAGE_SYM_CLASS_REGISTER 4 +#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5 +#define EFI_IMAGE_SYM_CLASS_LABEL 6 +#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7 +#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8 +#define EFI_IMAGE_SYM_CLASS_ARGUMENT 9 +#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10 +#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11 +#define EFI_IMAGE_SYM_CLASS_UNION_TAG 12 +#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13 +#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14 +#define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15 +#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16 +#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17 +#define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18 +#define EFI_IMAGE_SYM_CLASS_BLOCK 100 +#define EFI_IMAGE_SYM_CLASS_FUNCTION 101 +#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102 +#define EFI_IMAGE_SYM_CLASS_FILE 103 +#define EFI_IMAGE_SYM_CLASS_SECTION 104 +#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105 + +// +// type packing constants +// +#define EFI_IMAGE_N_BTMASK 017 +#define EFI_IMAGE_N_TMASK 060 +#define EFI_IMAGE_N_TMASK1 0300 +#define EFI_IMAGE_N_TMASK2 0360 +#define EFI_IMAGE_N_BTSHFT 4 +#define EFI_IMAGE_N_TSHIFT 2 + +// +// Communal selection types. +// +#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1 +#define EFI_IMAGE_COMDAT_SELECT_ANY 2 +#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3 +#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4 +#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 + +#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1 +#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 +#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3 + +// +// Relocation format. +// +typedef struct { + UINT32 VirtualAddress; + UINT32 SymbolTableIndex; + UINT16 Type; +} EFI_IMAGE_RELOCATION; + +#define EFI_IMAGE_SIZEOF_RELOCATION 10 + +// +// I386 relocation types. +// +#define EFI_IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary +#define EFI_IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address +#define EFI_IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address +#define EFI_IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address +#define EFI_IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included +#define EFI_IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address +#define EFI_IMAGE_REL_I386_SECTION 012 +#define EFI_IMAGE_REL_I386_SECREL 013 +#define EFI_IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address +// +// Based relocation format. +// +typedef struct { + UINT32 VirtualAddress; + UINT32 SizeOfBlock; +} EFI_IMAGE_BASE_RELOCATION; + +#define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8 + +// +// Based relocation types. +// +#define EFI_IMAGE_REL_BASED_ABSOLUTE 0 +#define EFI_IMAGE_REL_BASED_HIGH 1 +#define EFI_IMAGE_REL_BASED_LOW 2 +#define EFI_IMAGE_REL_BASED_HIGHLOW 3 +#define EFI_IMAGE_REL_BASED_HIGHADJ 4 +#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5 +#define EFI_IMAGE_REL_BASED_IA64_IMM64 9 +#define EFI_IMAGE_REL_BASED_DIR64 10 + +// +// Line number format. +// +typedef struct { + union { + UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0. + UINT32 VirtualAddress; // Virtual address of line number. + } Type; + UINT16 Linenumber; // Line number. +} EFI_IMAGE_LINENUMBER; + +#define EFI_IMAGE_SIZEOF_LINENUMBER 6 + +// +// Archive format. +// +#define EFI_IMAGE_ARCHIVE_START_SIZE 8 +#define EFI_IMAGE_ARCHIVE_START "!\n" +#define EFI_IMAGE_ARCHIVE_END "`\n" +#define EFI_IMAGE_ARCHIVE_PAD "\n" +#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ " +#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// " + +typedef struct { + UINT8 Name[16]; // File member name - `/' terminated. + UINT8 Date[12]; // File member date - decimal. + UINT8 UserID[6]; // File member user id - decimal. + UINT8 GroupID[6]; // File member group id - decimal. + UINT8 Mode[8]; // File member mode - octal. + UINT8 Size[10]; // File member size - decimal. + UINT8 EndHeader[2]; // String to end header. +} EFI_IMAGE_ARCHIVE_MEMBER_HEADER; + +#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 + +// +// DLL support. +// +// +// Export Format +// +typedef struct { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT16 MajorVersion; + UINT16 MinorVersion; + UINT32 Name; + UINT32 Base; + UINT32 NumberOfFunctions; + UINT32 NumberOfNames; + UINT32 AddressOfFunctions; + UINT32 AddressOfNames; + UINT32 AddressOfNameOrdinals; +} EFI_IMAGE_EXPORT_DIRECTORY; + +// +// Import Format +// +typedef struct { + UINT16 Hint; + UINT8 Name[1]; +} EFI_IMAGE_IMPORT_BY_NAME; + +typedef struct { + union { + UINT32 Function; + UINT32 Ordinal; + EFI_IMAGE_IMPORT_BY_NAME *AddressOfData; + } u1; +} EFI_IMAGE_THUNK_DATA; + +#define EFI_IMAGE_ORDINAL_FLAG 0x80000000 +#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0) +#define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) + +typedef struct { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT32 ForwarderChain; + UINT32 Name; + EFI_IMAGE_THUNK_DATA *FirstThunk; +} EFI_IMAGE_IMPORT_DESCRIPTOR; + +// +// Debug Format +// +#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 + +typedef struct { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT16 MajorVersion; + UINT16 MinorVersion; + UINT32 Type; + UINT32 SizeOfData; + UINT32 RVA; + UINT32 FileOffset; +} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY; + +#define CODEVIEW_SIGNATURE_NB10 0x3031424E // "NB10" +typedef struct { + UINT32 Signature; // "NB10" + UINT32 Unknown; + UINT32 Unknown2; + UINT32 Unknown3; + // + // Filename of .PDB goes here + // +} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY; + +#define CODEVIEW_SIGNATURE_RSDS 0x53445352 // "RSDS" +typedef struct { + UINT32 Signature; // "RSDS" + UINT32 Unknown; + UINT32 Unknown2; + UINT32 Unknown3; + UINT32 Unknown4; + UINT32 Unknown5; + // + // Filename of .PDB goes here + // +} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY; + +// +// Header format for TE images +// +typedef struct { + UINT16 Signature; // signature for TE format = "VZ" + UINT16 Machine; // from the original file header + UINT8 NumberOfSections; // from the original file header + UINT8 Subsystem; // from original optional header + UINT16 StrippedSize; // how many bytes we removed from the header + UINT32 AddressOfEntryPoint; // offset to entry point -- from original optional header + UINT32 BaseOfCode; // from original image -- required for ITP debug + UINT64 ImageBase; // from original file header + EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; // only base relocation and debug directory +} EFI_TE_IMAGE_HEADER; + +#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56 // "VZ" +// +// Data directory indexes in our TE image header +// +#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0 +#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1 + +// +// Union of PE32, PE32+, and TE headers +// +typedef union { + EFI_IMAGE_NT_HEADERS32 Pe32; + EFI_IMAGE_NT_HEADERS64 Pe32Plus; + EFI_TE_IMAGE_HEADER Te; +} EFI_IMAGE_OPTIONAL_HEADER_UNION; + +typedef union { + EFI_IMAGE_NT_HEADERS32 *Pe32; + EFI_IMAGE_NT_HEADERS64 *Pe32Plus; + EFI_TE_IMAGE_HEADER *Te; + EFI_IMAGE_OPTIONAL_HEADER_UNION *Union; +} EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h new file mode 100644 index 0000000000..25a6e02ee9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h @@ -0,0 +1,292 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiTypes.h + +Abstract: + + EFI defined types. Use these types when ever possible! + +--*/ + +#ifndef _EFI_TYPES_H_ +#define _EFI_TYPES_H_ + +// +// EFI Data Types based on ANSI C integer types in EfiBind.h +// +typedef uint8_t BOOLEAN; +typedef intn_t INTN; +typedef uintn_t UINTN; +typedef int8_t INT8; +typedef uint8_t UINT8; +typedef int16_t INT16; +typedef uint16_t UINT16; +typedef int32_t INT32; +typedef uint32_t UINT32; +typedef int64_t INT64; +typedef uint64_t UINT64; +typedef uint8_t CHAR8; +typedef uint16_t CHAR16; +typedef UINT64 EFI_LBA; + +// +// Modifiers for EFI Data Types used to self document code. +// Please see EFI coding convention for proper usage. +// +#ifndef IN +// +// Some other envirnments use this construct, so #ifndef to prevent +// mulitple definition. +// +#define IN +#define OUT +#define OPTIONAL +#endif +#define UNALIGNED + +// +// Modifiers for EFI Runtime and Boot Services +// +#define EFI_RUNTIMESERVICE +#define EFI_BOOTSERVICE + +// +// Boot Service add in EFI 1.1 +// +#define EFI_BOOTSERVICE11 + +// +// Modifiers to absract standard types to aid in debug of problems +// +#define CONST const +#define STATIC static +#define VOID void +#define VOLATILE volatile + +// +// Modifier to ensure that all protocol member functions and EFI intrinsics +// use the correct C calling convention. All protocol member functions and +// EFI intrinsics are required to modify thier member functions with EFIAPI. +// +#define EFIAPI _EFIAPI + +// +// EFI Constants. They may exist in other build structures, so #ifndef them. +// +#ifndef TRUE +#define TRUE ((BOOLEAN) 1 == 1) +#endif + +#ifndef FALSE +#define FALSE ((BOOLEAN) 0 == 1) +#endif + +#ifndef NULL +#define NULL ((VOID *) 0) +#endif +// +// EFI Data Types derived from other EFI data types. +// +typedef UINTN EFI_STATUS; + +typedef VOID *EFI_HANDLE; +#define NULL_HANDLE ((VOID *) 0) + +typedef VOID *EFI_EVENT; +typedef UINTN EFI_TPL; + +typedef struct { + UINT32 Data1; + UINT16 Data2; + UINT16 Data3; + UINT8 Data4[8]; +} EFI_GUID; + +typedef union { + EFI_GUID Guid; + UINT8 Raw[16]; +} EFI_GUID_UNION; + +// +// EFI Time Abstraction: +// Year: 2000 - 20XX +// Month: 1 - 12 +// Day: 1 - 31 +// Hour: 0 - 23 +// Minute: 0 - 59 +// Second: 0 - 59 +// Nanosecond: 0 - 999,999,999 +// TimeZone: -1440 to 1440 or 2047 +// +typedef struct { + UINT16 Year; + UINT8 Month; + UINT8 Day; + UINT8 Hour; + UINT8 Minute; + UINT8 Second; + UINT8 Pad1; + UINT32 Nanosecond; + INT16 TimeZone; + UINT8 Daylight; + UINT8 Pad2; +} EFI_TIME; + +// +// Bit definitions for EFI_TIME.Daylight +// +#define EFI_TIME_ADJUST_DAYLIGHT 0x01 +#define EFI_TIME_IN_DAYLIGHT 0x02 + +// +// Value definition for EFI_TIME.TimeZone +// +#define EFI_UNSPECIFIED_TIMEZONE 0x07FF + +// +// Networking +// +typedef struct { + UINT8 Addr[4]; +} EFI_IPv4_ADDRESS; + +typedef struct { + UINT8 Addr[16]; +} EFI_IPv6_ADDRESS; + +typedef struct { + UINT8 Addr[32]; +} EFI_MAC_ADDRESS; + +typedef union { + UINT32 Addr[4]; + EFI_IPv4_ADDRESS v4; + EFI_IPv6_ADDRESS v6; +} EFI_IP_ADDRESS; + +typedef enum { + EfiReservedMemoryType, + EfiLoaderCode, + EfiLoaderData, + EfiBootServicesCode, + EfiBootServicesData, + EfiRuntimeServicesCode, + EfiRuntimeServicesData, + EfiConventionalMemory, + EfiUnusableMemory, + EfiACPIReclaimMemory, + EfiACPIMemoryNVS, + EfiMemoryMappedIO, + EfiMemoryMappedIOPortSpace, + EfiPalCode, + EfiMaxMemoryType +} EFI_MEMORY_TYPE; + +typedef enum { + AllocateAnyPages, + AllocateMaxAddress, + AllocateAddress, + MaxAllocateType +} EFI_ALLOCATE_TYPE; + +typedef struct { + UINT64 Signature; + UINT32 Revision; + UINT32 HeaderSize; + UINT32 CRC32; + UINT32 Reserved; +} EFI_TABLE_HEADER; + +// +// possible caching types for the memory range +// +#define EFI_MEMORY_UC 0x0000000000000001 +#define EFI_MEMORY_WC 0x0000000000000002 +#define EFI_MEMORY_WT 0x0000000000000004 +#define EFI_MEMORY_WB 0x0000000000000008 +#define EFI_MEMORY_UCE 0x0000000000000010 + +// +// physical memory protection on range +// +#define EFI_MEMORY_WP 0x0000000000001000 +#define EFI_MEMORY_RP 0x0000000000002000 +#define EFI_MEMORY_XP 0x0000000000004000 + +// +// range requires a runtime mapping +// +#define EFI_MEMORY_RUNTIME 0x8000000000000000 + +typedef UINT64 EFI_PHYSICAL_ADDRESS; +typedef UINT64 EFI_VIRTUAL_ADDRESS; + +#define EFI_MEMORY_DESCRIPTOR_VERSION 1 +typedef struct { + UINT32 Type; + UINT32 Pad; + EFI_PHYSICAL_ADDRESS PhysicalStart; + EFI_VIRTUAL_ADDRESS VirtualStart; + UINT64 NumberOfPages; + UINT64 Attribute; +} EFI_MEMORY_DESCRIPTOR; + +// +// The EFI memory allocation functions work in units of EFI_PAGEs that are +// 4K. This should in no way be confused with the page size of the processor. +// An EFI_PAGE is just the quanta of memory in EFI. +// +#define EFI_PAGE_SIZE 4096 +#define EFI_PAGE_MASK 0xFFF +#define EFI_PAGE_SHIFT 12 + +#define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0)) + +#define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT) + +// +// ALIGN_POINTER - aligns a pointer to the lowest boundry +// +#define ALIGN_POINTER(p, s) ((VOID *) (p + ((s - ((UINTN) p)) & (s - 1)))) + +// +// ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor +// +#define ALIGN_VARIABLE(Value, Adjustment) \ + (UINTN) Adjustment = 0; \ + if ((UINTN) Value % sizeof (UINTN)) { \ + (UINTN) Adjustment = sizeof (UINTN) - ((UINTN) Value % sizeof (UINTN)); \ + } \ + Value = (UINTN) Value + (UINTN) Adjustment + +// +// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure +// +#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field))) + +// +// CONTAINING_RECORD - returns a pointer to the structure +// from one of it's elements. +// +#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) + +// +// Define macros to build data structure signatures from characters. +// +#define EFI_SIGNATURE_16(A, B) ((A) | (B << 8)) +#define EFI_SIGNATURE_32(A, B, C, D) (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16)) +#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \ + (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32)) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/Pxe.h b/EdkCompatibilityPkg/Foundation/Efi/Include/Pxe.h new file mode 100644 index 0000000000..ee0ca1f0e7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Include/Pxe.h @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + pxe.h + +Abstract: + + PXE 2.1 Common Structures + +Revision History + +--*/ + +#ifndef _PXE_H +#define _PXE_H + +// +// Packet definitions +// +typedef struct { + UINT8 BootpOpcode; + UINT8 BootpHwType; + UINT8 BootpHwAddrLen; + UINT8 BootpGateHops; + UINT32 BootpIdent; + UINT16 BootpSeconds; + UINT16 BootpFlags; + UINT8 BootpCiAddr[4]; + UINT8 BootpYiAddr[4]; + UINT8 BootpSiAddr[4]; + UINT8 BootpGiAddr[4]; + UINT8 BootpHwAddr[16]; + UINT8 BootpSrvName[64]; + UINT8 BootpBootFile[128]; + UINT32 DhcpMagik; + UINT8 DhcpOptions[56]; +} EFI_PXE_BASE_CODE_DHCPV4_PACKET; + +typedef union { + UINT8 Raw[1472]; + EFI_PXE_BASE_CODE_DHCPV4_PACKET Dhcpv4; + + // + // EFI_PXE_BASE_CODE_DHCPV6_PACKET Dhcpv6; + // +} EFI_PXE_BASE_CODE_PACKET; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c new file mode 100644 index 0000000000..0ab1f7095f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiTable.c + +Abstract: + + ACPI Table Protocol from the UEFI 2.1 specification. + + This protocol may be used to install or remove an ACPI table from a platform. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (AcpiTable) + +EFI_GUID gEfiAcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiAcpiTableProtocolGuid, "UEFI ACPI Table Protocol", "UEFI ACPI Table Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h new file mode 100644 index 0000000000..2b7d27fd1a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h @@ -0,0 +1,112 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiTable.h + +Abstract: + + ACPI Table Protocol from the UEFI 2.1 specification. + + This protocol may be used to install or remove an ACPI table from a platform. + +--*/ + +#ifndef __ACPI_TABLE_H__ +#define __ACPI_TABLE_H__ + +#include "Acpi.h" + +// +// Global ID for the Acpi Table Protocol +// +#define EFI_ACPI_TABLE_PROTOCOL_GUID \ + { \ + 0xffe06bdd, 0x6107, 0x46a6, 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c \ + } + +EFI_FORWARD_DECLARATION (EFI_ACPI_TABLE_PROTOCOL); + +#define UEFI_ACPI_TABLE_SIGNATURE EFI_SIGNATURE_32 ('U', 'E', 'F', 'I') + +#pragma pack(1) + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + EFI_GUID Identifier; + UINT16 DataOffset; +} EFI_ACPI_TABLE; + +#pragma pack() + +typedef +EFI_STATUS +(EFIAPI *EFI_ACPI_TABLE_INSTALL_ACPI_TABLE) ( + IN EFI_ACPI_TABLE_PROTOCOL *This, + IN VOID *AcpiTableBuffer, + IN UINTN AcpiTableBufferSize, + OUT UINTN *TableKey + ) +/*++ + + Routine Description: + Installs an ACPI table into the RSDT/XSDT. + + Arguments: + This - Protocol instance pointer. + AcpiTableBuffer - A pointer to a buffer containing the ACPI table to be installed. + AcpiTableBufferSize - Specifies the size, in bytes, of the AcpiTableBuffer buffer. + TableKey - Reurns a key to refer to the ACPI table. + + Returns: + EFI_SUCCESS - The table was successfully inserted. + EFI_INVALID_PARAMETER - Either AcpiTableBuffer is NULL, TableKey is NULL, or AcpiTableBufferSize + and the size field embedded in the ACPI table pointed to by AcpiTableBuffer + are not in sync. + EFI_OUT_OF_RESOURCES - Insufficient resources exist to complete the request. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE) ( + IN EFI_ACPI_TABLE_PROTOCOL *This, + IN UINTN TableKey + ) +/*++ + + Routine Description: + Removes an ACPI table from the RSDT/XSDT. + + Arguments: + This - Protocol instance pointer. + TableKey - Specifies the table to uninstall. The key was returned from InstallAcpiTable(). + + Returns: + EFI_SUCCESS - The table was successfully uninstalled. + EFI_NOT_FOUND - TableKey does not refer to a valid key for a table entry. + +--*/ +; + +// +// Interface structure for the ACPI Table Protocol +// +typedef struct _EFI_ACPI_TABLE_PROTOCOL { + EFI_ACPI_TABLE_INSTALL_ACPI_TABLE InstallAcpiTable; + EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE UninstallAcpiTable; +} EFI_ACPI_TABLE_PROTOCOL; + +extern EFI_GUID gEfiAcpiTableProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.c new file mode 100644 index 0000000000..9b6af4c6b4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Arp.c + +Abstract: + + UEFI Arp protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Arp) + +EFI_GUID gEfiArpServiceBindingProtocolGuid = EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID; +EFI_GUID gEfiArpProtocolGuid = EFI_ARP_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiArpServiceBindingProtocolGuid, "ARP Service Binding Protocol", "ARP Service Binding Protocol"); +EFI_GUID_STRING (&gEfiArpProtocolGuid, "ARP Protocol", "ARP Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.h new file mode 100644 index 0000000000..2a7e81f3c5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Arp/Arp.h @@ -0,0 +1,136 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Arp.h + +Abstract: + + UEFI Arp protocol definition. + +--*/ + +#ifndef _ARP_H_ +#define _ARP_H_ + +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) + +#define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \ + { 0xf44c00ee, 0x1f2c, 0x4a00, 0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3 } + +#define EFI_ARP_PROTOCOL_GUID \ + { 0xf4b427bb, 0xba21, 0x4f16, 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } + +EFI_FORWARD_DECLARATION (EFI_ARP_PROTOCOL); + +typedef struct _EFI_ARP_FIND_DATA { +UINT32 Size; +BOOLEAN DenyFlag; +BOOLEAN StaticFlag; +UINT16 HwAddressType; +UINT16 SwAddressType; +UINT8 HwAddressLength; +UINT8 SwAddressLength; +} EFI_ARP_FIND_DATA; + + +//**************************************************** +// EFI_ARP_CONFIG_DATA +//**************************************************** +typedef struct EFI_ARP_CONFIG_DATA { + UINT16 SwAddressType; // Host byte order + UINT8 SwAddressLength; + VOID *StationAddress; // Network byte order + UINT32 EntryTimeOut; + UINT32 RetryCount; + UINT32 RetryTimeOut; +} EFI_ARP_CONFIG_DATA; + + +typedef +EFI_STATUS +(EFIAPI *EFI_ARP_CONFIGURE) ( + IN EFI_ARP_PROTOCOL *This, + IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_ARP_ADD) ( + IN EFI_ARP_PROTOCOL *This, + IN BOOLEAN DenyFlag, + IN VOID *TargetSwAddress OPTIONAL, + IN VOID *TargetHwAddress OPTIONAL, + IN UINT32 TimeoutValue, + IN BOOLEAN Overwrite + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ARP_FIND) ( + IN EFI_ARP_PROTOCOL *This, + IN BOOLEAN BySwAddress, + IN VOID *AddressBuffer OPTIONAL, + OUT UINT32 *EntryLength OPTIONAL, + OUT UINT32 *EntryCount OPTIONAL, + OUT EFI_ARP_FIND_DATA **Entries OPTIONAL, + IN BOOLEAN Refresh +); + + +typedef +EFI_STATUS +(EFIAPI *EFI_ARP_DELETE) ( + IN EFI_ARP_PROTOCOL *This, + IN BOOLEAN BySwAddress, + IN VOID *AddressBuffer OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ARP_FLUSH) ( + IN EFI_ARP_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ARP_REQUEST) ( + IN EFI_ARP_PROTOCOL *This, + IN VOID *TargetSwAddress OPTIONAL, + IN EFI_EVENT ResolvedEvent OPTIONAL, + OUT VOID *TargetHwAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ARP_CANCEL) ( +IN EFI_ARP_PROTOCOL *This, +IN VOID *TargetSwAddress OPTIONAL, +IN EFI_EVENT ResolvedEvent OPTIONAL +); + +typedef struct _EFI_ARP_PROTOCOL { + EFI_ARP_CONFIGURE Configure; + EFI_ARP_ADD Add; + EFI_ARP_FIND Find; + EFI_ARP_DELETE Delete; + EFI_ARP_FLUSH Flush; + EFI_ARP_REQUEST Request; + EFI_ARP_CANCEL Cancel; +} EFI_ARP_PROTOCOL; + + +extern EFI_GUID gEfiArpServiceBindingProtocolGuid; +extern EFI_GUID gEfiArpProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.c new file mode 100644 index 0000000000..649f51cce8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Bis.c + +Abstract: + + This file defines the Bis protocol + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Bis) + +EFI_GUID gEfiBisProtocolGuid = EFI_BIS_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiBisProtocolGuid, "BIS Base Protocol", "BIS Base protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.h new file mode 100644 index 0000000000..71d5fb3b10 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Bis/Bis.h @@ -0,0 +1,233 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Bis.h + +Abstract: + + This file defines the BIS protocol. + +--*/ + +#ifndef _BIS_H_ +#define _BIS_H_ + +#include + +// +// Basic types +// +typedef VOID *BIS_APPLICATION_HANDLE; +typedef UINT16 BIS_ALG_ID; +typedef UINT32 BIS_CERT_ID; + +// +// EFI_BIS_DATA type. +// +// EFI_BIS_DATA instances obtained from BIS must be freed by calling Free( ). +// +typedef struct _EFI_BIS_DATA { + UINT32 Length; // Length of Data in 8 bit bytes. + UINT8 *Data; // 32 Bit Flat Address of data. +} EFI_BIS_DATA; + +// +// EFI_BIS_VERSION type. +// +typedef struct _EFI_BIS_VERSION { + UINT32 Major; // BIS Interface version number. + UINT32 Minor; // Build number. +} EFI_BIS_VERSION; + +// +// ----------------------------------------------------// +// Use these values to initialize EFI_BIS_VERSION.Major +// and to interpret results of Initialize. +// ----------------------------------------------------// +// +#define BIS_CURRENT_VERSION_MAJOR BIS_VERSION_1 +#define BIS_VERSION_1 1 + +// +// EFI_BIS_SIGNATURE_INFO type. +// +typedef struct _EFI_BIS_SIGNATURE_INFO { + BIS_CERT_ID CertificateID; // Truncated hash of platform Boot Object + // authorization certificate. + // + BIS_ALG_ID AlgorithmID; // A signature algorithm number. + UINT16 KeyLength; // Length of alg. keys in bits. +} EFI_BIS_SIGNATURE_INFO; + +// +// Currently defined values for EFI_BIS_SIGNATURE_INFO.AlgorithmID. +// The exact numeric values come from +// "Common Data Security Architecture (CDSA) Specification". +// +#define BIS_ALG_DSA (41) // CSSM_ALGID_DSA +#define BIS_ALG_RSA_MD5 (42) // CSSM_ALGID_MD5_WITH_RSA +// Currently defined values for EFI_BIS_SIGNATURE_INFO.CertificateId. +// +#define BIS_CERT_ID_DSA BIS_ALG_DSA // CSSM_ALGID_DSA +#define BIS_CERT_ID_RSA_MD5 BIS_ALG_RSA_MD5 // CSSM_ALGID_MD5_WITH_RSA +// The following is a mask value that gets applied to the truncated hash of a +// platform Boot Object Authorization Certificate to create the certificateID. +// A certificateID must not have any bits set to the value 1 other than bits in +// this mask. +// +#define BIS_CERT_ID_MASK (0xFF7F7FFF) + +// +// Macros for dealing with the EFI_BIS_DATA object obtained +// from BIS_GetSignatureInfo() +// BIS_GET_SIGINFO_COUNT - tells how many EFI_BIS_SIGNATURE_INFO +// elements are contained in a EFI_BIS_DATA struct pointed to +// by the provided EFI_BIS_DATA*. +// +#define BIS_GET_SIGINFO_COUNT(BisDataPtr) ((BisDataPtr)->Length / sizeof (EFI_BIS_SIGNATURE_INFO)) + +// +// BIS_GET_SIGINFO_ARRAY - produces a EFI_BIS_SIGNATURE_INFO* +// from a given EFI_BIS_DATA*. +// +#define BIS_GET_SIGINFO_ARRAY(BisDataPtr) ((EFI_BIS_SIGNATURE_INFO *) (BisDataPtr)->Data) + +// +// Binary Value of "X-Intel-BIS-ParameterSet" Attribute. +// (Value is Base64 encoded in actual signed manifest). +// {EDD35E31-07B9-11d2-83A3-00A0C91FADCF} +// +#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE \ + { \ + 0xedd35e31, 0x7b9, 0x11d2, \ + { \ + 0x83, 0xa3, 0x0, 0xa0, 0xc9, 0x1f, 0xad, 0xcf \ + } \ + } + +// +// -----------------------------------// +// EFI_BIS_PROTOCOL +// -----------------------------------// +// +#define EFI_BIS_PROTOCOL_GUID \ + { \ + 0x0b64aab0, 0x5429, 0x11d4, 0x98, 0x16, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf \ + } + +typedef struct _EFI_BIS_PROTOCOL EFI_BIS_PROTOCOL; + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_INITIALIZE) ( + IN EFI_BIS_PROTOCOL * This, // this + OUT BIS_APPLICATION_HANDLE * AppHandle, // Application handle. + IN OUT EFI_BIS_VERSION * InterfaceVersion, // ver needed/available. + IN EFI_BIS_DATA * TargetAddress // Address of BIS platform. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_FREE) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + IN EFI_BIS_DATA * ToFree // EFI_BIS_DATA being freed. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_SHUTDOWN) ( + IN BIS_APPLICATION_HANDLE AppHandle // From Initialize( ). + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + OUT EFI_BIS_DATA **Certificate // Pointer to certificate. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_VERIFY_BOOT_OBJECT) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + IN EFI_BIS_DATA * Credentials, // Verification signed manifest. + IN EFI_BIS_DATA * DataObject, // Boot object to verify. + OUT BOOLEAN *IsVerified // Result of verifcation. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + OUT BOOLEAN *CheckIsRequired // Value of check flag. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + OUT EFI_BIS_DATA **UpdateToken // Value of update token. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + IN EFI_BIS_DATA * RequestCredential, // Update Request Manifest. + OUT EFI_BIS_DATA **NewUpdateToken // Next update token. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + IN EFI_BIS_DATA * Credentials, // Verification signed manifest. + IN EFI_BIS_DATA * DataObject, // Boot object to verify. + IN EFI_BIS_DATA * SectionName, // Name of credential section to use. + IN EFI_BIS_DATA * AuthorityCertificate, // Certificate for credentials. + OUT BOOLEAN *IsVerified // Result of verifcation. + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BIS_GET_SIGNATURE_INFO) ( + IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ). + OUT EFI_BIS_DATA **SignatureInfo // Signature info struct. + ); + +#define EFI_BIS_PROTOCOL_REVISION 0x00010000 + +typedef struct _EFI_BIS_PROTOCOL { + // + // member vars + // + UINT64 Revision; + + // + // methods + // + EFI_BIS_INITIALIZE Initialize; + EFI_BIS_SHUTDOWN Shutdown; + EFI_BIS_FREE Free; + EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE GetBootObjectAuthorizationCertificate; + EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG GetBootObjectAuthorizationCheckFlag; + EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN GetBootObjectAuthorizationUpdateToken; + EFI_BIS_GET_SIGNATURE_INFO GetSignatureInfo; + EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION UpdateBootObjectAuthorization; + EFI_BIS_VERIFY_BOOT_OBJECT VerifyBootObject; + EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL VerifyObjectWithCredential; +} EFI_BIS_PROTOCOL; + +extern EFI_GUID gEfiBisProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.c new file mode 100644 index 0000000000..5b7ac3926b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BlockIo.c + +Abstract: + + Block IO protocol as defined in the EFI 1.0 specification. + + The Block IO protocol is used to abstract block devices like hard drives, + DVD-ROMs and floppy drives. + + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (BlockIo) + +EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiBlockIoProtocolGuid, "BlockIo Protocol", "EFI 1.0 Block IO protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.h new file mode 100644 index 0000000000..740b58d64c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIO/BlockIO.h @@ -0,0 +1,206 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BlockIo.h + +Abstract: + + Block IO protocol as defined in the EFI 1.0 specification. + + The Block IO protocol is used to abstract block devices like hard drives, + DVD-ROMs and floppy drives. + + +--*/ + +#ifndef __BLOCK_IO_H__ +#define __BLOCK_IO_H__ + +#define EFI_BLOCK_IO_PROTOCOL_GUID \ + { \ + 0x964e5b21, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_BLOCK_IO_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_RESET) ( + IN EFI_BLOCK_IO_PROTOCOL * This, + IN BOOLEAN ExtendedVerification + ) +/*++ + + Routine Description: + Reset the Block Device. + + Arguments: + This - Protocol instance pointer. + ExtendedVerification - Driver may perform diagnostics on reset. + + Returns: + EFI_SUCCESS - The device was reset. + EFI_DEVICE_ERROR - The device is not functioning properly and could + not be reset. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_READ) ( + IN EFI_BLOCK_IO_PROTOCOL * This, + IN UINT32 MediaId, + IN EFI_LBA Lba, + IN UINTN BufferSize, + OUT VOID *Buffer + ) +/*++ + + Routine Description: + Read BufferSize bytes from Lba into Buffer. + + Arguments: + This - Protocol instance pointer. + MediaId - Id of the media, changes every time the media is replaced. + Lba - The starting Logical Block Address to read from + BufferSize - Size of Buffer, must be a multiple of device block size. + Buffer - Buffer containing read data + + Returns: + EFI_SUCCESS - The data was read correctly from the device. + EFI_DEVICE_ERROR - The device reported an error while performing the read. + EFI_NO_MEDIA - There is no media in the device. + EFI_MEDIA_CHANGED - The MediaId does not matched the current device. + EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the + device. + EFI_INVALID_PARAMETER - The read request contains device addresses that are not + valid for the device. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_WRITE) ( + IN EFI_BLOCK_IO_PROTOCOL * This, + IN UINT32 MediaId, + IN EFI_LBA Lba, + IN UINTN BufferSize, + IN VOID *Buffer + ) +/*++ + + Routine Description: + Write BufferSize bytes from Lba into Buffer. + + Arguments: + This - Protocol instance pointer. + MediaId - Id of the media, changes every time the media is replaced. + Lba - The starting Logical Block Address to read from + BufferSize - Size of Buffer, must be a multiple of device block size. + Buffer - Buffer containing read data + + Returns: + EFI_SUCCESS - The data was written correctly to the device. + EFI_WRITE_PROTECTED - The device can not be written to. + EFI_DEVICE_ERROR - The device reported an error while performing the write. + EFI_NO_MEDIA - There is no media in the device. + EFI_MEDIA_CHNAGED - The MediaId does not matched the current device. + EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the + device. + EFI_INVALID_PARAMETER - The write request contains a LBA that is not + valid for the device. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_FLUSH) ( + IN EFI_BLOCK_IO_PROTOCOL * This + ) +/*++ + + Routine Description: + Flush the Block Device. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - All outstanding data was written to the device + EFI_DEVICE_ERROR - The device reported an error while writting back the data + EFI_NO_MEDIA - There is no media in the device. + +--*/ +; + +/*++ + + Block IO read only mode data and updated only via members of BlockIO + + MediaId - The curent media Id. If the media changes, this value is changed. + RemovableMedia - TRUE if the media is removable; otherwise, FALSE. + MediaPresent - TRUE if there is a media currently present in the device; + othersise, FALSE. THis field shows the media present status + as of the most recent ReadBlocks() or WriteBlocks() call. + LogicalPartition - TRUE if LBA 0 is the first block of a partition; otherwise + FALSE. For media with only one partition this would be TRUE. + ReadOnly - TRUE if the media is marked read-only otherwise, FALSE. This + field shows the read-only status as of the most recent + WriteBlocks () call. + WriteCaching - TRUE if the WriteBlock () function caches write data. + BlockSize - The intrinsic block size of the device. If the media changes, then + this field is updated. + IoAlign - Supplies the alignment requirement for any buffer to read or write + block(s). + LastBlock - The last logical block address on the device. If the media changes, + then this field is updated. + +--*/ +typedef struct { + UINT32 MediaId; + BOOLEAN RemovableMedia; + BOOLEAN MediaPresent; + + BOOLEAN LogicalPartition; + BOOLEAN ReadOnly; + BOOLEAN WriteCaching; + + UINT32 BlockSize; + UINT32 IoAlign; + + EFI_LBA LastBlock; +} EFI_BLOCK_IO_MEDIA; + +#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000 + +typedef struct _EFI_BLOCK_IO_PROTOCOL { + UINT64 Revision; + + EFI_BLOCK_IO_MEDIA *Media; + + EFI_BLOCK_RESET Reset; + EFI_BLOCK_READ ReadBlocks; + EFI_BLOCK_WRITE WriteBlocks; + EFI_BLOCK_FLUSH FlushBlocks; + +} EFI_BLOCK_IO_PROTOCOL; + +extern EFI_GUID gEfiBlockIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c new file mode 100644 index 0000000000..4b4a44d09d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BusSpecificDriverOverride.c + +Abstract: + + Bus Specific Driver Override protocol as defined in the EFI 1.1 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride) + +EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid = EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiBusSpecificDriverOverrideProtocolGuid, "Bus Specific Driver Override Protocol", + "EFI 1.1 Bus Specific Driver Override Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h new file mode 100644 index 0000000000..ad7eade50a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BusSpecificDriverOverride.h + +Abstract: + + Bus Specific Driver Override protocol as defined in the EFI 1.1 specification. + +--*/ + +#ifndef _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_H_ +#define _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_H_ + +// +// Global ID for the Bus Specific Driver Override Protocol +// +#define EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID \ + { \ + 0x3bc1b285, 0x8a15, 0x4a82, 0xaa, 0xbf, 0x4d, 0x7d, 0x13, 0xfb, 0x32, 0x65 \ + } + +EFI_FORWARD_DECLARATION (EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL); + +// +// Prototypes for the Bus Specific Driver Override Protocol +// +typedef +EFI_STATUS +(EFIAPI *EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER) ( + IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL * This, + IN OUT EFI_HANDLE * DriverImageHandle + ); + +// +// Interface structure for the Bus Specific Driver Override Protocol +// +typedef struct _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL { + EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER GetDriver; +} EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL; + +extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.c new file mode 100644 index 0000000000..0d0d31271f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ComponentName.c + +Abstract: + + EFI Component Name Protocol + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (ComponentName) + +EFI_GUID gEfiComponentNameProtocolGuid = EFI_COMPONENT_NAME_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiComponentNameProtocolGuid, "Component Name Protocol", "EFI 1.1 Component Name Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.h new file mode 100644 index 0000000000..984252394b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName/ComponentName.h @@ -0,0 +1,137 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ComponentName.h + +Abstract: + + EFI Component Name Protocol + +Revision History + +--*/ + +#ifndef _EFI_COMPONENT_NAME_H_ +#define _EFI_COMPONENT_NAME_H_ + +// +// Global ID for the Component Name Protocol +// +#define EFI_COMPONENT_NAME_PROTOCOL_GUID \ + { \ + 0x107a772c, 0xd5e1, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_COMPONENT_NAME_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME_GET_DRIVER_NAME) ( + IN EFI_COMPONENT_NAME_PROTOCOL * This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ); + +/*++ + + Routine Description: + Retrieves a Unicode string that is the user readable name of the EFI Driver. + + Arguments: + This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. + Language - A pointer to a three character ISO 639-2 language identifier. + This is the language of the driver name that that the caller + is requesting, and it must match one of the languages specified + in SupportedLanguages. The number of languages supported by a + driver is up to the driver writer. + DriverName - A pointer to the Unicode string to return. This Unicode string + is the name of the driver specified by This in the language + specified by Language. + + Returns: + EFI_SUCCESS - The Unicode string for the Driver specified by This + and the language specified by Language was returned + in DriverName. + EFI_INVALID_PARAMETER - Language is NULL. + EFI_INVALID_PARAMETER - DriverName is NULL. + EFI_UNSUPPORTED - The driver specified by This does not support the + language specified by Language. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) ( + IN EFI_COMPONENT_NAME_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ); + +/*++ + + Routine Description: + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by an EFI Driver. + + Arguments: + This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. + ControllerHandle - The handle of a controller that the driver specified by + This is managing. This handle specifies the controller + whose name is to be returned. + ChildHandle - The handle of the child controller to retrieve the name + of. This is an optional parameter that may be NULL. It + will be NULL for device drivers. It will also be NULL + for a bus drivers that wish to retrieve the name of the + bus controller. It will not be NULL for a bus driver + that wishes to retrieve the name of a child controller. + Language - A pointer to a three character ISO 639-2 language + identifier. This is the language of the controller name + that that the caller is requesting, and it must match one + of the languages specified in SupportedLanguages. The + number of languages supported by a driver is up to the + driver writer. + ControllerName - A pointer to the Unicode string to return. This Unicode + string is the name of the controller specified by + ControllerHandle and ChildHandle in the language specified + by Language from the point of view of the driver specified + by This. + + Returns: + EFI_SUCCESS - The Unicode string for the user readable name in the + language specified by Language for the driver + specified by This was returned in DriverName. + EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - Language is NULL. + EFI_INVALID_PARAMETER - ControllerName is NULL. + EFI_UNSUPPORTED - The driver specified by This is not currently managing + the controller specified by ControllerHandle and + ChildHandle. + EFI_UNSUPPORTED - The driver specified by This does not support the + language specified by Language. + +--*/ + +// +// Interface structure for the Component Name Protocol +// +typedef struct _EFI_COMPONENT_NAME_PROTOCOL { + EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName; + EFI_COMPONENT_NAME_GET_CONTROLLER_NAME GetControllerName; + CHAR8 *SupportedLanguages; +} EFI_COMPONENT_NAME_PROTOCOL; + +extern EFI_GUID gEfiComponentNameProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c new file mode 100644 index 0000000000..fee053effb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ComponentName.c + +Abstract: + + EFI Component Name Protocol + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (ComponentName2) + +EFI_GUID gEfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiComponentName2ProtocolGuid, "Component Name2 Protocol", "EFI 2.0 Component Name2 Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h new file mode 100644 index 0000000000..4f6bb35b02 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h @@ -0,0 +1,136 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ComponentName.h + +Abstract: + + EFI Component Name Protocol + +Revision History + +--*/ + +#ifndef _EFI_COMPONENT_NAME2_H_ +#define _EFI_COMPONENT_NAME2_H_ + +// +// Global ID for the Component Name Protocol +// + +#define EFI_COMPONENT_NAME2_PROTOCOL_GUID \ + { \ + 0x6a7a5cff, 0xe8d9, 0x4f70, 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14 \ + } + +EFI_FORWARD_DECLARATION (EFI_COMPONENT_NAME2_PROTOCOL); + + +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ( + IN EFI_COMPONENT_NAME2_PROTOCOL * This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ); + +/*++ + + Routine Description: + Retrieves a Unicode string that is the user readable name of the EFI Driver. + + Arguments: + This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. + Language - A pointer to a three character ISO 639-2 language identifier. + This is the language of the driver name that that the caller + is requesting, and it must match one of the languages specified + in SupportedLanguages. The number of languages supported by a + driver is up to the driver writer. + DriverName - A pointer to the Unicode string to return. This Unicode string + is the name of the driver specified by This in the language + specified by Language. + + Returns: + EFI_SUCCESS - The Unicode string for the Driver specified by This + and the language specified by Language was returned + in DriverName. + EFI_INVALID_PARAMETER - Language is NULL or DriverName is NULL. + EFI_UNSUPPORTED - The driver specified by This does not support the + language specified by Language. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ( + IN EFI_COMPONENT_NAME2_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ); + +/*++ + + Routine Description: + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by an EFI Driver. + + Arguments: + This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. + ControllerHandle - The handle of a controller that the driver specified by + This is managing. This handle specifies the controller + whose name is to be returned. + ChildHandle - The handle of the child controller to retrieve the name + of. This is an optional parameter that may be NULL. It + will be NULL for device drivers. It will also be NULL + for a bus drivers that wish to retrieve the name of the + bus controller. It will not be NULL for a bus driver + that wishes to retrieve the name of a child controller. + Language - A pointer to a three character ISO 639-2 language + identifier. This is the language of the controller name + that that the caller is requesting, and it must match one + of the languages specified in SupportedLanguages. The + number of languages supported by a driver is up to the + driver writer. + ControllerName - A pointer to the Unicode string to return. This Unicode + string is the name of the controller specified by + ControllerHandle and ChildHandle in the language specified + by Language from the point of view of the driver specified + by This. + + Returns: + EFI_SUCCESS - The Unicode string for the user readable name in the + language specified by Language for the driver + specified by This was returned in DriverName. + EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE; ChildHandle + is not NULL and it is not a valid EFI_HANDLE;Language + is NULL;ControllerName is NULL. + EFI_UNSUPPORTED - The driver specified by This is not currently managing + the controller specified by ControllerHandle and + ChildHandle;The driver specified by This does not support the + language specified by Language. + +--*/ + +// +// Interface structure for the Component Name Protocol +// +typedef struct _EFI_COMPONENT_NAME2_PROTOCOL { + EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName; + EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME GetControllerName; + CHAR8 *SupportedLanguages; +} EFI_COMPONENT_NAME2_PROTOCOL; + +extern EFI_GUID gEfiComponentName2ProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.c new file mode 100644 index 0000000000..f6db9ea49f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugPort.c + +Abstract: + + DebugPort protocol as defined in the EFI 1.1 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DebugPort) + +EFI_GUID gEfiDebugPortProtocolGuid = EFI_DEBUGPORT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDebugPortProtocolGuid, "DebugPort Protocol", "EFI 1.1 DebugPort Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.h new file mode 100644 index 0000000000..af80b751fc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugPort/DebugPort.h @@ -0,0 +1,98 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugPort.h + +Abstract: + +--*/ + +#ifndef _DEBUG_PORT_H_ +#define _DEBUG_PORT_H_ + +#include "EfiApi.h" + +// +// DebugPortIo protocol {EBA4E8D2-3858-41EC-A281-2647BA9660D0} +// +#define EFI_DEBUGPORT_PROTOCOL_GUID \ + { \ + 0xEBA4E8D2, 0x3858, 0x41EC, 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 \ + } + +extern EFI_GUID gEfiDebugPortProtocolGuid; + +EFI_FORWARD_DECLARATION (EFI_DEBUGPORT_PROTOCOL); + +// +// DebugPort member functions +// +typedef +EFI_STATUS +(EFIAPI *EFI_DEBUGPORT_RESET) ( + IN EFI_DEBUGPORT_PROTOCOL * This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DEBUGPORT_WRITE) ( + IN EFI_DEBUGPORT_PROTOCOL * This, + IN UINT32 Timeout, + IN OUT UINTN *BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DEBUGPORT_READ) ( + IN EFI_DEBUGPORT_PROTOCOL * This, + IN UINT32 Timeout, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DEBUGPORT_POLL) ( + IN EFI_DEBUGPORT_PROTOCOL * This + ); + +// +// DebugPort protocol definition +// +typedef struct _EFI_DEBUGPORT_PROTOCOL { + EFI_DEBUGPORT_RESET Reset; + EFI_DEBUGPORT_WRITE Write; + EFI_DEBUGPORT_READ Read; + EFI_DEBUGPORT_POLL Poll; +} EFI_DEBUGPORT_PROTOCOL; + +// +// DEBUGPORT variable definitions... +// +#define EFI_DEBUGPORT_VARIABLE_NAME L"DEBUGPORT" +#define EFI_DEBUGPORT_VARIABLE_GUID EFI_DEBUGPORT_PROTOCOL_GUID +#define gEfiDebugPortVariableGuid gEfiDebugPortProtocolGuid + +// +// DebugPort device path definitions... +// +#define DEVICE_PATH_MESSAGING_DEBUGPORT EFI_DEBUGPORT_PROTOCOL_GUID +#define gEfiDebugPortDevicePathGuid gEfiDebugPortProtocolGuid + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID Guid; +} DEBUGPORT_DEVICE_PATH; + +#endif /* _DEBUG_PORT_H_ */ diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c new file mode 100644 index 0000000000..b770ffbf8a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugSupport.c + +Abstract: + + DebugSupport protocol as defined in the EFI 1.1 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DebugSupport) + +EFI_GUID gEfiDebugSupportProtocolGuid = EFI_DEBUG_SUPPORT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDebugSupportProtocolGuid, "DebugSupport Protocol", "EFI 1.1 DebugSupport Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h new file mode 100644 index 0000000000..d5ed15f232 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h @@ -0,0 +1,594 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugSupport.h + +Abstract: + + DebugSupport protocol and supporting definitions as defined in the EFI 1.1 + specification. + + The DebugSupport protocol is used by source level debuggers to abstract the + processor and handle context save and restore operations. + +--*/ + +#ifndef _DEBUG_SUPPORT_H_ +#define _DEBUG_SUPPORT_H_ + +#include "EfiApi.h" +#include "EfiImage.h" +// +// Debug Support protocol {2755590C-6F3C-42FA-9EA4-A3BA543CDA25} +// +#define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \ + { \ + 0x2755590C, 0x6F3C, 0x42FA, 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 \ + } + +// +// Debug Support definitions +// +typedef INTN EFI_EXCEPTION_TYPE; + +// +// IA-32 processor exception types +// +#define EXCEPT_IA32_DIVIDE_ERROR 0 +#define EXCEPT_IA32_DEBUG 1 +#define EXCEPT_IA32_NMI 2 +#define EXCEPT_IA32_BREAKPOINT 3 +#define EXCEPT_IA32_OVERFLOW 4 +#define EXCEPT_IA32_BOUND 5 +#define EXCEPT_IA32_INVALID_OPCODE 6 +#define EXCEPT_IA32_DOUBLE_FAULT 8 +#define EXCEPT_IA32_INVALID_TSS 10 +#define EXCEPT_IA32_SEG_NOT_PRESENT 11 +#define EXCEPT_IA32_STACK_FAULT 12 +#define EXCEPT_IA32_GP_FAULT 13 +#define EXCEPT_IA32_PAGE_FAULT 14 +#define EXCEPT_IA32_FP_ERROR 16 +#define EXCEPT_IA32_ALIGNMENT_CHECK 17 +#define EXCEPT_IA32_MACHINE_CHECK 18 +#define EXCEPT_IA32_SIMD 19 + +// +// IA-32 processor context definition +// +// +// FXSAVE_STATE +// FP / MMX / XMM registers (see fxrstor instruction definition) +// +typedef struct { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT32 Eip; + UINT16 Cs; + UINT16 Reserved1; + UINT32 DataOffset; + UINT16 Ds; + UINT8 Reserved2[10]; +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + UINT8 St0Mm0[10], Reserved3[6]; + UINT8 St1Mm1[10], Reserved4[6]; + UINT8 St2Mm2[10], Reserved5[6]; + UINT8 St3Mm3[10], Reserved6[6]; + UINT8 St4Mm4[10], Reserved7[6]; + UINT8 St5Mm5[10], Reserved8[6]; + UINT8 St6Mm6[10], Reserved9[6]; + UINT8 St7Mm7[10], Reserved10[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; + UINT8 Reserved11[14 * 16]; +} EFI_FX_SAVE_STATE_IA32; +#else + UINT8 St0Mm0[10], Reserved3[6]; + UINT8 St0Mm1[10], Reserved4[6]; + UINT8 St0Mm2[10], Reserved5[6]; + UINT8 St0Mm3[10], Reserved6[6]; + UINT8 St0Mm4[10], Reserved7[6]; + UINT8 St0Mm5[10], Reserved8[6]; + UINT8 St0Mm6[10], Reserved9[6]; + UINT8 St0Mm7[10], Reserved10[6]; + UINT8 Reserved11[22 * 16]; +} EFI_FX_SAVE_STATE; +#endif + +typedef struct { + UINT32 ExceptionData; +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + EFI_FX_SAVE_STATE_IA32 FxSaveState; +#else + EFI_FX_SAVE_STATE FxSaveState; +#endif + UINT32 Dr0; + UINT32 Dr1; + UINT32 Dr2; + UINT32 Dr3; + UINT32 Dr6; + UINT32 Dr7; + UINT32 Cr0; + UINT32 Cr1; /* Reserved */ + UINT32 Cr2; + UINT32 Cr3; + UINT32 Cr4; + UINT32 Eflags; + UINT32 Ldtr; + UINT32 Tr; + UINT32 Gdtr[2]; + UINT32 Idtr[2]; + UINT32 Eip; + UINT32 Gs; + UINT32 Fs; + UINT32 Es; + UINT32 Ds; + UINT32 Cs; + UINT32 Ss; + UINT32 Edi; + UINT32 Esi; + UINT32 Ebp; + UINT32 Esp; + UINT32 Ebx; + UINT32 Edx; + UINT32 Ecx; + UINT32 Eax; +} EFI_SYSTEM_CONTEXT_IA32; + +// +// X64 processor exception types +// +#define EXCEPT_X64_DIVIDE_ERROR 0 +#define EXCEPT_X64_DEBUG 1 +#define EXCEPT_X64_NMI 2 +#define EXCEPT_X64_BREAKPOINT 3 +#define EXCEPT_X64_OVERFLOW 4 +#define EXCEPT_X64_BOUND 5 +#define EXCEPT_X64_INVALID_OPCODE 6 +#define EXCEPT_X64_DOUBLE_FAULT 8 +#define EXCEPT_X64_INVALID_TSS 10 +#define EXCEPT_X64_SEG_NOT_PRESENT 11 +#define EXCEPT_X64_STACK_FAULT 12 +#define EXCEPT_X64_GP_FAULT 13 +#define EXCEPT_X64_PAGE_FAULT 14 +#define EXCEPT_X64_FP_ERROR 16 +#define EXCEPT_X64_ALIGNMENT_CHECK 17 +#define EXCEPT_X64_MACHINE_CHECK 18 +#define EXCEPT_X64_SIMD 19 + +// +// X64 processor context definition +// +// FXSAVE_STATE +// FP / MMX / XMM registers (see fxrstor instruction definition) +// +typedef struct { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT64 Rip; + UINT64 DataOffset; + UINT8 Reserved1[8]; + UINT8 St0Mm0[10], Reserved2[6]; + UINT8 St1Mm1[10], Reserved3[6]; + UINT8 St2Mm2[10], Reserved4[6]; + UINT8 St3Mm3[10], Reserved5[6]; + UINT8 St4Mm4[10], Reserved6[6]; + UINT8 St5Mm5[10], Reserved7[6]; + UINT8 St6Mm6[10], Reserved8[6]; + UINT8 St7Mm7[10], Reserved9[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + // + // NOTE: UEFI 2.0 spec definition as follows. It should be updated + // after spec update. + // + UINT8 Reserved11[14 * 16]; +#else + UINT8 Xmm8[16]; + UINT8 Xmm9[16]; + UINT8 Xmm10[16]; + UINT8 Xmm11[16]; + UINT8 Xmm12[16]; + UINT8 Xmm13[16]; + UINT8 Xmm14[16]; + UINT8 Xmm15[16]; + UINT8 Reserved10[6 * 16]; +#endif +} EFI_FX_SAVE_STATE_X64; + +typedef struct { + UINT64 ExceptionData; + EFI_FX_SAVE_STATE_X64 FxSaveState; + UINT64 Dr0; + UINT64 Dr1; + UINT64 Dr2; + UINT64 Dr3; + UINT64 Dr6; + UINT64 Dr7; + UINT64 Cr0; + UINT64 Cr1; /* Reserved */ + UINT64 Cr2; + UINT64 Cr3; + UINT64 Cr4; + UINT64 Cr8; + UINT64 Rflags; + UINT64 Ldtr; + UINT64 Tr; + UINT64 Gdtr[2]; + UINT64 Idtr[2]; + UINT64 Rip; + UINT64 Gs; + UINT64 Fs; + UINT64 Es; + UINT64 Ds; + UINT64 Cs; + UINT64 Ss; + UINT64 Rdi; + UINT64 Rsi; + UINT64 Rbp; + UINT64 Rsp; + UINT64 Rbx; + UINT64 Rdx; + UINT64 Rcx; + UINT64 Rax; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; +} EFI_SYSTEM_CONTEXT_X64; + +// +// IPF processor exception types +// +#define EXCEPT_IPF_VHTP_TRANSLATION 0 +#define EXCEPT_IPF_INSTRUCTION_TLB 1 +#define EXCEPT_IPF_DATA_TLB 2 +#define EXCEPT_IPF_ALT_INSTRUCTION_TLB 3 +#define EXCEPT_IPF_ALT_DATA_TLB 4 +#define EXCEPT_IPF_DATA_NESTED_TLB 5 +#define EXCEPT_IPF_INSTRUCTION_KEY_MISSED 6 +#define EXCEPT_IPF_DATA_KEY_MISSED 7 +#define EXCEPT_IPF_DIRTY_BIT 8 +#define EXCEPT_IPF_INSTRUCTION_ACCESS_BIT 9 +#define EXCEPT_IPF_DATA_ACCESS_BIT 10 +#define EXCEPT_IPF_BREAKPOINT 11 +#define EXCEPT_IPF_EXTERNAL_INTERRUPT 12 +// +// 13 - 19 reserved +// +#define EXCEPT_IPF_PAGE_NOT_PRESENT 20 +#define EXCEPT_IPF_KEY_PERMISSION 21 +#define EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS 22 +#define EXCEPT_IPF_DATA_ACCESS_RIGHTS 23 +#define EXCEPT_IPF_GENERAL_EXCEPTION 24 +#define EXCEPT_IPF_DISABLED_FP_REGISTER 25 +#define EXCEPT_IPF_NAT_CONSUMPTION 26 +#define EXCEPT_IPF_SPECULATION 27 +// +// 28 reserved +// +#define EXCEPT_IPF_DEBUG 29 +#define EXCEPT_IPF_UNALIGNED_REFERENCE 30 +#define EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE 31 +#define EXCEPT_IPF_FP_FAULT 32 +#define EXCEPT_IPF_FP_TRAP 33 +#define EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP 34 +#define EXCEPT_IPF_TAKEN_BRANCH 35 +#define EXCEPT_IPF_SINGLE_STEP 36 +// +// 37 - 44 reserved +// +#define EXCEPT_IPF_IA32_EXCEPTION 45 +#define EXCEPT_IPF_IA32_INTERCEPT 46 +#define EXCEPT_IPF_IA32_INTERRUPT 47 + +// +// IPF processor context definition +// +typedef struct { + // + // The first reserved field is necessary to preserve alignment for the correct + // bits in UNAT and to insure F2 is 16 byte aligned.. + // + UINT64 Reserved; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 R16; + UINT64 R17; + UINT64 R18; + UINT64 R19; + UINT64 R20; + UINT64 R21; + UINT64 R22; + UINT64 R23; + UINT64 R24; + UINT64 R25; + UINT64 R26; + UINT64 R27; + UINT64 R28; + UINT64 R29; + UINT64 R30; + UINT64 R31; + + UINT64 F2[2]; + UINT64 F3[2]; + UINT64 F4[2]; + UINT64 F5[2]; + UINT64 F6[2]; + UINT64 F7[2]; + UINT64 F8[2]; + UINT64 F9[2]; + UINT64 F10[2]; + UINT64 F11[2]; + UINT64 F12[2]; + UINT64 F13[2]; + UINT64 F14[2]; + UINT64 F15[2]; + UINT64 F16[2]; + UINT64 F17[2]; + UINT64 F18[2]; + UINT64 F19[2]; + UINT64 F20[2]; + UINT64 F21[2]; + UINT64 F22[2]; + UINT64 F23[2]; + UINT64 F24[2]; + UINT64 F25[2]; + UINT64 F26[2]; + UINT64 F27[2]; + UINT64 F28[2]; + UINT64 F29[2]; + UINT64 F30[2]; + UINT64 F31[2]; + + UINT64 Pr; + + UINT64 B0; + UINT64 B1; + UINT64 B2; + UINT64 B3; + UINT64 B4; + UINT64 B5; + UINT64 B6; + UINT64 B7; + + // + // application registers + // + UINT64 ArRsc; + UINT64 ArBsp; + UINT64 ArBspstore; + UINT64 ArRnat; + + UINT64 ArFcr; + + UINT64 ArEflag; + UINT64 ArCsd; + UINT64 ArSsd; + UINT64 ArCflg; + UINT64 ArFsr; + UINT64 ArFir; + UINT64 ArFdr; + + UINT64 ArCcv; + + UINT64 ArUnat; + + UINT64 ArFpsr; + + UINT64 ArPfs; + UINT64 ArLc; + UINT64 ArEc; + + // + // control registers + // + UINT64 CrDcr; + UINT64 CrItm; + UINT64 CrIva; + UINT64 CrPta; + UINT64 CrIpsr; + UINT64 CrIsr; + UINT64 CrIip; + UINT64 CrIfa; + UINT64 CrItir; + UINT64 CrIipa; + UINT64 CrIfs; + UINT64 CrIim; + UINT64 CrIha; + + // + // debug registers + // + UINT64 Dbr0; + UINT64 Dbr1; + UINT64 Dbr2; + UINT64 Dbr3; + UINT64 Dbr4; + UINT64 Dbr5; + UINT64 Dbr6; + UINT64 Dbr7; + + UINT64 Ibr0; + UINT64 Ibr1; + UINT64 Ibr2; + UINT64 Ibr3; + UINT64 Ibr4; + UINT64 Ibr5; + UINT64 Ibr6; + UINT64 Ibr7; + + // + // virtual registers - nat bits for R1-R31 + // + UINT64 IntNat; + +} EFI_SYSTEM_CONTEXT_IPF; + +// +// EBC processor exception types +// +#define EXCEPT_EBC_UNDEFINED 0 +#define EXCEPT_EBC_DIVIDE_ERROR 1 +#define EXCEPT_EBC_DEBUG 2 +#define EXCEPT_EBC_BREAKPOINT 3 +#define EXCEPT_EBC_OVERFLOW 4 +#define EXCEPT_EBC_INVALID_OPCODE 5 // opcode out of range +#define EXCEPT_EBC_STACK_FAULT 6 +#define EXCEPT_EBC_ALIGNMENT_CHECK 7 +#define EXCEPT_EBC_INSTRUCTION_ENCODING 8 // malformed instruction +#define EXCEPT_EBC_BAD_BREAK 9 // BREAK 0 or undefined BREAK +#define EXCEPT_EBC_STEP 10 // to support debug stepping +// +// For coding convenience, define the maximum valid EBC exception. +// +#define MAX_EBC_EXCEPTION EXCEPT_EBC_STEP + +// +// EBC processor context definition +// +typedef struct { + UINT64 R0; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 Flags; + UINT64 ControlFlags; + UINT64 Ip; +} EFI_SYSTEM_CONTEXT_EBC; + +// +// Universal EFI_SYSTEM_CONTEXT definition +// +typedef union { + EFI_SYSTEM_CONTEXT_EBC *SystemContextEbc; + EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32; + EFI_SYSTEM_CONTEXT_X64 *SystemContextX64; + EFI_SYSTEM_CONTEXT_IPF *SystemContextIpf; +} EFI_SYSTEM_CONTEXT; + +// +// DebugSupport callback function prototypes +// +typedef +VOID +(*EFI_EXCEPTION_CALLBACK) ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ); + +typedef +VOID +(*EFI_PERIODIC_CALLBACK) ( + IN OUT EFI_SYSTEM_CONTEXT SystemContext + ); + +// +// Machine type definition +// +typedef enum { + IsaIa32 = EFI_IMAGE_MACHINE_IA32, + IsaX64 = EFI_IMAGE_MACHINE_X64, + IsaIpf = EFI_IMAGE_MACHINE_IA64, + IsaEbc = EFI_IMAGE_MACHINE_EBC +} EFI_INSTRUCTION_SET_ARCHITECTURE; + +EFI_FORWARD_DECLARATION (EFI_DEBUG_SUPPORT_PROTOCOL); + +// +// DebugSupport member function definitions +// +typedef +EFI_STATUS +(EFIAPI *EFI_GET_MAXIMUM_PROCESSOR_INDEX) ( + IN EFI_DEBUG_SUPPORT_PROTOCOL * This, + OUT UINTN *MaxProcessorIndex + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_PERIODIC_CALLBACK) ( + IN EFI_DEBUG_SUPPORT_PROTOCOL * This, + IN UINTN ProcessorIndex, + IN EFI_PERIODIC_CALLBACK PeriodicCallback + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_EXCEPTION_CALLBACK) ( + IN EFI_DEBUG_SUPPORT_PROTOCOL * This, + IN UINTN ProcessorIndex, + IN EFI_EXCEPTION_CALLBACK ExceptionCallback, + IN EFI_EXCEPTION_TYPE ExceptionType + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_INVALIDATE_INSTRUCTION_CACHE) ( + IN EFI_DEBUG_SUPPORT_PROTOCOL * This, + IN UINTN ProcessorIndex, + IN VOID *Start, + IN UINT64 Length + ); + +// +// DebugSupport protocol definition +// +typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL { + EFI_INSTRUCTION_SET_ARCHITECTURE Isa; + EFI_GET_MAXIMUM_PROCESSOR_INDEX GetMaximumProcessorIndex; + EFI_REGISTER_PERIODIC_CALLBACK RegisterPeriodicCallback; + EFI_REGISTER_EXCEPTION_CALLBACK RegisterExceptionCallback; + EFI_INVALIDATE_INSTRUCTION_CACHE InvalidateInstructionCache; +} EFI_DEBUG_SUPPORT_PROTOCOL; + +extern EFI_GUID gEfiDebugSupportProtocolGuid; + +#endif /* _DEBUG_SUPPORT_H_ */ diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.c new file mode 100644 index 0000000000..366322ea78 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Decompress.c + +Abstract: + + The GUID for the EFI Decompress Protocol + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Decompress) + +EFI_GUID gEfiDecompressProtocolGuid = EFI_DECOMPRESS_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDecompressProtocolGuid, "Decompress", "Decompression Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.h new file mode 100644 index 0000000000..93839a7898 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Decompress/Decompress.h @@ -0,0 +1,140 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Decompress.h + +Abstract: + + The Decompress Protocol Interface + +--*/ + +#ifndef _DECOMPRESS_H_ +#define _DECOMPRESS_H_ + +#define EFI_DECOMPRESS_PROTOCOL_GUID \ + { \ + 0xd8117cfe, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_DECOMPRESS_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DECOMPRESS_GET_INFO) ( + IN EFI_DECOMPRESS_PROTOCOL * This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); + +/*++ + +Routine Description: + + The GetInfo() function retrieves the size of the uncompressed buffer + and the temporary scratch buffer required to decompress the buffer + specified by Source and SourceSize. If the size of the uncompressed + buffer or the size of the scratch buffer cannot be determined from + the compressed data specified by Source and SourceData, then + EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed + buffer is returned in DestinationSize, the size of the scratch buffer is + returned in ScratchSize, and EFI_SUCCESS is returned. + + The GetInfo() function does not have scratch buffer available to perform + a thorough checking of the validity of the source data. It just retrieves + the 'Original Size' field from the beginning bytes of the source data and + output it as DestinationSize. And ScratchSize is specific to the decompression + implementation. + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SourceSize - The size, in bytes, of source buffer. + DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer + that will be generated when the compressed buffer specified + by Source and SourceSize is decompressed. + ScratchSize - A pointer to the size, in bytes, of the scratch buffer that + is required to decompress the compressed buffer specified by + Source and SourceSize. + +Returns: + EFI_SUCCESS - The size of the uncompressed data was returned in DestinationSize + and the size of the scratch buffer was returned in ScratchSize. + EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch + buffer cannot be determined from the compressed data specified by + Source and SourceData. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_DECOMPRESS_DECOMPRESS) ( + IN EFI_DECOMPRESS_PROTOCOL * This, + IN VOID *Source, + IN UINT32 SourceSize, + IN OUT VOID *Destination, + IN UINT32 DestinationSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ); + +/*++ + +Routine Description: + + The Decompress() function extracts decompressed data to its original form. + + This protocol is designed so that the decompression algorithm can be + implemented without using any memory services. As a result, the + Decompress() function is not allowed to call AllocatePool() or + AllocatePages() in its implementation. It is the caller's responsibility + to allocate and free the Destination and Scratch buffers. + + If the compressed source data specified by Source and SourceSize is + sucessfully decompressed into Destination, then EFI_SUCCESS is returned. + If the compressed source data specified by Source and SourceSize is not in + a valid compressed data format, then EFI_INVALID_PARAMETER is returned. + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SourceSize - The size of source data. + Destination - On output, the destination buffer that contains + the uncompressed data. + DestinationSize - The size of destination buffer. The size of destination + buffer needed is obtained from GetInfo(). + Scratch - A temporary scratch buffer that is used to perform the + decompression. + ScratchSize - The size of scratch buffer. The size of scratch buffer needed + is obtained from GetInfo(). + +Returns: + + EFI_SUCCESS - Decompression completed successfully, and the uncompressed + buffer is returned in Destination. + EFI_INVALID_PARAMETER + - The source buffer specified by Source and SourceSize is + corrupted (not in a valid compressed format). + +--*/ +typedef struct _EFI_DECOMPRESS_PROTOCOL { + EFI_DECOMPRESS_GET_INFO GetInfo; + EFI_DECOMPRESS_DECOMPRESS Decompress; +} EFI_DECOMPRESS_PROTOCOL; + +extern EFI_GUID gEfiDecompressProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c new file mode 100644 index 0000000000..34d90b75f4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DeviceIo.c + +Abstract: + + Device IO protocol as defined in the EFI 1.0 specification. + + Device IO is used to abstract hardware access to devices. It includes + memory mapped IO, IO, PCI Config space, and DMA. + + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DeviceIo) + +EFI_GUID gEfiDeviceIoProtocolGuid = EFI_DEVICE_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDeviceIoProtocolGuid, "DeviceIo Protocol", "EFI 1.0 Device IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h new file mode 100644 index 0000000000..d0f4678a50 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h @@ -0,0 +1,132 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DeviceIo.h + +Abstract: + + Device IO protocol as defined in the EFI 1.0 specification. + + Device IO is used to abstract hardware access to devices. It includes + memory mapped IO, IO, PCI Config space, and DMA. + + +--*/ + +#ifndef _DEVICE_IO_H_ +#define _DEVICE_IO_H_ + +#define EFI_DEVICE_IO_PROTOCOL_GUID \ + { \ + 0xaf6ac311, 0x84c3, 0x11d2, 0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +EFI_FORWARD_DECLARATION (EFI_DEVICE_IO_PROTOCOL); + +typedef enum { + IO_UINT8, + IO_UINT16, + IO_UINT32, + IO_UINT64, + MMIO_COPY_UINT8, + MMIO_COPY_UINT16, + MMIO_COPY_UINT32, + MMIO_COPY_UINT64 +} EFI_IO_WIDTH; + +typedef +EFI_STATUS +(EFIAPI *EFI_DEVICE_IO) ( + IN EFI_DEVICE_IO_PROTOCOL * This, + IN EFI_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + EFI_DEVICE_IO Read; + EFI_DEVICE_IO Write; +} EFI_IO_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_DEVICE_PATH) ( + IN EFI_DEVICE_IO_PROTOCOL * This, + IN UINT64 Address, + IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath + ); + +typedef enum { + EfiBusMasterRead, + EfiBusMasterWrite, + EfiBusMasterCommonBuffer +} EFI_IO_OPERATION_TYPE; + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_MAP) ( + IN EFI_DEVICE_IO_PROTOCOL * This, + IN EFI_IO_OPERATION_TYPE Operation, + IN EFI_PHYSICAL_ADDRESS * HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS * DeviceAddress, + OUT VOID **Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_UNMAP) ( + IN EFI_DEVICE_IO_PROTOCOL * This, + IN VOID *Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_ALLOCATE_BUFFER) ( + IN EFI_DEVICE_IO_PROTOCOL * This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS * HostAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_FLUSH) ( + IN EFI_DEVICE_IO_PROTOCOL * This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IO_FREE_BUFFER) ( + IN EFI_DEVICE_IO_PROTOCOL * This, + IN UINTN Pages, + IN EFI_PHYSICAL_ADDRESS HostAddress + ); + +typedef struct _EFI_DEVICE_IO_PROTOCOL { + EFI_IO_ACCESS Mem; + EFI_IO_ACCESS Io; + EFI_IO_ACCESS Pci; + EFI_IO_MAP Map; + EFI_PCI_DEVICE_PATH PciDevicePath; + EFI_IO_UNMAP Unmap; + EFI_IO_ALLOCATE_BUFFER AllocateBuffer; + EFI_IO_FLUSH Flush; + EFI_IO_FREE_BUFFER FreeBuffer; +} EFI_DEVICE_IO_PROTOCOL; + +extern EFI_GUID gEfiDeviceIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.c new file mode 100644 index 0000000000..7cca9853c0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.c @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePath.c + +Abstract: + + The device path protocol as defined in EFI 1.0. + + The device path represents a programatic path to a device. It's the view + from a software point of view. It also must persist from boot to boot, so + it can not contain things like PCI bus numbers that change from boot to boot. + + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DevicePath) + +EFI_GUID gEfiDevicePathProtocolGuid = EFI_DEVICE_PATH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDevicePathProtocolGuid, "Device Path Protocol", "EFI 1.0 Device Path protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.h new file mode 100644 index 0000000000..4991e2b012 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePath/DevicePath.h @@ -0,0 +1,67 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePath.h + +Abstract: + + The device path protocol as defined in EFI 1.0. + + The device path represents a programatic path to a device. It's the view + from a software point of view. It also must persist from boot to boot, so + it can not contain things like PCI bus numbers that change from boot to boot. + + +--*/ + +#ifndef _DEVICE_PATH_H_ +#define _DEVICE_PATH_H_ + +// +// Device Path protocol +// +#define EFI_DEVICE_PATH_PROTOCOL_GUID \ + { \ + 0x9576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +#pragma pack(push, 1) + +typedef struct { + UINT8 Type; + UINT8 SubType; + UINT8 Length[2]; +} EFI_DEVICE_PATH_PROTOCOL; + +#pragma pack(pop) + +#define EFI_END_ENTIRE_DEVICE_PATH 0xff +#define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff +#define EFI_END_INSTANCE_DEVICE_PATH 0x01 +#define EFI_END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL)) + +#define EfiDevicePathNodeLength(a) (((a)->Length[0]) | ((a)->Length[1] << 8)) +#define EfiNextDevicePathNode(a) ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a))) + +#define EfiDevicePathType(a) (((a)->Type) & 0x7f) +#define EfiIsDevicePathEndType(a) (EfiDevicePathType (a) == 0x7f) + +#define EfiIsDevicePathEndSubType(a) ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE) +#define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH) + +#define EfiIsDevicePathEnd(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a)) +#define EfiIsDevicePathEndInstance(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a)) + +extern EFI_GUID gEfiDevicePathProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c new file mode 100644 index 0000000000..ee4289b1d1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePathFromText.c + +Abstract: + + DevicePathFromText protocol as defined in the UEFI 2.0 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DevicePathFromText) + +EFI_GUID gEfiDevicePathFromTextProtocolGuid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDevicePathFromTextProtocolGuid, "Device Path From Text Protocol", "UEFI 2.0 Device Path From Text Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h new file mode 100644 index 0000000000..8218cfce87 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h @@ -0,0 +1,82 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePathFromText.h + +Abstract: + +--*/ + +#ifndef _DEVICE_PATH_FROM_TEXT_PROTOCOL_H_ +#define _DEVICE_PATH_FROM_TEXT_PROTOCOL_H_ + +// +// Device Path From Text protocol +// +#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \ + { \ + 0x5c99a21, 0xc70f, 0x4ad2, 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e \ + } + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) ( + IN CONST CHAR16 *TextDeviceNode + ) +/*++ + + Routine Description: + Convert text to the binary representation of a device node. + + Arguments: + TextDeviceNode - TextDeviceNode points to the text representation of a device + node. Conversion starts with the first character and continues + until the first non-device node character. + + Returns: + A pointer - Pointer to the EFI device node. + NULL - if TextDeviceNode is NULL or there was insufficient memory. + +--*/ +; + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) ( + IN CONST CHAR16 *TextDevicePath + ) +/*++ + + Routine Description: + Convert text to the binary representation of a device path. + + Arguments: + TextDevicePath - TextDevicePath points to the text representation of a device + path. Conversion starts with the first character and continues + until the first non-device node character. + + Returns: + A pointer - Pointer to the allocated device path. + NULL - if TextDeviceNode is NULL or there was insufficient memory. + +--*/ +; + +typedef struct { + EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode; + EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath; +} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL; + +extern EFI_GUID gEfiDevicePathFromTextProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c new file mode 100644 index 0000000000..046a391ad8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePathToText.c + +Abstract: + + DevicePathToText protocol as defined in the UEFI 2.0 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DevicePathToText) + +EFI_GUID gEfiDevicePathToTextProtocolGuid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDevicePathToTextProtocolGuid, "Device Path To Text Protocol", "UEFI 2.0 Device Path To Text protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h new file mode 100644 index 0000000000..4d03aad257 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h @@ -0,0 +1,95 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePathToText.h + +Abstract: + +--*/ + + +#ifndef _DEVICE_PATH_TO_TEXT_PROTOCOL_H_ +#define _DEVICE_PATH_TO_TEXT_PROTOCOL_H_ + +// +// Device Path To Text protocol +// +#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ + { \ + 0x8b843e20, 0x8132, 0x4852, 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c \ + } + +typedef +CHAR16* +(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +/*++ + + Routine Description: + Convert a device node to its text representation. + + Arguments: + DeviceNode - Points to the device node to be converted. + DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + + Returns: + A pointer - a pointer to the allocated text representation of the device node. + NULL - if DeviceNode is NULL or there was insufficient memory. + +--*/ +; + +typedef +CHAR16* +(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +/*++ + + Routine Description: + Convert a device path to its text representation. + + Arguments: + DeviceNode - Points to the device path to be converted. + DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + + Returns: + A pointer - a pointer to the allocated text representation of the device path. + NULL - if DeviceNode is NULL or there was insufficient memory. + +--*/ +; + +typedef struct { + EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText; + EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText; +} EFI_DEVICE_PATH_TO_TEXT_PROTOCOL; + +extern EFI_GUID gEfiDevicePathToTextProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c new file mode 100644 index 0000000000..d23b9a6552 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePathUtilities.c + +Abstract: + + DevicePathUtilities protocol as defined in the UEFI 2.0 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities) + +EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDevicePathUtilitiesProtocolGuid, "Device Path Utilities Protocol", "UEFI 2.0 Device Path Utilities protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h new file mode 100644 index 0000000000..6cf2c69533 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h @@ -0,0 +1,225 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePathUtilities.h + +Abstract: + +--*/ + +#ifndef _DEVICE_PATH_UTILITIES_PROTOCOL_H_ +#define _DEVICE_PATH_UTILITIES_PROTOCOL_H_ + +// +// Device Path Utilities protocol +// +#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \ + { \ + 0x379be4e, 0xd706, 0x437d, 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 \ + } + +typedef +UINTN +(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + + Routine Description: + Returns the size of the device path, in bytes. + + Arguments: + DevicePath - Points to the start of the EFI device path. + + Returns: + Size - Size of the specified device path, in bytes, including the end-of-path tag. + +--*/ +; + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + + Routine Description: + Create a duplicate of the specified path. + + Arguments: + DevicePath - Points to the source EFI device path. + + Returns: + Pointer - A pointer to the duplicate device path. + NULL - Insufficient memory. + +--*/ +; + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1, + IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + + Routine Description: + Create a new path by appending the second device path to the first. + + Arguments: + Src1 - Points to the first device path. If NULL, then it is ignored. + Src2 - Points to the second device path. If NULL, then it is ignored. + + Returns: + Pointer - A pointer to the newly created device path. + NULL - Memory could not be allocated + or either DevicePath or DeviceNode is NULL. + +--*/ +; + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode + ) +/*++ + + Routine Description: + Creates a new path by appending the device node to the device path. + + Arguments: + DevicePath - Points to the device path. + DeviceNode - Points to the device node. + + Returns: + Pointer - A pointer to the allocated device node. + NULL - Memory could not be allocated + or either DevicePath or DeviceNode is NULL. + +--*/ +; + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance + ) +/*++ + + Routine Description: + Creates a new path by appending the specified device path instance to the specified device path. + + Arguments: + DevicePath - Points to the device path. If NULL, then ignored. + DevicePathInstance - Points to the device path instance. + + Returns: + Pointer - A pointer to the newly created device path + NULL - Memory could not be allocated or DevicePathInstance is NULL. + +--*/ +; + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE) ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance, + OUT UINTN *DevicePathInstanceSize + ) +/*++ + + Routine Description: + Creates a copy of the current device path instance and returns a pointer to the next device path instance. + + Arguments: + DevicePathInstance - On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next + device path instance or NULL if there are no more device + path instances in the device path. + DevicePathInstanceSize - On output, this holds the size of the device path instance, + in bytes or zero, if DevicePathInstance is zero. + + Returns: + Pointer - A pointer to the copy of the current device path instance. + NULL - DevicePathInstace was NULL on entry or there was insufficient memory. + +--*/ +; + +typedef +BOOLEAN +(EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + + Routine Description: + Returns whether a device path is multi-instance. + + Arguments: + DevicePath - Points to the device path. If NULL, then ignored. + + Returns: + TRUE - The device path has more than one instance + FALSE - The device path is empty or contains only a single instance. + +--*/ +; + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE) ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ) +/*++ + + Routine Description: + Creates a device node + + Arguments: + NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for + the new device node. + NodeSubType - NodeSubType is the device node sub-type + EFI_DEVICE_PATH.SubType) for the new device node. + NodeLength - NodeLength is the length of the device node + (EFI_DEVICE_PATH.Length) for the new device node. + + Returns: + Pointer - A pointer to the newly created device node. + NULL - NodeLength is less than + the size of the header or there was insufficient memory. + +--*/ +; + +typedef struct { + EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize; + EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath; + EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath; + EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode; + EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance; + EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance; + EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance; + EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode; +} EFI_DEVICE_PATH_UTILITIES_PROTOCOL; + +extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c new file mode 100644 index 0000000000..d2775cffcb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Dhcp4.c + +Abstract: + + UEFI Dynamic Host Configuration Protocol 4. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Dhcp4) + +EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid + = EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID; + +EFI_GUID gEfiDhcp4ProtocolGuid + = EFI_DHCP4_PROTOCOL_GUID; + +EFI_GUID_STRING ( + &gEfiDhcp4ServiceBindingProtocolGuid, + "DHCP4 Service Binding Protocol", + "DHCP4 Service Binding Protocol" + ); + +EFI_GUID_STRING ( + &gEfiDhcp4ProtocolGuid, + "DHCP4 Protocol", + "DHCP4 Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h new file mode 100644 index 0000000000..3409ca06cb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h @@ -0,0 +1,237 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Dhcp4.h + +Abstract: + + UEFI Dynamic Host Configuration Protocol 4 Definition + +--*/ + +#ifndef _DHCP4_H_ +#define _DHCP4_H_ + +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) +#include EFI_PROTOCOL_DEFINITION (Udp4) + +//GUID definitions +#define EFI_DHCP4_PROTOCOL_GUID \ + {0x8a219718, 0x4ef5, 0x4761, 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56} + +#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \ + {0x9d9a39d8, 0xbd42, 0x4a73, 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80} + +extern EFI_GUID gEfiDhcp4ProtocolGuid; +extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid; + +EFI_FORWARD_DECLARATION (EFI_DHCP4_PROTOCOL); + +#pragma pack(1) +typedef struct { + UINT8 OpCode; + UINT8 Length; + UINT8 Data[1]; +} EFI_DHCP4_PACKET_OPTION; + +typedef struct{ + UINT8 OpCode; + UINT8 HwType; + UINT8 HwAddrLen; + UINT8 Hops; + UINT32 Xid; + UINT16 Seconds; + UINT16 Reserved; + EFI_IPv4_ADDRESS ClientAddr; + EFI_IPv4_ADDRESS YourAddr; + EFI_IPv4_ADDRESS ServerAddr; + EFI_IPv4_ADDRESS GwAddr; + UINT8 ClientHwAddr[16]; + CHAR8 ServerName[64]; + CHAR8 BootFileName[128]; +}EFI_DHCP4_HEADER; + +typedef struct { + UINT32 Size; + UINT32 Length; + struct { + EFI_DHCP4_HEADER Header; + UINT32 Magik; + UINT8 Option[1]; + } Dhcp4; +} EFI_DHCP4_PACKET; +#pragma pack() + +typedef enum { + Dhcp4Stopped = 0x0, + Dhcp4Init = 0x1, + Dhcp4Selecting = 0x2, + Dhcp4Requesting = 0x3, + Dhcp4Bound = 0x4, + Dhcp4Renewing = 0x5, + Dhcp4Rebinding = 0x6, + Dhcp4InitReboot = 0x7, + Dhcp4Rebooting = 0x8 +} EFI_DHCP4_STATE; + +typedef enum{ + Dhcp4SendDiscover = 0x01, + Dhcp4RcvdOffer = 0x02, + Dhcp4SelectOffer = 0x03, + Dhcp4SendRequest = 0x05, + Dhcp4RcvdAck = 0x06, + Dhcp4RcvdNak = 0x07, + Dhcp4SendDecline = 0x08, + Dhcp4BoundCompleted = 0x09, + Dhcp4EnterRenewing = 0x0a, + Dhcp4EnterRebinding = 0x0b, + Dhcp4AddressLost = 0x0c, + Dhcp4Fail = 0x0d +} EFI_DHCP4_EVENT; + +typedef EFI_STATUS (*EFI_DHCP4_CALLBACK)( + IN EFI_DHCP4_PROTOCOL *This, + IN VOID *Context, + IN EFI_DHCP4_STATE CurrentState, + IN EFI_DHCP4_EVENT Dhcp4Event, + IN EFI_DHCP4_PACKET *Packet OPTIONAL, + OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL +); + +typedef struct { + UINT32 DiscoverTryCount; + UINT32 *DiscoverTimeout; + UINT32 RequestTryCount; + UINT32 *RequestTimeout; + EFI_IPv4_ADDRESS ClientAddress; + EFI_DHCP4_CALLBACK Dhcp4Callback; + VOID *CallbackContext; + UINT32 OptionCount; + EFI_DHCP4_PACKET_OPTION **OptionList; +}EFI_DHCP4_CONFIG_DATA; + +typedef struct { + EFI_DHCP4_STATE State; + EFI_DHCP4_CONFIG_DATA ConfigData; + EFI_IPv4_ADDRESS ClientAddress; + EFI_MAC_ADDRESS ClientMacAddress; + EFI_IPv4_ADDRESS ServerAddress; + EFI_IPv4_ADDRESS RouterAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT32 LeaseTime; + EFI_DHCP4_PACKET *ReplyPacket; + } EFI_DHCP4_MODE_DATA; + +typedef struct { + EFI_IPv4_ADDRESS ListenAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT16 ListenPort; +} EFI_DHCP4_LISTEN_POINT; + +typedef struct { + OUT EFI_STATUS Status; + IN EFI_EVENT CompletionEvent; + IN EFI_IPv4_ADDRESS RemoteAddress; + IN UINT16 RemotePort; + IN EFI_IPv4_ADDRESS GatewayAddress; + IN UINT32 ListenPointCount; + IN EFI_DHCP4_LISTEN_POINT *ListenPoints; + IN UINT32 TimeoutValue; + IN EFI_DHCP4_PACKET *Packet; + OUT UINT32 ResponseCount; + OUT EFI_DHCP4_PACKET *ResponseList; +}EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN; + + +typedef +EFI_STATUS +(EFIAPI *EFI_DHCP4_GET_MODE_DATA)( + IN EFI_DHCP4_PROTOCOL *This, + OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData +); + +typedef +EFI_STATUS +(EFIAPI *EFI_DHCP4_CONFIGURE) ( + IN EFI_DHCP4_PROTOCOL *This, + IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL +); + + +typedef EFI_STATUS +(EFIAPI *EFI_DHCP4_START) ( + IN EFI_DHCP4_PROTOCOL *This, + IN EFI_EVENT CompletionEvent OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_DHCP4_RENEW) ( + IN EFI_DHCP4_PROTOCOL *This, + IN BOOLEAN RebindRequest, + IN EFI_EVENT CompletionEvent OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_DHCP4_RELEASE) ( + IN EFI_DHCP4_PROTOCOL *This +); + +typedef EFI_STATUS +(EFIAPI *EFI_DHCP4_STOP) ( + IN EFI_DHCP4_PROTOCOL *This +); + +typedef +EFI_STATUS +(EFIAPI *EFI_DHCP4_BUILD) ( + IN EFI_DHCP4_PROTOCOL *This, + IN EFI_DHCP4_PACKET *SeedPacket, + IN UINT32 DeleteCount, + IN UINT8 *DeleteList OPTIONAL, + IN UINT32 AppendCount, + IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL, + OUT EFI_DHCP4_PACKET **NewPacket +); + +typedef +EFI_STATUS +(EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE) ( + IN EFI_DHCP4_PROTOCOL *This, + IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token +); + + +typedef +EFI_STATUS +(EFIAPI *EFI_DHCP4_PARSE) ( + IN EFI_DHCP4_PROTOCOL *This, + IN EFI_DHCP4_PACKET *Packet, + IN OUT UINT32 *OptionCount, + OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL +); + +typedef struct _EFI_DHCP4_PROTOCOL { + EFI_DHCP4_GET_MODE_DATA GetModeData; + EFI_DHCP4_CONFIGURE Configure; + EFI_DHCP4_START Start; + EFI_DHCP4_RENEW RenewRebind; + EFI_DHCP4_RELEASE Release; + EFI_DHCP4_STOP Stop; + EFI_DHCP4_BUILD Build; + EFI_DHCP4_TRANSMIT_RECEIVE TransmitReceive; + EFI_DHCP4_PARSE Parse; +} EFI_DHCP4_PROTOCOL; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.c new file mode 100644 index 0000000000..223ac6429f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DiskIo.c + +Abstract: + + Disk IO protocol as defined in the EFI 1.0 specification. + + The Disk IO protocol is used to convert block oriented devices into byte + oriented devices. The Disk IO protocol is intended to layer on top of the + Block IO protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DiskIo) + +EFI_GUID gEfiDiskIoProtocolGuid = EFI_DISK_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDiskIoProtocolGuid, "DiskIo Protocol", "EFI 1.0 Disk IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.h new file mode 100644 index 0000000000..fee3034fc8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DiskIO/DiskIo.h @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DiskIo.h + +Abstract: + + Disk IO protocol as defined in the EFI 1.0 specification. + + The Disk IO protocol is used to convert block oriented devices into byte + oriented devices. The Disk IO protocol is intended to layer on top of the + Block IO protocol. + +--*/ + +#ifndef __DISK_IO_H__ +#define __DISK_IO_H__ + +#define EFI_DISK_IO_PROTOCOL_GUID \ + { \ + 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +EFI_FORWARD_DECLARATION (EFI_DISK_IO_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_READ) ( + IN EFI_DISK_IO_PROTOCOL * This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + OUT VOID *Buffer + ) +/*++ + + Routine Description: + Read BufferSize bytes from Offset into Buffer. + + Arguments: + This - Protocol instance pointer. + MediaId - Id of the media, changes every time the media is replaced. + Offset - The starting byte offset to read from + BufferSize - Size of Buffer + Buffer - Buffer containing read data + + Returns: + EFI_SUCCESS - The data was read correctly from the device. + EFI_DEVICE_ERROR - The device reported an error while performing the read. + EFI_NO_MEDIA - There is no media in the device. + EFI_MEDIA_CHNAGED - The MediaId does not matched the current device. + EFI_INVALID_PARAMETER - The read request contains device addresses that are not + valid for the device. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_WRITE) ( + IN EFI_DISK_IO_PROTOCOL * This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + IN VOID *Buffer + ) +/*++ + + Routine Description: + Read BufferSize bytes from Offset into Buffer. + + Arguments: + This - Protocol instance pointer. + MediaId - Id of the media, changes every time the media is replaced. + Offset - The starting byte offset to read from + BufferSize - Size of Buffer + Buffer - Buffer containing read data + + Returns: + EFI_SUCCESS - The data was written correctly to the device. + EFI_WRITE_PROTECTED - The device can not be written to. + EFI_DEVICE_ERROR - The device reported an error while performing the write. + EFI_NO_MEDIA - There is no media in the device. + EFI_MEDIA_CHNAGED - The MediaId does not matched the current device. + EFI_INVALID_PARAMETER - The write request contains device addresses that are not + valid for the device. + +--*/ +; + +#define EFI_DISK_IO_PROTOCOL_REVISION 0x00010000 + +typedef struct _EFI_DISK_IO_PROTOCOL { + UINT64 Revision; + EFI_DISK_READ ReadDisk; + EFI_DISK_WRITE WriteDisk; +} EFI_DISK_IO_PROTOCOL; + +extern EFI_GUID gEfiDiskIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c new file mode 100644 index 0000000000..4bdc43657e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DriverBinding.c + +Abstract: + + EFI Controller Driver Protocol + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DriverBinding) + +EFI_GUID gEfiDriverBindingProtocolGuid = EFI_DRIVER_BINDING_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDriverBindingProtocolGuid, "Controller Driver Protocol", "EFI 1.1 Controller Driver Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h new file mode 100644 index 0000000000..2f30df64a3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h @@ -0,0 +1,130 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DriverBinding.h + +Abstract: + + EFI ControllerHandle Driver Protocol + +Revision History + +--*/ + +#ifndef _EFI_DRIVER_BINDING_H_ +#define _EFI_DRIVER_BINDING_H_ + +// +// Global ID for the ControllerHandle Driver Protocol +// +#define EFI_DRIVER_BINDING_PROTOCOL_GUID \ + { \ + 0x18a031ab, 0xb443, 0x4d1a, 0xa5, 0xc0, 0xc, 0x9, 0x26, 0x1e, 0x9f, 0x71 \ + } + +EFI_FORWARD_DECLARATION (EFI_DRIVER_BINDING_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_BINDING_SUPPORTED) ( + IN EFI_DRIVER_BINDING_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL + ) +/*++ + + Routine Description: + Test to see if this driver supports ControllerHandle. + + Arguments: + This - Protocol instance pointer. + ControllerHandle - Handle of device to test + RemainingDevicePath - Optional parameter use to pick a specific child + device to start. + + Returns: + EFI_SUCCESS - This driver supports this device + EFI_ALREADY_STARTED - This driver is already running on this device + other - This driver does not support this device + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_BINDING_START) ( + IN EFI_DRIVER_BINDING_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL + ) +/*++ + + Routine Description: + Start this driver on ControllerHandle. + + Arguments: + This - Protocol instance pointer. + ControllerHandle - Handle of device to bind driver to + RemainingDevicePath - Optional parameter use to pick a specific child + device to start. + + Returns: + EFI_SUCCESS - This driver is added to ControllerHandle + EFI_ALREADY_STARTED - This driver is already running on ControllerHandle + other - This driver does not support this device + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_BINDING_STOP) ( + IN EFI_DRIVER_BINDING_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE * ChildHandleBuffer + ) +/*++ + + Routine Description: + Stop this driver on ControllerHandle. + + Arguments: + This - Protocol instance pointer. + ControllerHandle - Handle of device to stop driver on + NumberOfChildren - Number of Handles in ChildHandleBuffer. If number of + children is zero stop the entire bus driver. + ChildHandleBuffer - List of Child Handles to Stop. + + Returns: + EFI_SUCCESS - This driver is removed ControllerHandle + other - This driver was not removed from this device + +--*/ +; + +// +// Interface structure for the ControllerHandle Driver Protocol +// +typedef struct _EFI_DRIVER_BINDING_PROTOCOL { + EFI_DRIVER_BINDING_SUPPORTED Supported; + EFI_DRIVER_BINDING_START Start; + EFI_DRIVER_BINDING_STOP Stop; + UINT32 Version; + EFI_HANDLE ImageHandle; + EFI_HANDLE DriverBindingHandle; +} EFI_DRIVER_BINDING_PROTOCOL; + +extern EFI_GUID gEfiDriverBindingProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c new file mode 100644 index 0000000000..697e48929d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DriverConfiguration.c + +Abstract: + + EFI Driver Configuration Protocol + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DriverConfiguration) + +EFI_GUID gEfiDriverConfigurationProtocolGuid = EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiDriverConfigurationProtocolGuid, "Driver Configuration Protocol", "EFI 1.1 Driver Configuration Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h new file mode 100644 index 0000000000..f43b816724 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h @@ -0,0 +1,211 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DriverConfiguration.h + +Abstract: + + EFI Driver Configuration Protocol + +Revision History + +--*/ + +#ifndef _EFI_DRIVER_CONFIGURATION_H_ +#define _EFI_DRIVER_CONFIGURATION_H_ + +// +// Global ID for the Driver Configuration Protocol +// +#define EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID \ + { \ + 0x107a772b, 0xd5e1, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_DRIVER_CONFIGURATION_PROTOCOL); + +typedef enum { + EfiDriverConfigurationActionNone = 0, + EfiDriverConfigurationActionStopController = 1, + EfiDriverConfigurationActionRestartController = 2, + EfiDriverConfigurationActionRestartPlatform = 3, + EfiDriverConfigurationActionMaximum +} EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED; + +#define EFI_DRIVER_CONFIGURATION_SAFE_DEFAULTS 0x00000000 +#define EFI_DRIVER_CONFIGURATION_MANUFACTURING_DEFAULTS 0x00000001 +#define EFI_DRIVER_CONFIGURATION_CUSTOM_DEFAULTS 0x00000002 +#define EFI_DRIVER_CONFIGURATION_PERORMANCE_DEFAULTS 0x00000003 + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_CONFIGURATION_SET_OPTIONS) ( + IN EFI_DRIVER_CONFIGURATION_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED * ActionRequired + ); + +/*++ + + Routine Description: + Allows the user to set controller specific options for a controller that a + driver is currently managing. + + Arguments: + This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance. + ControllerHandle - The handle of the controller to set options on. + ChildHandle - The handle of the child controller to set options on. This + is an optional parameter that may be NULL. It will be NULL + for device drivers, and for a bus drivers that wish to set + options for the bus controller. It will not be NULL for a + bus driver that wishes to set options for one of its child + controllers. + Language - A pointer to a three character ISO 639-2 language identifier. + This is the language of the user interface that should be + presented to the user, and it must match one of the languages + specified in SupportedLanguages. The number of languages + supported by a driver is up to the driver writer. + ActionRequired - A pointer to the action that the calling agent is required + to perform when this function returns. See "Related + Definitions" for a list of the actions that the calling + agent is required to perform prior to accessing + ControllerHandle again. + + Returns: + EFI_SUCCESS - The driver specified by This successfully set the + configuration options for the controller specified + by ControllerHandle.. + EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ActionRequired is NULL. + EFI_UNSUPPORTED - The driver specified by This does not support setting + configuration options for the controller specified by + ControllerHandle and ChildHandle. + EFI_UNSUPPORTED - The driver specified by This does not support the + language specified by Language. + EFI_DEVICE_ERROR - A device error occurred while attempt to set the + configuration options for the controller specified + by ControllerHandle and ChildHandle. + EFI_OUT_RESOURCES - There are not enough resources available to set the + configuration options for the controller specified + by ControllerHandle and ChildHandle. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_CONFIGURATION_OPTIONS_VALID) ( + IN EFI_DRIVER_CONFIGURATION_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL + ); + +/*++ + + Routine Description: + Tests to see if a controller's current configuration options are valid. + + Arguments: + This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance. + ControllerHandle - The handle of the controller to test if it's current + configuration options are valid. + ChildHandle - The handle of the child controller to test if it's current + configuration options are valid. This is an optional + parameter that may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers that wish + to test the configuration options for the bus controller. + It will not be NULL for a bus driver that wishes to test + configuration options for one of its child controllers. + + Returns: + EFI_SUCCESS - The controller specified by ControllerHandle and + ChildHandle that is being managed by the driver + specified by This has a valid set of configuration + options. + EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. + EFI_UNSUPPORTED - The driver specified by This is not currently + managing the controller specified by ControllerHandle + and ChildHandle. + EFI_DEVICE_ERROR - The controller specified by ControllerHandle and + ChildHandle that is being managed by the driver + specified by This has an invalid set of configuration + options. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_CONFIGURATION_FORCE_DEFAULTS) ( + IN EFI_DRIVER_CONFIGURATION_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN UINT32 DefaultType, + OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED * ActionRequired + ); + +/*++ + + Routine Description: + Forces a driver to set the default configuration options for a controller. + + Arguments: + This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance. + ControllerHandle - The handle of the controller to force default configuration options on. + ChildHandle - The handle of the child controller to force default configuration options on This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller. It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers. + DefaultType - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle. See Table 9-1 for legal values. A DefaultType of 0x00000000 must be supported by this protocol. + ActionRequired - A pointer to the action that the calling agent is required to perform when this function returns. See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again. + + Returns: + EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle. + EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ActionRequired is NULL. + EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle. + EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType. + EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle. + EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle. + +--*/ + +// +// Interface structure for the Driver Configuration Protocol +// +typedef struct _EFI_DRIVER_CONFIGURATION_PROTOCOL { + EFI_DRIVER_CONFIGURATION_SET_OPTIONS SetOptions; + EFI_DRIVER_CONFIGURATION_OPTIONS_VALID OptionsValid; + EFI_DRIVER_CONFIGURATION_FORCE_DEFAULTS ForceDefaults; + CHAR8 *SupportedLanguages; +} EFI_DRIVER_CONFIGURATION_PROTOCOL; + +/*++ + + Protocol Description: + Used to set configuration options for a controller that an EFI Driver is managing. + + Parameters: + SetOptions - Allows the use to set drivers specific configuration + options for a controller that the driver is currently + managing. + OptionsValid - Tests to see if a controller's current configuration + options are valid. + ForceDefaults - Forces a driver to set the default configuration options + for a controller. + SupportedLanguages - A Null-terminated ASCII string that contains one or more + ISO 639-2 language codes. This is the list of language + codes that this protocol supports. + +--*/ +extern EFI_GUID gEfiDriverConfigurationProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c new file mode 100644 index 0000000000..2b20c2bb39 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DriverDiagnostics.c + +Abstract: + + EFI Driver Diagnostics Protocol + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics) + +EFI_GUID gEfiDriverDiagnosticsProtocolGuid = EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiDriverDiagnosticsProtocolGuid, "Driver Diagnostics Protocol", "EFI 1.1 Driver Diagnostics Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h new file mode 100644 index 0000000000..9a96f47a5e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h @@ -0,0 +1,138 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DriverDiagnostics.h + +Abstract: + + EFI Driver Diagnostics Protocol + +Revision History + +--*/ + +#ifndef _EFI_DRIVER_DIAGNOSTICS_H_ +#define _EFI_DRIVER_DIAGNOSTICS_H_ + +// +// Global ID for the Driver Diagnostics Protocol +// +#define EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID \ + { \ + 0x0784924f, 0xe296, 0x11d4, 0x9a, 0x49, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_DRIVER_DIAGNOSTICS_PROTOCOL); + +typedef enum { + EfiDriverDiagnosticTypeStandard = 0, + EfiDriverDiagnosticTypeExtended = 1, + EfiDriverDiagnosticTypeManufacturing= 2, + EfiDriverDiagnosticTypeMaximum +} EFI_DRIVER_DIAGNOSTIC_TYPE; + +typedef +EFI_STATUS +(EFIAPI *EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS) ( + IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType, + IN CHAR8 *Language, + OUT EFI_GUID **ErrorType, + OUT UINTN *BufferSize, + OUT CHAR16 **Buffer + ); + +/*++ + + Routine Description: + Runs diagnostics on a controller. + + Arguments: + This - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance. + ControllerHandle - The handle of the controller to run diagnostics on. + ChildHandle - The handle of the child controller to run diagnostics on + This is an optional parameter that may be NULL. It will + be NULL for device drivers. It will also be NULL for a + bus drivers that wish to run diagnostics on the bus + controller. It will not be NULL for a bus driver that + wishes to run diagnostics on one of its child controllers. + DiagnosticType - Indicates type of diagnostics to perform on the controller + specified by ControllerHandle and ChildHandle. See + "Related Definitions" for the list of supported types. + Language - A pointer to a three character ISO 639-2 language + identifier. This is the language in which the optional + error message should be returned in Buffer, and it must + match one of the languages specified in SupportedLanguages. + The number of languages supported by a driver is up to + the driver writer. + ErrorType - A GUID that defines the format of the data returned in + Buffer. + BufferSize - The size, in bytes, of the data returned in Buffer. + Buffer - A buffer that contains a Null-terminated Unicode string + plus some additional data whose format is defined by + ErrorType. Buffer is allocated by this function with + AllocatePool(), and it is the caller's responsibility + to free it with a call to FreePool(). + + Returns: + EFI_SUCCESS - The controller specified by ControllerHandle and + ChildHandle passed the diagnostic. + EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. + EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + EFI_INVALID_PARAMETER - Language is NULL. + EFI_INVALID_PARAMETER - ErrorType is NULL. + EFI_INVALID_PARAMETER - BufferType is NULL. + EFI_INVALID_PARAMETER - Buffer is NULL. + EFI_UNSUPPORTED - The driver specified by This does not support + running diagnostics for the controller specified + by ControllerHandle and ChildHandle. + EFI_UNSUPPORTED - The driver specified by This does not support the + type of diagnostic specified by DiagnosticType. + EFI_UNSUPPORTED - The driver specified by This does not support the + language specified by Language. + EFI_OUT_OF_RESOURCES - There are not enough resources available to complete + the diagnostics. + EFI_OUT_OF_RESOURCES - There are not enough resources available to return + the status information in ErrorType, BufferSize, + and Buffer. + EFI_DEVICE_ERROR - The controller specified by ControllerHandle and + ChildHandle did not pass the diagnostic. + +--*/ + +// +// Interface structure for the Driver Diagnostics Protocol +// +typedef struct _EFI_DRIVER_DIAGNOSTICS_PROTOCOL { + EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS RunDiagnostics; + CHAR8 *SupportedLanguages; +} EFI_DRIVER_DIAGNOSTICS_PROTOCOL; + +/*++ + + Protocol Description: + Used to perform diagnostics on a controller that an EFI Driver is managing. + + Parameters: + RunDiagnostics - Runs diagnostics on a controller. + SupportedLanguages - A Null-terminated ASCII string that contains one or more + ISO 639-2 language codes. This is the list of language + codes that this protocol supports. + +--*/ +extern EFI_GUID gEfiDriverDiagnosticsProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.c new file mode 100644 index 0000000000..6ce94a03aa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Ebc.c + +Abstract: + + EBC protocol as defined in the EFI 1.1 specification. + + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Ebc) + +EFI_GUID gEfiEbcProtocolGuid = EFI_EBC_INTERPRETER_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiEbcProtocolGuid, "EBC Protocol", "EFI 1.1 EBC protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.h new file mode 100644 index 0000000000..35c4221284 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ebc/Ebc.h @@ -0,0 +1,183 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Ebc.h + +Abstract: + + Describes the protocol interface to the EBC interpreter. + +--*/ + +#ifndef _EBC_H_ +#define _EBC_H_ + +#define EFI_EBC_INTERPRETER_PROTOCOL_GUID \ + { \ + 0x13AC6DD1, 0x73D0, 0x11D4, 0xB0, 0x6B, 0x00, 0xAA, 0x00, 0xBD, 0x6D, 0xE7 \ + } + +// +// Define for forward reference. +// +EFI_FORWARD_DECLARATION (EFI_EBC_PROTOCOL); + +/*++ + +Routine Description: + + Create a thunk for an image entry point. In short, given the physical address + of the entry point for a loaded image, create a thunk that does some + fixup of arguments (and perform any other necessary overhead) and then + calls the original entry point. The caller can then use the returned pointer + to the created thunk as the new entry point to image. + +Arguments: + + This - protocol instance pointer + ImageHandle - handle to the image. The EBC interpreter may use this to keep + track of any resource allocations performed in loading and + executing the image. + EbcEntryPoint - the entry point for the image (as defined in the file header) + Thunk - pointer to thunk pointer where the address of the created + thunk is returned. + +Returns: + + Standard EFI_STATUS + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_CREATE_THUNK) ( + IN EFI_EBC_PROTOCOL * This, + IN EFI_HANDLE ImageHandle, + IN VOID *EbcEntryPoint, + OUT VOID **Thunk + ); + +/*++ + +Routine Description: + + Perform any cleanup necessary when an image is unloaded. Basically it gives + the EBC interpreter the chance to free up any resources allocated during + load and execution of an EBC image. + +Arguments: + + This - protocol instance pointer + ImageHandle - the handle of the image being unloaded. + +Returns: + + Standard EFI_STATUS. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_UNLOAD_IMAGE) ( + IN EFI_EBC_PROTOCOL * This, + IN EFI_HANDLE ImageHandle + ); + +/*++ + +Routine Description: + + The I-Cache-flush registration service takes a pointer to a function to + call to flush the I-Cache. Here's the prototype for that function pointer. + +Arguments: + + Start - physical start address of CPU instruction cache to flush. + Length - how many bytes to flush of the instruction cache. + +Returns: + + Standard EFI_STATUS. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EBC_ICACHE_FLUSH) ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ); + +/*++ + +Routine Description: + + This routine is called by the core firmware to provide the EBC driver with + a function to call to flush the CPU's instruction cache following creation + of a thunk. It is not required. + +Arguments: + + This - protocol instance pointer + Flush - pointer to the function to call to flush the CPU instruction + cache. + +Returns: + + Standard EFI_STATUS. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_REGISTER_ICACHE_FLUSH) ( + IN EFI_EBC_PROTOCOL * This, + IN EBC_ICACHE_FLUSH Flush + ); + +/*++ + +Routine Description: + + This routine can be called to get the VM revision. It returns the same + value as the EBC BREAK 1 instruction returns. + +Arguments: + + This - protocol instance pointer + Version - pointer to where to return the VM version + +Returns: + + Standard EFI_STATUS. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_GET_VERSION) ( + IN EFI_EBC_PROTOCOL * This, + IN OUT UINT64 *Version + ); + +// +// Prototype for the actual EBC protocol interface +// +typedef struct _EFI_EBC_PROTOCOL { + EFI_EBC_CREATE_THUNK CreateThunk; + EFI_EBC_UNLOAD_IMAGE UnloadImage; + EFI_EBC_REGISTER_ICACHE_FLUSH RegisterICacheFlush; + EFI_EBC_GET_VERSION GetVersion; +} EFI_EBC_PROTOCOL; + +// +// Extern the global EBC protocol GUID +// +extern EFI_GUID gEfiEbcProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.c new file mode 100644 index 0000000000..43a4144b70 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EdidActive.c + +Abstract: + + EDID Active Protocol from the UEFI 2.0 specification. + + Placed on the video output device child handle that are actively displaying output. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (EdidActive) + +EFI_GUID gEfiEdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiEdidActiveProtocolGuid, "EFI EDID Active Protocol", "UEFI EDID Active Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.h new file mode 100644 index 0000000000..50b325dd3b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidActive/EdidActive.h @@ -0,0 +1,39 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EdidActive.h + +Abstract: + + EDID Active Protocol from the UEFI 2.0 specification. + + Placed on the video output device child handle that are actively displaying output. + +--*/ + +#ifndef __EDID_ACTIVE_H__ +#define __EDID_ACTIVE_H__ + +#define EFI_EDID_ACTIVE_PROTOCOL_GUID \ + { \ + 0xbd8c1056, 0x9f36, 0x44ec, 0x92, 0xa8, 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 \ + } + +typedef struct { + UINT32 SizeOfEdid; + UINT8 *Edid; +} EFI_EDID_ACTIVE_PROTOCOL; + +extern EFI_GUID gEfiEdidActiveProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c new file mode 100644 index 0000000000..babfa519f4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EdidDiscovered.c + +Abstract: + + EDID Discovered Protocol from the UEFI 2.0 specification. + + This protocol is placed on the video output device child handle and it represents + the EDID information being used for output device represented by the child handle. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (EdidDiscovered) + +EFI_GUID gEfiEdidDiscoveredProtocolGuid = EFI_EDID_DISCOVERED_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiEdidDiscoveredProtocolGuid, "EFI EDID Discovered Protocol", "UEFI EDID Discovered Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h new file mode 100644 index 0000000000..36061f66f8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EdidDiscovered.h + +Abstract: + + EDID Discovered Protocol from the UEFI 2.0 specification. + + This protocol is placed on the video output device child handle and it represents + the EDID information being used for output device represented by the child handle. + +--*/ + +#ifndef __EDID_DISCOVERED_H__ +#define __EDID_DISCOVERED_H__ + +#define EFI_EDID_DISCOVERED_PROTOCOL_GUID \ + { \ + 0x1c0c34f6, 0xd380, 0x41fa, 0xa0, 0x49, 0x8a, 0xd0, 0x6c,0x1a, 0x66, 0xaa \ + } + +typedef struct { + UINT32 SizeOfEdid; + UINT8 *Edid; +} EFI_EDID_DISCOVERED_PROTOCOL; + +extern EFI_GUID gEfiEdidDiscoveredProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c new file mode 100644 index 0000000000..fae77a7455 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EdidOverride.c + +Abstract: + + EDID Override Protocol from the UEFI 2.0 specification. + + Allow platform to provide EDID information to producer of the Graphics Output + protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (EdidOverride) + +EFI_GUID gEfiEdidOverrideProtocolGuid = EFI_EDID_OVERRIDE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiEdidOverrideProtocolGuid, "EFI EDID Override Protocol", "UEFI EDID Override Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h new file mode 100644 index 0000000000..d720a789c5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h @@ -0,0 +1,78 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EdidOverride.h + +Abstract: + + EDID Override Protocol from the UEFI 2.0 specification. + + Allow platform to provide EDID information to producer of the Graphics Output + protocol. + +--*/ + +#ifndef __EDID_OVERRIDE_H__ +#define __EDID_OVERRIDE_H__ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (EdidDiscovered) + +#define EFI_EDID_OVERRIDE_PROTOCOL_GUID \ + { \ + 0x48ecb431, 0xfb72, 0x45c0, 0xa9, 0x22, 0xf4, 0x58, 0xfe, 0x4, 0xb, 0xd5 \ + } + +typedef struct _EFI_EDID_OVERRIDE_PROTOCOL EFI_EDID_OVERRIDE_PROTOCOL; + +#define EFI_EDID_OVERRIDE_DONT_OVERRIDE 0x01 +#define EFI_EDID_OVERRIDE_ENABLE_HOT_PLUG 0x02 + +typedef +EFI_STATUS +(EFIAPI *EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID) ( + IN EFI_EDID_OVERRIDE_PROTOCOL *This, + IN EFI_HANDLE *ChildHandle, + OUT UINT32 *Attributes, + IN OUT UINTN *EdidSize, + IN OUT UINT8 **Edid + ) +/*++ + + Routine Description: + Return the current video mode information. + + Arguments: + This - Protocol instance pointer. + ChildHandle - A child handle produced by the Graphics Output EFI + driver that represents a video output device. + Attributes - The attributes associated with ChildHandle video output device. + EdidSize - A pointer to the size, in bytes, of the Edid buffer. + Edid - A pointer to callee allocated buffer that contains the EDID that + should be used for ChildHandle. A value of NULL + represents no EDID override for ChildHandle. + + Returns: + EFI_SUCCESS - Valid overrides returned for ChildHandle. + EFI_UNSUPPORTED - ChildHandle has no overrides. + +--*/ +; + +typedef struct _EFI_EDID_OVERRIDE_PROTOCOL { + EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID GetEdid; +} EFI_EDID_OVERRIDE_PROTOCOL; + +extern EFI_GUID gEfiEdidOverrideProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c new file mode 100644 index 0000000000..c37e9c61e6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiNetworkInterfaceIdentifier.c + +Abstract: + + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier) + +EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiNetworkInterfaceIdentifierProtocolGuid, "Network Interface Identifier Protocol", + "EFI Network Interface Identifier Protocol" + ); + +EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid_31 = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31; + +EFI_GUID_STRING + ( + &gEfiNetworkInterfaceIdentifierProtocolGuid_31, "Network Interface Identifier Protocol_31", + "EFI1.1 Network Interface Identifier Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h new file mode 100644 index 0000000000..5a6bedd069 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h @@ -0,0 +1,102 @@ +/*++ +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module name: + + EfiNetworkInterfaceIdentifier.h + +Abstract: + +Revision history: + 2000-Feb-18 M(f)J GUID updated. + Structure order changed for machine word alignment. + Added StringId[4] to structure. + + 2000-Feb-14 M(f)J Genesis. +--*/ +#ifndef _EFI_NETWORKINTERFACEIDENTIFER_H +#define _EFI_NETWORKINTERFACEIDENTIFER_H + + +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \ + { \ + 0xE18541CD, 0xF755, 0x4f73, 0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29 \ + } +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31 \ + { \ + 0x1ACED566, 0x76ED, 0x4218, 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 \ + } + +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000 +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31 0x00010001 + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL); + +typedef enum { + EfiNetworkInterfaceUndi = 1 +} EFI_NETWORK_PROTOCOL_TYPE; + +typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL { + + UINT64 Revision; + // + // Revision of the network interface identifier protocol interface. + // + UINT64 ID; + // + // Address of the first byte of the identifying structure for this + // network interface. This is set to zero if there is no structure. + // + // For PXE/UNDI this is the first byte of the !PXE structure. + // + UINT64 ImageAddr; + // + // Address of the UNrelocated driver/ROM image. This is set + // to zero if there is no driver/ROM image. + // + // For 16-bit UNDI, this is the first byte of the option ROM in + // upper memory. + // + // For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM + // image. + // + // For H/W UNDI, this is set to zero. + // + UINT32 ImageSize; + // + // Size of the UNrelocated driver/ROM image of this network interface. + // This is set to zero if there is no driver/ROM image. + // + CHAR8 StringId[4]; + // + // 4 char ASCII string to go in class identifier (option 60) in DHCP + // and Boot Server discover packets. + // For EfiNetworkInterfaceUndi this field is "UNDI". + // For EfiNetworkInterfaceSnp this field is "SNPN". + // + UINT8 Type; + UINT8 MajorVer; + UINT8 MinorVer; + // + // Information to be placed into the PXE DHCP and Discover packets. + // This is the network interface type and version number that will + // be placed into DHCP option 94 (client network interface identifier). + // + BOOLEAN Ipv6Supported; + UINT8 IfNum; // interface number to be used with pxeid structure +} EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL; + +extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid; +extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid_31; + +#endif // _EFI_NII_H diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf new file mode 100644 index 0000000000..f1add5c8d8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf @@ -0,0 +1,158 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiProtocolLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME= EfiProtocolLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[nmake.common] + +[sources.common] + AcpiTable\AcpiTable.h + AcpiTable\AcpiTable.c + Arp\Arp.h + Arp\Arp.c + Bis\Bis.h + Bis\Bis.c + BlockIo\BlockIo.h + BlockIo\BlockIo.c + BusSpecificDriverOverride\BusSpecificDriverOverride.h + BusSpecificDriverOverride\BusSpecificDriverOverride.c + ComponentName\ComponentName.h + ComponentName\ComponentName.c + ComponentName2\ComponentName2.h + ComponentName2\ComponentName2.c + DebugPort\DebugPort.h + DebugPort\DebugPort.c + DebugSupport\DebugSupport.h + DebugSupport\DebugSupport.c + Decompress\Decompress.h + Decompress\Decompress.c + DeviceIo\DeviceIo.h + DeviceIo\DeviceIo.c + DevicePath\DevicePath.h + DevicePath\DevicePath.c + DevicePathFromText\DevicePathFromText.h + DevicePathFromText\DevicePathFromText.c + DevicePathToText\DevicePathToText.h + DevicePathToText\DevicePathToText.c + DevicePathUtilities\DevicePathUtilities.h + DevicePathUtilities\DevicePathUtilities.c + Dhcp4\Dhcp4.h + Dhcp4\Dhcp4.c + DiskIo\DiskIo.h + DiskIo\DiskIo.c + DriverBinding\DriverBinding.h + DriverBinding\DriverBinding.c + DriverConfiguration\DriverConfiguration.h + DriverConfiguration\DriverConfiguration.c + DriverDiagnostics\DriverDiagnostics.h + DriverDiagnostics\DriverDiagnostics.c + Ebc\Ebc.h + Ebc\Ebc.c + EdidActive\EdidActive.h + EdidActive\EdidActive.c + EdidDiscovered\EdidDiscovered.h + EdidDiscovered\EdidDiscovered.c + EdidOverride\EdidOverride.h + EdidOverride\EdidOverride.c + EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.h + EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.c + FileInfo\FileInfo.h + FileInfo\FileInfo.c + FileSystemInfo\FileSystemInfo.h + FileSystemInfo\FileSystemInfo.c + FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.h + FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.c + GraphicsOutput\GraphicsOutput.h + GraphicsOutput\GraphicsOutput.c + Ip4\Ip4.h + Ip4\Ip4.c + Ip4Config\Ip4Config.h + Ip4Config\Ip4Config.c + LoadedImage\LoadedImage.h + LoadedImage\LoadedImage.c + LoadFile\LoadFile.h + LoadFile\LoadFile.c + ManagedNetwork\ManagedNetwork.h + ManagedNetwork\ManagedNetwork.c + Mtftp4\Mtftp4.h + Mtftp4\Mtftp4.c + PciIo\PciIo.h + PciIo\PciIo.c + PciRootBridgeIo\PciRootBridgeIo.h + PciRootBridgeIo\PciRootBridgeIo.c + PlatformDriverOverride\PlatformDriverOverride.h + PlatformDriverOverride\PlatformDriverOverride.c + PxeBaseCode\PxeBaseCode.h + PxeBaseCode\PxeBaseCode.c + PxeBaseCodeCallBack\PxeBaseCodeCallBack.h + PxeBaseCodeCallBack\PxeBaseCodeCallBack.c + ScsiPassThru\ScsiPassThru.h + ScsiPassThru\ScsiPassThru.c + SerialIo\SerialIo.h + SerialIo\SerialIo.c + SimpleFileSystem\SimpleFileSystem.h + SimpleFileSystem\SimpleFileSystem.c + SimpleNetwork\SimpleNetwork.h + SimpleNetwork\SimpleNetwork.c + SimplePointer\SimplePointer.h + SimplePointer\SimplePointer.c + SimpleTextIn\SimpleTextIn.h + SimpleTextIn\SimpleTextIn.c + SimpleTextOut\SimpleTextOut.h + SimpleTextOut\SimpleTextOut.c + Udp4\Udp4.h + Udp4\Udp4.c + UgaDraw\UgaDraw.h + UgaDraw\UgaDraw.c + UgaIo\UgaIo.h + UgaIo\UgaIo.c + UnicodeCollation\UnicodeCollation.h + UnicodeCollation\UnicodeCollation.c + UsbHostController\UsbHostController.h + UsbHostController\UsbHostController.c + UsbIo\UsbIo.h + UsbIo\UsbIo.c + Hash\Hash.h + Hash\Hash.c + ServiceBinding\ServiceBinding.h + ScsiPassThruExt\ScsiPassThruExt.h + ScsiPassThruExt\ScsiPassThruExt.c + ScsiIo\ScsiIo.h + ScsiIo\ScsiIo.c + TapeIo\TapeIo.h + TapeIo\TapeIo.c + Tcp4\Tcp4.h + Tcp4\Tcp4.c + IScsiInitiatorName\IScsiInitiatorName.h + IScsiInitiatorName\IScsiInitiatorName.c \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.c new file mode 100644 index 0000000000..60bf39a1f9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileInfo.c + +Abstract: + + FileInfo protocol as defined in the EFI 1.0 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (FileInfo) + +EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID; + +EFI_GUID_STRING(&gEfiFileInfoGuid, "File System Info", "EFI File System Info GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.h new file mode 100644 index 0000000000..6400c0fcf7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileInfo/FileInfo.h @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileInfo.c + +Abstract: + + SimpleFileSystem protocol as defined in the EFI 1.0 specification. + + The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) + file system specified in EFI 1.0. It can also be used to abstract any + file system other than FAT. + + EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem + +--*/ + +#ifndef _FILE_INFO_H_ +#define _FILE_INFO_H_ + +#define EFI_FILE_INFO_ID \ + { \ + 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +typedef struct { + UINT64 Size; + UINT64 FileSize; + UINT64 PhysicalSize; + EFI_TIME CreateTime; + EFI_TIME LastAccessTime; + EFI_TIME ModificationTime; + UINT64 Attribute; + CHAR16 FileName[1]; +} EFI_FILE_INFO; + +// +// The FileName field of the EFI_FILE_INFO data structure is variable length. +// Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to +// be the size of the data structure without the FileName field. The following macro +// computes this size correctly no matter how big the FileName array is declared. +// This is required to make the EFI_FILE_INFO data structure ANSI compilant. +// +#define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET (EFI_FILE_INFO, FileName) + +extern EFI_GUID gEfiFileInfoGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c new file mode 100644 index 0000000000..fe7a1b0dd3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileSystemInfo.c + +Abstract: + + FileSystemInfo protocol as defined in the EFI 1.0 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (FileSystemInfo) + +EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID_GUID; + +EFI_GUID_STRING(&gEfiFileSystemInfoGuid, "File System Info ID", "EFI File System Info ID GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h new file mode 100644 index 0000000000..fd3c737a9b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileSystemInfo.h + +Abstract: + + FileSystemInfo protocol as defined in the EFI 1.0 specification. + + +--*/ + +#ifndef _FILE_SYSTEM_INFO_H_ +#define _FILE_SYSTEM_INFO_H_ + +#define EFI_FILE_SYSTEM_INFO_ID_GUID \ + { \ + 0x9576e93, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +typedef struct { + UINT64 Size; + BOOLEAN ReadOnly; + UINT64 VolumeSize; + UINT64 FreeSpace; + UINT32 BlockSize; + CHAR16 VolumeLabel[1]; +} EFI_FILE_SYSTEM_INFO; + +// +// The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length. +// Whenever code needs to know the size of the EFI_FILE_SYSTEM_INFO data structure, it needs +// to be the size of the data structure without the VolumeLable field. The following macro +// computes this size correctly no matter how big the VolumeLable array is declared. +// This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant. +// +#define SIZE_OF_EFI_FILE_SYSTEM_INFO EFI_FIELD_OFFSET (EFI_FILE_SYSTEM_INFO, VolumeLabel) + +extern EFI_GUID gEfiFileSystemInfoGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c new file mode 100644 index 0000000000..021e19a196 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileSystemVolumeLabelInfo.c + +Abstract: + + SimpleFileSystem protocol as defined in the EFI 1.0 specification. + + The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) + file system specified in EFI 1.0. It can also be used to abstract any + file system other than FAT. + + EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (FileSystemVolumeLabelInfo) + +EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID; + +EFI_GUID_STRING + (&gEfiFileSystemVolumeLabelInfoIdGuid, "File System Vol Label ID", "EFI File System Volume Label Info ID GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h new file mode 100644 index 0000000000..a831d3a35c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileSystemVolumeLabelInfo.h + +Abstract: + + FileSystemVolumeLabelInfo protocol as defined in the EFI 1.0 specification. + +--*/ + +#ifndef _FILE_SYSTEM_VOLUME_LABEL_INFO_H_ +#define _FILE_SYSTEM_VOLUME_LABEL_INFO_H_ + +#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID \ + { \ + 0xDB47D7D3, 0xFE81, 0x11d3, 0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \ + } + +typedef struct { + CHAR16 VolumeLabel[1]; +} EFI_FILE_SYSTEM_VOLUME_LABEL_INFO; + +#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET (EFI_FILE_SYSTEM_VOLUME_LABEL_INFO, VolumeLabel) + +extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c new file mode 100644 index 0000000000..fd498f0474 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GraphicsOutput.c + +Abstract: + + Graphics Output Protocol from the UEFI 2.0 specification. + + Abstraction of a very simple graphics device. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (GraphicsOutput) + +EFI_GUID gEfiGraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiGraphicsOutputProtocolGuid, "EFI Graphics Output Protocol", "UEFI Graphics Output Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h new file mode 100644 index 0000000000..6afb558a46 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h @@ -0,0 +1,206 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GraphicsOutput.h + +Abstract: + + Graphics Output Protocol from the UEFI 2.0 specification. + + Abstraction of a very simple graphics device. + +--*/ + +#ifndef __GRAPHICS_OUTPUT_H__ +#define __GRAPHICS_OUTPUT_H__ + +#include EFI_PROTOCOL_DEFINITION (UgaDraw) + +#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ + { \ + 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a \ + } + +typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL; + +typedef struct { + UINT32 RedMask; + UINT32 GreenMask; + UINT32 BlueMask; + UINT32 ReservedMask; +} EFI_PIXEL_BITMASK; + +typedef enum { + PixelRedGreenBlueReserved8BitPerColor, + PixelBlueGreenRedReserved8BitPerColor, + PixelBitMask, + PixelBltOnly, + PixelFormatMax +} EFI_GRAPHICS_PIXEL_FORMAT; + +typedef struct { + UINT32 Version; + UINT32 HorizontalResolution; + UINT32 VerticalResolution; + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; + EFI_PIXEL_BITMASK PixelInformation; + UINT32 PixelsPerScanLine; +} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION; + +typedef +EFI_STATUS +(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE) ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, + IN UINT32 ModeNumber, + OUT UINTN *SizeOfInfo, + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info + ) +/*++ + + Routine Description: + Return the current video mode information. + + Arguments: + This - Protocol instance pointer. + ModeNumber - The mode number to return information on. + SizeOfInfo - A pointer to the size, in bytes, of the Info buffer. + Info - A pointer to callee allocated buffer that returns information about ModeNumber. + + Returns: + EFI_SUCCESS - Mode information returned. + EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode. + EFI_NOT_STARTED - Video display is not initialized. Call SetMode () + EFI_INVALID_PARAMETER - One of the input args was NULL. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE) ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This, + IN UINT32 ModeNumber + ) +/*++ + + Routine Description: + Return the current video mode information. + + Arguments: + This - Protocol instance pointer. + ModeNumber - The mode number to be set. + + Returns: + EFI_SUCCESS - Graphics mode was changed. + EFI_DEVICE_ERROR - The device had an error and could not complete the request. + EFI_UNSUPPORTED - ModeNumber is not supported by this device. + +--*/ +; + +typedef EFI_UGA_PIXEL EFI_GRAPHICS_OUTPUT_BLT_PIXEL; + +typedef union { + EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel; + UINT32 Raw; +} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION; + +typedef enum { + EfiBltVideoFill, + EfiBltVideoToBltBuffer, + EfiBltBufferToVideo, + EfiBltVideoToVideo, + EfiGraphicsOutputBltOperationMax +} EFI_GRAPHICS_OUTPUT_BLT_OPERATION; + +typedef +EFI_STATUS +(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT) ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL * BltBuffer, OPTIONAL + IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta OPTIONAL + ); + +/*++ + + Routine Description: + The following table defines actions for BltOperations: + EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY) + directly to every pixel of the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + Only one pixel will be used from the BltBuffer. Delta is NOT used. + EfiBltVideoToBltBuffer - Read data from the video display rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in + the BltBuffer rectangle (DestinationX, DestinationY ) + (DestinationX + Width, DestinationY + Height). If DestinationX or + DestinationY is not zero then Delta must be set to the length in bytes + of a row in the BltBuffer. + EfiBltBufferToVideo - Write data from the BltBuffer rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the + video display rectangle (DestinationX, DestinationY) + (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is + not zero then Delta must be set to the length in bytes of a row in the + BltBuffer. + EfiBltVideoToVideo - Copy from the video display rectangle (SourceX, SourceY) + (SourceX + Width, SourceY + Height) .to the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + The BltBuffer and Delta are not used in this mode. + + Arguments: + This - Protocol instance pointer. + BltBuffer - Buffer containing data to blit into video buffer. This + buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + BltOperation - Operation to perform on BlitBuffer and video memory + SourceX - X coordinate of source for the BltBuffer. + SourceY - Y coordinate of source for the BltBuffer. + DestinationX - X coordinate of destination for the BltBuffer. + DestinationY - Y coordinate of destination for the BltBuffer. + Width - Width of rectangle in BltBuffer in pixels. + Height - Hight of rectangle in BltBuffer in pixels. + Delta - + + Returns: + EFI_SUCCESS - The Blt operation completed. + EFI_INVALID_PARAMETER - BltOperation is not valid. + EFI_DEVICE_ERROR - A hardware error occured writting to the video + buffer. + +--*/ +; + +typedef struct { + UINT32 MaxMode; + UINT32 Mode; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + UINTN SizeOfInfo; + EFI_PHYSICAL_ADDRESS FrameBufferBase; + UINTN FrameBufferSize; +} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE; + +typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL { + EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode; + EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode; + EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT Blt; + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; +} EFI_GRAPHICS_OUTPUT_PROTOCOL; + +extern EFI_GUID gEfiGraphicsOutputProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.c new file mode 100644 index 0000000000..feba9e6b7a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.c @@ -0,0 +1,40 @@ +/*++ + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Hash.c + +Abstract: + EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0. + EFI_HASH_PROTOCOL as defined in UEFI 2.0. + The EFI Hash Service Binding Protocol is used to locate hashing services support + provided by a driver and create and destroy instances of the EFI Hash Protocol + so that a multiple drivers can use the underlying hashing services. + The EFI Service Binding Protocol defines the generic Service Binding Protocol functions. + +Revision History +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Hash) + +EFI_GUID gEfiHashServiceBindingProtocolGuid = EFI_HASH_SERVICE_BINDING_PROTOCOL; +EFI_GUID gEfiHashProtocolGuid = EFI_HASH_PROTOCOL_GUID; +EFI_GUID gEfiHashAlgorithmSha1Guid = EFI_HASH_ALGORITHM_SHA1_GUID; +EFI_GUID gEfiHashAlgorithmSha224Guid = EFI_HASH_ALGORITHM_SHA224_GUID; +EFI_GUID gEfiHashAlgorithmSha256Guid = EFI_HASH_ALGORITHM_SHA256_GUID; +EFI_GUID gEfiHashAlgorithmSha384Guid = EFI_HASH_ALGORITHM_SHA384_GUID; +EFI_GUID gEfiHashAlgorithmSha512Guid = EFI_HASH_ALGORITHM_SHA512_GUID; +EFI_GUID gEfiHashAlgorithmMD5Guid = EFI_HASH_ALGORTIHM_MD5_GUID; + +EFI_GUID_STRING(&gEfiHashProtocolGuid, "Hash protoco", "UEFI 2.0 Hash protocol"); +EFI_GUID_STRING(&gEfiHashServiceBindingProtocolGuid, "Hash service binding protoco", "UEFI 2.0 Hash service binding protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.h new file mode 100644 index 0000000000..1fa9afb8dd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Hash/Hash.h @@ -0,0 +1,161 @@ +/*++ + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Hash.h + +Abstract: + EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0. + EFI_HASH_PROTOCOL as defined in UEFI 2.0. + The EFI Hash Service Binding Protocol is used to locate hashing services support + provided by a driver and create and destroy instances of the EFI Hash Protocol + so that a multiple drivers can use the underlying hashing services. + The EFI Service Binding Protocol defines the generic Service Binding Protocol functions. + +Revision History +--*/ + +#ifndef __EFI_HASH_PROTOCOL_H__ +#define __EFI_HASH_PROTOCOL_H__ + +#define EFI_HASH_SERVICE_BINDING_PROTOCOL \ + { \ + 0x42881c98, 0xa4f3, 0x44b0, {0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } \ + } + +#define EFI_HASH_PROTOCOL_GUID \ + { \ + 0xc5184932, 0xdba5, 0x46db, {0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } \ + } + +#define EFI_HASH_ALGORITHM_SHA1_GUID \ + { \ + 0x2ae9d80f, 0x3fb2, 0x4095, {0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } \ + } + +#define EFI_HASH_ALGORITHM_SHA224_GUID \ + { \ + 0x8df01a06, 0x9bd5, 0x4bf7, {0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } \ + } + +#define EFI_HASH_ALGORITHM_SHA256_GUID \ + { \ + 0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } \ + } + +#define EFI_HASH_ALGORITHM_SHA384_GUID \ + { \ + 0xefa96432, 0xde33, 0x4dd2, {0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } \ + } + +#define EFI_HASH_ALGORITHM_SHA512_GUID \ + { \ + 0xcaa4381e, 0x750c, 0x4770, {0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } \ + } + +#define EFI_HASH_ALGORTIHM_MD5_GUID \ + { \ + 0xaf7c79c, 0x65b5, 0x4319, {0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } \ + } + +typedef struct _EFI_HASH_PROTOCOL EFI_HASH_PROTOCOL; + +typedef UINT8 EFI_MD5_HASH[16]; +typedef UINT8 EFI_SHA1_HASH[20]; +typedef UINT8 EFI_SHA224_HASH[28]; +typedef UINT8 EFI_SHA256_HASH[32]; +typedef UINT8 EFI_SHA384_HASH[48]; +typedef UINT8 EFI_SHA512_HASH[64]; + +typedef union { + EFI_MD5_HASH *Md5Hash; + EFI_SHA1_HASH *Sha1Hash; + EFI_SHA224_HASH *Sha224Hash; + EFI_SHA256_HASH *Sha256Hash; + EFI_SHA384_HASH *Sha384Hash; + EFI_SHA512_HASH *Sha512Hash; +} EFI_HASH_OUTPUT; + +typedef +EFI_STATUS +(EFIAPI *EFI_HASH_GET_HASH_SIZE) ( + IN CONST EFI_HASH_PROTOCOL *This, + IN CONST EFI_GUID *HashAlgorithm, + OUT UINTN *HashSize + ) +/*++ + + Routine Description: + Returns the size of the hash which results from a specific algorithm. + + Arguments: + This - Points to this instance of EFI_HASH_PROTOCOL. + HashAlgorithm - Points to the EFI_GUID which identifies the algorithm to use. + HashSize - Holds the returned size of the algorithm¡¯s hash. + + Returns: + EFI_SUCCESS - Hash size returned successfully. + EFI_INVALID_PARAMETER - HashSize is NULL + EFI_UNSUPPORTED - The algorithm specified by HashAlgorithm is not supported + by this driver. +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_HASH_HASH) ( + IN CONST EFI_HASH_PROTOCOL *This, + IN CONST EFI_GUID *HashAlgorithm, + IN BOOLEAN Extend, + IN CONST UINT8 *Message, + IN UINT64 MessageSize, + IN OUT EFI_HASH_OUTPUT *Hash + ) +/*++ + + Routine Description: + Returns the size of the hash which results from a specific algorithm. + + Arguments: + This - Points to this instance of EFI_HASH_PROTOCOL. + HashAlgorithm - Points to the EFI_GUID which identifies the algorithm to use. + Extend - Specifies whether to create a new hash (FALSE) or extend the specified + existing hash (TRUE). + Message - Points to the start of the message. + MessageSize - The size of Message, in bytes. + Hash - On input, if Extend is TRUE, then this holds the hash to extend. On + output, holds the resulting hash computed from the message. + + Returns: + EFI_SUCCESS - Hash returned successfully. + EFI_INVALID_PARAMETER - Message or Hash is NULL + EFI_UNSUPPORTED - The algorithm specified by HashAlgorithm is not supported by this + driver. Or extend is TRUE and the algorithm doesn¡¯t support extending the hash. + +--*/ +; + +struct _EFI_HASH_PROTOCOL { + EFI_HASH_GET_HASH_SIZE GetHashSize; + EFI_HASH_HASH Hash; +}; + +extern EFI_GUID gEfiHashServiceBindingProtocolGuid; +extern EFI_GUID gEfiHashProtocolGuid; +extern EFI_GUID gEfiHashAlgorithmSha1Guid; +extern EFI_GUID gEfiHashAlgorithmSha224Guid; +extern EFI_GUID gEfiHashAlgorithmSha256Guid; +extern EFI_GUID gEfiHashAlgorithmSha384Guid; +extern EFI_GUID gEfiHashAlgorithmSha512Guid; +extern EFI_GUID gEfiHashAlgorithmMD5Guid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c new file mode 100644 index 0000000000..d268b43278 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c @@ -0,0 +1,27 @@ +/*++ + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IScsiInitatorName.c + +Abstract: + EFI_ISCSI_INITIATOR_NAME_PROTOCOL as defined in UEFI 2.0. + It rovides the ability to get and set the iSCSI Initiator Name. + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName) + +EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = EFI_ISCSI_INITIATOR_NAME_PROTOCOL_GUID; +EFI_GUID_STRING(&gEfiIScsiInitiatorNameProtocolGuid, "ISCSI Initiator Name Protocol", "UEFI 2.0 ISCSI Initiator Name Protocol"); \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h new file mode 100644 index 0000000000..65ef0f7970 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h @@ -0,0 +1,98 @@ +/*++ + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IScsiInitatorName.h + +Abstract: + EFI_ISCSI_INITIATOR_NAME_PROTOCOL as defined in UEFI 2.0. + It rovides the ability to get and set the iSCSI Initiator Name. + +Revision History + +--*/ + +#ifndef __ISCSI_INITIATOR_NAME_H__ +#define __ISCSI_INITIATOR_NAME_H__ + +#define EFI_ISCSI_INITIATOR_NAME_PROTOCOL_GUID \ +{ \ + 0x59324945, 0xec44, 0x4c0d, {0xb1, 0xcd, 0x9d, 0xb1, 0x39, 0xdf, 0x7, 0xc } \ +} + +typedef struct _EFI_ISCSI_INITIATOR_NAME_PROTOCOL EFI_ISCSI_INITIATOR_NAME_PROTOCOL; + +typedef +EFI_STATUS +(EFIAPI *EFI_ISCSI_INITIATOR_NAME_GET) ( + IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ) +/*++ + + Routine Description: + Retrieves the current set value of iSCSI Initiator Name. + + Arguments: + This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance. + BufferSize - Size of the buffer in bytes pointed to by Buffer / Actual size of the + variable data buffer. + Buffer - Pointer to the buffer for data to be read. + + Returns: + EFI_SUCCESS - Data was successfully retrieved into the provided buffer and the + BufferSize was sufficient to handle the iSCSI initiator name + EFI_BUFFER_TOO_SMALL - BufferSize is too small for the result. + EFI_INVALID_PARAMETER - BufferSize or Buffer is NULL. + EFI_DEVICE_ERROR - The iSCSI initiator name could not be retrieved due to a hardware error. + +--*/ +; + + + +typedef EFI_STATUS +(EFIAPI *EFI_ISCSI_INITIATOR_NAME_SET) ( + IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This, + IN OUT UINTN *BufferSize, + IN VOID *Buffer + ) +/*++ + + Routine Description: + Sets the iSCSI Initiator Name. + + Arguments: + This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance. + BufferSize - Size of the buffer in bytes pointed to by Buffer. + Buffer - Pointer to the buffer for data to be written. + + Returns: + EFI_SUCCESS - Data was successfully stored by the protocol. + EFI_UNSUPPORTED - Platform policies do not allow for data to be written. + EFI_INVALID_PARAMETER - BufferSize or Buffer is NULL, or BufferSize exceeds the maximum allowed limit. + EFI_DEVICE_ERROR - The data could not be stored due to a hardware error. + EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the data. + EFI_PROTOCOL_ERROR - Input iSCSI initiator name does not adhere to RFC 3720 + (and other related protocols) + +--*/ +; + +struct _EFI_ISCSI_INITIATOR_NAME_PROTOCOL { + EFI_ISCSI_INITIATOR_NAME_GET Get; + EFI_ISCSI_INITIATOR_NAME_SET Set; +}; + +extern EFI_GUID gEfiIScsiInitiatorNameProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.c new file mode 100644 index 0000000000..b1e6389c67 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.c @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Ip4.c + +Abstract: + + UEFI IPv4 protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Ip4) + +EFI_GUID gEfiIp4ServiceBindingProtocolGuid + = EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID; + +EFI_GUID gEfiIp4ProtocolGuid = EFI_IP4_PROTOCOL_GUID; + +EFI_GUID_STRING ( + &gEfiIp4ServiceBindingProtocolGuid, + "IP4 Service Binding Protocol", + "IP4 Service Binding Protocol" + ); + +EFI_GUID_STRING ( + &gEfiIp4ProtocolGuid, + "IP4 Protocol", + "IP4 Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h new file mode 100644 index 0000000000..a2daf6fdd7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h @@ -0,0 +1,241 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Ip4.h + +Abstract: + + UEFI IPv4 protocol. + +--*/ + +#ifndef _IP4_H_ +#define _IP4_H_ + +#include EFI_PROTOCOL_DEFINITION (ManagedNetwork) +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) + +// +//GUID definitions +// +#define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \ + {0xc51711e7, 0xb4bf, 0x404a, 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4} + +#define EFI_IP4_PROTOCOL_GUID \ + {0x41d94cd2, 0x35b6, 0x455a, 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd} + +EFI_FORWARD_DECLARATION (EFI_IP4_PROTOCOL); + +typedef struct { + EFI_HANDLE InstanceHandle; + EFI_IPv4_ADDRESS Ip4Address; + EFI_IPv4_ADDRESS SubnetMask; +} EFI_IP4_ADDRESS_PAIR; + +typedef struct { + EFI_HANDLE DriverHandle; + UINT32 AddressCount; + EFI_IP4_ADDRESS_PAIR AddressPairs[1]; +} EFI_IP4_VARIABLE_DATA; + +typedef struct { + UINT8 DefaultProtocol; + BOOLEAN AcceptAnyProtocol; + BOOLEAN AcceptIcmpErrors; + BOOLEAN AcceptBroadcast; + BOOLEAN AcceptPromiscuous; + BOOLEAN UseDefaultAddress; + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; + BOOLEAN RawData; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; +} EFI_IP4_CONFIG_DATA; + + +typedef struct _EFI_IP4_ROUTE_TABLE { + EFI_IPv4_ADDRESS SubnetAddress; + EFI_IPv4_ADDRESS SubnetMask; + EFI_IPv4_ADDRESS GatewayAddress; +} EFI_IP4_ROUTE_TABLE; + +typedef struct _EFI_IP4_ICMP_TYPE { + UINT8 Type; + UINT8 Code; +} EFI_IP4_ICMP_TYPE; + +typedef struct { + BOOLEAN IsStarted; + + EFI_IP4_CONFIG_DATA ConfigData; + BOOLEAN IsConfigured; + + UINT32 GroupCount; + EFI_IPv4_ADDRESS *GroupTable; + + UINT32 RouteCount; + EFI_IP4_ROUTE_TABLE *RouteTable; + + UINT32 IcmpTypeCount; + EFI_IP4_ICMP_TYPE *IcmpTypeList; +} EFI_IP4_MODE_DATA; + +#pragma pack(1) +typedef struct _EFI_IP4_HEADER { + UINT8 HeaderLength:4; + UINT8 Version:4; + UINT8 TypeOfService; + UINT16 TotalLength; + UINT16 Identification; + UINT16 Fragmentation; + UINT8 TimeToLive; + UINT8 Protocol; + UINT16 Checksum; + EFI_IPv4_ADDRESS SourceAddress; + EFI_IPv4_ADDRESS DestinationAddress; +} EFI_IP4_HEADER; +#pragma pack() + +typedef struct _EFI_IP4_FRAGMENT_DATA { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_IP4_FRAGMENT_DATA; + + +typedef struct _EFI_IP4_OVERRIDE_DATA { + EFI_IPv4_ADDRESS SourceAddress; + EFI_IPv4_ADDRESS GatewayAddress; + + UINT8 Protocol; + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; +} EFI_IP4_OVERRIDE_DATA; + +typedef struct _EFI_IP4_TRANSMIT_DATA { + EFI_IPv4_ADDRESS DestinationAddress; + + EFI_IP4_OVERRIDE_DATA *OverrideData; + UINT32 OptionsLength; + VOID *OptionsBuffer; + + UINT32 TotalDataLength; + UINT32 FragmentCount; + EFI_IP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP4_TRANSMIT_DATA; + +typedef struct _EFI_IP4_RECEIVE_DATA { + EFI_TIME TimeStamp; + EFI_EVENT RecycleSignal; + + UINT32 HeaderLength; + EFI_IP4_HEADER *Header; + + UINT32 OptionsLength; + VOID *Options; + + UINT32 DataLength; + UINT32 FragmentCount; + EFI_IP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP4_RECEIVE_DATA; + +typedef struct _EFI_IP4_COMPLETION_TOKEN { + EFI_EVENT Event; + EFI_STATUS Status; + + union { + EFI_IP4_RECEIVE_DATA *RxData; + EFI_IP4_TRANSMIT_DATA *TxData; + } Packet; +} EFI_IP4_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_GET_MODE_DATA) ( + IN EFI_IP4_PROTOCOL *This, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIGURE) ( + IN EFI_IP4_PROTOCOL *This, + IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_GROUPS) ( + IN EFI_IP4_PROTOCOL *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_ROUTES) ( + IN EFI_IP4_PROTOCOL *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_TRANSMIT) ( + IN EFI_IP4_PROTOCOL *This, + IN EFI_IP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_RECEIVE) ( + IN EFI_IP4_PROTOCOL *This, + IN EFI_IP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CANCEL) ( + IN EFI_IP4_PROTOCOL *This, + IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_POLL) ( + IN EFI_IP4_PROTOCOL *This + ); + +typedef struct _EFI_IP4_PROTOCOL { + EFI_IP4_GET_MODE_DATA GetModeData; + EFI_IP4_CONFIGURE Configure; + EFI_IP4_GROUPS Groups; + EFI_IP4_ROUTES Routes; + EFI_IP4_TRANSMIT Transmit; + EFI_IP4_RECEIVE Receive; + EFI_IP4_CANCEL Cancel; + EFI_IP4_POLL Poll; +} EFI_IP4_PROTOCOL; + + +extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid; +extern EFI_GUID gEfiIp4RegistryDataGuid; +extern EFI_GUID gEfiIp4ProtocolGuid; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c new file mode 100644 index 0000000000..453ca6fedf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Ip4Config.c + +Abstract: + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Ip4Config) + +EFI_GUID gEfiIp4ConfigProtocolGuid = EFI_IP4_CONFIG_PROTOCOL_GUID; + +EFI_GUID_STRING ( + &gEfiIp4ConfigProtocolGuid, + "Ip4Config Protocol", + "Ip4Config Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h new file mode 100644 index 0000000000..2b752681f6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h @@ -0,0 +1,73 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Ip4Config.h + +Abstract: + +--*/ + +#ifndef _IP4CONFIG_H_ +#define _IP4CONFIG_H_ + +#include EFI_PROTOCOL_DEFINITION (Ip4) + + +#define EFI_IP4_CONFIG_PROTOCOL_GUID \ + {0x25c98279, 0x3d9c, 0x43f2, 0xa7, 0x0e, 0xe1, 0xea, 0x4e, 0x0d, 0xed, 0x1b} + +EFI_FORWARD_DECLARATION (EFI_IP4_CONFIG_PROTOCOL); + +#define IP4_CONFIG_VARIABLE_ATTRIBUTES (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS ) + +typedef struct { + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT32 RouteTableSize; + EFI_IP4_ROUTE_TABLE RouteTable[1]; +} EFI_IP4_IPCONFIG_DATA; + + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG_START) ( + IN EFI_IP4_CONFIG_PROTOCOL *This, + IN EFI_EVENT DoneEvent, + IN EFI_EVENT ReconfigEvent + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG_STOP) ( + IN EFI_IP4_CONFIG_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG_GET_DATA) ( + IN EFI_IP4_CONFIG_PROTOCOL *This, + IN OUT UINTN *ConfigDataSize, + OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL + ); + + +typedef struct _EFI_IP4_CONFIG_PROTOCOL { + EFI_IP4_CONFIG_START Start; + EFI_IP4_CONFIG_STOP Stop; + EFI_IP4_CONFIG_GET_DATA GetData; +} EFI_IP4_CONFIG_PROTOCOL; + + +extern EFI_GUID gEfiIp4ConfigProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.c new file mode 100644 index 0000000000..33e7c52731 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.c @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadFile.c + +Abstract: + + Load File protocol as defined in the EFI 1.0 specification. + + Load file protocol exists to supports the addition of new boot devices, + and to support booting from devices that do not map well to file system. + Network boot is done via a LoadFile protocol. + + EFI 1.0 can boot from any device that produces a LoadFile protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (LoadFile) + +EFI_GUID gEfiLoadFileProtocolGuid = LOAD_FILE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLoadFileProtocolGuid, "LoadFile Protocol", "EFI 1.0 Load File Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.h new file mode 100644 index 0000000000..fc8aea5b7a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadFile/LoadFile.h @@ -0,0 +1,87 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadFile.h + +Abstract: + + Load File protocol as defined in the EFI 1.0 specification. + + Load file protocol exists to supports the addition of new boot devices, + and to support booting from devices that do not map well to file system. + Network boot is done via a LoadFile protocol. + + EFI 1.0 can boot from any device that produces a LoadFile protocol. + +--*/ + +#ifndef _LOAD_FILE_H_ +#define _LOAD_FILE_H_ + +#define LOAD_FILE_PROTOCOL_GUID \ + { \ + 0x56EC3091, 0x954C, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \ + } + +EFI_FORWARD_DECLARATION (EFI_LOAD_FILE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_LOAD_FILE) ( + IN EFI_LOAD_FILE_PROTOCOL * This, + IN EFI_DEVICE_PATH_PROTOCOL * FilePath, + IN BOOLEAN BootPolicy, + IN OUT UINTN *BufferSize, + IN VOID *Buffer OPTIONAL + ) +/*++ + + Routine Description: + Causes the driver to load a specified file. + + Arguments: + This - Protocol instance pointer. + FilePath - The device specific path of the file to load. + BootPolicy - If TRUE, indicates that the request originates from the + boot manager is attempting to load FilePath as a boot + selection. If FALSE, then FilePath must match as exact file + to be loaded. + BufferSize - On input the size of Buffer in bytes. On output with a return + code of EFI_SUCCESS, the amount of data transferred to + Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL, + the size of Buffer required to retrieve the requested file. + Buffer - The memory buffer to transfer the file to. IF Buffer is NULL, + then no the size of the requested file is returned in + BufferSize. + + Returns: + EFI_SUCCESS - The file was loaded. + EFI_UNSUPPORTED - The device does not support the provided BootPolicy + EFI_INVALID_PARAMETER - FilePath is not a valid device path, or + BufferSize is NULL. + EFI_NO_MEDIA - No medium was present to load the file. + EFI_DEVICE_ERROR - The file was not loaded due to a device error. + EFI_NO_RESPONSE - The remote system did not respond. + EFI_NOT_FOUND - The file was not found + EFI_ABORTED - The file load process was manually cancelled. + +--*/ +; + +typedef struct _EFI_LOAD_FILE_PROTOCOL { + EFI_LOAD_FILE LoadFile; +} EFI_LOAD_FILE_PROTOCOL; + +extern EFI_GUID gEfiLoadFileProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c new file mode 100644 index 0000000000..961bc00e75 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadedImage.c + +Abstract: + + EFI 1.0 Loaded Image Protocol definition. + + Every EFI driver and application is passed an image handle when it is loaded. + This image handle will contain a Loaded Image Protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (LoadedImage) + +EFI_GUID gEfiLoadedImageProtocolGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLoadedImageProtocolGuid, "LoadedImage Protocol", "EFI 1.0 Loaded Image Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h new file mode 100644 index 0000000000..07c62f1d17 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h @@ -0,0 +1,73 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadedImage.h + +Abstract: + + EFI 1.0 Loaded image protocol definition. + + Every EFI driver and application is passed an image handle when it is loaded. + This image handle will contain a Loaded Image Protocol. + +--*/ + +#ifndef _LOADED_IMAGE_H_ +#define _LOADED_IMAGE_H_ + +#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ + { \ + 0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \ + } + +// +// EFI_SYSTEM_TABLE & EFI_IMAGE_UNLOAD are defined in EfiApi.h +// +#define EFI_LOADED_IMAGE_INFORMATION_REVISION 0x1000 + +typedef struct { + UINT32 Revision; + EFI_HANDLE ParentHandle; + EFI_SYSTEM_TABLE *SystemTable; + + // + // Source location of image + // + EFI_HANDLE DeviceHandle; + EFI_DEVICE_PATH_PROTOCOL *FilePath; + VOID *Reserved; + + // + // Images load options + // + UINT32 LoadOptionsSize; + VOID *LoadOptions; + + // + // Location of where image was loaded + // + VOID *ImageBase; + UINT64 ImageSize; + EFI_MEMORY_TYPE ImageCodeType; + EFI_MEMORY_TYPE ImageDataType; + + // + // If the driver image supports a dynamic unload request + // + EFI_IMAGE_UNLOAD Unload; + +} EFI_LOADED_IMAGE_PROTOCOL; + +extern EFI_GUID gEfiLoadedImageProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c new file mode 100644 index 0000000000..93b80f8c9b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ManagedNetwork.c + +Abstract: + + UEFI Managed Network protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (ManagedNetwork) + +EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID; +EFI_GUID gEfiManagedNetworkProtocolGuid = EFI_MANAGED_NETWORK_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiManagedNetworkServiceBindingProtocolGuid, "Managed Network Service Binding Protocol", "Managed Network Service Binding Protocol"); +EFI_GUID_STRING (&gEfiManagedNetworkProtocolGuid, "Managed Network Protocol", "Managed Network Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h new file mode 100644 index 0000000000..274bb10773 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h @@ -0,0 +1,164 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ManagedNetwork.h + +Abstract: + + UEFI Managed Network protocol definition. + +--*/ + +#ifndef _MANAGED_NETWORK_H_ +#define _MANAGED_NETWORK_H_ + +#include EFI_PROTOCOL_DEFINITION (SimpleNetwork) +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) + +#define EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID \ + {0xf36ff770, 0xa7e1, 0x42cf, 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c} + +#define EFI_MANAGED_NETWORK_PROTOCOL_GUID \ + { 0x3b95aa31, 0x3793, 0x434b, 0x86, 0x67, 0xc8, 0x7, 0x8, 0x92, 0xe0, 0x5e } + +EFI_FORWARD_DECLARATION (EFI_MANAGED_NETWORK_PROTOCOL); + +typedef struct { + UINT32 ReceivedQueueTimeoutValue; + UINT32 TransmitQueueTimeoutValue; + UINT16 ProtocolTypeFilter; + BOOLEAN EnableUnicastReceive; + BOOLEAN EnableMulticastReceive; + BOOLEAN EnableBroadcastReceive; + BOOLEAN EnablePromiscuousReceive; + BOOLEAN FlushQueuesOnReset; + BOOLEAN EnableReceiveTimestamps; + BOOLEAN DisableBackgroundPolling; +} EFI_MANAGED_NETWORK_CONFIG_DATA; + +typedef struct { + EFI_TIME Timestamp; + EFI_EVENT RecycleEvent; + UINT32 PacketLength; + UINT32 HeaderLength; + UINT32 AddressLength; + UINT32 DataLength; + BOOLEAN BroadcastFlag; + BOOLEAN MulticastFlag; + BOOLEAN PromiscuousFlag; + UINT16 ProtocolType; + VOID *DestinationAddress; + VOID *SourceAddress; + VOID *MediaHeader; + VOID *PacketData; +} EFI_MANAGED_NETWORK_RECEIVE_DATA; + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_MANAGED_NETWORK_FRAGMENT_DATA; + +typedef struct { + EFI_MAC_ADDRESS *DestinationAddress; + EFI_MAC_ADDRESS *SourceAddress; + UINT16 ProtocolType; + UINT32 DataLength; + UINT16 HeaderLength; + UINT16 FragmentCount; + EFI_MANAGED_NETWORK_FRAGMENT_DATA FragmentTable[1]; +} EFI_MANAGED_NETWORK_TRANSMIT_DATA; + + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + union { + EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData; + EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData; + } Packet; +} EFI_MANAGED_NETWORK_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_GET_MODE_DATA) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_CONFIGURE) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This, + IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This, + IN BOOLEAN Ipv6Flag, + IN EFI_IP_ADDRESS *IpAddress, + OUT EFI_MAC_ADDRESS *MacAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_GROUPS) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This, + IN BOOLEAN JoinFlag, + IN EFI_MAC_ADDRESS *MacAddress OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_TRANSMIT) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This, + IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_RECEIVE) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This, + IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_CANCEL) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This, + IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MANAGED_NETWORK_POLL) ( + IN EFI_MANAGED_NETWORK_PROTOCOL *This + ); + +typedef struct _EFI_MANAGED_NETWORK_PROTOCOL { + EFI_MANAGED_NETWORK_GET_MODE_DATA GetModeData; + EFI_MANAGED_NETWORK_CONFIGURE Configure; + EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC McastIpToMac; + EFI_MANAGED_NETWORK_GROUPS Groups; + EFI_MANAGED_NETWORK_TRANSMIT Transmit; + EFI_MANAGED_NETWORK_RECEIVE Receive; + EFI_MANAGED_NETWORK_CANCEL Cancel; + EFI_MANAGED_NETWORK_POLL Poll; +} EFI_MANAGED_NETWORK_PROTOCOL; + +extern EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid; +extern EFI_GUID gEfiManagedNetworkProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c new file mode 100644 index 0000000000..d4f1dc240a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c @@ -0,0 +1,39 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Mtftp4.c + +Abstract: + + UEFI Multicast Trivial File Transfer Protocol GUID Declaration. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Mtftp4) + +EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID; +EFI_GUID gEfiMtftp4ProtocolGuid = EFI_MTFTP4_PROTOCOL_GUID; + +EFI_GUID_STRING ( + &gEfiMtftp4ServiceBindingProtocolGuid, + "MTFTP4 Service Binding Protocol", + "MTFTP4 Service Binding Protocol" + ); + +EFI_GUID_STRING ( + &gEfiMtftp4ProtocolGuid, + "MTFTP4 Protocol", + "MTFTP4 Protocol" + ); + diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h new file mode 100644 index 0000000000..5c6d29fbc4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h @@ -0,0 +1,308 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Mtftp4.h + +Abstract: + + UEFI Multicast Trivial File Tranfer Protocol Definition + +--*/ + +#ifndef __EFI_MTFTP4_H__ +#define __EFI_MTFTP4_H__ + +#include EFI_PROTOCOL_DEFINITION(ServiceBinding) + +#define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \ + { 0x2FE800BE, 0x8F01, 0x4aa6, 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } + +#define EFI_MTFTP4_PROTOCOL_GUID \ + { 0x78247c57, 0x63db, 0x4708, 0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b } + +EFI_FORWARD_DECLARATION (EFI_MTFTP4_PROTOCOL); +EFI_FORWARD_DECLARATION (EFI_MTFTP4_TOKEN); + +extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid; +extern EFI_GUID gEfiMtftp4ProtocolGuid; + + +// +//MTFTP4 packet opcode definition +// +#define EFI_MTFTP4_OPCODE_RRQ 1 +#define EFI_MTFTP4_OPCODE_WRQ 2 +#define EFI_MTFTP4_OPCODE_DATA 3 +#define EFI_MTFTP4_OPCODE_ACK 4 +#define EFI_MTFTP4_OPCODE_ERROR 5 +#define EFI_MTFTP4_OPCODE_OACK 6 +#define EFI_MTFTP4_OPCODE_DIR 7 +#define EFI_MTFTP4_OPCODE_DATA8 8 +#define EFI_MTFTP4_OPCODE_ACK8 9 + +// +//MTFTP4 error code definition +// +#define EFI_MTFTP4_ERRORCODE_NOT_DEFINED 0 +#define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND 1 +#define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION 2 +#define EFI_MTFTP4_ERRORCODE_DISK_FULL 3 +#define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION 4 +#define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID 5 +#define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS 6 +#define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER 7 +#define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED 8 + + +// +//MTFTP4 pacekt definition +// +#pragma pack(1) + +typedef struct { + UINT16 OpCode; + UINT8 Filename[1]; +} EFI_MTFTP4_REQ_HEADER; + +typedef struct { + UINT16 OpCode; + UINT8 Data[1]; +} EFI_MTFTP4_OACK_HEADER; + +typedef struct { + UINT16 OpCode; + UINT16 Block; + UINT8 Data[1]; +} EFI_MTFTP4_DATA_HEADER; + +typedef struct { + UINT16 OpCode; + UINT16 Block[1]; +} EFI_MTFTP4_ACK_HEADER; + +typedef struct { + UINT16 OpCode; + UINT64 Block; + UINT8 Data[1]; +} EFI_MTFTP4_DATA8_HEADER; + +typedef struct { + UINT16 OpCode; + UINT64 Block[1]; +} EFI_MTFTP4_ACK8_HEADER; + +typedef struct { + UINT16 OpCode; + UINT16 ErrorCode; + UINT8 ErrorMessage[1]; +} EFI_MTFTP4_ERROR_HEADER; + +typedef union { + UINT16 OpCode; + EFI_MTFTP4_REQ_HEADER Rrq; + EFI_MTFTP4_REQ_HEADER Wrq; + EFI_MTFTP4_OACK_HEADER Oack; + EFI_MTFTP4_DATA_HEADER Data; + EFI_MTFTP4_ACK_HEADER Ack; + EFI_MTFTP4_DATA8_HEADER Data8; + EFI_MTFTP4_ACK8_HEADER Ack8; + EFI_MTFTP4_ERROR_HEADER Error; +} EFI_MTFTP4_PACKET; + +#pragma pack() + +// +//MTFTP4 option definition +// +typedef struct { + UINT8 *OptionStr; + UINT8 *ValueStr; +} EFI_MTFTP4_OPTION; + +// +//MTFTP4 config data +// +typedef struct { + BOOLEAN UseDefaultSetting; + EFI_IPv4_ADDRESS StationIp; + EFI_IPv4_ADDRESS SubnetMask; + UINT16 LocalPort; + EFI_IPv4_ADDRESS GatewayIp; + EFI_IPv4_ADDRESS ServerIp; + UINT16 InitialServerPort; + UINT16 TryCount; + UINT16 TimeoutValue; +} EFI_MTFTP4_CONFIG_DATA; + +// +//MTFTP4 Mode data +// +typedef struct { + EFI_MTFTP4_CONFIG_DATA ConfigData; + UINT8 SupportedOptionCount; + UINT8 **SupportedOptoins; + UINT8 UnsupportedOptionCount; + UINT8 **UnsupportedOptoins; +} EFI_MTFTP4_MODE_DATA; + + +// +//MTFTP4 override data +// +typedef struct { + EFI_IPv4_ADDRESS GatewayIp; + EFI_IPv4_ADDRESS ServerIp; + UINT16 ServerPort; + UINT16 TryCount; + UINT16 TimeoutValue; +} EFI_MTFTP4_OVERRIDE_DATA; + + +// +//Packet checking function +// +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_CHECK_PACKET)( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_TOKEN *Token, + IN UINT16 PacketLen, + IN EFI_MTFTP4_PACKET *Paket + ); + +// +//Timeout callback funtion +// +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_TIMEOUT_CALLBACK) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_TOKEN *Token + ); + +// +//Packet needed function +// +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_PACKET_NEEDED) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_TOKEN *Token, + IN OUT UINT16 *Length, + OUT VOID **Buffer + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_GET_MODE_DATA) ( + IN EFI_MTFTP4_PROTOCOL *This, + OUT EFI_MTFTP4_MODE_DATA *ModeData + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_CONFIGURE) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_CONFIG_DATA *MtftpConfigData OPTIONAL + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_GET_INFO) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData OPTIONAL, + IN UINT8 *Filename, + IN UINT8 *ModeStr OPTIONAL, + IN UINT8 OptionCount, + IN EFI_MTFTP4_OPTION *OptionList, + OUT UINT32 *PacketLength, + OUT EFI_MTFTP4_PACKET **Packet OPTIONAL + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_PARSE_OPTIONS) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN UINT32 PacketLen, + IN EFI_MTFTP4_PACKET *Packet, + OUT UINT32 *OptionCount, + OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_READ_FILE) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_TOKEN *Token + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_WRITE_FILE) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_TOKEN *Token + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_READ_DIRECTORY) ( + IN EFI_MTFTP4_PROTOCOL *This, + IN EFI_MTFTP4_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_MTFTP4_POLL) ( + IN EFI_MTFTP4_PROTOCOL *This +); + + +typedef struct _EFI_MTFTP4_PROTOCOL { + EFI_MTFTP4_GET_MODE_DATA GetModeData; + EFI_MTFTP4_CONFIGURE Configure; + EFI_MTFTP4_GET_INFO GetInfo; + EFI_MTFTP4_PARSE_OPTIONS ParseOptions; + EFI_MTFTP4_READ_FILE ReadFile; + EFI_MTFTP4_WRITE_FILE WriteFile; + EFI_MTFTP4_READ_DIRECTORY ReadDirectory; + EFI_MTFTP4_POLL Poll; +} EFI_MTFTP4_PROTOCOL; + +// +//MTFTP4 token data +// +typedef struct _EFI_MTFTP4_TOKEN{ + IN OUT EFI_STATUS Status; + IN EFI_EVENT Event; + IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData; + IN UINT8 *Filename; + IN UINT8 *ModeStr; + IN UINT32 OptionCount; + IN EFI_MTFTP4_OPTION *OptionList; + IN OUT UINT64 BufferSize; + IN OUT VOID *Buffer; + IN VOID *Context; + IN EFI_MTFTP4_CHECK_PACKET CheckPacket; + IN EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback; + IN EFI_MTFTP4_PACKET_NEEDED PacketNeeded; +} EFI_MTFTP4_TOKEN; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.c new file mode 100644 index 0000000000..873d77d840 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciIo.c + +Abstract: + + EFI PCI I/O Protocol + +Revision History + +--*/ + +#include "EfiSpec.h" + +#include EFI_PROTOCOL_DEFINITION (PciIo) + +EFI_GUID gEfiPciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPciIoProtocolGuid, "PCI IO Protocol", "EFI 1.1 PCI IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.h new file mode 100644 index 0000000000..425dc5f170 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciIo/PciIo.h @@ -0,0 +1,275 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciIo.h + +Abstract: + + EFI PCI I/O Protocol + +Revision History + +--*/ + +#ifndef _EFI_PCI_IO_H +#define _EFI_PCI_IO_H + +// +// Global ID for the PCI I/O Protocol +// +#define EFI_PCI_IO_PROTOCOL_GUID \ + { \ + 0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a \ + } + +EFI_FORWARD_DECLARATION (EFI_PCI_IO_PROTOCOL); + +// +// Prototypes for the PCI I/O Protocol +// +typedef enum { + EfiPciIoWidthUint8 = 0, + EfiPciIoWidthUint16, + EfiPciIoWidthUint32, + EfiPciIoWidthUint64, + EfiPciIoWidthFifoUint8, + EfiPciIoWidthFifoUint16, + EfiPciIoWidthFifoUint32, + EfiPciIoWidthFifoUint64, + EfiPciIoWidthFillUint8, + EfiPciIoWidthFillUint16, + EfiPciIoWidthFillUint32, + EfiPciIoWidthFillUint64, + EfiPciIoWidthMaximum +} EFI_PCI_IO_PROTOCOL_WIDTH; + +// +// Complete PCI address generater +// +#define EFI_PCI_IO_PASS_THROUGH_BAR 0xff // Special BAR that passes a memory or I/O cycle through unchanged +#define EFI_PCI_IO_ATTRIBUTE_MASK 0x077f // All the following I/O and Memory cycles +#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 // I/O cycles 0x0000-0x00FF (10 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 // I/O cycles 0x0000-0x03FF (10 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 // I/O cycles 0x3C6, 0x3C8, 0x3C9 (10 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 // MEM cycles 0xA0000-0xBFFFF (24 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 // I/O cycles 0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 // I/O cycles 0x170-0x177, 0x376, 0x377 (10 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 // Map a memory range so write are combined +#define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 // Enable the I/O decode bit in the PCI Config Header +#define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 // Enable the Memory decode bit in the PCI Config Header +#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 // Enable the DMA bit in the PCI Config Header +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 // Map a memory range so all r/w accesses are cached +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 // Disable a memory range +#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 // Clear for an add-in PCI Device +#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 // Clear for a physical PCI Option ROM accessed through ROM BAR +#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 // Clear for PCI controllers that can not genrate a DAC +// +// The following definition is added in EFI1.1 spec update and UEFI2.0 spec. +// +#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 // I/O cycles 0x0100-0x03FF (16 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 // I/O cycles 0x3C6, 0x3C8, 0x3C9 (16 bit decode) +#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode) + +#define EFI_PCI_DEVICE_ENABLE (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER) +#define EFI_VGA_DEVICE_ENABLE (EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_IO) + +// +// ******************************************************* +// EFI_PCI_IO_PROTOCOL_OPERATION +// ******************************************************* +// +typedef enum { + EfiPciIoOperationBusMasterRead, + EfiPciIoOperationBusMasterWrite, + EfiPciIoOperationBusMasterCommonBuffer, + EfiPciIoOperationMaximum +} EFI_PCI_IO_PROTOCOL_OPERATION; + +// +// ******************************************************* +// EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION +// ******************************************************* +// +typedef enum { + EfiPciIoAttributeOperationGet, + EfiPciIoAttributeOperationSet, + EfiPciIoAttributeOperationEnable, + EfiPciIoAttributeOperationDisable, + EfiPciIoAttributeOperationSupported, + EfiPciIoAttributeOperationMaximum +} EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 BarIndex, + IN UINT64 Offset, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 BarIndex, + IN UINT64 Offset, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + EFI_PCI_IO_PROTOCOL_IO_MEM Read; + EFI_PCI_IO_PROTOCOL_IO_MEM Write; +} EFI_PCI_IO_PROTOCOL_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT32 Offset, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + EFI_PCI_IO_PROTOCOL_CONFIG Read; + EFI_PCI_IO_PROTOCOL_CONFIG Write; +} EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 DestBarIndex, + IN UINT64 DestOffset, + IN UINT8 SrcBarIndex, + IN UINT64 SrcOffset, + IN UINTN Count + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_MAP) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN EFI_PCI_IO_PROTOCOL_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS * DeviceAddress, + OUT VOID **Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN VOID *Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + OUT VOID **HostAddress, + IN UINT64 Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN UINTN Pages, + IN VOID *HostAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH) ( + IN EFI_PCI_IO_PROTOCOL * This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION) ( + IN EFI_PCI_IO_PROTOCOL * This, + OUT UINTN *SegmentNumber, + OUT UINTN *BusNumber, + OUT UINTN *DeviceNumber, + OUT UINTN *FunctionNumber + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation, + IN UINT64 Attributes, + OUT UINT64 *Result OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN UINT8 BarIndex, + OUT UINT64 *Supports, OPTIONAL + OUT VOID **Resources OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES) ( + IN EFI_PCI_IO_PROTOCOL * This, + IN UINT64 Attributes, + IN UINT8 BarIndex, + IN OUT UINT64 *Offset, + IN OUT UINT64 *Length + ); + +// +// Interface structure for the PCI I/O Protocol +// +typedef struct _EFI_PCI_IO_PROTOCOL { + EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem; + EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo; + EFI_PCI_IO_PROTOCOL_ACCESS Mem; + EFI_PCI_IO_PROTOCOL_ACCESS Io; + EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci; + EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem; + EFI_PCI_IO_PROTOCOL_MAP Map; + EFI_PCI_IO_PROTOCOL_UNMAP Unmap; + EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; + EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer; + EFI_PCI_IO_PROTOCOL_FLUSH Flush; + EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation; + EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes; + EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes; + EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes; + UINT64 RomSize; + VOID *RomImage; +} EFI_PCI_IO_PROTOCOL; + +extern EFI_GUID gEfiPciIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c new file mode 100644 index 0000000000..7faecbb719 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciRootBridgeIo.c + +Abstract: + + PCI Root Bridge I/O protocol as defined in the EFI 1.1 specification. + + PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O, + and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform + defferent types of bus mastering DMA + +--*/ + +#include "EfiSpec.h" + +#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo) + +EFI_GUID gEfiPciRootBridgeIoProtocolGuid = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPciRootBridgeIoProtocolGuid, "PciRootBridgeIo Protocol", "EFI 1.1 Pci Root Bridge IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h new file mode 100644 index 0000000000..7773c9af0e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h @@ -0,0 +1,220 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciRootBridgeIo.h + +Abstract: + + PCI Root Bridge I/O protocol as defined in the EFI 1.1 specification. + + PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O, + and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform + defferent types of bus mastering DMA + +--*/ + +#ifndef _PCI_ROOT_BRIDGE_IO_H_ +#define _PCI_ROOT_BRIDGE_IO_H_ + +#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \ + { \ + 0x2f707ebb, 0x4a1a, 0x11d4, 0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL); + +typedef enum { + EfiPciWidthUint8, + EfiPciWidthUint16, + EfiPciWidthUint32, + EfiPciWidthUint64, + EfiPciWidthFifoUint8, + EfiPciWidthFifoUint16, + EfiPciWidthFifoUint32, + EfiPciWidthFifoUint64, + EfiPciWidthFillUint8, + EfiPciWidthFillUint16, + EfiPciWidthFillUint32, + EfiPciWidthFillUint64, + EfiPciWidthMaximum +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH; + +typedef enum { + EfiPciOperationBusMasterRead, + EfiPciOperationBusMasterWrite, + EfiPciOperationBusMasterCommonBuffer, + EfiPciOperationBusMasterRead64, + EfiPciOperationBusMasterWrite64, + EfiPciOperationBusMasterCommonBuffer64, + EfiPciOperationMaximum +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION; + +#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 +#define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002 +#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004 +#define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008 +#define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010 +#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 +#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 +#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 +#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800 +#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000 +#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 +// +// The following definition is added in EFI1.1 spec update and UEFI2.0 spec. +// +#define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000 +#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 +#define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000 + +#define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) + +#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER) + +#define EFI_PCI_ADDRESS(bus, dev, func, reg) \ + ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg))) + +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT32 ExtendedRegister; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 DestAddress, + IN UINT64 SrcAddress, + IN UINTN Count + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS * DeviceAddress, + OUT VOID **Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN VOID *Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT VOID **HostAddress, + IN UINT64 Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN UINTN Pages, + IN VOID *HostAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + OUT UINT64 *Supports, + OUT UINT64 *Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN UINT64 Attributes, + IN OUT UINT64 *ResourceBase, + IN OUT UINT64 *ResourceLength + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + OUT VOID **Resources + ); + +typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL { + EFI_HANDLE ParentHandle; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration; + UINT32 SegmentNumber; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL; + +extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c new file mode 100644 index 0000000000..6fc13d8fe2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PlatformDriverOverride.c + +Abstract: + + Platform Driver Override protocol as defined in the EFI 1.1 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride) + +EFI_GUID gEfiPlatformDriverOverrideProtocolGuid = EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiPlatformDriverOverrideProtocolGuid, "Platform Driver Override Protocol", + "EFI 1.1 Platform Driver Override Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h new file mode 100644 index 0000000000..6d19d14d8a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PlatformDriverOverride.h + +Abstract: + + Platform Driver Override protocol as defined in the EFI 1.1 specification. + +--*/ + +#ifndef _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_H_ +#define _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_H_ + +// +// Global ID for the Platform Driver Override Protocol +// +#define EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID \ + { \ + 0x6b30c738, 0xa391, 0x11d4, 0x9a, 0x3b, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL); + +// +// Prototypes for the Platform Driver Override Protocol +// +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER) ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN OUT EFI_HANDLE * DriverImageHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH) ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED) ( + IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL * DriverImagePath, + IN EFI_HANDLE DriverImageHandle + ); + +// +// Interface structure for the Platform Driver Override Protocol +// +typedef struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL { + EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER GetDriver; + EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH GetDriverPath; + EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED DriverLoaded; +} EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL; + +extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c new file mode 100644 index 0000000000..ea74514bfe --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeBaseCode.c + +Abstract: + PxeBaseCode GUID declaration. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (PxeBaseCode) + +EFI_GUID gEfiPxeBaseCodeProtocolGuid = EFI_PXE_BASE_CODE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPxeBaseCodeProtocolGuid, "PXE Base Code Protocol", "EFI PXE Base Code Protocol"); + +/* EOF - PxeBaseCode.c */ diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h new file mode 100644 index 0000000000..7fc959db34 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h @@ -0,0 +1,386 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeBaseCode.h + +Abstract: + EFI PXE Base Code Protocol definitions. + +--*/ +#ifndef _EFIPXEBC_H +#define _EFIPXEBC_H + +#include "Pxe.h" + +// +// PXE Base Code protocol +// +#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \ + { \ + 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_PXE_BASE_CODE_PROTOCOL); + +// +// Default IP TTL and ToS. +// +#define DEFAULT_TTL 16 +#define DEFAULT_ToS 0 + +// +// ICMP error format +// +typedef struct { + UINT8 Type; + UINT8 Code; + UINT16 Checksum; + union { + UINT32 reserved; + UINT32 Mtu; + UINT32 Pointer; + struct { + UINT16 Identifier; + UINT16 Sequence; + } Echo; + } u; + UINT8 Data[494]; +} EFI_PXE_BASE_CODE_ICMP_ERROR; + +// +// TFTP error format +// +typedef struct { + UINT8 ErrorCode; + CHAR8 ErrorString[127]; +} EFI_PXE_BASE_CODE_TFTP_ERROR; + +// +// IP Receive Filter definitions +// +#define EFI_PXE_BASE_CODE_MAX_IPCNT 8 + +typedef struct { + UINT8 Filters; + UINT8 IpCnt; + UINT16 reserved; + EFI_IP_ADDRESS IpList[EFI_PXE_BASE_CODE_MAX_IPCNT]; +} EFI_PXE_BASE_CODE_IP_FILTER; + +#define EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP 0x0001 +#define EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST 0x0002 +#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS 0x0004 +#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST 0x0008 + +// +// ARP Cache definitions +// +typedef struct { + EFI_IP_ADDRESS IpAddr; + EFI_MAC_ADDRESS MacAddr; +} EFI_PXE_BASE_CODE_ARP_ENTRY; + +typedef struct { + EFI_IP_ADDRESS IpAddr; + EFI_IP_ADDRESS SubnetMask; + EFI_IP_ADDRESS GwAddr; +} EFI_PXE_BASE_CODE_ROUTE_ENTRY; + +// +// UDP definitions +// +typedef UINT16 EFI_PXE_BASE_CODE_UDP_PORT; + +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP 0x0001 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT 0x0002 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP 0x0004 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT 0x0008 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER 0x0010 +#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_MAY_FRAGMENT 0x0020 + +// +// Discover() definitions +// +#define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP 0 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_MS_WINNT_RIS 1 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_INTEL_LCM 2 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_DOSUNDI 3 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_NEC_ESMPRO 4 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_WSoD 5 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_LCCM 6 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_CA_UNICENTER_TNG 7 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_HP_OPENVIEW 8 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_9 9 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_10 10 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_11 11 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_NOT_USED_12 12 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_INSTALL 13 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_BOOT 14 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_REMBO 15 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_BEOBOOT 16 +// +// 17 through 32767 are reserved +// 32768 through 65279 are for vendor use +// 65280 through 65534 are reserved +// +#define EFI_PXE_BASE_CODE_BOOT_TYPE_PXETEST 65535 + +#define EFI_PXE_BASE_CODE_BOOT_LAYER_MASK 0x7FFF +#define EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL 0x0000 + +// +// Discover() server list structure. +// +typedef struct { + UINT16 Type; + BOOLEAN AcceptAnyResponse; + UINT8 Reserved; + EFI_IP_ADDRESS IpAddr; +} EFI_PXE_BASE_CODE_SRVLIST; + +// +// Discover() information override structure. +// +typedef struct { + BOOLEAN UseMCast; + BOOLEAN UseBCast; + BOOLEAN UseUCast; + BOOLEAN MustUseList; + EFI_IP_ADDRESS ServerMCastIp; + UINT16 IpCnt; + EFI_PXE_BASE_CODE_SRVLIST SrvList[1]; +} EFI_PXE_BASE_CODE_DISCOVER_INFO; + +// +// Mtftp() definitions +// +typedef enum { + EFI_PXE_BASE_CODE_TFTP_FIRST, + EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE, + EFI_PXE_BASE_CODE_TFTP_READ_FILE, + EFI_PXE_BASE_CODE_TFTP_WRITE_FILE, + EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY, + EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE, + EFI_PXE_BASE_CODE_MTFTP_READ_FILE, + EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY, + EFI_PXE_BASE_CODE_MTFTP_LAST +} EFI_PXE_BASE_CODE_TFTP_OPCODE; + +typedef struct { + EFI_IP_ADDRESS MCastIp; + EFI_PXE_BASE_CODE_UDP_PORT CPort; + EFI_PXE_BASE_CODE_UDP_PORT SPort; + UINT16 ListenTimeout; + UINT16 TransmitTimeout; +} EFI_PXE_BASE_CODE_MTFTP_INFO; + +// +// PXE Base Code Mode structure +// +#define EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8 +#define EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8 + +typedef struct { + BOOLEAN Started; + BOOLEAN Ipv6Available; + BOOLEAN Ipv6Supported; + BOOLEAN UsingIpv6; + BOOLEAN BisSupported; + BOOLEAN BisDetected; + BOOLEAN AutoArp; + BOOLEAN SendGUID; + BOOLEAN DhcpDiscoverValid; + BOOLEAN DhcpAckReceived; + BOOLEAN ProxyOfferReceived; + BOOLEAN PxeDiscoverValid; + BOOLEAN PxeReplyReceived; + BOOLEAN PxeBisReplyReceived; + BOOLEAN IcmpErrorReceived; + BOOLEAN TftpErrorReceived; + BOOLEAN MakeCallbacks; + UINT8 TTL; + UINT8 ToS; + EFI_IP_ADDRESS StationIp; + EFI_IP_ADDRESS SubnetMask; + EFI_PXE_BASE_CODE_PACKET DhcpDiscover; + EFI_PXE_BASE_CODE_PACKET DhcpAck; + EFI_PXE_BASE_CODE_PACKET ProxyOffer; + EFI_PXE_BASE_CODE_PACKET PxeDiscover; + EFI_PXE_BASE_CODE_PACKET PxeReply; + EFI_PXE_BASE_CODE_PACKET PxeBisReply; + EFI_PXE_BASE_CODE_IP_FILTER IpFilter; + UINT32 ArpCacheEntries; + EFI_PXE_BASE_CODE_ARP_ENTRY ArpCache[EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES]; + UINT32 RouteTableEntries; + EFI_PXE_BASE_CODE_ROUTE_ENTRY RouteTable[EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES]; + EFI_PXE_BASE_CODE_ICMP_ERROR IcmpError; + EFI_PXE_BASE_CODE_TFTP_ERROR TftpError; +} EFI_PXE_BASE_CODE_MODE; + +// +// PXE Base Code Interface Function definitions +// +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_START) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN BOOLEAN UseIpv6 + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_STOP) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_DHCP) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN BOOLEAN SortOffers + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_DISCOVER) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN UINT16 Type, + IN UINT16 *Layer, + IN BOOLEAN UseBis, + IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO * Info OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_MTFTP) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation, + IN OUT VOID *BufferPtr OPTIONAL, + IN BOOLEAN Overwrite, + IN OUT UINT64 *BufferSize, + IN UINTN *BlockSize OPTIONAL, + IN EFI_IP_ADDRESS * ServerIp, + IN UINT8 *Filename, + IN EFI_PXE_BASE_CODE_MTFTP_INFO * Info OPTIONAL, + IN BOOLEAN DontUseBuffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_UDP_WRITE) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN UINT16 OpFlags, + IN EFI_IP_ADDRESS * DestIp, + IN EFI_PXE_BASE_CODE_UDP_PORT * DestPort, + IN EFI_IP_ADDRESS * GatewayIp, OPTIONAL + IN EFI_IP_ADDRESS * SrcIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT * SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN UINTN *BufferSize, + IN VOID *BufferPtr + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_UDP_READ) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN UINT16 OpFlags, + IN OUT EFI_IP_ADDRESS * DestIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT * DestPort, OPTIONAL + IN OUT EFI_IP_ADDRESS * SrcIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT * SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN OUT UINTN *BufferSize, + IN VOID *BufferPtr + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_IP_FILTER) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN EFI_PXE_BASE_CODE_IP_FILTER * NewFilter + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_ARP) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN EFI_IP_ADDRESS * IpAddr, + IN EFI_MAC_ADDRESS * MacAddr OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_PARAMETERS) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN BOOLEAN *NewAutoArp, OPTIONAL + IN BOOLEAN *NewSendGUID, OPTIONAL + IN UINT8 *NewTTL, OPTIONAL + IN UINT8 *NewToS, OPTIONAL + IN BOOLEAN *NewMakeCallback OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_STATION_IP) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + IN EFI_IP_ADDRESS * NewStationIp, OPTIONAL + IN EFI_IP_ADDRESS * NewSubnetMask OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_BASE_CODE_SET_PACKETS) ( + IN EFI_PXE_BASE_CODE_PROTOCOL * This, + BOOLEAN *NewDhcpDiscoverValid, OPTIONAL + BOOLEAN *NewDhcpAckReceived, OPTIONAL + BOOLEAN *NewProxyOfferReceived, OPTIONAL + BOOLEAN *NewPxeDiscoverValid, OPTIONAL + BOOLEAN *NewPxeReplyReceived, OPTIONAL + BOOLEAN *NewPxeBisReplyReceived, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET * NewDhcpDiscover, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET * NewDhcpAck, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET * NewProxyOffer, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET * NewPxeDiscover, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET * NewPxeReply, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET * NewPxeBisReply OPTIONAL + ); + +// +// PXE Base Code Protocol structure +// +#define EFI_PXE_BASE_CODE_INTERFACE_REVISION 0x00010000 + +typedef struct _EFI_PXE_BASE_CODE_PROTOCOL { + UINT64 Revision; + EFI_PXE_BASE_CODE_START Start; + EFI_PXE_BASE_CODE_STOP Stop; + EFI_PXE_BASE_CODE_DHCP Dhcp; + EFI_PXE_BASE_CODE_DISCOVER Discover; + EFI_PXE_BASE_CODE_MTFTP Mtftp; + EFI_PXE_BASE_CODE_UDP_WRITE UdpWrite; + EFI_PXE_BASE_CODE_UDP_READ UdpRead; + EFI_PXE_BASE_CODE_SET_IP_FILTER SetIpFilter; + EFI_PXE_BASE_CODE_ARP Arp; + EFI_PXE_BASE_CODE_SET_PARAMETERS SetParameters; + EFI_PXE_BASE_CODE_SET_STATION_IP SetStationIp; + EFI_PXE_BASE_CODE_SET_PACKETS SetPackets; + EFI_PXE_BASE_CODE_MODE *Mode; +} EFI_PXE_BASE_CODE_PROTOCOL; + +extern EFI_GUID gEfiPxeBaseCodeProtocolGuid; + +#endif /* _EFIPXEBC_H */ + +/* EOF - PxeBaseCode.h */ diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c new file mode 100644 index 0000000000..dcb7e26534 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeBaseCodeCallBack.c + +Abstract: + PXE BaseCode Callback GUID declaration. + +--*/ + +#include "EfiSpec.h" + +#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack) + +EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid = EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiPxeBaseCodeCallbackProtocolGuid, "PXE Base Code Callback Protocol", "EFI PXE Base Code Callback Protocol"); + +/* EOF - PxeBaseCodeCallBack.c */ diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h new file mode 100644 index 0000000000..bc9305818d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h @@ -0,0 +1,82 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeBaseCodeCallBack.h + +Abstract: + EFI PXE Base Code CallBack Protocol + +--*/ + +#ifndef _PXE_BASE_CODE_CALLBACK_H_ +#define _PXE_BASE_CODE_CALLBACK_H_ + +#include "Pxe.h" + +// +// Call Back Definitions +// +#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID \ + { \ + 0x245dca21, 0xfb7b, 0x11d3, 0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +// +// Revision Number +// +#define EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION 0x00010000 + +// +// Protocol definition +// +EFI_FORWARD_DECLARATION (EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL); + +typedef enum { + EFI_PXE_BASE_CODE_FUNCTION_FIRST, + EFI_PXE_BASE_CODE_FUNCTION_DHCP, + EFI_PXE_BASE_CODE_FUNCTION_DISCOVER, + EFI_PXE_BASE_CODE_FUNCTION_MTFTP, + EFI_PXE_BASE_CODE_FUNCTION_UDP_WRITE, + EFI_PXE_BASE_CODE_FUNCTION_UDP_READ, + EFI_PXE_BASE_CODE_FUNCTION_ARP, + EFI_PXE_BASE_CODE_FUNCTION_IGMP, + EFI_PXE_BASE_CODE_FUNCTION_TCP_WRITE, + EFI_PXE_BASE_CODE_FUNCTION_TCP_READ, + EFI_PXE_BASE_CODE_PXE_FUNCTION_LAST +} EFI_PXE_BASE_CODE_FUNCTION; + +typedef enum { + EFI_PXE_BASE_CODE_CALLBACK_STATUS_FIRST, + EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT, + EFI_PXE_BASE_CODE_CALLBACK_STATUS_LAST +} EFI_PXE_BASE_CODE_CALLBACK_STATUS; + +typedef EFI_PXE_BASE_CODE_CALLBACK_STATUS (EFIAPI *EFI_PXE_CALLBACK) + ( + IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL * This, + IN EFI_PXE_BASE_CODE_FUNCTION Function, + IN BOOLEAN Received, + IN UINT32 PacketLen, + IN EFI_PXE_BASE_CODE_PACKET * Packet OPTIONAL + ); + +typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL { + UINT64 Revision; + EFI_PXE_CALLBACK Callback; +} EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL; + +extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid; + +#endif /* _EFIPXEBC_H */ + +/* EOF - PxeBaseCodeCallBack.h */ diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c new file mode 100644 index 0000000000..c691a01344 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c @@ -0,0 +1,26 @@ +/*++ + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScsiIo.c + +Abstract: + EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0. + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (ScsiIo) + +EFI_GUID gEfiScsiIoProtocolGuid = EFI_SCSI_IO_PROTOCOL_GUID; +EFI_GUID_STRING(&gEfiScsiIoProtocolGuid, "SCSI IO protoco", "UEFI 2.0 SCSI IO protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h new file mode 100644 index 0000000000..94aa06aa73 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h @@ -0,0 +1,256 @@ +/*++ + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScsiIo.h + +Abstract: + EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0. + +Revision History + +--*/ + +#ifndef __EFI_SCSI_IO_PROTOCOL_H__ +#define __EFI_SCSI_IO_PROTOCOL_H__ + +#define EFI_SCSI_IO_PROTOCOL_GUID \ + { \ + 0x932f47e6, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \ + } + +// +// Forward reference for pure ANSI compatability +// +typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL; + +// +// SCSI Data Direction definition +// +#define EFI_SCSI_IO_DATA_DIRECTION_READ 0 +#define EFI_SCSI_IO_DATA_DIRECTION_WRITE 1 +#define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL 2 + +// +// SCSI Host Adapter Status definition +// +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK 0x00 +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 // timeout when processing the command +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT 0x0b // timeout when waiting for the command processing +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d // a message reject was received when processing command +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET 0x0e // a bus reset was detected +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 // the adapter failed in issuing request sense command +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 // selection timeout +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 // data overrun or data underrun +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE 0x13 // Unexepected bus free +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 // Target bus phase sequence failure +#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER 0x7f + + +// +// SCSI Target Status definition +// +#define EFI_SCSI_IO_STATUS_TARGET_GOOD 0x00 +#define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION 0x02 // check condition +#define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET 0x04 // condition met +#define EFI_SCSI_IO_STATUS_TARGET_BUSY 0x08 // busy +#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE 0x10 // intermediate +#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 // intermediate-condition met +#define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT 0x18 // reservation conflict +#define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED 0x22 // command terminated +#define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL 0x28 // queue full + +typedef struct { + UINT64 Timeout; + VOID *InDataBuffer; + VOID *OutDataBuffer; + VOID *SenseData; + VOID *Cdb; + UINT32 InTransferLength; + UINT32 OutTransferLength; + UINT8 CdbLength; + UINT8 DataDirection; + UINT8 HostAdapterStatus; + UINT8 TargetStatus; + UINT8 SenseDataLength; +} EFI_SCSI_IO_SCSI_REQUEST_PACKET; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE) ( + IN EFI_SCSI_IO_PROTOCOL *This, + OUT UINT8 *DeviceType + ) +/*++ + + Routine Description: + Retrieves the device type information of the SCSI Controller. + + Arguments: + This - Protocol instance pointer. + DeviceType - A pointer to the device type information + retrieved from the SCSI Controller. + + Returns: + EFI_SUCCESS - Retrieves the device type information successfully. + EFI_INVALID_PARAMETER - The DeviceType is NULL. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION) ( + IN EFI_SCSI_IO_PROTOCOL *This, + IN OUT UINT8 **Target, + OUT UINT64 *Lun + ) +/*++ + + Routine Description: + Retrieves the device location in the SCSI channel. + + Arguments: + This - Protocol instance pointer. + Target - A pointer to the Target Array which represents ID of a SCSI device + on the SCSI channel. + Lun - A pointer to the LUN of the SCSI device on + the SCSI channel. + + Returns: + EFI_SUCCESS - Retrieves the device location successfully. + EFI_INVALID_PARAMETER - The Target or Lun is NULL. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS) ( + IN EFI_SCSI_IO_PROTOCOL *This + ) +/*++ + + Routine Description: + Resets the SCSI Bus that the SCSI Controller is attached to. + + Arguments: + This - This Protocol instance pointer. + + Returns: + EFI_SUCCESS - The SCSI bus is reset successfully. + EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus. + EFI_UNSUPPORTED - The bus reset operation is not supported by the + SCSI Host Controller. + EFI_TIMEOUT - A timeout occurred while attempting to reset + the SCSI bus. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE) ( + IN EFI_SCSI_IO_PROTOCOL *This + ) +/*++ + + Routine Description: + Resets the SCSI Controller that the device handle specifies. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - Reset the SCSI controller successfully. + EFI_DEVICE_ERROR - Errors are encountered when resetting the + SCSI Controller. + EFI_UNSUPPORTED - The SCSI bus does not support a device + reset operation. + EFI_TIMEOUT - A timeout occurred while attempting to + reset the SCSI Controller. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND) ( + IN EFI_SCSI_IO_PROTOCOL *This, + IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet, + IN EFI_EVENT Event OPTIONAL + ) +/*++ + + Routine Description: + Sends a SCSI Request Packet to the SCSI Controller for execution. + + Arguments: + This - Protocol instance pointer. + Packet - The SCSI request packet to send to the SCSI + Controller specified by the device handle. + Event - If the SCSI bus where the SCSI device is attached + does not support non-blocking I/O, then Event is + ignored, and blocking I/O is performed. + If Event is NULL, then blocking I/O is performed. + If Event is not NULL and non-blocking I/O is + supported, then non-blocking I/O is performed, + and Event will be signaled when the SCSI Request + Packet completes. + + Returns: + EFI_SUCCESS - The SCSI Request Packet was sent by the host + successfully, and TransferLength bytes were + transferred to/from DataBuffer.See + HostAdapterStatus, TargetStatus, + SenseDataLength, and SenseData in that order + for additional status information. + EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed, + but the entire DataBuffer could not be transferred. + The actual number of bytes transferred is returned + in TransferLength. See HostAdapterStatus, + TargetStatus, SenseDataLength, and SenseData in + that order for additional status information. + EFI_NOT_READY - The SCSI Request Packet could not be sent because + there are too many SCSI Command Packets already + queued.The caller may retry again later. + EFI_DEVICE_ERROR - A device error occurred while attempting to send + the SCSI Request Packet. See HostAdapterStatus, + TargetStatus, SenseDataLength, and SenseData in + that order for additional status information. + EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid. + The SCSI Request Packet was not sent, so no + additional status information is available. + EFI_UNSUPPORTED - The command described by the SCSI Request Packet + is not supported by the SCSI initiator(i.e., SCSI + Host Controller). The SCSI Request Packet was not + sent, so no additional status information is + available. + EFI_TIMEOUT - A timeout occurred while waiting for the SCSI + Request Packet to execute. See HostAdapterStatus, + TargetStatus, SenseDataLength, and SenseData in + that order for additional status information. +--*/ +; + +struct _EFI_SCSI_IO_PROTOCOL { + EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE GetDeviceType; + EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION GetDeviceLocation; + EFI_SCSI_IO_PROTOCOL_RESET_BUS ResetBus; + EFI_SCSI_IO_PROTOCOL_RESET_DEVICE ResetDevice; + EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand; + UINT32 IoAlign; +}; + +extern EFI_GUID gEfiScsiIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c new file mode 100644 index 0000000000..f193015865 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScsiPassThru.c + +Abstract: + + SCSI Pass Through protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (ScsiPassThru) + +EFI_GUID gEfiScsiPassThruProtocolGuid = EFI_SCSI_PASS_THRU_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiScsiPassThruProtocolGuid, "SCSI Pass Through Protocol", "EFI 1.0 SCSI Pass Through protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h new file mode 100644 index 0000000000..88887aef57 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h @@ -0,0 +1,332 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScsiPassThru.h + +Abstract: + + SCSI Pass Through protocol. + +--*/ + +#ifndef __SCSI_PT_H__ +#define __SCSI_PT_H__ + +#define EFI_SCSI_PASS_THRU_PROTOCOL_GUID \ + { \ + 0xa59e8fcf, 0xbda0, 0x43bb, 0x90, 0xb1, 0xd3, 0x73, 0x2e, 0xca, 0xa8, 0x77 \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_SCSI_PASS_THRU_PROTOCOL); + +#define EFI_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001 +#define EFI_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002 +#define EFI_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004 + +// +// SCSI Host Adapter Status definition +// +#define EFI_SCSI_STATUS_HOST_ADAPTER_OK 0x00 +#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 // timeout when processing the command +#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT 0x0b // timeout when waiting for the command processing +#define EFI_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d // a message reject was received when processing command +#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_RESET 0x0e // a bus reset was detected +#define EFI_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f +#define EFI_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 // the adapter failed in issuing request sense command +#define EFI_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 // selection timeout +#define EFI_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 // data overrun or data underrun +#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_FREE 0x13 // Unexepected bus free +#define EFI_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 // Target bus phase sequence failure +#define EFI_SCSI_STATUS_HOST_ADAPTER_OTHER 0x7f + +// +// SCSI Target Status definition +// +#define EFI_SCSI_STATUS_TARGET_GOOD 0x00 +#define EFI_SCSI_STATUS_TARGET_CHECK_CONDITION 0x02 // check condition +#define EFI_SCSI_STATUS_TARGET_CONDITION_MET 0x04 // condition met +#define EFI_SCSI_STATUS_TARGET_BUSY 0x08 // busy +#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE 0x10 // intermediate +#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 // intermediate-condition met +#define EFI_SCSI_STATUS_TARGET_RESERVATION_CONFLICT 0x18 // reservation conflict +#define EFI_SCSI_STATUS_TARGET_COMMOND_TERMINATED 0x22 // command terminated +#define EFI_SCSI_STATUS_TARGET_QUEUE_FULL 0x28 // queue full +typedef struct { + UINT64 Timeout; + VOID *DataBuffer; + VOID *SenseData; + VOID *Cdb; + UINT32 TransferLength; + UINT8 CdbLength; + UINT8 DataDirection; + UINT8 HostAdapterStatus; + UINT8 TargetStatus; + UINT8 SenseDataLength; +} EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET; + +typedef struct { + CHAR16 *ControllerName; + CHAR16 *ChannelName; + UINT32 AdapterId; + UINT32 Attributes; + UINT32 IoAlign; +} EFI_SCSI_PASS_THRU_MODE; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_PASS_THRU_PASSTHRU) ( + IN EFI_SCSI_PASS_THRU_PROTOCOL * This, + IN UINT32 Target, + IN UINT64 Lun, + IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET * Packet, + IN EFI_EVENT Event OPTIONAL + ) +/*++ + + Routine Description: + Sends a SCSI Request Packet to a SCSI device that is attached to + the SCSI channel. This function supports both blocking I/O and + non-blocking I/O. The blocking I/O functionality is required, + and the non-blocking I/O functionality is optional. + + Arguments: + This - Protocol instance pointer. + Target - The Target ID of the SCSI device to + send the SCSI Request Packet. + Lun - The LUN of the SCSI device to send the + SCSI Request Packet. + Packet - A pointer to the SCSI Request Packet to send + to the SCSI device specified by Target and Lun. + Event - If non-blocking I/O is not supported then Event + is ignored, and blocking I/O is performed. + If Event is NULL, then blocking I/O is performed. + If Event is not NULL and non blocking I/O is + supported, then non-blocking I/O is performed, + and Event will be signaled when the SCSI Request + Packet completes + + Returns: + EFI_SUCCESSThe - SCSI Request Packet was sent by the host, and + TransferLength bytes were transferred to/from + DataBuffer.See HostAdapterStatus, TargetStatus, + SenseDataLength,and SenseData in that order + for additional status information. + EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed, but the + entire DataBuffer could not be transferred. + The actual number of bytes transferred is returned + in TransferLength. See HostAdapterStatus, + TargetStatus, SenseDataLength, and SenseData in + that order for additional status information. + EFI_NOT_READY - The SCSI Request Packet could not be sent because + there are too many SCSI Request Packets already + queued. The caller may retry again later. + EFI_DEVICE_ERROR - A device error occurred while attempting to send + the SCSI Request Packet. See HostAdapterStatus, + TargetStatus, SenseDataLength, and SenseData in + that order for additional status information. + EFI_INVALID_PARAMETER - Target, Lun, or the contents of ScsiRequestPacket + are invalid. The SCSI Request Packet was not sent, + so no additional status information is available. + EFI_UNSUPPORTED - The command described by the SCSI Request Packet + is not supported by the host adapter. The SCSI + Request Packet was not sent, so no additional + status information is available. + EFI_TIMEOUT - A timeout occurred while waiting for the SCSI + Request Packet to execute. See HostAdapterStatus, + TargetStatus, SenseDataLength, and SenseData in + that order for additional status information. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE) ( + IN EFI_SCSI_PASS_THRU_PROTOCOL * This, + IN OUT UINT32 *Target, + IN OUT UINT64 *Lun + ) +/*++ + + Routine Description: + Used to retrieve the list of legal Target IDs for SCSI devices + on a SCSI channel. + + Arguments: + This - Protocol instance pointer. + Target - On input, a pointer to the Target ID of a + SCSI device present on the SCSI channel. + On output, a pointer to the Target ID of + the next SCSI device present on a SCSI channel. + An input value of 0xFFFFFFFF retrieves the + Target ID of the first SCSI device present on + a SCSI channel. + Lun - On input, a pointer to the LUN of a SCSI device + present on the SCSI channel.On output, a pointer + to the LUN of the next SCSI device present on a + SCSI channel. + Returns: + EFI_SUCCESS - The Target ID of the next SCSI device on the SCSI + channel was returned in Target and Lun. + EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel. + EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF, and Target and Lun were + not returned on a previous call to GetNextDevice(). +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH) ( + IN EFI_SCSI_PASS_THRU_PROTOCOL * This, + IN UINT32 Target, + IN UINT64 Lun, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath + ) +/*++ + + Routine Description: + Used to allocate and build a device path node for a SCSI device + on a SCSI channel. + + Arguments: + This - Protocol instance pointer. + Target - The Target ID of the SCSI device for which + a device path node is to be allocated and built. + Lun - The LUN of the SCSI device for which a device + path node is to be allocated and built. + DevicePath - A pointer to a single device path node that + describes the SCSI device specified by + Target and Lun. This function is responsible + for allocating the buffer DevicePath with the boot + service AllocatePool(). It is the caller's + responsibility to free DevicePath when the caller + is finished with DevicePath. + Returns: + EFI_SUCCESS - The device path node that describes the SCSI device + specified by Target and Lun was allocated and + returned in DevicePath. + EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does + not exist on the SCSI channel. + EFI_INVALID_PARAMETER - DevicePath is NULL. + EFI_OUT_OF_RESOURCES - There are not enough resources to allocate + DevicePath. +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_PASS_THRU_GET_TARGET_LUN) ( + IN EFI_SCSI_PASS_THRU_PROTOCOL * This, + IN EFI_DEVICE_PATH_PROTOCOL * DevicePath, + OUT UINT32 *Target, + OUT UINT64 *Lun + ) +/*++ + + Routine Description: + Used to translate a device path node to a Target ID and LUN. + + Arguments: + This - Protocol instance pointer. + DevicePath - A pointer to the device path node that + describes a SCSI device on the SCSI channel. + Target - A pointer to the Target ID of a SCSI device + on the SCSI channel. + Lun - A pointer to the LUN of a SCSI device on + the SCSI channel. + Returns: + EFI_SUCCESS - DevicePath was successfully translated to a + Target ID and LUN, and they were returned + in Target and Lun. + EFI_INVALID_PARAMETER - DevicePath is NULL. + EFI_INVALID_PARAMETER - Target is NULL. + EFI_INVALID_PARAMETER - Lun is NULL. + EFI_UNSUPPORTED - This driver does not support the device path + node type in DevicePath. + EFI_NOT_FOUND - A valid translation from DevicePath to a + Target ID and LUN does not exist. +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_PASS_THRU_RESET_CHANNEL) ( + IN EFI_SCSI_PASS_THRU_PROTOCOL * This + ) +/*++ + + Routine Description: + Resets a SCSI channel.This operation resets all the + SCSI devices connected to the SCSI channel. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The SCSI channel was reset. + EFI_UNSUPPORTED - The SCSI channel does not support + a channel reset operation. + EFI_DEVICE_ERROR - A device error occurred while + attempting to reset the SCSI channel. + EFI_TIMEOUT - A timeout occurred while attempting + to reset the SCSI channel. +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SCSI_PASS_THRU_RESET_TARGET) ( + IN EFI_SCSI_PASS_THRU_PROTOCOL * This, + IN UINT32 Target, + IN UINT64 Lun + ) +/*++ + + Routine Description: + Resets a SCSI device that is connected to a SCSI channel. + + Arguments: + This - Protocol instance pointer. + Target - The Target ID of the SCSI device to reset. + Lun - The LUN of the SCSI device to reset. + + Returns: + EFI_SUCCESS - The SCSI device specified by Target and + Lun was reset. + EFI_UNSUPPORTED - The SCSI channel does not support a target + reset operation. + EFI_INVALID_PARAMETER - Target or Lun are invalid. + EFI_DEVICE_ERROR - A device error occurred while attempting + to reset the SCSI device specified by Target + and Lun. + EFI_TIMEOUT - A timeout occurred while attempting to reset + the SCSI device specified by Target and Lun. +--*/ +; + +typedef struct _EFI_SCSI_PASS_THRU_PROTOCOL { + EFI_SCSI_PASS_THRU_MODE *Mode; + EFI_SCSI_PASS_THRU_PASSTHRU PassThru; + EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE GetNextDevice; + EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath; + EFI_SCSI_PASS_THRU_GET_TARGET_LUN GetTargetLun; + EFI_SCSI_PASS_THRU_RESET_CHANNEL ResetChannel; + EFI_SCSI_PASS_THRU_RESET_TARGET ResetTarget; +} EFI_SCSI_PASS_THRU_PROTOCOL; + +extern EFI_GUID gEfiScsiPassThruProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c new file mode 100644 index 0000000000..32007b3bec --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c @@ -0,0 +1,28 @@ +/*++ + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScsiPassThruExt.c + +Abstract: + EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0. + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (ScsiPassThruExt) + +EFI_GUID gEfiExtScsiPassThruProtocolGuid = EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiExtScsiPassThruProtocolGuid, "Extended Scsi Pass Thru", "UEFI 2.0 Extended SCSI Pass Thru protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h new file mode 100644 index 0000000000..5c69f13852 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h @@ -0,0 +1,365 @@ +/*++ + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScsiPassThruExt.h + +Abstract: + EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0. + +Revision History + +--*/ + +#ifndef __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__ +#define __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__ + +#define EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID \ + { \ + 0x143b7632, 0xb81b, 0x4cb7, {0xab, 0xd3, 0xb6, 0x25, 0xa5, 0xb9, 0xbf, 0xfe } \ + } + +typedef struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL EFI_EXT_SCSI_PASS_THRU_PROTOCOL; + +#define TARGET_MAX_BYTES 0x10 + +#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001 +#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002 +#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004 + +// +// DataDirection +// +#define EFI_EXT_SCSI_DATA_DIRECTION_READ 0 +#define EFI_EXT_SCSI_DATA_DIRECTION_WRITE 1 +#define EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL 2 +// +// HostAdapterStatus +// +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK 0x00 +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT 0x0b +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET 0x0e +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE 0x13 +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 +#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER 0x7f +// +// TargetStatus +// +#define EFI_EXT_SCSI_STATUS_TARGET_GOOD 0x00 +#define EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION 0x02 +#define EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET 0x04 +#define EFI_EXT_SCSI_STATUS_TARGET_BUSY 0x08 +#define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE 0x10 +#define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 +#define EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT 0x18 +#define EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL 0x28 +#define EFI_EXT_SCSI_STATUS_TARGET_ACA_ACTIVE 0x30 +#define EFI_EXT_SCSI_STATUS_TARGET_TASK_ABORTED 0x40 + +typedef struct { + UINT32 AdapterId; + UINT32 Attributes; + UINT32 IoAlign; +} EFI_EXT_SCSI_PASS_THRU_MODE; + +typedef struct { + UINT64 Timeout; + VOID *InDataBuffer; + VOID *OutDataBuffer; + VOID *SenseData; + VOID *Cdb; + UINT32 InTransferLength; + UINT32 OutTransferLength; + UINT8 CdbLength; + UINT8 DataDirection; + UINT8 HostAdapterStatus; + UINT8 TargetStatus; + UINT8 SenseDataLength; +} EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET; + +typedef +EFI_STATUS +(EFIAPI *EFI_EXT_SCSI_PASS_THRU_PASSTHRU) ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN UINT8 *Target, + IN UINT64 Lun, + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, + IN EFI_EVENT Event OPTIONAL + ) +/*++ + + Routine Description: + Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function + supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the + nonblocking I/O functionality is optional. + + Arguments: + This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. + Target - The Target is an array of size TARGET_MAX_BYTES and it represents + the id of the SCSI device to send the SCSI Request Packet. Each + transport driver may chose to utilize a subset of this size to suit the needs + of transport target representation. For example, a Fibre Channel driver + may use only 8 bytes (WWN) to represent an FC target. + Lun - The LUN of the SCSI device to send the SCSI Request Packet. + Packet - A pointer to the SCSI Request Packet to send to the SCSI device + specified by Target and Lun. + Event - If nonblocking I/O is not supported then Event is ignored, and blocking + I/O is performed. If Event is NULL, then blocking I/O is performed. If + Event is not NULL and non blocking I/O is supported, then + nonblocking I/O is performed, and Event will be signaled when the + SCSI Request Packet completes. + + Returns: + EFI_SUCCESS - The SCSI Request Packet was sent by the host. For bi-directional + commands, InTransferLength bytes were transferred from + InDataBuffer. For write and bi-directional commands, + OutTransferLength bytes were transferred by + OutDataBuffer. + EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was not executed. The number of bytes that + could be transferred is returned in InTransferLength. For write + and bi-directional commands, OutTransferLength bytes were + transferred by OutDataBuffer. + EFI_NOT_READY - The SCSI Request Packet could not be sent because there are too many + SCSI Request Packets already queued. The caller may retry again later. + EFI_DEVICE_ERROR - A device error occurred while attempting to send the SCSI Request + Packet. + EFI_INVALID_PARAMETER- Target, Lun, or the contents of ScsiRequestPacket are invalid. + EFI_UNSUPPORTED - The command described by the SCSI Request Packet is not supported + by the host adapter. This includes the case of Bi-directional SCSI + commands not supported by the implementation. The SCSI Request + Packet was not sent, so no additional status information is available. + EFI_TIMEOUT - A timeout occurred while waiting for the SCSI Request Packet to execute. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN) ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN OUT UINT8 **Target, + IN OUT UINT64 *Lun + ) +/*++ + Routine Description: + Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These + can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal + Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the + Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI + channel. + + Arguments: + This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance + Target - On input, a pointer to the Target ID (an array of size + TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel. + On output, a pointer to the Target ID (an array of + TARGET_MAX_BYTES) of the next SCSI device present on a SCSI + channel. An input value of 0xF(all bytes in the array are 0xF) in the + Target array retrieves the Target ID of the first SCSI device present on + a SCSI channel. + Lun - On input, a pointer to the LUN of a SCSI device present on the SCSI + channel. On output, a pointer to the LUN of the next SCSI device present + on a SCSI channel. + + Returns: + EFI_SUCCESS - The Target ID and LUN of the next SCSI device on the SCSI + channel was returned in Target and Lun. + EFI_INVALID_PARAMETER - Target array is not all 0xF, and Target and Lun were + not returned on a previous call to GetNextTargetLun(). + EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH) ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN UINT8 *Target, + IN UINT64 Lun, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath + ) +/*++ + + Routine Description: + Used to allocate and build a device path node for a SCSI device on a SCSI channel. + + Arguments: + This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. + Target - The Target is an array of size TARGET_MAX_BYTES and it specifies the + Target ID of the SCSI device for which a device path node is to be + allocated and built. Transport drivers may chose to utilize a subset of + this size to suit the representation of targets. For example, a Fibre + Channel driver may use only 8 bytes (WWN) in the array to represent a + FC target. + Lun - The LUN of the SCSI device for which a device path node is to be + allocated and built. + + DevicePath - A pointer to a single device path node that describes the SCSI device + specified by Target and Lun. This function is responsible for + allocating the buffer DevicePath with the boot service + AllocatePool(). It is the caller's responsibility to free + DevicePath when the caller is finished with DevicePath. + + Returns: + EFI_SUCCESS - The device path node that describes the SCSI device specified by + Target and Lun was allocated and returned in + DevicePath. + EFI_INVALID_PARAMETER - DevicePath is NULL. + EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does not exist + on the SCSI channel. + EFI_OUT_OF_RESOURCES - There are not enough resources to allocate DevicePath. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN) ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, + OUT UINT8 **Target, + OUT UINT64 *Lun + ) +/*++ + + Routine Description: + Used to translate a device path node to a Target ID and LUN. + + Arguments: + This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. + DevicePath - A pointer to a single device path node that describes the SCSI device + on the SCSI channel. + Target - A pointer to the Target Array which represents the ID of a SCSI device + on the SCSI channel. + Lun - A pointer to the LUN of a SCSI device on the SCSI channel. + + Returns: + EFI_SUCCESS - DevicePath was successfully translated to a Target ID and + LUN, and they were returned in Target and Lun. + EFI_INVALID_PARAMETER - DevicePath or Target or Lun is NULL. + EFI_NOT_FOUND - A valid translation from DevicePath to a Target ID and LUN + does not exist. + EFI_UNSUPPORTED - This driver does not support the device path node type in + DevicePath. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL) ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This + ) +/*++ + + Routine Description: + Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel. + + Arguments: + This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. + + Returns: + EFI_SUCCESS - The SCSI channel was reset. + EFI_DEVICE_ERROR - A device error occurred while attempting to reset the SCSI channel. + EFI_TIMEOUT - A timeout occurred while attempting to reset the SCSI channel. + EFI_UNSUPPORTED - The SCSI channel does not support a channel reset operation. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN) ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN UINT8 *Target, + IN UINT64 Lun + ) +/*++ + + Routine Description: + Resets a SCSI logical unit that is connected to a SCSI channel. + + Arguments: + This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. + Target The Target is an array of size TARGET_MAX_BYTE and it represents the + target port ID of the SCSI device containing the SCSI logical unit to + reset. Transport drivers may chose to utilize a subset of this array to suit + the representation of their targets. + Lun The LUN of the SCSI device to reset. + + Returns: + EFI_SUCCESS - The SCSI device specified by Target and Lun was reset. + EFI_INVALID_PARAMETER - Target or Lun is NULL. + EFI_TIMEOUT - A timeout occurred while attempting to reset the SCSI device + specified by Target and Lun. + EFI_UNSUPPORTED - The SCSI channel does not support a target reset operation. + EFI_DEVICE_ERROR - A device error occurred while attempting to reset the SCSI device + specified by Target and Lun. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET) ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN OUT UINT8 **Target + ) +/*++ + + Routine Description: + Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either + be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs + for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to + see if a SCSI device is actually present at that location on the SCSI channel. + + Arguments: + This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. + Target - (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel. + On output, a pointer to the Target ID (an array of + TARGET_MAX_BYTES) of the next SCSI device present on a SCSI + channel. An input value of 0xF(all bytes in the array are 0xF) in the + Target array retrieves the Target ID of the first SCSI device present on a + SCSI channel. + + Returns: + EFI_SUCCESS - The Target ID of the next SCSI device on the SCSI + channel was returned in Target. + EFI_INVALID_PARAMETER - Target or Lun is NULL. + EFI_TIMEOUT - Target array is not all 0xF, and Target were not + returned on a previous call to GetNextTarget(). + EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel. + +--*/ +; + +struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL { + EFI_EXT_SCSI_PASS_THRU_MODE *Mode; + EFI_EXT_SCSI_PASS_THRU_PASSTHRU PassThru; + EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN GetNextTargetLun; + EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath; + EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN GetTargetLun; + EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL ResetChannel; + EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN ResetTargetLun; + EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET GetNextTarget; +}; + +extern EFI_GUID gEfiExtScsiPassThruProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.c new file mode 100644 index 0000000000..c77072a601 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SerialIo.c + +Abstract: + + Serial IO protocol as defined in the EFI 1.0 specification. + + Abstraction of a basic serial device. Targeted at 16550 UART, but + could be much more generic. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (SerialIo) + +EFI_GUID gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSerialIoProtocolGuid, "SerialIo Protocol", "EFI 1.0 Serial IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.h new file mode 100644 index 0000000000..54a653ad53 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SerialIO/SerialIo.h @@ -0,0 +1,296 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SerialIo.h + +Abstract: + + Serial IO protocol as defined in the EFI 1.0 specification. + + Abstraction of a basic serial device. Targeted at 16550 UART, but + could be much more generic. + +--*/ + +#ifndef _SERIAL_IO_H_ +#define _SERIAL_IO_H_ + +#define EFI_SERIAL_IO_PROTOCOL_GUID \ + { \ + 0xBB25CF6F, 0xF1D4, 0x11D2, 0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD \ + } + +EFI_FORWARD_DECLARATION (EFI_SERIAL_IO_PROTOCOL); + +// +// Serial IO Data structures +// +typedef enum { + DefaultParity, + NoParity, + EvenParity, + OddParity, + MarkParity, + SpaceParity +} EFI_PARITY_TYPE; + +typedef enum { + DefaultStopBits, + OneStopBit, + OneFiveStopBits, + TwoStopBits +} EFI_STOP_BITS_TYPE; + +// +// define for Control bits, grouped by read only, write only, and read write +// +// +// Read Only +// +#define EFI_SERIAL_CLEAR_TO_SEND 0x00000010 +#define EFI_SERIAL_DATA_SET_READY 0x00000020 +#define EFI_SERIAL_RING_INDICATE 0x00000040 +#define EFI_SERIAL_CARRIER_DETECT 0x00000080 +#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100 +#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200 + +// +// Write Only +// +#define EFI_SERIAL_REQUEST_TO_SEND 0x00000002 +#define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001 + +// +// Read Write +// +#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000 +#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000 +#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000 + +// +// Serial IO Member Functions +// +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_RESET) ( + IN EFI_SERIAL_IO_PROTOCOL * This + ) +/*++ + + Routine Description: + Reset the serial device. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The device was reset. + EFI_DEVICE_ERROR - The serial device could not be reset. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) ( + IN EFI_SERIAL_IO_PROTOCOL * This, + IN UINT64 BaudRate, + IN UINT32 ReceiveFifoDepth, + IN UINT32 Timeout, + IN EFI_PARITY_TYPE Parity, + IN UINT8 DataBits, + IN EFI_STOP_BITS_TYPE StopBits + ) +/*++ + + Routine Description: + Sets the baud rate, receive FIFO depth, transmit/receice time out, parity, + data buts, and stop bits on a serial device. + + Arguments: + This - Protocol instance pointer. + BaudRate - The requested baud rate. A BaudRate value of 0 will use the the + device's default interface speed. + ReveiveFifoDepth - The requested depth of the FIFO on the receive side of the + serial interface. A ReceiveFifoDepth value of 0 will use + the device's dfault FIFO depth. + Timeout - The requested time out for a single character in microseconds. + This timeout applies to both the transmit and receive side of the + interface. A Timeout value of 0 will use the device's default time + out value. + Parity - The type of parity to use on this serial device. A Parity value of + DefaultParity will use the device's default parity value. + DataBits - The number of data bits to use on the serial device. A DataBits + vaule of 0 will use the device's default data bit setting. + StopBits - The number of stop bits to use on this serial device. A StopBits + value of DefaultStopBits will use the device's default number of + stop bits. + + Returns: + EFI_SUCCESS - The device was reset. + EFI_DEVICE_ERROR - The serial device could not be reset. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) ( + IN EFI_SERIAL_IO_PROTOCOL * This, + IN UINT32 Control + ) +/*++ + + Routine Description: + Set the control bits on a serial device + + Arguments: + This - Protocol instance pointer. + Control - Set the bits of Control that are settable. + + Returns: + EFI_SUCCESS - The new control bits were set on the serial device. + EFI_UNSUPPORTED - The serial device does not support this operation. + EFI_DEVICE_ERROR - The serial device is not functioning correctly. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) ( + IN EFI_SERIAL_IO_PROTOCOL * This, + OUT UINT32 *Control + ) +/*++ + + Routine Description: + Retrieves the status of thecontrol bits on a serial device + + Arguments: + This - Protocol instance pointer. + Control - A pointer to return the current Control signals from the serial + device. + + Returns: + EFI_SUCCESS - The control bits were read from the serial device. + EFI_DEVICE_ERROR - The serial device is not functioning correctly. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_WRITE) ( + IN EFI_SERIAL_IO_PROTOCOL * This, + IN OUT UINTN *BufferSize, + IN VOID *Buffer + ) +/*++ + + Routine Description: + Writes data to a serial device. + + Arguments: + This - Protocol instance pointer. + BufferSize - On input, the size of the Buffer. On output, the amount of + data actually written. + Buffer - The buffer of data to write + + Returns: + EFI_SUCCESS - The data was written. + EFI_DEVICE_ERROR - The device reported an error. + EFI_TIMEOUT - The data write was stopped due to a timeout. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SERIAL_READ) ( + IN EFI_SERIAL_IO_PROTOCOL * This, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ) +/*++ + + Routine Description: + Writes data to a serial device. + + Arguments: + This - Protocol instance pointer. + BufferSize - On input, the size of the Buffer. On output, the amount of + data returned in Buffer. + Buffer - The buffer to return the data into. + + Returns: + EFI_SUCCESS - The data was read. + EFI_DEVICE_ERROR - The device reported an error. + EFI_TIMEOUT - The data write was stopped due to a timeout. + +--*/ +; + +/*++ + + The data values in SERIAL_IO_MODE are read-only and are updated by the code + that produces the SERIAL_IO_PROTOCOL member functions. + + ControlMask - A mask fo the Control bits that the device supports. The device + must always support the Input Buffer Empty control bit. + TimeOut - If applicable, the number of microseconds to wait before timing out + a Read or Write operation. + BaudRate - If applicable, the current baud rate setting of the device; otherwise, + baud rate has the value of zero to indicate that device runs at the + device's designed speed. + ReceiveFifoDepth - The number of characters the device will buffer on input + DataBits - The number of characters the device will buffer on input + Parity - If applicable, this is the EFI_PARITY_TYPE that is computed or + checked as each character is transmitted or reveived. If the device + does not support parity the value is the default parity value. + StopBits - If applicable, the EFI_STOP_BITS_TYPE number of stop bits per + character. If the device does not support stop bits the value is + the default stop bit values. + +--*/ +typedef struct { + UINT32 ControlMask; + + // + // current Attributes + // + UINT32 Timeout; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + UINT32 DataBits; + UINT32 Parity; + UINT32 StopBits; +} EFI_SERIAL_IO_MODE; + +#define SERIAL_IO_INTERFACE_REVISION 0x00010000 + +typedef struct _EFI_SERIAL_IO_PROTOCOL { + UINT32 Revision; + EFI_SERIAL_RESET Reset; + EFI_SERIAL_SET_ATTRIBUTES SetAttributes; + EFI_SERIAL_SET_CONTROL_BITS SetControl; + EFI_SERIAL_GET_CONTROL_BITS GetControl; + EFI_SERIAL_WRITE Write; + EFI_SERIAL_READ Read; + + EFI_SERIAL_IO_MODE *Mode; +} EFI_SERIAL_IO_PROTOCOL; + +extern EFI_GUID gEfiSerialIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h new file mode 100644 index 0000000000..7751c838ca --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ServiceBinding.h + +Abstract: + + UEFI Service Binding protocol definition. + +--*/ + +#ifndef _EFI_SERVICE_BINDING_H_ +#define _EFI_SERVICE_BINDING_H_ + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_SERVICE_BINDING_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_SERVICE_BINDING_CREATE_CHILD) ( + IN EFI_SERVICE_BINDING_PROTOCOL *This, + IN OUT EFI_HANDLE *ChildHandle + ) +/*++ + + Routine Description: + Creates a child handle with a set of I/O services. + + Arguments: + This - Protocol instance pointer. + ChildHandle - Pointer to the handle of the child to create. If it is NULL, + then a new handle is created. If it is not NULL, then the + I/O services are added to the existing child handle. + + Returns: + EFI_SUCCES - The child handle was created with the I/O services. + EFI_OUT_OF_RESOURCES - There are not enough resources availabe to create + the child. + other - The child handle was not created. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SERVICE_BINDING_DESTROY_CHILD) ( + IN struct _EFI_SERVICE_BINDING_PROTOCOL *This, + IN EFI_HANDLE ChildHandle + ) +/*++ + + Routine Description: + Destroys a child handle with a set of I/O services. + + Arguments: + This - Protocol instance pointer. + ChildHandle - Handle of the child to destroy. + + Returns: + EFI_SUCCES - The I/O services were removed from the child handle. + EFI_UNSUPPORTED - The child handle does not support the I/O services + that are being removed. + EFI_INVALID_PARAMETER - Child handle is not a valid EFI Handle. + EFI_ACCESS_DENIED - The child handle could not be destroyed because its + I/O services are being used. + other - The child handle was not destroyed. + +--*/ +; + +typedef struct _EFI_SERVICE_BINDING_PROTOCOL { + EFI_SERVICE_BINDING_CREATE_CHILD CreateChild; + EFI_SERVICE_BINDING_DESTROY_CHILD DestroyChild; +} EFI_SERVICE_BINDING_PROTOCOL; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c new file mode 100644 index 0000000000..20d5a2e41f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleFileSystem.c + +Abstract: + + SimpleFileSystem protocol as defined in the EFI 1.0 specification. + + The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) + file system specified in EFI 1.0. It can also be used to abstract any + file system other than FAT. + + EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (SimpleFileSystem) + +EFI_GUID gEfiSimpleFileSystemProtocolGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSimpleFileSystemProtocolGuid, "Filesystem Protocol", "EFI 1.0 Simple FileSystem Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h new file mode 100644 index 0000000000..da66ba5f7d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h @@ -0,0 +1,376 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleFileSystem.h + +Abstract: + + SimpleFileSystem protocol as defined in the EFI 1.0 specification. + + The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32) + file system specified in EFI 1.0. It can also be used to abstract a file + system other than FAT. + + EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem + +--*/ + +#ifndef _SIMPLE_FILE_SYSTEM_H_ +#define _SIMPLE_FILE_SYSTEM_H_ + +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ + { \ + 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +EFI_FORWARD_DECLARATION (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL); +EFI_FORWARD_DECLARATION (EFI_FILE); + +typedef +EFI_STATUS +(EFIAPI *EFI_VOLUME_OPEN) ( + IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * This, + OUT EFI_FILE **Root + ) +/*++ + + Routine Description: + Open the root directory on a volume. + + Arguments: + This - Protocol instance pointer. + Root - Returns an Open file handle for the root directory + + Returns: + EFI_SUCCESS - The device was opened. + EFI_UNSUPPORTED - This volume does not suppor the file system. + EFI_NO_MEDIA - The device has no media. + EFI_DEVICE_ERROR - The device reported an error. + EFI_VOLUME_CORRUPTED - The file system structures are corrupted + EFI_ACCESS_DENIED - The service denied access to the file + EFI_OUT_OF_RESOURCES - The volume was not opened due to lack of resources + +--*/ +; + +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000 + +typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL { + UINT64 Revision; + EFI_VOLUME_OPEN OpenVolume; +} EFI_SIMPLE_FILE_SYSTEM_PROTOCOL; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_OPEN) ( + IN EFI_FILE * File, + OUT EFI_FILE **NewHandle, + IN CHAR16 *FileName, + IN UINT64 OpenMode, + IN UINT64 Attributes + ) +/*++ + + Routine Description: + Open the root directory on a volume. + + Arguments: + File - Protocol instance pointer. + NewHandle - Returns File Handle for FileName + FileName - Null terminated string. "\", ".", and ".." are supported + OpenMode - Open mode for file. + Attributes - Only used for EFI_FILE_MODE_CREATE + + Returns: + EFI_SUCCESS - The device was opened. + EFI_NOT_FOUND - The specified file could not be found on the device + EFI_NO_MEDIA - The device has no media. + EFI_MEDIA_CHANGED - The media has changed + EFI_DEVICE_ERROR - The device reported an error. + EFI_VOLUME_CORRUPTED - The file system structures are corrupted + EFI_ACCESS_DENIED - The service denied access to the file + EFI_OUT_OF_RESOURCES - The volume was not opened due to lack of resources + EFI_VOLUME_FULL - The volume is full. + +--*/ +; + +// +// Open modes +// +#define EFI_FILE_MODE_READ 0x0000000000000001 +#define EFI_FILE_MODE_WRITE 0x0000000000000002 +#define EFI_FILE_MODE_CREATE 0x8000000000000000 + +// +// File attributes +// +#define EFI_FILE_READ_ONLY 0x0000000000000001 +#define EFI_FILE_HIDDEN 0x0000000000000002 +#define EFI_FILE_SYSTEM 0x0000000000000004 +#define EFI_FILE_RESERVED 0x0000000000000008 +#define EFI_FILE_DIRECTORY 0x0000000000000010 +#define EFI_FILE_ARCHIVE 0x0000000000000020 +#define EFI_FILE_VALID_ATTR 0x0000000000000037 + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_CLOSE) ( + IN EFI_FILE * File + ) +/*++ + + Routine Description: + Close the file handle + + Arguments: + File - Protocol instance pointer. + + Returns: + EFI_SUCCESS- The device was opened. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_DELETE) ( + IN EFI_FILE * File + ) +/*++ + + Routine Description: + Close and delete the file handle + + Arguments: + File - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The device was opened. + EFI_WARN_DELETE_FAILURE - The handle was closed but the file was not + deleted + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_READ) ( + IN EFI_FILE * File, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ) +/*++ + + Routine Description: + Read data from the file. + + Arguments: + File - Protocol instance pointer. + BufferSize - On input size of buffer, on output amount of data in + buffer. + Buffer - The buffer in which data is read. + + Returns: + EFI_SUCCESS - Data was read. + EFI_NO_MEDIA - The device has no media + EFI_DEVICE_ERROR - The device reported an error + EFI_VOLUME_CORRUPTED - The file system structures are corrupted + EFI_BUFFER_TO_SMALL - BufferSize is too small. BufferSize contains + required size + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_WRITE) ( + IN EFI_FILE * File, + IN OUT UINTN *BufferSize, + IN VOID *Buffer + ) +/*++ + + Routine Description: + Write data from to the file. + + Arguments: + File - Protocol instance pointer. + BufferSize - On input size of buffer, on output amount of data in buffer. + Buffer - The buffer in which data to write. + + Returns: + EFI_SUCCESS - Data was written. + EFI_UNSUPPORT - Writes to Open directory are not supported + EFI_NO_MEDIA - The device has no media + EFI_DEVICE_ERROR - The device reported an error + EFI_VOLUME_CORRUPTED - The file system structures are corrupted + EFI_WRITE_PROTECTED - The device is write protected + EFI_ACCESS_DENIED - The file was open for read only + EFI_VOLUME_FULL - The volume is full + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_SET_POSITION) ( + IN EFI_FILE * File, + IN UINT64 Position + ) +/*++ + + Routine Description: + Set a files current position + + Arguments: + File - Protocol instance pointer. + Position - Byte possition from the start of the file + + Returns: + EFI_SUCCESS - Data was written. + EFI_UNSUPPORTED - Seek request for non-zero is not valid on open. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_GET_POSITION) ( + IN EFI_FILE * File, + OUT UINT64 *Position + ) +/*++ + + Routine Description: + Get a files current position + + Arguments: + File - Protocol instance pointer. + Position - Byte possition from the start of the file + + Returns: + EFI_SUCCESS - Data was written. + EFI_UNSUPPORTED - Seek request for non-zero is not valid on open. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_GET_INFO) ( + IN EFI_FILE * File, + IN EFI_GUID * InformationType, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ) +/*++ + + Routine Description: + Get information about a file + + Arguments: + File - Protocol instance pointer. + InformationType - Type of info to return in Buffer + BufferSize - On input size of buffer, on output amount of data in + buffer. + Buffer - The buffer to return data. + + Returns: + EFI_SUCCESS - Data was returned. + EFI_UNSUPPORT - InformationType is not supported + EFI_NO_MEDIA - The device has no media + EFI_DEVICE_ERROR - The device reported an error + EFI_VOLUME_CORRUPTED - The file system structures are corrupted + EFI_WRITE_PROTECTED - The device is write protected + EFI_ACCESS_DENIED - The file was open for read only + EFI_BUFFER_TOO_SMALL - Buffer was too small, required size returned in + BufferSize +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_SET_INFO) ( + IN EFI_FILE * File, + IN EFI_GUID * InformationType, + IN UINTN BufferSize, + IN VOID *Buffer + ) +/*++ + + Routine Description: + Set information about a file + + Arguments: + File - Protocol instance pointer. + InformationType - Type of info in Buffer + BufferSize - Size of buffer. + Buffer - The data to write. + + Returns: + EFI_SUCCESS - Data was returned. + EFI_UNSUPPORT - InformationType is not supported + EFI_NO_MEDIA - The device has no media + EFI_DEVICE_ERROR - The device reported an error + EFI_VOLUME_CORRUPTED - The file system structures are corrupted + EFI_WRITE_PROTECTED - The device is write protected + EFI_ACCESS_DENIED - The file was open for read only +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_FLUSH) ( + IN EFI_FILE * File + ) +/*++ + + Routine Description: + Flush data back for the file handle + + Arguments: + File - Protocol instance pointer. + + Returns: + EFI_SUCCESS - Data was written. + EFI_UNSUPPORT - Writes to Open directory are not supported + EFI_NO_MEDIA - The device has no media + EFI_DEVICE_ERROR - The device reported an error + EFI_VOLUME_CORRUPTED - The file system structures are corrupted + EFI_WRITE_PROTECTED - The device is write protected + EFI_ACCESS_DENIED - The file was open for read only + EFI_VOLUME_FULL - The volume is full + +--*/ +; + +#define EFI_FILE_HANDLE_REVISION 0x00010000 +typedef struct _EFI_FILE { + UINT64 Revision; + EFI_FILE_OPEN Open; + EFI_FILE_CLOSE Close; + EFI_FILE_DELETE Delete; + EFI_FILE_READ Read; + EFI_FILE_WRITE Write; + EFI_FILE_GET_POSITION GetPosition; + EFI_FILE_SET_POSITION SetPosition; + EFI_FILE_GET_INFO GetInfo; + EFI_FILE_SET_INFO SetInfo; + EFI_FILE_FLUSH Flush; +} +EFI_FILE, *EFI_FILE_HANDLE; + +extern EFI_GUID gEfiSimpleFileSystemProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c new file mode 100644 index 0000000000..3ea2429691 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleNetwork.c + +Abstract: + + Simple Network protocol as defined in the EFI 1.0 specification. + + Basic network device abstraction. + + Rx - Received + Tx - Transmit + MCast - MultiCast + ... + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (SimpleNetwork) + +EFI_GUID gEfiSimpleNetworkProtocolGuid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSimpleNetworkProtocolGuid, "Simple Network Protocol", "EFI 1.0 Simple Network Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h new file mode 100644 index 0000000000..8c79745f4c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h @@ -0,0 +1,639 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleNetwork.h + +Abstract: + + Simple Network protocol as defined in the EFI 1.0 specification. + + Basic network device abstraction. + + Rx - Received + Tx - Transmit + MCast - MultiCast + ... + +--*/ + +#ifndef _SIMPLE_NETWORK_H_ +#define _SIMPLE_NETWORK_H_ + +#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ + { \ + 0xA19832B9, 0xAC25, 0x11D3, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \ + } + +EFI_FORWARD_DECLARATION (EFI_SIMPLE_NETWORK_PROTOCOL); + +// +// Simple Network Protocol data structures +// +typedef struct { + // + // Total number of frames received. Includes frames with errors and + // dropped frames. + // + UINT64 RxTotalFrames; + + // + // Number of valid frames received and copied into receive buffers. + // + UINT64 RxGoodFrames; + + // + // Number of frames below the minimum length for the media. + // This would be <64 for ethernet. + // + UINT64 RxUndersizeFrames; + + // + // Number of frames longer than the maxminum length for the + // media. This would be >1500 for ethernet. + // + UINT64 RxOversizeFrames; + + // + // Valid frames that were dropped because receive buffers were full. + // + UINT64 RxDroppedFrames; + + // + // Number of valid unicast frames received and not dropped. + // + UINT64 RxUnicastFrames; + + // + // Number of valid broadcast frames received and not dropped. + // + UINT64 RxBroadcastFrames; + + // + // Number of valid mutlicast frames received and not dropped. + // + UINT64 RxMulticastFrames; + + // + // Number of frames w/ CRC or alignment errors. + // + UINT64 RxCrcErrorFrames; + + // + // Total number of bytes received. Includes frames with errors + // and dropped frames. + // + UINT64 RxTotalBytes; + + // + // Transmit statistics. + // + UINT64 TxTotalFrames; + UINT64 TxGoodFrames; + UINT64 TxUndersizeFrames; + UINT64 TxOversizeFrames; + UINT64 TxDroppedFrames; + UINT64 TxUnicastFrames; + UINT64 TxBroadcastFrames; + UINT64 TxMulticastFrames; + UINT64 TxCrcErrorFrames; + UINT64 TxTotalBytes; + + // + // Number of collisions detection on this subnet. + // + UINT64 Collisions; + + // + // Number of frames destined for unsupported protocol. + // + UINT64 UnsupportedProtocol; + +} EFI_NETWORK_STATISTICS; + +typedef enum { + EfiSimpleNetworkStopped, + EfiSimpleNetworkStarted, + EfiSimpleNetworkInitialized, + EfiSimpleNetworkMaxState +} EFI_SIMPLE_NETWORK_STATE; + +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01 +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02 +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 + +#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01 +#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02 +#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04 +#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08 + +#define MAX_MCAST_FILTER_CNT 16 +typedef struct { + UINT32 State; + UINT32 HwAddressSize; + UINT32 MediaHeaderSize; + UINT32 MaxPacketSize; + UINT32 NvRamSize; + UINT32 NvRamAccessSize; + UINT32 ReceiveFilterMask; + UINT32 ReceiveFilterSetting; + UINT32 MaxMCastFilterCount; + UINT32 MCastFilterCount; + EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT]; + EFI_MAC_ADDRESS CurrentAddress; + EFI_MAC_ADDRESS BroadcastAddress; + EFI_MAC_ADDRESS PermanentAddress; + UINT8 IfType; + BOOLEAN MacAddressChangeable; + BOOLEAN MultipleTxSupported; + BOOLEAN MediaPresentSupported; + BOOLEAN MediaPresent; +} EFI_SIMPLE_NETWORK_MODE; + +// +// Protocol Member Functions +// +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_START) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This + ) +/*++ + + Routine Description: + Changes the state of a network interface from "stopped" to "started". + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The network interface was started. + EFI_ALREADY_STARTED - The network interface is already in the started state. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_STOP) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This + ) +/*++ + + Routine Description: + Changes the state of a network interface from "started" to "stopped". + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The network interface was stopped. + EFI_ALREADY_STARTED - The network interface is already in the stopped state. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN UINTN ExtraRxBufferSize OPTIONAL, + IN UINTN ExtraTxBufferSize OPTIONAL + ) +/*++ + + Routine Description: + Resets a network adapter and allocates the transmit and receive buffers + required by the network interface; optionally, also requests allocation + of additional transmit and receive buffers. + + Arguments: + This - Protocol instance pointer. + ExtraRxBufferSize - The size, in bytes, of the extra receive buffer space + that the driver should allocate for the network interface. + Some network interfaces will not be able to use the extra + buffer, and the caller will not know if it is actually + being used. + ExtraTxBufferSize - The size, in bytes, of the extra transmit buffer space + that the driver should allocate for the network interface. + Some network interfaces will not be able to use the extra + buffer, and the caller will not know if it is actually + being used. + + Returns: + EFI_SUCCESS - The network interface was initialized. + EFI_NOT_STARTED - The network interface has not been started + EFI_OUT_OF_RESOURCES - There was not enough memory for the transmit and + receive buffers. . + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_RESET) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN BOOLEAN ExtendedVerification + ) +/*++ + + Routine Description: + Resets a network adapter and re-initializes it with the parameters that were + provided in the previous call to Initialize(). + + Arguments: + This - Protocol instance pointer. + ExtendedVerification - Indicates that the driver may perform a more + exhaustive verification operation of the device + during reset. + + + Returns: + EFI_SUCCESS - The network interface was reset. + EFI_NOT_STARTED - The network interface has not been started + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This + ) +/*++ + + Routine Description: + Resets a network adapter and leaves it in a state that is safe for + another driver to initialize. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The network interface was shutdown. + EFI_NOT_STARTED - The network interface has not been started + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN UINT32 Enable, + IN UINT32 Disable, + IN BOOLEAN ResetMCastFilter, + IN UINTN MCastFilterCnt OPTIONAL, + IN EFI_MAC_ADDRESS * MCastFilter OPTIONAL + ) +/*++ + + Routine Description: + Manages the multicast receive filters of a network interface. + + Arguments: + This - Protocol instance pointer. + Enable - A bit mask of receive filters to enable on the network interface. + Disable - A bit mask of receive filters to disable on the network interface. + ResetMCastFilter - Set to TRUE to reset the contents of the multicast receive + filters on the network interface to their default values. + McastFilterCnt - Number of multicast HW MAC addresses in the new + MCastFilter list. This value must be less than or equal to + the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This + field is optional if ResetMCastFilter is TRUE. + MCastFilter - A pointer to a list of new multicast receive filter HW MAC + addresses. This list will replace any existing multicast + HW MAC address list. This field is optional if + ResetMCastFilter is TRUE. + + Returns: + EFI_SUCCESS - The multicast receive filter list was updated. + EFI_NOT_STARTED - The network interface has not been started + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN BOOLEAN Reset, + IN EFI_MAC_ADDRESS * New OPTIONAL + ) +/*++ + + Routine Description: + Modifies or resets the current station address, if supported. + + Arguments: + This - Protocol instance pointer. + Reset - Flag used to reset the station address to the network interfaces + permanent address. + New - New station address to be used for the network interface. + + Returns: + EFI_SUCCESS - The network interfaces station address was updated. + EFI_NOT_STARTED - The network interface has not been started + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN BOOLEAN Reset, + IN OUT UINTN *StatisticsSize OPTIONAL, + OUT EFI_NETWORK_STATISTICS * StatisticsTable OPTIONAL + ) +/*++ + + Routine Description: + Resets or collects the statistics on a network interface. + + Arguments: + This - Protocol instance pointer. + Reset - Set to TRUE to reset the statistics for the network interface. + StatisticsSize - On input the size, in bytes, of StatisticsTable. On + output the size, in bytes, of the resulting table of + statistics. + StatisticsTable - A pointer to the EFI_NETWORK_STATISTICS structure that + contains the statistics. + + Returns: + EFI_SUCCESS - The statistics were collected from the network interface. + EFI_NOT_STARTED - The network interface has not been started. + EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer + size needed to hold the statistics is returned in + StatisticsSize. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN BOOLEAN IPv6, + IN EFI_IP_ADDRESS * IP, + OUT EFI_MAC_ADDRESS * MAC + ) +/*++ + + Routine Description: + Converts a multicast IP address to a multicast HW MAC address. + + Arguments: + This - Protocol instance pointer. + IPv6 - Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set + to FALSE if the multicast IP address is IPv4 [RFC 791]. + IP - The multicast IP address that is to be converted to a multicast + HW MAC address. + MAC - The multicast HW MAC address that is to be generated from IP. + + Returns: + EFI_SUCCESS - The multicast IP address was mapped to the multicast + HW MAC address. + EFI_NOT_STARTED - The network interface has not been started. + EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer + size needed to hold the statistics is returned in + StatisticsSize. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_NVDATA) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN BOOLEAN ReadWrite, + IN UINTN Offset, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ) +/*++ + + Routine Description: + Performs read and write operations on the NVRAM device attached to a + network interface. + + Arguments: + This - Protocol instance pointer. + ReadWrite - TRUE for read operations, FALSE for write operations. + Offset - Byte offset in the NVRAM device at which to start the read or + write operation. This must be a multiple of NvRamAccessSize and + less than NvRamSize. + BufferSize - The number of bytes to read or write from the NVRAM device. + This must also be a multiple of NvramAccessSize. + Buffer - A pointer to the data buffer. + + Returns: + EFI_SUCCESS - The NVRAM access was performed. + EFI_NOT_STARTED - The network interface has not been started. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + OUT UINT32 *InterruptStatus OPTIONAL, + OUT VOID **TxBuf OPTIONAL + ) +/*++ + + Routine Description: + Reads the current interrupt status and recycled transmit buffer status from + a network interface. + + Arguments: + This - Protocol instance pointer. + InterruptStatus - A pointer to the bit mask of the currently active interrupts + If this is NULL, the interrupt status will not be read from + the device. If this is not NULL, the interrupt status will + be read from the device. When the interrupt status is read, + it will also be cleared. Clearing the transmit interrupt + does not empty the recycled transmit buffer array. + TxBuf - Recycled transmit buffer address. The network interface will + not transmit if its internal recycled transmit buffer array + is full. Reading the transmit buffer does not clear the + transmit interrupt. If this is NULL, then the transmit buffer + status will not be read. If there are no transmit buffers to + recycle and TxBuf is not NULL, * TxBuf will be set to NULL. + + Returns: + EFI_SUCCESS - The status of the network interface was retrieved. + EFI_NOT_STARTED - The network interface has not been started. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + IN UINTN HeaderSize, + IN UINTN BufferSize, + IN VOID *Buffer, + IN EFI_MAC_ADDRESS * SrcAddr OPTIONAL, + IN EFI_MAC_ADDRESS * DestAddr OPTIONAL, + IN UINT16 *Protocol OPTIONAL + ) +/*++ + + Routine Description: + Places a packet in the transmit queue of a network interface. + + Arguments: + This - Protocol instance pointer. + HeaderSize - The size, in bytes, of the media header to be filled in by + the Transmit() function. If HeaderSize is non-zero, then it + must be equal to This->Mode->MediaHeaderSize and the DestAddr + and Protocol parameters must not be NULL. + BufferSize - The size, in bytes, of the entire packet (media header and + data) to be transmitted through the network interface. + Buffer - A pointer to the packet (media header followed by data) to be + transmitted. This parameter cannot be NULL. If HeaderSize is zero, + then the media header in Buffer must already be filled in by the + caller. If HeaderSize is non-zero, then the media header will be + filled in by the Transmit() function. + SrcAddr - The source HW MAC address. If HeaderSize is zero, then this parameter + is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then + This->Mode->CurrentAddress is used for the source HW MAC address. + DsetAddr - The destination HW MAC address. If HeaderSize is zero, then this + parameter is ignored. + Protocol - The type of header to build. If HeaderSize is zero, then this + parameter is ignored. See RFC 1700, section "Ether Types", for + examples. + + Returns: + EFI_SUCCESS - The packet was placed on the transmit queue. + EFI_NOT_STARTED - The network interface has not been started. + EFI_NOT_READY - The network interface is too busy to accept this transmit + request. + EFI_BUFFER_TOO_SMALL - The BufferSize parameter is too small. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE) ( + IN EFI_SIMPLE_NETWORK_PROTOCOL * This, + OUT UINTN *HeaderSize OPTIONAL, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer, + OUT EFI_MAC_ADDRESS * SrcAddr OPTIONAL, + OUT EFI_MAC_ADDRESS * DestAddr OPTIONAL, + OUT UINT16 *Protocol OPTIONAL + ) +/*++ + + Routine Description: + Receives a packet from a network interface. + + Arguments: + This - Protocol instance pointer. + HeaderSize - The size, in bytes, of the media header received on the network + interface. If this parameter is NULL, then the media header size + will not be returned. + BufferSize - On entry, the size, in bytes, of Buffer. On exit, the size, in + bytes, of the packet that was received on the network interface. + Buffer - A pointer to the data buffer to receive both the media header and + the data. + SrcAddr - The source HW MAC address. If this parameter is NULL, the + HW MAC source address will not be extracted from the media + header. + DsetAddr - The destination HW MAC address. If this parameter is NULL, + the HW MAC destination address will not be extracted from the + media header. + Protocol - The media header type. If this parameter is NULL, then the + protocol will not be extracted from the media header. See + RFC 1700 section "Ether Types" for examples. + + Returns: + EFI_SUCCESS - The received data was stored in Buffer, and BufferSize has + been updated to the number of bytes received. + EFI_NOT_STARTED - The network interface has not been started. + EFI_NOT_READY - The network interface is too busy to accept this transmit + request. + EFI_BUFFER_TOO_SMALL - The BufferSize parameter is too small. + EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value. + EFI_DEVICE_ERROR - The command could not be sent to the network interface. + EFI_UNSUPPORTED - This function is not supported by the network interface. + +--*/ +; + +#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 + +typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL { + UINT64 Revision; + EFI_SIMPLE_NETWORK_START Start; + EFI_SIMPLE_NETWORK_STOP Stop; + EFI_SIMPLE_NETWORK_INITIALIZE Initialize; + EFI_SIMPLE_NETWORK_RESET Reset; + EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown; + EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters; + EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress; + EFI_SIMPLE_NETWORK_STATISTICS Statistics; + EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac; + EFI_SIMPLE_NETWORK_NVDATA NvData; + EFI_SIMPLE_NETWORK_GET_STATUS GetStatus; + EFI_SIMPLE_NETWORK_TRANSMIT Transmit; + EFI_SIMPLE_NETWORK_RECEIVE Receive; + EFI_EVENT WaitForPacket; + EFI_SIMPLE_NETWORK_MODE *Mode; +} EFI_SIMPLE_NETWORK_PROTOCOL; + +extern EFI_GUID gEfiSimpleNetworkProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c new file mode 100644 index 0000000000..aa5e1c9353 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimplePointer.c + +Abstract: + + Simple Pointer protocol from the EFI 1.1 specification. + + Abstraction of a very simple pointer device like a mice or trackballs. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (SimplePointer) + +EFI_GUID gEfiSimplePointerProtocolGuid = EFI_SIMPLE_POINTER_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSimplePointerProtocolGuid, "Simple Pointer Protocol", "EFI 1.1 Simple Pointer Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h new file mode 100644 index 0000000000..35aed1d987 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h @@ -0,0 +1,76 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimplePointer.h + +Abstract: + + Simple Pointer protocol from the EFI 1.1 specification. + + Abstraction of a very simple pointer device like a mice or tracekballs. + +--*/ + +#ifndef _SIMPLE_POINTER_H_ +#define _SIMPLE_POINTER_H_ + +#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \ + { \ + 0x31878c87, 0xb75, 0x11d5, 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_SIMPLE_POINTER_PROTOCOL); + +// +// Data structures +// +typedef struct { + INT32 RelativeMovementX; + INT32 RelativeMovementY; + INT32 RelativeMovementZ; + BOOLEAN LeftButton; + BOOLEAN RightButton; +} EFI_SIMPLE_POINTER_STATE; + +typedef struct { + UINT64 ResolutionX; + UINT64 ResolutionY; + UINT64 ResolutionZ; + BOOLEAN LeftButton; + BOOLEAN RightButton; +} EFI_SIMPLE_POINTER_MODE; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_POINTER_RESET) ( + IN EFI_SIMPLE_POINTER_PROTOCOL * This, + IN BOOLEAN ExtendedVerification + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) ( + IN EFI_SIMPLE_POINTER_PROTOCOL * This, + IN OUT EFI_SIMPLE_POINTER_STATE * State + ); + +typedef struct _EFI_SIMPLE_POINTER_PROTOCOL { + EFI_SIMPLE_POINTER_RESET Reset; + EFI_SIMPLE_POINTER_GET_STATE GetState; + EFI_EVENT WaitForInput; + EFI_SIMPLE_POINTER_MODE *Mode; +} EFI_SIMPLE_POINTER_PROTOCOL; + +extern EFI_GUID gEfiSimplePointerProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c new file mode 100644 index 0000000000..89a6c264fb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleTextIn.c + +Abstract: + + Simple Text In protocol from the EFI 1.0 specification. + + Abstraction of a very simple input device like a keyboard or serial + terminal. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (SimpleTextIn) + +EFI_GUID gEfiSimpleTextInProtocolGuid = EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSimpleTextInProtocolGuid, "Simple Text In Protocol", "EFI 1.0 Simple Text In Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h new file mode 100644 index 0000000000..620acf65d0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h @@ -0,0 +1,136 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleTextIn.h + +Abstract: + + Simple Text In protocol from the EFI 1.0 specification. + + Abstraction of a very simple input device like a keyboard or serial + terminal. + +--*/ + +#ifndef _SIMPLE_TEXT_IN_H_ +#define _SIMPLE_TEXT_IN_H_ + +#define EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID \ + { \ + 0x387477c1, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +EFI_FORWARD_DECLARATION (EFI_SIMPLE_TEXT_IN_PROTOCOL); + +// +// Data structures +// +typedef struct { + UINT16 ScanCode; + CHAR16 UnicodeChar; +} EFI_INPUT_KEY; + +// +// Required unicode control chars +// +#define CHAR_NULL 0x0000 +#define CHAR_BACKSPACE 0x0008 +#define CHAR_TAB 0x0009 +#define CHAR_LINEFEED 0x000A +#define CHAR_CARRIAGE_RETURN 0x000D + +// +// EFI Scan codes +// +#define SCAN_NULL 0x0000 +#define SCAN_UP 0x0001 +#define SCAN_DOWN 0x0002 +#define SCAN_RIGHT 0x0003 +#define SCAN_LEFT 0x0004 +#define SCAN_HOME 0x0005 +#define SCAN_END 0x0006 +#define SCAN_INSERT 0x0007 +#define SCAN_DELETE 0x0008 +#define SCAN_PAGE_UP 0x0009 +#define SCAN_PAGE_DOWN 0x000A +#define SCAN_F1 0x000B +#define SCAN_F2 0x000C +#define SCAN_F3 0x000D +#define SCAN_F4 0x000E +#define SCAN_F5 0x000F +#define SCAN_F6 0x0010 +#define SCAN_F7 0x0011 +#define SCAN_F8 0x0012 +#define SCAN_F9 0x0013 +#define SCAN_F10 0x0014 +#define SCAN_F11 0x0015 +#define SCAN_F12 0x0016 +#define SCAN_ESC 0x0017 + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_RESET) ( + IN EFI_SIMPLE_TEXT_IN_PROTOCOL * This, + IN BOOLEAN ExtendedVerification + ) +/*++ + + Routine Description: + Reset the input device and optionaly run diagnostics + + Arguments: + This - Protocol instance pointer. + ExtendedVerification - Driver may perform diagnostics on reset. + + Returns: + EFI_SUCCESS - The device was reset. + EFI_DEVICE_ERROR - The device is not functioning properly and could + not be reset. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_READ_KEY) ( + IN EFI_SIMPLE_TEXT_IN_PROTOCOL * This, + OUT EFI_INPUT_KEY * Key + ) +/*++ + + Routine Description: + Reads the next keystroke from the input device. The WaitForKey Event can + be used to test for existance of a keystroke via WaitForEvent () call. + + Arguments: + This - Protocol instance pointer. + Key - Driver may perform diagnostics on reset. + + Returns: + EFI_SUCCESS - The keystroke information was returned. + EFI_NOT_READY - There was no keystroke data availiable. + EFI_DEVICE_ERROR - The keydtroke information was not returned due to + hardware errors. + +--*/ +; + +typedef struct _EFI_SIMPLE_TEXT_IN_PROTOCOL { + EFI_INPUT_RESET Reset; + EFI_INPUT_READ_KEY ReadKeyStroke; + EFI_EVENT WaitForKey; +} EFI_SIMPLE_TEXT_IN_PROTOCOL; + +extern EFI_GUID gEfiSimpleTextInProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c new file mode 100644 index 0000000000..a5db2135da --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleTextOut.c + +Abstract: + + Simple Text Out protocol from the EFI 1.0 specification. + + Abstraction of a very simple text based output device like VGA text mode or + a serial terminal. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (SimpleTextOut) + +EFI_GUID gEfiSimpleTextOutProtocolGuid = EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSimpleTextOutProtocolGuid, "Simple Text Out Protocol", "EFI 1.0 Simple Text Out Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h new file mode 100644 index 0000000000..286ebda44e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h @@ -0,0 +1,423 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleTextOut.h + +Abstract: + + Simple Text Out protocol from the EFI 1.0 specification. + + Abstraction of a very simple text based output device like VGA text mode or + a serial terminal. The Simple Text Out protocol instance can represent + a single hardware device or a virtual device that is an agregation + of multiple physical devices. + +--*/ + +#ifndef _SIMPLE_TEXT_OUT_H_ +#define _SIMPLE_TEXT_OUT_H_ + +#define EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID \ + { \ + 0x387477c2, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } + +EFI_FORWARD_DECLARATION (EFI_SIMPLE_TEXT_OUT_PROTOCOL); + +// +// Define's for required EFI Unicode Box Draw characters +// +#define BOXDRAW_HORIZONTAL 0x2500 +#define BOXDRAW_VERTICAL 0x2502 +#define BOXDRAW_DOWN_RIGHT 0x250c +#define BOXDRAW_DOWN_LEFT 0x2510 +#define BOXDRAW_UP_RIGHT 0x2514 +#define BOXDRAW_UP_LEFT 0x2518 +#define BOXDRAW_VERTICAL_RIGHT 0x251c +#define BOXDRAW_VERTICAL_LEFT 0x2524 +#define BOXDRAW_DOWN_HORIZONTAL 0x252c +#define BOXDRAW_UP_HORIZONTAL 0x2534 +#define BOXDRAW_VERTICAL_HORIZONTAL 0x253c +#define BOXDRAW_DOUBLE_HORIZONTAL 0x2550 +#define BOXDRAW_DOUBLE_VERTICAL 0x2551 +#define BOXDRAW_DOWN_RIGHT_DOUBLE 0x2552 +#define BOXDRAW_DOWN_DOUBLE_RIGHT 0x2553 +#define BOXDRAW_DOUBLE_DOWN_RIGHT 0x2554 +#define BOXDRAW_DOWN_LEFT_DOUBLE 0x2555 +#define BOXDRAW_DOWN_DOUBLE_LEFT 0x2556 +#define BOXDRAW_DOUBLE_DOWN_LEFT 0x2557 +#define BOXDRAW_UP_RIGHT_DOUBLE 0x2558 +#define BOXDRAW_UP_DOUBLE_RIGHT 0x2559 +#define BOXDRAW_DOUBLE_UP_RIGHT 0x255a +#define BOXDRAW_UP_LEFT_DOUBLE 0x255b +#define BOXDRAW_UP_DOUBLE_LEFT 0x255c +#define BOXDRAW_DOUBLE_UP_LEFT 0x255d +#define BOXDRAW_VERTICAL_RIGHT_DOUBLE 0x255e +#define BOXDRAW_VERTICAL_DOUBLE_RIGHT 0x255f +#define BOXDRAW_DOUBLE_VERTICAL_RIGHT 0x2560 +#define BOXDRAW_VERTICAL_LEFT_DOUBLE 0x2561 +#define BOXDRAW_VERTICAL_DOUBLE_LEFT 0x2562 +#define BOXDRAW_DOUBLE_VERTICAL_LEFT 0x2563 +#define BOXDRAW_DOWN_HORIZONTAL_DOUBLE 0x2564 +#define BOXDRAW_DOWN_DOUBLE_HORIZONTAL 0x2565 +#define BOXDRAW_DOUBLE_DOWN_HORIZONTAL 0x2566 +#define BOXDRAW_UP_HORIZONTAL_DOUBLE 0x2567 +#define BOXDRAW_UP_DOUBLE_HORIZONTAL 0x2568 +#define BOXDRAW_DOUBLE_UP_HORIZONTAL 0x2569 +#define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE 0x256a +#define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL 0x256b +#define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL 0x256c + +// +// EFI Required Block Elements Code Chart +// +#define BLOCKELEMENT_FULL_BLOCK 0x2588 +#define BLOCKELEMENT_LIGHT_SHADE 0x2591 + +// +// EFI Required Geometric Shapes Code Chart +// +#define GEOMETRICSHAPE_UP_TRIANGLE 0x25b2 +#define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba +#define GEOMETRICSHAPE_DOWN_TRIANGLE 0x25bc +#define GEOMETRICSHAPE_LEFT_TRIANGLE 0x25c4 + +// +// EFI Required Arrow shapes +// +#define ARROW_LEFT 0x2190 +#define ARROW_UP 0x2191 +#define ARROW_RIGHT 0x2192 +#define ARROW_DOWN 0x2193 + +// +// EFI Console Colours +// +#define EFI_BLACK 0x00 +#define EFI_BLUE 0x01 +#define EFI_GREEN 0x02 +#define EFI_CYAN (EFI_BLUE | EFI_GREEN) +#define EFI_RED 0x04 +#define EFI_MAGENTA (EFI_BLUE | EFI_RED) +#define EFI_BROWN (EFI_GREEN | EFI_RED) +#define EFI_LIGHTGRAY (EFI_BLUE | EFI_GREEN | EFI_RED) +#define EFI_BRIGHT 0x08 +#define EFI_DARKGRAY (EFI_BRIGHT) +#define EFI_LIGHTBLUE (EFI_BLUE | EFI_BRIGHT) +#define EFI_LIGHTGREEN (EFI_GREEN | EFI_BRIGHT) +#define EFI_LIGHTCYAN (EFI_CYAN | EFI_BRIGHT) +#define EFI_LIGHTRED (EFI_RED | EFI_BRIGHT) +#define EFI_LIGHTMAGENTA (EFI_MAGENTA | EFI_BRIGHT) +#define EFI_YELLOW (EFI_BROWN | EFI_BRIGHT) +#define EFI_WHITE (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT) + +#define EFI_TEXT_ATTR(f, b) ((f) | ((b) << 4)) + +#define EFI_BACKGROUND_BLACK 0x00 +#define EFI_BACKGROUND_BLUE 0x10 +#define EFI_BACKGROUND_GREEN 0x20 +#define EFI_BACKGROUND_CYAN (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN) +#define EFI_BACKGROUND_RED 0x40 +#define EFI_BACKGROUND_MAGENTA (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED) +#define EFI_BACKGROUND_BROWN (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED) +#define EFI_BACKGROUND_LIGHTGRAY (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED) + +// +// We currently define attributes from 0 - 7F for color manipulations +// To internally handle the local display characteristics for a particular character, we are defining +// Bit 7 to signify the local glyph representation for a character. If turned on, glyphs will be +// pulled from the wide glyph database and will display locally as a wide character (16 X 19 versus 8 X 19) +// If bit 7 is off, the narrow glyph database will be used. This does NOT affect information that is sent to +// non-local displays (e.g. serial or LAN consoles). +// +#define EFI_WIDE_ATTRIBUTE 0x80 + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_RESET) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN BOOLEAN ExtendedVerification + ) +/*++ + + Routine Description: + Reset the text output device hardware and optionaly run diagnostics + + Arguments: + This - Protocol instance pointer. + ExtendedVerification - Driver may perform more exhaustive verfication + operation of the device during reset. + + Returns: + EFI_SUCCESS - The text output device was reset. + EFI_DEVICE_ERROR - The text output device is not functioning correctly and + could not be reset. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_OUTPUT_STRING) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN CHAR16 *String + ) +/*++ + + Routine Description: + Write a Unicode string to the output device. + + Arguments: + This - Protocol instance pointer. + String - The NULL-terminated Unicode string to be displayed on the output + device(s). All output devices must also support the Unicode + drawing defined in this file. + + Returns: + EFI_SUCCESS - The string was output to the device. + EFI_DEVICE_ERROR - The device reported an error while attempting to output + the text. + EFI_UNSUPPORTED - The output device's mode is not currently in a + defined text mode. + EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the + characters in the Unicode string could not be + rendered and were skipped. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_TEST_STRING) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN CHAR16 *String + ) +/*++ + + Routine Description: + Verifies that all characters in a Unicode string can be output to the + target device. + + Arguments: + This - Protocol instance pointer. + String - The NULL-terminated Unicode string to be examined for the output + device(s). + + Returns: + EFI_SUCCESS - The device(s) are capable of rendering the output string. + EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be + rendered by one or more of the output devices mapped + by the EFI handle. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_QUERY_MODE) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN UINTN ModeNumber, + OUT UINTN *Columns, + OUT UINTN *Rows + ) +/*++ + + Routine Description: + Returns information for an available text mode that the output device(s) + supports. + + Arguments: + This - Protocol instance pointer. + ModeNumber - The mode number to return information on. + Columns, Rows - Returns the geometry of the text output device for the + requested ModeNumber. + + Returns: + EFI_SUCCESS - The requested mode information was returned. + EFI_DEVICE_ERROR - The device had an error and could not complete the request. + EFI_UNSUPPORTED - The mode number was not valid. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_MODE) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN UINTN ModeNumber + ) +/*++ + + Routine Description: + Sets the output device(s) to a specified mode. + + Arguments: + This - Protocol instance pointer. + ModeNumber - The mode number to set. + + Returns: + EFI_SUCCESS - The requested text mode was set. + EFI_DEVICE_ERROR - The device had an error and could not complete the request. + EFI_UNSUPPORTED - The mode number was not valid. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN UINTN Attribute + ) +/*++ + + Routine Description: + Sets the background and foreground colors for the OutputString () and + ClearScreen () functions. + + Arguments: + This - Protocol instance pointer. + Attribute - The attribute to set. Bits 0..3 are the foreground color, and + bits 4..6 are the background color. All other bits are undefined + and must be zero. The valid Attributes are defined in this file. + + Returns: + EFI_SUCCESS - The attribute was set. + EFI_DEVICE_ERROR - The device had an error and could not complete the request. + EFI_UNSUPPORTED - The attribute requested is not defined. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_CLEAR_SCREEN) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This + ) +/*++ + + Routine Description: + Clears the output device(s) display to the currently selected background + color. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The operation completed successfully. + EFI_DEVICE_ERROR - The device had an error and could not complete the request. + EFI_UNSUPPORTED - The output device is not in a valid text mode. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN UINTN Column, + IN UINTN Row + ) +/*++ + + Routine Description: + Sets the current coordinates of the cursor position + + Arguments: + This - Protocol instance pointer. + Column, Row - the position to set the cursor to. Must be greater than or + equal to zero and less than the number of columns and rows + by QueryMode (). + + Returns: + EFI_SUCCESS - The operation completed successfully. + EFI_DEVICE_ERROR - The device had an error and could not complete the request. + EFI_UNSUPPORTED - The output device is not in a valid text mode, or the + cursor position is invalid for the current mode. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TEXT_ENABLE_CURSOR) ( + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This, + IN BOOLEAN Enable + ) +/*++ + + Routine Description: + Makes the cursor visible or invisible + + Arguments: + This - Protocol instance pointer. + Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is + set to be invisible. + + Returns: + EFI_SUCCESS - The operation completed successfully. + EFI_DEVICE_ERROR - The device had an error and could not complete the + request, or the device does not support changing + the cursor mode. + EFI_UNSUPPORTED - The output device is not in a valid text mode. + +--*/ +; + +/*++ + Mode Structure pointed to by Simple Text Out protocol. + + MaxMode - The number of modes supported by QueryMode () and SetMode (). + Mode - The text mode of the output device(s). + Attribute - The current character output attribute + CursorColumn - The cursor's column. + CursorRow - The cursor's row. + CursorVisible - The cursor is currently visbile or not. + +--*/ +typedef struct { + INT32 MaxMode; + + // + // current settings + // + INT32 Mode; + INT32 Attribute; + INT32 CursorColumn; + INT32 CursorRow; + BOOLEAN CursorVisible; +} EFI_SIMPLE_TEXT_OUTPUT_MODE; + +typedef struct _EFI_SIMPLE_TEXT_OUT_PROTOCOL { + EFI_TEXT_RESET Reset; + + EFI_TEXT_OUTPUT_STRING OutputString; + EFI_TEXT_TEST_STRING TestString; + + EFI_TEXT_QUERY_MODE QueryMode; + EFI_TEXT_SET_MODE SetMode; + EFI_TEXT_SET_ATTRIBUTE SetAttribute; + + EFI_TEXT_CLEAR_SCREEN ClearScreen; + EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; + EFI_TEXT_ENABLE_CURSOR EnableCursor; + + // + // Current mode + // + EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode; +} EFI_SIMPLE_TEXT_OUT_PROTOCOL; + +extern EFI_GUID gEfiSimpleTextOutProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.c new file mode 100644 index 0000000000..b454e13f0d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.c @@ -0,0 +1,28 @@ +/*++ + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TapeIo.c + +Abstract: + EFI_TAPE_IO_PROTOCOL as defined in the UEFI 2.0. + Provide services to control and access a tape device. + +Revision History + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (TapeIo) + +EFI_GUID gEfiTapeIoProtocolGuid = EFI_TAPE_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiTapeIoProtocolGuid, "Tape IO protoco", "UEFI 2.0 Tape IO protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.h new file mode 100644 index 0000000000..8d1bd63f31 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/TapeIo/TapeIo.h @@ -0,0 +1,263 @@ +/*++ + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TapeIo.h + +Abstract: + EFI_TAPE_IO_PROTOCOL as defined in the UEFI 2.0. + Provide services to control and access a tape device. + +Revision History + +--*/ + +#ifndef __EFI_TAPE_IO_PROTOCOL_H__ +#define __EFI_TAPE_IO_PROTOCOL_H__ + +#define EFI_TAPE_IO_PROTOCOL_GUID \ + { \ + 0x1e93e633, 0xd65a, 0x459e, {0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \ + } + +typedef struct _EFI_TAPE_IO_PROTOCOL EFI_TAPE_IO_PROTOCOL; + +typedef struct { + UINT64 Signature; + UINT32 Revision; + UINT32 BootDescSize; + UINT32 BootDescCRC; + EFI_GUID TapeGUID; + EFI_GUID TapeType; + EFI_GUID TapeUnique; + UINT32 BLLocation; + UINT32 BLBlocksize; + UINT32 BLFilesize; + CHAR8 OSVersion[40]; + CHAR8 AppVersion[40]; + CHAR8 CreationDate[10]; + CHAR8 CreationTime[10]; + CHAR8 SystemName[256]; // UTF-8 + CHAR8 TapeTitle[120]; // UTF-8 + CHAR8 pad[468]; // pad to 1024 +} TAPE_HEADER; + +typedef +EFI_STATUS +(EFIAPI *EFI_TAPE_READ) ( + IN EFI_TAPE_IO_PROTOCOL *This, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ) +/*++ + + Routine Description: + Reads from the tape. + + Arguments: + This - A pointer to the EFI_TAPE_IO_PROTOCOL instance. + BufferSize - Size of the buffer in bytes pointed to by Buffer. + Buffer - Pointer to the buffer for data to be read into. + + Returns: + EFI_SUCCESS - Data was successfully transferred from the media. + EFI_END_OF_FILE - A filemark was encountered which limited the data + transferred by the read operation or the head is positioned + just after a filemark. + EFI_NO_MEDIA - No media is loaded in the device. + EFI_NOT_READY - The transfer failed since the device was not ready (e.g. not + online). The transfer may be retried at a later time. + EFI_UNSUPPORTED - The device does not support this type of transfer. + EFI_TIMEOUT - The transfer failed to complete within the timeout specified. + EFI_MEDIA_CHANGED - The media in the device was changed since the last access. + The transfer was aborted since the current position of the + media may be incorrect. + EFI_INVALID_PARAMETER - A NULL Buffer was specified with a non-zero + BufferSize or the device is operating in fixed block + size mode and the BufferSize was not a multiple of + device¡¯s fixed block size + EFI_DEVICE_ERROR - A device error occurred while attempting to transfer data + from the media. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TAPE_WRITE) ( + IN EFI_TAPE_IO_PROTOCOL *This, + IN UINTN *BufferSize, + IN VOID *Buffer + ) +/*++ + + Routine Description: + Writes to the tape. + + Arguments: + This - A pointer to the EFI_TAPE_IO_PROTOCOL instance. + BufferSize - Size of the buffer in bytes pointed to by Buffer. + Buffer - Pointer to the buffer for data to be written from. + + Returns: + EFI_SUCCESS - Data was successfully transferred to the media. + EFI_END_OF_MEDIA - The logical end of media has been reached. Data may have + been successfully transferred to the media. + EFI_NO_MEDIA - No media is loaded in the device. + EFI_NOT_READY - The transfer failed since the device was not ready (e.g. not + online). The transfer may be retried at a later time. + EFI_UNSUPPORTED - The device does not support this type of transfer. + EFI_TIMEOUT - The transfer failed to complete within the timeout specified. + EFI_MEDIA_CHANGED - The media in the device was changed since the last access. + The transfer was aborted since the current position of the + media may be incorrect. + EFI_WRITE_PROTECTED - The media in the device is write-protected. The transfer + was aborted since a write cannot be completed. + EFI_INVALID_PARAMETER - A NULL Buffer was specified with a non-zero + BufferSize or the device is operating in fixed block + size mode and the BufferSize was not a multiple of + device¡¯s fixed block size + EFI_DEVICE_ERROR A device error occurred while attempting to transfer data + from the media. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI *EFI_TAPE_REWIND) ( + IN EFI_TAPE_IO_PROTOCOL *This + ) +/*++ + + Routine Description: + Rewinds the tape. + + Arguments: + This - A pointer to the EFI_TAPE_IO_PROTOCOL instance. + + Returns: + EFI_SUCCESS - The media was successfully repositioned. + EFI_NO_MEDIA - No media is loaded in the device. + EFI_NOT_READY - Repositioning the media failed since the device was not + ready (e.g. not online). The transfer may be retried at a later time. + EFI_UNSUPPORTED - The device does not support this type of media repositioning. + EFI_TIMEOUT - Repositioning of the media did not complete within the timeout specified. + EFI_DEVICE_ERROR - A device error occurred while attempting to reposition the media. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI *EFI_TAPE_SPACE) ( + IN EFI_TAPE_IO_PROTOCOL *This, + INTN Direction, + UINTN Type + ) +/*++ + + Routine Description: + Positions the tape. + + Arguments: + This - A pointer to the EFI_TAPE_IO_PROTOCOL instance. + Direction - Direction and number of data blocks or filemarks to space over on media. + Type - Type of mark to space over on media. + + Returns: + EFI_SUCCESS - The media was successfully repositioned. + EFI_END_OF_MEDIA - Beginning or end of media was reached before the + indicated number of data blocks or filemarks were found. + EFI_NO_MEDIA - No media is loaded in the device. + EFI_NOT_READY - The reposition failed since the device was not ready (e.g. not + online). The reposition may be retried at a later time. + EFI_UNSUPPORTED - The device does not support this type of repositioning. + EFI_TIMEOUT - The repositioning failed to complete within the timeout specified. + EFI_MEDIA_CHANGED - The media in the device was changed since the last access. + Repositioning the media was aborted since the current + position of the media may be incorrect. + EFI_DEVICE_ERROR - A device error occurred while attempting to reposition the media. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TAPE_WRITEFM) ( + IN EFI_TAPE_IO_PROTOCOL *This, + IN UINTN Count + ) +/*++ + + Routine Description: + Writes filemarks to the media. + + Arguments: + This - A pointer to the EFI_TAPE_IO_PROTOCOL instance. + Count - Number of filemarks to write to the media. + + Returns: + EFI_SUCCESS - Data was successfully transferred from the media. + EFI_NO_MEDIA - No media is loaded in the device. + EFI_NOT_READY - The transfer failed since the device was not ready (e.g. not + online). The transfer may be retried at a later time. + EFI_UNSUPPORTED - The device does not support this type of repositioning. + EFI_TIMEOUT - The transfer failed to complete within the timeout specified. + EFI_MEDIA_CHANGED - The media in the device was changed since the last access. + The transfer was aborted since the current position of the + media may be incorrect. + EFI_DEVICE_ERROR - A device error occurred while attempting to transfer data from the media. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_TAPE_RESET) ( + IN EFI_TAPE_IO_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ) +/*++ + + Routine Description: + Resets the tape device. + + Arguments: + This - A pointer to the EFI_TAPE_IO_PROTOCOL instance. + ExtendedVerification - Indicates whether the parent bus should also be reset. + + Returns: + EFI_SUCCESS - The bus and/or device were successfully reset. + EFI_NO_MEDIA - No media is loaded in the device. + EFI_NOT_READY - The reset failed since the device and/or bus was not ready. + The reset may be retried at a later time. + EFI_UNSUPPORTED - The device does not support this type of reset. + EFI_TIMEOUT - The reset did not complete within the timeout allowed. + EFI_DEVICE_ERROR - A device error occurred while attempting to reset the bus and/or device. + +--*/ +; + +struct _EFI_TAPE_IO_PROTOCOL { + EFI_TAPE_READ TapeRead; + EFI_TAPE_WRITE TapeWrite; + EFI_TAPE_REWIND TapeRewind; + EFI_TAPE_SPACE TapeSpace; + EFI_TAPE_WRITEFM TapeWriteFM; + EFI_TAPE_RESET TapeReset; +}; + +extern EFI_GUID gEfiTapeIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.c new file mode 100644 index 0000000000..54f75b9b35 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Tcp4.c + +Abstract: + + UEFI TCPv4 Protocol + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Tcp4) + +EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID; +EFI_GUID gEfiTcp4ProtocolGuid = EFI_TCP4_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiTcp4ServiceBindingProtocolGuid, "TCP4 Service Binding Protocol", "TCP4 Service Binding Protocol"); +EFI_GUID_STRING(&gEfiTcp4ProtocolGuid, "TCP4 Protocol", "TCP4 Protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.h new file mode 100644 index 0000000000..e4d1e3efe1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Tcp4/Tcp4.h @@ -0,0 +1,247 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Tcp4.h + +Abstract: + + UEFI TCPv4 Protocol Definition + +--*/ + +#ifndef _TCP4_H_ +#define _TCP4_H_ + +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) +#include EFI_PROTOCOL_DEFINITION (Ip4) + +#define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \ + { \ + 0x00720665, 0x67EB, 0x4a99, 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 \ + } + +extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid; + +#define EFI_TCP4_PROTOCOL_GUID \ + { \ + 0x65530BC7, 0xA359, 0x410f, 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 \ + } + +extern EFI_GUID gEfiTcp4ProtocolGuid; + +EFI_FORWARD_DECLARATION (EFI_TCP4_PROTOCOL); + +typedef struct { + EFI_HANDLE InstanceHandle; + EFI_IPv4_ADDRESS LocalAddress; + UINT16 LocalPort; + EFI_IPv4_ADDRESS RemoteAddress; + UINT16 RemotePort; +} EFI_TCP4_SERVICE_POINT; + +typedef struct { + EFI_HANDLE DriverHandle; + UINT32 ServiceCount; + EFI_TCP4_SERVICE_POINT Services[1]; +} EFI_TCP4_VARIABLE_DATA; + +typedef struct { + BOOLEAN UseDefaultAddress; + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT16 StationPort; + EFI_IPv4_ADDRESS RemoteAddress; + UINT16 RemotePort; + BOOLEAN ActiveFlag; +} EFI_TCP4_ACCESS_POINT; + +typedef struct { + UINT32 ReceiveBufferSize; + UINT32 SendBufferSize; + UINT32 MaxSynBackLog; + UINT32 ConnectionTimeout; + UINT32 DataRetries; + UINT32 FinTimeout; + UINT32 TimeWaitTimeout; + UINT32 KeepAliveProbes; + UINT32 KeepAliveTime; + UINT32 KeepAliveInterval; + BOOLEAN EnableNagle; + BOOLEAN EnableTimeStamp; + BOOLEAN EnableWindowScaling; + BOOLEAN EnableSelectiveAck; + BOOLEAN EnablePathMtuDiscovery; +} EFI_TCP4_OPTION; + +typedef struct { + UINT8 TypeOfService; + UINT8 TimeToLive; + EFI_TCP4_ACCESS_POINT AccessPoint; + EFI_TCP4_OPTION *ControlOption; +} EFI_TCP4_CONFIG_DATA; + +typedef enum { + Tcp4StateClosed = 0, + Tcp4StateListen = 1, + Tcp4StateSynSent = 2, + Tcp4StateSynReceived= 3, + Tcp4StateEstablished= 4, + Tcp4StateFinWait1 = 5, + Tcp4StateFinWait2 = 6, + Tcp4StateClosing = 7, + Tcp4StateTimeWait = 8, + Tcp4StateCloseWait = 9, + Tcp4StateLastAck = 10 +} EFI_TCP4_CONNECTION_STATE; + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; +} EFI_TCP4_COMPLETION_TOKEN; + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; +} EFI_TCP4_CONNECTION_TOKEN; + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; + EFI_HANDLE NewChildHandle; +} EFI_TCP4_LISTEN_TOKEN; + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_TCP4_FRAGMENT_DATA; + +typedef struct { + BOOLEAN UrgentFlag; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_TCP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP4_RECEIVE_DATA; + +typedef struct { + BOOLEAN Push; + BOOLEAN Urgent; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_TCP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_TCP4_TRANSMIT_DATA; + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; + union { + EFI_TCP4_RECEIVE_DATA *RxData; + EFI_TCP4_TRANSMIT_DATA *TxData; + } Packet; +} EFI_TCP4_IO_TOKEN; + +typedef struct { + EFI_TCP4_COMPLETION_TOKEN CompletionToken; + BOOLEAN AbortOnClose; +} EFI_TCP4_CLOSE_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_GET_MODE_DATA) ( + IN EFI_TCP4_PROTOCOL *This, + OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL, + OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CONFIGURE) ( + IN EFI_TCP4_PROTOCOL *This, + IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_ROUTES) ( + IN EFI_TCP4_PROTOCOL *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CONNECT) ( + IN EFI_TCP4_PROTOCOL *This, + IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_ACCEPT) ( + IN EFI_TCP4_PROTOCOL *This, + IN EFI_TCP4_LISTEN_TOKEN *ListenToken + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_TRANSMIT) ( + IN EFI_TCP4_PROTOCOL *This, + IN EFI_TCP4_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_RECEIVE) ( + IN EFI_TCP4_PROTOCOL *This, + IN EFI_TCP4_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CLOSE) ( + IN EFI_TCP4_PROTOCOL *This, + IN EFI_TCP4_CLOSE_TOKEN *CloseToken + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_CANCEL) ( + IN EFI_TCP4_PROTOCOL *This, + IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP4_POLL) ( + IN EFI_TCP4_PROTOCOL *This + ); + +typedef struct _EFI_TCP4_PROTOCOL { + EFI_TCP4_GET_MODE_DATA GetModeData; + EFI_TCP4_CONFIGURE Configure; + EFI_TCP4_ROUTES Routes; + EFI_TCP4_CONNECT Connect; + EFI_TCP4_ACCEPT Accept; + EFI_TCP4_TRANSMIT Transmit; + EFI_TCP4_RECEIVE Receive; + EFI_TCP4_CLOSE Close; + EFI_TCP4_CANCEL Cancel; + EFI_TCP4_POLL Poll; +} EFI_TCP4_PROTOCOL; + +#define EFI_CONNECTION_FIN EFIERR (104) +#define EFI_CONNECTION_RESET EFIERR (105) +#define EFI_CONNECTION_REFUSED EFIERR (106) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.c new file mode 100644 index 0000000000..1206b15d60 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Udp4.c + +Abstract: + + UEFI UDPv4 protocol. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (Udp4) + +EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID; +EFI_GUID gEfiUdp4ProtocolGuid = EFI_UDP4_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiUdp4ServiceBindingProtocolGuid, "UDP4 Service Binding Protocol", "UDP4 Service Binding Protocol"); +EFI_GUID_STRING (&gEfiUdp4ProtocolGuid, "UDP4 Protocol", "UDP4 Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.h new file mode 100644 index 0000000000..c8730a7222 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Udp4/Udp4.h @@ -0,0 +1,214 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Udp4.h + +Abstract: + +--*/ + +#ifndef _UDP4_H_ +#define _UDP4_H_ + +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) +#include EFI_PROTOCOL_DEFINITION (Ip4) + +// +//GUID definitions +// +#define EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID \ + { 0x83f01464, 0x99bd, 0x45e5, 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } + +#define EFI_UDP4_PROTOCOL_GUID \ + { 0x3ad9df29, 0x4501, 0x478d, 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } + +typedef struct { + EFI_HANDLE InstanceHandle; + EFI_IPv4_ADDRESS LocalAddress; + UINT16 LocalPort; + EFI_IPv4_ADDRESS RemoteAddress; + UINT16 RemotePort; +} EFI_UDP4_SERVICE_POINT; + +typedef struct { + EFI_HANDLE DriverHandle; + UINT32 ServiceCount; + EFI_UDP4_SERVICE_POINT Services[1]; +} EFI_UDP4_VARIABLE_DATA; + +// +//ICMP error definitions +// +#define EFI_NETWORK_UNREACHABLE EFIERR(100) +#define EFI_HOST_UNREACHABLE EFIERR(101) +#define EFI_PROTOCOL_UNREACHABLE EFIERR(102) +#define EFI_PORT_UNREACHABLE EFIERR(103) + +EFI_FORWARD_DECLARATION (EFI_UDP4_PROTOCOL); + +//************************************************* +// EFI_UDP4_FRAGMENT_DATA * +//************************************************* +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_UDP4_FRAGMENT_DATA; + +//************************************************* +// EFI_UDP4_SESSION_DATA * +//************************************************* +typedef struct { + EFI_IPv4_ADDRESS SourceAddress; + UINT16 SourcePort; + EFI_IPv4_ADDRESS DestinationAddress; + UINT16 DestinationPort; +} EFI_UDP4_SESSION_DATA; + +//************************************************ +// EFI_UDP4_CONFIG_DATA * +//************************************************ +typedef struct { + //Receiving Filters + BOOLEAN AcceptBroadcast; + BOOLEAN AcceptPromiscuous; + BOOLEAN AcceptAnyPort; + BOOLEAN AllowDuplicatePort; + //I/O parameters + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; + //Access Point + BOOLEAN UseDefaultAddress; + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT16 StationPort; + EFI_IPv4_ADDRESS RemoteAddress; + UINT16 RemotePort; +} EFI_UDP4_CONFIG_DATA; + +//******************************************************* +// EFI_UDP4_TRANSMIT_DATA * +//******************************************************* +typedef struct { + EFI_UDP4_SESSION_DATA *UdpSessionData; + EFI_IPv4_ADDRESS *GatewayAddress; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_UDP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_UDP4_TRANSMIT_DATA; + +//******************************************************* +// EFI_UDP4_RECEIVE_DATA * +//******************************************************* +typedef struct { + EFI_TIME TimeStamp; + EFI_EVENT RecycleSignal; + EFI_UDP4_SESSION_DATA UdpSession; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_UDP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_UDP4_RECEIVE_DATA; + + +//******************************************************* +// EFI_UDP4_COMPLETION_TOKEN * +//******************************************************* +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + union { + EFI_UDP4_RECEIVE_DATA *RxData; + EFI_UDP4_TRANSMIT_DATA *TxData; + } Packet; +} EFI_UDP4_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_GET_MODE_DATA) ( + IN EFI_UDP4_PROTOCOL *This, + OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_CONFIGURE) ( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_GROUPS) ( + IN EFI_UDP4_PROTOCOL *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_ROUTES) ( + IN EFI_UDP4_PROTOCOL *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress +); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_TRANSMIT) ( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token +); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_RECEIVE) ( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token +); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_CANCEL)( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_UDP4_POLL) ( + IN EFI_UDP4_PROTOCOL *This +); + +typedef struct _EFI_UDP4_PROTOCOL { + EFI_UDP4_GET_MODE_DATA GetModeData; + EFI_UDP4_CONFIGURE Configure; + EFI_UDP4_GROUPS Groups; + EFI_UDP4_ROUTES Routes; + EFI_UDP4_TRANSMIT Transmit; + EFI_UDP4_RECEIVE Receive; + EFI_UDP4_CANCEL Cancel; + EFI_UDP4_POLL Poll; +} EFI_UDP4_PROTOCOL; + +extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid; +extern EFI_GUID gEfiUdp4ProtocolGuid; +extern EFI_GUID gEfiUdp4RegistryDataGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c new file mode 100644 index 0000000000..dfd6ca8caa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UgaDraw.c + +Abstract: + + UGA Draw protocol from the EFI 1.1 specification. + + Abstraction of a very simple graphics device. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (UgaDraw) + +EFI_GUID gEfiUgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiUgaDrawProtocolGuid, "UGA Draw Protocol", "EFI 1.1 UGA Draw Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h new file mode 100644 index 0000000000..cc7ca211b9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h @@ -0,0 +1,181 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UgaDraw.h + +Abstract: + + UGA Draw protocol from the EFI 1.1 specification. + + Abstraction of a very simple graphics device. + +--*/ + +#ifndef __UGA_DRAW_H__ +#define __UGA_DRAW_H__ + +#define EFI_UGA_DRAW_PROTOCOL_GUID \ + { \ + 0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 \ + } + +typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL; + +typedef +EFI_STATUS +(EFIAPI *EFI_UGA_DRAW_PROTOCOL_GET_MODE) ( + IN EFI_UGA_DRAW_PROTOCOL * This, + OUT UINT32 *HorizontalResolution, + OUT UINT32 *VerticalResolution, + OUT UINT32 *ColorDepth, + OUT UINT32 *RefreshRate + ) +/*++ + + Routine Description: + Return the current video mode information. + + Arguments: + This - Protocol instance pointer. + HorizontalResolution - Current video horizontal resolution in pixels + VerticalResolution - Current video vertical resolution in pixels + ColorDepth - Current video color depth in bits per pixel + RefreshRate - Current video refresh rate in Hz. + + Returns: + EFI_SUCCESS - Mode information returned. + EFI_NOT_STARTED - Video display is not initialized. Call SetMode () + EFI_INVALID_PARAMETER - One of the input args was NULL. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_UGA_DRAW_PROTOCOL_SET_MODE) ( + IN EFI_UGA_DRAW_PROTOCOL * This, + IN UINT32 HorizontalResolution, + IN UINT32 VerticalResolution, + IN UINT32 ColorDepth, + IN UINT32 RefreshRate + ) +/*++ + + Routine Description: + Return the current video mode information. + + Arguments: + This - Protocol instance pointer. + HorizontalResolution - Current video horizontal resolution in pixels + VerticalResolution - Current video vertical resolution in pixels + ColorDepth - Current video color depth in bits per pixel + RefreshRate - Current video refresh rate in Hz. + + Returns: + EFI_SUCCESS - Mode information returned. + EFI_NOT_STARTED - Video display is not initialized. Call SetMode () + +--*/ +; + +typedef struct { + UINT8 Blue; + UINT8 Green; + UINT8 Red; + UINT8 Reserved; +} EFI_UGA_PIXEL; + +typedef union { + EFI_UGA_PIXEL Pixel; + UINT32 Raw; +} EFI_UGA_PIXEL_UNION; + +typedef enum { + EfiUgaVideoFill, + EfiUgaVideoToBltBuffer, + EfiUgaBltBufferToVideo, + EfiUgaVideoToVideo, + EfiUgaBltMax +} EFI_UGA_BLT_OPERATION; + +typedef +EFI_STATUS +(EFIAPI *EFI_UGA_DRAW_PROTOCOL_BLT) ( + IN EFI_UGA_DRAW_PROTOCOL * This, + IN EFI_UGA_PIXEL * BltBuffer, OPTIONAL + IN EFI_UGA_BLT_OPERATION BltOperation, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta OPTIONAL + ); + +/*++ + + Routine Description: + The following table defines actions for BltOperations: + EfiUgaVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY) + directly to every pixel of the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + Only one pixel will be used from the BltBuffer. Delta is NOT used. + EfiUgaVideoToBltBuffer - Read data from the video display rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in + the BltBuffer rectangle (DestinationX, DestinationY ) + (DestinationX + Width, DestinationY + Height). If DestinationX or + DestinationY is not zero then Delta must be set to the length in bytes + of a row in the BltBuffer. + EfiUgaBltBufferToVideo - Write data from the BltBuffer rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the + video display rectangle (DestinationX, DestinationY) + (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is + not zero then Delta must be set to the length in bytes of a row in the + BltBuffer. + EfiUgaVideoToVideo - Copy from the video display rectangle (SourceX, SourceY) + (SourceX + Width, SourceY + Height) .to the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + The BltBuffer and Delta are not used in this mode. + + Arguments: + This - Protocol instance pointer. + BltBuffer - Buffer containing data to blit into video buffer. This + buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL) + BltOperation - Operation to perform on BlitBuffer and video memory + SourceX - X coordinate of source for the BltBuffer. + SourceY - Y coordinate of source for the BltBuffer. + DestinationX - X coordinate of destination for the BltBuffer. + DestinationY - Y coordinate of destination for the BltBuffer. + Width - Width of rectangle in BltBuffer in pixels. + Height - Hight of rectangle in BltBuffer in pixels. + Delta - + + Returns: + EFI_SUCCESS - The Blt operation completed. + EFI_INVALID_PARAMETER - BltOperation is not valid. + EFI_DEVICE_ERROR - A hardware error occured writting to the video + buffer. + +--*/ +; + +typedef struct _EFI_UGA_DRAW_PROTOCOL { + EFI_UGA_DRAW_PROTOCOL_GET_MODE GetMode; + EFI_UGA_DRAW_PROTOCOL_SET_MODE SetMode; + EFI_UGA_DRAW_PROTOCOL_BLT Blt; +} EFI_UGA_DRAW_PROTOCOL; + +extern EFI_GUID gEfiUgaDrawProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.c new file mode 100644 index 0000000000..1248e5cd3b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UgaIo.c + +Abstract: + + UGA IO protocol from the EFI 1.1 specification. + + Abstraction of a very simple graphics device. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (UgaIo) + +EFI_GUID gEfiUgaIoProtocolGuid = EFI_UGA_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiUgaIoProtocolGuid, "UGA Protocol", "EFI 1.1 UGA Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.h new file mode 100644 index 0000000000..1bfb0494b7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UgaIo/UgaIo.h @@ -0,0 +1,236 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UgaIo.h + +Abstract: + + UGA IO protocol from the EFI 1.1 specification. + + Abstraction of a very simple graphics device. + +--*/ + +#ifndef __UGA_IO_H__ +#define __UGA_IO_H__ + +#define EFI_UGA_IO_PROTOCOL_GUID \ + { \ + 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 \ + } + +typedef struct _EFI_UGA_IO_PROTOCOL EFI_UGA_IO_PROTOCOL; + +typedef UINT32 UGA_STATUS; + +typedef enum { + UgaDtParentBus = 1, + UgaDtGraphicsController, + UgaDtOutputController, + UgaDtOutputPort, + UgaDtOther +} +UGA_DEVICE_TYPE, *PUGA_DEVICE_TYPE; + +typedef UINT32 UGA_DEVICE_ID, *PUGA_DEVICE_ID; + +typedef struct { + UGA_DEVICE_TYPE deviceType; + UGA_DEVICE_ID deviceId; + UINT32 ui32DeviceContextSize; + UINT32 ui32SharedContextSize; +} +UGA_DEVICE_DATA, *PUGA_DEVICE_DATA; + +typedef struct _UGA_DEVICE { + VOID *pvDeviceContext; + VOID *pvSharedContext; + VOID *pvRunTimeContext; + struct _UGA_DEVICE *pParentDevice; + VOID *pvBusIoServices; + VOID *pvStdIoServices; + UGA_DEVICE_DATA deviceData; +} +UGA_DEVICE, *PUGA_DEVICE; + +#ifndef UGA_IO_REQUEST_CODE +// +// Prevent conflicts with UGA typedefs. +// +typedef enum { + UgaIoGetVersion = 1, + UgaIoGetChildDevice, + UgaIoStartDevice, + UgaIoStopDevice, + UgaIoFlushDevice, + UgaIoResetDevice, + UgaIoGetDeviceState, + UgaIoSetDeviceState, + UgaIoSetPowerState, + UgaIoGetMemoryConfiguration, + UgaIoSetVideoMode, + UgaIoCopyRectangle, + UgaIoGetEdidSegment, + UgaIoDeviceChannelOpen, + UgaIoDeviceChannelClose, + UgaIoDeviceChannelRead, + UgaIoDeviceChannelWrite, + UgaIoGetPersistentDataSize, + UgaIoGetPersistentData, + UgaIoSetPersistentData, + UgaIoGetDevicePropertySize, + UgaIoGetDeviceProperty, + UgaIoBtPrivateInterface +} +UGA_IO_REQUEST_CODE, *PUGA_IO_REQUEST_CODE; + +#endif + +typedef struct { + IN UGA_IO_REQUEST_CODE ioRequestCode; + IN VOID *pvInBuffer; + IN UINT64 ui64InBufferSize; + OUT VOID *pvOutBuffer; + IN UINT64 ui64OutBufferSize; + OUT UINT64 ui64BytesReturned; +} +UGA_IO_REQUEST, *PUGA_IO_REQUEST; + +typedef +EFI_STATUS +(EFIAPI *EFI_UGA_IO_PROTOCOL_CREATE_DEVICE) ( + IN EFI_UGA_IO_PROTOCOL * This, + IN UGA_DEVICE * ParentDevice, + IN UGA_DEVICE_DATA * DeviceData, + IN VOID *RunTimeContext, + OUT UGA_DEVICE **Device + ); + +/*++ + + Routine Description: + + Dynamically allocate storage for a child UGA_DEVICE . + + Arguments: + + This - The EFI_UGA_IO_PROTOCOL instance. Type EFI_UGA_IO_PROTOCOL is + defined in Section 10.7. + + ParentDevice - ParentDevice specifies a pointer to the parent device of Device. + + DeviceData - A pointer to UGA_DEVICE_DATA returned from a call to DispatchService() + with a UGA_DEVICE of Parent and an IoRequest of type UgaIoGetChildDevice. + + RuntimeContext - Context to associate with Device. + + Device - The Device returns a dynamically allocated child UGA_DEVICE object + for ParentDevice. The caller is responsible for deleting Device. + + Returns: + + EFI_SUCCESS - Device was returned. + + EFI_INVALID_PARAMETER - One of the arguments was not valid. + + EFI_DEVICE_ERROR - The device had an error and could not complete the request. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_UGA_IO_PROTOCOL_DELETE_DEVICE) ( + IN EFI_UGA_IO_PROTOCOL * This, + IN UGA_DEVICE * Device + ); + +/*++ + + Routine Description: + + Delete a dynamically allocated child UGA_DEVICE object that was allocated via + CreateDevice() . + + Arguments: + + This - The EFI_UGA_IO_PROTOCOL instance. Type EFI_UGA_IO_PROTOCOL is defined + in Section 10.7. + + Device - The Device points to a UGA_DEVICE object that was dynamically + allocated via a CreateDevice() call. + + Returns: + + EFI_SUCCESS - Device was deleted. + + EFI_INVALID_PARAMETER - The Device was not allocated via CreateDevice() + +--*/ +typedef UGA_STATUS (EFIAPI *PUGA_FW_SERVICE_DISPATCH) (IN PUGA_DEVICE pDevice, IN OUT PUGA_IO_REQUEST pIoRequest); + +/*++ + + Routine Description: + + This is the main UGA service dispatch routine for all UGA_IO_REQUEST s. + + Arguments: + + pDevice - pDevice specifies a pointer to a device object associated with a + device enumerated by a pIoRequest->ioRequestCode of type + UgaIoGetChildDevice. The root device for the EFI_UGA_IO_PROTOCOL + is represented by pDevice being set to NULL. + + pIoRequest - pIoRequest points to a caller allocated buffer that contains data + defined by pIoRequest->ioRequestCode. See Related Definitions for + a definition of UGA_IO_REQUEST_CODE s and their associated data + structures. + + Returns: + + Varies depending on pIoRequest. + +--*/ +typedef struct _EFI_UGA_IO_PROTOCOL { + EFI_UGA_IO_PROTOCOL_CREATE_DEVICE CreateDevice; + EFI_UGA_IO_PROTOCOL_DELETE_DEVICE DeleteDevice; + PUGA_FW_SERVICE_DISPATCH DispatchService; +} EFI_UGA_IO_PROTOCOL; + +extern EFI_GUID gEfiUgaIoProtocolGuid; + +// +// Data structure that is stored in the EFI Configuration Table with the +// EFI_UGA_IO_PROTOCOL_GUID. The option ROMs listed in this table may have +// EBC UGA drivers. +// +typedef struct { + UINT32 Version; + UINT32 HeaderSize; + UINT32 SizeOfEntries; + UINT32 NumberOfEntries; +} EFI_DRIVER_OS_HANDOFF_HEADER; + +typedef enum { + EfiUgaDriverFromPciRom, + EfiUgaDriverFromSystem, + EfiDriverHandoffMax +} EFI_DRIVER_HANOFF_ENUM; + +typedef struct { + EFI_DRIVER_HANOFF_ENUM Type; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + VOID *PciRomImage; + UINT64 PciRomSize; +} EFI_DRIVER_OS_HANDOFF; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c new file mode 100644 index 0000000000..e9c3e6c07e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UnicodeCollation.c + +Abstract: + + Unicode Collation protocol that follows the EFI 1.0 specification. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (UnicodeCollation) + +EFI_GUID gEfiUnicodeCollationProtocolGuid = EFI_UNICODE_COLLATION_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiUnicodeCollationProtocolGuid, "Unicode Collation Protocol", "EFI 1.0 Unicode Collation Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h new file mode 100644 index 0000000000..0c84796f91 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h @@ -0,0 +1,211 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UnicodeCollation.h + +Abstract: + + Unicode Collation protocol that follows the EFI 1.0 specification. + +--*/ + +#ifndef _UNICODE_COLLATION_H_ +#define _UNICODE_COLLATION_H_ + +#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \ + { \ + 0x1d85cd7f, 0xf43d, 0x11d2, 0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +EFI_FORWARD_DECLARATION (EFI_UNICODE_COLLATION_PROTOCOL); + +// +// Protocol data structures and defines +// +#define EFI_UNICODE_BYTE_ORDER_MARK ((CHAR16)(0xfeff)) +#define EFI_UNICODE_BYTE_ORDER_MARK_REVERSE ((CHAR16)(0xfffe)) + +// +// Protocol member functions +// +typedef +INTN +(EFIAPI *EFI_UNICODE_COLLATION_STRICOLL) ( + IN EFI_UNICODE_COLLATION_PROTOCOL * This, + IN CHAR16 *Str1, + IN CHAR16 *Str2 + ) +/*++ + + Routine Description: + Performs a case-insensitive comparison of two Null-terminated Unicode + strings. + + Arguments: + This - Protocol instance pointer. + Str1 - A pointer to a Null-terminated Unicode string. + Str2 - A pointer to a Null-terminated Unicode string. + + Returns: + 0 - Str1 is equivalent to Str2 + > 0 - Str1 is lexically greater than Str2 + < 0 - Str1 is lexically less than Str2 + +--*/ +; + +typedef +BOOLEAN +(EFIAPI *EFI_UNICODE_COLLATION_METAIMATCH) ( + IN EFI_UNICODE_COLLATION_PROTOCOL * This, + IN CHAR16 *String, + IN CHAR16 *Pattern + ) +/*++ + + Routine Description: + Performs a case-insensitive comparison of a Null-terminated Unicode + pattern string and a Null-terminated Unicode string. + + Arguments: + This - Protocol instance pointer. + String - A pointer to a Null-terminated Unicode string. + Pattern - A pointer to a Null-terminated Unicode pattern string. + + Returns: + TRUE - Pattern was found in String. + FALSE - Pattern was not found in String. + +--*/ +; + +typedef +VOID +(EFIAPI *EFI_UNICODE_COLLATION_STRLWR) ( + IN EFI_UNICODE_COLLATION_PROTOCOL * This, + IN OUT CHAR16 *Str + ) +/*++ + + Routine Description: + Converts all the Unicode characters in a Null-terminated Unicode string to + lower case Unicode characters. + + Arguments: + This - Protocol instance pointer. + String - A pointer to a Null-terminated Unicode string. + + Returns: + NONE + +--*/ +; + +typedef +VOID +(EFIAPI *EFI_UNICODE_COLLATION_STRUPR) ( + IN EFI_UNICODE_COLLATION_PROTOCOL * This, + IN OUT CHAR16 *Str + ) +/*++ + + Routine Description: + Converts all the Unicode characters in a Null-terminated Unicode string to upper + case Unicode characters. + + Arguments: + This - Protocol instance pointer. + String - A pointer to a Null-terminated Unicode string. + + Returns: + NONE + +--*/ +; + +typedef +VOID +(EFIAPI *EFI_UNICODE_COLLATION_FATTOSTR) ( + IN EFI_UNICODE_COLLATION_PROTOCOL * This, + IN UINTN FatSize, + IN CHAR8 *Fat, + OUT CHAR16 *String + ) +/*++ + + Routine Description: + Converts an 8.3 FAT file name in an OEM character set to a Null-terminated + Unicode string. + + Arguments: + This - Protocol instance pointer. + FatSize - The size of the string Fat in bytes. + Fat - A pointer to a Null-terminated string that contains an 8.3 file + name using an OEM character set. + String - A pointer to a Null-terminated Unicode string. The string must + be preallocated to hold FatSize Unicode characters. + Returns: + NONE + +--*/ +; + +typedef +BOOLEAN +(EFIAPI *EFI_UNICODE_COLLATION_STRTOFAT) ( + IN EFI_UNICODE_COLLATION_PROTOCOL * This, + IN CHAR16 *String, + IN UINTN FatSize, + OUT CHAR8 *Fat + ) +/*++ + + Routine Description: + Converts a Null-terminated Unicode string to legal characters in a FAT + filename using an OEM character set. + + Arguments: + This - Protocol instance pointer. + String - A pointer to a Null-terminated Unicode string. The string must + be preallocated to hold FatSize Unicode characters. + FatSize - The size of the string Fat in bytes. + Fat - A pointer to a Null-terminated string that contains an 8.3 file + name using an OEM character set. + Returns: + TRUE - Fat is a Long File Name + FALSE - Fat is an 8.3 file name + +--*/ +; + +typedef struct _EFI_UNICODE_COLLATION_PROTOCOL { + // + // general + // + EFI_UNICODE_COLLATION_STRICOLL StriColl; + EFI_UNICODE_COLLATION_METAIMATCH MetaiMatch; + EFI_UNICODE_COLLATION_STRLWR StrLwr; + EFI_UNICODE_COLLATION_STRUPR StrUpr; + + // + // for supporting fat volumes + // + EFI_UNICODE_COLLATION_FATTOSTR FatToStr; + EFI_UNICODE_COLLATION_STRTOFAT StrToFat; + + CHAR8 *SupportedLanguages; +} EFI_UNICODE_COLLATION_PROTOCOL; + +extern EFI_GUID gEfiUnicodeCollationProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c new file mode 100644 index 0000000000..340a4ca5c8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UsbHostController.c + +Abstract: + + USB Host Controller protocol. + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (UsbHostController) + +EFI_GUID gEfiUsbHcProtocolGuid = EFI_USB_HC_PROTOCOL_GUID; +EFI_GUID gEfiUsb2HcProtocolGuid = EFI_USB2_HC_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiUsbHcProtocolGuid, "Usb Host Controller Protocol", "USB 1.1 Host Controller"); +EFI_GUID_STRING(&gEfiUsb2HcProtocolGuid, "Usb2 Host Controller Protocol", "USB 2.0 Host Controller"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h new file mode 100644 index 0000000000..0061fd9793 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h @@ -0,0 +1,411 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UsbHostController.h + +Abstract: + + +--*/ + +#ifndef _USB_HOSTCONTROLLER_H_ +#define _USB_HOSTCONTROLLER_H_ + +#include "usb.h" +#include EFI_PROTOCOL_DEFINITION (UsbIo) + +#define EFI_USB_HC_PROTOCOL_GUID \ + { \ + 0xf5089266, 0x1aa0, 0x4953, 0x97, 0xd8, 0x56, 0x2f, 0x8a, 0x73, 0xb5, 0x19 \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_USB_HC_PROTOCOL); + +typedef enum { + EfiUsbHcStateHalt, + EfiUsbHcStateOperational, + EfiUsbHcStateSuspend, + EfiUsbHcStateMaximum +} EFI_USB_HC_STATE; + +#define EFI_USB_HC_RESET_GLOBAL 0x0001 +#define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002 +#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004 +#define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008 + +// +// Protocol definitions +// +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_RESET) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT16 Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_GET_STATE) ( + IN EFI_USB_HC_PROTOCOL * This, + OUT EFI_USB_HC_STATE * State + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_SET_STATE) ( + IN EFI_USB_HC_PROTOCOL * This, + IN EFI_USB_HC_STATE State + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 DeviceAddress, + IN BOOLEAN IsSlowDevice, + IN UINT8 MaximumPacketLength, + IN EFI_USB_DEVICE_REQUEST * Request, + IN EFI_USB_DATA_DIRECTION TransferDirection, + IN OUT VOID *Data OPTIONAL, + IN OUT UINTN *DataLength OPTIONAL, + IN UINTN TimeOut, + OUT UINT32 *TransferResult + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_BULK_TRANSFER) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 MaximumPacketLength, + IN OUT VOID *Data, + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + OUT UINT32 *TransferResult + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN BOOLEAN IsSlowDevice, + IN UINT8 MaxiumPacketLength, + IN BOOLEAN IsNewTransfer, + IN OUT UINT8 *DataToggle, + IN UINTN PollingInterval OPTIONAL, + IN UINTN DataLength OPTIONAL, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, + IN VOID *Context OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN BOOLEAN IsSlowDevice, + IN UINT8 MaximumPacketLength, + IN OUT VOID *Data, + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + OUT UINT32 *TransferResult + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 MaximumPacketLength, + IN OUT VOID *Data, + IN UINTN DataLength, + OUT UINT32 *TransferResult + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 MaximumPacketLength, + IN OUT VOID *Data, + IN UINTN DataLength, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, + IN VOID *Context OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER) ( + IN EFI_USB_HC_PROTOCOL * This, + OUT UINT8 *PortNumber + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 PortNumber, + OUT EFI_USB_PORT_STATUS * PortStatus + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 PortNumber, + IN EFI_USB_PORT_FEATURE PortFeature + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE) ( + IN EFI_USB_HC_PROTOCOL * This, + IN UINT8 PortNumber, + IN EFI_USB_PORT_FEATURE PortFeature + ); + +typedef struct _EFI_USB_HC_PROTOCOL { + EFI_USB_HC_PROTOCOL_RESET Reset; + EFI_USB_HC_PROTOCOL_GET_STATE GetState; + EFI_USB_HC_PROTOCOL_SET_STATE SetState; + EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER ControlTransfer; + EFI_USB_HC_PROTOCOL_BULK_TRANSFER BulkTransfer; + EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER AsyncInterruptTransfer; + EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER SyncInterruptTransfer; + EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER IsochronousTransfer; + EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER AsyncIsochronousTransfer; + EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER GetRootHubPortNumber; + EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS GetRootHubPortStatus; + EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE SetRootHubPortFeature; + EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE ClearRootHubPortFeature; + UINT16 MajorRevision; + UINT16 MinorRevision; +} EFI_USB_HC_PROTOCOL; + +extern EFI_GUID gEfiUsbHcProtocolGuid; + + +#define EFI_USB2_HC_PROTOCOL_GUID \ + { \ + 0x3e745226, 0x9818, 0x45b6, 0xa2, 0xac, 0xd7, 0xcd, 0xe, 0x8b, 0xa2, 0xbc \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_USB2_HC_PROTOCOL); + +#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004 +#define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008 + +typedef struct { + UINT8 TranslatorHubAddress; + UINT8 TranslatorPortNumber; +} EFI_USB2_HC_TRANSACTION_TRANSLATOR; + +// +// Protocol definitions +// +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_CAPABILITY) ( + IN EFI_USB2_HC_PROTOCOL *This, + OUT UINT8 *MaxSpeed, + OUT UINT8 *PortNumber, + OUT UINT8 *Is64BitCapable + ); + +#define EFI_USB_SPEED_FULL 0x0000 +#define EFI_USB_SPEED_LOW 0x0001 +#define EFI_USB_SPEED_HIGH 0x0002 + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_RESET) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT16 Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_STATE) ( + IN EFI_USB2_HC_PROTOCOL *This, + OUT EFI_USB_HC_STATE *State + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_STATE) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN EFI_USB_HC_STATE State + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN EFI_USB_DEVICE_REQUEST *Request, + IN EFI_USB_DATA_DIRECTION TransferDirection, + IN OUT VOID *Data OPTIONAL, + IN OUT UINTN *DataLength OPTIONAL, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult + ); + +#define EFI_USB_MAX_BULK_BUFFER_NUM 10 + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_BULK_TRANSFER) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaxiumPacketLength, + IN BOOLEAN IsNewTransfer, + IN OUT UINT8 *DataToggle, + IN UINTN PollingInterval OPTIONAL, + IN UINTN DataLength OPTIONAL, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, + IN VOID *Context OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN OUT VOID *Data, + IN OUT UINTN *DataLength, + IN OUT UINT8 *DataToggle, + IN UINTN TimeOut, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult + ); + +#define EFI_USB_MAX_ISO_BUFFER_NUM 7 +#define EFI_USB_MAX_ISO_BUFFER_NUM1 2 + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], + IN UINTN DataLength, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + OUT UINT32 *TransferResult + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 DeviceAddress, + IN UINT8 EndPointAddress, + IN UINT8 DeviceSpeed, + IN UINTN MaximumPacketLength, + IN UINT8 DataBuffersNumber, + IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], + IN UINTN DataLength, + IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, + IN VOID *Context OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 PortNumber, + OUT EFI_USB_PORT_STATUS *PortStatus + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 PortNumber, + IN EFI_USB_PORT_FEATURE PortFeature + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE) ( + IN EFI_USB2_HC_PROTOCOL *This, + IN UINT8 PortNumber, + IN EFI_USB_PORT_FEATURE PortFeature + ); + +typedef struct _EFI_USB2_HC_PROTOCOL { + EFI_USB2_HC_PROTOCOL_GET_CAPABILITY GetCapability; + EFI_USB2_HC_PROTOCOL_RESET Reset; + EFI_USB2_HC_PROTOCOL_GET_STATE GetState; + EFI_USB2_HC_PROTOCOL_SET_STATE SetState; + EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER ControlTransfer; + EFI_USB2_HC_PROTOCOL_BULK_TRANSFER BulkTransfer; + EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER AsyncInterruptTransfer; + EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER SyncInterruptTransfer; + EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER IsochronousTransfer; + EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER AsyncIsochronousTransfer; + EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS GetRootHubPortStatus; + EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE SetRootHubPortFeature; + EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE ClearRootHubPortFeature; + UINT16 MajorRevision; + UINT16 MinorRevision; +} EFI_USB2_HC_PROTOCOL; + +extern EFI_GUID gEfiUsb2HcProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.c new file mode 100644 index 0000000000..d28e327e65 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UsbIo.c + +Abstract: + + EFI Usb I/O Protocol + +Revision History + +--*/ + +#include "EfiSpec.h" + +#include EFI_PROTOCOL_DEFINITION (UsbIo) + +EFI_GUID gEfiUsbIoProtocolGuid = EFI_USB_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiUsbIoProtocolGuid, "Usb IO Protocol", "EFI 1.1 Usb IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.h new file mode 100644 index 0000000000..41c0ccb6d6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/UsbIo/UsbIo.h @@ -0,0 +1,205 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UsbIo.h + +Abstract: + + EFI Usb I/O Protocol + +Revision History + +--*/ + +#ifndef _EFI_USB_IO_H +#define _EFI_USB_IO_H + +#include "usb.h" + +// +// Global ID for the USB I/O Protocol +// +#define EFI_USB_IO_PROTOCOL_GUID \ + { \ + 0x2B2F68D6, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 \ + } + +EFI_FORWARD_DECLARATION (EFI_USB_IO_PROTOCOL); + +// +// Asynchronous USB transfer call back function +// +typedef +EFI_STATUS +(EFIAPI *EFI_ASYNC_USB_TRANSFER_CALLBACK) ( + IN VOID *Data, + IN UINTN DataLength, + IN VOID *Context, + IN UINT32 Status + ); + +// +// Prototype for EFI USB I/O protocol +// +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_CONTROL_TRANSFER) ( + IN EFI_USB_IO_PROTOCOL * This, + IN EFI_USB_DEVICE_REQUEST * Request, + IN EFI_USB_DATA_DIRECTION Direction, + IN UINT32 Timeout, + IN OUT VOID *Data OPTIONAL, + IN UINTN DataLength OPTIONAL, + OUT UINT32 *Status + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_BULK_TRANSFER) ( + IN EFI_USB_IO_PROTOCOL * This, + IN UINT8 DeviceEndpoint, + IN OUT VOID *Data, + IN OUT UINTN *DataLength, + IN UINTN Timeout, + OUT UINT32 *Status + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER) ( + IN EFI_USB_IO_PROTOCOL * This, + IN UINT8 DeviceEndpoint, + IN BOOLEAN IsNewTransfer, + IN UINTN PollingInterval OPTIONAL, + IN UINTN DataLength OPTIONAL, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK InterruptCallBack OPTIONAL, + IN VOID *Context OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_SYNC_INTERRUPT_TRANSFER) ( + IN EFI_USB_IO_PROTOCOL * This, + IN UINT8 DeviceEndpoint, + IN OUT VOID *Data, + IN OUT UINTN *DataLength, + IN UINTN Timeout, + OUT UINT32 *Status + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_ISOCHRONOUS_TRANSFER) ( + IN EFI_USB_IO_PROTOCOL * This, + IN UINT8 DeviceEndpoint, + IN OUT VOID *Data, + IN UINTN DataLength, + OUT UINT32 *Status + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER) ( + IN EFI_USB_IO_PROTOCOL * This, + IN UINT8 DeviceEndpoint, + IN OUT VOID *Data, + IN UINTN DataLength, + IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, + IN VOID *Context OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_PORT_RESET) ( + IN EFI_USB_IO_PROTOCOL * This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_GET_DEVICE_DESCRIPTOR) ( + IN EFI_USB_IO_PROTOCOL * This, + OUT EFI_USB_DEVICE_DESCRIPTOR * DeviceDescriptor + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_GET_CONFIG_DESCRIPTOR) ( + IN EFI_USB_IO_PROTOCOL * This, + OUT EFI_USB_CONFIG_DESCRIPTOR * ConfigurationDescriptor + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_GET_INTERFACE_DESCRIPTOR) ( + IN EFI_USB_IO_PROTOCOL * This, + OUT EFI_USB_INTERFACE_DESCRIPTOR * InterfaceDescriptor + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR) ( + IN EFI_USB_IO_PROTOCOL * This, + IN UINT8 EndpointIndex, + OUT EFI_USB_ENDPOINT_DESCRIPTOR * EndpointDescriptor + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_GET_STRING_DESCRIPTOR) ( + IN EFI_USB_IO_PROTOCOL * This, + IN UINT16 LangID, + IN UINT8 StringID, + OUT CHAR16 **String + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_IO_GET_SUPPORTED_LANGUAGE) ( + IN EFI_USB_IO_PROTOCOL * This, + OUT UINT16 **LangIDTable, + OUT UINT16 *TableSize + ); + +// +// Protocol Interface Structure +// +typedef struct _EFI_USB_IO_PROTOCOL { + // + // IO transfer + // + EFI_USB_IO_CONTROL_TRANSFER UsbControlTransfer; + EFI_USB_IO_BULK_TRANSFER UsbBulkTransfer; + EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER UsbAsyncInterruptTransfer; + EFI_USB_IO_SYNC_INTERRUPT_TRANSFER UsbSyncInterruptTransfer; + EFI_USB_IO_ISOCHRONOUS_TRANSFER UsbIsochronousTransfer; + EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER UsbAsyncIsochronousTransfer; + + // + // Common device request + // + EFI_USB_IO_GET_DEVICE_DESCRIPTOR UsbGetDeviceDescriptor; + EFI_USB_IO_GET_CONFIG_DESCRIPTOR UsbGetConfigDescriptor; + EFI_USB_IO_GET_INTERFACE_DESCRIPTOR UsbGetInterfaceDescriptor; + EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR UsbGetEndpointDescriptor; + EFI_USB_IO_GET_STRING_DESCRIPTOR UsbGetStringDescriptor; + EFI_USB_IO_GET_SUPPORTED_LANGUAGE UsbGetSupportedLanguages; + + // + // Reset controller's parent port + // + EFI_USB_IO_PORT_RESET UsbPortReset; +} EFI_USB_IO_PROTOCOL; + +extern EFI_GUID gEfiUsbIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c new file mode 100644 index 0000000000..5680f0a2cd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiTableStorage.c + +Abstract: + + The filename of the Acpi table storage file. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (AcpiTableStorage) + +EFI_GUID gEfiAcpiTableStorageGuid = EFI_ACPI_TABLE_STORAGE_GUID; + +EFI_GUID_STRING (&gEfiAcpiTableStorageGuid, "ACPI Table Storage File Name", + "Tiano ACPI 2.0 Table Storage file name GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h new file mode 100644 index 0000000000..b424671588 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiTableStorage.h + +Abstract: + + GUID for the ACPI Table Storage filename. + + This GUID is defined in the Tiano ACPI Table Storage EPS. + +--*/ + +#ifndef _ACPI_TABLE_STORAGE_H_ +#define _ACPI_TABLE_STORAGE_H_ + +#define EFI_ACPI_TABLE_STORAGE_GUID \ + { 0x7e374e25, 0x8e01, 0x4fee, 0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd } + +extern EFI_GUID gEfiAcpiTableStorageGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.c new file mode 100644 index 0000000000..b7b9feb855 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Apriori.c + +Abstract: + + GUID used as an FV filename for A Priori file. The A Priori file contains a + list of FV filenames that the DXE dispatcher will schedule reguardless of + the dependency grammer. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (Apriori) + +EFI_GUID gAprioriGuid = EFI_APRIORI_GUID; + +EFI_GUID_STRING(&gAprioriGuid, "Apriori File Name", "Apriori File containing FV GUIDs"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.h new file mode 100644 index 0000000000..5cf5d51650 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/Apriori/Apriori.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Apriori.h + +Abstract: + + GUID used as an FV filename for A Priori file. The A Priori file contains a + list of FV filenames that the DXE dispatcher will schedule reguardless of + the dependency grammer. + +--*/ + +#ifndef _APRIORI_GUID_H_ +#define _APRIORI_GUID_H_ + +#define EFI_APRIORI_GUID \ + { \ + 0xfc510ee7, 0xffdc, 0x11d4, 0xbd, 0x41, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gAprioriGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c new file mode 100644 index 0000000000..2a97b1ef08 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHubRecords.c + +Abstract: + + This file defines GUIDs and associated data structures for records + posted to the Data Hub. + The producers of these records use these definitions to construct + records. + The consumers of these records use these definitions to retrieve, + filter and parse records. + + For more information please look at DataHub.doc + +--*/ + + + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (DataHubRecords) + +EFI_GUID gProcessorProducerGuid = EFI_PROCESSOR_PRODUCER_GUID; + +EFI_GUID gProcessorSubClassName = EFI_PROCESSOR_SUBCLASS_GUID; + +EFI_GUID gCacheSubClassName = EFI_CACHE_SUBCLASS_GUID; + +EFI_GUID gMiscProducerGuid = EFI_MISC_PRODUCER_GUID; +EFI_GUID gMiscSubClassName = EFI_MISC_SUBCLASS_GUID; +EFI_GUID gEfiMiscSubClassGuid = EFI_MISC_SUBCLASS_GUID; + + +EFI_GUID gMemoryProducerGuid = EFI_MEMORY_PRODUCER_GUID; + +EFI_GUID gEfiMemorySubClassGuid = EFI_MEMORY_SUBCLASS_GUID; + + + +/* eof - DataHubRecords.c */ diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h new file mode 100644 index 0000000000..baaf1819cc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h @@ -0,0 +1,109 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHubRecords.h + +Abstract: + + This file defines GUIDs and associated data structures for records + posted to the Data Hub. + The producers of these records use these definitions to construct + records. + The consumers of these records use these definitions to retrieve, + filter and parse records. + + For more information please look at DataHub.doc + +--*/ + +#ifndef _DATAHUB_RECORDS_H_ +#define _DATAHUB_RECORDS_H_ + + +#include "EfiInternalFormRepresentation.h" +#include "DataHubSubClass.h" +#include "DataHubSubClassProcessor.h" +#include "DataHubSubClassCache.h" +#include "DataHubSubClassMemory.h" +#include "DataHubSubClassMisc.h" + +/*++ +BEGIN: Processor records definitions +--*/ + +extern EFI_GUID gProcessorProducerGuid; + +#define EFI_PROCESSOR_PRODUCER_GUID \ + { 0x1bf06aea, 0x5bec, 0x4a8d, 0x95, 0x76, 0x74, 0x9b, 0x09, 0x56, 0x2d, 0x30 } + + +extern EFI_GUID gProcessorSubClassName; + + +extern EFI_GUID gCacheSubClassName; + + +extern EFI_GUID gMiscSubClassName; + +/*++ +END: Processor records definitions +--*/ + + + +/*++ +BEGIN: Memory records definitions +--*/ + +extern EFI_GUID gMemoryProducerGuid; + +#define EFI_MEMORY_PRODUCER_GUID \ + { 0x1d7add6e, 0xb2da, 0x4b0b, 0xb2, 0x9f, 0x49, 0xcb, 0x42, 0xf4, 0x63, 0x56 } + +// +// ... need memory sub classes here... +// +extern EFI_GUID gEfiMemorySubClassGuid; + + + +/*++ +END: Memory records definitions +--*/ + + +/*++ +BEGIN: Misc records definitions +--*/ + +extern EFI_GUID gMiscProducerGuid; + +#define EFI_MISC_PRODUCER_GUID \ +{ 0x62512c92, 0x63c4, 0x4d80, 0x82, 0xb1, 0xc1, 0xa4, 0xdc, 0x44, 0x80, 0xe5 } + + + +// +// ... need misc sub classes here... +// +extern EFI_GUID gEfiMiscSubClassGuid; + + + + +/*++ +END: Misc records definitions +--*/ + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h new file mode 100644 index 0000000000..19b3c38c7a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h @@ -0,0 +1,73 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHubSubClass.h + +Abstract: + + Definitions for data hub data records that contains a sub class header + +Revision History + +--*/ + +#ifndef _DATA_HUB_SUBCLASS_H_ +#define _DATA_HUB_SUBCLASS_H_ + +// +// Sub Class Header type1 +// + +#define EFI_SUBCLASS_INSTANCE_RESERVED 0 +#define EFI_SUBCLASS_INSTANCE_NON_APPLICABLE 0xFFFF //16 bit + +typedef struct { + UINT32 Version; + UINT32 HeaderSize; + UINT16 Instance; + UINT16 SubInstance; + UINT32 RecordType; +} EFI_SUBCLASS_TYPE1_HEADER; + +// +// EXP data +// + +typedef struct { + INT16 Value; + INT16 Exponent; +} EFI_EXP_BASE10_DATA; + +typedef struct { + UINT16 Value; + UINT16 Exponent; +} EFI_EXP_BASE2_DATA; + +// +// Inter link data that references another data record +// + +typedef struct { + EFI_GUID ProducerName; + UINT16 Instance; + UINT16 SubInstance; +} EFI_INTER_LINK_DATA; + + +// +// String Token Definition +// +#define EFI_STRING_TOKEN UINT16 + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h new file mode 100644 index 0000000000..0e7ed3212d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h @@ -0,0 +1,151 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHubSubClassCache.h + +Abstract: + + Definitions for Cache sub class data records + +Revision History + +--*/ + +#ifndef _DATAHUB_SUBCLASS_CACHE_H_ +#define _DATAHUB_SUBCLASS_CACHE_H_ + +#define EFI_CACHE_SUBCLASS_VERSION 0x00010000 + +#define EFI_CACHE_SUBCLASS_GUID \ +{ 0x7f0013a7, 0xdc79, 0x4b22, 0x80, 0x99, 0x11, 0xf7, 0x5f, 0xdc, 0x82, 0x9d } + +typedef EFI_EXP_BASE2_DATA EFI_CACHE_SIZE_DATA; + +typedef EFI_EXP_BASE2_DATA EFI_MAXIMUM_CACHE_SIZE_DATA; + +typedef EFI_EXP_BASE10_DATA EFI_CACHE_SPEED_DATA; + +typedef STRING_REF EFI_CACHE_SOCKET_DATA; + +typedef struct { + UINT32 Other :1; + UINT32 Unknown :1; + UINT32 NonBurst :1; + UINT32 Burst :1; + UINT32 PipelineBurst :1; + UINT32 Asynchronous :1; + UINT32 Synchronous :1; + UINT32 Reserved :25; +} EFI_CACHE_SRAM_TYPE_DATA; + +typedef enum { + EfiCacheErrorOther = 1, + EfiCacheErrorUnknown = 2, + EfiCacheErrorNone = 3, + EfiCacheErrorParity = 4, + EfiCacheErrorSingleBit = 5, + EfiCacheErrorMultiBit = 6 +} EFI_CACHE_ERROR_TYPE_DATA; + +typedef enum { + EfiCacheTypeOther = 1, + EfiCacheTypeUnknown = 2, + EfiCacheTypeInstruction = 3, + EfiCacheTypeData = 4, + EfiCacheTypeUnified = 5 +} EFI_CACHE_TYPE_DATA; + +typedef enum { + EfiCacheAssociativityOther = 1, + EfiCacheAssociativityUnknown = 2, + EfiCacheAssociativityDirectMapped = 3, + EfiCacheAssociativity2Way = 4, + EfiCacheAssociativity4Way = 5, + EfiCacheAssociativityFully = 6, + EfiCacheAssociativity8Way = 7, + EfiCacheAssociativity16Way = 8 +} EFI_CACHE_ASSOCIATIVITY_DATA; + +typedef struct { + UINT32 Level :3; + UINT32 Socketed :1; + UINT32 Reserved2 :1; + UINT32 Location :2; + UINT32 Enable :1; + UINT32 OperationalMode :2; + UINT32 Reserved1 :22; +} EFI_CACHE_CONFIGURATION_DATA; + +#define EFI_CACHE_L1 1 +#define EFI_CACHE_L2 2 +#define EFI_CACHE_L3 3 +#define EFI_CACHE_L4 4 +#define EFI_CACHE_LMAX EFI_CACHE_L4 + +#define EFI_CACHE_SOCKETED 1 +#define EFI_CACHE_NOT_SOCKETED 0 + +typedef enum { + EfiCacheInternal = 0, + EfiCacheExternal = 1, + EfiCacheReserved = 2, + EfiCacheUnknown = 3 +} EFI_CACHE_LOCATION; + +#define EFI_CACHE_ENABLED 1 +#define EFI_CACHE_DISABLED 0 + +typedef enum { + EfiCacheWriteThrough = 0, + EfiCacheWriteBack = 1, + EfiCacheDynamicMode = 2, + EfiCacheUnknownMode = 3 +} EFI_CACHE_OPERATIONAL_MODE; + + + +typedef enum { + CacheSizeRecordType = 1, + MaximumSizeCacheRecordType = 2, + CacheSpeedRecordType = 3, + CacheSocketRecordType = 4, + CacheSramTypeRecordType = 5, + CacheInstalledSramTypeRecordType = 6, + CacheErrorTypeRecordType = 7, + CacheTypeRecordType = 8, + CacheAssociativityRecordType = 9, + CacheConfigRecordType = 10 +} EFI_CACHE_VARIABLE_RECORD_TYPE; + + +typedef union { + EFI_CACHE_SIZE_DATA CacheSize; + EFI_MAXIMUM_CACHE_SIZE_DATA MaximumCacheSize; + EFI_CACHE_SPEED_DATA CacheSpeed; + EFI_CACHE_SOCKET_DATA CacheSocket; + EFI_CACHE_SRAM_TYPE_DATA CacheSramType; + EFI_CACHE_SRAM_TYPE_DATA CacheInstalledSramType; + EFI_CACHE_ERROR_TYPE_DATA CacheErrorType; + EFI_CACHE_TYPE_DATA CacheType; + EFI_CACHE_ASSOCIATIVITY_DATA CacheAssociativity; + EFI_CACHE_CONFIGURATION_DATA CacheConfig; + EFI_CACHE_ASSOCIATION_DATA CacheAssociation; +} EFI_CACHE_VARIABLE_RECORD; + +typedef struct { + EFI_SUBCLASS_TYPE1_HEADER DataRecordHeader; + EFI_CACHE_VARIABLE_RECORD VariableRecord; +} EFI_CACHE_DATA_RECORD; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h new file mode 100644 index 0000000000..2ab674324d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h @@ -0,0 +1,408 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHubSubClassMemory.h + +Abstract: + + Definitions for memory sub class data records + +Revision History + +--*/ + +#ifndef _DATAHUB_SUBCLASS_MEMORY_H_ +#define _DATAHUB_SUBCLASS_MEMORY_H_ + +#include EFI_GUID_DEFINITION (DataHubRecords) + + +#define EFI_MEMORY_SUBCLASS_GUID \ + {0x4E8F4EBB, 0x64B9, 0x4e05, 0x9B, 0x18, 0x4C, 0xFE, 0x49, 0x23, 0x50, 0x97} + +#define EFI_MEMORY_SUBCLASS_VERSION 0x0100 + + +#define EFI_MEMORY_SIZE_RECORD_NUMBER 0x00000001 + +typedef enum _EFI_MEMORY_REGION_TYPE { + EfiMemoryRegionMemory = 0x01, + EfiMemoryRegionReserved = 0x02, + EfiMemoryRegionAcpi = 0x03, + EfiMemoryRegionNvs = 0x04 +} EFI_MEMORY_REGION_TYPE; + +typedef struct { + UINT32 ProcessorNumber; + UINT16 StartBusNumber; + UINT16 EndBusNumber; + EFI_MEMORY_REGION_TYPE MemoryRegionType; + EFI_EXP_BASE2_DATA MemorySize; + EFI_PHYSICAL_ADDRESS MemoryStartAddress; +} EFI_MEMORY_SIZE_DATA; + + +#define EFI_MEMORY_ARRAY_LOCATION_RECORD_NUMBER 0x00000002 + +typedef enum _EFI_MEMORY_ARRAY_LOCATION { + EfiMemoryArrayLocationOther = 0x01, + EfiMemoryArrayLocationUnknown = 0x02, + EfiMemoryArrayLocationSystemBoard = 0x03, + EfiMemoryArrayLocationIsaAddonCard = 0x04, + EfiMemoryArrayLocationEisaAddonCard = 0x05, + EfiMemoryArrayLocationPciAddonCard = 0x06, + EfiMemoryArrayLocationMcaAddonCard = 0x07, + EfiMemoryArrayLocationPcmciaAddonCard = 0x08, + EfiMemoryArrayLocationProprietaryAddonCard = 0x09, + EfiMemoryArrayLocationNuBus = 0x0A, + EfiMemoryArrayLocationPc98C20AddonCard = 0xA0, + EfiMemoryArrayLocationPc98C24AddonCard = 0xA1, + EfiMemoryArrayLocationPc98EAddonCard = 0xA2, + EfiMemoryArrayLocationPc98LocalBusAddonCard = 0xA3 +} EFI_MEMORY_ARRAY_LOCATION; + +typedef enum _EFI_MEMORY_ARRAY_USE { + EfiMemoryArrayUseOther = 0x01, + EfiMemoryArrayUseUnknown = 0x02, + EfiMemoryArrayUseSystemMemory = 0x03, + EfiMemoryArrayUseVideoMemory = 0x04, + EfiMemoryArrayUseFlashMemory = 0x05, + EfiMemoryArrayUseNonVolatileRam = 0x06, + EfiMemoryArrayUseCacheMemory = 0x07, +} EFI_MEMORY_ARRAY_USE; + +typedef enum _EFI_MEMORY_ERROR_CORRECTION { + EfiMemoryErrorCorrectionOther = 0x01, + EfiMemoryErrorCorrectionUnknown = 0x02, + EfiMemoryErrorCorrectionNone = 0x03, + EfiMemoryErrorCorrectionParity = 0x04, + EfiMemoryErrorCorrectionSingleBitEcc = 0x05, + EfiMemoryErrorCorrectionMultiBitEcc = 0x06, + EfiMemoryErrorCorrectionCrc = 0x07, +} EFI_MEMORY_ERROR_CORRECTION; + +typedef struct { + EFI_MEMORY_ARRAY_LOCATION MemoryArrayLocation; + EFI_MEMORY_ARRAY_USE MemoryArrayUse; + EFI_MEMORY_ERROR_CORRECTION MemoryErrorCorrection; + UINT32 MaximumMemoryCapacity; + UINT16 NumberMemoryDevices; +} EFI_MEMORY_ARRAY_LOCATION_DATA; + + +#define EFI_MEMORY_ARRAY_LINK_RECORD_NUMBER 0x00000003 + +typedef enum _EFI_MEMORY_FORM_FACTOR { + EfiMemoryFormFactorOther = 0x01, + EfiMemoryFormFactorUnknown = 0x02, + EfiMemoryFormFactorSimm = 0x03, + EfiMemoryFormFactorSip = 0x04, + EfiMemoryFormFactorChip = 0x05, + EfiMemoryFormFactorDip = 0x06, + EfiMemoryFormFactorZip = 0x07, + EfiMemoryFormFactorProprietaryCard = 0x08, + EfiMemoryFormFactorDimm = 0x09, + EfiMemoryFormFactorTsop = 0x0A, + EfiMemoryFormFactorRowOfChips = 0x0B, + EfiMemoryFormFactorRimm = 0x0C, + EfiMemoryFormFactorSodimm = 0x0D, + EfiMemoryFormFactorSrimm = 0x0E, + EfiMemoryFormFactorFbDimm = 0x0F +} EFI_MEMORY_FORM_FACTOR; + +typedef enum _EFI_MEMORY_ARRAY_TYPE { + EfiMemoryTypeOther = 0x01, + EfiMemoryTypeUnknown = 0x02, + EfiMemoryTypeDram = 0x03, + EfiMemoryTypeEdram = 0x04, + EfiMemoryTypeVram = 0x05, + EfiMemoryTypeSram = 0x06, + EfiMemoryTypeRam = 0x07, + EfiMemoryTypeRom = 0x08, + EfiMemoryTypeFlash = 0x09, + EfiMemoryTypeEeprom = 0x0A, + EfiMemoryTypeFeprom = 0x0B, + EfiMemoryTypeEprom = 0x0C, + EfiMemoryTypeCdram = 0x0D, + EfiMemoryType3Dram = 0x0E, + EfiMemoryTypeSdram = 0x0F, + EfiMemoryTypeSgram = 0x10, + EfiMemoryTypeRdram = 0x11, + EfiMemoryTypeDdr = 0x12, + EfiMemoryTypeDdr2 = 0x13, + EfiMemoryTypeDdr2FbDimm = 0x14 +} EFI_MEMORY_ARRAY_TYPE; + +typedef struct { + UINT32 Reserved :1; + UINT32 Other :1; + UINT32 Unknown :1; + UINT32 FastPaged :1; + UINT32 StaticColumn :1; + UINT32 PseudoStatic :1; + UINT32 Rambus :1; + UINT32 Synchronous :1; + UINT32 Cmos :1; + UINT32 Edo :1; + UINT32 WindowDram :1; + UINT32 CacheDram :1; + UINT32 Nonvolatile :1; + UINT32 Reserved1 :19; +} EFI_MEMORY_TYPE_DETAIL; + +typedef enum { + EfiMemoryStateEnabled =0, + EfiMemoryStateUnknown, + EfiMemoryStateUnsupported, + EfiMemoryStateError, + EfiMemoryStateAbsent, + EfiMemoryStateDisabled, + EfiMemoryStatePartial +} EFI_MEMORY_STATE; + +typedef struct { + EFI_STRING_TOKEN MemoryDeviceLocator; + EFI_STRING_TOKEN MemoryBankLocator; + EFI_STRING_TOKEN MemoryManufacturer; + EFI_STRING_TOKEN MemorySerialNumber; + EFI_STRING_TOKEN MemoryAssetTag; + EFI_STRING_TOKEN MemoryPartNumber; + EFI_INTER_LINK_DATA MemoryArrayLink; + EFI_INTER_LINK_DATA MemorySubArrayLink; + UINT16 MemoryTotalWidth; + UINT16 MemoryDataWidth; + UINT64 MemoryDeviceSize; + EFI_MEMORY_FORM_FACTOR MemoryFormFactor; + UINT8 MemoryDeviceSet; + EFI_MEMORY_ARRAY_TYPE MemoryType; + EFI_MEMORY_TYPE_DETAIL MemoryTypeDetail; + UINT16 MemorySpeed; + EFI_MEMORY_STATE MemoryState; +} EFI_MEMORY_ARRAY_LINK; + + +#define EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER 0x00000004 + +typedef struct { + EFI_PHYSICAL_ADDRESS MemoryArrayStartAddress; + EFI_PHYSICAL_ADDRESS MemoryArrayEndAddress; + EFI_INTER_LINK_DATA PhysicalMemoryArrayLink; + UINT16 MemoryArrayPartitionWidth; +} EFI_MEMORY_ARRAY_START_ADDRESS; + + +#define EFI_MEMORY_DEVICE_START_ADDRESS_RECORD_NUMBER 0x00000005 + +typedef struct { + EFI_PHYSICAL_ADDRESS MemoryDeviceStartAddress; + EFI_PHYSICAL_ADDRESS MemoryDeviceEndAddress; + EFI_INTER_LINK_DATA PhysicalMemoryDeviceLink; + EFI_INTER_LINK_DATA PhysicalMemoryArrayLink; + UINT8 MemoryDevicePartitionRowPosition; + UINT8 MemoryDeviceInterleavePosition; + UINT8 MemoryDeviceInterleaveDataDepth; +} EFI_MEMORY_DEVICE_START_ADDRESS; + + +// +// Memory. Channel Device Type - SMBIOS Type 37 +// + +#define EFI_MEMORY_CHANNEL_TYPE_RECORD_NUMBER 0x00000006 + +typedef enum _EFI_MEMORY_CHANNEL_TYPE { + EfiMemoryChannelTypeOther = 1, + EfiMemoryChannelTypeUnknown = 2, + EfiMemoryChannelTypeRambus = 3, + EfiMemoryChannelTypeSyncLink = 4 +} EFI_MEMORY_CHANNEL_TYPE; + +typedef struct { + EFI_MEMORY_CHANNEL_TYPE MemoryChannelType; + UINT8 MemoryChannelMaximumLoad; + UINT8 MemoryChannelDeviceCount; +} EFI_MEMORY_CHANNEL_TYPE_DATA; + +#define EFI_MEMORY_CHANNEL_DEVICE_RECORD_NUMBER 0x00000007 + +typedef struct { + UINT8 DeviceId; + EFI_INTER_LINK_DATA DeviceLink; + UINT8 MemoryChannelDeviceLoad; +} EFI_MEMORY_CHANNEL_DEVICE_DATA; + +// +// Memory. Controller Information - SMBIOS Type 5 +// +#define EFI_MEMORY_CONTROLLER_INFORMATION_RECORD_NUMBER 0x00000008 + +typedef enum { + EfiErrorDetectingMethodOther = 1, + EfiErrorDetectingMethodUnknown = 2, + EfiErrorDetectingMethodNone = 3, + EfiErrorDetectingMethodParity = 4, + EfiErrorDetectingMethod32Ecc = 5, + EfiErrorDetectingMethod64Ecc = 6, + EfiErrorDetectingMethod128Ecc = 7, + EfiErrorDetectingMethodCrc = 8 +} EFI_MEMORY_ERROR_DETECT_METHOD_TYPE; + +typedef struct { + UINT8 Other :1; + UINT8 Unknown :1; + UINT8 None :1; + UINT8 SingleBitErrorCorrect :1; + UINT8 DoubleBitErrorCorrect :1; + UINT8 ErrorScrubbing :1; + UINT8 Reserved :2; +} EFI_MEMORY_ERROR_CORRECT_CAPABILITY; + +typedef enum { + EfiMemoryInterleaveOther = 1, + EfiMemoryInterleaveUnknown = 2, + EfiMemoryInterleaveOneWay = 3, + EfiMemoryInterleaveTwoWay = 4, + EfiMemoryInterleaveFourWay = 5, + EfiMemoryInterleaveEightWay = 6, + EfiMemoryInterleaveSixteenWay = 7 +} EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE; + +typedef struct { + UINT16 Other :1; + UINT16 Unknown :1; + UINT16 SeventyNs :1; + UINT16 SixtyNs :1; + UINT16 FiftyNs :1; + UINT16 Reserved :11; +} EFI_MEMORY_SPEED_TYPE; + +typedef struct { + UINT16 Other :1; + UINT16 Unknown :1; + UINT16 Standard :1; + UINT16 FastPageMode :1; + UINT16 EDO :1; + UINT16 Parity :1; + UINT16 ECC :1; + UINT16 SIMM :1; + UINT16 DIMM :1; + UINT16 BurstEdo :1; + UINT16 SDRAM :1; + UINT16 Reserved :5; +} EFI_MEMORY_SUPPORTED_TYPE; + +typedef struct { + UINT8 Five :1; + UINT8 There :1; + UINT8 Two :1; + UINT8 Reserved :5; +} EFI_MEMORY_MODULE_VOLTAGE_TYPE; + +typedef struct { + EFI_MEMORY_ERROR_DETECT_METHOD_TYPE ErrorDetectingMethod; + EFI_MEMORY_ERROR_CORRECT_CAPABILITY ErrorCorrectingCapability; + EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemorySupportedInterleave; + EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemoryCurrentInterleave; + UINT8 MaxMemoryModuleSize; + EFI_MEMORY_SPEED_TYPE MemorySpeedType; + EFI_MEMORY_SUPPORTED_TYPE MemorySupportedType; + EFI_MEMORY_MODULE_VOLTAGE_TYPE MemoryModuleVoltage; + UINT8 NumberofMemorySlot; + EFI_MEMORY_ERROR_CORRECT_CAPABILITY EnabledCorrectingCapability; + UINT16 *MemoryModuleConfigHandles; +} EFI_MEMORY_CONTROLLER_INFORMATION; + +// +// Memory. Error Information - SMBIOS Type 18 +// +#define EFI_MEMORY_32BIT_ERROR_INFORMATION_RECORD_NUMBER 0x00000009 + +typedef enum { + EfiMemoryErrorOther = 1, + EfiMemoryErrorUnknown = 2, + EfiMemoryErrorOk = 3, + EfiMemoryErrorBadRead = 4, + EfiMemoryErrorParity = 5, + EfiMemoryErrorSigleBit = 6, + EfiMemoryErrorDoubleBit = 7, + EfiMemoryErrorMultiBit = 8, + EfiMemoryErrorNibble = 9, + EfiMemoryErrorChecksum = 10, + EfiMemoryErrorCrc = 11, + EfiMemoryErrorCorrectSingleBit = 12, + EfiMemoryErrorCorrected = 13, + EfiMemoryErrorUnCorrectable = 14 +} EFI_MEMORY_ERROR_TYPE; + +typedef enum { + EfiMemoryGranularityOther = 1, + EfiMemoryGranularityOtherUnknown = 2, + EfiMemoryGranularityDeviceLevel = 3, + EfiMemoryGranularityMemPartitionLevel = 4 +} EFI_MEMORY_ERROR_GRANULARITY_TYPE; + +typedef enum { + EfiMemoryErrorOperationOther = 1, + EfiMemoryErrorOperationUnknown = 2, + EfiMemoryErrorOperationRead = 3, + EfiMemoryErrorOperationWrite = 4, + EfiMemoryErrorOperationPartialWrite = 5 +} EFI_MEMORY_ERROR_OPERATION_TYPE; + +typedef struct { + EFI_MEMORY_ERROR_TYPE MemoryErrorType; + EFI_MEMORY_ERROR_GRANULARITY_TYPE MemoryErrorGranularity; + EFI_MEMORY_ERROR_OPERATION_TYPE MemoryErrorOperation; + UINT32 VendorSyndrome; + UINT32 MemoryArrayErrorAddress; + UINT32 DeviceErrorAddress; + UINT32 DeviceErrorResolution; +} EFI_MEMORY_32BIT_ERROR_INFORMATION; + +// +// Memory. Error Information - SMBIOS Type 33 +// +#define EFI_MEMORY_64BIT_ERROR_INFORMATION_RECORD_NUMBER 0x0000000A + +typedef struct { + EFI_MEMORY_ERROR_TYPE MemoryErrorType; + EFI_MEMORY_ERROR_GRANULARITY_TYPE MemoryErrorGranularity; + EFI_MEMORY_ERROR_OPERATION_TYPE MemoryErrorOperation; + UINT32 VendorSyndrome; + UINT64 MemoryArrayErrorAddress; + UINT64 DeviceErrorAddress; + UINT32 DeviceErrorResolution; +} EFI_MEMORY_64BIT_ERROR_INFORMATION; + + +typedef union _EFI_MEMORY_SUBCLASS_RECORDS { + EFI_MEMORY_SIZE_DATA SizeData; + EFI_MEMORY_ARRAY_LOCATION_DATA ArrayLocationData; + EFI_MEMORY_ARRAY_LINK ArrayLink; + EFI_MEMORY_ARRAY_START_ADDRESS ArrayStartAddress; + EFI_MEMORY_DEVICE_START_ADDRESS DeviceStartAddress; + EFI_MEMORY_CHANNEL_TYPE_DATA ChannelTypeData; + EFI_MEMORY_CHANNEL_DEVICE_DATA ChannelDeviceData; + EFI_MEMORY_CONTROLLER_INFORMATION MemoryControllerInfo; + EFI_MEMORY_32BIT_ERROR_INFORMATION Memory32bitErrorInfo; + EFI_MEMORY_64BIT_ERROR_INFORMATION Memory64bitErrorInfo; +} EFI_MEMORY_SUBCLASS_RECORDS; + +typedef struct { + EFI_SUBCLASS_TYPE1_HEADER Header; + EFI_MEMORY_SUBCLASS_RECORDS Record; +} EFI_MEMORY_SUBCLASS_DRIVER_DATA; + + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h new file mode 100644 index 0000000000..901a464487 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h @@ -0,0 +1,1130 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHubSubClassMisc.h + +Abstract: + + Definitions for Misc sub class data records + +Revision History + +--*/ + +#ifndef _DATAHUB_SUBCLASS_MISC_H_ +#define _DATAHUB_SUBCLASS_MISC_H_ + +#include EFI_GUID_DEFINITION(DataHubRecords) + +#define EFI_MISC_SUBCLASS_GUID \ +{ 0x772484B2, 0x7482, 0x4b91, 0x9F, 0x9A, 0xAD, 0x43, 0xF8, 0x1C, 0x58, 0x81 } + +#define EFI_MISC_SUBCLASS_VERSION 0x0100 + +#pragma pack(1) +// +////////////////////////////////////////////////////////////////////////////// +// +// Last PCI Bus Number +// +#define EFI_MISC_LAST_PCI_BUS_RECORD_NUMBER 0x00000001 + +typedef struct { + UINT8 LastPciBus; +} EFI_MISC_LAST_PCI_BUS; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. BIOS Vendor - SMBIOS Type 0 +// +#define EFI_MISC_BIOS_VENDOR_RECORD_NUMBER 0x00000002 + +typedef struct { + UINT32 Reserved1 :2; + UINT32 Unknown :1; + UINT32 BiosCharacteristicsNotSupported :1; + UINT32 IsaIsSupported :1; + UINT32 McaIsSupported :1; + UINT32 EisaIsSupported :1; + UINT32 PciIsSupported :1; + UINT32 PcmciaIsSupported :1; + UINT32 PlugAndPlayIsSupported :1; + UINT32 ApmIsSupported :1; + UINT32 BiosIsUpgradable :1; + UINT32 BiosShadowingAllowed :1; + UINT32 VlVesaIsSupported :1; + UINT32 EscdSupportIsAvailable :1; + UINT32 BootFromCdIsSupported :1; + UINT32 SelectableBootIsSupported :1; + UINT32 RomBiosIsSocketed :1; + UINT32 BootFromPcmciaIsSupported :1; + UINT32 EDDSpecificationIsSupported :1; + UINT32 JapaneseNecFloppyIsSupported :1; + UINT32 JapaneseToshibaFloppyIsSupported :1; + UINT32 Floppy525_360IsSupported :1; + UINT32 Floppy525_12IsSupported :1; + UINT32 Floppy35_720IsSupported :1; + UINT32 Floppy35_288IsSupported :1; + UINT32 PrintScreenIsSupported :1; + UINT32 Keyboard8042IsSupported :1; + UINT32 SerialIsSupported :1; + UINT32 PrinterIsSupported :1; + UINT32 CgaMonoIsSupported :1; + UINT32 NecPc98 :1; + UINT32 AcpiIsSupported :1; + UINT32 UsbLegacyIsSupported :1; + UINT32 AgpIsSupported :1; + UINT32 I20BootIsSupported :1; + UINT32 Ls120BootIsSupported :1; + UINT32 AtapiZipDriveBootIsSupported :1; + UINT32 Boot1394IsSupported :1; + UINT32 SmartBatteryIsSupported :1; + UINT32 BiosBootSpecIsSupported :1; + UINT32 FunctionKeyNetworkBootIsSupported :1; + UINT32 TargetContentDistributionEnabled :1; + UINT32 Reserved :21; +} EFI_MISC_BIOS_CHARACTERISTICS; + +typedef struct { + UINT32 BiosReserved :16; + UINT32 SystemReserved :16; + UINT32 Reserved :32; +} EFI_MISC_BIOS_CHARACTERISTICS_EXTENSION; + +typedef struct { + STRING_REF BiosVendor; + STRING_REF BiosVersion; + STRING_REF BiosReleaseDate; + EFI_PHYSICAL_ADDRESS BiosStartingAddress; + EFI_EXP_BASE2_DATA BiosPhysicalDeviceSize; + EFI_MISC_BIOS_CHARACTERISTICS BiosCharacteristics1; + EFI_MISC_BIOS_CHARACTERISTICS_EXTENSION BiosCharacteristics2; + UINT8 BiosMajorRelease; + UINT8 BiosMinorRelease; + UINT8 BiosEmbeddedFirmwareMajorRelease; + UINT8 BiosEmbeddedFirmwareMinorRelease; +} EFI_MISC_BIOS_VENDOR; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. System Manufacturer - SMBIOS Type 1 +// +#define EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER 0x00000003 + +typedef enum { + EfiSystemWakeupTypeReserved = 0, + EfiSystemWakeupTypeOther = 1, + EfiSystemWakeupTypeUnknown = 2, + EfiSystemWakeupTypeApmTimer = 3, + EfiSystemWakeupTypeModemRing = 4, + EfiSystemWakeupTypeLanRemote = 5, + EfiSystemWakeupTypePowerSwitch = 6, + EfiSystemWakeupTypePciPme = 7, + EfiSystemWakeupTypeAcPowerRestored = 8, +} EFI_MISC_SYSTEM_WAKEUP_TYPE; + +typedef struct { + STRING_REF SystemManufacturer; + STRING_REF SystemProductName; + STRING_REF SystemVersion; + STRING_REF SystemSerialNumber; + EFI_GUID SystemUuid; + EFI_MISC_SYSTEM_WAKEUP_TYPE SystemWakeupType; + STRING_REF SystemSKUNumber; + STRING_REF SystemFamily; +} EFI_MISC_SYSTEM_MANUFACTURER; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Base Board Manufacturer - SMBIOS Type 2 +// +#define EFI_MISC_BASE_BOARD_MANUFACTURER_RECORD_NUMBER 0x00000004 + +typedef struct { + UINT32 Motherboard :1; + UINT32 RequiresDaughterCard :1; + UINT32 Removable :1; + UINT32 Replaceable :1; + UINT32 HotSwappable :1; + UINT32 Reserved :27; +} EFI_BASE_BOARD_FEATURE_FLAGS; + +typedef enum { + EfiBaseBoardTypeUnknown = 1, + EfiBaseBoardTypeOther = 2, + EfiBaseBoardTypeServerBlade = 3, + EfiBaseBoardTypeConnectivitySwitch = 4, + EfiBaseBoardTypeSystemManagementModule = 5, + EfiBaseBoardTypeProcessorModule = 6, + EfiBaseBoardTypeIOModule = 7, + EfiBaseBoardTypeMemoryModule = 8, + EfiBaseBoardTypeDaughterBoard = 9, + EfiBaseBoardTypeMotherBoard = 0xA, + EfiBaseBoardTypeProcessorMemoryModule = 0xB, + EfiBaseBoardTypeProcessorIOModule = 0xC, + EfiBaseBoardTypeInterconnectBoard = 0xD, +} EFI_BASE_BOARD_TYPE; + +typedef struct { + STRING_REF BaseBoardManufacturer; + STRING_REF BaseBoardProductName; + STRING_REF BaseBoardVersion; + STRING_REF BaseBoardSerialNumber; + STRING_REF BaseBoardAssetTag; + STRING_REF BaseBoardChassisLocation; + EFI_BASE_BOARD_FEATURE_FLAGS BaseBoardFeatureFlags; + EFI_BASE_BOARD_TYPE BaseBoardType; + EFI_INTER_LINK_DATA BaseBoardChassisLink; + UINT32 BaseBoardNumberLinks; + EFI_INTER_LINK_DATA LinkN; +} EFI_MISC_BASE_BOARD_MANUFACTURER; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. System/Chassis Enclosure - SMBIOS Type 3 +// +#define EFI_MISC_CHASSIS_MANUFACTURER_RECORD_NUMBER 0x00000005 + +typedef enum { + EfiMiscChassisTypeOther = 0x1, + EfiMiscChassisTypeUnknown = 0x2, + EfiMiscChassisTypeDeskTop = 0x3, + EfiMiscChassisTypeLowProfileDesktop = 0x4, + EfiMiscChassisTypePizzaBox = 0x5, + EfiMiscChassisTypeMiniTower = 0x6, + EfiMiscChassisTypeTower = 0x7, + EfiMiscChassisTypePortable = 0x8, + EfiMiscChassisTypeLapTop = 0x9, + EfiMiscChassisTypeNotebook = 0xA, + EfiMiscChassisTypeHandHeld = 0xB, + EfiMiscChassisTypeDockingStation = 0xC, + EfiMiscChassisTypeAllInOne = 0xD, + EfiMiscChassisTypeSubNotebook = 0xE, + EfiMiscChassisTypeSpaceSaving = 0xF, + EfiMiscChassisTypeLunchBox = 0x10, + EfiMiscChassisTypeMainServerChassis = 0x11, + EfiMiscChassisTypeExpansionChassis = 0x12, + EfiMiscChassisTypeSubChassis = 0x13, + EfiMiscChassisTypeBusExpansionChassis = 0x14, + EfiMiscChassisTypePeripheralChassis = 0x15, + EfiMiscChassisTypeRaidChassis = 0x16, + EfiMiscChassisTypeRackMountChassis = 0x17, + EfiMiscChassisTypeSealedCasePc = 0x18, + EfiMiscChassisMultiSystemChassis = 0x19, +} EFI_MISC_CHASSIS_TYPE; + +typedef struct { + UINT32 ChassisType :16; + UINT32 ChassisLockPresent:1; + UINT32 Reserved :15; +} EFI_MISC_CHASSIS_STATUS; + +typedef enum { + EfiChassisStateOther = 1, + EfiChassisStateUnknown = 2, + EfiChassisStateSafe = 3, + EfiChassisStateWarning = 4, + EfiChassisStateCritical = 5, + EfiChassisStateNonRecoverable = 6, +} EFI_MISC_CHASSIS_STATE; + +typedef enum { + EfiChassisSecurityStatusOther = 1, + EfiChassisSecurityStatusUnknown = 2, + EfiChassisSecurityStatusNone = 3, + EfiChassisSecurityStatusExternalInterfaceLockedOut = 4, + EfiChassisSecurityStatusExternalInterfaceLockedEnabled = 5, +} EFI_MISC_CHASSIS_SECURITY_STATE; + +typedef struct { + UINT32 RecordType :1; + UINT32 Reserved :24; +} EFI_MISC_ELEMENT_TYPE; + +typedef struct { + EFI_MISC_ELEMENT_TYPE ChassisElementType; + EFI_INTER_LINK_DATA ChassisElementStructure; + EFI_BASE_BOARD_TYPE ChassisBaseBoard; + UINT32 ChassisElementMinimum; + UINT32 ChassisElementMaximum; +} EFI_MISC_ELEMENTS; + +typedef struct { + STRING_REF ChassisManufacturer; + STRING_REF ChassisVersion; + STRING_REF ChassisSerialNumber; + STRING_REF ChassisAssetTag; + EFI_MISC_CHASSIS_STATUS ChassisType; + EFI_MISC_CHASSIS_STATE ChassisBootupState; + EFI_MISC_CHASSIS_STATE ChassisPowerSupplyState; + EFI_MISC_CHASSIS_STATE ChassisThermalState; + EFI_MISC_CHASSIS_SECURITY_STATE ChassisSecurityState; + UINT32 ChassisOemDefined; + UINT32 ChassisHeight; + UINT32 ChassisNumberPowerCords; + UINT32 ChassisElementCount; + UINT32 ChassisElementRecordLength;// + EFI_MISC_ELEMENTS ChassisElements; +} EFI_MISC_CHASSIS_MANUFACTURER; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Port Connector Information - SMBIOS Type 8 +// +#define EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER 0x00000006 + +typedef enum { + EfiPortConnectorTypeNone = 0x0, + EfiPortConnectorTypeCentronics = 0x1, + EfiPortConnectorTypeMiniCentronics = 0x2, + EfiPortConnectorTypeProprietary = 0x3, + EfiPortConnectorTypeDB25Male = 0x4, + EfiPortConnectorTypeDB25Female = 0x5, + EfiPortConnectorTypeDB15Male = 0x6, + EfiPortConnectorTypeDB15Female = 0x7, + EfiPortConnectorTypeDB9Male = 0x8, + EfiPortConnectorTypeDB9Female = 0x9, + EfiPortConnectorTypeRJ11 = 0xA, + EfiPortConnectorTypeRJ45 = 0xB, + EfiPortConnectorType50PinMiniScsi = 0xC, + EfiPortConnectorTypeMiniDin = 0xD, + EfiPortConnectorTypeMicriDin = 0xE, + EfiPortConnectorTypePS2 = 0xF, + EfiPortConnectorTypeInfrared = 0x10, + EfiPortConnectorTypeHpHil = 0x11, + EfiPortConnectorTypeUsb = 0x12, + EfiPortConnectorTypeSsaScsi = 0x13, + EfiPortConnectorTypeCircularDin8Male = 0x14, + EfiPortConnectorTypeCircularDin8Female = 0x15, + EfiPortConnectorTypeOnboardIde = 0x16, + EfiPortConnectorTypeOnboardFloppy = 0x17, + EfiPortConnectorType9PinDualInline = 0x18, + EfiPortConnectorType25PinDualInline = 0x19, + EfiPortConnectorType50PinDualInline = 0x1A, + EfiPortConnectorType68PinDualInline = 0x1B, + EfiPortConnectorTypeOnboardSoundInput = 0x1C, + EfiPortConnectorTypeMiniCentronicsType14 = 0x1D, + EfiPortConnectorTypeMiniCentronicsType26 = 0x1E, + EfiPortConnectorTypeHeadPhoneMiniJack = 0x1F, + EfiPortConnectorTypeBNC = 0x20, + EfiPortConnectorType1394 = 0x21, + EfiPortConnectorTypePC98 = 0xA0, + EfiPortConnectorTypePC98Hireso = 0xA1, + EfiPortConnectorTypePCH98 = 0xA2, + EfiPortConnectorTypePC98Note = 0xA3, + EfiPortConnectorTypePC98Full = 0xA4, + EfiPortConnectorTypeOther = 0xFF, +} EFI_MISC_PORT_CONNECTOR_TYPE; + +typedef enum { + EfiPortTypeNone = 0x0, + EfiPortTypeParallelXtAtCompatible = 0x1, + EfiPortTypeParallelPortPs2 = 0x2, + EfiPortTypeParallelPortEcp = 0x3, + EfiPortTypeParallelPortEpp = 0x4, + EfiPortTypeParallelPortEcpEpp = 0x5, + EfiPortTypeSerialXtAtCompatible = 0x6, + EfiPortTypeSerial16450Compatible = 0x7, + EfiPortTypeSerial16550Compatible = 0x8, + EfiPortTypeSerial16550ACompatible = 0x9, + EfiPortTypeScsi = 0xA, + EfiPortTypeMidi = 0xB, + EfiPortTypeJoyStick = 0xC, + EfiPortTypeKeyboard = 0xD, + EfiPortTypeMouse = 0xE, + EfiPortTypeSsaScsi = 0xF, + EfiPortTypeUsb = 0x10, + EfiPortTypeFireWire = 0x11, + EfiPortTypePcmciaTypeI = 0x12, + EfiPortTypePcmciaTypeII = 0x13, + EfiPortTypePcmciaTypeIII = 0x14, + EfiPortTypeCardBus = 0x15, + EfiPortTypeAccessBusPort = 0x16, + EfiPortTypeScsiII = 0x17, + EfiPortTypeScsiWide = 0x18, + EfiPortTypePC98 = 0x19, + EfiPortTypePC98Hireso = 0x1A, + EfiPortTypePCH98 = 0x1B, + EfiPortTypeVideoPort = 0x1C, + EfiPortTypeAudioPort = 0x1D, + EfiPortTypeModemPort = 0x1E, + EfiPortTypeNetworkPort = 0x1F, + EfiPortType8251Compatible = 0xA0, + EfiPortType8251FifoCompatible = 0xA1, + EfiPortTypeOther = 0xFF, +} EFI_MISC_PORT_TYPE; + + +typedef struct { + EFI_STRING_TOKEN PortInternalConnectorDesignator; + EFI_STRING_TOKEN PortExternalConnectorDesignator; + EFI_MISC_PORT_CONNECTOR_TYPE PortInternalConnectorType; + EFI_MISC_PORT_CONNECTOR_TYPE PortExternalConnectorType; + EFI_MISC_PORT_TYPE PortType; + EFI_MISC_PORT_DEVICE_PATH PortPath; +} EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. System Slots - SMBIOS Type 9 +// +#define EFI_MISC_SYSTEM_SLOT_DESIGNATION_RECORD_NUMBER 0x00000007 + +typedef enum { + EfiSlotTypeOther = 0x1, + EfiSlotTypeUnknown = 0x2, + EfiSlotTypeIsa = 0x3, + EfiSlotTypeMca = 0x4, + EfiSlotTypeEisa = 0x5, + EfiSlotTypePci = 0x6, + EfiSlotTypePcmcia = 0x7, + EfiSlotTypeVlVesa = 0x8, + EfiSlotTypeProprietary = 0x9, + EfiSlotTypeProcessorCardSlot = 0xA, + EfiSlotTypeProprietaryMemoryCardSlot = 0xB, + EfiSlotTypeIORiserCardSlot = 0xC, + EfiSlotTypeNuBus = 0xD, + EfiSlotTypePci66MhzCapable = 0xE, + EfiSlotTypeAgp = 0xF, + EfiSlotTypeApg2X = 0x10, + EfiSlotTypeAgp4X = 0x11, + EfiSlotTypePciX = 0x12, + EfiSlotTypeAgp4x = 0x13, + EfiSlotTypePC98C20 = 0xA0, + EfiSlotTypePC98C24 = 0xA1, + EfiSlotTypePC98E = 0xA2, + EfiSlotTypePC98LocalBus = 0xA3, + EfiSlotTypePC98Card = 0xA4, + EfiSlotTypePciExpress = 0xA5, +} EFI_MISC_SLOT_TYPE; + +typedef enum { + EfiSlotDataBusWidthOther = 1, + EfiSlotDataBusWidthUnknown = 2, + EfiSlotDataBusWidth8Bit = 3, + EfiSlotDataBusWidth16Bit = 4, + EfiSlotDataBusWidth32Bit = 5, + EfiSlotDataBusWidth64Bit = 6, + EfiSlotDataBusWidth128Bit = 7, + EfiSlotDataBusWidth1xOrx1 = 8, + EfiSlotDataBusWidth2xOrx2 = 9, + EfiSlotDataBusWidth4xOrx4 = 0xA, + EfiSlotDataBusWidth8xOrx8 = 0xB, + EfiSlotDataBusWidth12xOrx12 = 0xC, + EfiSlotDataBusWidth16xOrx16 = 0xD, + EfiSlotDataBusWidth32xOrx32 = 0xE, +} EFI_MISC_SLOT_DATA_BUS_WIDTH; + +typedef enum { + EfiSlotUsageOther = 1, + EfiSlotUsageUnknown = 2, + EfiSlotUsageAvailable = 3, + EfiSlotUsageInUse = 4, +} EFI_MISC_SLOT_USAGE; + +typedef enum { + EfiSlotLengthOther = 1, + EfiSlotLengthUnknown = 2, + EfiSlotLengthShort = 3, + EfiSlotLengthLong = 4 +} EFI_MISC_SLOT_LENGTH; + +typedef struct { + UINT32 CharacteristicsUnknown :1; + UINT32 Provides50Volts :1; + UINT32 Provides33Volts :1; + UINT32 SharedSlot :1; + UINT32 PcCard16Supported :1; + UINT32 CardBusSupported :1; + UINT32 ZoomVideoSupported :1; + UINT32 ModemRingResumeSupported:1; + UINT32 PmeSignalSupported :1; + UINT32 HotPlugDevicesSupported :1; + UINT32 SmbusSignalSupported :1; + UINT32 Reserved :21; +} EFI_MISC_SLOT_CHARACTERISTICS; + +typedef struct { + STRING_REF SlotDesignation; + EFI_MISC_SLOT_TYPE SlotType; + EFI_MISC_SLOT_DATA_BUS_WIDTH SlotDataBusWidth; + EFI_MISC_SLOT_USAGE SlotUsage; + EFI_MISC_SLOT_LENGTH SlotLength; + UINT16 SlotId; + EFI_MISC_SLOT_CHARACTERISTICS SlotCharacteristics; + EFI_DEVICE_PATH_PROTOCOL SlotDevicePath; +} EFI_MISC_SYSTEM_SLOT_DESIGNATION; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Onboard Device - SMBIOS Type 10 +// +#define EFI_MISC_ONBOARD_DEVICE_RECORD_NUMBER 0x00000008 + +typedef enum { + EfiOnBoardDeviceTypeOther = 1, + EfiOnBoardDeviceTypeUnknown = 2, + EfiOnBoardDeviceTypeVideo = 3, + EfiOnBoardDeviceTypeScsiController = 4, + EfiOnBoardDeviceTypeEthernet = 5, + EfiOnBoardDeviceTypeTokenRing = 6, + EfiOnBoardDeviceTypeSound = 7, +} EFI_MISC_ONBOARD_DEVICE_TYPE; + +typedef struct { + UINT32 DeviceType :16; + UINT32 DeviceEnabled :1; + UINT32 Reserved :15; +} EFI_MISC_ONBOARD_DEVICE_STATUS; + +typedef struct { + STRING_REF OnBoardDeviceDescription; + EFI_MISC_ONBOARD_DEVICE_STATUS OnBoardDeviceStatus; + EFI_DEVICE_PATH_PROTOCOL OnBoardDevicePath; +} EFI_MISC_ONBOARD_DEVICE; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. BIOS Language Information - SMBIOS Type 11 +// +#define EFI_MISC_OEM_STRING_RECORD_NUMBER 0x00000009 + +typedef struct { + STRING_REF OemStringRef[1]; +} EFI_MISC_OEM_STRING; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. System Options - SMBIOS Type 12 +// +typedef struct { + STRING_REF SystemOptionStringRef[1]; +} EFI_MISC_SYSTEM_OPTION_STRING; + +#define EFI_MISC_SYSTEM_OPTION_STRING_RECORD_NUMBER 0x0000000A + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Number of Installable Languages - SMBIOS Type 13 +// +#define EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_RECORD_NUMBER 0x0000000B + +typedef struct { + UINT32 AbbreviatedLanguageFormat :1; + UINT32 Reserved :31; +} EFI_MISC_LANGUAGE_FLAGS; + +typedef struct { + UINT16 NumberOfInstallableLanguages; + EFI_MISC_LANGUAGE_FLAGS LanguageFlags; + UINT16 CurrentLanguageNumber; +} EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. System Language String +// +#define EFI_MISC_SYSTEM_LANGUAGE_STRING_RECORD_NUMBER 0x0000000C + +typedef struct { + UINT16 LanguageId; + STRING_REF SystemLanguageString; +} EFI_MISC_SYSTEM_LANGUAGE_STRING; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Group Associations - SMBIOS Type 14 +// +#define EFI_MISC_GROUP_NAME_RECORD_NUMBER 0x0000000D + +typedef struct { + STRING_REF GroupName; + UINT16 NumberGroupItems; + UINT16 GroupId; +} EFI_MISC_GROUP_NAME_DATA; + +#define EFI_MISC_GROUP_ITEM_SET_RECORD_NUMBER 0x0000000E + +typedef struct { + EFI_GUID SubClass; + EFI_INTER_LINK_DATA GroupLink; + UINT16 GroupId; + UINT16 GroupElementId; +} EFI_MISC_GROUP_ITEM_SET_DATA; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Pointing Device Type - SMBIOS Type 21 +// +#define EFI_MISC_POINTING_DEVICE_TYPE_RECORD_NUMBER 0x0000000F + +typedef enum { + EfiPointingDeviceTypeOther = 1, + EfiPointingDeviceTypeUnknown = 2, + EfiPointingDeviceTypeMouse = 3, + EfiPointingDeviceTypeTrackBall = 4, + EfiPointingDeviceTypeTrackPoint = 5, + EfiPointingDeviceTypeGlidePoint = 6, + EfiPointingDeviceTouchPad = 7, + EfiPointingDeviceTouchScreen = 8, + EfiPointingDeviceOpticalSensor = 9, +} EFI_MISC_POINTING_DEVICE_TYPE; + +typedef enum { + EfiPointingDeviceInterfaceOther = 1, + EfiPointingDeviceInterfaceUnknown = 2, + EfiPointingDeviceInterfaceSerial = 3, + EfiPointingDeviceInterfacePs2 = 4, + EfiPointingDeviceInterfaceInfrared = 5, + EfiPointingDeviceInterfaceHpHil = 6, + EfiPointingDeviceInterfaceBusMouse = 7, + EfiPointingDeviceInterfaceADB = 8, + EfiPointingDeviceInterfaceBusMouseDB9 = 0xA0, + EfiPointingDeviceInterfaceBusMouseMicroDin = 0xA1, + EfiPointingDeviceInterfaceUsb = 0xA2, +} EFI_MISC_POINTING_DEVICE_INTERFACE; + +typedef struct { + EFI_MISC_POINTING_DEVICE_TYPE PointingDeviceType; + EFI_MISC_POINTING_DEVICE_INTERFACE PointingDeviceInterface; + UINT16 NumberPointingDeviceButtons; + EFI_DEVICE_PATH_PROTOCOL PointingDevicePath; +} EFI_MISC_ONBOARD_DEVICE_TYPE_DATA; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Portable Battery - SMBIOS Type 22 +// +#define EFI_MISC_PORTABLE_BATTERY_RECORD_NUMBER 0x00000010 + +typedef enum { + EfiPortableBatteryDeviceChemistryOther = 1, + EfiPortableBatteryDeviceChemistryUnknown = 2, + EfiPortableBatteryDeviceChemistryLeadAcid = 3, + EfiPortableBatteryDeviceChemistryNickelCadmium = 4, + EfiPortableBatteryDeviceChemistryNickelMetalHydride = 5, + EfiPortableBatteryDeviceChemistryLithiumIon = 6, + EfiPortableBatteryDeviceChemistryZincAir = 7, + EfiPortableBatteryDeviceChemistryLithiumPolymer = 8, +} EFI_MISC_PORTABLE_BATTERY_DEVICE_CHEMISTRY; + +typedef struct { + STRING_REF Location; + STRING_REF Manufacturer; + STRING_REF ManufactureDate; + STRING_REF SerialNumber; + STRING_REF DeviceName; + EFI_MISC_PORTABLE_BATTERY_DEVICE_CHEMISTRY DeviceChemistry; + UINT16 DesignCapacity; + UINT16 DesignVoltage; + STRING_REF SBDSVersionNumber; + UINT8 MaximumError; + UINT16 SBDSSerialNumber; + UINT16 SBDSManufactureDate; + STRING_REF SBDSDeviceChemistry; + UINT8 DesignCapacityMultiplier; + UINT32 OEMSpecific; + UINT8 BatteryNumber; // Temporary + BOOLEAN Valid; // Is entry valid - Temporary +} EFI_MISC_PORTABLE_BATTERY; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Reset Capabilities - SMBIOS Type 23 +// +#define EFI_MISC_RESET_CAPABILITIES_RECORD_NUMBER 0x00000011 + +typedef struct { + UINT32 Status :1; + UINT32 BootOption :2; + UINT32 BootOptionOnLimit :2; + UINT32 WatchdogTimerPresent:1; + UINT32 Reserved :26; +} EFI_MISC_RESET_CAPABILITIES_TYPE; + +typedef struct { + EFI_MISC_RESET_CAPABILITIES_TYPE ResetCapabilities; + UINT16 ResetCount; + UINT16 ResetLimit; + UINT16 ResetTimerInterval; + UINT16 ResetTimeout; +} EFI_MISC_RESET_CAPABILITIES; + +typedef struct { + EFI_MISC_RESET_CAPABILITIES ResetCapabilities; + UINT16 ResetCount; + UINT16 ResetLimit; + UINT16 ResetTimerInterval; + UINT16 ResetTimeout; +} EFI_MISC_RESET_CAPABILITIES_DATA; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Hardware Security - SMBIOS Type 24 +// +#define EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA_RECORD_NUMBER 0x00000012 + +typedef enum { + EfiHardwareSecurityStatusDisabled = 0, + EfiHardwareSecurityStatusEnabled = 1, + EfiHardwareSecurityStatusNotImplemented = 2, + EfiHardwareSecurityStatusUnknown = 3 +} EFI_MISC_HARDWARE_SECURITY_STATUS; + +typedef struct { + EFI_MISC_HARDWARE_SECURITY_STATUS FrontPanelResetStatus :2; + EFI_MISC_HARDWARE_SECURITY_STATUS AdministratorPasswordStatus :2; + EFI_MISC_HARDWARE_SECURITY_STATUS KeyboardPasswordStatus :2; + EFI_MISC_HARDWARE_SECURITY_STATUS PowerOnPasswordStatus :2; + EFI_MISC_HARDWARE_SECURITY_STATUS Reserved :24; +} EFI_MISC_HARDWARE_SECURITY_SETTINGS; + +typedef struct { + EFI_MISC_HARDWARE_SECURITY_SETTINGS HardwareSecuritySettings; +} EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. System Power Controls - SMBIOS Type 25 +// +#define EFI_MISC_SCHEDULED_POWER_ON_MONTH_RECORD_NUMBER 0x00000013 + +typedef struct { + UINT8 ScheduledPoweronMonth; + UINT8 ScheduledPoweronDayOfMonth; + UINT8 ScheduledPoweronHour; + UINT8 ScheduledPoweronMinute; + UINT8 ScheduledPoweronSecond; +} EFI_MISC_SCHEDULED_POWER_ON_MONTH; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Voltage Probe - SMBIOS Type 26 +// +#define EFI_MISC_VOLTAGE_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000014 + +typedef struct { + UINT32 VoltageProbeSite :5; + UINT32 VoltageProbeStatus :3; + UINT32 Reserved :24; +} EFI_MISC_VOLTAGE_PROBE_LOCATION; + +typedef struct { + STRING_REF VoltageProbeDescription; + EFI_MISC_VOLTAGE_PROBE_LOCATION VoltageProbeLocation; + UINT16 VoltageProbeMaximumValue; + UINT16 VoltageProbeMinimumValue; + UINT16 VoltageProbeResolution; + UINT16 VoltageProbeTolerance; + UINT16 VoltageProbeAccuracy; + UINT16 VoltageProbeNominalValue; + UINT16 MDLowerNoncriticalThreshold; + UINT16 MDUpperNoncriticalThreshold; + UINT16 MDLowerCriticalThreshold; + UINT16 MDUpperCriticalThreshold; + UINT16 MDLowerNonrecoverableThreshold; + UINT16 MDUpperNonrecoverableThreshold; + UINT32 VoltageProbeOemDefined; +} EFI_MISC_VOLTAGE_PROBE_DESCRIPTION; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Cooling Device - SMBIOS Type 27 +// +#define EFI_MISC_COOLING_DEVICE_TEMP_LINK_RECORD_NUMBER 0x00000015 + +typedef struct { + UINT32 CoolingDevice :5; + UINT32 CoolingDeviceStatus :3; + UINT32 Reserved :24; +} EFI_MISC_COOLING_DEVICE_TYPE; + +typedef struct { + EFI_MISC_COOLING_DEVICE_TYPE CoolingDeviceType; + EFI_INTER_LINK_DATA CoolingDeviceTemperatureLink; + UINT8 CoolingDeviceUnitGroup; + UINT16 CoolingDeviceNominalSpeed; + UINT32 CoolingDeviceOemDefined; +} EFI_MISC_COOLING_DEVICE_TEMP_LINK; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Temperature Probe - SMBIOS Type 28 +// +#define EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000016 + +typedef struct { + UINT32 TemperatureProbeSite :5; + UINT32 TemperatureProbeStatus :3; + UINT32 Reserved :24; +} EFI_MISC_TEMPERATURE_PROBE_LOCATION; + +typedef struct { + STRING_REF TemperatureProbeDescription; + EFI_MISC_TEMPERATURE_PROBE_LOCATION TemperatureProbeLocation; + UINT16 TemperatureProbeMaximumValue; + UINT16 TemperatureProbeMinimumValue; + UINT16 TemperatureProbeResolution; + UINT16 TemperatureProbeTolerance; + UINT16 TemperatureProbeAccuracy; + UINT16 TemperatureProbeNominalValue; + UINT16 MDLowerNoncriticalThreshold; + UINT16 MDUpperNoncriticalThreshold; + UINT16 MDLowerCriticalThreshold; + UINT16 MDUpperCriticalThreshold; + UINT16 MDLowerNonrecoverableThreshold; + UINT16 MDUpperNonrecoverableThreshold; + UINT32 TemperatureProbeOemDefined; +} EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Electrical Current Probe - SMBIOS Type 29 +// +#define EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000017 + +typedef struct { + UINT32 ElectricalCurrentProbeSite :5; + UINT32 ElectricalCurrentProbeStatus :3; + UINT32 Reserved :24; +} EFI_MISC_ELECTRICAL_CURRENT_PROBE_LOCATION; + +typedef struct { + STRING_REF ElectricalCurrentProbeDescription; + EFI_MISC_ELECTRICAL_CURRENT_PROBE_LOCATION ElectricalCurrentProbeLocation; + UINT16 ElectricalCurrentProbeMaximumValue; + UINT16 ElectricalCurrentProbeMinimumValue; + UINT16 ElectricalCurrentProbeResolution; + UINT16 ElectricalCurrentProbeTolerance; + UINT16 ElectricalCurrentProbeAccuracy; + UINT16 ElectricalCurrentProbeNominalValue; + UINT16 MDLowerNoncriticalThreshold; + UINT16 MDUpperNoncriticalThreshold; + UINT16 MDLowerCriticalThreshold; + UINT16 MDUpperCriticalThreshold; + UINT16 MDLowerNonrecoverableThreshold; + UINT16 MDUpperNonrecoverableThreshold; + UINT32 ElectricalCurrentProbeOemDefined; +} EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Out-of-Band Remote Access - SMBIOS Type 30 +// +#define EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION_RECORD_NUMBER 0x00000018 + +typedef struct { + UINT32 InboundConnectionEnabled :1; + UINT32 OutboundConnectionEnabled :1; + UINT32 Reserved :30; +} EFI_MISC_REMOTE_ACCESS_CONNECTIONS; + +typedef struct { + STRING_REF RemoteAccessManufacturerNameDescription; + EFI_MISC_REMOTE_ACCESS_CONNECTIONS RemoteAccessConnections; +} EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION; +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. BIS Entry Point - SMBIOS Type 31 +// +#define EFI_MISC_BIS_ENTRY_POINT_RECORD_NUMBER 0x00000019 + +typedef struct { + EFI_PHYSICAL_ADDRESS BisEntryPoint; +} EFI_MISC_BIS_ENTRY_POINT; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Boot Information - SMBIOS Type 32 +// +#define EFI_MISC_BOOT_INFORMATION_STATUS_RECORD_NUMBER 0x0000001A + +typedef enum { + EfiBootInformationStatusNoError = 0, + EfiBootInformationStatusNoBootableMedia = 1, + EfiBootInformationStatusNormalOSFailedLoading = 2, + EfiBootInformationStatusFirmwareDetectedFailure = 3, + EfiBootInformationStatusOSDetectedFailure = 4, + EfiBootInformationStatusUserRequestedBoot = 5, + EfiBootInformationStatusSystemSecurityViolation = 6, + EfiBootInformationStatusPreviousRequestedImage = 7, + EfiBootInformationStatusWatchdogTimerExpired = 8, + EfiBootInformationStatusStartReserved = 9, + EfiBootInformationStatusStartOemSpecific = 128, + EfiBootInformationStatusStartProductSpecific = 192, +} EFI_MISC_BOOT_INFORMATION_STATUS_TYPE; + +typedef struct { + EFI_MISC_BOOT_INFORMATION_STATUS_TYPE BootInformationStatus; + UINT8 BootInformationData[9]; +} EFI_MISC_BOOT_INFORMATION_STATUS; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Management Device - SMBIOS Type 34 +// +#define EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION_RECORD_NUMBER 0x0000001B + +typedef enum { + EfiManagementDeviceTypeOther = 1, + EfiManagementDeviceTypeUnknown = 2, + EfiManagementDeviceTypeLm75 = 3, + EfiManagementDeviceTypeLm78 = 4, + EfiManagementDeviceTypeLm79 = 5, + EfiManagementDeviceTypeLm80 = 6, + EfiManagementDeviceTypeLm81 = 7, + EfiManagementDeviceTypeAdm9240 = 8, + EfiManagementDeviceTypeDs1780 = 9, + EfiManagementDeviceTypeMaxim1617 = 0xA, + EfiManagementDeviceTypeGl518Sm = 0xB, + EfiManagementDeviceTypeW83781D = 0xC, + EfiManagementDeviceTypeHt82H791 = 0xD +} EFI_MISC_MANAGEMENT_DEVICE_TYPE; + +typedef enum { + EfiManagementDeviceAddressTypeOther = 1, + EfiManagementDeviceAddressTypeUnknown = 2, + EfiManagementDeviceAddressTypeIOPort = 3, + EfiManagementDeviceAddressTypeMemory = 4, + EfiManagementDeviceAddressTypeSmbus = 5 +} EFI_MISC_MANAGEMENT_DEVICE_ADDRESS_TYPE; + +typedef struct { + STRING_REF ManagementDeviceDescription; + EFI_MISC_MANAGEMENT_DEVICE_TYPE ManagementDeviceType; + UINTN ManagementDeviceAddress; + EFI_MISC_MANAGEMENT_DEVICE_ADDRESS_TYPE ManagementDeviceAddressType; +} EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION; + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. Management Device Component - SMBIOS Type 35 +// +#define EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION_RECORD_NUMBER 0x0000001C + +typedef struct { + STRING_REF ManagementDeviceComponentDescription; + EFI_INTER_LINK_DATA ManagementDeviceLink; + EFI_INTER_LINK_DATA ManagementDeviceComponentLink; + EFI_INTER_LINK_DATA ManagementDeviceThresholdLink; +} EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION; + +// +////////////////////////////////////////////////////////////////////////////// +// +// IPMI Data Record - SMBIOS Type 38 +// +typedef enum { + EfiIpmiOther = 0, + EfiIpmiKcs = 1, + EfiIpmiSmic = 2, + EfiIpmiBt = 3, +} EFI_MISC_IPMI_INTERFACE_TYPE; + +typedef struct { + UINT16 IpmiSpecLeastSignificantDigit:4; + UINT16 IpmiSpecMostSignificantDigit:4; + UINT16 Reserved:8; +} EFI_MISC_IPMI_SPECIFICATION_REVISION; + +typedef struct { + EFI_MISC_IPMI_INTERFACE_TYPE IpmiInterfaceType; + EFI_MISC_IPMI_SPECIFICATION_REVISION IpmiSpecificationRevision; + UINT16 IpmiI2CSlaveAddress; + UINT16 IpmiNvDeviceAddress; + UINT64 IpmiBaseAddress; + EFI_DEVICE_PATH_PROTOCOL IpmiDevicePath; +} EFI_MISC_IPMI_INTERFACE_TYPE_DATA; + +#define EFI_MISC_IPMI_INTERFACE_TYPE_RECORD_NUMBER 0x0000001D + +// +////////////////////////////////////////////////////////////////////////////// +// +//System Power supply Record - SMBIOS Type 39 +// +typedef struct { + UINT16 PowerSupplyHotReplaceable :1; + UINT16 PowerSupplyPresent :1; + UINT16 PowerSupplyUnplugged :1; + UINT16 InputVoltageRangeSwitch :4; + UINT16 PowerSupplyStatus :3; + UINT16 PowerSupplyType :4; + UINT16 Reserved :2; +} POWER_SUPPLY_CHARACTERISTICS; + +typedef struct { + UINT8 PowerUnitGroup; + STRING_REF PowerSupplyLocation; + STRING_REF PowerSupplyDeviceName; + STRING_REF PowerSupplyManufacturer; + STRING_REF PowerSupplySerialNumber; + STRING_REF PowerSupplyAssetTagNumber; + STRING_REF PowerSupplyModelPartNumber; + STRING_REF PowerSupplyRevisionLevel; + UINT16 PowerSupplyMaxPowerCapacity; + POWER_SUPPLY_CHARACTERISTICS PowerSupplyCharacteristics; + EFI_INTER_LINK_DATA PowerSupplyInputVoltageProbeLink; + EFI_INTER_LINK_DATA PowerSupplyCoolingDeviceLink; + EFI_INTER_LINK_DATA PowerSupplyInputCurrentProbeLink; +} EFI_MISC_SYSTEM_POWER_SUPPLY; + +#define EFI_MISC_SYSTEM_POWER_SUPPLY_RECORD_NUMBER 0x0000001E + +// +////////////////////////////////////////////////////////////////////////////// +// +// Generic Data Record - All SMBIOS Type +// Put smbios raw data into one datahub record directly. Smbios driver would +// copy smbios raw data into smbios table but not take any translation. +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Handle; +} SMBIOS_STRUCTURE_HDR; + +typedef struct { + SMBIOS_STRUCTURE_HDR Header; + UINT8 RawData[1]; +} EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION; + +#define EFI_MISC_SMBIOS_STRUCT_ENCAP_RECORD_NUMBER 0x0000001F + +// +////////////////////////////////////////////////////////////////////////////// +// +// Misc. System Event Log - SMBIOS Type 15 +// +#define EFI_MISC_SYSTEM_EVENT_LOG_RECORD_NUMBER 0x00000020 +typedef struct { + //SMBIOS_STRUCTURE_HDR Header; + UINT16 LogAreaLength; + UINT16 LogHeaderStartOffset; + UINT16 LogDataStartOffset; + UINT8 AccessMethod; + UINT8 LogStatus; + UINT32 LogChangeToken; + UINT32 AccessMethodAddress; + UINT8 LogHeaderFormat; + UINT8 NumberOfSupportedLogType; + UINT8 LengthOfLogDescriptor; +} EFI_MISC_SYSTEM_EVENT_LOG; + +// +// Access Method. +// 0x00~0x04: as following definition +// 0x05~0x7f: Available for future assignment. +// 0x80~0xff: BIOS Vendor/OEM-specific. +// +#define ACCESS_INDEXIO_1INDEX8BIT_DATA8BIT 0x00 +#define ACCESS_INDEXIO_2INDEX8BIT_DATA8BIT 0X01 +#define ACCESS_INDEXIO_1INDEX16BIT_DATA8BIT 0X02 +#define ACCESS_MEMORY_MAPPED 0x03 +#define ACCESS_GPNV 0x04 + +// +////////////////////////////////////////////////////////////////////////////// +// +//Management Device Threshold Data Record - SMBIOS Type 36 +// +#define EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD_RECORD_NUMBER 0x00000021 + +typedef struct { + UINT16 LowerThresNonCritical; + UINT16 UpperThresNonCritical; + UINT16 LowerThresCritical; + UINT16 UpperThresCritical; + UINT16 LowerThresNonRecover; + UINT16 UpperThresNonRecover; +} EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD; + +// +////////////////////////////////////////////////////////////////////////////// +// +// +// +typedef union { + EFI_MISC_LAST_PCI_BUS LastPciBus; + EFI_MISC_BIOS_VENDOR MiscBiosVendor; + EFI_MISC_SYSTEM_MANUFACTURER MiscSystemManufacturer; + EFI_MISC_BASE_BOARD_MANUFACTURER MiscBaseBoardManufacturer; + EFI_MISC_CHASSIS_MANUFACTURER MiscChassisManufacturer; + EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR MiscPortInternalConnectorDesignator; + EFI_MISC_SYSTEM_SLOT_DESIGNATION MiscSystemSlotDesignation; + EFI_MISC_ONBOARD_DEVICE MiscOnboardDevice; + EFI_MISC_OEM_STRING MiscOemString; + EFI_MISC_SYSTEM_OPTION_STRING MiscOptionString; + EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES NumberOfInstallableLanguages; + EFI_MISC_SYSTEM_LANGUAGE_STRING MiscSystemLanguageString; + EFI_MISC_GROUP_NAME_DATA MiscGroupNameData; + EFI_MISC_GROUP_ITEM_SET_DATA MiscGroupItemSetData; + EFI_MISC_SYSTEM_EVENT_LOG MiscSystemEventLog; + EFI_MISC_ONBOARD_DEVICE_TYPE_DATA MiscOnboardDeviceTypeData; + EFI_MISC_PORTABLE_BATTERY MiscPortableBattery; + EFI_MISC_RESET_CAPABILITIES_DATA MiscResetCapablilitiesData; + EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA MiscHardwareSecuritySettingsData; + EFI_MISC_SCHEDULED_POWER_ON_MONTH MiscScheduledPowerOnMonth; + EFI_MISC_VOLTAGE_PROBE_DESCRIPTION MiscVoltageProbeDescription; + EFI_MISC_COOLING_DEVICE_TEMP_LINK MiscCoolingDeviceTempLink; + EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION MiscTemperatureProbeDescription; + EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION MiscElectricalCurrentProbeDescription; + EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION MiscRemoteAccessManufacturerDescription; + EFI_MISC_BIS_ENTRY_POINT MiscBisEntryPoint; + EFI_MISC_BOOT_INFORMATION_STATUS MiscBootInformationStatus; + EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION MiscManagementDeviceDescription; + EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION MiscManagementDeviceComponentDescription; + EFI_MISC_IPMI_INTERFACE_TYPE_DATA MiscIpmiInterfaceTypeData; + EFI_MISC_SYSTEM_POWER_SUPPLY MiscPowerSupplyInfo; + EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION MiscSmbiosStructEncapsulation; + EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD MiscManagementDeviceThreshold; +} EFI_MISC_SUBCLASS_RECORDS; + +// +// +// +typedef struct { + EFI_SUBCLASS_TYPE1_HEADER Header; + EFI_MISC_SUBCLASS_RECORDS Record; +} EFI_MISC_SUBCLASS_DRIVER_DATA; + +#pragma pack() + +#endif /* _DATAHUB_SUBCLASS_MISC_H_ */ +/* eof - DataHubSubClassMisc.h */ diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h new file mode 100644 index 0000000000..ed0c885da0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h @@ -0,0 +1,360 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHubSubClassProcessor.h + +Abstract: + + Definitions for processor sub class data records + +Revision History + +--*/ + +#ifndef _DATAHUB_SUBCLASS_PROCESSOR_H_ +#define _DATAHUB_SUBCLASS_PROCESSOR_H_ + +#define EFI_PROCESSOR_SUBCLASS_VERSION 0x00010000 + +#define EFI_PROCESSOR_SUBCLASS_GUID \ + { 0x26fdeb7e, 0xb8af, 0x4ccf, 0xaa, 0x97, 0x02, 0x63, 0x3c, 0xe4, 0x8c, 0xa7 } + + +typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_MAX_CORE_FREQUENCY_DATA; + +typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA; + +typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_CORE_FREQUENCY_DATA; + +typedef EFI_EXP_BASE10_DATA *EFI_PROCESSOR_CORE_FREQUENCY_LIST_DATA; + +typedef EFI_EXP_BASE10_DATA *EFI_PROCESSOR_FSB_FREQUENCY_LIST_DATA; + +typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_FSB_FREQUENCY_DATA; + +typedef STRING_REF EFI_PROCESSOR_VERSION_DATA; + +typedef STRING_REF EFI_PROCESSOR_MANUFACTURER_DATA; + +typedef STRING_REF EFI_PROCESSOR_SERIAL_NUMBER_DATA; + +typedef STRING_REF EFI_PROCESSOR_ASSET_TAG_DATA; + +typedef struct { + UINT32 ProcessorSteppingId:4; + UINT32 ProcessorModel: 4; + UINT32 ProcessorFamily: 4; + UINT32 ProcessorType: 2; + UINT32 ProcessorReserved1: 2; + UINT32 ProcessorXModel: 4; + UINT32 ProcessorXFamily: 8; + UINT32 ProcessorReserved2: 4; +} EFI_PROCESSOR_SIGNATURE; + +typedef struct { + UINT32 ProcessorBrandIndex :8; + UINT32 ProcessorClflush :8; + UINT32 ProcessorReserved :8; + UINT32 ProcessorDfltApicId :8; +} EFI_PROCESSOR_MISC_INFO; + +typedef struct { + UINT32 ProcessorFpu: 1; + UINT32 ProcessorVme: 1; + UINT32 ProcessorDe: 1; + UINT32 ProcessorPse: 1; + UINT32 ProcessorTsc: 1; + UINT32 ProcessorMsr: 1; + UINT32 ProcessorPae: 1; + UINT32 ProcessorMce: 1; + UINT32 ProcessorCx8: 1; + UINT32 ProcessorApic: 1; + UINT32 ProcessorReserved1: 1; + UINT32 ProcessorSep: 1; + UINT32 ProcessorMtrr: 1; + UINT32 ProcessorPge: 1; + UINT32 ProcessorMca: 1; + UINT32 ProcessorCmov: 1; + UINT32 ProcessorPat: 1; + UINT32 ProcessorPse36: 1; + UINT32 ProcessorPsn: 1; + UINT32 ProcessorClfsh: 1; + UINT32 ProcessorReserved2: 1; + UINT32 ProcessorDs: 1; + UINT32 ProcessorAcpi: 1; + UINT32 ProcessorMmx: 1; + UINT32 ProcessorFxsr: 1; + UINT32 ProcessorSse: 1; + UINT32 ProcessorSse2: 1; + UINT32 ProcessorSs: 1; + UINT32 ProcessorReserved3: 1; + UINT32 ProcessorTm: 1; + UINT32 ProcessorReserved4: 2; +} EFI_PROCESSOR_FEATURE_FLAGS; + +typedef struct { + EFI_PROCESSOR_SIGNATURE Signature; + EFI_PROCESSOR_MISC_INFO MiscInfo; + UINT32 Reserved; + EFI_PROCESSOR_FEATURE_FLAGS FeatureFlags; +} EFI_PROCESSOR_ID_DATA; + +typedef enum { + EfiProcessorOther = 1, + EfiProcessorUnknown = 2, + EfiCentralProcessor = 3, + EfiMathProcessor = 4, + EfiDspProcessor = 5, + EfiVideoProcessor = 6 +} EFI_PROCESSOR_TYPE_DATA; + +typedef enum { + EfiProcessorFamilyOther = 1, + EfiProcessorFamilyUnknown = 2, + EfiProcessorFamily8086 = 3, + EfiProcessorFamily80286 = 4, + EfiProcessorFamilyIntel386 = 5, + EfiProcessorFamilyIntel486 = 6, + EfiProcessorFamily8087 = 7, + EfiProcessorFamily80287 = 8, + EfiProcessorFamily80387 = 9, + EfiProcessorFamily80487 = 0x0A, + EfiProcessorFamilyPentium = 0x0B, + EfiProcessorFamilyPentiumPro = 0x0C, + EfiProcessorFamilyPentiumII = 0x0D, + EfiProcessorFamilyPentiumMMX = 0x0E, + EfiProcessorFamilyCeleron = 0x0F, + EfiProcessorFamilyPentiumIIXeon = 0x10, + EfiProcessorFamilyPentiumIII = 0x11, + EfiProcessorFamilyM1 = 0x12, + EfiProcessorFamilyM2 = 0x13, + EfiProcessorFamilyM1Reserved2 = 0x14, + EfiProcessorFamilyM1Reserved3 = 0x15, + EfiProcessorFamilyM1Reserved4 = 0x16, + EfiProcessorFamilyM1Reserved5 = 0x17, + EfiProcessorFamilyAmdDuron = 0x18, + EfiProcessorFamilyK5 = 0x19, + EfiProcessorFamilyK6 = 0x1A, + EfiProcessorFamilyK6_2 = 0x1B, + EfiProcessorFamilyK6_3 = 0x1C, + EfiProcessorFamilyAmdAthlon = 0x1D, + EfiProcessorFamilyK6_2Plus = 0x1E, + EfiProcessorFamilyK5Reserved6 = 0x1F, + EfiProcessorFamilyPowerPC = 0x20, + EfiProcessorFamilyPowerPC601 = 0x21, + EfiProcessorFamilyPowerPC603 = 0x22, + EfiProcessorFamilyPowerPC603Plus = 0x23, + EfiProcessorFamilyPowerPC604 = 0x24, + EfiProcessorFamilyPowerPC620 = 0x25, + EfiProcessorFamilyPowerPC704 = 0x26, + EfiProcessorFamilyPowerPC750 = 0x27, + EfiProcessorFamilyAlpha2 = 0x30, + EfiProcessorFamilyAlpha21064 = 0x31, + EfiProcessorFamilyAlpha21066 = 0x32, + EfiProcessorFamilyAlpha21164 = 0x33, + EfiProcessorFamilyAlpha21164PC = 0x34, + EfiProcessorFamilyAlpha21164a = 0x35, + EfiProcessorFamilyAlpha21264 = 0x36, + EfiProcessorFamilyAlpha21364 = 0x37, + EfiProcessorFamilyMips = 0x40, + EfiProcessorFamilyMIPSR4000 = 0x41, + EfiProcessorFamilyMIPSR4200 = 0x42, + EfiProcessorFamilyMIPSR4400 = 0x43, + EfiProcessorFamilyMIPSR4600 = 0x44, + EfiProcessorFamilyMIPSR10000 = 0x45, + EfiProcessorFamilySparc = 0x50, + EfiProcessorFamilySuperSparc = 0x51, + EfiProcessorFamilymicroSparcII = 0x52, + EfiProcessorFamilymicroSparcIIep = 0x53, + EfiProcessorFamilyUltraSparc = 0x54, + EfiProcessorFamilyUltraSparcII = 0x55, + EfiProcessorFamilyUltraSparcIIi = 0x56, + EfiProcessorFamilyUltraSparcIII = 0x57, + EfiProcessorFamilyUltraSparcIIIi = 0x58, + EfiProcessorFamily68040 = 0x60, + EfiProcessorFamily68xxx = 0x61, + EfiProcessorFamily68000 = 0x62, + EfiProcessorFamily68010 = 0x63, + EfiProcessorFamily68020 = 0x64, + EfiProcessorFamily68030 = 0x65, + EfiProcessorFamilyHobbit = 0x70, + EfiProcessorFamilyCrusoeTM5000 = 0x78, + EfiProcessorFamilyCrusoeTM3000 = 0x79, + EfiProcessorFamilyWeitek = 0x80, + EfiProcessorFamilyItanium = 0x82, + EfiProcessorFamilyAmdAthlon64 = 0x83, + EfiProcessorFamilyAmdOpteron = 0x84, + EfiProcessorFamilyPARISC = 0x90, + EfiProcessorFamilyPaRisc8500 = 0x91, + EfiProcessorFamilyPaRisc8000 = 0x92, + EfiProcessorFamilyPaRisc7300LC = 0x93, + EfiProcessorFamilyPaRisc7200 = 0x94, + EfiProcessorFamilyPaRisc7100LC = 0x95, + EfiProcessorFamilyPaRisc7100 = 0x96, + EfiProcessorFamilyV30 = 0xA0, + EfiProcessorFamilyPentiumIIIXeon = 0xB0, + EfiProcessorFamilyPentiumIIISpeedStep = 0xB1, + EfiProcessorFamilyPentium4 = 0xB2, + EfiProcessorFamilyIntelXeon = 0xB3, + EfiProcessorFamilyAS400 = 0xB4, + EfiProcessorFamilyIntelXeonMP = 0xB5, + EfiProcessorFamilyAMDAthlonXP = 0xB6, + EfiProcessorFamilyAMDAthlonMP = 0xB7, + EfiProcessorFamilyIntelItanium2 = 0xB8, + EfiProcessorFamilyIntelPentiumM = 0xB9, + EfiProcessorFamilyIntelCeleronD = 0xBA, + EfiProcessorFamilyIntelPentiumD = 0xBB, + EfiProcessorFamilyIntelPentiumEx = 0xBC, + EfiProcessorFamilyIBM390 = 0xC8, + EfiProcessorFamilyG4 = 0xC9, + EfiProcessorFamilyG5 = 0xCA, + EfiProcessorFamilyi860 = 0xFA, + EfiProcessorFamilyi960 = 0xFB +} EFI_PROCESSOR_FAMILY_DATA; + + +typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_VOLTAGE_DATA; + +typedef EFI_PHYSICAL_ADDRESS EFI_PROCESSOR_APIC_BASE_ADDRESS_DATA; + +typedef UINT32 EFI_PROCESSOR_APIC_ID_DATA; + +typedef UINT32 EFI_PROCESSOR_APIC_VERSION_NUMBER_DATA; + +typedef enum { + EfiProcessorIa32Microcode = 1, + EfiProcessorIpfPalAMicrocode = 2, + EfiProcessorIpfPalBMicrocode = 3 +} EFI_PROCESSOR_MICROCODE_TYPE; + +typedef struct { + EFI_PROCESSOR_MICROCODE_TYPE ProcessorMicrocodeType; + UINT32 ProcessorMicrocodeRevisionNumber; +} EFI_PROCESSOR_MICROCODE_REVISION_DATA; + +typedef struct { + UINT32 CpuStatus :3; + UINT32 Reserved1 :3; + UINT32 SocketPopulated :1; + UINT32 Reserved2 :1; + UINT32 ApicEnable :1; + UINT32 BootApplicationProcessor :1; + UINT32 Reserved3 :22; +} EFI_PROCESSOR_STATUS_DATA; + +typedef enum { + EfiCpuStatusUnknown = 0, + EfiCpuStatusEnabled = 1, + EfiCpuStatusDisabledByUser = 2, + EfiCpuStatusDisabledbyBios = 3, + EfiCpuStatusIdle = 4, + EfiCpuStatusOther = 7 +} EFI_CPU_STATUS; + +typedef enum { + EfiProcessorSocketOther = 1, + EfiProcessorSocketUnknown = 2, + EfiProcessorSocketDaughterBoard = 3, + EfiProcessorSocketZIF = 4, + EfiProcessorSocketReplacePiggyBack = 5, + EfiProcessorSocketNone = 6, + EfiProcessorSocketLIF = 7, + EfiProcessorSocketSlot1 = 8, + EfiProcessorSocketSlot2 = 9, + EfiProcessorSocket370Pin = 0xA, + EfiProcessorSocketSlotA = 0xB, + EfiProcessorSocketSlotM = 0xC, + EfiProcessorSocket423 = 0xD, + EfiProcessorSocketA462 = 0xE, + EfiProcessorSocket478 = 0xF, + EfiProcessorSocket754 = 0x10, + EfiProcessorSocket940 = 0x11, + EfiProcessorSocket939 = 0x12, + EfiProcessorSocketmPGA604 = 0x13, + EfiProcessorSocketLGA771 = 0x14, + EfiProcessorSocketLGA775 = 0x15 +} EFI_PROCESSOR_SOCKET_TYPE_DATA; + +typedef STRING_REF EFI_PROCESSOR_SOCKET_NAME_DATA; + +typedef EFI_INTER_LINK_DATA EFI_CACHE_ASSOCIATION_DATA; + +typedef enum { + EfiProcessorHealthy = 1, + EfiProcessorPerfRestricted = 2, + EfiProcessorFuncRestricted = 3 +} EFI_PROCESSOR_HEALTH_STATUS; + +typedef UINTN EFI_PROCESSOR_PACKAGE_NUMBER_DATA; + +typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA; + +typedef enum { + ProcessorCoreFrequencyRecordType = 1, + ProcessorFsbFrequencyRecordType = 2, + ProcessorVersionRecordType = 3, + ProcessorManufacturerRecordType = 4, + ProcessorSerialNumberRecordType = 5, + ProcessorIdRecordType = 6, + ProcessorTypeRecordType = 7, + ProcessorFamilyRecordType = 8, + ProcessorVoltageRecordType = 9, + ProcessorApicBaseAddressRecordType = 10, + ProcessorApicIdRecordType = 11, + ProcessorApicVersionNumberRecordType = 12, + CpuUcodeRevisionDataRecordType = 13, + ProcessorStatusRecordType = 14, + ProcessorSocketTypeRecordType = 15, + ProcessorSocketNameRecordType = 16, + CacheAssociationRecordType = 17, + ProcessorMaxCoreFrequencyRecordType = 18, + ProcessorAssetTagRecordType = 19, + ProcessorMaxFsbFrequencyRecordType = 20, + ProcessorPackageNumberRecordType = 21, + ProcessorCoreFrequencyListRecordType = 22, + ProcessorFsbFrequencyListRecordType = 23, + ProcessorHealthStatusRecordType = 24 +} EFI_CPU_VARIABLE_RECORD_TYPE; + +typedef union { + EFI_PROCESSOR_CORE_FREQUENCY_LIST_DATA ProcessorCoreFrequencyList; + EFI_PROCESSOR_FSB_FREQUENCY_LIST_DATA ProcessorFsbFrequencyList; + EFI_PROCESSOR_SERIAL_NUMBER_DATA ProcessorSerialNumber; + EFI_PROCESSOR_CORE_FREQUENCY_DATA ProcessorCoreFrequency; + EFI_PROCESSOR_FSB_FREQUENCY_DATA ProcessorFsbFrequency; + EFI_PROCESSOR_MAX_CORE_FREQUENCY_DATA ProcessorMaxCoreFrequency; + EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA ProcessorMaxFsbFrequency; + EFI_PROCESSOR_VERSION_DATA ProcessorVersion; + EFI_PROCESSOR_MANUFACTURER_DATA ProcessorManufacturer; + EFI_PROCESSOR_ID_DATA ProcessorId; + EFI_PROCESSOR_TYPE_DATA ProcessorType; + EFI_PROCESSOR_FAMILY_DATA ProcessorFamily; + EFI_PROCESSOR_VOLTAGE_DATA ProcessorVoltage; + EFI_PROCESSOR_APIC_BASE_ADDRESS_DATA ProcessorApicBase; + EFI_PROCESSOR_APIC_ID_DATA ProcessorApicId; + EFI_PROCESSOR_APIC_VERSION_NUMBER_DATA ProcessorApicVersionNumber; + EFI_PROCESSOR_MICROCODE_REVISION_DATA CpuUcodeRevisionData; + EFI_PROCESSOR_STATUS_DATA ProcessorStatus; + EFI_PROCESSOR_SOCKET_TYPE_DATA ProcessorSocketType; + EFI_PROCESSOR_SOCKET_NAME_DATA ProcessorSocketName; + EFI_PROCESSOR_ASSET_TAG_DATA ProcessorAssetTag; + EFI_PROCESSOR_HEALTH_STATUS ProcessorHealthStatus; + EFI_PROCESSOR_PACKAGE_NUMBER_DATA ProcessorPackageNumber; +} EFI_CPU_VARIABLE_RECORD; + +typedef struct { + EFI_SUBCLASS_TYPE1_HEADER DataRecordHeader; + EFI_CPU_VARIABLE_RECORD VariableRecord; +} EFI_CPU_DATA_RECORD; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.c new file mode 100644 index 0000000000..4d991f937a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DxeServices.c + +Abstract: + + GUID used for the DXE Services Table + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (DxeServices) + +EFI_GUID gEfiDxeServicesTableGuid = EFI_DXE_SERVICES_TABLE_GUID; + +EFI_GUID_STRING(&gEfiDxeServicesTableGuid, "DXE Services Table", "DXE Services Table GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.h new file mode 100644 index 0000000000..29a4050bdd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DxeServices/DxeServices.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DxeServices.h + +Abstract: + + GUID used for the DXE Services Table + +--*/ + +#ifndef _DXE_SERVICES_H_ +#define _DXE_SERVICES_H_ + +#define EFI_DXE_SERVICES_TABLE_GUID \ + { \ + 0x5ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 \ + } + +extern EFI_GUID gEfiDxeServicesTableGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf new file mode 100644 index 0000000000..f3c2b74602 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf @@ -0,0 +1,63 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkFrameworkGuidLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME= EdkFrameworkGuidLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + +[nmake.common] + +[sources.common] + AcpiTableStorage\AcpiTableStorage.h + AcpiTableStorage\AcpiTableStorage.c + Apriori\Apriori.h + Apriori\Apriori.c + DataHubRecords\DataHubRecords.h + DataHubRecords\DataHubRecords.c + DxeServices\DxeServices.h + DxeServices\DxeServices.c + FirmwareFileSystem\FirmwareFileSystem.h + FirmwareFileSystem\FirmwareFileSystem.c + Hob\Hob.h + Hob\Hob.c + MemoryAllocationHob\MemoryAllocationHob.c + MemoryAllocationHob\MemoryAllocationHob.h + SmramMemoryReserve\SmramMemoryReserve.h + SmramMemoryReserve\SmramMemoryReserve.c + StatusCodeDataTypeId\StatusCodeDataTypeId.h + StatusCodeDataTypeId\StatusCodeDataTypeId.c + FrameworkDevicePath\FrameworkDevicePath.h + FrameworkDevicePath\FrameworkDevicePath.c + FirmwareFileSystem2\FirmwareFileSystem2.h + FirmwareFileSystem2\FirmwareFileSystem2.c + PeiApriori\PeiApriori.h + PeiApriori\PeiApriori.c diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c new file mode 100644 index 0000000000..a704cf1b48 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareFileSystem.c + +Abstract: + + Tiano Guid used to define the Firmware File System. See the EFI Firmware + File System Specification for more details. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (FirmwareFileSystem) + +EFI_GUID gEfiFirmwareFileSystemGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID; +EFI_GUID gEfiFirmwareVolumeTopFileGuid = EFI_FFS_VOLUME_TOP_FILE_GUID; + +EFI_GUID_STRING(&gEfiFirmwareFileSystemGuid, "Firmware File System GUID", "EFI Firmware File System GUID"); +EFI_GUID_STRING(&gEfiFirmwareVolumeTopFileGuid, "Firmware Volume Top File GUID", "EFI FFS Volume Top File GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h new file mode 100644 index 0000000000..6d04092a88 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareFileSystem.h + +Abstract: + + Tiano Guid used to define the Firmware File System. See the EFI Firmware + File System Specification for more details. + +--*/ + +#ifndef _FIRMWARE_FILE_SYSTEM_GUID_H +#define _FIRMWARE_FILE_SYSTEM_GUID_H + +// +// GUID definitions are in EfiFirmwareFileSystem.h +// +#include "EfiFirmwareFileSystem.h" + +extern EFI_GUID gEfiFirmwareFileSystemGuid; +extern EFI_GUID gEfiFirmwareVolumeTopFileGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c new file mode 100644 index 0000000000..27a8b837bf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareFileSystem2.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(FirmwareFileSystem2) + +EFI_GUID gEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID; +EFI_GUID_STRING(&gEfiFirmwareFileSystem2Guid, "FirmwareFileSystem2", "Efi FirmwareFileSystem2") + diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h new file mode 100644 index 0000000000..3aca502aae --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareFileSystem2.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#ifndef __FIRMWARE_FILE_SYSTEM2_GUID_H__ +#define __FIRMWARE_FILE_SYSTEM2_GUID_H__ + +// +// GUIDs defined by the FFS specification. +// +#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \ + { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } } + +extern EFI_GUID gEfiFirmwareFileSystem2Guid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c new file mode 100644 index 0000000000..60562c91bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FrameworkDevicePath.c + +Abstract: + + GUID used for + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (FrameworkDevicePath) + +EFI_GUID gEfiFrameworkDevicePathGuid = EFI_FRAMEWORK_DEVICE_PATH_GUID; + +EFI_GUID_STRING(&gEfiFrameworkDevicePathGuid, "Framework Devic Path", "Framework Device Path GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h new file mode 100644 index 0000000000..e8adbaf32a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h @@ -0,0 +1,29 @@ +/*++ + This GUID is used to define a vendor specific device path being owned by the + Framework specificaitons. + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: FrameworkDevicePath.h + + @par Revision Reference: + Spec Version 0.9 + +--*/ + +#ifndef __FRAMEWORK_DEVICE_PATH_GUID_H__ +#define __FRAMEWORK_DEVICE_PATH_GUID_H__ + +#define EFI_FRAMEWORK_DEVICE_PATH_GUID \ + { 0xb7084e63, 0x46b7, 0x4d1a, { 0x86, 0x77, 0xe3, 0x0b, 0x53, 0xdb, 0xf0, 0x50 } } + +extern EFI_GUID gEfiFrameworkDevicePathGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.c new file mode 100644 index 0000000000..b69d107bb3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Hob.c + +Abstract: + + GUIDs used for HOB List in the EFI 1.0 system table + + These GUIDs point the HOB List passed in from PEI to DXE. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (Hob) + +EFI_GUID gEfiHobListGuid = EFI_HOB_LIST_GUID; + +EFI_GUID_STRING(&gEfiHobListGuid, "HOB List", "HOB List GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.h new file mode 100644 index 0000000000..250359fe11 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/Hob/Hob.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Hob.h + +Abstract: + + GUIDs used for HOB List entries in the in the EFI 1.0 system table + + These GUIDs point the HOB List passed from PEI to DXE. + +--*/ + +#ifndef _HOB_GUID_H_ +#define _HOB_GUID_H_ + +#define EFI_HOB_LIST_GUID \ + { \ + 0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \ + } + +extern EFI_GUID gEfiHobListGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c new file mode 100644 index 0000000000..7a03712773 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemoryAllocationHob.c + +Abstract: + + GUIDs for HOBs used in memory allcation + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(MemoryAllocationHob) + +EFI_GUID gEfiHobMemeryAllocBspStoreGuid = EFI_HOB_MEMORY_ALLOC_BSP_STORE_GUID; +EFI_GUID gEfiHobMemeryAllocStackGuid = EFI_HOB_MEMORY_ALLOC_STACK_GUID; +EFI_GUID gEfiHobMemeryAllocModuleGuid = EFI_HOB_MEMORY_ALLOC_MODULE_GUID; + +EFI_GUID_STRING(&gEfiHobMemeryAllocBspStoreGuid, "BSP Store HOB", "HOB for BSP Store Memory Allocation"); +EFI_GUID_STRING(&gEfiHobMemeryAllocStackGuid, "Stack HOB", "HOB for Stack Memory Allocation"); +EFI_GUID_STRING(&gEfiHobMemeryAllocModuleGuid, "Memry Allocation Module HOB", "HOB for Memory Allocation Module"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h new file mode 100644 index 0000000000..9afc36d702 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemoryAllocationHob.h + +Abstract: + + GUIDs for HOBs used in memory allcation + +--*/ + +#ifndef _HOB__MEMORY_ALLOCATION_GUID_H_ +#define _HOB__MEMORY_ALLOCATION_GUID_H_ + +#define EFI_HOB_MEMORY_ALLOC_BSP_STORE_GUID \ + {0x564b33cd, 0xc92a, 0x4593, 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22}; + +#define EFI_HOB_MEMORY_ALLOC_STACK_GUID \ + {0x4ed4bf27, 0x4092, 0x42e9, 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x0, 0xc9, 0xbd} + +#define EFI_HOB_MEMORY_ALLOC_MODULE_GUID \ + {0xf8e21975, 0x899, 0x4f58, 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a} + +extern EFI_GUID gEfiHobMemeryAllocBspStoreGuid; +extern EFI_GUID gEfiHobMemeryAllocStackGuid; +extern EFI_GUID gEfiHobMemeryAllocModuleGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.c new file mode 100644 index 0000000000..c8136efddd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.c @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiApriori.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PeiApriori) + +EFI_GUID gEfiPeiAprioriGuid = EFI_PEI_APRIORI_FILE_NAME_GUID; +EFI_GUID_STRING(&gEfiPeiAprioriGuid, "PeiApriori", "Efi PeiApriori") diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.h new file mode 100644 index 0000000000..9125e45878 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/PeiApriori/PeiApriori.h @@ -0,0 +1,36 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiApriori.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#ifndef __PEI_APRIORI_GUID_H__ +#define __PEI_APRIORI_GUID_H__ + +#include "Tiano.h" + +// +// GUIDs defined by the FFS specification. +// +#define EFI_PEI_APRIORI_FILE_NAME_GUID \ + { 0x1b45cc0a, 0x156a, 0x428a, 0xaf, 0x62, 0x49, 0x86, 0x4d, 0xa0, 0xe6, 0xe6} + + +extern EFI_GUID gEfiPeiAprioriGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c new file mode 100644 index 0000000000..ea0391798b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmramMemoryReserve.c + +Abstract: + + GUID for use in reserving SMRAM regions. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(SmramMemoryReserve) + +EFI_GUID gEfiSmmPeiSmramMemoryReserve = EFI_SMM_PEI_SMRAM_MEMORY_RESERVE; + +EFI_GUID_STRING(&gEfiSmmPeiSmramMemoryReserve, "SMRAM Memory Reserve", "SMRAM Memory Reserve"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h new file mode 100644 index 0000000000..d848e28dc8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h @@ -0,0 +1,70 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmramMemoryReserve.h + +Abstract: + + GUID for use in reserving SMRAM regions. + +--*/ + +#ifndef _EFI_SMM_PEI_SMRAM_MEMORY_RESERVE_H_ +#define _EFI_SMM_PEI_SMRAM_MEMORY_RESERVE_H_ + +#define EFI_SMM_PEI_SMRAM_MEMORY_RESERVE \ + { \ + 0x6dadf1d1, 0xd4cc, 0x4910, 0xbb, 0x6e, 0x82, 0xb1, 0xfd, 0x80, 0xff, 0x3d \ + } + +// +// ******************************************************* +// EFI_SMRAM_DESCRIPTOR +// ******************************************************* +// +typedef struct { + EFI_PHYSICAL_ADDRESS PhysicalStart; // Phsyical location in DRAM + EFI_PHYSICAL_ADDRESS CpuStart; // Address CPU uses to access the SMI handler + // May or may not match PhysicalStart + // + UINT64 PhysicalSize; + UINT64 RegionState; +} EFI_SMRAM_DESCRIPTOR; + +// +// ******************************************************* +// EFI_SMRAM_STATE +// ******************************************************* +// +#define EFI_SMRAM_OPEN 0x00000001 +#define EFI_SMRAM_CLOSED 0x00000002 +#define EFI_SMRAM_LOCKED 0x00000004 +#define EFI_CACHEABLE 0x00000008 +#define EFI_ALLOCATED 0x00000010 +#define EFI_NEEDS_TESTING 0x00000020 +#define EFI_NEEDS_ECC_INITIALIZATION 0x00000040 + +// +// ******************************************************* +// EFI_SMRAM_HOB_DESCRIPTOR_BLOCK +// ******************************************************* +// +typedef struct { + UINT32 NumberOfSmmReservedRegions; + EFI_SMRAM_DESCRIPTOR Descriptor[1]; +} EFI_SMRAM_HOB_DESCRIPTOR_BLOCK; + +extern EFI_GUID gEfiSmmPeiSmramMemoryReserve; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c b/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c new file mode 100644 index 0000000000..1fa9c2ef91 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCodeDataTypeId.c + +Abstract: + + GUID used to identify id for the caller who is initiating the Status Code. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +// +// Taken out from StatusCode.C created by PRC +// +EFI_GUID gEfiStatusCodeDataTypeStringGuid = EFI_STATUS_CODE_DATA_TYPE_STRING_GUID; +EFI_GUID gEfiStatusCodeDataTypeDebugGuid = EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID; +EFI_GUID gEfiStatusCodeDataTypeAssertGuid = EFI_STATUS_CODE_DATA_TYPE_ASSERT_GUID; +EFI_GUID gEfiStatusCodeDataTypeExceptionHandlerGuid = EFI_STATUS_CODE_DATA_TYPE_EXCEPTION_HANDLER_GUID; +EFI_GUID gEfiStatusCodeDataTypeErrorGuid = EFI_STATUS_CODE_DATA_TYPE_ERROR_GUID; +EFI_GUID gEfiStatusCodeDataTypeProgressCodeGuid = EFI_STATUS_CODE_DATA_TYPE_PROGRESS_CODE_GUID; + +EFI_GUID gEfiStatusCodeSpecificDataGuid = EFI_STATUS_CODE_SPECIFIC_DATA_GUID; + +EFI_GUID_STRING(&gEfiStatusCodeDataTypeStringGuid, "Status Code", "Data Hub record Data type String"); +EFI_GUID_STRING(&gEfiStatusCodeSpecificDataGuid, "Status Code", "Data Hub record Data type specific "); +EFI_GUID_STRING(&gEfiStatusCodeDataTypeDebugGuid, "Status Code", "Data Hub record data type Debug"); +EFI_GUID_STRING(&gEfiStatusCodeDataTypeAssertGuid, "Status Code", "Data Hub record data type Assert"); +EFI_GUID_STRING(&gEfiStatusCodeDataTypeErrorGuid, "Status Code", "Data Hub record data type Error"); +EFI_GUID_STRING(&gEfiStatusCodeDataTypeProgressCodeGuid, "Status Code", "Data Hub record data type Progress Code"); +EFI_GUID_STRING + (&gEfiStatusCodeDataTypeExceptionHandlerGuid, "Status Code", "Data Hub record Data type Exception handler"); + +EFI_GUID_STRING + (&gEfiStatusCodeSpecificDataGuid, "Status Code Specific Data", "Specific Data for Tiano ReportStatusCode API"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h new file mode 100644 index 0000000000..bc26539ac0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h @@ -0,0 +1,385 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCodeDataTypeId.h + +Abstract: + + GUID used to identify id for the caller who is initiating the Status Code. + +--*/ + +#ifndef _STATUS_CODE_DATA_TYPE_ID_H__ +#define _STATUS_CODE_DATA_TYPE_ID_H__ + + +#include "EfiStatusCode.h" +#include EFI_PROTOCOL_DEFINITION (DebugSupport) +#include EFI_PROTOCOL_DEFINITION (Hii) +// +// The size of string +// +#define EFI_STATUS_CODE_DATA_MAX_STRING_SIZE 150 + +// +// This is the max data size including all the headers which can be passed +// as Status Code data. This data should be multiple of 8 byte +// to avoid any kind of boundary issue. Also, sum of this data size (inclusive +// of size of EFI_STATUS_CODE_DATA should not exceed the max record size of +// data hub +// +#define EFI_STATUS_CODE_DATA_MAX_SIZE 200 + +// +// String Data Type defintion. This is part of Status Code Specification +// +#define EFI_STATUS_CODE_DATA_TYPE_STRING_GUID \ + { \ + 0x92D11080, 0x496F, 0x4D95, 0xBE, 0x7E, 0x03, 0x74, 0x88, 0x38, 0x2B, 0x0A \ + } + +extern EFI_GUID gEfiStatusCodeDataTypeStringGuid; + +// +// This GUID indicates that the format of the accompanying data depends +// upon the Status Code Value, but follows this Specification +// +#define EFI_STATUS_CODE_SPECIFIC_DATA_GUID \ + { \ + 0x335984bd, 0xe805, 0x409a, 0xb8, 0xf8, 0xd2, 0x7e, 0xce, 0x5f, 0xf7, 0xa6 \ + } + +extern EFI_GUID gEfiStatusCodeSpecificDataGuid; + +#pragma pack(1) + +typedef enum { + EfiStringAscii, + EfiStringUnicode, + EfiStringToken +} EFI_STRING_TYPE; + +// +// HII string token +// +typedef struct { +EFI_HII_HANDLE Handle; +STRING_REF Token; +} EFI_STATUS_CODE_STRING_TOKEN; + +typedef union { +CHAR8 *Ascii; +CHAR16 *Unicode; +EFI_STATUS_CODE_STRING_TOKEN Hii; +} EFI_STATUS_CODE_STRING; + +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_STRING_TYPE StringType; + EFI_STATUS_CODE_STRING String; +} EFI_STATUS_CODE_STRING_DATA; + +#pragma pack() +// +// Debug Assert Data. This is part of Status Code Specification +// +#define EFI_STATUS_CODE_DATA_TYPE_ASSERT_GUID \ + { \ + 0xDA571595, 0x4D99, 0x487C, 0x82, 0x7C, 0x26, 0x22, 0x67, 0x7D, 0x33, 0x07 \ + } + +extern EFI_GUID gEfiStatusCodeDataTypeAssertGuid; + +// +// Exception Data type (CPU REGS) +// +#define EFI_STATUS_CODE_DATA_TYPE_EXCEPTION_HANDLER_GUID \ + { \ + 0x3BC2BD12, 0xAD2E, 0x11D5, 0x87, 0xDD, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9 \ + } + +extern EFI_GUID gEfiStatusCodeDataTypeExceptionHandlerGuid; + +// +// Debug DataType defintions. User Defined Data Types. +// +#define EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID \ + { \ + 0x9A4E9246, 0xD553, 0x11D5, 0x87, 0xE2, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xb9 \ + } + +#pragma pack(1) + +typedef struct { + UINT32 ErrorLevel; + // + // 12 * sizeof (UINT64) Var Arg stack + // + // ascii DEBUG () Format string + // +} EFI_DEBUG_INFO; + +#pragma pack() + +extern EFI_GUID gEfiStatusCodeDataTypeDebugGuid; + +// +// Progress Code. User Defined Data Type Guid. +// +#define EFI_STATUS_CODE_DATA_TYPE_ERROR_GUID \ + { \ + 0xAB359CE3, 0x99B3, 0xAE18, 0xC8, 0x9D, 0x95, 0xD3, 0xB0, 0x72, 0xE1, 0x9B \ + } + +extern EFI_GUID gEfiStatusCodeDataTypeErrorGuid; + +// +// declaration for EFI_EXP_DATA. This may change +// +typedef UINTN EFI_EXP_DATA; + +// +// Voltage Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_EXP_DATA Voltage; + EFI_EXP_DATA Threshold; +} EFI_COMPUTING_UNIT_VOLTAGE_ERROR_DATA; + +// +// Microcode Update Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + UINT32 Version; +} EFI_COMPUTING_UNIT_MICROCODE_UPDATE_ERROR_DATA; + +// +// Asynchronous Timer Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_EXP_DATA TimerLimit; +} EFI_COMPUTING_UNIT_TIMER_EXPIRED_ERROR_DATA; + +// +// Host Processor Mismatch Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + UINT32 Instance; + UINT16 Attributes; +} EFI_HOST_PROCESSOR_MISMATCH_ERROR_DATA; + +// +// EFI_COMPUTING_UNIT_MISMATCH_ATTRIBUTES +// All other attributes are reserved for future use and +// must be initialized to 0. +// +#define EFI_COMPUTING_UNIT_MISMATCH_SPEED 0x0001 +#define EFI_COMPUTING_UNIT_MISMATCH_FSB_SPEED 0x0002 +#define EFI_COMPUTING_UNIT_MISMATCH_FAMILY 0x0004 +#define EFI_COMPUTING_UNIT_MISMATCH_MODEL 0x0008 +#define EFI_COMPUTING_UNIT_MISMATCH_STEPPING 0x0010 +#define EFI_COMPUTING_UNIT_MISMATCH_CACHE_SIZE 0x0020 +#define EFI_COMPUTING_UNIT_MISMATCH_OEM1 0x1000 +#define EFI_COMPUTING_UNIT_MISMATCH_OEM2 0x2000 +#define EFI_COMPUTING_UNIT_MISMATCH_OEM3 0x4000 +#define EFI_COMPUTING_UNIT_MISMATCH_OEM4 0x8000 + +// +// Thermal Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_EXP_DATA Temperature; + EFI_EXP_DATA Threshold; +} EFI_COMPUTING_UNIT_THERMAL_ERROR_DATA; + +// +// Processor Disabled Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + UINT32 Cause; + BOOLEAN SoftwareDisabled; +} EFI_COMPUTING_UNIT_CPU_DISABLED_ERROR_DATA; + +typedef enum { + EfiInitCacheDataOnly, + EfiInitCacheInstrOnly, + EfiInitCacheBoth, + EfiInitCacheUnspecified +} EFI_INIT_CACHE_TYPE; + +// +// Embedded cache init extended data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + UINT32 Level; + EFI_INIT_CACHE_TYPE Type; +} EFI_CACHE_INIT_DATA; + +// +// Memory Extended Error Data +// +// +// Memory Error Granularity Definition +// +typedef UINT8 EFI_MEMORY_ERROR_GRANULARITY; + +// +// Memory Error Operation Definition +// +typedef UINT8 EFI_MEMORY_ERROR_OPERATION; + +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_MEMORY_ERROR_GRANULARITY Granularity; + EFI_MEMORY_ERROR_OPERATION Operation; + UINTN Syndrome; + EFI_PHYSICAL_ADDRESS Address; + UINTN Resolution; +} EFI_MEMORY_EXTENDED_ERROR_DATA; + +// +// Memory Error Granularities +// +#define EFI_MEMORY_ERROR_OTHER 0x01 +#define EFI_MEMORY_ERROR_UNKNOWN 0x02 +#define EFI_MEMORY_ERROR_DEVICE 0x03 +#define EFI_MEMORY_ERROR_PARTITION 0x04 + +// +// Memory Error Operations +// +#define EFI_MEMORY_OPERATION_OTHER 0x01 +#define EFI_MEMORY_OPERATION_UNKNOWN 0x02 +#define EFI_MEMORY_OPERATION_READ 0x03 +#define EFI_MEMORY_OPERATION_WRITE 0x04 +#define EFI_MEMORY_OPERATION_PARTIAL_WRITE 0x05 + +// +// Define shorthands to describe Group Operations +// Many memory init operations are essentially group +// operations. +// A shorthand to describe that the operation is performed +// on multiple devices within the array +// +#define EFI_MULTIPLE_MEMORY_DEVICE_OPERATION 0xfffe +// +// A shorthand to describe that the operation is performed // on all devices within the array +// +#define EFI_ALL_MEMORY_DEVICE_OPERATION 0xffff +// +// A shorthand to describe that the operation is performed // on multiple arrays +// +#define EFI_MULTIPLE_MEMORY_ARRAY_OPERATION 0xfffe +// +// A shorthand to describe that the operation is performed // on all the arrays +// +#define EFI_ALL_MEMORY_ARRAY_OPERATION 0xffff + +// +// DIMM number +// +#pragma pack(1) +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + UINT16 Array; + UINT16 Device; +} EFI_STATUS_CODE_DIMM_NUMBER; +#pragma pack() +// +// Memory Module Mismatch Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_STATUS_CODE_DIMM_NUMBER Instance; +} EFI_MEMORY_MODULE_MISMATCH_ERROR_DATA; + +// +// Memory Range Extended Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_PHYSICAL_ADDRESS Start; + EFI_PHYSICAL_ADDRESS Length; +} EFI_MEMORY_RANGE_EXTENDED_DATA; + +// +// Device handle Extended Data. Used for many +// errors and progress codes to point to the device. +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_HANDLE Handle; +} EFI_DEVICE_HANDLE_EXTENDED_DATA; + +// +// Resource Allocation Failure Extended Error Data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + UINT32 Bar; + VOID *ReqRes; + VOID *AllocRes; +} EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA; + +// +// Extended Error Data for Assert +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + UINT32 LineNumber; + UINT32 FileNameSize; + EFI_STATUS_CODE_STRING_DATA *FileName; +} EFI_DEBUG_ASSERT_DATA; + +// +// System Context Data EBC/IA32/IPF +// +typedef union { + EFI_SYSTEM_CONTEXT_EBC SystemContextEbc; + EFI_SYSTEM_CONTEXT_IA32 SystemContextIa32; + EFI_SYSTEM_CONTEXT_IPF SystemContextIpf; +} EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT; + +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT Context; +} EFI_STATUS_CODE_EXCEP_EXTENDED_DATA; + +// +// Legacy Oprom extended data +// +typedef struct { + EFI_STATUS_CODE_DATA DataHeader; + EFI_HANDLE DeviceHandle; + EFI_PHYSICAL_ADDRESS RomImageBase; +} EFI_LEGACY_OPROM_EXTENDED_DATA; + +// +// Progress Code. User Defined Data Type Guid. +// +#define EFI_STATUS_CODE_DATA_TYPE_PROGRESS_CODE_GUID \ + { \ + 0xA356AB39, 0x35C4, 0x35DA, 0xB3, 0x7A, 0xF8, 0xEA, 0x9E, 0x8B, 0x36, 0xA3 \ + } + +extern EFI_GUID gEfiStatusCodeDataTypeProgressCodeGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/BootMode.h b/EdkCompatibilityPkg/Foundation/Framework/Include/BootMode.h new file mode 100644 index 0000000000..c37f368f0a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/BootMode.h @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootMode.h + +Abstract: + + This includes for the Boot mode information. + +--*/ + +#ifndef _EFI_BOOT_MODE_H +#define _EFI_BOOT_MODE_H + +#define BOOT_WITH_FULL_CONFIGURATION 0x00 +#define BOOT_WITH_MINIMAL_CONFIGURATION 0x01 +#define BOOT_ASSUMING_NO_CONFIGURATION_CHANGES 0x02 +#define BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03 +#define BOOT_WITH_DEFAULT_SETTINGS 0x04 +#define BOOT_ON_S4_RESUME 0x05 +#define BOOT_ON_S5_RESUME 0x06 +#define BOOT_ON_S2_RESUME 0x10 +#define BOOT_ON_S3_RESUME 0x11 +#define BOOT_ON_FLASH_UPDATE 0x12 +#define BOOT_IN_RECOVERY_MODE 0x20 +#define BOOT_IN_RECOVERY_MODE_MASK 0x40 +#define BOOT_SPECIAL_MASK 0x80 +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiBootScript.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiBootScript.h new file mode 100644 index 0000000000..0daa738110 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiBootScript.h @@ -0,0 +1,210 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiBootScript.h + +Abstract: + + + +--*/ + +#ifndef _EFI_SCRIPT_H_ +#define _EFI_SCRIPT_H_ + +#include "EfiSmbus.h" + +#define EFI_ACPI_S3_RESUME_SCRIPT_TABLE 0x00 + +// +// Boot Script Opcode Definitions +// +typedef const UINT16 EFI_BOOT_SCRIPT_OPCODE; + +#define EFI_BOOT_SCRIPT_IO_WRITE_OPCODE 0x00 +#define EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE 0x01 +#define EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE 0x02 +#define EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE 0x03 +#define EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE 0x04 +#define EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE 0x05 +#define EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE 0x06 +#define EFI_BOOT_SCRIPT_STALL_OPCODE 0x07 +#define EFI_BOOT_SCRIPT_DISPATCH_OPCODE 0x08 +#define EFI_BOOT_SCRIPT_INFORMATION_OPCODE 0x0A + +#define EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE 0x0B +#define EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE 0x0C + +#define EFI_BOOT_SCRIPT_TABLE_OPCODE 0xAA +#define EFI_BOOT_SCRIPT_TERMINATE_OPCODE 0xFF + +#pragma pack(1) + +// +// EFI Boot Script Width +// +typedef enum { + EfiBootScriptWidthUint8, + EfiBootScriptWidthUint16, + EfiBootScriptWidthUint32, + EfiBootScriptWidthUint64, + EfiBootScriptWidthFifoUint8, + EfiBootScriptWidthFifoUint16, + EfiBootScriptWidthFifoUint32, + EfiBootScriptWidthFifoUint64, + EfiBootScriptWidthFillUint8, + EfiBootScriptWidthFillUint16, + EfiBootScriptWidthFillUint32, + EfiBootScriptWidthFillUint64, + EfiBootScriptWidthMaximum +} EFI_BOOT_SCRIPT_WIDTH; + +typedef struct { + UINT16 OpCode; + UINT8 Length; +} EFI_BOOT_SCRIPT_GENERIC_HEADER; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT16 Version; + UINT32 TableLength; + UINT16 Reserved[2]; +} EFI_BOOT_SCRIPT_TABLE_HEADER; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; +} EFI_BOOT_SCRIPT_COMMON_HEADER; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT32 Count; + UINT64 Address; +} EFI_BOOT_SCRIPT_IO_WRITE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT64 Address; +} EFI_BOOT_SCRIPT_IO_READ_WRITE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT32 Count; + UINT64 Address; +} EFI_BOOT_SCRIPT_MEM_WRITE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT64 Address; +} EFI_BOOT_SCRIPT_MEM_READ_WRITE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT32 Count; + UINT64 Address; +} EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT32 Count; + UINT64 Address; + UINT16 Segment; +} EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT64 Address; +} EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 Width; + UINT64 Address; + UINT16 Segment; +} EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE; + + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT64 SlaveAddress; + UINT64 Command; + UINT32 Operation; + BOOLEAN PecCheck; + UINT32 DataSize; +} EFI_BOOT_SCRIPT_SMBUS_EXECUTE; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT64 Duration; +} EFI_BOOT_SCRIPT_STALL; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + EFI_PHYSICAL_ADDRESS EntryPoint; +} EFI_BOOT_SCRIPT_DISPATCH; + +typedef struct { + UINT16 OpCode; + UINT8 Length; + UINT32 InformationLength; + EFI_PHYSICAL_ADDRESS Information; +} EFI_BOOT_SCRIPT_INFORMATION; + +typedef struct { + UINT16 OpCode; + UINT8 Length; +} EFI_BOOT_SCRIPT_TERMINATE; + +typedef union { + EFI_BOOT_SCRIPT_GENERIC_HEADER *Header; + EFI_BOOT_SCRIPT_TABLE_HEADER *TableInfo; + EFI_BOOT_SCRIPT_IO_WRITE *IoWrite; + EFI_BOOT_SCRIPT_IO_READ_WRITE *IoReadWrite; + EFI_BOOT_SCRIPT_MEM_WRITE *MemWrite; + EFI_BOOT_SCRIPT_MEM_READ_WRITE *MemReadWrite; + EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE *PciWrite; + EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE *PciReadWrite; + EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE *PciWrite2; + EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE *PciReadWrite2; + EFI_BOOT_SCRIPT_SMBUS_EXECUTE *SmbusExecute; + EFI_BOOT_SCRIPT_STALL *Stall; + EFI_BOOT_SCRIPT_DISPATCH *Dispatch; + EFI_BOOT_SCRIPT_INFORMATION *Information; + EFI_BOOT_SCRIPT_TERMINATE *Terminate; + EFI_BOOT_SCRIPT_COMMON_HEADER *CommonHeader; + UINT8 *Raw; +} BOOT_SCRIPT_POINTERS; + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h new file mode 100644 index 0000000000..79ecfc58b8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h @@ -0,0 +1,136 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCapsule.h + +Abstract: + + Defines for the EFI Capsule functionality + +--*/ + +#ifndef _EFI_CAPSULE_H_ +#define _EFI_CAPSULE_H_ + + +#define CAPSULE_BLOCK_DESCRIPTOR_SIGNATURE EFI_SIGNATURE_32 ('C', 'B', 'D', 'S') + +typedef struct { + EFI_GUID OemGuid; + UINT32 HeaderSize; + // + // UINT8 OemHdrData[]; + // +} EFI_CAPSULE_OEM_HEADER; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +#define MAX_SUPPORT_CAPSULE_NUM 50 +#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 +#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 + +typedef struct { + UINT64 Length; + union { + EFI_PHYSICAL_ADDRESS DataBlock; + EFI_PHYSICAL_ADDRESS ContinuationPointer; + } Union; +} EFI_CAPSULE_BLOCK_DESCRIPTOR; + +typedef struct { + EFI_GUID CapsuleGuid; + UINT32 HeaderSize; + UINT32 Flags; + UINT32 CapsuleImageSize; +} EFI_CAPSULE_HEADER; + +typedef struct { + UINT32 CapsuleArrayNumber; + VOID* CapsulePtr[1]; +} EFI_CAPSULE_TABLE; + +typedef struct { + UINT32 CapsuleGuidNumber; + EFI_GUID CapsuleGuidPtr[1]; +} EFI_CAPSULE_INFO_TABLE; + +// +// This GUID is used for collecting all capsules' Guids who install in ConfigTable. +// +#define EFI_CAPSULE_INFO_GUID \ + { \ + 0x8B34EAC7, 0x2690, 0x460B, 0x8B, 0xA5, 0xD5, 0xCF, 0x32, 0x83, 0x17, 0x35 \ + } + +#else + +typedef struct { + EFI_GUID CapsuleGuid; + UINT32 HeaderSize; + UINT32 Flags; + UINT32 CapsuleImageSize; + UINT32 SequenceNumber; + EFI_GUID InstanceId; + UINT32 OffsetToSplitInformation; + UINT32 OffsetToCapsuleBody; + UINT32 OffsetToOemDefinedHeader; + UINT32 OffsetToAuthorInformation; + UINT32 OffsetToRevisionInformation; + UINT32 OffsetToShortDescription; + UINT32 OffsetToLongDescription; + UINT32 OffsetToApplicableDevices; +} EFI_CAPSULE_HEADER; + +// +// An array of these describe the blocks that make up a capsule for +// a capsule update. +// +typedef struct { + UINT64 Length; // length of the data block + EFI_PHYSICAL_ADDRESS Data; // physical address of the data block + UINT32 Signature; // CBDS + UINT32 CheckSum; // to sum this structure to 0 +} EFI_CAPSULE_BLOCK_DESCRIPTOR; + +#endif + +// +// Bits in the flags field of the capsule header +// +#define EFI_CAPSULE_HEADER_FLAG_SETUP 0x00000001 // supports setup changes +// +// This is the GUID of the capsule header of the image on disk. +// +#define EFI_CAPSULE_GUID \ + { \ + 0x3B6686BD, 0x0D76, 0x4030, 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 \ + } + +// +// This is the GUID of the file created by the capsule application that contains +// the path to the device(s) to update. +// +#define EFI_PATH_FILE_NAME_GUID \ + { \ + 0x7644C181, 0xFA6E, 0x46DA, 0x80, 0xCB, 0x04, 0xB9, 0x90, 0x40, 0x62, 0xE8 \ + } +// +// This is the GUID of the configuration results file created by the capsule +// application. +// +#define EFI_CONFIG_FILE_NAME_GUID \ + { \ + 0x98B8D59B, 0xE8BA, 0x48EE, 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB \ + } + +#endif // #ifndef _EFI_CAPSULE_H_ diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiDependency.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiDependency.h new file mode 100644 index 0000000000..599698d209 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiDependency.h @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiDependency.h + +Abstract: + + This module contains data specific to dependency expressions + and local function prototypes. + +--*/ + +#ifndef _DEPENDENCY_H_ +#define _DEPENDENCY_H_ + +// +// +// EFI_DEP_BEFORE - If present, it must be the first and only opcode +// EFI_DEP_AFTER - If present, it must be the first and only opcode +// EFI_DEP_SOR - If present, it must be the first opcode +// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression +// to save time. A EFI_DEP_PUSH is evauated one an +// replaced with EFI_DEP_REPLACE_TRUE +// +#define EFI_DEP_BEFORE 0x00 +#define EFI_DEP_AFTER 0x01 +#define EFI_DEP_PUSH 0x02 +#define EFI_DEP_AND 0x03 +#define EFI_DEP_OR 0x04 +#define EFI_DEP_NOT 0x05 +#define EFI_DEP_TRUE 0x06 +#define EFI_DEP_FALSE 0x07 +#define EFI_DEP_END 0x08 +#define EFI_DEP_SOR 0x09 +#define EFI_DEP_REPLACE_TRUE 0xff + +// +// Define the initial size of the dependency expression evaluation stack +// +#define DEPEX_STACK_SIZE_INCREMENT 0x1000 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareFileSystem.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareFileSystem.h new file mode 100644 index 0000000000..e246eac6eb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareFileSystem.h @@ -0,0 +1,128 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiFirmwareFileSystem.h + +Abstract: + + This file defines the data structures that comprise the FFS file system. + +--*/ + +#ifndef _EFI_FFS_FILE_SYSTEM_H_ +#define _EFI_FFS_FILE_SYSTEM_H_ + +#include "EfiImageFormat.h" + +// +// GUIDs defined by the FFS specification. +// +#define EFI_FIRMWARE_FILE_SYSTEM_GUID \ + { \ + 0x7A9354D9, 0x0468, 0x444a, 0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF \ + } + +#define EFI_FFS_VOLUME_TOP_FILE_GUID \ + { \ + 0x1BA0062E, 0xC779, 0x4582, 0x85, 0x66, 0x33, 0x6A, 0xE8, 0xF7, 0x8F, 0x9 \ + } + +// +// FFS specific file types +// +#define EFI_FV_FILETYPE_FFS_PAD 0xF0 + +// +// FFS File Attributes +// +#define FFS_ATTRIB_TAIL_PRESENT 0x01 +#define FFS_ATTRIB_RECOVERY 0x02 +#define FFS_ATTRIB_DATA_ALIGNMENT 0x38 +#define FFS_ATTRIB_CHECKSUM 0x40 +#if (PI_SPECIFICATION_VERSION < 0x00010000) +#define FFS_ATTRIB_HEADER_EXTENSION 0x04 +#else +// +// PI 1.0 definition. +// +#define FFS_ATTRIB_FIXED 0x04 +#endif + + +// +// FFS_FIXED_CHECKSUM is the default checksum value used when the +// FFS_ATTRIB_CHECKSUM attribute bit is clear +// note this is NOT an architecturally defined value, but is in this file for +// implementation convenience +// +#define FFS_FIXED_CHECKSUM 0x5A + + +// +// File state definitions +// +#define EFI_FILE_HEADER_CONSTRUCTION 0x01 +#define EFI_FILE_HEADER_VALID 0x02 +#define EFI_FILE_DATA_VALID 0x04 +#define EFI_FILE_MARKED_FOR_UPDATE 0x08 +#define EFI_FILE_DELETED 0x10 +#define EFI_FILE_HEADER_INVALID 0x20 + +#define EFI_FILE_ALL_STATE_BITS (EFI_FILE_HEADER_CONSTRUCTION | \ + EFI_FILE_HEADER_VALID | \ + EFI_FILE_DATA_VALID | \ + EFI_FILE_MARKED_FOR_UPDATE | \ + EFI_FILE_DELETED | \ + EFI_FILE_HEADER_INVALID \ + ) + +#define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bit) \ + ( \ + (BOOLEAN) ( \ + (FvbAttributes & EFI_FVB_ERASE_POLARITY) ? (((~TestAttributes) & Bit) == Bit) : ((TestAttributes & Bit) == Bit) \ + ) \ + ) + +// +// FFS file integrity check structure +// +typedef UINT16 EFI_FFS_FILE_TAIL; + +typedef union { + struct { + UINT8 Header; + UINT8 File; + } Checksum; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + UINT16 TailReference; +#else + UINT16 Checksum16; +#endif +} EFI_FFS_INTEGRITY_CHECK; + +// +// FFS file header definition +// +typedef UINT8 EFI_FFS_FILE_ATTRIBUTES; +typedef UINT8 EFI_FFS_FILE_STATE; + +typedef struct { + EFI_GUID Name; + EFI_FFS_INTEGRITY_CHECK IntegrityCheck; + EFI_FV_FILETYPE Type; + EFI_FFS_FILE_ATTRIBUTES Attributes; + UINT8 Size[3]; + EFI_FFS_FILE_STATE State; +} EFI_FFS_FILE_HEADER; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolume.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolume.h new file mode 100644 index 0000000000..3a99d51610 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolume.h @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2007 , Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiFirmwareVolume.h + +Abstract: + +--*/ + +#ifndef _EFI_FIRMWARE_VOLUME_H_ +#define _EFI_FIRMWARE_VOLUME_H_ + + +#define FV_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '_') +#define EFI_FV_FILE_ATTRIB_ALIGNMENT 0x0000001F +#define EFI_FV_UNRELIABLE_WRITE 0x00000000 +#define EFI_FV_RELIABLE_WRITE 0x00000001 + + +// +// EFI_FV_ATTRIBUTES bit definitions +// +typedef UINT64 EFI_FV_ATTRIBUTES; +typedef UINT32 EFI_FV_FILE_ATTRIBUTES; +typedef UINT32 EFI_FV_WRITE_POLICY; + + +typedef struct { + EFI_GUID *NameGuid; + EFI_FV_FILETYPE Type; + EFI_FV_FILE_ATTRIBUTES FileAttributes; + VOID *Buffer; + UINT32 BufferSize; +} EFI_FV_WRITE_FILE_DATA; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h new file mode 100644 index 0000000000..6e0fe399c9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h @@ -0,0 +1,213 @@ +/*++ + +Copyright (c) 2004 - 2007 , Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiFirmwareVolumeHeader.h + +Abstract: + + Defines data structure that is the volume header found at the beginning of + all firmware volumes that are either memory mapped, or have an + associated FirmwareVolumeBlock protocol. + +--*/ + +#ifndef _EFI_FIRMWARE_VOLUME_HEADER_H_ +#define _EFI_FIRMWARE_VOLUME_HEADER_H_ + + +// +// Firmware Volume Block Attributes bit definitions +// They are the shared between Framework and PI1.0. +// +typedef UINT32 EFI_FVB_ATTRIBUTES; + +#define EFI_FVB_READ_DISABLED_CAP 0x00000001 +#define EFI_FVB_READ_ENABLED_CAP 0x00000002 +#define EFI_FVB_READ_STATUS 0x00000004 + +#define EFI_FVB_WRITE_DISABLED_CAP 0x00000008 +#define EFI_FVB_WRITE_ENABLED_CAP 0x00000010 +#define EFI_FVB_WRITE_STATUS 0x00000020 + +#define EFI_FVB_LOCK_CAP 0x00000040 +#define EFI_FVB_LOCK_STATUS 0x00000080 + +#define EFI_FVB_STICKY_WRITE 0x00000200 +#define EFI_FVB_MEMORY_MAPPED 0x00000400 +#define EFI_FVB_ERASE_POLARITY 0x00000800 + + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + +#define EFI_FVB_ALIGNMENT_CAP 0x00008000 +#define EFI_FVB_ALIGNMENT_2 0x00010000 +#define EFI_FVB_ALIGNMENT_4 0x00020000 +#define EFI_FVB_ALIGNMENT_8 0x00040000 +#define EFI_FVB_ALIGNMENT_16 0x00080000 +#define EFI_FVB_ALIGNMENT_32 0x00100000 +#define EFI_FVB_ALIGNMENT_64 0x00200000 +#define EFI_FVB_ALIGNMENT_128 0x00400000 +#define EFI_FVB_ALIGNMENT_256 0x00800000 +#define EFI_FVB_ALIGNMENT_512 0x01000000 +#define EFI_FVB_ALIGNMENT_1K 0x02000000 +#define EFI_FVB_ALIGNMENT_2K 0x04000000 +#define EFI_FVB_ALIGNMENT_4K 0x08000000 +#define EFI_FVB_ALIGNMENT_8K 0x10000000 +#define EFI_FVB_ALIGNMENT_16K 0x20000000 +#define EFI_FVB_ALIGNMENT_32K 0x40000000 +#define EFI_FVB_ALIGNMENT_64K 0x80000000 + +#define EFI_FVB_CAPABILITIES (EFI_FVB_READ_DISABLED_CAP | \ + EFI_FVB_READ_ENABLED_CAP | \ + EFI_FVB_WRITE_DISABLED_CAP | \ + EFI_FVB_WRITE_ENABLED_CAP | \ + EFI_FVB_LOCK_CAP \ + ) + +#define EFI_FVB_STATUS (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | EFI_FVB_LOCK_STATUS) + + + +#else + +#define EFI_FVB2_READ_LOCK_CAP 0x00001000 +#define EFI_FVB2_READ_LOCK_STATUS 0x00002000 + +#define EFI_FVB2_WRITE_LOCK_CAP 0x00004000 +#define EFI_FVB2_WRITE_LOCK_STATUS 0x00008000 + +#define EFI_FVB2_ALIGNMENT 0x001F0000 +#define EFI_FVB2_ALIGNMENT_1 0x00000000 +#define EFI_FVB2_ALIGNMENT_2 0x00010000 +#define EFI_FVB2_ALIGNMENT_4 0x00020000 +#define EFI_FVB2_ALIGNMENT_8 0x00030000 +#define EFI_FVB2_ALIGNMENT_16 0x00040000 +#define EFI_FVB2_ALIGNMENT_32 0x00050000 +#define EFI_FVB2_ALIGNMENT_64 0x00060000 +#define EFI_FVB2_ALIGNMENT_128 0x00070000 +#define EFI_FVB2_ALIGNMENT_256 0x00080000 +#define EFI_FVB2_ALIGNMENT_512 0x00090000 +#define EFI_FVB2_ALIGNMENT_1K 0x000A0000 +#define EFI_FVB2_ALIGNMENT_2K 0x000B0000 +#define EFI_FVB2_ALIGNMENT_4K 0x000C0000 +#define EFI_FVB2_ALIGNMENT_8K 0x000D0000 +#define EFI_FVB2_ALIGNMENT_16K 0x000E0000 +#define EFI_FVB2_ALIGNMENT_32K 0x000F0000 +#define EFI_FVB2_ALIGNMENT_64K 0x00100000 +#define EFI_FVB2_ALIGNMENT_128K 0x00110000 +#define EFI_FVB2_ALIGNMENT_256K 0x00120000 +#define EFI_FVB2_ALIGNMNET_512K 0x00130000 +#define EFI_FVB2_ALIGNMENT_1M 0x00140000 +#define EFI_FVB2_ALIGNMENT_2M 0x00150000 +#define EFI_FVB2_ALIGNMENT_4M 0x00160000 +#define EFI_FVB2_ALIGNMENT_8M 0x00170000 +#define EFI_FVB2_ALIGNMENT_16M 0x00180000 +#define EFI_FVB2_ALIGNMENT_32M 0x00190000 +#define EFI_FVB2_ALIGNMENT_64M 0x001A0000 +#define EFI_FVB2_ALIGNMENT_128M 0x001B0000 +#define EFI_FVB2_ALIGNMENT_256M 0x001C0000 +#define EFI_FVB2_ALIGNMENT_512M 0x001D0000 +#define EFI_FVB2_ALIGNMENT_1G 0x001E0000 +#define EFI_FVB2_ALIGNMENT_2G 0x001F0000 + +#define EFI_FVB_CAPABILITIES (EFI_FVB_READ_DISABLED_CAP | \ + EFI_FVB_READ_ENABLED_CAP | \ + EFI_FVB_WRITE_DISABLED_CAP | \ + EFI_FVB_WRITE_ENABLED_CAP | \ + EFI_FVB_LOCK_CAP | \ + EFI_FVB2_READ_LOCK_CAP | \ + EFI_FVB2_WRITE_LOCK_CAP ) + +#define EFI_FVB_STATUS (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | \ + EFI_FVB_LOCK_STATUS | EFI_FVB2_READ_LOCK_STATUS | \ + EFI_FVB2_WRITE_LOCK_STATUS ) + + + +// +// Extended Header Header. Located via ExtHeaderOffset. +// The extended headers follow each other in memory and are +// terminated by ExtHeaderType EFI_FV_EXT_TYPE_END +// +#define EFI_FV_EXT_TYPE_END 0x00 +typedef struct { + UINT16 ExtEntrySize; + UINT16 ExtEntryType; +} EFI_FIRMWARE_VOLUME_EXT_ENTRY; + +// +// GUID that maps OEM file types to GUIDs +// +#define EFI_FV_EXT_TYPE_OEM_TYPE 0x01 +typedef struct { + EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr; + UINT32 TypeMask; + EFI_GUID Types[1]; +} EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE; + +// +// Unique name of the FV +// +typedef struct { + EFI_GUID FvName; + UINT32 ExtHeaderSize; +} EFI_FIRMWARE_VOLUME_EXT_HEADER; + + +#endif + + +// +// Firmware Volume Header Revision definition +// +#define EFI_FVH_REVISION 0x01 +// +// PI1.0 define Firmware Volume Header Revision to 2 +// +#define EFI_FVH_PI_REVISION 0x02 + +// +// Firmware Volume Header Signature definition +// +#define EFI_FVH_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', 'H') + +// +// Firmware Volume Header Block Map Entry definition +// +typedef struct { + UINT32 NumBlocks; + UINT32 BlockLength; +} EFI_FV_BLOCK_MAP_ENTRY; + +// +// Firmware Volume Header definition +// +typedef struct { + UINT8 ZeroVector[16]; + EFI_GUID FileSystemGuid; + UINT64 FvLength; + UINT32 Signature; + EFI_FVB_ATTRIBUTES Attributes; + UINT16 HeaderLength; + UINT16 Checksum; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + UINT8 Reserved[3]; +#else + UINT16 ExtHeaderOffset; + UINT8 Reserved[1]; +#endif + UINT8 Revision; + EFI_FV_BLOCK_MAP_ENTRY FvBlockMap[1]; +} EFI_FIRMWARE_VOLUME_HEADER; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiImageFormat.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiImageFormat.h new file mode 100644 index 0000000000..c4ac828d61 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiImageFormat.h @@ -0,0 +1,279 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiImageFormat.h + +Abstract: + + This file defines the data structures that are architecturally defined for file + images loaded via the FirmwareVolume protocol. The Firmware Volume specification + is the basis for these definitions. + +--*/ + +#ifndef _EFI_IMAGE_FORMAT_H_ +#define _EFI_IMAGE_FORMAT_H_ + +// +// pack all data structures since this is actually a binary format and we cannot +// allow internal padding in the data structures because of some compilerism.. +// +#pragma pack(1) +// +// //////////////////////////////////////////////////////////////////////////// +// +// Architectural file types +// +typedef UINT8 EFI_FV_FILETYPE; + +#define EFI_FV_FILETYPE_ALL 0x00 +#define EFI_FV_FILETYPE_RAW 0x01 +#define EFI_FV_FILETYPE_FREEFORM 0x02 +#define EFI_FV_FILETYPE_SECURITY_CORE 0x03 +#define EFI_FV_FILETYPE_PEI_CORE 0x04 +#define EFI_FV_FILETYPE_DXE_CORE 0x05 +#define EFI_FV_FILETYPE_PEIM 0x06 +#define EFI_FV_FILETYPE_DRIVER 0x07 +#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08 +#define EFI_FV_FILETYPE_APPLICATION 0x09 +// +// File type 0x0A is reserved and should not be used +// +#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Section types +// +typedef UINT8 EFI_SECTION_TYPE; + +// +// ************************************************************ +// The section type EFI_SECTION_ALL is a psuedo type. It is +// used as a wildcard when retrieving sections. The section +// type EFI_SECTION_ALL matches all section types. +// ************************************************************ +// +#define EFI_SECTION_ALL 0x00 + +// +// ************************************************************ +// Encapsulation section Type values +// ************************************************************ +// +#define EFI_SECTION_COMPRESSION 0x01 +#define EFI_SECTION_GUID_DEFINED 0x02 + +// +// ************************************************************ +// Leaf section Type values +// ************************************************************ +// +#define EFI_SECTION_FIRST_LEAF_SECTION_TYPE 0x10 + +#define EFI_SECTION_PE32 0x10 +#define EFI_SECTION_PIC 0x11 +#define EFI_SECTION_TE 0x12 +#define EFI_SECTION_DXE_DEPEX 0x13 +#define EFI_SECTION_VERSION 0x14 +#define EFI_SECTION_USER_INTERFACE 0x15 +#define EFI_SECTION_COMPATIBILITY16 0x16 +#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17 +#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18 +#define EFI_SECTION_RAW 0x19 +#define EFI_SECTION_PEI_DEPEX 0x1B + +#define EFI_SECTION_LAST_LEAF_SECTION_TYPE 0x1B +#define EFI_SECTION_LAST_SECTION_TYPE 0x1B + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Common section header +// +typedef struct { + UINT8 Size[3]; + UINT8 Type; +} EFI_COMMON_SECTION_HEADER; + +#define SECTION_SIZE(SectionHeaderPtr) \ + ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff)) + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Compression section +// +// +// CompressionType values +// +#define EFI_NOT_COMPRESSED 0x00 +#define EFI_STANDARD_COMPRESSION 0x01 +#define EFI_CUSTOMIZED_COMPRESSION 0x02 + +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; + UINT32 UncompressedLength; + UINT8 CompressionType; +} EFI_COMPRESSION_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// GUID defined section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; + EFI_GUID SectionDefinitionGuid; + UINT16 DataOffset; + UINT16 Attributes; +} EFI_GUID_DEFINED_SECTION; + +// +// Bit values for Attributes +// +#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01 +#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02 + +// +// Bit values for AuthenticationStatus +// +#define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001 +#define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED 0x000002 +#define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED 0x000004 +#define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED 0x000008 +#define EFI_AGGREGATE_AUTH_STATUS_ALL 0x00000f + +#define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE 0x010000 +#define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED 0x020000 +#define EFI_LOCAL_AUTH_STATUS_NOT_TESTED 0x040000 +#define EFI_LOCAL_AUTH_STATUS_TEST_FAILED 0x080000 +#define EFI_LOCAL_AUTH_STATUS_ALL 0x0f0000 + +// +// //////////////////////////////////////////////////////////////////////////// +// +// PE32+ section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; +} EFI_PE32_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// PIC section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; +} EFI_PIC_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// PEIM header section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; +} EFI_PEIM_HEADER_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// DEPEX section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; +} EFI_DEPEX_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Version section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; + UINT16 BuildNumber; + INT16 VersionString[1]; +} EFI_VERSION_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// User interface section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; + INT16 FileNameString[1]; +} EFI_USER_INTERFACE_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Code16 section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; +} EFI_CODE16_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Firmware Volume Image section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; +} EFI_FIRMWARE_VOLUME_IMAGE_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Freeform subtype GUID section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; + EFI_GUID SubTypeGuid; +} EFI_FREEFORM_SUBTYPE_GUID_SECTION; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// Raw section +// +typedef struct { + EFI_COMMON_SECTION_HEADER CommonHeader; +} EFI_RAW_SECTION; + +// +// undo the pragma from the beginning... +// +#pragma pack() + +typedef union { + EFI_COMMON_SECTION_HEADER *CommonHeader; + EFI_COMPRESSION_SECTION *CompressionSection; + EFI_GUID_DEFINED_SECTION *GuidDefinedSection; + EFI_PE32_SECTION *Pe32Section; + EFI_PIC_SECTION *PicSection; + EFI_PEIM_HEADER_SECTION *PeimHeaderSection; + EFI_DEPEX_SECTION *DependencySection; + EFI_VERSION_SECTION *VersionSection; + EFI_USER_INTERFACE_SECTION *UISection; + EFI_CODE16_SECTION *Code16Section; + EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection; + EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection; + EFI_RAW_SECTION *RawSection; +} EFI_FILE_SECTION_POINTER; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiInternalFormRepresentation.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiInternalFormRepresentation.h new file mode 100644 index 0000000000..fb3e6b95c7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiInternalFormRepresentation.h @@ -0,0 +1,431 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiInternalFormRepresentation.h + +Abstract: + + This file defines the encoding for the VFR (Visual Form Representation) language. + IFR is primarily consumed by the EFI presentation engine, and produced by EFI + internal application and drivers as well as all add-in card option-ROM drivers + +--*/ + +#ifndef _EFI_INTERNAL_FORM_REPRESENTATION_H_ +#define _EFI_INTERNAL_FORM_REPRESENTATION_H_ + +// +// The following types are currently defined: +// +typedef UINT32 RELOFST; +typedef UINT16 STRING_REF; +typedef CHAR16 *EFI_STRING; + +// +// IFR Op codes +// +#define EFI_IFR_FORM_OP 0x01 +#define EFI_IFR_SUBTITLE_OP 0x02 +#define EFI_IFR_TEXT_OP 0x03 +#define EFI_IFR_GRAPHIC_OP 0x04 +#define EFI_IFR_ONE_OF_OP 0x05 +#define EFI_IFR_CHECKBOX_OP 0x06 +#define EFI_IFR_NUMERIC_OP 0x07 +#define EFI_IFR_PASSWORD_OP 0x08 +#define EFI_IFR_ONE_OF_OPTION_OP 0x09 // ONEOF OPTION field +#define EFI_IFR_SUPPRESS_IF_OP 0x0A +#define EFI_IFR_END_FORM_OP 0x0B +#define EFI_IFR_HIDDEN_OP 0x0C +#define EFI_IFR_END_FORM_SET_OP 0x0D +#define EFI_IFR_FORM_SET_OP 0x0E +#define EFI_IFR_REF_OP 0x0F +#define EFI_IFR_END_ONE_OF_OP 0x10 +#define EFI_IFR_END_OP EFI_IFR_END_ONE_OF_OP +#define EFI_IFR_INCONSISTENT_IF_OP 0x11 +#define EFI_IFR_EQ_ID_VAL_OP 0x12 +#define EFI_IFR_EQ_ID_ID_OP 0x13 +#define EFI_IFR_EQ_ID_LIST_OP 0x14 +#define EFI_IFR_AND_OP 0x15 +#define EFI_IFR_OR_OP 0x16 +#define EFI_IFR_NOT_OP 0x17 +#define EFI_IFR_END_IF_OP 0x18 // for endif of inconsistentif, suppressif, grayoutif +#define EFI_IFR_GRAYOUT_IF_OP 0x19 +#define EFI_IFR_DATE_OP 0x1A +#define EFI_IFR_TIME_OP 0x1B +#define EFI_IFR_STRING_OP 0x1C +#define EFI_IFR_LABEL_OP 0x1D +#define EFI_IFR_SAVE_DEFAULTS_OP 0x1E +#define EFI_IFR_RESTORE_DEFAULTS_OP 0x1F +#define EFI_IFR_BANNER_OP 0x20 +#define EFI_IFR_INVENTORY_OP 0x21 +#define EFI_IFR_EQ_VAR_VAL_OP 0x22 +#define EFI_IFR_ORDERED_LIST_OP 0x23 +#define EFI_IFR_VARSTORE_OP 0x24 +#define EFI_IFR_VARSTORE_SELECT_OP 0x25 +#define EFI_IFR_VARSTORE_SELECT_PAIR_OP 0x26 +#define EFI_IFR_TRUE_OP 0x27 +#define EFI_IFR_FALSE_OP 0x28 +#define EFI_IFR_GT_OP 0x29 +#define EFI_IFR_GE_OP 0x2A +#define EFI_IFR_OEM_DEFINED_OP 0x2B +#define EFI_IFR_LAST_OPCODE EFI_IFR_OEM_DEFINED_OP +#define EFI_IFR_OEM_OP 0xFE +#define EFI_IFR_NV_ACCESS_COMMAND 0xFF + +// +// Define values for the flags fields in some VFR opcodes. These are +// bitmasks. +// +#define EFI_IFR_FLAG_DEFAULT 0x01 +#define EFI_IFR_FLAG_MANUFACTURING 0x02 +#define EFI_IFR_FLAG_INTERACTIVE 0x04 +#define EFI_IFR_FLAG_NV_ACCESS 0x08 +#define EFI_IFR_FLAG_RESET_REQUIRED 0x10 +#define EFI_IFR_FLAG_LATE_CHECK 0x20 + +#define EFI_NON_DEVICE_CLASS 0x00 // Useful when you do not want something in the Device Manager +#define EFI_DISK_DEVICE_CLASS 0x01 +#define EFI_VIDEO_DEVICE_CLASS 0x02 +#define EFI_NETWORK_DEVICE_CLASS 0x04 +#define EFI_INPUT_DEVICE_CLASS 0x08 +#define EFI_ON_BOARD_DEVICE_CLASS 0x10 +#define EFI_OTHER_DEVICE_CLASS 0x20 + +#define EFI_SETUP_APPLICATION_SUBCLASS 0x00 +#define EFI_GENERAL_APPLICATION_SUBCLASS 0x01 +#define EFI_FRONT_PAGE_SUBCLASS 0x02 +#define EFI_SINGLE_USE_SUBCLASS 0x03 // Used to display a single entity and then exit +// +// Used to flag dynamically created op-codes. This is meaningful to the IFR Library set +// and the browser since we need to distinguish between compiled NV map data and created data. +// We do not allow new entries to be created in the NV map dynamically however we still need +// to display this information correctly. To dynamically create op-codes and assume that their +// data will be saved, ensure that the NV starting location they refer to is pre-defined in the +// NV map. +// +#define EFI_IFR_FLAG_CREATED 128 + +#pragma pack(1) +// +// IFR Structure definitions +// +typedef struct { + UINT8 OpCode; + UINT8 Length; +} EFI_IFR_OP_HEADER; + +typedef struct { + EFI_IFR_OP_HEADER Header; + EFI_GUID Guid; + STRING_REF FormSetTitle; + STRING_REF Help; + EFI_PHYSICAL_ADDRESS CallbackHandle; + UINT16 Class; + UINT16 SubClass; + UINT16 NvDataSize; // set once, size of the NV data as defined in the script +} EFI_IFR_FORM_SET; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 FormId; + STRING_REF FormTitle; +} EFI_IFR_FORM; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 LabelId; +} EFI_IFR_LABEL; + +typedef struct { + EFI_IFR_OP_HEADER Header; + STRING_REF SubTitle; +} EFI_IFR_SUBTITLE; + +typedef struct { + EFI_IFR_OP_HEADER Header; + STRING_REF Help; + STRING_REF Text; + STRING_REF TextTwo; + UINT8 Flags; // This is included solely for purposes of interactive/dynamic support. + UINT16 Key; // Value to be passed to caller to identify this particular op-code +} EFI_IFR_TEXT; + +// +// goto +// +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 FormId; + STRING_REF Prompt; + STRING_REF Help; // The string Token for the context-help + UINT8 Flags; // This is included solely for purposes of interactive/dynamic support. + UINT16 Key; // Value to be passed to caller to identify this particular op-code +} EFI_IFR_REF; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_END_FORM; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_END_FORM_SET; + +// +// Also notice that the IFR_ONE_OF and IFR_CHECK_BOX are identical in structure......code assumes this to be true, if this ever +// changes we need to revisit the InitializeTagStructures code +// +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name + UINT8 Width; // The Size of the Data being saved + STRING_REF Prompt; // The String Token for the Prompt + STRING_REF Help; // The string Token for the context-help +} EFI_IFR_ONE_OF; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The offset in NV for storage of the data + UINT8 MaxEntries; // The maximum number of options in the ordered list (=size of NVStore) + STRING_REF Prompt; // The string token for the prompt + STRING_REF Help; // The string token for the context-help +} EFI_IFR_ORDERED_LIST; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name + UINT8 Width; // The Size of the Data being saved + STRING_REF Prompt; // The String Token for the Prompt + STRING_REF Help; // The string Token for the context-help + UINT8 Flags; // For now, if non-zero, means that it is the default option, - further definition likely + UINT16 Key; // Value to be passed to caller to identify this particular op-code +} EFI_IFR_CHECK_BOX; + +typedef struct { + EFI_IFR_OP_HEADER Header; + STRING_REF Option; // The string token describing the option + UINT16 Value; // The value associated with this option that is stored in the NVRAM if chosen + UINT8 Flags; // For now, if non-zero, means that it is the default option, - further definition likely above + UINT16 Key; // Value to be passed to caller to identify this particular op-code +} EFI_IFR_ONE_OF_OPTION; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name + UINT8 Width; // The Size of the Data being saved + STRING_REF Prompt; // The String Token for the Prompt + STRING_REF Help; // The string Token for the context-help + UINT8 Flags; // This is included solely for purposes of interactive/dynamic support. + UINT16 Key; // Value to be passed to caller to identify this particular op-code + UINT16 Minimum; + UINT16 Maximum; + UINT16 Step; // If step is 0, then manual input is specified, otherwise, left/right arrow selection is called for + UINT16 Default; +} EFI_IFR_NUMERIC; + +// +// There is an interesting twist with regards to Time and Date. This is one of the few items which can accept input from +// a user, however may or may not need to use storage in the NVRAM space. The decided method for determining if NVRAM space +// will be used (only for a TimeOp or DateOp) is: If .QuestionId == 0 && .Width == 0 (normally an impossibility) then use system +// resources to store the data away and not NV resources. In other words, the setup engine will call gRT->SetTime, and gRT->SetDate +// for the saving of data, and the values displayed will be from the gRT->GetXXXX series of calls. +// +typedef struct { + EFI_IFR_NUMERIC Hour; + EFI_IFR_NUMERIC Minute; + EFI_IFR_NUMERIC Second; +} EFI_IFR_TIME; + +typedef struct { + EFI_IFR_NUMERIC Year; + EFI_IFR_NUMERIC Month; + EFI_IFR_NUMERIC Day; +} EFI_IFR_DATE; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name + UINT8 Width; // The Size of the Data being saved -- BUGBUG -- remove someday + STRING_REF Prompt; // The String Token for the Prompt + STRING_REF Help; // The string Token for the context-help + UINT8 Flags; // This is included solely for purposes of interactive/dynamic support. + UINT16 Key; // Value to be passed to caller to identify this particular op-code + UINT8 MinSize; // Minimum allowable sized password + UINT8 MaxSize; // Maximum allowable sized password + UINT16 Encoding; +} EFI_IFR_PASSWORD; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name + UINT8 Width; // The Size of the Data being saved -- BUGBUG -- remove someday + STRING_REF Prompt; // The String Token for the Prompt + STRING_REF Help; // The string Token for the context-help + UINT8 Flags; // This is included solely for purposes of interactive/dynamic support. + UINT16 Key; // Value to be passed to caller to identify this particular op-code + UINT8 MinSize; // Minimum allowable sized password + UINT8 MaxSize; // Maximum allowable sized password +} EFI_IFR_STRING; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_END_ONE_OF; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 Value; + UINT16 Key; +} EFI_IFR_HIDDEN; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT8 Flags; +} EFI_IFR_SUPPRESS; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT8 Flags; +} EFI_IFR_GRAYOUT; + +typedef struct { + EFI_IFR_OP_HEADER Header; + STRING_REF Popup; + UINT8 Flags; +} EFI_IFR_INCONSISTENT; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // offset into variable storage + UINT8 Width; // size of variable storage + UINT16 Value; // value to compare against +} EFI_IFR_EQ_ID_VAL; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // offset into variable storage + UINT8 Width; // size of variable storage + UINT16 ListLength; + UINT16 ValueList[1]; +} EFI_IFR_EQ_ID_LIST; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId1; // offset into variable storage for first value to compare + UINT8 Width; // size of variable storage (must be same for both) + UINT16 QuestionId2; // offset into variable storage for second value to compare +} EFI_IFR_EQ_ID_ID; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 VariableId; // offset into variable storage + UINT16 Value; // value to compare against +} EFI_IFR_EQ_VAR_VAL; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_AND; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_OR; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_NOT; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_END_IF; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 FormId; + STRING_REF Prompt; + STRING_REF Help; + UINT8 Flags; + UINT16 Key; +} EFI_IFR_SAVE_DEFAULTS; + +typedef struct { + EFI_IFR_OP_HEADER Header; + STRING_REF Help; + STRING_REF Text; + STRING_REF TextTwo; // optional text +} EFI_IFR_INVENTORY; + +typedef struct { + EFI_IFR_OP_HEADER Header; + EFI_GUID Guid; // GUID for the variable + UINT16 VarId; // variable store ID, as referenced elsewhere in the form + UINT16 Size; // size of the variable storage +} EFI_IFR_VARSTORE; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 VarId; // variable store ID, as referenced elsewhere in the form +} EFI_IFR_VARSTORE_SELECT; + +// +// Used for the ideqid VFR statement where two variable stores may be referenced in the +// same VFR statement. +// A browser should treat this as an EFI_IFR_VARSTORE_SELECT statement and assume that all following +// IFR opcodes use the VarId as defined here. +// +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 VarId; // variable store ID, as referenced elsewhere in the form + UINT16 SecondaryVarId; // variable store ID, as referenced elsewhere in the form +} EFI_IFR_VARSTORE_SELECT_PAIR; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_TRUE; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_FALSE; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_GT; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_GE; + +// +// Save defaults and restore defaults have same structure +// +#define EFI_IFR_RESTORE_DEFAULTS EFI_IFR_SAVE_DEFAULTS + +typedef struct { + EFI_IFR_OP_HEADER Header; + STRING_REF Title; // The string token for the banner title + UINT16 LineNumber; // 1-based line number + UINT8 Alignment; // left, center, or right-aligned +} EFI_IFR_BANNER; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // Offset into the map + UINT8 StorageWidth; // Width of the value + CHAR8 Data[1]; // The Data itself +} EFI_IFR_NV_DATA; + +#define EFI_IFR_BANNER_ALIGN_LEFT 0 +#define EFI_IFR_BANNER_ALIGN_CENTER 1 +#define EFI_IFR_BANNER_ALIGN_RIGHT 2 +#define EFI_IFR_BANNER_TIMEOUT 0xFF + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h new file mode 100644 index 0000000000..957eb4fc77 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h @@ -0,0 +1,82 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPciCfg.h + +Abstract: + + Abstract the common fields of PciCfg definition between Framework 0.9x + and PI 1.0. + +--*/ + +#ifndef _EFI_PCI_CFG_H_ +#define _EFI_PCI_CFG_H_ + +// +// Framework specification 0.9x definition. +// +typedef enum { + PeiPciCfgWidthUint8 = 0, + PeiPciCfgWidthUint16 = 1, + PeiPciCfgWidthUint32 = 2, + PeiPciCfgWidthUint64 = 3, + PeiPciCfgWidthMaximum +} PEI_PCI_CFG_PPI_WIDTH; + +#define PEI_PCI_CFG_ADDRESS(bus, dev, func, reg) ( \ + (UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)) \ + ) & 0x00000000ffffffff + +// +// PI 1.0 definition. +// +typedef enum { + EfiPeiPciCfgWidthUint8 = 0, + EfiPeiPciCfgWidthUint16 = 1, + EfiPeiPciCfgWidthUint32 = 2, + EfiPeiPciCfgWidthUint64 = 3, + EfiPeiPciCfgWidthMaximum +} EFI_PEI_PCI_CFG_PPI_WIDTH; + +#define EFI_PEI_PCI_CFG_ADDRESS(bus, dev, func, reg) \ + ( ((bus) << 24) | \ + ((dev) << 16) | \ + ((func) << 8) | \ + ((reg) < 256 ? (reg): ((UINT64)(reg) << 32))) + + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT8 Reserved[4]; +} PEI_PCI_CFG_PPI_PCI_ADDRESS; + +typedef PEI_PCI_CFG_PPI_PCI_ADDRESS EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS; + +#else + +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT32 ExtendedRegister; +} EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS; +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiSmbus.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiSmbus.h new file mode 100644 index 0000000000..ed5f10d2ff --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiSmbus.h @@ -0,0 +1,69 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiSmbus.h + +Abstract: + + + +--*/ + +#ifndef _EFI_SMBUS_DEFINITION_H_ +#define _EFI_SMBUS_DEFINITION_H_ + +// +// EFI Smbus Device Address, Smbus Device Command, Smbus Operation +// +typedef struct { + UINTN SmbusDeviceAddress : 7; +} EFI_SMBUS_DEVICE_ADDRESS; + +typedef UINTN EFI_SMBUS_DEVICE_COMMAND; + +typedef enum _EFI_SMBUS_OPERATION +{ + EfiSmbusQuickRead, + EfiSmbusQuickWrite, + EfiSmbusReceiveByte, + EfiSmbusSendByte, + EfiSmbusReadByte, + EfiSmbusWriteByte, + EfiSmbusReadWord, + EfiSmbusWriteWord, + EfiSmbusReadBlock, + EfiSmbusWriteBlock, + EfiSmbusProcessCall, + EfiSmbusBWBRProcessCall +} EFI_SMBUS_OPERATION; + +typedef struct { + UINT32 VendorSpecificId; + UINT16 SubsystemDeviceId; + UINT16 SubsystemVendorId; + UINT16 Interface; + UINT16 DeviceId; + UINT16 VendorId; + UINT8 VendorRevision; + UINT8 DeviceCapabilities; +} EFI_SMBUS_UDID; + + +typedef struct { + EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress; + EFI_SMBUS_UDID SmbusDeviceUdid; +} EFI_SMBUS_DEVICE_MAP; + + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiStatusCode.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiStatusCode.h new file mode 100644 index 0000000000..cbad559b2b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiStatusCode.h @@ -0,0 +1,954 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiStatusCode.h + +Abstract: + + Status Code Definitions, according to Intel Platform Innovation Framework + for EFI Status Codes Specification + Revision 0.92 + + The file is divided into sections for ease of use. + + Section: Contents: + 1 General Status Code Definitions + 2 Class definitions + 3 Computing Unit Subclasses, Progress and Error Codes + 4 Peripheral Subclasses, Progress and Error Codes. + 5 IO Bus Subclasses, Progress and Error Codes. + 6 Software Subclasses, Progress and Error Codes. + 7 Debug Codes + +--*/ + +#ifndef _EFI_STATUS_CODE_H_ +#define _EFI_STATUS_CODE_H_ + +// +// ///////////////////////////////////////////////////////////////////////////// +// Section 1 +/////////////////////////////////////////////////////////////////////////////// +// +// Status Code Type Definition +// +typedef UINT32 EFI_STATUS_CODE_TYPE; + +// +// A Status Code Type is made up of the code type and severity +// All values masked by EFI_STATUS_CODE_RESERVED_MASK are +// reserved for use by this specification. +// +#define EFI_STATUS_CODE_TYPE_MASK 0x000000FF +#define EFI_STATUS_CODE_SEVERITY_MASK 0xFF000000 +#define EFI_STATUS_CODE_RESERVED_MASK 0x00FFFF00 + +// +// Definition of code types, all other values masked by +// EFI_STATUS_CODE_TYPE_MASK are reserved for use by +// this specification. +// +#define EFI_PROGRESS_CODE 0x00000001 +#define EFI_ERROR_CODE 0x00000002 +#define EFI_DEBUG_CODE 0x00000003 + +// +// Definitions of severities, all other values masked by +// EFI_STATUS_CODE_SEVERITY_MASK are reserved for use by +// this specification. +// +#define EFI_ERROR_MINOR 0x40000000 +#define EFI_ERROR_MAJOR 0x80000000 +#define EFI_ERROR_UNRECOVERED 0x90000000 +#define EFI_ERROR_UNCONTAINED 0xA0000000 + +// +// Status Code Value Definition +// +typedef UINT32 EFI_STATUS_CODE_VALUE; + +// +// A Status Code Value is made up of the class, subclass, and +// an operation. Classes, subclasses, and operations are defined +// in the following sections. +// +#define EFI_STATUS_CODE_CLASS_MASK 0xFF000000 +#define EFI_STATUS_CODE_SUBCLASS_MASK 0x00FF0000 +#define EFI_STATUS_CODE_OPERATION_MASK 0x0000FFFF + +typedef struct { + UINT16 HeaderSize; + UINT16 Size; + EFI_GUID Type; +} EFI_STATUS_CODE_DATA; + +// +// Data Hub Status Code class record definition +// +typedef struct { + EFI_STATUS_CODE_TYPE CodeType; + EFI_STATUS_CODE_VALUE Value; + UINT32 Instance; + EFI_GUID CallerId; + EFI_STATUS_CODE_DATA Data; +} DATA_HUB_STATUS_CODE_DATA_RECORD; + +// +// ///////////////////////////////////////////////////////////////////////////// +// Section 2 +/////////////////////////////////////////////////////////////////////////////// +// +// Class definitions +// Values of 4-127 are reserved for future use by this +// specification. +// Values in the range 128-255 are reserved for OEM use. +// +#define EFI_COMPUTING_UNIT 0x00000000 +#define EFI_PERIPHERAL 0x01000000 +#define EFI_IO_BUS 0x02000000 +#define EFI_SOFTWARE 0x03000000 + +// +// General partitioning scheme for Progress and Error Codes are +// 0x0000-0x0FFF - Shared by all sub-classes in a given class +// 0x1000-0x7FFF - Subclass Specific +// 0x8000-0xFFFF - OEM specific +// +#define EFI_SUBCLASS_SPECIFIC 0x1000 +#define EFI_OEM_SPECIFIC 0x8000 + +// +// ///////////////////////////////////////////////////////////////////////////// +// Section 3 +/////////////////////////////////////////////////////////////////////////////// +// +// Computing Unit Subclass definitions. +// Values of 7-127 are reserved for future use by this +// specification. +// Values of 128-255 are reserved for OEM use. +// +#define EFI_COMPUTING_UNIT_UNSPECIFIED (EFI_COMPUTING_UNIT | 0x00000000) +#define EFI_COMPUTING_UNIT_HOST_PROCESSOR (EFI_COMPUTING_UNIT | 0x00010000) +#define EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR (EFI_COMPUTING_UNIT | 0x00020000) +#define EFI_COMPUTING_UNIT_IO_PROCESSOR (EFI_COMPUTING_UNIT | 0x00030000) +#define EFI_COMPUTING_UNIT_CACHE (EFI_COMPUTING_UNIT | 0x00040000) +#define EFI_COMPUTING_UNIT_MEMORY (EFI_COMPUTING_UNIT | 0x00050000) +#define EFI_COMPUTING_UNIT_CHIPSET (EFI_COMPUTING_UNIT | 0x00060000) + +// +// Computing Unit Class Progress Code definitions. +// These are shared by all subclasses. +// +#define EFI_CU_PC_INIT_BEGIN 0x00000000 +#define EFI_CU_PC_INIT_END 0x00000001 + +// +// Computing Unit Unspecified Subclass Progress Code definitions. +// +// +// Computing Unit Host Processor Subclass Progress Code definitions. +// +#define EFI_CU_HP_PC_POWER_ON_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_CU_HP_PC_CACHE_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_CU_HP_PC_RAM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_CU_HP_PC_MEMORY_CONTROLLER_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_CU_HP_PC_IO_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_CU_HP_PC_BSP_SELECT (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_CU_HP_PC_BSP_RESELECT (EFI_SUBCLASS_SPECIFIC | 0x00000006) +#define EFI_CU_HP_PC_AP_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000007) +#define EFI_CU_HP_PC_SMM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000008) + +// +// Computing Unit Firmware Processor Subclass Progress Code definitions. +// +// +// Computing Unit IO Processor Subclass Progress Code definitions. +// +// +// Computing Unit Cache Subclass Progress Code definitions. +// +#define EFI_CU_CACHE_PC_PRESENCE_DETECT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_CU_CACHE_PC_CONFIGURATION (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// Computing Unit Memory Subclass Progress Code definitions. +// +#define EFI_CU_MEMORY_PC_SPD_READ (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_CU_MEMORY_PC_PRESENCE_DETECT (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_CU_MEMORY_PC_TIMING (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_CU_MEMORY_PC_CONFIGURING (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_CU_MEMORY_PC_OPTIMIZING (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_CU_MEMORY_PC_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_CU_MEMORY_PC_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000006) + +// +// Computing Unit Chipset Subclass Progress Code definitions. +// +// +// Computing Unit Class Error Code definitions. +// These are shared by all subclasses. +// +#define EFI_CU_EC_NON_SPECIFIC 0x00000000 +#define EFI_CU_EC_DISABLED 0x00000001 +#define EFI_CU_EC_NOT_SUPPORTED 0x00000002 +#define EFI_CU_EC_NOT_DETECTED 0x00000003 +#define EFI_CU_EC_NOT_CONFIGURED 0x00000004 + +// +// Computing Unit Unspecified Subclass Error Code definitions. +// +// +// Computing Unit Host Processor Subclass Error Code definitions. +// +#define EFI_CU_HP_EC_INVALID_TYPE (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_CU_HP_EC_INVALID_SPEED (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_CU_HP_EC_MISMATCH (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_CU_HP_EC_TIMER_EXPIRED (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_CU_HP_EC_SELF_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_CU_HP_EC_INTERNAL (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_CU_HP_EC_THERMAL (EFI_SUBCLASS_SPECIFIC | 0x00000006) +#define EFI_CU_HP_EC_LOW_VOLTAGE (EFI_SUBCLASS_SPECIFIC | 0x00000007) +#define EFI_CU_HP_EC_HIGH_VOLTAGE (EFI_SUBCLASS_SPECIFIC | 0x00000008) +#define EFI_CU_HP_EC_CACHE (EFI_SUBCLASS_SPECIFIC | 0x00000009) +#define EFI_CU_HP_EC_MICROCODE_UPDATE (EFI_SUBCLASS_SPECIFIC | 0x0000000A) +#define EFI_CU_HP_EC_CORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x0000000B) +#define EFI_CU_HP_EC_UNCORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x0000000C) +#define EFI_CU_HP_EC_NO_MICROCODE_UPDATE (EFI_SUBCLASS_SPECIFIC | 0x0000000D) + +// +// Computing Unit Firmware Processor Subclass Error Code definitions. +// +#define EFI_CU_FP_EC_HARD_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_CU_FP_EC_SOFT_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_CU_FP_EC_COMM_ERROR (EFI_SUBCLASS_SPECIFIC | 0x00000002) + +// +// Computing Unit IO Processor Subclass Error Code definitions. +// +// +// Computing Unit Cache Subclass Error Code definitions. +// +#define EFI_CU_CACHE_EC_INVALID_TYPE (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_CU_CACHE_EC_INVALID_SPEED (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_CU_CACHE_EC_INVALID_SIZE (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_CU_CACHE_EC_MISMATCH (EFI_SUBCLASS_SPECIFIC | 0x00000003) + +// +// Computing Unit Memory Subclass Error Code definitions. +// +#define EFI_CU_MEMORY_EC_INVALID_TYPE (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_CU_MEMORY_EC_INVALID_SPEED (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_CU_MEMORY_EC_CORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_CU_MEMORY_EC_UNCORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_CU_MEMORY_EC_SPD_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_CU_MEMORY_EC_INVALID_SIZE (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_CU_MEMORY_EC_MISMATCH (EFI_SUBCLASS_SPECIFIC | 0x00000006) +#define EFI_CU_MEMORY_EC_S3_RESUME_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000007) +#define EFI_CU_MEMORY_EC_UPDATE_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000008) +#define EFI_CU_MEMORY_EC_NONE_DETECTED (EFI_SUBCLASS_SPECIFIC | 0x00000009) +#define EFI_CU_MEMORY_EC_NONE_USEFUL (EFI_SUBCLASS_SPECIFIC | 0x0000000A) + +// +// Computing Unit Chipset Subclass Error Code definitions. +// + +/////////////////////////////////////////////////////////////////////////////// +// Section 4 +/////////////////////////////////////////////////////////////////////////////// +// +// Peripheral Subclass definitions. +// Values of 13-127 are reserved for future use by this +// specification. +// Values of 128-255 are reserved for OEM use. +// +#define EFI_PERIPHERAL_UNSPECIFIED (EFI_PERIPHERAL | 0x00000000) +#define EFI_PERIPHERAL_KEYBOARD (EFI_PERIPHERAL | 0x00010000) +#define EFI_PERIPHERAL_MOUSE (EFI_PERIPHERAL | 0x00020000) +#define EFI_PERIPHERAL_LOCAL_CONSOLE (EFI_PERIPHERAL | 0x00030000) +#define EFI_PERIPHERAL_REMOTE_CONSOLE (EFI_PERIPHERAL | 0x00040000) +#define EFI_PERIPHERAL_SERIAL_PORT (EFI_PERIPHERAL | 0x00050000) +#define EFI_PERIPHERAL_PARALLEL_PORT (EFI_PERIPHERAL | 0x00060000) +#define EFI_PERIPHERAL_FIXED_MEDIA (EFI_PERIPHERAL | 0x00070000) +#define EFI_PERIPHERAL_REMOVABLE_MEDIA (EFI_PERIPHERAL | 0x00080000) +#define EFI_PERIPHERAL_AUDIO_INPUT (EFI_PERIPHERAL | 0x00090000) +#define EFI_PERIPHERAL_AUDIO_OUTPUT (EFI_PERIPHERAL | 0x000A0000) +#define EFI_PERIPHERAL_LCD_DEVICE (EFI_PERIPHERAL | 0x000B0000) +#define EFI_PERIPHERAL_NETWORK (EFI_PERIPHERAL | 0x000C0000) + +// +// Peripheral Class Progress Code definitions. +// These are shared by all subclasses. +// +#define EFI_P_PC_INIT 0x00000000 +#define EFI_P_PC_RESET 0x00000001 +#define EFI_P_PC_DISABLE 0x00000002 +#define EFI_P_PC_PRESENCE_DETECT 0x00000003 +#define EFI_P_PC_ENABLE 0x00000004 +#define EFI_P_PC_RECONFIG 0x00000005 +#define EFI_P_PC_DETECTED 0x00000006 + +// +// Peripheral Class Unspecified Subclass Progress Code definitions. +// +// +// Peripheral Class Keyboard Subclass Progress Code definitions. +// +#define EFI_P_KEYBOARD_PC_CLEAR_BUFFER (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_P_KEYBOARD_PC_SELF_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// Peripheral Class Mouse Subclass Progress Code definitions. +// +#define EFI_P_MOUSE_PC_SELF_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000000) + +// +// Peripheral Class Local Console Subclass Progress Code definitions. +// +// +// Peripheral Class Remote Console Subclass Progress Code definitions. +// +// +// Peripheral Class Serial Port Subclass Progress Code definitions. +// +#define EFI_P_SERIAL_PORT_PC_CLEAR_BUFFER (EFI_SUBCLASS_SPECIFIC | 0x00000000) + +// +// Peripheral Class Parallel Port Subclass Progress Code definitions. +// +// +// Peripheral Class Fixed Media Subclass Progress Code definitions. +// +// +// Peripheral Class Removable Media Subclass Progress Code definitions. +// +// +// Peripheral Class Audio Input Subclass Progress Code definitions. +// +// +// Peripheral Class Audio Output Subclass Progress Code definitions. +// +// +// Peripheral Class LCD Device Subclass Progress Code definitions. +// +// +// Peripheral Class Network Subclass Progress Code definitions. +// +// +// Peripheral Class Error Code definitions. +// These are shared by all subclasses. +// +#define EFI_P_EC_NON_SPECIFIC 0x00000000 +#define EFI_P_EC_DISABLED 0x00000001 +#define EFI_P_EC_NOT_SUPPORTED 0x00000002 +#define EFI_P_EC_NOT_DETECTED 0x00000003 +#define EFI_P_EC_NOT_CONFIGURED 0x00000004 +#define EFI_P_EC_INTERFACE_ERROR 0x00000005 +#define EFI_P_EC_CONTROLLER_ERROR 0x00000006 +#define EFI_P_EC_INPUT_ERROR 0x00000007 +#define EFI_P_EC_OUTPUT_ERROR 0x00000008 +#define EFI_P_EC_RESOURCE_CONFLICT 0x00000009 + +// +// Peripheral Class Unspecified Subclass Error Code definitions. +// +// +// Peripheral Class Keyboard Subclass Error Code definitions. +// +#define EFI_P_KEYBOARD_EC_LOCKED (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_P_KEYBOARD_EC_STUCK_KEY (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// Peripheral Class Mouse Subclass Error Code definitions. +// +#define EFI_P_MOUSE_EC_LOCKED (EFI_SUBCLASS_SPECIFIC | 0x00000000) + +// +// Peripheral Class Local Console Subclass Error Code definitions. +// +// +// Peripheral Class Remote Console Subclass Error Code definitions. +// +// +// Peripheral Class Serial Port Subclass Error Code definitions. +// +// +// Peripheral Class Parallel Port Subclass Error Code definitions. +// +// +// Peripheral Class Fixed Media Subclass Error Code definitions. +// +// +// Peripheral Class Removable Media Subclass Error Code definitions. +// +// +// Peripheral Class Audio Input Subclass Error Code definitions. +// +// +// Peripheral Class Audio Output Subclass Error Code definitions. +// +// +// Peripheral Class LCD Device Subclass Error Code definitions. +// +// +// Peripheral Class Network Subclass Error Code definitions. +// + +/////////////////////////////////////////////////////////////////////////////// +// Section 5 +/////////////////////////////////////////////////////////////////////////////// +// +// IO Bus Subclass definitions. +// Values of 13-127 are reserved for future use by this +// specification. +// Values of 128-255 are reserved for OEM use. +// +#define EFI_IO_BUS_UNSPECIFIED (EFI_IO_BUS | 0x00000000) +#define EFI_IO_BUS_PCI (EFI_IO_BUS | 0x00010000) +#define EFI_IO_BUS_USB (EFI_IO_BUS | 0x00020000) +#define EFI_IO_BUS_IBA (EFI_IO_BUS | 0x00030000) +#define EFI_IO_BUS_AGP (EFI_IO_BUS | 0x00040000) +#define EFI_IO_BUS_PC_CARD (EFI_IO_BUS | 0x00050000) +#define EFI_IO_BUS_LPC (EFI_IO_BUS | 0x00060000) +#define EFI_IO_BUS_SCSI (EFI_IO_BUS | 0x00070000) +#define EFI_IO_BUS_ATA_ATAPI (EFI_IO_BUS | 0x00080000) +#define EFI_IO_BUS_FC (EFI_IO_BUS | 0x00090000) +#define EFI_IO_BUS_IP_NETWORK (EFI_IO_BUS | 0x000A0000) +#define EFI_IO_BUS_SMBUS (EFI_IO_BUS | 0x000B0000) +#define EFI_IO_BUS_I2C (EFI_IO_BUS | 0x000C0000) + +// +// IO Bus Class Progress Code definitions. +// These are shared by all subclasses. +// +#define EFI_IOB_PC_INIT 0x00000000 +#define EFI_IOB_PC_RESET 0x00000001 +#define EFI_IOB_PC_DISABLE 0x00000002 +#define EFI_IOB_PC_DETECT 0x00000003 +#define EFI_IOB_PC_ENABLE 0x00000004 +#define EFI_IOB_PC_RECONFIG 0x00000005 +#define EFI_IOB_PC_HOTPLUG 0x00000006 + +// +// IO Bus Class Unspecified Subclass Progress Code definitions. +// +// +// IO Bus Class PCI Subclass Progress Code definitions. +// +#define EFI_IOB_PCI_PC_BUS_ENUM (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_IOB_PCI_PC_RES_ALLOC (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_IOB_PCI_PC_HPC_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000002) + +// +// IO Bus Class USB Subclass Progress Code definitions. +// +// +// IO Bus Class IBA Subclass Progress Code definitions. +// +// +// IO Bus Class AGP Subclass Progress Code definitions. +// +// +// IO Bus Class PC Card Subclass Progress Code definitions. +// +// +// IO Bus Class LPC Subclass Progress Code definitions. +// +// +// IO Bus Class SCSI Subclass Progress Code definitions. +// +// +// IO Bus Class ATA/ATAPI Subclass Progress Code definitions. +// +#define EFI_IOB_ATA_BUS_SMART_ENABLE (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_IOB_ATA_BUS_SMART_DISABLE (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000003) + +// +// IO Bus Class FC Subclass Progress Code definitions. +// +// +// IO Bus Class IP Network Subclass Progress Code definitions. +// +// +// IO Bus Class SMBUS Subclass Progress Code definitions. +// +// +// IO Bus Class I2C Subclass Progress Code definitions. +// +// +// IO Bus Class Error Code definitions. +// These are shared by all subclasses. +// +#define EFI_IOB_EC_NON_SPECIFIC 0x00000000 +#define EFI_IOB_EC_DISABLED 0x00000001 +#define EFI_IOB_EC_NOT_SUPPORTED 0x00000002 +#define EFI_IOB_EC_NOT_DETECTED 0x00000003 +#define EFI_IOB_EC_NOT_CONFIGURED 0x00000004 +#define EFI_IOB_EC_INTERFACE_ERROR 0x00000005 +#define EFI_IOB_EC_CONTROLLER_ERROR 0x00000006 +#define EFI_IOB_EC_READ_ERROR 0x00000007 +#define EFI_IOB_EC_WRITE_ERROR 0x00000008 +#define EFI_IOB_EC_RESOURCE_CONFLICT 0x00000009 + +// +// IO Bus Class Unspecified Subclass Error Code definitions. +// +// +// IO Bus Class PCI Subclass Error Code definitions. +// +#define EFI_IOB_PCI_EC_PERR (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_IOB_PCI_EC_SERR (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// IO Bus Class USB Subclass Error Code definitions. +// +// +// IO Bus Class IBA Subclass Error Code definitions. +// +// +// IO Bus Class AGP Subclass Error Code definitions. +// +// +// IO Bus Class PC Card Subclass Error Code definitions. +// +// +// IO Bus Class LPC Subclass Error Code definitions. +// +// +// IO Bus Class SCSI Subclass Error Code definitions. +// +// +// IO Bus Class ATA/ATAPI Subclass Error Code definitions. +// +#define EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_IOB_ATA_BUS_SMART_DISABLED (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// IO Bus Class FC Subclass Error Code definitions. +// +// +// IO Bus Class IP Network Subclass Error Code definitions. +// +// +// IO Bus Class SMBUS Subclass Error Code definitions. +// +// +// IO Bus Class I2C Subclass Error Code definitions. +// + +/////////////////////////////////////////////////////////////////////////////// +// Section 6 +/////////////////////////////////////////////////////////////////////////////// +// +// Software Subclass definitions. +// Values of 20-127 are reserved for future use by this +// specification. +// Values of 128-255 are reserved for OEM use. +// +#define EFI_SOFTWARE_UNSPECIFIED (EFI_SOFTWARE | 0x00000000) +#define EFI_SOFTWARE_SEC (EFI_SOFTWARE | 0x00010000) +#define EFI_SOFTWARE_PEI_CORE (EFI_SOFTWARE | 0x00020000) +#define EFI_SOFTWARE_PEI_MODULE (EFI_SOFTWARE | 0x00030000) +#define EFI_SOFTWARE_DXE_CORE (EFI_SOFTWARE | 0x00040000) +#define EFI_SOFTWARE_DXE_BS_DRIVER (EFI_SOFTWARE | 0x00050000) +#define EFI_SOFTWARE_DXE_RT_DRIVER (EFI_SOFTWARE | 0x00060000) +#define EFI_SOFTWARE_SMM_DRIVER (EFI_SOFTWARE | 0x00070000) +#define EFI_SOFTWARE_EFI_APPLICATION (EFI_SOFTWARE | 0x00080000) +#define EFI_SOFTWARE_EFI_OS_LOADER (EFI_SOFTWARE | 0x00090000) +#define EFI_SOFTWARE_RT (EFI_SOFTWARE | 0x000A0000) +#define EFI_SOFTWARE_AL (EFI_SOFTWARE | 0x000B0000) +#define EFI_SOFTWARE_EBC_EXCEPTION (EFI_SOFTWARE | 0x000C0000) +#define EFI_SOFTWARE_IA32_EXCEPTION (EFI_SOFTWARE | 0x000D0000) +#define EFI_SOFTWARE_IPF_EXCEPTION (EFI_SOFTWARE | 0x000E0000) +#define EFI_SOFTWARE_PEI_SERVICE (EFI_SOFTWARE | 0x000F0000) +#define EFI_SOFTWARE_EFI_BOOT_SERVICE (EFI_SOFTWARE | 0x00100000) +#define EFI_SOFTWARE_EFI_RUNTIME_SERVICE (EFI_SOFTWARE | 0x00110000) +#define EFI_SOFTWARE_EFI_DXE_SERVICE (EFI_SOFTWARE | 0x00120000) +#define EFI_SOFTWARE_X64_EXCEPTION (EFI_SOFTWARE | 0x00130000) + +// +// Software Class Progress Code definitions. +// These are shared by all subclasses. +// +#define EFI_SW_PC_INIT 0x00000000 +#define EFI_SW_PC_LOAD 0x00000001 +#define EFI_SW_PC_INIT_BEGIN 0x00000002 +#define EFI_SW_PC_INIT_END 0x00000003 +#define EFI_SW_PC_AUTHENTICATE_BEGIN 0x00000004 +#define EFI_SW_PC_AUTHENTICATE_END 0x00000005 +#define EFI_SW_PC_INPUT_WAIT 0x00000006 +#define EFI_SW_PC_USER_SETUP 0x00000007 + +// +// Software Class Unspecified Subclass Progress Code definitions. +// +// +// Software Class SEC Subclass Progress Code definitions. +// +#define EFI_SW_SEC_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_SEC_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// Software Class PEI Core Subclass Progress Code definitions. +// +#define EFI_SW_PEI_CORE_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_PEI_CORE_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000002) + +// +// Software Class PEI Module Subclass Progress Code definitions. +// +#define EFI_SW_PEIM_PC_RECOVERY_BEGIN (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_PEIM_PC_CAPSULE_LOAD (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_PEIM_PC_CAPSULE_START (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_PEIM_PC_RECOVERY_USER (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_SW_PEIM_PC_RECOVERY_AUTO (EFI_SUBCLASS_SPECIFIC | 0x00000004) + +// +// Software Class DXE Core Subclass Progress Code definitions. +// +#define EFI_SW_DXE_CORE_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_DXE_CORE_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_DXE_CORE_PC_START_DRIVER (EFI_SUBCLASS_SPECIFIC | 0x00000003) + +// +// Software Class DXE BS Driver Subclass Progress Code definitions. +// +#define EFI_SW_DXE_BS_PC_LEGACY_OPROM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_DXE_BS_PC_EXIT_BOOT_SERVICES_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_SW_DXE_BS_PC_VIRTUAL_ADDRESS_CHANGE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD (EFI_SUBCLASS_SPECIFIC | 0x00000006) + +// +// Software Class DXE RT Driver Subclass Progress Code definitions. +// +#define EFI_SW_DXE_RT_PC_S0 (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_DXE_RT_PC_S1 (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_DXE_RT_PC_S2 (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_DXE_RT_PC_S3 (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_SW_DXE_RT_PC_S4 (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_SW_DXE_RT_PC_S5 (EFI_SUBCLASS_SPECIFIC | 0x00000005) + +// +// Software Class SMM Driver Subclass Progress Code definitions. +// +// +// Software Class EFI Application Subclass Progress Code definitions. +// +// +// Software Class EFI OS Loader Subclass Progress Code definitions. +// +// +// Software Class EFI RT Subclass Progress Code definitions. +// +#define EFI_SW_RT_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_RT_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_RT_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000002) + +// +// Software Class EFI AL Subclass Progress Code definitions. +// +#define EFI_SW_AL_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_AL_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// Software Class EBC Exception Subclass Progress Code definitions. +// +// +// Software Class IA32 Exception Subclass Progress Code definitions. +// +// +// Software Class X64 Exception Subclass Progress Code definitions. +// +// +// Software Class IPF Exception Subclass Progress Code definitions. +// +// +// Software Class PEI Services Subclass Progress Code definitions. +// +#define EFI_SW_PS_PC_INSTALL_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_PS_PC_REINSTALL_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_PS_PC_LOCATE_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_PS_PC_NOTIFY_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_SW_PS_PC_GET_BOOT_MODE (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_SW_PS_PC_SET_BOOT_MODE (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_SW_PS_PC_GET_HOB_LIST (EFI_SUBCLASS_SPECIFIC | 0x00000006) +#define EFI_SW_PS_PC_CREATE_HOB (EFI_SUBCLASS_SPECIFIC | 0x00000007) +#define EFI_SW_PS_PC_FFS_FIND_NEXT_VOLUME (EFI_SUBCLASS_SPECIFIC | 0x00000008) +#define EFI_SW_PS_PC_FFS_FIND_NEXT_FILE (EFI_SUBCLASS_SPECIFIC | 0x00000009) +#define EFI_SW_PS_PC_FFS_FIND_SECTION_DATA (EFI_SUBCLASS_SPECIFIC | 0x0000000A) +#define EFI_SW_PS_PC_INSTALL_PEI_MEMORY (EFI_SUBCLASS_SPECIFIC | 0x0000000B) +#define EFI_SW_PS_PC_ALLOCATE_PAGES (EFI_SUBCLASS_SPECIFIC | 0x0000000C) +#define EFI_SW_PS_PC_ALLOCATE_POOL (EFI_SUBCLASS_SPECIFIC | 0x0000000D) +#define EFI_SW_PS_PC_COPY_MEM (EFI_SUBCLASS_SPECIFIC | 0x0000000E) +#define EFI_SW_PS_PC_SET_MEM (EFI_SUBCLASS_SPECIFIC | 0x0000000F) + +// +// Software Class EFI Boot Services Subclass Progress Code definitions. +// +#define EFI_SW_BS_PC_RAISE_TPL (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_BS_PC_RESTORE_TPL (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_BS_PC_ALLOCATE_PAGES (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_BS_PC_FREE_PAGES (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_SW_BS_PC_GET_MEMORY_MAP (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_SW_BS_PC_ALLOCATE_POOL (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_SW_BS_PC_FREE_POOL (EFI_SUBCLASS_SPECIFIC | 0x00000006) +#define EFI_SW_BS_PC_CREATE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000007) +#define EFI_SW_BS_PC_SET_TIMER (EFI_SUBCLASS_SPECIFIC | 0x00000008) +#define EFI_SW_BS_PC_WAIT_FOR_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000009) +#define EFI_SW_BS_PC_SIGNAL_EVENT (EFI_SUBCLASS_SPECIFIC | 0x0000000A) +#define EFI_SW_BS_PC_CLOSE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x0000000B) +#define EFI_SW_BS_PC_CHECK_EVENT (EFI_SUBCLASS_SPECIFIC | 0x0000000C) +#define EFI_SW_BS_PC_INSTALL_PROTOCOL_INTERFACE (EFI_SUBCLASS_SPECIFIC | 0x0000000D) +#define EFI_SW_BS_PC_REINSTALL_PROTOCOL_INTERFACE (EFI_SUBCLASS_SPECIFIC | 0x0000000E) +#define EFI_SW_BS_PC_UNINSTALL_PROTOCOL_INTERFACE (EFI_SUBCLASS_SPECIFIC | 0x0000000F) +#define EFI_SW_BS_PC_HANDLE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000010) +#define EFI_SW_BS_PC_PC_HANDLE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000011) +#define EFI_SW_BS_PC_REGISTER_PROTOCOL_NOTIFY (EFI_SUBCLASS_SPECIFIC | 0x00000012) +#define EFI_SW_BS_PC_LOCATE_HANDLE (EFI_SUBCLASS_SPECIFIC | 0x00000013) +#define EFI_SW_BS_PC_INSTALL_CONFIGURATION_TABLE (EFI_SUBCLASS_SPECIFIC | 0x00000014) +#define EFI_SW_BS_PC_LOAD_IMAGE (EFI_SUBCLASS_SPECIFIC | 0x00000015) +#define EFI_SW_BS_PC_START_IMAGE (EFI_SUBCLASS_SPECIFIC | 0x00000016) +#define EFI_SW_BS_PC_EXIT (EFI_SUBCLASS_SPECIFIC | 0x00000017) +#define EFI_SW_BS_PC_UNLOAD_IMAGE (EFI_SUBCLASS_SPECIFIC | 0x00000018) +#define EFI_SW_BS_PC_EXIT_BOOT_SERVICES (EFI_SUBCLASS_SPECIFIC | 0x00000019) +#define EFI_SW_BS_PC_GET_NEXT_MONOTONIC_COUNT (EFI_SUBCLASS_SPECIFIC | 0x0000001A) +#define EFI_SW_BS_PC_STALL (EFI_SUBCLASS_SPECIFIC | 0x0000001B) +#define EFI_SW_BS_PC_SET_WATCHDOG_TIMER (EFI_SUBCLASS_SPECIFIC | 0x0000001C) +#define EFI_SW_BS_PC_CONNECT_CONTROLLER (EFI_SUBCLASS_SPECIFIC | 0x0000001D) +#define EFI_SW_BS_PC_DISCONNECT_CONTROLLER (EFI_SUBCLASS_SPECIFIC | 0x0000001E) +#define EFI_SW_BS_PC_OPEN_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x0000001F) +#define EFI_SW_BS_PC_CLOSE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000020) +#define EFI_SW_BS_PC_OPEN_PROTOCOL_INFORMATION (EFI_SUBCLASS_SPECIFIC | 0x00000021) +#define EFI_SW_BS_PC_PROTOCOLS_PER_HANDLE (EFI_SUBCLASS_SPECIFIC | 0x00000022) +#define EFI_SW_BS_PC_LOCATE_HANDLE_BUFFER (EFI_SUBCLASS_SPECIFIC | 0x00000023) +#define EFI_SW_BS_PC_LOCATE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000024) +#define EFI_SW_BS_PC_INSTALL_MULTIPLE_INTERFACES (EFI_SUBCLASS_SPECIFIC | 0x00000025) +#define EFI_SW_BS_PC_UNINSTALL_MULTIPLE_INTERFACES (EFI_SUBCLASS_SPECIFIC | 0x00000026) +#define EFI_SW_BS_PC_CALCULATE_CRC_32 (EFI_SUBCLASS_SPECIFIC | 0x00000027) +#define EFI_SW_BS_PC_COPY_MEM (EFI_SUBCLASS_SPECIFIC | 0x00000028) +#define EFI_SW_BS_PC_SET_MEM (EFI_SUBCLASS_SPECIFIC | 0x00000029) + +// +// Software Class EFI Runtime Services Subclass Progress Code definitions. +// +#define EFI_SW_RS_PC_GET_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_RS_PC_SET_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_RS_PC_GET_WAKEUP_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_RS_PC_SET_WAKEUP_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_SW_RS_PC_SET_VIRTUAL_ADDRESS_MAP (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_SW_RS_PC_CONVERT_POINTER (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_SW_RS_PC_GET_VARIABLE (EFI_SUBCLASS_SPECIFIC | 0x00000006) +#define EFI_SW_RS_PC_GET_NEXT_VARIABLE_NAME (EFI_SUBCLASS_SPECIFIC | 0x00000007) +#define EFI_SW_RS_PC_SET_VARIABLE (EFI_SUBCLASS_SPECIFIC | 0x00000008) +#define EFI_SW_RS_PC_GET_NEXT_HIGH_MONOTONIC_COUNT (EFI_SUBCLASS_SPECIFIC | 0x00000009) +#define EFI_SW_RS_PC_RESET_SYSTEM (EFI_SUBCLASS_SPECIFIC | 0x0000000A) + +// +// Software Class EFI DXE Services Subclass Progress Code definitions +// +#define EFI_SW_DS_PC_ADD_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_DS_PC_ALLOCATE_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000001) +#define EFI_SW_DS_PC_FREE_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000002) +#define EFI_SW_DS_PC_REMOVE_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000003) +#define EFI_SW_DS_PC_GET_MEMORY_SPACE_DESCRIPTOR (EFI_SUBCLASS_SPECIFIC | 0x00000004) +#define EFI_SW_DS_PC_SET_MEMORY_SPACE_ATTRIBUTES (EFI_SUBCLASS_SPECIFIC | 0x00000005) +#define EFI_SW_DS_PC_GET_MEMORY_SPACE_MAP (EFI_SUBCLASS_SPECIFIC | 0x00000006) +#define EFI_SW_DS_PC_ADD_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000007) +#define EFI_SW_DS_PC_ALLOCATE_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000008) +#define EFI_SW_DS_PC_FREE_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000009) +#define EFI_SW_DS_PC_REMOVE_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x0000000A) +#define EFI_SW_DS_PC_GET_IO_SPACE_DESCRIPTOR (EFI_SUBCLASS_SPECIFIC | 0x0000000B) +#define EFI_SW_DS_PC_GET_IO_SPACE_MAP (EFI_SUBCLASS_SPECIFIC | 0x0000000C) +#define EFI_SW_DS_PC_DISPATCH (EFI_SUBCLASS_SPECIFIC | 0x0000000D) +#define EFI_SW_DS_PC_SCHEDULE (EFI_SUBCLASS_SPECIFIC | 0x0000000E) +#define EFI_SW_DS_PC_TRUST (EFI_SUBCLASS_SPECIFIC | 0x0000000F) +#define EFI_SW_DS_PC_PROCESS_FIRMWARE_VOLUME (EFI_SUBCLASS_SPECIFIC | 0x00000010) + +// +// Software Class Error Code definitions. +// These are shared by all subclasses. +// +#define EFI_SW_EC_NON_SPECIFIC 0x00000000 +#define EFI_SW_EC_LOAD_ERROR 0x00000001 +#define EFI_SW_EC_INVALID_PARAMETER 0x00000002 +#define EFI_SW_EC_UNSUPPORTED 0x00000003 +#define EFI_SW_EC_INVALID_BUFFER 0x00000004 +#define EFI_SW_EC_OUT_OF_RESOURCES 0x00000005 +#define EFI_SW_EC_ABORTED 0x00000006 +#define EFI_SW_EC_ILLEGAL_SOFTWARE_STATE 0x00000007 +#define EFI_SW_EC_ILLEGAL_HARDWARE_STATE 0x00000008 +#define EFI_SW_EC_START_ERROR 0x00000009 +#define EFI_SW_EC_BAD_DATE_TIME 0x0000000A +#define EFI_SW_EC_CFG_INVALID 0x0000000B +#define EFI_SW_EC_CFG_CLR_REQUEST 0x0000000C +#define EFI_SW_EC_CFG_DEFAULT 0x0000000D +#define EFI_SW_EC_PWD_INVALID 0x0000000E +#define EFI_SW_EC_PWD_CLR_REQUEST 0x0000000F +#define EFI_SW_EC_PWD_CLEARED 0x00000010 +#define EFI_SW_EC_EVENT_LOG_FULL 0x00000011 + +// +// Software Class Unspecified Subclass Error Code definitions. +// +// +// Software Class SEC Subclass Error Code definitions. +// +// +// Software Class PEI Core Subclass Error Code definitions. +// +#define EFI_SW_PEI_CORE_EC_DXE_CORRUPT (EFI_SUBCLASS_SPECIFIC | 0x00000000) + +// +// Software Class PEI Module Subclass Error Code definitions. +// +#define EFI_SW_PEIM_EC_NO_RECOVERY_CAPSULE (EFI_SUBCLASS_SPECIFIC | 0x00000000) +#define EFI_SW_PEIM_EC_INVALID_CAPSULE_DESCRIPTOR (EFI_SUBCLASS_SPECIFIC | 0x00000001) + +// +// Software Class DXE Core Subclass Error Code definitions. +// +#define EFI_SW_CSM_LEGACY_ROM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000000) +// +// Software Class DXE Boot Service Driver Subclass Error Code definitions. +// +#define EFI_SW_DXE_BS_EC_LEGACY_OPROM_NO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000000) + +// +// Software Class DXE Runtime Service Driver Subclass Error Code definitions. +// +// +// Software Class SMM Driver Subclass Error Code definitions. +// +// +// Software Class EFI Application Subclass Error Code definitions. +// +// +// Software Class EFI OS Loader Subclass Error Code definitions. +// +// +// Software Class EFI RT Subclass Error Code definitions. +// +// +// Software Class EFI AL Subclass Error Code definitions. +// +// +// Software Class EBC Exception Subclass Error Code definitions. +// These exceptions are derived from the debug protocol definitions in the EFI +// specification. +// +#define EFI_SW_EC_EBC_UNDEFINED (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_UNDEFINED) +#define EFI_SW_EC_EBC_DIVIDE_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_DIVIDE_ERROR) +#define EFI_SW_EC_EBC_DEBUG (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_DEBUG) +#define EFI_SW_EC_EBC_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_BREAKPOINT) +#define EFI_SW_EC_EBC_OVERFLOW (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_OVERFLOW) +#define EFI_SW_EC_EBC_INVALID_OPCODE (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_INVALID_OPCODE) +#define EFI_SW_EC_EBC_STACK_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_STACK_FAULT) +#define EFI_SW_EC_EBC_ALIGNMENT_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_ALIGNMENT_CHECK) +#define EFI_SW_EC_EBC_INSTRUCTION_ENCODING (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_INSTRUCTION_ENCODING) +#define EFI_SW_EC_EBC_BAD_BREAK (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_BAD_BREAK) +#define EFI_SW_EC_EBC_STEP (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_STEP) + +// +// Software Class IA32 Exception Subclass Error Code definitions. +// These exceptions are derived from the debug protocol definitions in the EFI +// specification. +// +#define EFI_SW_EC_IA32_DIVIDE_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DIVIDE_ERROR) +#define EFI_SW_EC_IA32_DEBUG (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DEBUG) +#define EFI_SW_EC_IA32_NMI (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_NMI) +#define EFI_SW_EC_IA32_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_BREAKPOINT) +#define EFI_SW_EC_IA32_OVERFLOW (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_OVERFLOW) +#define EFI_SW_EC_IA32_BOUND (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_BOUND) +#define EFI_SW_EC_IA32_INVALID_OPCODE (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_INVALID_OPCODE) +#define EFI_SW_EC_IA32_DOUBLE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DOUBLE_FAULT) +#define EFI_SW_EC_IA32_INVALID_TSS (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_INVALID_TSS) +#define EFI_SW_EC_IA32_SEG_NOT_PRESENT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_SEG_NOT_PRESENT) +#define EFI_SW_EC_IA32_STACK_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_STACK_FAULT) +#define EFI_SW_EC_IA32_GP_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_GP_FAULT) +#define EFI_SW_EC_IA32_PAGE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_PAGE_FAULT) +#define EFI_SW_EC_IA32_FP_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_FP_ERROR) +#define EFI_SW_EC_IA32_ALIGNMENT_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_ALIGNMENT_CHECK) +#define EFI_SW_EC_IA32_MACHINE_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_MACHINE_CHECK) +#define EFI_SW_EC_IA32_SIMD (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_SIMD) + +// +// Software Class X64 Exception Subclass Error Code definitions. +// These exceptions are derived from the debug protocol definitions in the EFI +// specification. +// +#define EFI_SW_EC_X64_DIVIDE_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DIVIDE_ERROR) +#define EFI_SW_EC_X64_DEBUG (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DEBUG) +#define EFI_SW_EC_X64_NMI (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_NMI) +#define EFI_SW_EC_X64_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_BREAKPOINT) +#define EFI_SW_EC_X64_OVERFLOW (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_OVERFLOW) +#define EFI_SW_EC_X64_BOUND (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_BOUND) +#define EFI_SW_EC_X64_INVALID_OPCODE (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_INVALID_OPCODE) +#define EFI_SW_EC_X64_DOUBLE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DOUBLE_FAULT) +#define EFI_SW_EC_X64_INVALID_TSS (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_INVALID_TSS) +#define EFI_SW_EC_X64_SEG_NOT_PRESENT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_SEG_NOT_PRESENT) +#define EFI_SW_EC_X64_STACK_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_STACK_FAULT) +#define EFI_SW_EC_X64_GP_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_GP_FAULT) +#define EFI_SW_EC_X64_PAGE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_PAGE_FAULT) +#define EFI_SW_EC_X64_FP_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_FP_ERROR) +#define EFI_SW_EC_X64_ALIGNMENT_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_ALIGNMENT_CHECK) +#define EFI_SW_EC_X64_MACHINE_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_MACHINE_CHECK) +#define EFI_SW_EC_X64_SIMD (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_SIMD) + +// +// Software Class IPF Exception Subclass Error Code definitions. +// These exceptions are derived from the debug protocol definitions in the EFI +// specification. +// +#define EFI_SW_EC_IPF_ALT_DTLB (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_ALT_DTLB) +#define EFI_SW_EC_IPF_DNESTED_TLB (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_DNESTED_TLB) +#define EFI_SW_EC_IPF_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_BREAKPOINT) +#define EFI_SW_EC_IPF_EXTERNAL_INTERRUPT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_EXTERNAL_INTERRUPT) +#define EFI_SW_EC_IPF_GEN_EXCEPT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_GEN_EXCEPT) +#define EFI_SW_EC_IPF_NAT_CONSUMPTION (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_NAT_CONSUMPTION) +#define EFI_SW_EC_IPF_DEBUG_EXCEPT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_DEBUG_EXCEPT) +#define EFI_SW_EC_IPF_UNALIGNED_ACCESS (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_UNALIGNED_ACCESS) +#define EFI_SW_EC_IPF_FP_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_FP_FAULT) +#define EFI_SW_EC_IPF_FP_TRAP (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_FP_TRAP) +#define EFI_SW_EC_IPF_TAKEN_BRANCH (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_TAKEN_BRANCH) +#define EFI_SW_EC_IPF_SINGLE_STEP (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_SINGLE_STEP) + +// +// Software Class PEI Service Subclass Error Code definitions. +// +// +// Software Class EFI Boot Service Subclass Error Code definitions. +// +// +// Software Class EFI Runtime Service Subclass Error Code definitions. +// +// +// Software Class EFI DXE Service Subclass Error Code definitions. +// + +/////////////////////////////////////////////////////////////////////////////// +// Section 7 +/////////////////////////////////////////////////////////////////////////////// +// +// Debug Code definitions for all classes and subclass +// Only one debug code is defined at this point and should +// be used for anything that gets sent to debug stream. +// +#define EFI_DC_UNSPECIFIED 0x0 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiVariable.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiVariable.h new file mode 100644 index 0000000000..fc6f532c80 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiVariable.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiVariable.h + +Abstract: + + + +--*/ + +#ifndef _EFI_VARIABLE_DEFINITION_H_ +#define _EFI_VARIABLE_DEFINITION_H_ + +// +// Variable attributes +// +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 +#define EFI_VARIABLE_READ_ONLY 0x00000008 + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h new file mode 100644 index 0000000000..e74e1f47e8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h @@ -0,0 +1,615 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiApi.h + +Abstract: + + Tiano PEI intrinsic definitions. This includes all Pei Services APIs. + + Peims are passed in a pointer to a pointer to the PEI Services table. + The PEI Services table contains pointers to the PEI services exported + by the PEI Core. + +--*/ + +#ifndef _PEI_API_H_ +#define _PEI_API_H_ + +#include "PeiHob.h" +#include "EfiFirmwareFileSystem.h" +#include "EfiFirmwareVolumeHeader.h" +#include EFI_PPI_DEFINITION (FirmwareVolumeInfo) +#include EFI_PPI_DEFINITION (FirmwareVolume) +#include EFI_PPI_DEFINITION (Decompress) + + +// +// Declare forward referenced data structures +// +EFI_FORWARD_DECLARATION (EFI_PEI_NOTIFY_DESCRIPTOR); +EFI_FORWARD_DECLARATION (EFI_PEI_SERVICES); + +#include EFI_PPI_DEFINITION (CpuIo) +#include EFI_PPI_DEFINITION (PciCfg) +#include EFI_PPI_DEFINITION (PciCfg2) + +// +// PEI Specification Revision information +// +#if (PI_SPECIFICATION_VERSION < 0x00010000) +#define PEI_SPECIFICATION_MAJOR_REVISION 0 +#define PEI_SPECIFICATION_MINOR_REVISION 91 +#else +#define PEI_SPECIFICATION_MAJOR_REVISION 1 +#define PEI_SPECIFICATION_MINOR_REVISION 00 + +#endif + +typedef +EFI_STATUS +(EFIAPI *EFI_PEIM_ENTRY_POINT)( + IN EFI_FFS_FILE_HEADER * FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEIM_NOTIFY_ENTRY_POINT) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR * NotifyDescriptor, + IN VOID *Ppi + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_VERIFICATION) ( + IN UINTN SectionAddress + ); + +// +// PEI Ppi Services List Descriptors +// +#define EFI_PEI_PPI_DESCRIPTOR_PIC 0x00000001 +#define EFI_PEI_PPI_DESCRIPTOR_PPI 0x00000010 +#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK 0x00000020 +#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH 0x00000040 +#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES 0x00000060 +#define EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST 0x80000000 + +typedef struct { + UINTN Flags; + EFI_GUID *Guid; + VOID *Ppi; +} EFI_PEI_PPI_DESCRIPTOR; + +typedef struct _EFI_PEI_NOTIFY_DESCRIPTOR { + UINTN Flags; + EFI_GUID *Guid; + EFI_PEIM_NOTIFY_ENTRY_POINT Notify; +} EFI_PEI_NOTIFY_DESCRIPTOR; + + + +typedef +EFI_STATUS +(EFIAPI *EFI_REPORT_STATUS_CODE) ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ); + + + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + +// +// PEI PPI Services +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_INSTALL_PPI) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_PPI_DESCRIPTOR * PpiList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_REINSTALL_PPI) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_PPI_DESCRIPTOR * OldPpi, + IN EFI_PEI_PPI_DESCRIPTOR * NewPpi + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_LOCATE_PPI) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID * Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_NOTIFY_PPI) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR * NotifyList + ); + +// +// PEI Boot Mode Services +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_GET_BOOT_MODE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT EFI_BOOT_MODE * BootMode + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SET_BOOT_MODE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_BOOT_MODE BootMode + ); + +// +// PEI HOB Services +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_GET_HOB_LIST) ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT VOID **HobList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_CREATE_HOB) ( + IN EFI_PEI_SERVICES **PeiServices, + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob + ); + + // + // PEI Firmware Volume Services + // + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME) ( + IN EFI_PEI_SERVICES **PeiServices, + IN UINTN Instance, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_FV_FILETYPE SearchType, + IN EFI_FIRMWARE_VOLUME_HEADER * FwVolHeader, + IN OUT EFI_FFS_FILE_HEADER **FileHeader + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER * FfsFileHeader, + IN OUT VOID **SectionData + ); + +// +// PEI Memory Services +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_ALLOCATE_PAGES) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS * Memory + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_ALLOCATE_POOL) ( + IN EFI_PEI_SERVICES **PeiServices, + IN UINTN Size, + OUT VOID **Buffer + ); + +typedef +VOID +(EFIAPI *EFI_PEI_COPY_MEM) ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ); + +typedef +VOID +(EFIAPI *EFI_PEI_SET_MEM) ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_REPORT_STATUS_CODE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ); + +// +// PEI Reset +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_RESET_SYSTEM) ( + IN EFI_PEI_SERVICES **PeiServices + ); + + + +#else + +// +// PEI PPI Services +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_INSTALL_PPI) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_PPI_DESCRIPTOR * PpiList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_REINSTALL_PPI) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_PPI_DESCRIPTOR * OldPpi, + IN CONST EFI_PEI_PPI_DESCRIPTOR * NewPpi + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_LOCATE_PPI) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_GUID * Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor OPTIONAL, + IN OUT VOID **Ppi + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_NOTIFY_PPI) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_NOTIFY_DESCRIPTOR * NotifyList + ); + +// +// PEI Boot Mode Services +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_GET_BOOT_MODE) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT EFI_BOOT_MODE * BootMode + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SET_BOOT_MODE) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_BOOT_MODE BootMode + ); + +// +// PEI HOB Services +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_GET_HOB_LIST) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT VOID **HobList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_CREATE_HOB) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob + ); + + + + // + // PEI Firmware Volume Services + // +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME2) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN UINTN Instance, + IN OUT EFI_PEI_FV_HANDLE *VolumeHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE2) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_FV_FILETYPE SearchType, + IN CONST EFI_PEI_FV_HANDLE *FwVolHeader, + IN OUT EFI_PEI_FILE_HANDLE **FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA2) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_SECTION_TYPE SectionType, + IN EFI_PEI_FILE_HANDLE *FileHandle, + OUT VOID **SectionData + ); + + + // + // PEI Memory Services + // +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_ALLOCATE_PAGES) ( + + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS * Memory + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_ALLOCATE_POOL) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN UINTN Size, + OUT VOID **Buffer + ); + +typedef +VOID +(EFIAPI *EFI_PEI_COPY_MEM) ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ); + +typedef +VOID +(EFIAPI *EFI_PEI_SET_MEM) ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ); + + // + // New interfaceas added by the PI 1.0 + // +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_FIND_BY_NAME) ( + IN CONST EFI_GUID *FileName, + IN EFI_PEI_FV_HANDLE VolumeHandle, + OUT EFI_PEI_FILE_HANDLE *FileHandle + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_GET_FILE_INFO) ( + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT EFI_FV_FILE_INFO *FileInfo + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FFS_GET_VOLUME_INFO) ( + IN EFI_PEI_FV_HANDLE *VolumeHandle, + OUT EFI_FV_INFO *VolumeInfo + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_REGISTER_FOR_SHADOW) ( + IN EFI_PEI_FILE_HANDLE FileHandle + ); + +// +// PEI Status Code Service +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_REPORT_STATUS_CODE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ); + +// +// PEI Reset Service +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_RESET_SYSTEM) ( + IN EFI_PEI_SERVICES **PeiServices + ); + +#endif + + +// +// EFI PEI Services Table +// +#define PEI_SERVICES_SIGNATURE 0x5652455320494550 +#define PEI_SERVICES_REVISION ((PEI_SPECIFICATION_MAJOR_REVISION << 16) | (PEI_SPECIFICATION_MINOR_REVISION)) +typedef PEI_CPU_IO_PPI EFI_PEI_CPU_IO_PPI; + + +typedef struct _EFI_PEI_SERVICES { + EFI_TABLE_HEADER Hdr; + + // + // PPI Functions + // + EFI_PEI_INSTALL_PPI InstallPpi; + EFI_PEI_REINSTALL_PPI ReInstallPpi; + EFI_PEI_LOCATE_PPI LocatePpi; + EFI_PEI_NOTIFY_PPI NotifyPpi; + + // + // Boot Mode Functions + // + EFI_PEI_GET_BOOT_MODE GetBootMode; + EFI_PEI_SET_BOOT_MODE SetBootMode; + + // + // HOB Functions + // + EFI_PEI_GET_HOB_LIST GetHobList; + EFI_PEI_CREATE_HOB CreateHob; + + // + // Firmware Volume Functions + // +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_PEI_FFS_FIND_NEXT_VOLUME FfsFindNextVolume; + EFI_PEI_FFS_FIND_NEXT_FILE FfsFindNextFile; + EFI_PEI_FFS_FIND_SECTION_DATA FfsFindSectionData; +#else + EFI_PEI_FFS_FIND_NEXT_VOLUME2 FfsFindNextVolume; + EFI_PEI_FFS_FIND_NEXT_FILE2 FfsFindNextFile; + EFI_PEI_FFS_FIND_SECTION_DATA2 FfsFindSectionData; +#endif + // + // PEI Memory Functions + // + EFI_PEI_INSTALL_PEI_MEMORY InstallPeiMemory; + EFI_PEI_ALLOCATE_PAGES AllocatePages; + EFI_PEI_ALLOCATE_POOL AllocatePool; + EFI_PEI_COPY_MEM CopyMem; + EFI_PEI_SET_MEM SetMem; + + // + // Status Code + // + EFI_PEI_REPORT_STATUS_CODE PeiReportStatusCode; + + // + // Reset + // + EFI_PEI_RESET_SYSTEM PeiResetSystem; + + // + // Pointer to PPI interface + // +#if (PI_SPECIFICATION_VERSION < 0x00010000) + + PEI_CPU_IO_PPI *CpuIo; + PEI_PCI_CFG_PPI *PciCfg; +#else + EFI_PEI_CPU_IO_PPI *CpuIo; + EFI_PEI_PCI_CFG2_PPI *PciCfg; + + // + // New interfaceas added by the PI 1.0 + // + EFI_PEI_FFS_FIND_BY_NAME FfsFindFileByName; + EFI_PEI_FFS_GET_FILE_INFO FfsGetFileInfo; + EFI_PEI_FFS_GET_VOLUME_INFO FfsGetVolumeInfo; + EFI_PEI_REGISTER_FOR_SHADOW RegisterForShadow; +#endif + +} EFI_PEI_SERVICES; + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + +typedef struct { + UINTN BootFirmwareVolume; + UINTN SizeOfCacheAsRam; + EFI_PEI_PPI_DESCRIPTOR *DispatchTable; +} EFI_PEI_STARTUP_DESCRIPTOR; + +typedef +EFI_STATUS +(EFIAPI *PEI_MAIN_ENTRY_POINT) ( + IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor + ); + +#else + +typedef struct _EFI_SEC_PEI_HAND_OFF{ + UINT16 DataSize; + VOID *BootFirmwareVolumeBase; + UINTN BootFirmwareVolumeSize; + VOID *TemporaryRamBase; + UINTN TemporaryRamSize; + VOID *PeiTemporaryRamBase; + UINTN PeiTemporaryRamSize; + VOID *StackBase; + UINTN StackSize; +}EFI_SEC_PEI_HAND_OFF; + +typedef +EFI_STATUS +(EFIAPI *PEI_MAIN_ENTRY_POINT) ( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList + ); + +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiHob.h b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiHob.h new file mode 100644 index 0000000000..abddea7a22 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiHob.h @@ -0,0 +1,251 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiHob.h + +Abstract: + + PEI Hand Off Block (HOB) definition. + + The HOB is a memory data structure used to hand-off system information from + PEI to DXE (the next phase). + +--*/ + +#ifndef _PEI_HOB_H_ +#define _PEI_HOB_H_ + +#include "BootMode.h" + +// +// Every Hob must start with this data structure. +// +typedef struct { + UINT16 HobType; + UINT16 HobLength; + UINT32 Reserved; +} EFI_HOB_GENERIC_HEADER; + +// +// End of HOB List HOB +// +#define EFI_HOB_TYPE_END_OF_HOB_LIST 0xffff + +// +// Handoff Information Table HOB +// +#define EFI_HOB_TYPE_HANDOFF 0x0001 + +#define EFI_HOB_HANDOFF_TABLE_VERSION 0x0009 + +typedef UINT32 EFI_BOOT_MODE; + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + UINT32 Version; + EFI_BOOT_MODE BootMode; + EFI_PHYSICAL_ADDRESS EfiMemoryTop; + EFI_PHYSICAL_ADDRESS EfiMemoryBottom; + EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop; + EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom; + EFI_PHYSICAL_ADDRESS EfiEndOfHobList; +} EFI_HOB_HANDOFF_INFO_TABLE; + +// +// Memory Descriptor HOB +// +#define EFI_HOB_TYPE_MEMORY_ALLOCATION 0x0002 + +typedef struct { + EFI_GUID Name; + EFI_PHYSICAL_ADDRESS MemoryBaseAddress; + UINT64 MemoryLength; + EFI_MEMORY_TYPE MemoryType; + UINT8 Reserved[4]; +} EFI_HOB_MEMORY_ALLOCATION_HEADER; + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor; + // + // Additional data pertaining to the "Name" Guid memory + // may go here. + // +} EFI_HOB_MEMORY_ALLOCATION; + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor; +} EFI_HOB_MEMORY_ALLOCATION_BSP_STORE; + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor; +} EFI_HOB_MEMORY_ALLOCATION_STACK; + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_HOB_MEMORY_ALLOCATION_HEADER MemoryAllocationHeader; + EFI_GUID ModuleName; + EFI_PHYSICAL_ADDRESS EntryPoint; +} EFI_HOB_MEMORY_ALLOCATION_MODULE; + +#define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR 0x0003 + +typedef UINT32 EFI_RESOURCE_TYPE; + +#define EFI_RESOURCE_SYSTEM_MEMORY 0 +#define EFI_RESOURCE_MEMORY_MAPPED_IO 1 +#define EFI_RESOURCE_IO 2 +#define EFI_RESOURCE_FIRMWARE_DEVICE 3 +#define EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 4 +#define EFI_RESOURCE_MEMORY_RESERVED 5 +#define EFI_RESOURCE_IO_RESERVED 6 +#define EFI_RESOURCE_MAX_MEMORY_TYPE 7 + +typedef UINT32 EFI_RESOURCE_ATTRIBUTE_TYPE; + +#define EFI_RESOURCE_ATTRIBUTE_PRESENT 0x00000001 +#define EFI_RESOURCE_ATTRIBUTE_INITIALIZED 0x00000002 +#define EFI_RESOURCE_ATTRIBUTE_TESTED 0x00000004 +#define EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC 0x00000008 +#define EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC 0x00000010 +#define EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_1 0x00000020 +#define EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_2 0x00000040 +#define EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED 0x00000080 +#define EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED 0x00000100 +#define EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED 0x00000200 +#define EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE 0x00000400 +#define EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE 0x00000800 +#define EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE 0x00001000 +#define EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE 0x00002000 +#define EFI_RESOURCE_ATTRIBUTE_16_BIT_IO 0x00004000 +#define EFI_RESOURCE_ATTRIBUTE_32_BIT_IO 0x00008000 +#define EFI_RESOURCE_ATTRIBUTE_64_BIT_IO 0x00010000 +#define EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED 0x00020000 + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_GUID Owner; + EFI_RESOURCE_TYPE ResourceType; + EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; + EFI_PHYSICAL_ADDRESS PhysicalStart; + UINT64 ResourceLength; +} EFI_HOB_RESOURCE_DESCRIPTOR; + +// +// GUID Extension HOB +// The HobLength is variable as it includes the GUID specific data. +// +#define EFI_HOB_TYPE_GUID_EXTENSION 0x0004 + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_GUID Name; + + // + // Guid specific data goes here + // +} EFI_HOB_GUID_TYPE; + +// +// Firmware Volume HOB +// +#define EFI_HOB_TYPE_FV 0x0005 + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 Length; +} EFI_HOB_FIRMWARE_VOLUME; + +// +// CPU HOB +// +#define EFI_HOB_TYPE_CPU 0x0006 + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + UINT8 SizeOfMemorySpace; + UINT8 SizeOfIoSpace; + UINT8 Reserved[6]; +} EFI_HOB_CPU; + +// +// PEI Core Memory Pool HOB +// The HobLength is variable as the HOB contains pool allocations by +// the PeiServices AllocatePool function +// +#define EFI_HOB_TYPE_PEI_MEMORY_POOL 0x0007 + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; +} EFI_HOB_MEMORY_POOL; + +// +// Capsule volume HOB -- identical to a firmware volume +// +#define EFI_HOB_TYPE_CV 0x0008 + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 Length; +} EFI_HOB_CAPSULE_VOLUME; + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + +#define EFI_HOB_TYPE_FV2 0x0009 + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 Length; + EFI_GUID FvName; + EFI_GUID FileName; +} EFI_HOB_FIRMWARE_VOLUME2; + +#define EFI_HOB_TYPE_LOAD_PEIM 0x000A + +#endif + +#define EFI_HOB_TYPE_UNUSED 0xFFFE + +// +// Union of all the possible HOB Types +// +typedef union { + EFI_HOB_GENERIC_HEADER *Header; + EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable; + EFI_HOB_MEMORY_ALLOCATION *MemoryAllocation; + EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *MemoryAllocationBspStore; + EFI_HOB_MEMORY_ALLOCATION_STACK *MemoryAllocationStack; + EFI_HOB_MEMORY_ALLOCATION_MODULE *MemoryAllocationModule; + EFI_HOB_RESOURCE_DESCRIPTOR *ResourceDescriptor; + EFI_HOB_GUID_TYPE *Guid; + EFI_HOB_FIRMWARE_VOLUME *FirmwareVolume; +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2; +#endif + EFI_HOB_CPU *Cpu; + EFI_HOB_MEMORY_POOL *Pool; + EFI_HOB_CAPSULE_VOLUME *CapsuleVolume; + UINT8 *Raw; +} EFI_PEI_HOB_POINTERS; + +#define GET_HOB_TYPE(Hob) ((Hob).Header->HobType) +#define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength) +#define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob)) +#define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_END_OF_HOB_LIST) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecApi.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecApi.h new file mode 100644 index 0000000000..5850075272 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecApi.h @@ -0,0 +1,589 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoSpecApi.h + +Abstract: + + Tiano intrinsic definitions in Tiano spec. + + +--*/ + +#ifndef _TIANO_SPEC_API_H_ +#define _TIANO_SPEC_API_H_ + + +#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000)) +// +// Prior to UEFI 2.0 Tiano extended these enums. This was replaced by +// CreateEventEx() Event Groups in UEFI 2.0 +// +#define EFI_EVENT_NOTIFY_SIGNAL_ALL 0x00000400 + +#define EFI_EVENT_SIGNAL_READY_TO_BOOT 0x00000203 +#define EFI_EVENT_SIGNAL_LEGACY_BOOT 0x00000204 +#endif + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_ADD_MEMORY_SPACE) ( + IN EFI_GCD_MEMORY_TYPE GcdMemoryType, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Capabilities + ) +/*++ + +Routine Description: + + Adds reserved memory, system memory, or memory-mapped I/O resources to the +global coherency domain of the processor. + +Arguments: + + GcdMemoryType - Memory type of the memory space. + + BaseAddress - Base address of the memory space. + + Length - Length of the memory space. + + Capabilities - alterable attributes of the memory space. + +Returns: + + EFI_SUCCESS - Merged this memory space into GCD map. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_MEMORY_SPACE) ( + IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType, + IN EFI_GCD_MEMORY_TYPE GcdMemoryType, + IN UINTN Alignment, + IN UINT64 Length, + IN OUT EFI_PHYSICAL_ADDRESS * BaseAddress, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE DeviceHandle OPTIONAL + ) +/*++ + +Routine Description: + + Allocates nonexistent memory, reserved memory, system memory, or memorymapped +I/O resources from the global coherency domain of the processor. + +Arguments: + + GcdAllocateType - The type of allocate operation + + GcdMemoryType - The desired memory type + + Alignment - Align with 2^Alignment + + Length - Length to allocate + + BaseAddress - Base address to allocate + + Imagehandle - The image handle consume the allocated space. + + DeviceHandle - The device handle consume the allocated space. + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter. + + EFI_NOT_FOUND - No descriptor contains the desired space. + + EFI_SUCCESS - Memory space successfully allocated. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_FREE_MEMORY_SPACE) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description:Routine Description: + + Frees nonexistent memory, reserved memory, system memory, or memory-mapped +I/O resources from the global coherency domain of the processor. + +Arguments: + + BaseAddress - Base address of the segment. + + Length - Length of the segment. + +Returns: + + EFI_SUCCESS - Space successfully freed. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_REMOVE_MEMORY_SPACE) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description:Routine Description: + + Removes reserved memory, system memory, or memory-mapped I/O resources from +the global coherency domain of the processor. + +Arguments: + + BaseAddress - Base address of the memory space. + + Length - Length of the memory space. + +Returns: + + EFI_SUCCESS - Successfully remove a segment of memory space. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_GET_MEMORY_SPACE_DESCRIPTOR) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR * Descriptor + ) +/*++ + +Routine Description: + + Retrieves the descriptor for a memory region containing a specified address. + +Arguments: + + BaseAddress - Specified start address + + Descriptor - Specified length + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + + EFI_SUCCESS - Successfully get memory space descriptor. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_SET_MEMORY_SPACE_ATTRIBUTES) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ) +/*++ + +Routine Description: + + Modifies the attributes for a memory region in the global coherency domain of the +processor. + +Arguments: + + BaseAddress - Specified start address + + Length - Specified length + + Attributes - Specified attributes + +Returns: + + EFI_SUCCESS - Successfully set attribute of a segment of memory space. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_GET_MEMORY_SPACE_MAP) ( + OUT UINTN *NumberOfDescriptors, + OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap + ) +/*++ + +Routine Description: + + Returns a map of the memory resources in the global coherency domain of the +processor. + +Arguments: + + NumberOfDescriptors - Number of descriptors. + + MemorySpaceMap - Descriptor array + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Successfully get memory space map. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_ADD_IO_SPACE) ( + IN EFI_GCD_IO_TYPE GcdIoType, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Adds reserved I/O or I/O resources to the global coherency domain of the processor. + +Arguments: + + GcdIoType - IO type of the segment. + + BaseAddress - Base address of the segment. + + Length - Length of the segment. + +Returns: + + EFI_SUCCESS - Merged this segment into GCD map. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_ALLOCATE_IO_SPACE) ( + IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType, + IN EFI_GCD_IO_TYPE GcdIoType, + IN UINTN Alignment, + IN UINT64 Length, + IN OUT EFI_PHYSICAL_ADDRESS * BaseAddress, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE DeviceHandle OPTIONAL + ) +/*++ + +Routine Description: + + Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency +domain of the processor. + +Arguments: + + GcdAllocateType - The type of allocate operation + + GcdIoType - The desired IO type + + Alignment - Align with 2^Alignment + + Length - Length to allocate + + BaseAddress - Base address to allocate + + Imagehandle - The image handle consume the allocated space. + + DeviceHandle - The device handle consume the allocated space. + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter. + + EFI_NOT_FOUND - No descriptor contains the desired space. + + EFI_SUCCESS - IO space successfully allocated. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_FREE_IO_SPACE) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description:Routine Description: + + Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency +domain of the processor. + +Arguments: + + BaseAddress - Base address of the segment. + + Length - Length of the segment. + +Returns: + + EFI_SUCCESS - Space successfully freed. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_REMOVE_IO_SPACE) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description:Routine Description: + + Removes reserved I/O or I/O resources from the global coherency domain of the +processor. + +Arguments: + + BaseAddress - Base address of the segment. + + Length - Length of the segment. + +Returns: + + EFI_SUCCESS - Successfully removed a segment of IO space. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_GET_IO_SPACE_DESCRIPTOR) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + OUT EFI_GCD_IO_SPACE_DESCRIPTOR * Descriptor + ) +/*++ + +Routine Description: + + Retrieves the descriptor for an I/O region containing a specified address. + +Arguments: + + BaseAddress - Specified start address + + Descriptor - Specified length + +Returns: + + EFI_INVALID_PARAMETER - Descriptor is NULL. + + EFI_SUCCESS - Successfully get the IO space descriptor. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_GET_IO_SPACE_MAP) ( + OUT UINTN *NumberOfDescriptors, + OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap + ) +/*++ + +Routine Description: + + Returns a map of the I/O resources in the global coherency domain of the processor. + +Arguments: + + NumberOfDescriptors - Number of descriptors. + + MemorySpaceMap - Descriptor array + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Successfully get IO space map. + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_DISPATCH) (VOID) +/*++ + +Routine Description: + + Loads and executed DXE drivers from firmware volumes. + +Arguments: + + None + +Returns: + + Status code + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_SCHEDULE) ( + IN EFI_HANDLE FirmwareVolumeHandle, + IN EFI_GUID * DriverName + ) +/*++ + +Routine Description: + + Clears the Schedule on Request (SOR) flag for a component that is stored in a firmware volume. + +Arguments: + + FirmwareVolumeHandle - The handle of the firmware volume that contains the file specified by FileName. + + DriverName - A pointer to the name of the file in a firmware volume. + +Returns: + + Status code + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_TRUST) ( + IN EFI_HANDLE FirmwareVolumeHandle, + IN EFI_GUID * DriverName + ) +/*++ + +Routine Description: + + Promotes a file stored in a firmware volume from the untrusted to the trusted state. + +Arguments: + + FirmwareVolumeHandle - The handle of the firmware volume that contains the file specified by FileName. + + DriverName - A pointer to the name of the file in a firmware volume. + +Returns: + + Status code + +--*/ +; + +typedef +EFI_BOOTSERVICE +EFI_STATUS +(EFIAPI *EFI_PROCESS_FIRMWARE_VOLUME) ( + IN VOID *FvHeader, + IN UINTN Size, + OUT EFI_HANDLE * FirmwareVolumeHandle + ) +/*++ + +Routine Description: + + Creates a firmware volume handle for a firmware volume that is present in system memory. + +Arguments: + + FirmwareVolumeHeader - A pointer to the header of the firmware volume. + Size - The size, in bytes, of the firmware volume. + FirmwareVolumeHandle - On output, a pointer to the created handle. + +Returns: + + Status code + +--*/ +; + +// +// DXE Services Table +// +#define EFI_DXE_SERVICES_SIGNATURE 0x565245535f455844 +#if (PI_SPECIFICATION_VERSION < 0x00010000) +#define EFI_DXE_SERVICES_REVISION ((0 << 16) | (90)) +#else +#define EFI_DXE_SERVICES_REVISION ((1 << 16) | (00)) +#endif + +typedef struct { + EFI_TABLE_HEADER Hdr; + + // + // Global Coherency Domain Services + // + EFI_ADD_MEMORY_SPACE AddMemorySpace; + EFI_ALLOCATE_MEMORY_SPACE AllocateMemorySpace; + EFI_FREE_MEMORY_SPACE FreeMemorySpace; + EFI_REMOVE_MEMORY_SPACE RemoveMemorySpace; + EFI_GET_MEMORY_SPACE_DESCRIPTOR GetMemorySpaceDescriptor; + EFI_SET_MEMORY_SPACE_ATTRIBUTES SetMemorySpaceAttributes; + EFI_GET_MEMORY_SPACE_MAP GetMemorySpaceMap; + EFI_ADD_IO_SPACE AddIoSpace; + EFI_ALLOCATE_IO_SPACE AllocateIoSpace; + EFI_FREE_IO_SPACE FreeIoSpace; + EFI_REMOVE_IO_SPACE RemoveIoSpace; + EFI_GET_IO_SPACE_DESCRIPTOR GetIoSpaceDescriptor; + EFI_GET_IO_SPACE_MAP GetIoSpaceMap; + + // + // Dispatcher Services + // + EFI_DISPATCH Dispatch; + EFI_SCHEDULE Schedule; + EFI_TRUST Trust; + // + // Service to process a single firmware volume found in a capsule + // + EFI_PROCESS_FIRMWARE_VOLUME ProcessFirmwareVolume; +} EFI_DXE_SERVICES; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h new file mode 100644 index 0000000000..a2f45a4a54 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h @@ -0,0 +1,73 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoSpecDevicePath.h + +Abstract: + + Tiano Device Path definitions in Tiano Spec. + +--*/ + +#ifndef _TIANO_SPEC_DEVICE_PATH_H +#define _TIANO_SPEC_DEVICE_PATH_H + +#pragma pack(1) + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) +// +// EFI Specification extension on Media Device Path +// +#define MEDIA_FV_FILEPATH_DP 0x06 +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID NameGuid; +} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH; +#endif + + +#if (EFI_SPECIFICATION_VERSION == 0x00020000) +// +// For UEFI 2.0, use GUIDed PIWG device path to work-around EFI Specification extension on Media Device Path +// +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + EFI_GUID PiwgSpecificDevicePath; + UINT32 Type; +} PIWG_DEVICE_PATH; + +#define PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE 0x01 +typedef struct { + PIWG_DEVICE_PATH Piwg; + EFI_GUID NameGuid; +} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH; + +// +// Place holder for a future extension +// +#define PIWG_MEDIA_FW_VOL_DEVICE_PATH_TYPE 0x02 +typedef struct { + PIWG_DEVICE_PATH Piwg; + EFI_GUID VolumeGuid; +} MEDIA_FW_VOL_DEVICE_PATH; +#endif + +#if (EFI_SPECIFICATION_VERSION > 0x00020000) +// +// EFI Specification extension on Media Device Path was added to UEFI 2.1 specification, +// so the definition is moved to EfiDevicePath.h +// +#endif + +#pragma pack() +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecError.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecError.h new file mode 100644 index 0000000000..4836462ff7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecError.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoSpecError.h + +Abstract: + + Tiano error codes defined in Tiano spec. + +--*/ + +#ifndef _TIANO_SPEC_ERROR_H_ +#define _TIANO_SPEC_ERROR_H_ + +#include "EfiBind.h" +#define TIANO_ERROR(a) (MAX_2_BITS | (a)) + +// +// Tiano added a couple of return types. These are owned by UEFI specification +// and Tiano can not use them. Thus for UEFI 2.0/R8.6 support we moved the values +// to a UEFI OEM extension range to conform to UEFI specification. +// +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + #define EFI_NOT_AVAILABLE_YET EFIERR (28) + #define EFI_UNLOAD_IMAGE EFIERR (29) +#else + #define EFI_NOT_AVAILABLE_YET TIANO_ERROR (0) + #define EFI_UNLOAD_IMAGE TIANO_ERROR (1) +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecTypes.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecTypes.h new file mode 100644 index 0000000000..5fdcf269f1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecTypes.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoSpecTypes.h + +Abstract: + + Tiano types defined in Tiano spec. + +--*/ + +#ifndef _TIANO_SPEC_TYPES_H_ +#define _TIANO_SPEC_TYPES_H_ + +// +// Modifier for EFI DXE Services +// +#define EFI_DXESERVICE + +// +// Global Coherencey Domain types +// +typedef enum { + EfiGcdMemoryTypeNonExistent, + EfiGcdMemoryTypeReserved, + EfiGcdMemoryTypeSystemMemory, + EfiGcdMemoryTypeMemoryMappedIo, + EfiGcdMemoryTypeMaximum +} EFI_GCD_MEMORY_TYPE; + +typedef enum { + EfiGcdIoTypeNonExistent, + EfiGcdIoTypeReserved, + EfiGcdIoTypeIo, + EfiGcdIoTypeMaximum +} EFI_GCD_IO_TYPE; + +typedef enum { + EfiGcdAllocateAnySearchBottomUp, + EfiGcdAllocateMaxAddressSearchBottomUp, + EfiGcdAllocateAddress, + EfiGcdAllocateAnySearchTopDown, + EfiGcdAllocateMaxAddressSearchTopDown, + EfiGcdMaxAllocateType +} EFI_GCD_ALLOCATE_TYPE; + +typedef struct { + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 Length; + UINT64 Capabilities; + UINT64 Attributes; + EFI_GCD_MEMORY_TYPE GcdMemoryType; + EFI_HANDLE ImageHandle; + EFI_HANDLE DeviceHandle; +} EFI_GCD_MEMORY_SPACE_DESCRIPTOR; + +typedef struct { + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 Length; + EFI_GCD_IO_TYPE GcdIoType; + EFI_HANDLE ImageHandle; + EFI_HANDLE DeviceHandle; +} EFI_GCD_IO_SPACE_DESCRIPTOR; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.c new file mode 100644 index 0000000000..40b7654679 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + BlockIo.c + +Abstract: + + BlockIo PPI GUID as defined in EFI 2.0 + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (BlockIo) + +EFI_GUID gPeiBlockIoPpiGuid = PEI_BLOCK_IO_PPI_GUID; + +EFI_GUID_STRING(&gPeiBlockIoPpiGuid, "BlockIo", "PEI Block I/O PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.h new file mode 100644 index 0000000000..5433edb370 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BlockIo/BlockIo.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + BlockIo.h + +Abstract: + + BlockIo PPI as defined in EFI 2.0 + + Used to access block-oriented storage devices + +--*/ + +#ifndef _PEI_BLOCK_IO_H_ +#define _PEI_BLOCK_IO_H_ + +#define PEI_BLOCK_IO_PPI_GUID \ + { \ + 0x695d8aa1, 0x42ee, 0x4c46, 0x80, 0x5c, 0x6e, 0xa6, 0xbc, 0xe7, 0x99, 0xe3 \ + } + +EFI_FORWARD_DECLARATION (PEI_RECOVERY_BLOCK_IO_INTERFACE); + +typedef UINT64 PEI_LBA; + +typedef enum { + LegacyFloppy = 0, + IdeCDROM = 1, + IdeLS120 = 2, + UsbMassStorage= 3, + MaxDeviceType +} PEI_BLOCK_DEVICE_TYPE; + +typedef struct { + PEI_BLOCK_DEVICE_TYPE DeviceType; + BOOLEAN MediaPresent; + UINTN LastBlock; + UINTN BlockSize; +} PEI_BLOCK_IO_MEDIA; + +typedef +EFI_STATUS +(EFIAPI *PEI_GET_NUMBER_BLOCK_DEVICES) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_RECOVERY_BLOCK_IO_INTERFACE * This, + OUT UINTN *NumberBlockDevices + ); + +typedef +EFI_STATUS +(EFIAPI *PEI_GET_DEVICE_MEDIA_INFORMATION) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_RECOVERY_BLOCK_IO_INTERFACE * This, + IN UINTN DeviceIndex, + OUT PEI_BLOCK_IO_MEDIA * MediaInfo + ); + +typedef +EFI_STATUS +(EFIAPI *PEI_READ_BLOCKS) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_RECOVERY_BLOCK_IO_INTERFACE * This, + IN UINTN DeviceIndex, + IN PEI_LBA StartLBA, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +typedef struct _PEI_RECOVERY_BLOCK_IO_INTERFACE { + PEI_GET_NUMBER_BLOCK_DEVICES GetNumberOfBlockDevices; + PEI_GET_DEVICE_MEDIA_INFORMATION GetBlockDeviceMediaInfo; + PEI_READ_BLOCKS ReadBlocks; +} PEI_RECOVERY_BLOCK_IO_INTERFACE; + +extern EFI_GUID gPeiBlockIoPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c new file mode 100644 index 0000000000..fad0db74b5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootInRecoveryMode.c + +Abstract: + + Boot Mode PPI GUID as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (BootInRecoveryMode) + +EFI_GUID gPeiBootInRecoveryModePpiGuid = PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI; + +EFI_GUID_STRING(&gPeiMasterBootModePpiGuid, "BootMode", "Master Boot Mode PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h new file mode 100644 index 0000000000..d601cb53b1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootInRecoveryMode.h + +Abstract: + + Boot Mode PPI as defined in Tiano + +--*/ + +#ifndef _PEI_BOOT_IN_RECOVERY_MODE_PPI_H +#define _PEI_BOOT_IN_RECOVERY_MODE_PPI_H + +#define PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI \ + { \ + 0x17ee496a, 0xd8e4, 0x4b9a, 0x94, 0xd1, 0xce, 0x82, 0x72, 0x30, 0x8, 0x50 \ + } + +EFI_FORWARD_DECLARATION (PEI_BOOT_IN_RECOVERY_MODE_PPI); + +extern EFI_GUID gPeiBootInRecoveryModePpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.c new file mode 100644 index 0000000000..8fa434508b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootMode.c + +Abstract: + + Boot Mode PPI GUID as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (BootMode) + +EFI_GUID gPeiMasterBootModePpiGuid = PEI_MASTER_BOOT_MODE_PEIM_PPI; + +EFI_GUID_STRING(&gPeiMasterBootModePpiGuid, "BootMode", "Master Boot Mode PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.h new file mode 100644 index 0000000000..e0cf8dec18 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootMode/BootMode.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootMode.h + +Abstract: + + Boot Mode PPI as defined in Tiano + +--*/ + +#ifndef _PEI_MASTER_BOOT_MODE_PPI_H +#define _PEI_MASTER_BOOT_MODE_PPI_H + +#define PEI_MASTER_BOOT_MODE_PEIM_PPI \ + { \ + 0x7408d748, 0xfc8c, 0x4ee6, 0x92, 0x88, 0xc4, 0xbe, 0xc0, 0x92, 0xa4, 0x10 \ + } + +EFI_FORWARD_DECLARATION (PEI_MASTER_BOOT_MODE_PPI); + +extern EFI_GUID gPeiMasterBootModePpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c new file mode 100644 index 0000000000..690330a84a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2001 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootScriptExecuter.c + +Abstract: + + Boot Script Executer PPI GUID as defined in EFI 2.0 + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (BootScriptExecuter) + +EFI_GUID gPeiBootScriptExecuterPpiGuid = PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID; + +EFI_GUID_STRING(&gPeiBootScriptExecuterPpiGuid, "BootScriptExecuter", "Boot Script Executer PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h new file mode 100644 index 0000000000..3dd29ce8f5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2001 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootScriptExecuter.h + +Abstract: + + Boot Script Executer PPI as defined in EFI 2.0 + +--*/ + +#ifndef _PEI_BOOT_SCRIPT_EXECUTER_PPI_H +#define _PEI_BOOT_SCRIPT_EXECUTER_PPI_H + +#define PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID \ + { \ + 0xabd42895, 0x78cf, 0x4872, 0x84, 0x44, 0x1b, 0x5c, 0x18, 0x0b, 0xfb, 0xff \ + } + +EFI_FORWARD_DECLARATION (PEI_BOOT_SCRIPT_EXECUTER_PPI); + +#define PEI_BOOT_SCRIPT_EXECUTER_PPI_REVISION 0x00000001 + +typedef +EFI_STATUS +(EFIAPI *PEI_BOOT_SCRIPT_EXECUTE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_BOOT_SCRIPT_EXECUTER_PPI * This, + IN EFI_PHYSICAL_ADDRESS Address, + IN EFI_GUID * FvFile OPTIONAL + ); + +typedef struct _PEI_BOOT_SCRIPT_EXECUTER_PPI { + UINT64 Revision; + PEI_BOOT_SCRIPT_EXECUTE Execute; +} PEI_BOOT_SCRIPT_EXECUTER_PPI; + +extern EFI_GUID gPeiBootScriptExecuterPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.c new file mode 100644 index 0000000000..339cacc246 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuIO.c + +Abstract: + + CPU IO PPI GUID as defined in Tiano + + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (CpuIo) + +EFI_GUID gPeiCpuIoPpiInServiceTableGuid = PEI_CPU_IO_PPI_GUID; + +EFI_GUID_STRING(&gPeiCpuIoPpiInServiceTableGuid, "CPU IO", "CPU IO PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.h new file mode 100644 index 0000000000..3d5aba7589 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/CpuIo/CpuIo.h @@ -0,0 +1,250 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuIo.h + +Abstract: + + CPU IO PPI defined in Tiano + CPU IO PPI abstracts CPU IO access + + +--*/ + +#ifndef _PEI_CPUIO_PPI_H_ +#define _PEI_CPUIO_PPI_H_ + +#define PEI_CPU_IO_PPI_GUID \ + { \ + 0xe6af1f7b, 0xfc3f, 0x46da, 0xa8, 0x28, 0xa3, 0xb4, 0x57, 0xa4, 0x42, 0x82 \ + } + +EFI_FORWARD_DECLARATION (PEI_CPU_IO_PPI); + +// +// ******************************************************* +// PEI_CPU_IO_PPI_WIDTH +// ******************************************************* +// +typedef enum { + PeiCpuIoWidthUint8, + PeiCpuIoWidthUint16, + PeiCpuIoWidthUint32, + PeiCpuIoWidthUint64, + PeiCpuIoWidthFifoUint8, + PeiCpuIoWidthFifoUint16, + PeiCpuIoWidthFifoUint32, + PeiCpuIoWidthFifoUint64, + PeiCpuIoWidthFillUint8, + PeiCpuIoWidthFillUint16, + PeiCpuIoWidthFillUint32, + PeiCpuIoWidthFillUint64, + PeiCpuIoWidthMaximum +} PEI_CPU_IO_PPI_WIDTH; + +// +// ******************************************************* +// PEI_CPU_IO_PPI_IO_MEM +// ******************************************************* +// +typedef +EFI_STATUS +(EFIAPI *PEI_CPU_IO_PPI_IO_MEM) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN PEI_CPU_IO_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +// +// ******************************************************* +// PEI_CPU_IO_PPI_ACCESS +// ******************************************************* +// +typedef struct { + PEI_CPU_IO_PPI_IO_MEM Read; + PEI_CPU_IO_PPI_IO_MEM Write; +} PEI_CPU_IO_PPI_ACCESS; + +// +// ******************************************************* +// Base IO Class Functions +// ******************************************************* +// +typedef +UINT8 +(EFIAPI *PEI_CPU_IO_PPI_IO_READ8) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +UINT16 +(EFIAPI *PEI_CPU_IO_PPI_IO_READ16) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +UINT32 +(EFIAPI *PEI_CPU_IO_PPI_IO_READ32) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +UINT64 +(EFIAPI *PEI_CPU_IO_PPI_IO_READ64) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE8) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT8 Data + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE16) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT16 Data + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE32) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT32 Data + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE64) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT64 Data + ); + +typedef +UINT8 +(EFIAPI *PEI_CPU_IO_PPI_MEM_READ8) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +UINT16 +(EFIAPI *PEI_CPU_IO_PPI_MEM_READ16) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +UINT32 +(EFIAPI *PEI_CPU_IO_PPI_MEM_READ32) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +UINT64 +(EFIAPI *PEI_CPU_IO_PPI_MEM_READ64) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE8) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT8 Data + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE16) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT16 Data + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE32) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT32 Data + ); + +typedef +VOID +(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE64) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CPU_IO_PPI * This, + IN UINT64 Address, + IN UINT64 Data + ); + +// +// ******************************************************* +// PEI_CPU_IO_PPI +// ******************************************************* +// +typedef struct _PEI_CPU_IO_PPI { + PEI_CPU_IO_PPI_ACCESS Mem; + PEI_CPU_IO_PPI_ACCESS Io; + PEI_CPU_IO_PPI_IO_READ8 IoRead8; + PEI_CPU_IO_PPI_IO_READ16 IoRead16; + PEI_CPU_IO_PPI_IO_READ32 IoRead32; + PEI_CPU_IO_PPI_IO_READ64 IoRead64; + PEI_CPU_IO_PPI_IO_WRITE8 IoWrite8; + PEI_CPU_IO_PPI_IO_WRITE16 IoWrite16; + PEI_CPU_IO_PPI_IO_WRITE32 IoWrite32; + PEI_CPU_IO_PPI_IO_WRITE64 IoWrite64; + PEI_CPU_IO_PPI_MEM_READ8 MemRead8; + PEI_CPU_IO_PPI_MEM_READ16 MemRead16; + PEI_CPU_IO_PPI_MEM_READ32 MemRead32; + PEI_CPU_IO_PPI_MEM_READ64 MemRead64; + PEI_CPU_IO_PPI_MEM_WRITE8 MemWrite8; + PEI_CPU_IO_PPI_MEM_WRITE16 MemWrite16; + PEI_CPU_IO_PPI_MEM_WRITE32 MemWrite32; + PEI_CPU_IO_PPI_MEM_WRITE64 MemWrite64; +} PEI_CPU_IO_PPI; + +extern EFI_GUID gPeiCpuIoPpiInServiceTableGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.c new file mode 100644 index 0000000000..0dddc6768e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Decompress.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (Decompress) + + +EFI_GUID gEfiPeiDecompressPpiGuid = EFI_PEI_DECOMPRESS_PPI_GUID; +EFI_GUID_STRING(&gEfiPeiDecompressPpiGuid, "PeiDecompress", "PeiDecompress PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.h new file mode 100644 index 0000000000..4a017428af --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Decompress/Decompress.h @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Decompress.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#ifndef __DECOMPRESS_PPI_H__ +#define __DECOMPRESS_PPI_H__ + + +#define EFI_PEI_DECOMPRESS_PPI_GUID \ + { 0x1a36e4e7, 0xfab6, 0x476a, 0x8e, 0x75, 0x69, 0x5a, 0x5, 0x76, 0xfd, 0xd7} + +EFI_FORWARD_DECLARATION (EFI_PEI_DECOMPRESS_PPI); + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_DECOMPRESS_DECOMPRESS)( + IN CONST EFI_PEI_DECOMPRESS_PPI *This, + IN CONST EFI_COMPRESSION_SECTION *InputSection, + OUT VOID **OutputBuffer, + OUT UINTN *OutputSize + ); + +typedef struct _EFI_PEI_DECOMPRESS_PPI { + EFI_PEI_DECOMPRESS_DECOMPRESS Decompress; +} EFI_PEI_DECOMPRESS_PPI; + + + +extern EFI_GUID gEfiPeiDecompressPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c new file mode 100644 index 0000000000..b48b2a4021 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DeviceRecoveryModule.c + +Abstract: + + Device Recovery Module PPI GUID as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (DeviceRecoveryModule) + +EFI_GUID gPeiDeviceRecoveryModulePpiGuid = PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI; + +EFI_GUID_STRING(&gPeiDeviceRecoveryModulePpiGuid, "DeviceRecoveryModule", "Device Recovery Module PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h new file mode 100644 index 0000000000..fd7b4cb4bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h @@ -0,0 +1,68 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DeviceRecoveryModule.h + +Abstract: + + Device Recovery Module PPI as defined in EFI 2.0 + +--*/ + +#ifndef _PEI_DEVICE_RECOVERY_MODULE_PPI_H +#define _PEI_DEVICE_RECOVERY_MODULE_PPI_H + +#define PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI \ + { \ + 0x0DE2CE25, 0x446A, 0x45a7, 0xBF, 0xC9, 0x37, 0xDA, 0x26, 0x34, 0x4B, 0x37 \ + } + +EFI_FORWARD_DECLARATION (PEI_DEVICE_RECOVERY_MODULE_INTERFACE); + +typedef +EFI_STATUS +(EFIAPI *PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE * This, + OUT UINTN *NumberRecoveryCapsules + ); + +typedef +EFI_STATUS +(EFIAPI *PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE * This, + IN UINTN CapsuleInstance, + OUT UINTN *Size, + OUT EFI_GUID * CapsuleType + ); + +typedef +EFI_STATUS +(EFIAPI *PEI_DEVICE_LOAD_RECOVERY_CAPSULE) ( + IN OUT EFI_PEI_SERVICES **PeiServices, + IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE * This, + IN UINTN CapsuleInstance, + OUT VOID *Buffer + ); + +typedef struct _PEI_DEVICE_RECOVERY_MODULE_INTERFACE { + PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE GetNumberRecoveryCapsules; + PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO GetRecoveryCapsuleInfo; + PEI_DEVICE_LOAD_RECOVERY_CAPSULE LoadRecoveryCapsule; +} PEI_DEVICE_RECOVERY_MODULE_INTERFACE; + +extern EFI_GUID gPeiDeviceRecoveryModulePpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c new file mode 100644 index 0000000000..a640309ba7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DxeIpl.c + +Abstract: + + DXE Initial Program Load PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (DxeIpl) + +EFI_GUID gEfiDxeIplPpiGuid = EFI_DXE_IPL_PPI_GUID; + +EFI_GUID_STRING(&gEfiDxeIplPpiGuid, "DxeIpl", "DXE IPL PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h new file mode 100644 index 0000000000..d3cd1b121c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DxeIpl.h + +Abstract: + + DXE Initial Program Load PPI as defined in Tiano + + When the PEI core is done it calls the DXE IPL via this PPI. + +--*/ + +#ifndef _DXE_IPL_H_ +#define _DXE_IPL_H_ + +#include "Tiano.h" +#include "PeiHob.h" + +#define EFI_DXE_IPL_PPI_GUID \ + { \ + 0xae8ce5d, 0xe448, 0x4437, 0xa8, 0xd7, 0xeb, 0xf5, 0xf1, 0x94, 0xf7, 0x31 \ + } + +EFI_FORWARD_DECLARATION (EFI_DXE_IPL_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_DXE_IPL_ENTRY) ( + IN EFI_DXE_IPL_PPI * This, + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_HOB_POINTERS HobList + ); + +typedef struct _EFI_DXE_IPL_PPI { + EFI_DXE_IPL_ENTRY Entry; +} EFI_DXE_IPL_PPI; + +extern EFI_GUID gEfiDxeIplPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf new file mode 100644 index 0000000000..f39c93ccc8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf @@ -0,0 +1,102 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkFrameworkPpiLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME= EdkFrameworkPpiLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[nmake.common] + +[sources.common] + BlockIo\BlockIo.h + BlockIo\BlockIo.c + BootInRecoveryMode\BootInRecoveryMode.h + BootInRecoveryMode\BootInRecoveryMode.c + BootMode\BootMode.h + BootMode\BootMode.c + BootScriptExecuter\BootScriptExecuter.h + BootScriptExecuter\BootScriptExecuter.c + CpuIo\CpuIo.h + CpuIo\CpuIo.c + DeviceRecoveryModule\DeviceRecoveryModule.h + DeviceRecoveryModule\DeviceRecoveryModule.c + DxeIpl\DxeIpl.h + DxeIpl\DxeIpl.c + EndOfPeiSignal\EndOfPeiSignal.h + EndOfPeiSignal\EndOfPeiSignal.c + FindFv\FindFv.h + FindFv\FindFv.c + LoadFile\LoadFile.h + LoadFile\LoadFile.c + MemoryDiscovered\MemoryDiscovered.h + MemoryDiscovered\MemoryDiscovered.c + PciCfg\PciCfg.h + PciCfg\PciCfg.c + PciCfg2\PciCfg2.h + PciCfg2\PciCfg2.c + RecoveryModule\RecoveryModule.h + RecoveryModule\RecoveryModule.c + Reset\Reset.h + Reset\Reset.c + S3Resume\S3Resume.h + S3Resume\S3Resume.c + SecPlatformInformation\SecPlatformInformation.h + SecPlatformInformation\SecPlatformInformation.c + SectionExtraction\SectionExtraction.h + SectionExtraction\SectionExtraction.c + Security\Security.h + Security\Security.c + Smbus\Smbus.h + Smbus\Smbus.c + Smbus2\Smbus2.h + Smbus2\Smbus2.c + Stall\Stall.h + Stall\Stall.c + StatusCode\StatusCode.h + StatusCode\StatusCode.c + Variable\Variable.h + Variable\Variable.c + Variable2\Variable2.h + Variable2\Variable2.c + Decompress\Decompress.h + Decompress\Decompress.c + FirmwareVolumeInfo\FirmwareVolumeInfo.h + FirmwareVolumeInfo\FirmwareVolumeInfo.c + LoadFile2\LoadFile2.h + LoadFile2\LoadFile2.c + Security2\Security2.h + Security2\Security2.c + FirmwareVolume\FirmwareVolume.h + FirmwareVolume\FirmwareVolume.c + GuidedSectionExtraction\GuidedSectionExtraction.h + GuidedSectionExtraction\GuidedSectionExtraction.c diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c new file mode 100644 index 0000000000..b4a222322b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EndOfPeiSignal.c + +Abstract: + + This is installed prior to DXE taking over the memory map + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (EndOfPeiSignal) + +EFI_GUID gEndOfPeiSignalPpiGuid = PEI_END_OF_PEI_PHASE_PPI_GUID; + +EFI_GUID_STRING(&gEndOfPeiSignalPpiGuid, "EndOfPeiSignal", "End of PEI Phase Signalled PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h new file mode 100644 index 0000000000..250d052f56 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EndOfPeiSignal.h + +Abstract: + + PPI to be used to signal when the PEI ownership of the memory map + officially ends and DXE will take over + +--*/ + +#ifndef _PEI_END_OF_PEI_SIGNAL_PPI_H +#define _PEI_END_OF_PEI_SIGNAL_PPI_H + +#define PEI_END_OF_PEI_PHASE_PPI_GUID \ + { \ + 0x605EA650, 0xC65C, 0x42e1, 0xBA, 0x80, 0x91, 0xA5, 0x2A, 0xB6, 0x18, 0xC6 \ + } + +EFI_FORWARD_DECLARATION (PEI_END_OF_PEI_SIGNAL_PPI); + +extern EFI_GUID gEndOfPeiSignalPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.c new file mode 100644 index 0000000000..48164c4e52 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FindFv.c + +Abstract: + + FindFv PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (FindFv) + +EFI_GUID gEfiFindFvPpiGuid = EFI_FIND_FV_PPI_GUID; + +EFI_GUID_STRING(&gEfiFindFvPpiGuid, "FindFv", "FindFv PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.h new file mode 100644 index 0000000000..72935f43a3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FindFv/FindFv.h @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FindFv.h + +Abstract: + + FindFv PPI as defined in Tiano + + Used to locate FVs that contain PEIMs in PEI + +--*/ + +#ifndef _FIND_FV_H_ +#define _FIND_FV_H_ + +#include "EfiFirmwareVolumeHeader.h" + +#define EFI_FIND_FV_PPI_GUID \ + { \ + 0x36164812, 0xa023, 0x44e5, 0xbd, 0x85, 0x5, 0xbf, 0x3c, 0x77, 0x0, 0xaa \ + } + +EFI_FORWARD_DECLARATION (EFI_FIND_FV_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_FIND_FV_FINDFV) ( + IN EFI_FIND_FV_PPI * This, + IN EFI_PEI_SERVICES **PeiServices, + UINT8 *FvNumber, + EFI_FIRMWARE_VOLUME_HEADER **FVAddress + ); + +typedef struct _EFI_FIND_FV_PPI { + EFI_FIND_FV_FINDFV FindFv; +} EFI_FIND_FV_PPI; + +extern EFI_GUID gEfiFindFvPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c new file mode 100644 index 0000000000..73ff00c80d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolume.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (FirmwareVolume) + +// +// There is no PPI Guid definition here, since the guid of +// this ppi is the same as the firmware volume format Guid. +// \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h new file mode 100644 index 0000000000..ff7584820a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h @@ -0,0 +1,112 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolume.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#ifndef __FIRMWARE_VOLUME_H__ +#define __FIRMWARE_VOLUME_H__ + +EFI_FORWARD_DECLARATION (EFI_PEI_FIRMWARE_VOLUME_PPI); + +typedef UINT32 EFI_FV_FILE_ATTRIBUTES; +typedef VOID * EFI_PEI_FILE_HANDLE; +typedef VOID * EFI_PEI_FV_HANDLE; + + +typedef struct { + EFI_GUID FileName; + EFI_FV_FILETYPE FileType; + EFI_FV_FILE_ATTRIBUTES FileAttributes; + VOID *Buffer; + UINT32 BufferSize; +} EFI_FV_FILE_INFO; + +typedef struct { + EFI_FVB_ATTRIBUTES FvAttributes; + EFI_GUID FvFormat; + EFI_GUID FvName; + VOID *FvStart; + UINT64 FvSize; +} EFI_FV_INFO; + + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FV_PROCESS_FV) ( + IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, + IN VOID *Buffer, + IN UINTN BufferSize, + OUT EFI_PEI_FV_HANDLE *FvHandle + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FV_FIND_FILE_TYPE) ( + IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, + IN EFI_FV_FILETYPE SearchType, + IN EFI_PEI_FV_HANDLE FvHandle, + IN OUT EFI_PEI_FILE_HANDLE *FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FV_FIND_FILE_NAME) ( + IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, + IN CONST EFI_GUID *FileName, + IN EFI_PEI_FV_HANDLE FvHandle, + OUT EFI_PEI_FILE_HANDLE *FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FV_GET_FILE_INFO) ( + IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT EFI_FV_FILE_INFO *FileInfo + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FV_GET_INFO)( + IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, + IN EFI_PEI_FV_HANDLE FvHandle, + OUT EFI_FV_INFO *VolumeInfo + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FV_FIND_SECTION) ( + IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, + IN EFI_SECTION_TYPE SearchType, + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT VOID **SectionData + ); + +typedef struct _EFI_PEI_FIRMWARE_VOLUME_PPI { + EFI_PEI_FV_PROCESS_FV ProcessVolume; + EFI_PEI_FV_FIND_FILE_TYPE FindFileByType; + EFI_PEI_FV_FIND_FILE_NAME FindFileByName; + EFI_PEI_FV_GET_FILE_INFO GetFileInfo; + EFI_PEI_FV_GET_INFO GetVolumeInfo; + EFI_PEI_FV_FIND_SECTION FindSectionByType; +} EFI_PEI_FIRMWARE_VOLUME_PPI; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c new file mode 100644 index 0000000000..ae584809fb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolumeInfo.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (FirmwareVolumeInfo) + +EFI_GUID gEfiFirmwareVolumeInfoPpiGuid = EFI_PEI_FIRMWARE_VOLUME_INFO_PPI_GUID; +EFI_GUID_STRING(&gEfiFirmwareVolumeInfoPpiGuid, "FirmwareVolumeInfo", "FirmwareVolumeInfo PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h new file mode 100644 index 0000000000..f659be7f2e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolumeInfo.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#ifndef __FIRMWARE_VOLUME_INFO_PPI__ +#define __FIRMWARE_VOLUME_INFO_PPI__ + +EFI_FORWARD_DECLARATION (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI); + + +// +// The PPI GUID must match the EFI_GUID FvFormat value +// +#define EFI_PEI_FIRMWARE_VOLUME_INFO_PPI_GUID \ + { 0x49edb1c1, 0xbf21, 0x4761, { 0xbb, 0x12, 0xeb, 0x0, 0x31, 0xaa, 0xbb, 0x39 } } + + +typedef struct _EFI_PEI_FIRMWARE_VOLUME_INFO_PPI { + EFI_GUID FvFormat; + VOID *FvInfo; + UINT32 FvInfoSize; + EFI_GUID *ParentFvName; + EFI_GUID *ParentFileName; +} EFI_PEI_FIRMWARE_VOLUME_INFO_PPI; + + +extern EFI_GUID gEfiFirmwareVolumeInfoPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c new file mode 100644 index 0000000000..5cfb65880d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidedSectionExtraction.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (GuidedSectionExtraction) + +// +// There is no PPI Guid definition here since this PPI is for +// extract EFI_SECTION_GUID_DEFINED type section. +// \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h new file mode 100644 index 0000000000..8ad5e6ae12 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidedSectionExtraction.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + + +#ifndef __GUIDED_SECTION_EXTRACTION_PPI_H__ +#define __GUIDED_SECTION_EXTRACTION_PPI_H__ + +EFI_FORWARD_DECLARATION (EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_EXTRACT_GUIDED_SECTION)( + IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This, + IN CONST VOID *InputSection, + OUT VOID **OutputBuffer, + OUT UINTN *OutputSize, + OUT UINT32 *AuthenticationStatus + ); + +typedef struct _EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI { + EFI_PEI_EXTRACT_GUIDED_SECTION ExtractSection; +} EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.c new file mode 100644 index 0000000000..03f9d271f0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadFile.c + +Abstract: + + Load File PPI GUID. + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (LoadFile) + +EFI_GUID gPeiFvFileLoaderPpiGuid = EFI_PEI_FV_FILE_LOADER_GUID; + +EFI_GUID_STRING(&gPeiFvFileLoaderPpiGuid, "FvFileLoader", "Fv File Loader Support PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.h new file mode 100644 index 0000000000..d6cf68af5d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile/LoadFile.h @@ -0,0 +1,48 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadFile.h + +Abstract: + + Load image file from fv to memory. + +--*/ + +#ifndef _PEI_FV_FILE_LOADER_PPI_H +#define _PEI_FV_FILE_LOADER_PPI_H + +#define EFI_PEI_FV_FILE_LOADER_GUID \ + { \ + 0x7e1f0d85, 0x4ff, 0x4bb2, 0x86, 0x6a, 0x31, 0xa2, 0x99, 0x6a, 0x48, 0xa8 \ + } + +EFI_FORWARD_DECLARATION (EFI_PEI_FV_FILE_LOADER_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FV_LOAD_FILE) ( + IN EFI_PEI_FV_FILE_LOADER_PPI * This, + IN EFI_FFS_FILE_HEADER * FfsHeader, + OUT EFI_PHYSICAL_ADDRESS * ImageAddress, + OUT UINT64 *ImageSize, + OUT EFI_PHYSICAL_ADDRESS * EntryPoint + ); + +typedef struct _EFI_PEI_FV_FILE_LOADER_PPI { + EFI_PEI_FV_LOAD_FILE FvLoadFile; +} EFI_PEI_FV_FILE_LOADER_PPI; + +extern EFI_GUID gPeiFvFileLoaderPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c new file mode 100644 index 0000000000..f10821e082 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadFile2.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (LoadFile2) + + +EFI_GUID gEfiLoadFile2PpiGuid = EFI_PEI_LOAD_FILE_GUID; +EFI_GUID_STRING(&gEfiLoadFile2PpiGuid, "PeiLoadFile2", "PeiLoadFile2 PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h new file mode 100644 index 0000000000..c43e1fd0da --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadFile2.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#ifndef __LOAD_FILE_PPI_H__ +#define __LOAD_FILE_PPI_H__ + +EFI_FORWARD_DECLARATION (EFI_PEI_LOAD_FILE_PPI); + +#define EFI_PEI_LOAD_FILE_GUID \ + { 0xb9e0abfe, 0x5979, 0x4914, 0x97, 0x7f, 0x6d, 0xee, 0x78, 0xc2, 0x78, 0xa6} + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_LOAD_FILE) ( + IN CONST EFI_PEI_LOAD_FILE_PPI *This, + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT EFI_PHYSICAL_ADDRESS *ImageAddress, + OUT UINT64 *ImageSize, + OUT EFI_PHYSICAL_ADDRESS *EntryPoint, + OUT UINT32 *AuthenticationState + ); + + +typedef struct _EFI_PEI_LOAD_FILE_PPI { + EFI_PEI_LOAD_FILE LoadFile; +} EFI_PEI_LOAD_FILE_PPI; + + +extern EFI_GUID gEfiLoadFile2PpiGuid; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c new file mode 100644 index 0000000000..52aaf3d464 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemoryDiscovered.c + +Abstract: + + Memory Discovered PPI GUID as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (MemoryDiscovered) + +EFI_GUID gPeiMemoryDiscoveredPpiGuid = PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID; + +EFI_GUID_STRING(&gPeiMemoryDiscoveredPpiGuid, "MemoryDiscovered", "Memory Discovered PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h new file mode 100644 index 0000000000..9fc5c3a92a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemoryDiscovered.h + +Abstract: + + Memory Discovered PPI as defined in Tiano + +--*/ + +#ifndef _PEI_MEMORY_DISCOVERED_PPI_H +#define _PEI_MEMORY_DISCOVERED_PPI_H + +#define PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID \ + { \ + 0xf894643d, 0xc449, 0x42d1, 0x8e, 0xa8, 0x85, 0xbd, 0xd8, 0xc6, 0x5b, 0xde \ + } + +EFI_FORWARD_DECLARATION (PEI_PERMANENT_MEMORY_INSTALLED_PPI); + +extern EFI_GUID gPeiMemoryDiscoveredPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.c new file mode 100644 index 0000000000..1175c605ea --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciCfg.c + +Abstract: + + PciCfg PPI GUID as defined in PEI CIS specification. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (PciCfg) + +EFI_GUID gPeiPciCfgPpiInServiceTableGuid = PEI_PCI_CFG_PPI_GUID; + +EFI_GUID_STRING(&gPeiPciCfgPpiInServiceTableGuid, "PciCfg", "PciCfg PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.h new file mode 100644 index 0000000000..520f0e686b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg/PciCfg.h @@ -0,0 +1,65 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciCfg.h + +Abstract: + + PciCfg PPI as defined in PEI CIS specification + + Used to access PCI configuration space in PEI + +--*/ + +#ifndef _PEI_PCI_CFG_H_ +#define _PEI_PCI_CFG_H_ +#include "EfiPciCfg.h" + +#define PEI_PCI_CFG_PPI_GUID \ + { \ + 0xe1f2eba0, 0xf7b9, 0x4a26, 0x86, 0x20, 0x13, 0x12, 0x21, 0x64, 0x2a, 0x90 \ + } + +EFI_FORWARD_DECLARATION (PEI_PCI_CFG_PPI); + + +typedef +EFI_STATUS +(EFIAPI *PEI_PCI_CFG_PPI_IO) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_PCI_CFG_PPI * This, + IN PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *PEI_PCI_CFG_PPI_RW) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_PCI_CFG_PPI * This, + IN PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN SetBits, + IN UINTN ClearBits + ); + +typedef struct _PEI_PCI_CFG_PPI { + PEI_PCI_CFG_PPI_IO Read; + PEI_PCI_CFG_PPI_IO Write; + PEI_PCI_CFG_PPI_RW Modify; +} PEI_PCI_CFG_PPI; + +extern EFI_GUID gPeiPciCfgPpiInServiceTableGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c new file mode 100644 index 0000000000..b508efe48e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciCfg2.c + +Abstract: + + PciCfg2 PPI GUID as defined in PI1.0 specification. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (PciCfg2) + +EFI_GUID gPeiPciCfg2PpiGuid = EFI_PEI_PCI_CFG2_PPI_GUID; + +EFI_GUID_STRING(&gPeiPciCfg2PpiGuid, "PciCfg2", "PciCfg2 PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h new file mode 100644 index 0000000000..766f165e66 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h @@ -0,0 +1,66 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciCfg2.h + +Abstract: + + PciCfg2 PPI as defined in PI1.0 specification + + Used to access PCI configuration space in PEI + +--*/ + +#ifndef _PEI_PCI_CFG2_H_ +#define _PEI_PCI_CFG2_H_ +#include "EfiPciCfg.h" + +#define EFI_PEI_PCI_CFG2_PPI_GUID \ + { \ + 0x57a449a, 0x1fdc, 0x4c06, 0xbf, 0xc9, 0xf5, 0x3f, 0x6a, 0x99, 0xbb, 0x92 \ + } + +EFI_FORWARD_DECLARATION (EFI_PEI_PCI_CFG2_PPI); + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_PCI_CFG_PPI_IO) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_PCI_CFG2_PPI *This, + IN EFI_PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_PCI_CFG_PPI_RW) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_PCI_CFG2_PPI *This, + IN EFI_PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN VOID *SetBits, + IN VOID *ClearBits + ); + +typedef struct _EFI_PEI_PCI_CFG2_PPI { + EFI_PEI_PCI_CFG_PPI_IO Read; + EFI_PEI_PCI_CFG_PPI_IO Write; + EFI_PEI_PCI_CFG_PPI_RW Modify; + UINT16 Segment; +} EFI_PEI_PCI_CFG2_PPI; + +extern EFI_GUID gPeiPciCfg2PpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c new file mode 100644 index 0000000000..c1a7a52285 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RecoveryModule.c + +Abstract: + + Recovery Module PPI GUID as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (RecoveryModule) + +EFI_GUID gPeiRecoveryModulePpiGuid = PEI_RECOVERY_MODULE_INTERFACE_PPI; + +EFI_GUID_STRING(&gPeiRecoveryModulePpiGuid, "RecoveryModule", "Recovery Module PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h new file mode 100644 index 0000000000..3a485e0947 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h @@ -0,0 +1,45 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RecoveryModule.h + +Abstract: + + Recovery Module PPI as defined in Tiano + +--*/ + +#ifndef _PEI_RECOVERY_MODULE_PPI_H +#define _PEI_RECOVERY_MODULE_PPI_H + +#define PEI_RECOVERY_MODULE_INTERFACE_PPI \ + { \ + 0xFB6D9542, 0x612D, 0x4f45, 0x87, 0x2F, 0x5C, 0xFF, 0x52, 0xE9, 0x3D, 0xCF \ + } + +EFI_FORWARD_DECLARATION (PEI_RECOVERY_MODULE_INTERFACE); + +typedef +EFI_STATUS +(EFIAPI *PEI_LOAD_RECOVERY_CAPSULE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_RECOVERY_MODULE_INTERFACE * This + ); + +typedef struct _PEI_RECOVERY_MODULE_INTERFACE { + PEI_LOAD_RECOVERY_CAPSULE LoadRecoveryCapsule; +} PEI_RECOVERY_MODULE_INTERFACE; + +extern EFI_GUID gPeiRecoveryModulePpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.c new file mode 100644 index 0000000000..37a434d629 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Reset.c + +Abstract: + + Reset Service PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (Reset) + +EFI_GUID gPeiResetPpiGuid = PEI_RESET_PPI_GUID; + +EFI_GUID_STRING(&gPeiResetPpiGuid, "Reset", "Reset PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.h new file mode 100644 index 0000000000..f93fd37f01 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Reset/Reset.h @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Reset.h + +Abstract: + + Reset PPI as defined in Tiano + + Used to reset the platform from PEI + +--*/ + +#ifndef _PEI_RESET_H_ +#define _PEI_RESET_H_ + +#define PEI_RESET_PPI_GUID \ + { \ + 0xef398d58, 0x9dfd, 0x4103, 0xbf, 0x94, 0x78, 0xc6, 0xf4, 0xfe, 0x71, 0x2f \ + } + +// +// ******************************************************* +// PEI_RESET_TYPE +// ******************************************************* +// +typedef enum { + PeiResetCold, + PeiResetWarm, +} PEI_RESET_TYPE; + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_RESET_SYSTEM) ( + IN EFI_PEI_SERVICES **PeiServices + ); + +typedef struct { + EFI_PEI_RESET_SYSTEM ResetSystem; +} PEI_RESET_PPI; + +extern EFI_GUID gPeiResetPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.c new file mode 100644 index 0000000000..3561bf1cfd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.c @@ -0,0 +1,29 @@ +/*++ + + Copyright (c) 2004, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + S3Resume.c + +Abstract: + + Boot Script Executer PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (S3Resume) + +EFI_GUID gPeiS3ResumePpiGuid = PEI_S3_RESUME_PPI_GUID; + +EFI_GUID_STRING(&gPeiS3ResumePpiGuid, "S3Resume", "S3 Resume PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.h new file mode 100644 index 0000000000..66f2c8a004 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/S3Resume/S3Resume.h @@ -0,0 +1,44 @@ +/*++ + + Copyright (c) 2004, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + S3Resume.h + +Abstract: + + S3 Resume PPI + +--*/ + +#ifndef _PEI_S3_RESUME_PPI_H +#define _PEI_S3_RESUME_PPI_H + +#define PEI_S3_RESUME_PPI_GUID \ + { \ + 0x4426CCB2, 0xE684, 0x4a8a, 0xAE, 0x40, 0x20, 0xD4, 0xB0, 0x25, 0xB7, 0x10 \ + } + +EFI_FORWARD_DECLARATION (PEI_S3_RESUME_PPI); + +typedef +EFI_STATUS +(EFIAPI *PEI_S3_RESUME_PPI_RESTORE_CONFIG) ( + IN EFI_PEI_SERVICES **PeiServices + ); + +typedef struct _PEI_S3_RESUME_PPI { + PEI_S3_RESUME_PPI_RESTORE_CONFIG S3RestoreConfig; +} PEI_S3_RESUME_PPI; + +extern EFI_GUID gPeiS3ResumePpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c new file mode 100644 index 0000000000..f8e6977b83 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SecPlatformInformation.c + +Abstract: + + Sec Platform Information as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (SecPlatformInformation) + +EFI_GUID gEfiSecPlatformInformationPpiGuid = EFI_SEC_PLATFORM_INFORMATION_GUID; + +EFI_GUID_STRING(&gEfiSecPlatformInformationPpiGuid, "SecPlatformInformation", "Sec Platform Information"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h new file mode 100644 index 0000000000..320396751b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h @@ -0,0 +1,71 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SecPlatformInformation.h + +Abstract: + + Sec Platform Information PPI as defined in Tiano + +--*/ + +#ifndef _PEI_SEC_PLATFORM_INFORMATION_PPI_H +#define _PEI_SEC_PLATFORM_INFORMATION_PPI_H + +#define EFI_SEC_PLATFORM_INFORMATION_GUID \ + { \ + 0x6f8c2b35, 0xfef4, 0x448d, 0x82, 0x56, 0xe1, 0x1b, 0x19, 0xd6, 0x10, 0x77 \ + } + +EFI_FORWARD_DECLARATION (EFI_SEC_PLATFORM_INFORMATION_PPI); + +extern EFI_GUID gEfiSecPlatformInformationPpiGuid; + +typedef union { + struct { + UINT32 Status : 2; + UINT32 Tested : 1; + UINT32 Reserved1 :13; + UINT32 VirtualMemoryUnavailable : 1; + UINT32 Ia32ExecutionUnavailable : 1; + UINT32 FloatingPointUnavailable : 1; + UINT32 MiscFeaturesUnavailable : 1; + UINT32 Reserved2 :12; + } Bits; + UINT32 Uint32; +} EFI_HEALTH_FLAGS; + +typedef struct { + EFI_HEALTH_FLAGS HealthFlags; +} SEC_PLATFORM_INFORMATION_RECORD; + +typedef struct { + UINTN BootPhase; // entry r20 value + UINTN UniqueId; // PAL arbitration ID + UINTN HealthStat; // Health Status + UINTN PALRetAddress; // return address to PAL +} IPF_HANDOFF_STATUS; + +typedef +EFI_STATUS +(EFIAPI *SEC_PLATFORM_INFORMATION) ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + IN OUT SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord + ); + +typedef struct _EFI_SEC_PLATFORM_INFORMATION_PPI { + SEC_PLATFORM_INFORMATION PlatformInformation; +} EFI_SEC_PLATFORM_INFORMATION_PPI; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c new file mode 100644 index 0000000000..422a29d504 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SectionExtraction.c + +Abstract: + + Section Extraction Protocol PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (SectionExtraction) + +EFI_GUID gPeiSectionExtractionPpiGuid = EFI_PEI_SECTION_EXTRACTION_PPI_GUID; + +EFI_GUID_STRING(&gPeiSectionExtractionPpiGuid, "Section Extraction PPI", "Section Extraction PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h new file mode 100644 index 0000000000..47ae3d3c97 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h @@ -0,0 +1,59 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SectionExtraction.h + +Abstract: + + Section Extraction PPI as defined in Tiano + +--*/ + +#ifndef _SECTION_EXTRACTION_PPI_H_ +#define _SECTION_EXTRACTION_PPI_H_ + +#define EFI_PEI_SECTION_EXTRACTION_PPI_GUID \ + { \ + 0x4F89E208, 0xE144, 0x4804, 0x9E, 0xC8, 0x0F, 0x89, 0x4F, 0x7E, 0x36, 0xD7 \ + } + +EFI_FORWARD_DECLARATION (EFI_PEI_SECTION_EXTRACTION_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_GET_SECTION) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_SECTION_EXTRACTION_PPI * This, + IN EFI_SECTION_TYPE * SectionType, + IN EFI_GUID * SectionDefinitionGuid, OPTIONAL + IN UINTN SectionInstance, + IN VOID **Buffer, + IN OUT UINT32 *BufferSize, + OUT UINT32 *AuthenticationStatus + ); + +// +// Bit values for AuthenticationStatus +// +#define EFI_PEI_AUTH_STATUS_PLATFORM_OVERRIDE 0x01 +#define EFI_PEI_AUTH_STATUS_IMAGE_SIGNED 0x02 +#define EFI_PEI_AUTH_STATUS_NOT_TESTED 0x04 +#define EFI_PEI_AUTH_STATUS_TEST_FAILED 0x08 + +typedef struct _EFI_PEI_SECTION_EXTRACTION_PPI { + EFI_PEI_GET_SECTION PeiGetSection; +} EFI_PEI_SECTION_EXTRACTION_PPI; + +extern EFI_GUID gPeiSectionExtractionPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.c new file mode 100644 index 0000000000..35e5f6ba70 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Security.c + +Abstract: + + Security Architectural Protocol PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (Security) + +EFI_GUID gPeiSecurityPpiGuid = PEI_SECURITY_PPI_GUID; + +EFI_GUID_STRING(&gPeiSecurityPpiGuid, "Security PPI", "Security Arch PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.h new file mode 100644 index 0000000000..9a5aa15730 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security/Security.h @@ -0,0 +1,48 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Security.h + +Abstract: + + Security Architectural PPI as defined in Tiano + +--*/ + +#ifndef _SECURITY_PPI_H_ +#define _SECURITY_PPI_H_ + +#define PEI_SECURITY_PPI_GUID \ + { \ + 0x1388066e, 0x3a57, 0x4efa, 0x98, 0xf3, 0xc1, 0x2f, 0x3a, 0x95, 0x8a, 0x29 \ + } + +EFI_FORWARD_DECLARATION (PEI_SECURITY_PPI); + +typedef +EFI_STATUS +(EFIAPI *PEI_SECURITY_AUTHENTICATION_STATE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_SECURITY_PPI * This, + IN UINT32 AuthenticationStatus, + IN EFI_FFS_FILE_HEADER * FfsFileHeader, + IN OUT BOOLEAN *StartCrisisRecovery + ); + +typedef struct _PEI_SECURITY_PPI { + PEI_SECURITY_AUTHENTICATION_STATE AuthenticationState; +} PEI_SECURITY_PPI; + +extern EFI_GUID gPeiSecurityPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.c new file mode 100644 index 0000000000..d267b29542 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Security2.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (Security2) + +EFI_GUID gEfiPeiSecurity2PpiGuid = EFI_PEI_SECURITY2_PPI_GUID; + +EFI_GUID_STRING(&gEfiPeiSecurity2PpiGuid, "Security2 PPI", "Security2 Arch PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.h new file mode 100644 index 0000000000..59dad703f5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Security2/Security2.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Security2.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + + +#ifndef __SECURITY2_PPI_H__ +#define __SECURITY2_PPI_H__ + +#define EFI_PEI_SECURITY2_PPI_GUID \ + { 0xdcd0be23, 0x9586, 0x40f4, 0xb6, 0x43, 0x6, 0x52, 0x2c, 0xed, 0x4e, 0xde} + + +EFI_FORWARD_DECLARATION (EFI_PEI_SECURITY2_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SECURITY_AUTHENTICATION_STATE) ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_SECURITY2_PPI *This, + IN UINT32 AuthenticationStatus, + IN EFI_PEI_FV_HANDLE FvHandle, + IN EFI_PEI_FILE_HANDLE FileHandle, + IN OUT BOOLEAN *DeferExection + ); + +typedef struct _EFI_PEI_SECURITY2_PPI { + EFI_PEI_SECURITY_AUTHENTICATION_STATE AuthenticationState; +} EFI_PEI_SECURITY2_PPI; + + +extern EFI_GUID gEfiPeiSecurity2PpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.c new file mode 100644 index 0000000000..c63c1f3151 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Smbus.c + +Abstract: + + Smbus PPI GUID as defined in EFI 2.0 + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (Smbus) + +EFI_GUID gPeiSmbusPpiGuid = PEI_SMBUS_PPI_GUID; + +EFI_GUID_STRING(&gPeiSmbusPpiGuid, "Smbus", "Smbus PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.h new file mode 100644 index 0000000000..cdd1834fa6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus/Smbus.h @@ -0,0 +1,101 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Smbus.h + +Abstract: + + Smbus PPI as defined in EFI 2.0 + +--*/ + +#ifndef _PEI_SMBUS_PPI_H +#define _PEI_SMBUS_PPI_H + +#include "EfiSmbus.h" + +#define PEI_SMBUS_PPI_GUID \ + { \ + 0xabd42895, 0x78cf, 0x4872, 0x84, 0x44, 0x1b, 0x5c, 0x18, 0xb, 0xfb, 0xda \ + } + +EFI_FORWARD_DECLARATION (PEI_SMBUS_PPI); + +typedef +EFI_STATUS +(EFIAPI *PEI_SMBUS_PPI_EXECUTE_OPERATION) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_SMBUS_PPI * This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ); + + +typedef +EFI_STATUS +(EFIAPI *PEI_SMBUS_NOTIFY_FUNCTION) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_SMBUS_PPI * SmbusPpi, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data + ); + +// +// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional. +// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress +// +typedef +EFI_STATUS +(EFIAPI *PEI_SMBUS_PPI_ARP_DEVICE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_SMBUS_PPI * This, + IN BOOLEAN ArpAll, + IN EFI_SMBUS_UDID * SmbusUdid, OPTIONAL + IN OUT EFI_SMBUS_DEVICE_ADDRESS * SlaveAddress OPTIONAL + ); + + +typedef +EFI_STATUS +(EFIAPI *PEI_SMBUS_PPI_GET_ARP_MAP) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_SMBUS_PPI * This, + IN OUT UINTN *Length, + IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap + ); + +typedef +EFI_STATUS +(EFIAPI *PEI_SMBUS_PPI_NOTIFY) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_SMBUS_PPI * This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data, + IN PEI_SMBUS_NOTIFY_FUNCTION NotifyFunction + ); + +typedef struct _PEI_SMBUS_PPI { + PEI_SMBUS_PPI_EXECUTE_OPERATION Execute; + PEI_SMBUS_PPI_ARP_DEVICE ArpDevice; + PEI_SMBUS_PPI_GET_ARP_MAP GetArpMap; + PEI_SMBUS_PPI_NOTIFY Notify; +} PEI_SMBUS_PPI; + +extern EFI_GUID gPeiSmbusPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.c new file mode 100644 index 0000000000..f1207f259d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Smbus2.c + +Abstract: + + Smbus2 PPI GUID as defined in PI1.0 + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (Smbus2) + +EFI_GUID gPeiSmbus2PpiGuid = PEI_SMBUS2_PPI_GUID; + +EFI_GUID_STRING(&gPeiSmbus2PpiGuid, "Smbus2", "Smbus2 PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.h new file mode 100644 index 0000000000..e34d380dfe --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Smbus2/Smbus2.h @@ -0,0 +1,96 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Smbus2.h + +Abstract: + + Smbus2 PPI as defined in PI 1.0 + +--*/ + +#ifndef _PEI_SMBUS2_PPI_H +#define _PEI_SMBUS2_PPI_H + +#include "EfiSmbus.h" + +#define PEI_SMBUS2_PPI_GUID \ + { \ + 0x9ca93627, 0xb65b, 0x4324, 0xa2, 0x2, 0xc0, 0xb4, 0x61, 0x76, 0x45, 0x43 \ + } + +EFI_FORWARD_DECLARATION (EFI_PEI_SMBUS2_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION) ( + IN CONST EFI_PEI_SMBUS2_PPI * This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SMBUS_NOTIFY2_FUNCTION) ( + IN CONST EFI_PEI_SMBUS2_PPI * SmbusPpi, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data + ); + +// +// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional. +// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress +// +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SMBUS2_PPI_ARP_DEVICE) ( + IN CONST EFI_PEI_SMBUS2_PPI * This, + IN BOOLEAN ArpAll, + IN EFI_SMBUS_UDID * SmbusUdid, OPTIONAL + IN OUT EFI_SMBUS_DEVICE_ADDRESS * SlaveAddress OPTIONAL + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SMBUS2_PPI_GET_ARP_MAP) ( + IN CONST EFI_PEI_SMBUS2_PPI * This, + IN OUT UINTN *Length, + IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_SMBUS2_PPI_NOTIFY) ( + IN CONST EFI_PEI_SMBUS2_PPI * This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data, + IN EFI_PEI_SMBUS_NOTIFY2_FUNCTION NotifyFunction + ); + +typedef struct _EFI_PEI_SMBUS2_PPI { + EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION Execute; + EFI_PEI_SMBUS2_PPI_ARP_DEVICE ArpDevice; + EFI_PEI_SMBUS2_PPI_GET_ARP_MAP GetArpMap; + EFI_PEI_SMBUS2_PPI_NOTIFY Notify; + EFI_GUID Identifier; +} EFI_PEI_SMBUS2_PPI; + +extern EFI_GUID gPeiSmbus2PpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.c new file mode 100644 index 0000000000..1e11f74b22 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.c @@ -0,0 +1,28 @@ +/*++ + + Copyright (c) 1999 - 2002, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Stall.c + +Abstract: + + Stall PPI + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (Stall) + +EFI_GUID gPeiStallPpiGuid = PEI_STALL_PPI_GUID; + +EFI_GUID_STRING(&gPeiStallPpiGuid, "Stall", "Stall PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.h new file mode 100644 index 0000000000..f84a17ec11 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Stall/Stall.h @@ -0,0 +1,47 @@ +/*++ + + Copyright (c) 1999 - 2002, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Stall.h + +Abstract: + + Stall PPI + +--*/ + +#ifndef _PEI_STALL_PPI_H_ +#define _PEI_STALL_PPI_H_ + +#define PEI_STALL_PPI_GUID \ + { \ + 0x1f4c6f90, 0xb06b, 0x48d8, 0xa2, 0x01, 0xba, 0xe5, 0xf1, 0xcd, 0x7d, 0x56 \ + } + +EFI_FORWARD_DECLARATION (PEI_STALL_PPI); + +typedef +EFI_STATUS +(EFIAPI *PEI_STALL) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_STALL_PPI * This, + IN UINTN Microseconds + ); + +typedef struct _PEI_STALL_PPI { + UINTN Resolution; + PEI_STALL Stall; +} PEI_STALL_PPI; + +extern EFI_GUID gPeiStallPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.c new file mode 100644 index 0000000000..85d1131e77 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCode.c + +Abstract: + + Status Code PPI GUID as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (StatusCode) + +EFI_GUID gPeiStatusCodePpiGuid = PEI_STATUS_CODE_PPI_GUID; + +EFI_GUID_STRING(&gPeiProgressCodePpiGuid, "StatusCode", "Status Code PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.h new file mode 100644 index 0000000000..fd05b649b7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/StatusCode/StatusCode.h @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCode.h + +Abstract: + + Status Code PPI as defined in Tiano + +--*/ + +#ifndef _PEI_STATUS_CODE_PPI_H +#define _PEI_STATUS_CODE_PPI_H + +#define PEI_STATUS_CODE_PPI_GUID \ + { \ + 0x229832d3, 0x7a30, 0x4b36, 0xb8, 0x27, 0xf4, 0xc, 0xb7, 0xd4, 0x54, 0x36 \ + } + +EFI_FORWARD_DECLARATION (PEI_STATUS_CODE_PPI); + +typedef +EFI_STATUS +(EFIAPI *PEI_REPORT_STATUS_CODE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ); + +typedef struct _PEI_STATUS_CODE_PPI { + PEI_REPORT_STATUS_CODE ReportStatusCode; +} PEI_STATUS_CODE_PPI; + +extern EFI_GUID gPeiStatusCodePpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.c new file mode 100644 index 0000000000..bc0a2a27dc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Variable.c + +Abstract: + + Boot Mode PPI GUID as defined in PEI EAS + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (Variable) + +EFI_GUID gPeiReadOnlyVariablePpiGuid = PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID; + +EFI_GUID_STRING(&gPeiReadOnlyVariablePpiGuid, "Variable", "Read Only Variable PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.h new file mode 100644 index 0000000000..f07fe360db --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable/Variable.h @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Variable.h + +Abstract: + + Read-only Variable Service PPI as defined in Tiano + +--*/ + +#ifndef _PEI_READ_ONLY_VARIABLE_PPI_H +#define _PEI_READ_ONLY_VARIABLE_PPI_H + +#include "EfiVariable.h" + +#define PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID \ + { \ + 0x3cdc90c6, 0x13fb, 0x4a75, 0x9e, 0x79, 0x59, 0xe9, 0xdd, 0x78, 0xb9, 0xfa \ + } + + +typedef +EFI_STATUS +(EFIAPI *PEI_GET_VARIABLE) ( + IN EFI_PEI_SERVICES **PeiServices, + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ); + +typedef +EFI_STATUS +(EFIAPI *PEI_GET_NEXT_VARIABLE_NAME) ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID * VendorGuid + ); + +typedef struct PEI_READ_ONLY_VARIABLE_PPI { + PEI_GET_VARIABLE PeiGetVariable; + PEI_GET_NEXT_VARIABLE_NAME PeiGetNextVariableName; +} PEI_READ_ONLY_VARIABLE_PPI; + +EFI_FORWARD_DECLARATION (PEI_MASTER_BOOT_MODE_PPI); + +extern EFI_GUID gPeiReadOnlyVariablePpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.c new file mode 100644 index 0000000000..684f7c4d83 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Variable2.c + +Abstract: + + Read-only Variable2 Service PPI as defined in PI1.0 + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION (Variable2) + +EFI_GUID gPeiReadOnlyVariable2PpiGuid = EFI_PEI_READ_ONLY_VARIABLE2_PPI_GUID; + +EFI_GUID_STRING(&gPeiReadOnlyVariable2PpiGuid, "Variable2", "Read Only Variable2 PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.h new file mode 100644 index 0000000000..52e5980749 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/Variable2/Variable2.h @@ -0,0 +1,61 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Variable2.h + +Abstract: + + Read-only Variable2 Service PPI as defined in PI1.0 + +--*/ + +#ifndef _PEI_READ_ONLY_VARIABLE2_PPI_H +#define _PEI_READ_ONLY_VARIABLE2_PPI_H + +#include "EfiVariable.h" + +#define EFI_PEI_READ_ONLY_VARIABLE2_PPI_GUID \ + { \ + 0x2ab86ef5, 0xecb5, 0x4134, 0xb5, 0x56, 0x38, 0x54, 0xca, 0x1f, 0xe1, 0xb4 \ + } + +EFI_FORWARD_DECLARATION (EFI_PEI_READ_ONLY_VARIABLE2_PPI); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_GET_VARIABLE2) ( + IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This, + IN CONST CHAR16 *VariableName, + IN CONST EFI_GUID *VariableGuid, + OUT UINT32 *Attributes, + IN OUT UINTN *DataSize, + OUT VOID *Data + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_GET_NEXT_VARIABLE_NAME2) ( + IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This, + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VariableGuid + ); + +typedef struct _EFI_PEI_READ_ONLY_VARIABLE2_PPI { + EFI_PEI_GET_VARIABLE2 GetVariable; + EFI_PEI_GET_NEXT_VARIABLE_NAME2 GetNextVariableName; +} EFI_PEI_READ_ONLY_VARIABLE2_PPI; + +extern EFI_GUID gPeiReadOnlyVariable2PpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c new file mode 100644 index 0000000000..1819c4e7f5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiS3Save.c + +Abstract: + + Tiano Tiano S3 Save Protocol + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (AcpiS3Save) + +EFI_GUID gEfiAcpiS3SaveGuid = EFI_ACPI_S3_SAVE_GUID; + +EFI_GUID_STRING(&gEfiAcpiS3SaveGuid, "EFI Acpi S3 Save Protocol", "Tiano Acpi S3 Save Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h new file mode 100644 index 0000000000..b616a2ef71 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h @@ -0,0 +1,68 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiS3Save.h + +Abstract: + + +--*/ + +#ifndef _ACPI_S3_SAVE_PROTOCOL_H +#define _ACPI_S3_SAVE_PROTOCOL_H + +// +// Includes +// +#include "Tiano.h" + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_ACPI_S3_SAVE_PROTOCOL); + +// +// S3 Save Protocol GUID +// +#define EFI_ACPI_S3_SAVE_GUID \ + { \ + 0x125f2de1, 0xfb85, 0x440c, 0xa5, 0x4c, 0x4d, 0x99, 0x35, 0x8a, 0x8d, 0x38 \ + } + +// +// Protocol Data Structures +// +typedef +EFI_STATUS +EFI_BOOTSERVICE +(EFIAPI *EFI_ACPI_S3_SAVE) ( + IN EFI_ACPI_S3_SAVE_PROTOCOL * This, + IN VOID * LegacyMemoryAddress + ); + +typedef +EFI_STATUS +EFI_BOOTSERVICE +(EFIAPI *EFI_ACPI_GET_LEGACY_MEMORY_SIZE) ( + IN EFI_ACPI_S3_SAVE_PROTOCOL * This, + OUT UINTN * Size +); + +typedef struct _EFI_ACPI_S3_SAVE_PROTOCOL { + EFI_ACPI_GET_LEGACY_MEMORY_SIZE GetLegacyMemorySize; + EFI_ACPI_S3_SAVE S3Save; +} EFI_ACPI_S3_SAVE_PROTOCOL; + +extern EFI_GUID gEfiAcpiS3SaveGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c new file mode 100644 index 0000000000..4d3fcc7cb5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 1999 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + AcpiSupport.c + +Abstract: + + Tiano EFI 2.0 ACPI Support Protocol + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (AcpiSupport) + +EFI_GUID gEfiAcpiSupportGuid = EFI_ACPI_SUPPORT_GUID; + +EFI_GUID_STRING(&gEfiAcpiSupportGuid, "ACPI Support Protocol", "EFI 2.0 ACPI Support Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h new file mode 100644 index 0000000000..b99a15b495 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h @@ -0,0 +1,128 @@ +/*++ + +Copyright (c) 1999 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + AcpiSupport.h + +Abstract: + + Definition of the ACPI Support protocol. This is defined in the + Tiano ACPI External Product Specification, revision 0.5.1. + +--*/ + +#ifndef _ACPI_SUPPORT_PROTOCOL_H_ +#define _ACPI_SUPPORT_PROTOCOL_H_ + +// +// Includes +// +#include "Tiano.h" + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_ACPI_SUPPORT_PROTOCOL); + +// +// ACPI Support Protocol GUID +// +#define EFI_ACPI_SUPPORT_GUID \ + { \ + 0xdbff9d55, 0x89b7, 0x46da, 0xbd, 0xdf, 0x67, 0x7d, 0x3d, 0xc0, 0x24, 0x1d \ + } + +// +// Extern the GUID for protocol users. +// +extern EFI_GUID gEfiAcpiSupportGuid; + +// +// Protocol Data Definitions +// +// +// ACPI Version bitmap definition: +// +// EFI_ACPI_TABLE_VERSION_1_0B - ACPI Version 1.0b +// EFI_ACPI_TABLE_VERSION_2_0 - ACPI Version 2.0 +// EFI_ACPI_TABLE_VERSION_3_0 - ACPI Version 3.0 +// EFI_ACPI_TABLE_VERSION_NONE - No ACPI Versions. This might be used +// to create memory-based operation regions or other information +// that is not part of the ACPI "tree" but must still be found +// in ACPI memory space and/or managed by the core ACPI driver. +// +// Note that EFI provides discrete GUIDs for each version of ACPI +// that is supported. It is expected that each EFI GUIDed +// version of ACPI will also have a corresponding bitmap +// definition. This allows maintenance of separate ACPI trees +// for each distinctly different version of ACPI. +// +#define EFI_ACPI_TABLE_VERSION UINT32 + +#define EFI_ACPI_TABLE_VERSION_NONE (1 << 0) +#define EFI_ACPI_TABLE_VERSION_1_0B (1 << 1) +#define EFI_ACPI_TABLE_VERSION_2_0 (1 << 2) +#define EFI_ACPI_TABLE_VERSION_3_0 (1 << 3) + +// +// Protocol Member Functions +// +// +// Retrieve a copy of an ACPI table and the handle of the table. +// +typedef +EFI_STATUS +EFI_BOOTSERVICE +(EFIAPI *EFI_ACPI_GET_ACPI_TABLE) ( + IN EFI_ACPI_SUPPORT_PROTOCOL * This, + IN INTN Index, + OUT VOID **Table, + OUT EFI_ACPI_TABLE_VERSION * Version, + OUT UINTN *Handle + ); + +// +// Add, update, or remove a table. +// +typedef +EFI_STATUS +EFI_BOOTSERVICE +(EFIAPI *EFI_ACPI_SET_ACPI_TABLE) ( + IN EFI_ACPI_SUPPORT_PROTOCOL * This, + IN VOID *Table OPTIONAL, + IN BOOLEAN Checksum, + IN EFI_ACPI_TABLE_VERSION Version, + IN OUT UINTN *Handle + ); + +// +// Publish tables to the outside world +// +typedef +EFI_STATUS +EFI_BOOTSERVICE +(EFIAPI *EFI_ACPI_PUBLISH_TABLES) ( + IN EFI_ACPI_SUPPORT_PROTOCOL * This, + IN EFI_ACPI_TABLE_VERSION Version + ); + +// +// ACPI Support Protocol +// +typedef struct _EFI_ACPI_SUPPORT_PROTOCOL { + EFI_ACPI_GET_ACPI_TABLE GetAcpiTable; + EFI_ACPI_SET_ACPI_TABLE SetAcpiTable; + EFI_ACPI_PUBLISH_TABLES PublishTables; +} EFI_ACPI_SUPPORT_PROTOCOL; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c new file mode 100644 index 0000000000..328299618f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootScriptSave.c + +Abstract: + + S3 Save Protocol + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (BootScriptSave) + +EFI_GUID gEfiBootScriptSaveGuid = EFI_BOOT_SCRIPT_SAVE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiBootScriptSaveGuid, "EFI Boot Script Save Protocol", "EFI Boot Script Save Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h new file mode 100644 index 0000000000..2d0348bbd4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootScriptSave.h + +Abstract: + + S3 Save Protocol + +--*/ + +#ifndef _BOOT_SCRIPT_SAVE_PROTOCOL_H +#define _BOOT_SCRIPT_SAVE_PROTOCOL_H + +// +// Includes +// +#include "Tiano.h" + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_BOOT_SCRIPT_SAVE_PROTOCOL); + +// +// S3 Save Protocol GUID +// +#define EFI_BOOT_SCRIPT_SAVE_PROTOCOL_GUID \ + { \ + 0x470e1529, 0xb79e, 0x4e32, 0xa0, 0xfe, 0x6a, 0x15, 0x6d, 0x29, 0xf9, 0xb2 \ + } + +// +// Protocol Data Structures +// +typedef +EFI_STATUS +EFI_BOOTSERVICE +(EFIAPI *EFI_BOOT_SCRIPT_WRITE) ( + IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL * This, + IN UINT16 TableName, + IN UINT16 OpCode, + ... + ); + +typedef +EFI_STATUS +EFI_BOOTSERVICE +(EFIAPI *EFI_BOOT_SCRIPT_CLOSE_TABLE) ( + IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL * This, + IN UINT16 TableName, + OUT EFI_PHYSICAL_ADDRESS * Address + ); + +// +// S3 Save Protocol data structure +// +typedef struct _EFI_BOOT_SCRIPT_SAVE_PROTOCOL { + EFI_BOOT_SCRIPT_WRITE Write; + EFI_BOOT_SCRIPT_CLOSE_TABLE CloseTable; +} EFI_BOOT_SCRIPT_SAVE_PROTOCOL; + +extern EFI_GUID gEfiBootScriptSaveGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.c new file mode 100644 index 0000000000..d767a665dc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuIO.c + +Abstract: + + CPU IO Protocol GUID as defined in Tiano + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (CpuIo) + +EFI_GUID gEfiCpuIoProtocolGuid = EFI_CPU_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiCpuIoProtocolGuid, "CPU IO", "CPU IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.h new file mode 100644 index 0000000000..c4944b4368 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/CpuIo/CpuIo.h @@ -0,0 +1,93 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuIO.h + +Abstract: + + CPU IO Protocol as defined in Tiano + + This code abstracts the CPU IO Protocol + +--*/ + +#ifndef _CPUIO_H_ +#define _CPUIO_H_ + +#define EFI_CPU_IO_PROTOCOL_GUID \ + { \ + 0xB0732526, 0x38C8, 0x4b40, 0x88, 0x77, 0x61, 0xC7, 0xB0, 0x6A, 0xAC, 0x45 \ + } + +EFI_FORWARD_DECLARATION (EFI_CPU_IO_PROTOCOL); + +// +// ******************************************************* +// EFI_CPU_IO_PROTOCOL_WIDTH +// ******************************************************* +// +typedef enum { + EfiCpuIoWidthUint8, + EfiCpuIoWidthUint16, + EfiCpuIoWidthUint32, + EfiCpuIoWidthUint64, + EfiCpuIoWidthFifoUint8, + EfiCpuIoWidthFifoUint16, + EfiCpuIoWidthFifoUint32, + EfiCpuIoWidthFifoUint64, + EfiCpuIoWidthFillUint8, + EfiCpuIoWidthFillUint16, + EfiCpuIoWidthFillUint32, + EfiCpuIoWidthFillUint64, + EfiCpuIoWidthMaximum +} EFI_CPU_IO_PROTOCOL_WIDTH; + +// +// ******************************************************* +// EFI_CPU_IO_PROTOCOL_IO_MEM +// ******************************************************* +// +typedef +EFI_STATUS +EFI_RUNTIMESERVICE +(EFIAPI *EFI_CPU_IO_PROTOCOL_IO_MEM) ( + IN EFI_CPU_IO_PROTOCOL * This, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +// +// ******************************************************* +// EFI_CPU_IO_PROTOCOL_ACCESS +// ******************************************************* +// +typedef struct { + EFI_CPU_IO_PROTOCOL_IO_MEM Read; + EFI_CPU_IO_PROTOCOL_IO_MEM Write; +} EFI_CPU_IO_PROTOCOL_ACCESS; + +// +// ******************************************************* +// EFI_CPU_IO_PROTOCOL +// ******************************************************* +// +typedef struct _EFI_CPU_IO_PROTOCOL { + EFI_CPU_IO_PROTOCOL_ACCESS Mem; + EFI_CPU_IO_PROTOCOL_ACCESS Io; +} EFI_CPU_IO_PROTOCOL; + +extern EFI_GUID gEfiCpuIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.c new file mode 100644 index 0000000000..ad45047e7c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.c @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHub.c + +Abstract: + + The logging hub protocol is used both by agents wishing to log + errors and those wishing to be made aware of all information that + has been logged. + + For more information please look at Intel Platform Innovation + Framework for EFI Data Hub Specification. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (DataHub) + +EFI_GUID gEfiDataHubProtocolGuid = EFI_DATA_HUB_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDataHubProtocolGuid, "DataHub Protocol", "EFI Data Hub Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.h new file mode 100644 index 0000000000..2a2d86f5ef --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/DataHub/DataHub.h @@ -0,0 +1,125 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DataHub.h + +Abstract: + + The data hub protocol is used both by agents wishing to log + data and those wishing to be made aware of all information that + has been logged. + + For more information please look at Intel Platform Innovation + Framework for EFI Data Hub Specification. + +--*/ + +#ifndef __DATA_HUB_H__ +#define __DATA_HUB_H__ + +#define EFI_DATA_HUB_PROTOCOL_GUID \ + { \ + 0xae80d021, 0x618e, 0x11d4, 0xbc, 0xd7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +// +// EFI generic Data Hub Header +// +// A Data Record is an EFI_DATA_RECORD_HEADER followed by RecordSize bytes of +// data. The format of the data is defined by the DataRecordGuid. +// +// If EFI_DATA_RECORD_HEADER is extended in the future the Version number must +// change and the HeaderSize will change if the definition of +// EFI_DATA_RECORD_HEADER is extended. +// +// The logger is responcible for initializing: +// Version, HeaderSize, RecordSize, DataRecordGuid, DataRecordClass +// +// The Data Hub driver is responcible for initializing: +// LogTime and LogMonotonicCount. +// +#define EFI_DATA_RECORD_HEADER_VERSION 0x0100 +typedef struct { + UINT16 Version; + UINT16 HeaderSize; + UINT32 RecordSize; + EFI_GUID DataRecordGuid; + EFI_GUID ProducerName; + UINT64 DataRecordClass; + EFI_TIME LogTime; + UINT64 LogMonotonicCount; +} EFI_DATA_RECORD_HEADER; + +// +// Definition of DataRecordClass. These are used to filter out class types +// at a very high level. The DataRecordGuid still defines the format of +// the data. See DateHub.doc for rules on what can and can not be a +// new DataRecordClass +// +#define EFI_DATA_RECORD_CLASS_DEBUG 0x0000000000000001 +#define EFI_DATA_RECORD_CLASS_ERROR 0x0000000000000002 +#define EFI_DATA_RECORD_CLASS_DATA 0x0000000000000004 +#define EFI_DATA_RECORD_CLASS_PROGRESS_CODE 0x0000000000000008 + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_DATA_HUB_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DATA_HUB_LOG_DATA) ( + IN EFI_DATA_HUB_PROTOCOL * This, + IN EFI_GUID * DataRecordGuid, + IN EFI_GUID * ProducerName, + IN UINT64 DataRecordClass, + IN VOID *RawData, + IN UINT32 RawDataSize + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DATA_HUB_GET_NEXT_RECORD) ( + IN EFI_DATA_HUB_PROTOCOL * This, + IN OUT UINT64 *MonotonicCount, + IN EFI_EVENT * FilterDriver OPTIONAL, + OUT EFI_DATA_RECORD_HEADER **Record + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DATA_HUB_REGISTER_FILTER_DRIVER) ( + IN EFI_DATA_HUB_PROTOCOL * This, + IN EFI_EVENT FilterEvent, + IN EFI_TPL FilterTpl, + IN UINT64 FilterClass, + IN EFI_GUID * FilterDataRecordGuid OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DATA_HUB_UNREGISTER_FILTER_DRIVER) ( + IN EFI_DATA_HUB_PROTOCOL * This, + IN EFI_EVENT FilterEvent + ); + +typedef struct _EFI_DATA_HUB_PROTOCOL { + EFI_DATA_HUB_LOG_DATA LogData; + EFI_DATA_HUB_GET_NEXT_RECORD GetNextRecord; + EFI_DATA_HUB_REGISTER_FILTER_DRIVER RegisterFilterDriver; + EFI_DATA_HUB_UNREGISTER_FILTER_DRIVER UnregisterFilterDriver; +} EFI_DATA_HUB_PROTOCOL; + +extern EFI_GUID gEfiDataHubProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf new file mode 100644 index 0000000000..8950b77116 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf @@ -0,0 +1,116 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkFrameworkProtocolLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME= EdkFrameworkProtocolLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[nmake.common] + +[sources.common] + AcpiS3Save\AcpiS3Save.h + AcpiS3Save\AcpiS3Save.c + AcpiSupport\AcpiSupport.h + AcpiSupport\AcpiSupport.c + BootScriptSave\BootScriptSave.h + BootScriptSave\BootScriptSave.c + CpuIo\CpuIo.h + CpuIo\CpuIo.c + DataHub\DataHub.h + DataHub\DataHub.c + FirmwareVolume\FirmwareVolume.h + FirmwareVolume\FirmwareVolume.c + FirmwareVolume2\FirmwareVolume2.h + FirmwareVolume2\FirmwareVolume2.c + FirmwareVolumeBlock\FirmwareVolumeBlock.h + FirmwareVolumeBlock\FirmwareVolumeBlock.c + FormBrowser\FormBrowser.h + FormBrowser\FormBrowser.c + FormCallback\FormCallback.h + FormCallback\FormCallback.c + Hii\Hii.h + Hii\Hii.c + IdeControllerInit\IdeControllerInit.h + IdeControllerInit\IdeControllerInit.c + IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.h + IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.c + Legacy8259\Legacy8259.h + Legacy8259\Legacy8259.c + LegacyBios\LegacyBios.h + LegacyBios\LegacyBios.c + LegacyBiosPlatform\LegacyBiosPlatform.h + LegacyBiosPlatform\LegacyBiosPlatform.c + LegacyInterrupt\LegacyInterrupt.h + LegacyInterrupt\LegacyInterrupt.c + LegacyRegion\LegacyRegion.h + LegacyRegion\LegacyRegion.c + PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.h + PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.c + PciHotPlugInit\PciHotPlugInit.h + PciHotPlugInit\PciHotPlugInit.c + PciPlatform\PciPlatform.h + PciPlatform\PciPlatform.c + SectionExtraction\SectionExtraction.h + SectionExtraction\SectionExtraction.c + SecurityPolicy\SecurityPolicy.h + SecurityPolicy\SecurityPolicy.c + Smbus\Smbus.h + Smbus\Smbus.c + +[sources.ia32,sources.x64] + SmmAccess\SmmAccess.h + SmmAccess\SmmAccess.c + SmmBase\SmmBase.h + SmmBase\SmmBase.c + SmmControl\SmmControl.h + SmmControl\SmmControl.c + SmmCpuState\SmmCpuState.h + SmmCpuState\SmmCpuState.c + SmmGpiDispatch\SmmGpiDispatch.h + SmmGpiDispatch\SmmGpiDispatch.c + SmmIchnDispatch\SmmIchnDispatch.h + SmmIchnDispatch\SmmIchnDispatch.c + SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.h + SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.c + SmmPowerButtonDispatch\SmmPowerButtonDispatch.h + SmmPowerButtonDispatch\SmmPowerButtonDispatch.c + SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.h + SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.c + SmmStatusCode\SmmStatusCode.h + SmmStatusCode\SmmStatusCode.c + SmmSwDispatch\SmmSwDispatch.h + SmmSwDispatch\SmmSwDispatch.c + SmmSxDispatch\SmmSxDispatch.h + SmmSxDispatch\SmmSxDispatch.c + SmmUsbDispatch\SmmUsbDispatch.h + SmmUsbDispatch\SmmUsbDispatch.c \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c new file mode 100644 index 0000000000..bba551e159 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolume.c + +Abstract: + + Firmware Volume protocol as defined in the Tiano Firmware Volume + specification. + + File level access layered on top of Firmware File System protocol. This + protocol exists to provide a hook for a filter driver for a firmware volume. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) + +EFI_GUID gEfiFirmwareVolumeProtocolGuid = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiFirmwareVolumeProtocolGuid, "FirmwareVolume Protocol", "Firmware Volume protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h new file mode 100644 index 0000000000..62bc492273 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h @@ -0,0 +1,301 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolume.h + +Abstract: + + Firmware Volume protocol as defined in the Tiano Firmware Volume + specification. + +--*/ + +#ifndef _FW_VOL_H_ +#define _FW_VOL_H_ + +// +// Statements that include other files +// +#include "EfiFirmwareVolumeHeader.h" +#include "EfiFirmwareFileSystem.h" +#include "EfiFirmwareVolume.h" +// +// Firmware Volume Protocol GUID definition +// +#define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \ + { \ + 0x389F751F, 0x1838, 0x4388, 0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 \ + } + + +EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_PROTOCOL); + +// +// ************************************************************ +// EFI_FV_ATTRIBUTES bit definitions +// ************************************************************ +// +#define EFI_FV_READ_DISABLE_CAP 0x0000000000000001 +#define EFI_FV_READ_ENABLE_CAP 0x0000000000000002 +#define EFI_FV_READ_STATUS 0x0000000000000004 + +#define EFI_FV_WRITE_DISABLE_CAP 0x0000000000000008 +#define EFI_FV_WRITE_ENABLE_CAP 0x0000000000000010 +#define EFI_FV_WRITE_STATUS 0x0000000000000020 + +#define EFI_FV_LOCK_CAP 0x0000000000000040 +#define EFI_FV_LOCK_STATUS 0x0000000000000080 +#define EFI_FV_WRITE_POLICY_RELIABLE 0x0000000000000100 + +#define EFI_FV_ALIGNMENT_CAP 0x0000000000008000 +#define EFI_FV_ALIGNMENT_2 0x0000000000010000 +#define EFI_FV_ALIGNMENT_4 0x0000000000020000 +#define EFI_FV_ALIGNMENT_8 0x0000000000040000 +#define EFI_FV_ALIGNMENT_16 0x0000000000080000 +#define EFI_FV_ALIGNMENT_32 0x0000000000100000 +#define EFI_FV_ALIGNMENT_64 0x0000000000200000 +#define EFI_FV_ALIGNMENT_128 0x0000000000400000 +#define EFI_FV_ALIGNMENT_256 0x0000000000800000 +#define EFI_FV_ALIGNMENT_512 0x0000000001000000 +#define EFI_FV_ALIGNMENT_1K 0x0000000002000000 +#define EFI_FV_ALIGNMENT_2K 0x0000000004000000 +#define EFI_FV_ALIGNMENT_4K 0x0000000008000000 +#define EFI_FV_ALIGNMENT_8K 0x0000000010000000 +#define EFI_FV_ALIGNMENT_16K 0x0000000020000000 +#define EFI_FV_ALIGNMENT_32K 0x0000000040000000 +#define EFI_FV_ALIGNMENT_64K 0x0000000080000000 + +// +// Protocol API definitions +// +// +// Forward declaration of protocol data structure +// +typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL EFI_FIRMWARE_VOLUME_PROTOCOL; + +typedef +EFI_STATUS +(EFIAPI *FV_GET_ATTRIBUTES) ( + IN EFI_FIRMWARE_VOLUME_PROTOCOL * This, + OUT EFI_FV_ATTRIBUTES * Attributes + ); + +/*++ + +Routine Description: + Retrieves attributes, insures positive polarity of attribute bits, returns + resulting attributes in output parameter + +Arguments: + This - Calling context + Attributes - output buffer which contains attributes + +Returns: + EFI_INVALID_PARAMETER + EFI_SUCCESS + +--*/ +typedef +EFI_STATUS +(EFIAPI *FV_SET_ATTRIBUTES) ( + IN EFI_FIRMWARE_VOLUME_PROTOCOL * This, + IN OUT EFI_FV_ATTRIBUTES * Attributes + ); + +/*++ + +Routine Description: + Sets volume attributes + +Arguments: + This Calling context + Attributes Buffer which contains attributes + +Returns: + EFI_INVALID_PARAMETER + EFI_DEVICE_ERROR + EFI_SUCCESS + +--*/ + +typedef +EFI_STATUS +(EFIAPI *FV_READ_FILE) ( + IN EFI_FIRMWARE_VOLUME_PROTOCOL * This, + IN EFI_GUID * NameGuid, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT EFI_FV_FILETYPE * FoundType, + OUT EFI_FV_FILE_ATTRIBUTES * FileAttributes, + OUT UINT32 *AuthenticationStatus + ); + +/*++ + +Routine Description: + Read the requested file (NameGuid) and returns data in Buffer. + +Arguments: + This - Calling context + NameGuid - Filename identifying which file to read + Buffer - Pointer to pointer to buffer in which contents of file are returned. + + If Buffer is NULL, only type, attributes, and size are returned as + there is no output buffer. + + If Buffer != NULL and *Buffer == NULL, the output buffer is allocated + from BS pool by ReadFile + + If Buffer != NULL and *Buffer != NULL, the output buffer has been + allocated by the caller and is being passed in. + + BufferSize - Indicates the buffer size passed in, and on output the size + required to complete the read + FoundType - Indicates the type of the file who's data is returned + FileAttributes - Indicates the attributes of the file who's data is resturned + AuthenticationStatus - Indicates the authentication status of the data + +Returns: + EFI_SUCCESS + EFI_WARN_BUFFER_TOO_SMALL + EFI_NOT_FOUND + EFI_DEVICE_ERROR + EFI_ACCESS_DENIED + +--*/ +typedef +EFI_STATUS +(EFIAPI *FV_READ_SECTION) ( + IN EFI_FIRMWARE_VOLUME_PROTOCOL * This, + IN EFI_GUID * NameGuid, + IN EFI_SECTION_TYPE SectionType, + IN UINTN SectionInstance, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT UINT32 *AuthenticationStatus + ); + +/*++ + +Routine Description: + Read the requested section from the specified file and returns data in Buffer. + +Arguments: + This - Calling context + NameGuid - Filename identifying the file from which to read + SectionType - Indicates what section type to retrieve + SectionInstance - Indicates which instance of SectionType to retrieve + Buffer - Pointer to pointer to buffer in which contents of file are returned. + + If Buffer is NULL, only type, attributes, and size are returned as + there is no output buffer. + + If Buffer != NULL and *Buffer == NULL, the output buffer is allocated + from BS pool by ReadFile + + If Buffer != NULL and *Buffer != NULL, the output buffer has been + allocated by the caller and is being passed in. + + BufferSize - Indicates the buffer size passed in, and on output the size + required to complete the read + AuthenticationStatus - Indicates the authentication status of the data + +Returns: + EFI_SUCCESS + EFI_WARN_BUFFER_TOO_SMALL + EFI_OUT_OF_RESOURCES + EFI_NOT_FOUND + EFI_DEVICE_ERROR + EFI_ACCESS_DENIED + +--*/ + +typedef +EFI_STATUS +(EFIAPI *FV_WRITE_FILE) ( + IN EFI_FIRMWARE_VOLUME_PROTOCOL * This, + IN UINT32 NumberOfFiles, + IN EFI_FV_WRITE_POLICY WritePolicy, + IN EFI_FV_WRITE_FILE_DATA * FileData + ); + +/*++ + +Routine Description: + Write the supplied file (NameGuid) to the FV. + +Arguments: + This - Calling context + NumberOfFiles - Indicates the number of file records pointed to by FileData + WritePolicy - Indicates the level of reliability of the write with respect to + things like power failure events. + FileData - A pointer to an array of EFI_FV_WRITE_FILE_DATA structures. Each + element in the array indicates a file to write, and there are + NumberOfFiles elements in the input array. + +Returns: + EFI_SUCCESS + EFI_OUT_OF_RESOURCES + EFI_DEVICE_ERROR + EFI_WRITE_PROTECTED + EFI_NOT_FOUND + EFI_INVALID_PARAMETER + +--*/ +typedef +EFI_STATUS +(EFIAPI *FV_GET_NEXT_FILE) ( + IN EFI_FIRMWARE_VOLUME_PROTOCOL * This, + IN OUT VOID *Key, + IN OUT EFI_FV_FILETYPE * FileType, + OUT EFI_GUID * NameGuid, + OUT EFI_FV_FILE_ATTRIBUTES * Attributes, + OUT UINTN *Size + ); + +/*++ + +Routine Description: + Given the input key, search for the next matching file in the volume. + +Arguments: + This - Calling context + Key - Pointer to a caller allocated buffer that contains an implementation + specific key that is used to track where to begin searching on + successive calls. + FileType - Indicates the file type to filter for + NameGuid - Guid filename of the file found + Attributes - Attributes of the file found + Size - Size in bytes of the file found + +Returns: + EFI_SUCCESS + EFI_NOT_FOUND + EFI_DEVICE_ERROR + EFI_ACCESS_DENIED + +--*/ +typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL { + FV_GET_ATTRIBUTES GetVolumeAttributes; + FV_SET_ATTRIBUTES SetVolumeAttributes; + FV_READ_FILE ReadFile; + FV_READ_SECTION ReadSection; + FV_WRITE_FILE WriteFile; + FV_GET_NEXT_FILE GetNextFile; + UINT32 KeySize; + EFI_HANDLE ParentHandle; +} EFI_FIRMWARE_VOLUME_PROTOCOL; + +extern EFI_GUID gEfiFirmwareVolumeProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c new file mode 100644 index 0000000000..6f4efaebfc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolume2.c + +Abstract: + + PI 1.0 spec definition. + +--*/ + + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) + +EFI_GUID gEfiFirmwareVolume2ProtocolGuid = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiFirmwareVolume2ProtocolGuid, "FirmwareVolume2Protocol", "Efi FirmwareVolume2Protocol"); \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h new file mode 100644 index 0000000000..7a56aa2ad9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h @@ -0,0 +1,195 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolume2.h + +Abstract: + + PI 1.0 spec definition. + +--*/ + +#ifndef __FIRMWARE_VOLUME2_H__ +#define __FIRMWARE_VOLUME2_H__ +#include "EfiImageFormat.h" +#include "EfiFirmwareVolume.h" + +// +// Firmware Volume Protocol GUID definition +// +#define EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID \ + { 0x220e73b6, 0x6bdb, 0x4413, 0x84, 0x5, 0xb9, 0x74, 0xb1, 0x8, 0x61, 0x9a } + + +EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME2_PROTOCOL); + + +// +// ************************************************************ +// EFI_FV2_ATTRIBUTES bit definitions +// ************************************************************ +// +#define EFI_FV2_READ_DISABLE_CAP 0x0000000000000001 +#define EFI_FV2_READ_ENABLE_CAP 0x0000000000000002 +#define EFI_FV2_READ_STATUS 0x0000000000000004 + +#define EFI_FV2_WRITE_DISABLE_CAP 0x0000000000000008 +#define EFI_FV2_WRITE_ENABLE_CAP 0x0000000000000010 +#define EFI_FV2_WRITE_STATUS 0x0000000000000020 + +#define EFI_FV2_LOCK_CAP 0x0000000000000040 +#define EFI_FV2_LOCK_STATUS 0x0000000000000080 +#define EFI_FV2_WRITE_POLICY_RELIABLE 0x0000000000000100 + +#define EFI_FV2_READ_LOCK_CAP 0x0000000000001000 +#define EFI_FV2_READ_LOCK_STATUS 0x0000000000002000 +#define EFI_FV2_WRITE_LOCK_CAP 0x0000000000004000 +#define EFI_FV2_WRITE_LOCK_STATUS 0x0000000000008000 +#define EFI_FV2_ALIGNMENT 0x00000000001F0000 + + +#define EFI_FV2_ALIGNMENT_1 0x0000000000000000 +#define EFI_FV2_ALIGNMENT_2 0x0000000000010000 +#define EFI_FV2_ALIGNMENT_4 0x0000000000020000 +#define EFI_FV2_ALIGNMENT_8 0x0000000000030000 +#define EFI_FV2_ALIGNMENT_16 0x0000000000040000 +#define EFI_FV2_ALIGNMENT_32 0x0000000000050000 +#define EFI_FV2_ALIGNMENT_64 0x0000000000060000 +#define EFI_FV2_ALIGNMENT_128 0x0000000000070000 +#define EFI_FV2_ALIGNMENT_256 0x0000000000080000 +#define EFI_FV2_ALIGNMENT_512 0x0000000000090000 +#define EFI_FV2_ALIGNMENT_1K 0x00000000000A0000 +#define EFI_FV2_ALIGNMENT_2K 0x00000000000B0000 +#define EFI_FV2_ALIGNMENT_4K 0x00000000000C0000 +#define EFI_FV2_ALIGNMENT_8K 0x00000000000D0000 +#define EFI_FV2_ALIGNMENT_16K 0x00000000000E0000 +#define EFI_FV2_ALIGNMENT_32K 0x00000000000F0000 +#define EFI_FV2_ALIGNMENT_64K 0x0000000000100000 +#define EFI_FV2_ALIGNMENT_128K 0x0000000000110000 +#define EFI_FV2_ALIGNMENT_256K 0x0000000000120000 +#define EFI_FV2_ALIGNMENT_512K 0x0000000000130000 +#define EFI_FV2_ALIGNMENT_1M 0x0000000000140000 +#define EFI_FV2_ALIGNMENT_2M 0x0000000000150000 +#define EFI_FV2_ALIGNMENT_4M 0x0000000000160000 +#define EFI_FV2_ALIGNMENT_8M 0x0000000000170000 +#define EFI_FV2_ALIGNMENT_16M 0x0000000000180000 +#define EFI_FV2_ALIGNMENT_32M 0x0000000000190000 +#define EFI_FV2_ALIGNMENT_64M 0x00000000001A0000 +#define EFI_FV2_ALIGNMENT_128M 0x00000000001B0000 +#define EFI_FV2_ALIGNMENT_256M 0x00000000001C0000 +#define EFI_FV2_ALIGNMENT_512M 0x00000000001D0000 +#define EFI_FV2_ALIGNMENT_1G 0x00000000001E0000 +#define EFI_FV2_ALIGNMENT_2G 0x00000000001F0000 + +#define EFI_FV_FILE_ATTRIB_FIXED 0x00000100 +#define EFI_FV_FILE_ATTRIB_MEMORY_MAPPED 0x00000200 + + +// +// Protocol API definitions +// + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_GET_ATTRIBUTES) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + OUT EFI_FV_ATTRIBUTES *Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_SET_ATTRIBUTES) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN OUT EFI_FV_ATTRIBUTES *Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_READ_FILE) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *NameGuid, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT EFI_FV_FILETYPE *FoundType, + OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes, + OUT UINT32 *AuthenticationStatus + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_READ_SECTION) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + IN UINTN SectionInstance, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT UINT32 *AuthenticationStatus + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_WRITE_FILE) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN UINT32 NumberOfFiles, + IN EFI_FV_WRITE_POLICY WritePolicy, + IN EFI_FV_WRITE_FILE_DATA *FileData + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_GET_NEXT_FILE) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN OUT VOID *Key, + IN OUT EFI_FV_FILETYPE *FileType, + OUT EFI_GUID *NameGuid, + OUT EFI_FV_FILE_ATTRIBUTES *Attributes, + OUT UINTN *Size + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_GET_INFO) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *InformationType, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FV_SET_INFO) ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *InformationType, + IN UINTN BufferSize, + IN CONST VOID *Buffer + ); + + +typedef struct _EFI_FIRMWARE_VOLUME2_PROTOCOL { + EFI_FV_GET_ATTRIBUTES GetVolumeAttributes; + EFI_FV_SET_ATTRIBUTES SetVolumeAttributes; + EFI_FV_READ_FILE ReadFile; + EFI_FV_READ_SECTION ReadSection; + EFI_FV_WRITE_FILE WriteFile; + EFI_FV_GET_NEXT_FILE GetNextFile; + UINT32 KeySize; + EFI_HANDLE ParentHandle; + EFI_FV_GET_INFO GetInfo; + EFI_FV_SET_INFO SetInfo; +} EFI_FIRMWARE_VOLUME2_PROTOCOL; + +extern EFI_GUID gEfiFirmwareVolume2ProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c new file mode 100644 index 0000000000..aae1860448 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolumeBlock.c + +Abstract: + + Firmware Volume Block protocol as defined in the Tiano Firmware Volume + specification. + + Low level firmware device access routines to abstract firmware device + hardware. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) + +EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiFirmwareVolumeBlockProtocolGuid, "FirmwareVolumeBlock Protocol", "Firmware Volume Block protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h new file mode 100644 index 0000000000..8502810e1b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h @@ -0,0 +1,251 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolumeBlock.h + +Abstract: + + Firmware Volume Block protocol as defined in the Tiano Firmware Volume + specification. + + Low level firmware device access routines to abstract firmware device + hardware. + +--*/ + +#ifndef _FW_VOL_BLOCK_H_ +#define _FW_VOL_BLOCK_H_ + +#include "EfiFirmwareVolumeHeader.h" + +#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \ + { \ + 0xDE28BC59, 0x6228, 0x41BD, 0xBD, 0xF6, 0xA3, 0xB9, 0xAD, 0xB5, 0x8D, 0xA1 \ + } + +EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_FVB_GET_ATTRIBUTES) ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This, + OUT EFI_FVB_ATTRIBUTES * Attributes + ) +/*++ + +Routine Description: + Retrieves Volume attributes. No polarity translations are done. + +Arguments: + This - Calling context + Attributes - output buffer which contains attributes + +Returns: + EFI_INVALID_PARAMETER + EFI_SUCCESS + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FVB_SET_ATTRIBUTES) ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This, + IN OUT EFI_FVB_ATTRIBUTES * Attributes + ) +/*++ + +Routine Description: + Sets Volume attributes. No polarity translations are done. + +Arguments: + This - Calling context + Attributes - On input: contains new attributes + On output: contains current attributes of FV + +Returns: + EFI_INVALID_PARAMETER + EFI_SUCCESS + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FVB_GET_PHYSICAL_ADDRESS) ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This, + OUT EFI_PHYSICAL_ADDRESS * Address + ) +/*++ + +Routine Description: + Retrieves the physical address of a memory mapped FV. + +Arguments: + This - Calling context + Attributes - Address is a pointer to a caller allocated EFI_PHYSICAL_ADDRESS + that on successful return from GetPhysicalAddress() contains the + base address of the firmware volume. + +Returns: + EFI_UNSUPPORTED + EFI_SUCCESS + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FVB_GET_BLOCK_SIZE) ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumberOfBlocks + ) +/*++ + +Routine Description: + Retrieves the size in bytes of a specific block within an FV. + +Arguments: + This - Calling context. + Lba - Indicates which block to return the size for. + BlockSize - BlockSize is a pointer to a caller allocated + UINTN in which the size of the block is returned. + NumberOfBlocks - NumberOfBlocks is a pointer to a caller allocated + UINTN in which the number of consecutive blocks + starting with Lba is returned. All blocks in this + range have a size of BlockSize. + +Returns: + EFI_INVALID_PARAMETER + EFI_SUCCESS + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FVB_READ) ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + OUT UINT8 *Buffer + ) +/*++ + +Routine Description: + Reads data beginning at Lba:Offset from FV and places the data in Buffer. + The read terminates either when *NumBytes of data have been read, or when + a block boundary is reached. *NumBytes is updated to reflect the actual + number of bytes read. + +Arguments: + This - Calling context + Lba - Block in which to begin read + Offset - Offset in the block at which to begin read + NumBytes - At input, indicates the requested read size. At output, indicates + the actual number of bytes read. + Buffer - Data buffer in which to place data read. + +Returns: + EFI_INVALID_PARAMETER + EFI_NOT_FOUND + EFI_DEVICE_ERROR + EFI_SUCCESS + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_FVB_WRITE) ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + + Writes data beginning at Lba:Offset from FV. The write terminates either + when *NumBytes of data have been written, or when a block boundary is + reached. *NumBytes is updated to reflect the actual number of bytes + written. + +Arguments: + This - Calling context + Lba - Block in which to begin write + Offset - Offset in the block at which to begin write + NumBytes - At input, indicates the requested write size. At output, indicates + the actual number of bytes written. + Buffer - Buffer containing source data for the write. + +Returns: + EFI_INVALID_PARAMETER + EFI_NOT_FOUND + EFI_DEVICE_ERROR + EFI_SUCCESS + +--*/ +; + +#define EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFF + +typedef +EFI_STATUS +(EFIAPI *EFI_FVB_ERASE_BLOCKS) ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This, + ... + ) +/*++ + +Routine Description: + The EraseBlock() function erases one or more blocks as denoted by the +variable argument list. The entire parameter list of blocks must be verified +prior to erasing any blocks. If a block is requested that does not exist +within the associated firmware volume (it has a larger index than the last +block of the firmware volume), the EraseBlock() function must return +EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. + +Arguments: + This - Calling context + ... - Starting LBA followed by Number of Lba to erase. a -1 to terminate + the list. + +Returns: + EFI_INVALID_PARAMETER + EFI_DEVICE_ERROR + EFI_SUCCESS + EFI_ACCESS_DENIED + +--*/ +; + +typedef struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL { + EFI_FVB_GET_ATTRIBUTES GetVolumeAttributes; + EFI_FVB_SET_ATTRIBUTES SetVolumeAttributes; + EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress; + EFI_FVB_GET_BLOCK_SIZE GetBlockSize; + EFI_FVB_READ Read; + EFI_FVB_WRITE Write; + EFI_FVB_ERASE_BLOCKS EraseBlocks; + EFI_HANDLE ParentHandle; +} EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL; + +extern EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c new file mode 100644 index 0000000000..2f65746596 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FormBrowser.c + +Abstract: + + The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI + Configuration Driver. This will allow the caller to direct the + configuration driver to use either the HII database or use the passed + in packet of data. This will also allow the caller to post messages + into the configuration drivers internal mailbox. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (FormBrowser) + +EFI_GUID gEfiFormBrowserProtocolGuid = EFI_FORM_BROWSER_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiFormBrowserProtocolGuid, "Form Browser Protocol", "Form Browser 1.0 protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h new file mode 100644 index 0000000000..566f7cc23b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h @@ -0,0 +1,97 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FormBrowser.h + +Abstract: + + The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI + Configuration Driver. This will allow the caller to direct the + configuration driver to use either the HII database or use the passed + in packet of data. This will also allow the caller to post messages + into the configuration drivers internal mailbox. + +--*/ + +#ifndef _FORM_BROWSER_H_ +#define _FORM_BROWSER_H_ + +#include EFI_PROTOCOL_DEFINITION (Hii) + +#define EFI_FORM_BROWSER_PROTOCOL_GUID \ + { \ + 0xe5a1333e, 0xe1b4, 0x4d55, 0xce, 0xeb, 0x35, 0xc3, 0xef, 0x13, 0x34, 0x43 \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_FORM_BROWSER_PROTOCOL); + +typedef struct _EFI_FORM_BROWSER_PROTOCOL EFI_FORM_BROWSER_PROTOCOL; + +typedef struct { + UINT32 Length; + UINT16 Type; + UINT8 Data[1]; +} EFI_HII_PACKET; + +typedef struct { + EFI_HII_IFR_PACK *IfrData; + EFI_HII_STRING_PACK *StringData; +} EFI_IFR_PACKET; + +typedef struct { + UINTN LeftColumn; + UINTN RightColumn; + UINTN TopRow; + UINTN BottomRow; +} SCREEN_DESCRIPTOR; + +// +// The following types are currently defined: +// +typedef +EFI_STATUS +(EFIAPI *EFI_SEND_FORM) ( + IN EFI_FORM_BROWSER_PROTOCOL * This, + IN BOOLEAN UseDatabase, + IN EFI_HII_HANDLE * Handle, + IN UINTN HandleCount, + IN EFI_IFR_PACKET * Packet, + IN EFI_HANDLE CallbackHandle, + IN UINT8 *NvMapOverride, + IN SCREEN_DESCRIPTOR * ScreenDimensions, + OUT BOOLEAN *ResetRequired OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CREATE_POP_UP) ( + IN UINTN NumberOfLines, + IN BOOLEAN HotKey, + IN UINTN MaximumStringSize, + OUT CHAR16 *StringBuffer, + OUT EFI_INPUT_KEY * KeyValue, + IN CHAR16 *String, + ... + ); + +typedef struct _EFI_FORM_BROWSER_PROTOCOL { + EFI_SEND_FORM SendForm; + EFI_CREATE_POP_UP CreatePopUp; +} EFI_FORM_BROWSER_PROTOCOL; + +extern EFI_GUID gEfiFormBrowserProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.c new file mode 100644 index 0000000000..69e2de08b5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FormCallback.c + +Abstract: + + The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom + NV storage devices as well as communication of user selections in a more + interactive environment. This protocol should be published by hardware + specific drivers which want to export access to custom hardware storage or + publish IFR which has a requirement to call back the original driver. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (FormCallback) + +EFI_GUID gEfiFormCallbackProtocolGuid = EFI_FORM_CALLBACK_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiFormCallbackProtocolGuid, "Form Callback Protocol", "Form Callback 1.0 protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.h new file mode 100644 index 0000000000..5091f3e90c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FormCallback/FormCallback.h @@ -0,0 +1,120 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FormCallback.h + +Abstract: + + The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom + NV storage devices as well as communication of user selections in a more + interactive environment. This protocol should be published by hardware + specific drivers which want to export access to custom hardware storage or + publish IFR which has a requirement to call back the original driver. + +--*/ + +#ifndef _FORM_CALLBACK_H_ +#define _FORM_CALLBACK_H_ + +#include EFI_PROTOCOL_DEFINITION (FormBrowser) + +#define EFI_FORM_CALLBACK_PROTOCOL_GUID \ + { \ + 0xf3e4543d, 0xcf35, 0x6cef, 0x35, 0xc4, 0x4f, 0xe6, 0x34, 0x4d, 0xfc, 0x54 \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_FORM_CALLBACK_PROTOCOL); + +typedef struct _EFI_FORM_CALLBACK_PROTOCOL EFI_FORM_CALLBACK_PROTOCOL; + +#define RESET_REQUIRED 1 // Flags setting to signify that the callback operation resulted in an eventual +// reset to be done upon exit of the browser +// +#define EXIT_REQUIRED 2 // Flags setting to signify that after the processing of the callback results - exit the browser +#define SAVE_REQUIRED 4 // Flags setting to signify that after the processing of the callback results - save the NV data +#define NV_CHANGED 8 // Flags setting to signify that after the processing of the callback results - turn the NV flag on +#define NV_NOT_CHANGED 16 // Flags setting to signify that after the processing of the callback results - turn the NV flag off +#pragma pack(1) +typedef struct { + UINT8 OpCode; // Likely a string, numeric, or one-of + UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet + UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback + VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately + // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value + // If the OpCode is a String type - Data is a CHAR16[x] type + // If the OpCode is a Checkbox type - Data is a UINT8 value + // If the OpCode is a NV Access type - Data is a EFI_IFR_NV_DATA structure + // +} EFI_IFR_DATA_ENTRY; + +typedef struct { + VOID *NvRamMap; // If the flag of the op-code specified retrieval of a copy of the NVRAM map, + // this is a pointer to a buffer copy + // + UINT32 EntryCount; // How many EFI_IFR_DATA_ENTRY entries + EFI_IFR_DATA_ENTRY Data[1]; // The in-line Data entries. +} EFI_IFR_DATA_ARRAY; + +typedef union { + EFI_IFR_DATA_ARRAY DataArray; // Primarily used by those who call back to their drivers and use HII as a repository + EFI_IFR_PACKET DataPacket; // Primarily used by those which do not use HII as a repository + CHAR16 String[1]; // If returning an error - fill the string with null-terminated contents +} EFI_HII_CALLBACK_PACKET; +#pragma pack() +// +// The following types are currently defined: +// +typedef +EFI_STATUS +(EFIAPI *EFI_NV_READ) ( + IN EFI_FORM_CALLBACK_PROTOCOL * This, + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_NV_WRITE) ( + IN EFI_FORM_CALLBACK_PROTOCOL * This, + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Buffer, + OUT BOOLEAN *ResetRequired + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FORM_CALLBACK) ( + IN EFI_FORM_CALLBACK_PROTOCOL * This, + IN UINT16 KeyValue, + IN EFI_IFR_DATA_ARRAY * Data, + OUT EFI_HII_CALLBACK_PACKET **Packet + ); + +typedef struct _EFI_FORM_CALLBACK_PROTOCOL { + EFI_NV_READ NvRead; + EFI_NV_WRITE NvWrite; + EFI_FORM_CALLBACK Callback; +} EFI_FORM_CALLBACK_PROTOCOL; + +extern EFI_GUID gEfiFormCallbackProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.c new file mode 100644 index 0000000000..3ec30730dc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Hii.c + +Abstract: + + This file defines the Human Interface Infrastructure protocol which will + be used by resources which want to publish IFR/Font/String data and have it + collected by the Configuration engine. + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (Hii) + +EFI_GUID gEfiHiiProtocolGuid = EFI_HII_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiHiiProtocolGuid, "Human Interface Infrastructure Protocol", "HII 1.0 protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.h new file mode 100644 index 0000000000..fd6c951653 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Hii/Hii.h @@ -0,0 +1,613 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Hii.h + +Abstract: + + This file defines the Human Interface Infrastructure protocol which will + be used by resources which want to publish IFR/Font/String data and have it + collected by the Configuration engine. + +--*/ + +#ifndef _HII_H_ +#define _HII_H_ + +#include "EfiInternalFormRepresentation.h" +#include EFI_PROTOCOL_DEFINITION (UgaDraw) +#include EFI_PROTOCOL_DEFINITION (GraphicsOutput) + +#define EFI_HII_PROTOCOL_GUID \ + { \ + 0xd7ad636e, 0xb997, 0x459b, 0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 0xe1 \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_HII_PROTOCOL); + +typedef struct _EFI_HII_PROTOCOL EFI_HII_PROTOCOL; + +// +// Global definition +// +#define NARROW_CHAR 0xFFF0 +#define WIDE_CHAR 0xFFF1 +#define NON_BREAKING_CHAR 0xFFF2 +#define GLYPH_WIDTH 8 +#define GLYPH_HEIGHT 19 + +#define EFI_HII_FONT 1 +#define EFI_HII_STRING 2 +#define EFI_HII_IFR 3 +#define EFI_HII_KEYBOARD 4 +#define EFI_HII_HANDLES 5 +#define EFI_HII_VARIABLE 6 +#define EFI_HII_DEVICE_PATH 7 + +#define HANG(foo) { \ + volatile INT32 __iii; \ + __iii = foo; \ + while (__iii) \ + ; \ + } +// +// #define HANG(foo) +// +// References to string tokens must use this macro to enable scanning for +// token usages. +// +#define STRING_TOKEN(t) t + +// +// The following types are currently defined: +// +typedef UINT16 EFI_FORM_ID; +typedef UINT16 EFI_FORM_LABEL; +typedef UINT16 EFI_HII_HANDLE; + +#pragma pack(1) + +typedef struct { + UINT32 Length; + UINT16 Type; +} EFI_HII_PACK_HEADER; + +// +// A form list consists of a large variety of structure +// possibilities so to represent the binary blob of data +// associated with a package of forms, we will assume a +// pointer to a self-describing data buffer. +// +typedef struct { + EFI_HII_PACK_HEADER Header; +} EFI_HII_IFR_PACK; + +typedef struct { + EFI_HII_PACK_HEADER Header; // Must be filled in + EFI_HANDLE ImageHandle; // Must be filled in + EFI_HANDLE DeviceHandle; // Optional + EFI_HANDLE ControllerHandle; // Optional + EFI_HANDLE CallbackHandle; // Optional + EFI_HANDLE COBExportHandle; // Optional +} EFI_HII_HANDLE_PACK; + +// +// ******************************************************** +// EFI_VARIABLE_CONTENTS +// ******************************************************** +// +typedef struct { + EFI_HII_PACK_HEADER Header; + EFI_GUID VariableGuid; + UINT32 VariableNameLength; + UINT16 VariableId; + // + // CHAR16 VariableName[]; //Null-terminated + // +} EFI_HII_VARIABLE_PACK; + +// +// ******************************************************** +// EFI_DEVICE_PATH_PACK +// ******************************************************** +// +typedef struct { + EFI_HII_PACK_HEADER Header; + // + // EFI_DEVICE_PATH DevicePath[]; + // +} EFI_HII_DEVICE_PATH_PACK; + +// +// ******************************************************** +// EFI_HII_DATA_TABLE +// ******************************************************** +// +typedef struct { + EFI_HII_HANDLE HiiHandle; + EFI_GUID PackageGuid; + UINT32 DataTableSize; + UINT32 IfrDataOffset; + UINT32 StringDataOffset; + UINT32 VariableDataOffset; + UINT32 DevicePathOffset; + UINT32 NumberOfVariableData; + UINT32 NumberOfLanguages; + // + // EFI_HII_DEVICE_PATH_PACK DevicePath[]; + // EFI_HII_VARIABLE_PACK VariableData[]; + // EFI_HII_IFR_PACK IfrData; + // EFI_HII_STRING_PACK StringData[]; + // +} EFI_HII_DATA_TABLE; + +// +// ******************************************************** +// EFI_HII_EXPORT_TABLE +// ******************************************************** +// +typedef struct { + UINT16 NumberOfHiiDataTables; + EFI_GUID Revision; + // + // EFI_HII_DATA_TABLE HiiDataTable[]; + // +} EFI_HII_EXPORT_TABLE; + +typedef struct { + BOOLEAN FormSetUpdate; // If TRUE, next variable is significant + EFI_PHYSICAL_ADDRESS FormCallbackHandle; // If not 0, will update Formset with this info + BOOLEAN FormUpdate; // If TRUE, next variable is significant + STRING_REF FormTitle; // If not 0, will update Form with this info + UINT16 DataCount; // The number of Data entries in this structure + UINT8 *Data; // An array of 1+ op-codes, specified by DataCount +} EFI_HII_UPDATE_DATA; + +// +// String attributes +// +#define LANG_RIGHT_TO_LEFT 0x00000001 + +// +// A string package is used to localize strings to a particular +// language. The package is associated with a particular driver +// or set of drivers. Tools are used to associate tokens with +// string references in forms and in programs. These tokens are +// language agnostic. When paired with a language pack (directly +// or indirectly), the string token resolves into an actual +// UNICODE string. The NumStringPointers determines how many +// StringPointers (offset values) there are as well as the total +// number of Strings that are defined. +// +typedef struct { + EFI_HII_PACK_HEADER Header; + RELOFST LanguageNameString; + RELOFST PrintableLanguageName; + UINT32 NumStringPointers; + UINT32 Attributes; + // + // RELOFST StringPointers[]; + // EFI_STRING Strings[]; + // +} EFI_HII_STRING_PACK; + +// +// We use this one to get the real size of the header +// +typedef struct { + EFI_HII_PACK_HEADER Header; + RELOFST LanguageNameString; + RELOFST PrintableLanguageName; + UINT32 NumStringPointers; + UINT32 Attributes; +} EFI_HII_STRING_PACK_HEADER; + +// +// Glyph Attributes +// +#define GLYPH_NON_SPACING 1 +#define GLYPH_NON_BREAKING 2 + +typedef struct { + CHAR16 UnicodeWeight; + UINT8 Attributes; + UINT8 GlyphCol1[GLYPH_HEIGHT]; +} EFI_NARROW_GLYPH; + +typedef struct { + CHAR16 UnicodeWeight; + UINT8 Attributes; + UINT8 GlyphCol1[GLYPH_HEIGHT]; + UINT8 GlyphCol2[GLYPH_HEIGHT]; + UINT8 Pad[3]; +} EFI_WIDE_GLYPH; + +// +// A font list consists of a font header followed by a series +// of glyph structures. Note that fonts are not language specific. +// +typedef struct { + EFI_HII_PACK_HEADER Header; + UINT16 NumberOfNarrowGlyphs; + UINT16 NumberOfWideGlyphs; +} EFI_HII_FONT_PACK; + +// +// The IfrData in the EFI_HII_IFR_PACK structure definition +// is variable length, and not really part of the header. To +// simplify from code the size of the header, define an +// identical structure that does not include the IfrData field. +// Then use sizeof() this new structure to determine the +// actual size of the header. +// +typedef struct { + EFI_HII_PACK_HEADER Header; +} EFI_HII_IFR_PACK_HEADER; + +// +// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER; +// +typedef enum { + EfiKeyLCtrl, + EfiKeyA0, + EfiKeyLAlt, + EfiKeySpaceBar, + EfiKeyA2, + EfiKeyA3, + EfiKeyA4, + EfiKeyRCtrl, + EfiKeyLeftArrow, + EfiKeyDownArrow, + EfiKeyRightArrow, + EfiKeyZero, + EfiKeyPeriod, + EfiKeyEnter, + EfiKeyLShift, + EfiKeyB0, + EfiKeyB1, + EfiKeyB2, + EfiKeyB3, + EfiKeyB4, + EfiKeyB5, + EfiKeyB6, + EfiKeyB7, + EfiKeyB8, + EfiKeyB9, + EfiKeyB10, + EfiKeyRshift, + EfiKeyUpArrow, + EfiKeyOne, + EfiKeyTwo, + EfiKeyThree, + EfiKeyCapsLock, + EfiKeyC1, + EfiKeyC2, + EfiKeyC3, + EfiKeyC4, + EfiKeyC5, + EfiKeyC6, + EfiKeyC7, + EfiKeyC8, + EfiKeyC9, + EfiKeyC10, + EfiKeyC11, + EfiKeyC12, + EfiKeyFour, + EfiKeyFive, + EfiKeySix, + EfiKeyPlus, + EfiKeyTab, + EfiKeyD1, + EfiKeyD2, + EfiKeyD3, + EfiKeyD4, + EfiKeyD5, + EfiKeyD6, + EfiKeyD7, + EfiKeyD8, + EfiKeyD9, + EfiKeyD10, + EfiKeyD11, + EfiKeyD12, + EfiKeyD13, + EfiKeyDel, + EfiKeyEnd, + EfiKeyPgDn, + EfiKeySeven, + EfiKeyEight, + EfiKeyNine, + EfiKeyE0, + EfiKeyE1, + EfiKeyE2, + EfiKeyE3, + EfiKeyE4, + EfiKeyE5, + EfiKeyE6, + EfiKeyE7, + EfiKeyE8, + EfiKeyE9, + EfiKeyE10, + EfiKeyE11, + EfiKeyE12, + EfiKeyBackSpace, + EfiKeyIns, + EfiKeyHome, + EfiKeyPgUp, + EfiKeyNLck, + EfiKeySlash, + EfiKeyAsterisk, + EfiKeyMinus, + EfiKeyEsc, + EfiKeyF1, + EfiKeyF2, + EfiKeyF3, + EfiKeyF4, + EfiKeyF5, + EfiKeyF6, + EfiKeyF7, + EfiKeyF8, + EfiKeyF9, + EfiKeyF10, + EfiKeyF11, + EfiKeyF12, + EfiKeyPrint, + EfiKeySLck, + EfiKeyPause +} EFI_KEY; + +typedef struct { + EFI_KEY Key; + CHAR16 Unicode; + CHAR16 ShiftedUnicode; + CHAR16 AltGrUnicode; + CHAR16 ShiftedAltGrUnicode; + UINT16 Modifier; +} EFI_KEY_DESCRIPTOR; + +// +// This structure allows a sparse set of keys to be redefined +// or a complete redefinition of the keyboard layout. Most +// keyboards have a lot of commonality in their layouts, therefore +// only defining those keys that need to change from the default +// minimizes the passed in information. +// +// Additionally, when an update occurs, the active keyboard layout +// will be switched to the newly updated keyboard layout. This +// allows for situations that when a keyboard layout driver is +// loaded as part of system initialization, the system will default +// the keyboard behavior to the new layout. +// +// Each call to update the keyboard mapping should contain the +// complete set of key descriptors to be updated, since every +// call to the HII which contains an EFI_HII_KEYBOARD_PACK will +// wipe the previous set of overrides. A call to +// +typedef struct { + EFI_HII_PACK_HEADER Header; + EFI_KEY_DESCRIPTOR *Descriptor; + UINT8 DescriptorCount; +} EFI_HII_KEYBOARD_PACK; + +// +// The EFI_HII_PACKAGES can contain different types of packages just +// after the structure as inline data. +// +typedef struct { + UINTN NumberOfPackages; + EFI_GUID *GuidId; + // + // EFI_HII_HANDLE_PACK *HandlePack; // Only one pack. + // EFI_HII_IFR_PACK *IfrPack; // Only one pack. + // EFI_HII_FONT_PACK *FontPack[]; // Multiple packs ok + // EFI_HII_STRING_PACK *StringPack[]; // Multiple packs ok + // EFI_HII_KEYBOARD_PACK *KeyboardPack[]; // Multiple packs ok + // +} EFI_HII_PACKAGES; + +typedef struct _EFI_HII_VARIABLE_PACK_LIST { + struct _EFI_HII_VARIABLE_PACK_LIST *NextVariablePack; + EFI_HII_VARIABLE_PACK *VariablePack; +} EFI_HII_VARIABLE_PACK_LIST; + +#pragma pack() + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_NEW_PACK) ( + IN EFI_HII_PROTOCOL * This, + IN EFI_HII_PACKAGES * Packages, + OUT EFI_HII_HANDLE * Handle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_REMOVE_PACK) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_FIND_HANDLES) ( + IN EFI_HII_PROTOCOL *This, + IN OUT UINT16 *HandleBufferLength, + OUT EFI_HII_HANDLE *Handle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_EXPORT) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_RESET_STRINGS) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_TEST_STRING) ( + IN EFI_HII_PROTOCOL *This, + IN CHAR16 *StringToTest, + IN OUT UINT32 *FirstMissing, + OUT UINT32 *GlyphBufferSize + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_GLYPH) ( + IN EFI_HII_PROTOCOL *This, + IN CHAR16 *Source, + IN OUT UINT16 *Index, + OUT UINT8 **GlyphBuffer, + OUT UINT16 *BitWidth, + IN OUT UINT32 *InternalStatus + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GLYPH_TO_BLT) ( + IN EFI_HII_PROTOCOL *This, + IN UINT8 *GlyphBuffer, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background, + IN UINTN Count, + IN UINTN Width, + IN UINTN Height, + IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_NEW_STRING) ( + IN EFI_HII_PROTOCOL *This, + IN CHAR16 *Language, + IN EFI_HII_HANDLE Handle, + IN OUT STRING_REF *Reference, + IN CHAR16 *NewString + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + OUT EFI_STRING *LanguageString + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN CHAR16 *PrimaryLanguage, + OUT EFI_STRING *LanguageString + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_STRING) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN STRING_REF Token, + IN BOOLEAN Raw, + IN CHAR16 *LanguageString, + IN OUT UINTN *BufferLength, + OUT EFI_STRING StringBuffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_LINE) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN STRING_REF Token, + IN OUT UINT16 *Index, + IN UINT16 LineWidth, + IN CHAR16 *LanguageString, + IN OUT UINT16 *BufferLength, + OUT EFI_STRING StringBuffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_FORMS) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN EFI_FORM_ID FormId, + IN OUT UINTN *BufferLength, + OUT UINT8 *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN UINTN DefaultMask, + OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_UPDATE_FORM) ( + IN EFI_HII_PROTOCOL *This, + IN EFI_HII_HANDLE Handle, + IN EFI_FORM_LABEL Label, + IN BOOLEAN AddData, + IN EFI_HII_UPDATE_DATA *Data + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) ( + IN EFI_HII_PROTOCOL * This, + OUT UINT16 *DescriptorCount, + OUT EFI_KEY_DESCRIPTOR * Descriptor + ); + +typedef struct _EFI_HII_PROTOCOL { + EFI_HII_NEW_PACK NewPack; + EFI_HII_REMOVE_PACK RemovePack; + EFI_HII_FIND_HANDLES FindHandles; + EFI_HII_EXPORT ExportDatabase; + + EFI_HII_TEST_STRING TestString; + EFI_HII_GET_GLYPH GetGlyph; + EFI_HII_GLYPH_TO_BLT GlyphToBlt; + + EFI_HII_NEW_STRING NewString; + EFI_HII_GET_PRI_LANGUAGES GetPrimaryLanguages; + EFI_HII_GET_SEC_LANGUAGES GetSecondaryLanguages; + EFI_HII_GET_STRING GetString; + EFI_HII_RESET_STRINGS ResetStrings; + EFI_HII_GET_LINE GetLine; + EFI_HII_GET_FORMS GetForms; + EFI_HII_GET_DEFAULT_IMAGE GetDefaultImage; + EFI_HII_UPDATE_FORM UpdateForm; + + EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout; +} EFI_HII_PROTOCOL; + +extern EFI_GUID gEfiHiiProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c new file mode 100644 index 0000000000..b7c8ae9ddc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IdeControllerInit.c + +Abstract: + + EFI IDE Controller Init Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (IdeControllerInit) + +EFI_GUID gEfiIdeControllerInitProtocolGuid = EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiIdeControllerInitProtocolGuid, "IDE Controller Init Protocol", "Platform IDE Init Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h new file mode 100644 index 0000000000..06df0192c5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h @@ -0,0 +1,348 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IdeControllerInit.h + +Abstract: + + EFI Platform IDE Init Protocol + +Revision History + + 0.01 - Draft, 5-01-2002 + Add Atapi6 Identify structure definition, 8-14-2002 + +--*/ + +#ifndef _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H +#define _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H + +// +// Global ID for the EFI Platform IDE Protocol GUID +// +#define EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID \ + { 0xa1e37052, 0x80d9, 0x4e65, 0xa3, 0x17, 0x3e, 0x9a, 0x55, 0xc4, 0x3e, 0xc9 } + +//////////////////////////////////////////////////////////////////////////////////////// +// Forward reference, ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_IDE_CONTROLLER_INIT_PROTOCOL); + +// +////////////////////////////////////////////////////////////////////////////////////////// +// EFI_IDE_BUS_ENUMERATION_PHASE +// EFI_IDE_CONTROLLER_ENUM_PHASE +// +typedef enum{ + EfiIdeBeforeChannelEnumeration, + EfiIdeAfterChannelEnumeration, + EfiIdeBeforeChannelReset, + EfiIdeAfterChannelReset, + EfiIdeBusBeforeDevicePresenceDetection, + EfiIdeBusAfterDevicePresenceDetection, + EfiIdeResetMode, + EfiIdeBusPhaseMaximum +} EFI_IDE_CONTROLLER_ENUM_PHASE; + +// +//****************************************************** +// EFI_ATA_EXT_TRANSFER_PROTOCOL +//****************************************************** +// +// This extended mode describes the SATA physical protocol. +// SATA physical layers can operate at different speeds. +// These speeds are defined below. Various PATA protocols +// and associated modes are not applicable to SATA devices. +// + +typedef enum { + EfiAtaSataTransferProtocol +} EFI_ATA_EXT_TRANSFER_PROTOCOL; + +#define EFI_SATA_AUTO_SPEED 0 +#define EFI_SATA_GEN1_SPEED 1 +#define EFI_SATA_GEN2_SPEED 2 + +// +//******************************************************* +// EFI_IDE_CABLE_TYPE +//******************************************************* +// +typedef enum { + EfiIdeCableTypeUnknown, + EfiIdeCableType40pin, + EfiIdeCableType80Pin, + EfiIdeCableTypeSerial, + EfiIdeCableTypeMaximum +} EFI_IDE_CABLE_TYPE; + +// +//****************************************************** +// EFI_ATA_MODE +//****************************************************** +// +typedef struct { + BOOLEAN Valid; + UINT32 Mode; +} EFI_ATA_MODE; + +// +//****************************************************** +// EFI_ATA_EXTENDED_MODE +//****************************************************** +// +typedef struct { + EFI_ATA_EXT_TRANSFER_PROTOCOL TransferProtocol; + UINT32 Mode; +} EFI_ATA_EXTENDED_MODE; + +// +//****************************************************** +// EFI_ATA_COLLECTIVE_MODE +//****************************************************** +// +typedef struct { + EFI_ATA_MODE PioMode; + EFI_ATA_MODE SingleWordDmaMode; + EFI_ATA_MODE MultiWordDmaMode; + EFI_ATA_MODE UdmaMode; + UINT32 ExtModeCount; + EFI_ATA_EXTENDED_MODE ExtMode[1]; +} EFI_ATA_COLLECTIVE_MODE; + +// +//******************************************************* +// EFI_ATA_IDENTIFY_DATA +//******************************************************* +// + +#pragma pack(1) + +typedef struct { + UINT16 config; // General Configuration + UINT16 cylinders; // Number of Cylinders + UINT16 reserved_2; + UINT16 heads; //Number of logical heads + UINT16 vendor_data1; + UINT16 vendor_data2; + UINT16 sectors_per_track; + UINT16 vendor_specific_7_9[3]; + CHAR8 SerialNo[20]; // ASCII + UINT16 vendor_specific_20_21[2]; + UINT16 ecc_bytes_available; + CHAR8 FirmwareVer[8]; // ASCII + CHAR8 ModelName[40]; // ASCII + UINT16 multi_sector_cmd_max_sct_cnt; + UINT16 reserved_48; + UINT16 capabilities; + UINT16 reserved_50; + UINT16 pio_cycle_timing; + UINT16 reserved_52; + UINT16 field_validity; + UINT16 current_cylinders; + UINT16 current_heads; + UINT16 current_sectors; + UINT16 CurrentCapacityLsb; + UINT16 CurrentCapacityMsb; + UINT16 reserved_59; + UINT16 user_addressable_sectors_lo; + UINT16 user_addressable_sectors_hi; + UINT16 reserved_62; + UINT16 multi_word_dma_mode; + UINT16 advanced_pio_modes; + UINT16 min_multi_word_dma_cycle_time; + UINT16 rec_multi_word_dma_cycle_time; + UINT16 min_pio_cycle_time_without_flow_control; + UINT16 min_pio_cycle_time_with_flow_control; + UINT16 reserved_69_79[11]; + UINT16 major_version_no; + UINT16 minor_version_no; + UINT16 command_set_supported_82; // word 82 + UINT16 command_set_supported_83; // word 83 + UINT16 command_set_feature_extn; // word 84 + UINT16 command_set_feature_enb_85; // word 85 + UINT16 command_set_feature_enb_86; // word 86 + UINT16 command_set_feature_default; // word 87 + UINT16 ultra_dma_mode; // word 88 + UINT16 reserved_89_127[39]; + UINT16 security_status; + UINT16 vendor_data_129_159[31]; + UINT16 reserved_160_255[96]; +} EFI_ATA_IDENTIFY_DATA; + +#pragma pack() +// +//******************************************************* +// EFI_ATAPI_IDENTIFY_DATA +//******************************************************* +// +#pragma pack(1) +typedef struct { + UINT16 config; // General Configuration + UINT16 obsolete_1; + UINT16 specific_config; + UINT16 obsolete_3; + UINT16 retired_4_5[2]; + UINT16 obsolete_6; + UINT16 cfa_reserved_7_8[2]; + UINT16 retired_9; + CHAR8 SerialNo[20]; // ASCII + UINT16 retired_20_21[2]; + UINT16 obsolete_22; + CHAR8 FirmwareVer[8]; // ASCII + CHAR8 ModelName[40]; // ASCII + UINT16 multi_sector_cmd_max_sct_cnt; + UINT16 reserved_48; + UINT16 capabilities_49; + UINT16 capabilities_50; + UINT16 obsolete_51_52[2]; + UINT16 field_validity; + UINT16 obsolete_54_58[5]; + UINT16 mutil_sector_setting; + UINT16 user_addressable_sectors_lo; + UINT16 user_addressable_sectors_hi; + UINT16 obsolete_62; + UINT16 multi_word_dma_mode; + UINT16 advanced_pio_modes; + UINT16 min_multi_word_dma_cycle_time; + UINT16 rec_multi_word_dma_cycle_time; + UINT16 min_pio_cycle_time_without_flow_control; + UINT16 min_pio_cycle_time_with_flow_control; + UINT16 reserved_69_74[6]; + UINT16 queue_depth; + UINT16 reserved_76_79[4]; + UINT16 major_version_no; + UINT16 minor_version_no; + UINT16 cmd_set_support_82; + UINT16 cmd_set_support_83; + UINT16 cmd_feature_support; + UINT16 cmd_feature_enable_85; + UINT16 cmd_feature_enable_86; + UINT16 cmd_feature_default; + UINT16 ultra_dma_select; + UINT16 time_required_for_sec_erase; + UINT16 time_required_for_enhanced_sec_erase; + UINT16 current_advanced_power_mgmt_value; + UINT16 master_pwd_revison_code; + UINT16 hardware_reset_result; + UINT16 current_auto_acoustic_mgmt_value; + UINT16 reserved_95_99[5]; + UINT16 max_user_lba_for_48bit_addr[4]; + UINT16 reserved_104_126[23]; + UINT16 removable_media_status_notification_support; + UINT16 security_status; + UINT16 vendor_data_129_159[31]; + UINT16 cfa_power_mode; + UINT16 cfa_reserved_161_175[15]; + UINT16 current_media_serial_no[30]; + UINT16 reserved_206_254[49]; + UINT16 integrity_word; +} EFI_ATAPI_IDENTIFY_DATA; + +#pragma pack() +// +//******************************************************* +// EFI_IDENTIFY_DATA +//******************************************************* +// +typedef union { + EFI_ATA_IDENTIFY_DATA AtaData; + EFI_ATAPI_IDENTIFY_DATA AtapiData; +} EFI_IDENTIFY_DATA; + +#define EFI_ATAPI_DEVICE_IDENTIFY_DATA 0x8000 + +// +///////////////////////////////////////////////////////////////////////////////////////// +// Function prototype declaration, for ANSI compatability +// +typedef +EFI_STATUS +(EFIAPI *EFI_IDE_CONTROLLER_GET_CHANNEL_INFO) ( + IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, + IN UINT8 Channel, + OUT BOOLEAN *Enabled, + OUT UINT8 *MaxDevices + +); + +typedef +EFI_STATUS +(EFIAPI *EFI_IDE_CONTROLLER_NOTIFY_PHASE) ( + IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, + IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase, + IN UINT8 Channel +); + +typedef +EFI_STATUS +(EFIAPI *EFI_IDE_CONTROLLER_SUBMIT_DATA) ( + IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, + IN UINT8 Channel, + IN UINT8 Device, + IN EFI_IDENTIFY_DATA *IdentifyData +); + + +typedef +EFI_STATUS +(EFIAPI *EFI_IDE_CONTROLLER_DISQUALIFY_MODE) ( + IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, + IN UINT8 Channel, + IN UINT8 Device, + IN EFI_ATA_COLLECTIVE_MODE *BadModes +); + +typedef +EFI_STATUS +(EFIAPI *EFI_IDE_CONTROLLER_CALCULATE_MODE) ( + IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, + IN UINT8 Channel, + IN UINT8 Device, + OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes +); + +// +// ?? What happen to EFI_IDE_CONTROLLER_SET_TIMING ??? +// +typedef +EFI_STATUS +(EFIAPI *EFI_IDE_CONTROLLER_SET_TIMING) ( + IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, + IN UINT8 Channel, + IN UINT8 Device, + IN EFI_ATA_COLLECTIVE_MODE *Modes +); + +// +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Interface structure +// EFI_IDE_CONTROLLER_INIT_PROTOCOL protocol provides the chipset specific information to the IDE bus driver. +// An IDE Bus driver wants to manage an IDE bus and possible IDE devices will have to retrieve the +// EFI_IDE_CONTROLLER_INIT_PROTOCOL instances. +// +typedef struct _EFI_IDE_CONTROLLER_INIT_PROTOCOL { + EFI_IDE_CONTROLLER_GET_CHANNEL_INFO GetChannelInfo; + EFI_IDE_CONTROLLER_NOTIFY_PHASE NotifyPhase; + EFI_IDE_CONTROLLER_SUBMIT_DATA SubmitData; + EFI_IDE_CONTROLLER_DISQUALIFY_MODE DisqualifyMode; + EFI_IDE_CONTROLLER_CALCULATE_MODE CalculateMode; + EFI_IDE_CONTROLLER_SET_TIMING SetTiming; + BOOLEAN EnumAll; + UINT8 ChannelCount; +} EFI_IDE_CONTROLLER_INIT_PROTOCOL; + + +extern EFI_GUID gEfiIdeControllerInitProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c new file mode 100644 index 0000000000..85ad37bd7e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IncompatiblePciDeviceSupport.c + +Abstract: + + EFI Incompatible PCI Device Support Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (IncompatiblePciDeviceSupport) + +EFI_GUID gEfiIncompatiblePciDeviceSupportProtocolGuid = EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiIncompatiblePciDeviceSupportProtocolGuid, "Incompatible PCI Device Support Protocol", + "Tiano Incompatible PCI Device Support Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h new file mode 100644 index 0000000000..01179e8bdb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h @@ -0,0 +1,55 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IncompatiblePciDeviceSupport.h + +Abstract: + + EFI Incompatible PCI Device Support Protocol + +Revision History + +--*/ + +#ifndef _INCOMPATIBLE_PCI_DEVICE_SUPPORT_H_ +#define _INCOMPATIBLE_PCI_DEVICE_SUPPORT_H_ + +#define EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL_GUID \ + {0xeb23f55a, 0x7863, 0x4ac2, 0x8d, 0x3d, 0x95, 0x65, 0x35, 0xde, 0x03, 0x75} + +EFI_FORWARD_DECLARATION (EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT); + + +typedef +EFI_STATUS +(EFIAPI *EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_CHECK_DEVICE) ( + IN EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT *This, + IN UINTN VendorId, + IN UINTN DeviceId, + IN UINTN Revision, + IN UINTN SubVendorId,OPTIONAL + IN UINTN SubDeviceId,OPTIONAL + OUT VOID *Configuration +); + + +// +// Interface structure for the Incompatible PCI Device Support Protocol +// +typedef struct _EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT { + EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_CHECK_DEVICE CheckDevice; +} EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL; + +extern EFI_GUID gEfiIncompatiblePciDeviceSupportProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c new file mode 100644 index 0000000000..bd67460f45 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Legacy8259.c + +Abstract: + + EFI Legacy Region Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (Legacy8259) + +EFI_GUID gEfiLegacy8259ProtocolGuid = EFI_LEGACY_8259_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLegacy8259ProtocolGuid, "Legacy 8259 Protocol", "Legacy 8259 Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h new file mode 100644 index 0000000000..3b7c826e38 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h @@ -0,0 +1,317 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Legacy8259.h + +Abstract: + + This protocol abstracts the 8259 interrupt controller. This includes + PCI IRQ routing need to program the PCI Interrupt Line register. + +Revision History + + The EFI Legacy 8259 Protocol is compliant with CSM spec 0.96. + +--*/ + +#ifndef _EFI_LEGACY_8259_H +#define _EFI_LEGACY_8259_H + +#define EFI_LEGACY_8259_PROTOCOL_GUID \ + { \ + 0x38321dba, 0x4fe0, 0x4e17, 0x8a, 0xec, 0x41, 0x30, 0x55, 0xea, 0xed, 0xc1 \ + } + +EFI_FORWARD_DECLARATION (EFI_LEGACY_8259_PROTOCOL); + +typedef enum { + Efi8259Irq0, + Efi8259Irq1, + Efi8259Irq2, + Efi8259Irq3, + Efi8259Irq4, + Efi8259Irq5, + Efi8259Irq6, + Efi8259Irq7, + Efi8259Irq8, + Efi8259Irq9, + Efi8259Irq10, + Efi8259Irq11, + Efi8259Irq12, + Efi8259Irq13, + Efi8259Irq14, + Efi8259Irq15, + Efi8259IrqMax +} EFI_8259_IRQ; + +typedef enum { + Efi8259LegacyMode, + Efi8259ProtectedMode, + Efi8259MaxMode +} EFI_8259_MODE; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_SET_VECTOR_BASE) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN UINT8 MasterBase, + IN UINT8 SlaveBase + ) +/*++ + + Routine Description: + Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for + the legacy mode mask and the protected mode mask. The base address for the 8259 + is different for legacy and protected mode, so two masks are required. + + Arguments: + This - Protocol instance pointer. + MasterBase - The base vector for the Master PIC in the 8259 controller + Slavebase - The base vector for the Master PIC in the 8259 controller + + Returns: + EFI_SUCCESS - The new bases were programmed + EFI_DEVICE_ERROR - A device erro occured programming the vector bases + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_GET_MASK) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + OUT UINT16 *LegacyMask, OPTIONAL + OUT UINT16 *LegacyEdgeLevel, OPTIONAL + OUT UINT16 *ProtectedMask, OPTIONAL + OUT UINT16 *ProtectedEdgeLevel OPTIONAL + ) +/*++ + + Routine Description: + Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for + the legacy mode mask and the protected mode mask. The base address for the 8259 + is different for legacy and protected mode, so two masks are required. + + Arguments: + This - Protocol instance pointer. + LegacyMask - Bit 0 is Irq0 - Bit 15 is Irq15 + LegacyEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15 + ProtectedMask - Bit 0 is Irq0 - Bit 15 is Irq15 + ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15 + + Returns: + EFI_SUCCESS - 8259 status returned + EFI_DEVICE_ERROR - Error reading 8259 + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_SET_MASK) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN UINT16 *LegacyMask, OPTIONAL + IN UINT16 *LegacyEdgeLevel, OPTIONAL + IN UINT16 *ProtectedMask, OPTIONAL + IN UINT16 *ProtectedEdgeLevel OPTIONAL + ) +/*++ + + Routine Description: + Set the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for + the legacy mode mask and the protected mode mask. The base address for the 8259 + is different for legacy and protected mode, so two masks are required. + Also set the edge/level masks. + + Arguments: + This - Protocol instance pointer. + LegacyMask - Bit 0 is Irq0 - Bit 15 is Irq15 + LegacyEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15 + ProtectedMask - Bit 0 is Irq0 - Bit 15 is Irq15 + ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15 + + Returns: + EFI_SUCCESS - 8259 status returned + EFI_DEVICE_ERROR - Error reading 8259 + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_SET_MODE) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN EFI_8259_MODE Mode, + IN UINT16 *Mask, OPTIONAL + IN UINT16 *EdgeLevel OPTIONAL + ) +/*++ + + Routine Description: + Set the 8259 mode of operation. The base address for the 8259 is different for + legacy and protected mode. The legacy mode requires the master 8259 to have a + master base of 0x08 and the slave base of 0x70. The protected mode base locations + are not defined. Interrupts must be masked by the caller before this function + is called. The interrupt mask from the current mode is saved. The interrupt + mask for the new mode is Mask, or if Mask does not exist the previously saved + mask is used. + + + Arguments: + This - Protocol instance pointer. + Mode - Mode of operation. i.e. real mode or protected mode + Mask - Optional interupt mask for the new mode. + EdgeLevel - Optional trigger mask for the new mode. + + Returns: + EFI_SUCCESS - 8259 programmed + EFI_DEVICE_ERROR - Error writting to 8259 + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_GET_VECTOR) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN EFI_8259_IRQ Irq, + OUT UINT8 *Vector + ) +/*++ + + Routine Description: + Convert from IRQ to processor interrupt vector number. + + Arguments: + This - Protocol instance pointer. + Irq - 8259 IRQ0 - IRQ15 + Vector - Processor vector number that matches Irq + + Returns: + EFI_SUCCESS - The Vector matching Irq is returned + EFI_INVALID_PARAMETER - Irq not valid + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_ENABLE_IRQ) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN EFI_8259_IRQ Irq, + IN BOOLEAN LevelTriggered + ) +/*++ + + Routine Description: + Enable Irq by unmasking interrupt in 8259 + + Arguments: + This - Protocol instance pointer. + Irq - 8259 IRQ0 - IRQ15 + LevelTriggered - TRUE if level triggered. FALSE if edge triggered. + + Returns: + EFI_SUCCESS - Irq enabled on 8259 + EFI_INVALID_PARAMETER - Irq not valid + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_DISABLE_IRQ) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN EFI_8259_IRQ Irq + ) +/*++ + + Routine Description: + Disable Irq by masking interrupt in 8259 + + Arguments: + This - Protocol instance pointer. + Irq - 8259 IRQ0 - IRQ15 + + Returns: + EFI_SUCCESS - Irq disabled on 8259 + EFI_INVALID_PARAMETER - Irq not valid + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_GET_INTERRUPT_LINE) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN EFI_HANDLE PciHandle, + OUT UINT8 *Vector + ) +/*++ + + Routine Description: + PciHandle represents a PCI config space of a PCI function. Vector + represents Interrupt Pin (from PCI config space) and it is the data + that is programmed into the Interrupt Line (from the PCI config space) + register. + + Arguments: + This - Protocol instance pointer. + PciHandle - PCI function to return vector for + Vector - Vector for fucntion that matches + + Returns: + EFI_SUCCESS - A valid Vector is returned + EFI_INVALID_PARAMETER - PciHandle not valid + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_8259_END_OF_INTERRUPT) ( + IN EFI_LEGACY_8259_PROTOCOL * This, + IN EFI_8259_IRQ Irq + ) +/*++ + + Routine Description: + Send an EOI to 8259 + + Arguments: + This - Protocol instance pointer. + Irq - 8259 IRQ0 - IRQ15 + + Returns: + EFI_SUCCESS - EOI successfully sent to 8259 + EFI_INVALID_PARAMETER - Irq not valid + +--*/ +; + +typedef struct _EFI_LEGACY_8259_PROTOCOL { + EFI_LEGACY_8259_SET_VECTOR_BASE SetVectorBase; + EFI_LEGACY_8259_GET_MASK GetMask; + EFI_LEGACY_8259_SET_MASK SetMask; + EFI_LEGACY_8259_SET_MODE SetMode; + EFI_LEGACY_8259_GET_VECTOR GetVector; + EFI_LEGACY_8259_ENABLE_IRQ EnableIrq; + EFI_LEGACY_8259_DISABLE_IRQ DisableIrq; + EFI_LEGACY_8259_GET_INTERRUPT_LINE GetInterruptLine; + EFI_LEGACY_8259_END_OF_INTERRUPT EndOfInterrupt; +} EFI_LEGACY_8259_PROTOCOL; + +extern EFI_GUID gEfiLegacy8259ProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c new file mode 100644 index 0000000000..b0bdb3276a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LegacyBios.c + +Abstract: + + EFI Legacy BIOS Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (LegacyBios) + +EFI_GUID gEfiLegacyBiosProtocolGuid = EFI_LEGACY_BIOS_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLegacyBiosProtocolGuid, "Legacy BIOS Protocol", "Legacy BIOS Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h new file mode 100644 index 0000000000..11b1c24c05 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h @@ -0,0 +1,701 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LegacyBios.h + +Abstract: + + The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage + under EFI and Legacy OS boot. + + Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow + well known naming conventions. + + Thunk - A thunk is a transition from one processor mode to another. A Thunk + is a transition from native EFI mode to 16-bit mode. A reverse thunk + would be a transition from 16-bit mode to native EFI mode. + + + Note: Note: Note: Note: Note: Note: Note: + + You most likely should not use this protocol! Find the EFI way to solve the + problem to make your code portable + + Note: Note: Note: Note: Note: Note: Note: + +Revision History + + The EFI Legacy BIOS Protocol is compliant with CSM spec 0.96. + +--*/ + +#ifndef _EFI_LEGACY_BIOS_H +#define _EFI_LEGACY_BIOS_H + +#define EFI_LEGACY_BIOS_PROTOCOL_GUID \ + { \ + 0xdb9a1e3d, 0x45cb, 0x4abb, 0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d \ + } + +EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_PROTOCOL); + +// +// Convert from 32-bit address (_Adr) to Segment:Offset 16-bit form +// +#define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000) +#define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff) +#define BYTE_GRANULARITY 0x01 +#define WORD_GRANULARITY 0x02 +#define DWORD_GRANULARITY 0x04 +#define QWORD_GRANULARITY 0x08 +#define PARAGRAPH_GRANULARITY 0x10 + +#define CARRY_FLAG 0x01 + +typedef struct { + UINT32 CF:1; + UINT32 Reserved1:1; + UINT32 PF:1; + UINT32 Reserved2:1; + UINT32 AF:1; + UINT32 Reserved3:1; + UINT32 ZF:1; + UINT32 SF:1; + UINT32 TF:1; + UINT32 IF:1; + UINT32 DF:1; + UINT32 OF:1; + UINT32 IOPL:2; + UINT32 NT:1; + UINT32 Reserved4:2; + UINT32 VM:1; + UINT32 Reserved5:14; +} EFI_EFLAGS_REG; + +typedef struct { + UINT16 CF : 1; + UINT16 Reserved1 : 1; + UINT16 PF : 1; + UINT16 Reserved2 : 1; + UINT16 AF : 1; + UINT16 Reserved3 : 1; + UINT16 ZF : 1; + UINT16 SF : 1; + UINT16 TF : 1; + UINT16 IF : 1; + UINT16 DF : 1; + UINT16 OF : 1; + UINT16 IOPL : 2; + UINT16 NT : 1; + UINT16 Reserved4 : 1; +} EFI_FLAGS_REG; + +typedef struct { + UINT32 EAX; + UINT32 EBX; + UINT32 ECX; + UINT32 EDX; + UINT32 ESI; + UINT32 EDI; + EFI_EFLAGS_REG EFlags; + UINT16 ES; + UINT16 CS; + UINT16 SS; + UINT16 DS; + UINT16 FS; + UINT16 GS; + UINT32 EBP; + UINT32 ESP; +} EFI_DWORD_REGS; + +typedef struct { + UINT16 AX; + UINT16 ReservedAX; + UINT16 BX; + UINT16 ReservedBX; + UINT16 CX; + UINT16 ReservedCX; + UINT16 DX; + UINT16 ReservedDX; + UINT16 SI; + UINT16 ReservedSI; + UINT16 DI; + UINT16 ReservedDI; + EFI_FLAGS_REG Flags; + UINT16 ReservedFlags; + UINT16 ES; + UINT16 CS; + UINT16 SS; + UINT16 DS; + UINT16 FS; + UINT16 GS; + UINT16 BP; + UINT16 ReservedBP; + UINT16 SP; + UINT16 ReservedSP; +} EFI_WORD_REGS; + +typedef struct { + UINT8 AL; + UINT8 AH; + UINT16 ReservedAX; + UINT8 BL; + UINT8 BH; + UINT16 ReservedBX; + UINT8 CL; + UINT8 CH; + UINT16 ReservedCX; + UINT8 DL; + UINT8 DH; + UINT16 ReservedDX; +} EFI_BYTE_REGS; + +typedef union { + EFI_DWORD_REGS E; + EFI_WORD_REGS X; + EFI_BYTE_REGS H; +} EFI_IA32_REGISTER_SET; + +#pragma pack(1) +// +// $EFI table created by Legacy16 code and consumed by EFI Legacy driver +// +typedef struct { + UINT32 Signature; // "$EFI" + UINT8 TableChecksum; + UINT8 TableLength; + UINT8 EfiMajorRevision; + UINT8 EfiMinorRevision; + UINT8 TableMajorRevision; + UINT8 TableMinorRevision; + UINT16 Reserved; + UINT16 Compatibility16CallSegment; + UINT16 Compatibility16CallOffset; + + UINT16 PnPInstallationCheckSegment; + UINT16 PnPInstallationCheckOffset; + + UINT32 EfiSystemTable; // IPF - CSM Integration + UINT32 OemIdStringPointer; + UINT32 AcpiRsdPtrPointer; + UINT16 OemRevision; + UINT32 E820Pointer; + UINT32 E820Length; + UINT32 IrqRoutingTablePointer; + UINT32 IrqRoutingTableLength; + UINT32 MpTablePtr; + UINT32 MpTableLength; + UINT16 OemIntSegment; + UINT16 OemIntOffset; + UINT16 Oem32Segment; + UINT16 Oem32Offset; + UINT16 Oem16Segment; + UINT16 Oem16Offset; + UINT16 TpmSegment; + UINT16 TpmOffset; + UINT32 IbvPointer; + UINT32 PciExpressBase; + UINT8 LastPciBus; + +} EFI_COMPATIBILITY16_TABLE; +// +// define maximum number of HDD system supports +// +#define MAX_HDD_ENTRIES 0x30 + +typedef struct { + UINT16 Raw[256]; +} ATAPI_IDENTIFY; + +// +// HDD_INFO status +// +#define HDD_PRIMARY 0x01 +#define HDD_SECONDARY 0x02 +#define HDD_MASTER_ATAPI_CDROM 0x04 +#define HDD_SLAVE_ATAPI_CDROM 0x08 +#define HDD_MASTER_IDE 0x20 +#define HDD_SLAVE_IDE 0x40 +#define HDD_MASTER_ATAPI_ZIPDISK 0x10 +#define HDD_SLAVE_ATAPI_ZIPDISK 0x80 + +typedef struct { + UINT16 Status; + UINT32 Bus; + UINT32 Device; + UINT32 Function; + UINT16 CommandBaseAddress; + UINT16 ControlBaseAddress; + UINT16 BusMasterAddress; + UINT8 HddIrq; + ATAPI_IDENTIFY IdentifyDrive[2]; +} HDD_INFO; + +// +// Parties data structures +// +typedef struct { + UINT8 DirectoryServiceValidity : 1; + UINT8 RabcaUsedFlag : 1; + UINT8 ExecuteHddDiagnosticsFlag : 1; + UINT8 Reserved : 5; +} UDC_ATTRIBUTES; + +typedef struct { + UDC_ATTRIBUTES Attributes; + UINT8 DeviceNumber; + UINT8 BbsTableEntryNumberForParentDevice; + UINT8 BbsTableEntryNumberForBoot; + UINT8 BbsTableEntryNumberForHddDiag; + UINT8 BeerData[128]; + UINT8 ServiceAreaData[64]; +} UD_TABLE; + +// +// define BBS Device Types +// +#define BBS_FLOPPY 0x01 +#define BBS_HARDDISK 0x02 +#define BBS_CDROM 0x03 +#define BBS_PCMCIA 0x04 +#define BBS_USB 0x05 +#define BBS_EMBED_NETWORK 0x06 +#define BBS_BEV_DEVICE 0x80 +#define BBS_UNKNOWN 0xff + +typedef struct { + UINT16 OldPosition : 4; + UINT16 Reserved1 : 4; + UINT16 Enabled : 1; + UINT16 Failed : 1; + UINT16 MediaPresent : 2; + UINT16 Reserved2 : 4; +} BBS_STATUS_FLAGS; + +#define MAX_BBS_ENTRIES 0x100 +// +// BBS_IGNORE_ENTRY is placed in the BootPriority field if the entry is to +// be skipped. +// BBS_UNPRIORITIZED_ENTRY is placed in the BootPriority field before +// priority has been assigned but indicates valid entry. +// BBS_LOWEST_PRIORITY is normally used for removable media with no media +// inserted. This allows the 16-bit CSM to allocate a drive letter to +// the device. +// BBS_DO_NOT_BOOT_FROM is used for devices that the 16-bit CSM is to assign +// a drive letter to but never boot from. +// +// AdditionalIrq??Handler usage is IBV specific. The fields have been added +// for: +// 1. Saving non-BBS card info about IRQs taken by card. +// 2. For BBS compliant cards that hook IRQs in order to have their SETUP +// executed. +// +#define BBS_DO_NOT_BOOT_FROM 0xFFFC +#define BBS_LOWEST_PRIORITY 0xFFFD +#define BBS_UNPRIORITIZED_ENTRY 0xFFFE +#define BBS_IGNORE_ENTRY 0xFFFF + +typedef struct { + UINT16 BootPriority; + UINT32 Bus; + UINT32 Device; + UINT32 Function; + UINT8 Class; + UINT8 SubClass; + UINT16 MfgStringOffset; + UINT16 MfgStringSegment; + UINT16 DeviceType; + BBS_STATUS_FLAGS StatusFlags; + UINT16 BootHandlerOffset; + UINT16 BootHandlerSegment; + UINT16 DescStringOffset; + UINT16 DescStringSegment; + UINT32 InitPerReserved; + UINT32 AdditionalIrq13Handler; + UINT32 AdditionalIrq18Handler; + UINT32 AdditionalIrq19Handler; + UINT32 AdditionalIrq40Handler; + UINT8 AssignedDriveNumber; + UINT32 AdditionalIrq41Handler; + UINT32 AdditionalIrq46Handler; + UINT32 IBV1; + UINT32 IBV2; +} BBS_TABLE; + +#pragma pack() + +typedef +BOOLEAN +(EFIAPI *EFI_LEGACY_BIOS_INT86) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN UINT8 BiosInt, + IN OUT EFI_IA32_REGISTER_SET * Regs + ) +/*++ + + Routine Description: + Thunk to 16-bit real mode and execute a software interrupt with a vector + of BiosInt. Regs will contain the 16-bit register context on entry and + exit. + + Arguments: + This - Protocol instance pointer. + BiosInt - Processor interrupt vector to invoke + Reg - Register contexted passed into (and returned) from thunk to + 16-bit mode + + Returns: + FALSE - Thunk completed, and there were no BIOS errors in the target code. + See Regs for status. + TRUE - There was a BIOS erro in the target code. + +--*/ +; + +typedef +BOOLEAN +(EFIAPI *EFI_LEGACY_BIOS_FARCALL86) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN UINT16 Segment, + IN UINT16 Offset, + IN EFI_IA32_REGISTER_SET * Regs, + IN VOID *Stack, + IN UINTN StackSize + ) +/*++ + + Routine Description: + Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the + 16-bit register context on entry and exit. Arguments can be passed on + the Stack argument + + Arguments: + This - Protocol instance pointer. + Segment - Segemnt of 16-bit mode call + Offset - Offset of 16-bit mdoe call + Reg - Register contexted passed into (and returned) from thunk to + 16-bit mode + Stack - Caller allocated stack used to pass arguments + StackSize - Size of Stack in bytes + + Returns: + FALSE - Thunk completed, and there were no BIOS errors in the target code. + See Regs for status. + TRUE - There was a BIOS erro in the target code. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN EFI_HANDLE PciHandle, + OUT VOID **RomImage, OPTIONAL + OUT UINTN *RomSize, OPTIONAL + OUT UINTN *Flags + + ) +/*++ + + Routine Description: + Test to see if a legacy PCI ROM exists for this device. Optionally return + the Legacy ROM instance for this PCI device. + + Arguments: + This - Protocol instance pointer. + PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded + RomImage - Return the legacy PCI ROM for this device + RomSize - Size of ROM Image + Flags - Indicates if ROM found and if PC-AT. + + Returns: + EFI_SUCCESS - Legacy Option ROM availible for this device + EFI_UNSUPPORTED - Legacy Option ROM not supported. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN EFI_HANDLE PciHandle, + IN VOID **RomImage, + OUT UINTN *Flags, + OUT UINT8 *DiskStart, OPTIONAL + OUT UINT8 *DiskEnd, OPTIONAL + OUT VOID **RomShadowAddress, OPTIONAL + OUT UINT32 *ShadowedRomSize OPTIONAL + ) +/*++ + + Routine Description: + Load a legacy PC-AT OPROM on the PciHandle device. Return information + about how many disks were added by the OPROM and the shadow address and + size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C: + + Arguments: + This - Protocol instance pointer. + PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded. + This value is NULL if RomImage is non-NULL. This is the normal + case. + RomImage - A PCI PC-AT ROM image. This argument is non-NULL if there is + no hardware associated with the ROM and thus no PciHandle, + otherwise is must be NULL. + Example is PXE base code. + Flags - Return Status if ROM was found and if was Legacy OPROM. + DiskStart - Disk number of first device hooked by the ROM. If DiskStart + is the same as DiskEnd no disked were hooked. + DiskEnd - Disk number of the last device hooked by the ROM. + RomShadowAddress - Shadow address of PC-AT ROM + RomShadowSize - Size of RomShadowAddress in bytes + + Returns: + EFI_SUCCESS - Thunk completed, see Regs for status. + EFI_INVALID_PARAMETER - PciHandle not found + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_BOOT) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN BBS_BBS_DEVICE_PATH * BootOption, + IN UINT32 LoadOptionsSize, + IN VOID *LoadOptions + ) +/*++ + + Routine Description: + Attempt to legacy boot the BootOption. If the EFI contexted has been + compromised this function will not return. + + Arguments: + This - Protocol instance pointer. + BootOption - EFI Device Path from BootXXXX variable. + LoadOptionSize - Size of LoadOption in size. + LoadOption - LoadOption from BootXXXX variable + + Returns: + EFI_SUCCESS - Removable media not present + +--*/ +; +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN UINT8 Leds + ) +/*++ + + Routine Description: + Update BDA with current Scroll, Num & Cap lock LEDS + + Arguments: + This - Protocol instance pointer. + Leds - Status of current Scroll, Num & Cap lock LEDS + Bit 0 is Scroll Lock 0 = Not locked + Bit 1 is Num Lock + Bit 2 is Caps Lock + + Returns: + EFI_SUCCESS - Removable media not present + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + OUT UINT16 *HddCount, + OUT HDD_INFO **HddInfo, + OUT UINT16 *BbsCount, + IN OUT BBS_TABLE **BbsTable + ) +/*++ + + Routine Description: + Retrieve legacy BBS info and assign boot priority. + + Arguments: + This - Protocol instance pointer. + HddCount - Number of HDD_INFO structures + HddInfo - Onboard IDE controller information + BbsCount - Number of BBS_TABLE structures + BbsTable - List BBS entries + + Returns: + EFI_SUCCESS - Tables returned + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + OUT UINT16 *BbsCount, + OUT BBS_TABLE **BbsTable + ) +/*++ + + Routine Description: + Assign drive number to legacy HDD drives prior to booting an EFI + aware OS so the OS can access drives without an EFI driver. + + Arguments: + This - Protocol instance pointer. + BbsCount - Number of BBS_TABLE structures + BbsTable - List BBS entries + + Returns: + EFI_SUCCESS - Drive numbers assigned + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN UDC_ATTRIBUTES Attributes, + IN UINTN BbsEntry, + IN VOID *BeerData, + IN VOID *ServiceAreaData + ) +/*++ + + Routine Description: + To boot from an unconventional device like parties and/or execute + HDD diagnostics. + + Arguments: + This - Protocol instance pointer. + Attributes - How to interpret the other input parameters + BbsEntry - The 0-based index into the BbsTable for the parent + device. + BeerData - Pointer to the 128 bytes of ram BEER data. + ServiceAreaData - Pointer to the 64 bytes of raw Service Area data. The + caller must provide a pointer to the specific Service + Area and not the start all Service Areas. + Returns: + EFI_INVALID_PARAMETER if error. Does NOT return if no error. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This + ) +/*++ + + Routine Description: + Shadow all legacy16 OPROMs that haven't been shadowed. + Warning: Use this with caution. This routine disconnects all EFI + drivers. If used externally then caller must re-connect EFI + drivers. + Arguments: + + Returns: + EFI_SUCCESS - OPROMs shadowed + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN UINTN LegacyMemorySize, + IN UINTN Region, + IN UINTN Alignment, + OUT VOID **LegacyMemoryAddress + ) +/*++ + +Routine Description: + Get a region from the LegacyBios for S3 usage. + +Arguments: + This - Protocol instance pointer. + LegacyMemorySize - Size of required region + Region - Region to use. + 00 = Either 0xE0000 or 0xF0000 block + Bit0 = 1 0xF0000 block + Bit1 = 1 0xE0000 block + Alignment - Address alignment. Bit mapped. First non-zero + bit from right is alignment. + LegacyMemoryAddress - Region Assigned + +Returns: + + EFI_SUCCESS - Region assigned + + Other - Region not assigned + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION) ( + IN EFI_LEGACY_BIOS_PROTOCOL * This, + IN UINTN LegacyMemorySize, + IN VOID *LegacyMemoryAddress, + IN VOID *LegacyMemorySourceAddress + ) +/*++ + +Routine Description: + Get a region from the LegacyBios for Tiano usage. Can only be invoked once. + +Arguments: + This - Protocol instance pointer. + LegacyMemorySize - Size of data to copy + LegacyMemoryAddress - Legacy Region destination address + Note: must be in region assigned by + LegacyBiosGetLegacyRegion + LegacyMemorySourceAddress - Source of data + +Returns: + + EFI_SUCCESS - Region assigned + EFI_ACCESS_DENIED - Destination outside assigned region + +--*/ +; + +typedef struct _EFI_LEGACY_BIOS_PROTOCOL { + EFI_LEGACY_BIOS_INT86 Int86; + EFI_LEGACY_BIOS_FARCALL86 FarCall86; + EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom; + EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom; + EFI_LEGACY_BIOS_BOOT LegacyBoot; + EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus; + EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo; + EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms; + EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi; + EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion; + EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion; + EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice; +} EFI_LEGACY_BIOS_PROTOCOL; + +extern EFI_GUID gEfiLegacyBiosProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c new file mode 100644 index 0000000000..f9f2ac7ee0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LegacyBiosPlatform.c + +Abstract: + + EFI Legacy BIOS Platform Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (LegacyBiosPlatform) + +EFI_GUID gEfiLegacyBiosPlatformProtocolGuid = EFI_LEGACY_BIOS_PLATFORM_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLegacyBiosPlatformProtocolGuid, "Legacy BIOS Platform Protocol", "Legacy BIOS Platform Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h new file mode 100644 index 0000000000..1a1a0fa406 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h @@ -0,0 +1,328 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LegacyBiosPlatform.h + +Abstract: + + The EFI Legacy BIOS Patform Protocol is used to mate a Legacy16 + implementation with this EFI code. The EFI driver that produces + the Legacy BIOS protocol is generic and consumes this protocol. + A driver that matches the Legacy16 produces this protocol + +Revision History + + The EFI Legacy BIOS Platform Protocol is compliant with CSM spec 0.96. + +--*/ + +#ifndef _EFI_LEGACY_BIOS_PLATFORM_H +#define _EFI_LEGACY_BIOS_PLATFORM_H + +#define EFI_LEGACY_BIOS_PLATFORM_PROTOCOL_GUID \ + { \ + 0x783658a3, 0x4172, 0x4421, 0xa2, 0x99, 0xe0, 0x9, 0x7, 0x9c, 0xc, 0xb4 \ + } + +EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_PLATFORM_PROTOCOL); + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (LegacyBios) + +#pragma pack(1) +// +// Define structures for GetOemIntData +// Note: +// OemIntDataElenent is an array of structures from 0 to Count-1. +// RawData is an array of bytes from 0 to RamDataLength-1. +// +typedef struct { + UINT16 Int; + UINT16 Ax; + UINT32 RawDataLength; + UINT8 RawData[1]; +} EFI_OEM_INT_DATA_ELEMENT; + +typedef struct { + UINT16 Count; + EFI_OEM_INT_DATA_ELEMENT OemIntDataElement[1]; +} EFI_OEM_INT_DATA; +#pragma pack() + +typedef enum { + EfiGetPlatformBinaryMpTable = 0, + EfiGetPlatformBinaryOemIntData = 1, + EfiGetPlatformBinaryOem16Data = 2, + EfiGetPlatformBinaryOem32Data = 3, + EfiGetPlatformBinaryTpmBinary = 4, + EfiGetPlatformBinarySystemRom = 5, + EfiGetPlatformPciExpressBase = 6, + EfiGetPlatformPmmSize = 7, + EfiGetPlatformEndOfOpromShadowAddr = 8 +} EFI_GET_PLATFORM_INFO_MODE; + +typedef enum { + EfiGetPlatformVgaHandle = 0, + EfiGetPlatformIdeHandle = 1, + EfiGetPlatformIsaBusHandle = 2, + EfiGetPlatformUsbHandle = 3 +} EFI_GET_PLATFORM_HANDLE_MODE; + +typedef enum { + EfiPlatformHookPrepareToScanRom = 0, + EfiPlatformHookShadowServiceRoms= 1, + EfiPlatformHookAfterRomInit = 2 +} EFI_GET_PLATFORM_HOOK_MODE; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO) ( + IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This, + IN EFI_GET_PLATFORM_INFO_MODE Mode, + OUT VOID **Table, + OUT UINTN *TableSize, + OUT UINTN *Location, + OUT UINTN *Alignment, + IN UINT16 LegacySegment, + IN UINT16 LegacyOffset + ) +/*++ + + Routine Description: + Return a System ROM image for the platform + + Arguments: + This - Protocol instance pointer. + Mode - Specifies what data to return + Table - Pointer to MP table. + TableSize - Size in bytes of table. + Location - Legacy region requested + 0x00 = Any location + Bit 0 = 0xF0000 region + Bit 1 = 0xE0000 region + Multiple bits can be set + Alignment - Address alignment for allocation. + Bit mapped. First non-zero bit from right + is alignment. + + LegacySegment - Segment in LegacyBios where Table is stored + LegacyOffset - Offset in LegacyBios where Table is stored + + Returns: + EFI_SUCCESS - Data was returned successfully. + EFI_UNSUPPORTED - Mode is not supported on the platform. + EFI_NOT_FOUND - Binary image or table not found. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE) ( + IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This, + IN EFI_GET_PLATFORM_HANDLE_MODE Mode, + IN UINT16 Type, + OUT EFI_HANDLE **HandleBuffer, + OUT UINTN *HandleCount, + IN VOID **AdditionalData OPTIONAL + ) +/*++ + + Routine Description: + Return the Legacy16 policy for which device should be the VGA controller + used during a Legacy16 boot. + + Arguments: + This - Protocol instance pointer. + Mode - Specifies what handle to return. + Type - Type from Device Path for Handle to represent. + HandleBuffer - Handles of the device/controller in priority order + with HandleBuffer[0] highest priority. + HandleCount - Number of handles in the buffer. + AdditionalData - Mode specific. + + + Returns: + EFI_SUCCESS - Handle is valid + EFI_UNSUPPORTED - Mode is not supported on the platform. + EFI_NOT_FOUND - Handle is not known + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_SMM_INIT) ( + IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This, + IN VOID *EfiToLegacy16BootTable + ); + +/*++ + + Routine Description: + Load and initialize the Legacy BIOS SMM handler. + + Arguments: + This - Protocol instance pointer. + EfiToLegacy16BootTable - Pointer to Legacy16 boot table. + Returns: + EFI_SUCCESS - SMM code loaded. + EFI_DEVICE_ERROR - SMM code failed to load + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_HOOKS) ( + IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This, + IN EFI_GET_PLATFORM_HOOK_MODE Mode, + IN UINT16 Type, + IN EFI_HANDLE DeviceHandle, + IN OUT UINTN *ShadowAddress, + IN EFI_COMPATIBILITY16_TABLE * Compatibility16Table, + IN VOID **AdditionalData OPTIONAL + ) +/*++ + + Routine Description: + Prepare to scan a ROM. + + Arguments: + This - Protocol instance pointer. + Handle - Device handle + ShadowAddress - Address that ROM is shadowed at prior to + initialization or first free ROM address, + depending upon mode. + Compatibility16Table - Pointer to Compatibility16Table. + AdditionalData - Mode specific. + + + Returns: + EFI_SUCCESS - RomImage is valid + EFI_UNSUPPORTED - Mode is not supported on the platform or platform + policy is to not install this OPROM. +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE) ( + IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This, + OUT VOID **RoutingTable, + OUT UINTN *RoutingTableEntries, + OUT VOID **LocalPirqTable, OPTIONAL + OUT UINTN *PirqTableSize, OPTIONAL + OUT VOID **LocalIrqPriorityTable, OPTIONAL + OUT UINTN *IrqPriorityTableEntries OPTIONAL + ) +/*++ + + Routine Description: + 1. List of IRQ routing entries and number of entries. + 2. Pointer to Entire $PIR table and length. + 3. List of IRQs to assign to PCI in priority. + + Arguments: + This - Protocol instance pointer. + RoutingTable - Pointer to PCI IRQ Routing table. + RoutingTableEntries - Number of entries in table. + LocalPirqTable - $PIR table + PirqTableSize - $PIR table size + LocalIrqPriorityTable - List of interrupts in priority order to assign + IrqPriorityTableEntries- Number of entries in priority table + + Returns: + EFI_SUCCESS - Table pointer returned + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ) ( + IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This, + IN UINTN PciBus, + IN UINTN PciDevice, + IN UINTN PciFunction, + IN OUT UINT8 *Pirq, + OUT UINT8 *PciIrq + ) +/*++ + + Routine Description: + Translate the PIRQ reported by the PCI device into the true PIRQ + from the internal IRQ routing information and IRQ assigned or to be + assigned to device. + + Arguments: + This - Protocol instance pointer. + Base as defined below is the bus,device, function in + IRQ routing table. + PciBus - Base Bus for this device. + PciDevice - Base Device for this device. + PciFunction - Base Function for this device. + Pirq - Input is PIRQ reported by device, output is true PIRQ. + PciIrq - The IRQ already assigned to the PIRQ or the IRQ to be + assigned to the PIRQ. + + Returns: + EFI_SUCCESS - Irq translated + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT) ( + IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This, + IN BBS_BBS_DEVICE_PATH * BbsDevicePath, + IN VOID *BbsTable, + IN UINT32 LoadOptionsSize, + IN VOID *LoadOptions, + IN VOID *EfiToLegacy16BootTable + ) +/*++ + + Routine Description: + Attempt to legacy boot the BootOption. If the EFI contexted has been + compromised this function will not return. + + Arguments: + This - Protocol instance pointer. + BbsDevicePath - EFI Device Path from BootXXXX variable. + BbsTable - Internal BBS table. + LoadOptionSize - Size of LoadOption in size. + LoadOption - LoadOption from BootXXXX variable + EfiToLegacy16BootTable - Pointer to BootTable structure + + Returns: + EFI_SUCCESS - Removable media not present + +--*/ +; + +typedef struct _EFI_LEGACY_BIOS_PLATFORM_PROTOCOL { + EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO GetPlatformInfo; + EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE GetPlatformHandle; + EFI_LEGACY_BIOS_PLATFORM_SMM_INIT SmmInit; + EFI_LEGACY_BIOS_PLATFORM_HOOKS PlatformHooks; + EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE GetRoutingTable; + EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ TranslatePirq; + EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT PrepareToBoot; +} EFI_LEGACY_BIOS_PLATFORM_PROTOCOL; + +extern EFI_GUID gEfiLegacyBiosPlatformProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c new file mode 100644 index 0000000000..ef9091f9f0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LegacyInterrupt.c + +Abstract: + + EFI Legacy InterruptProtocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (LegacyInterrupt) + +EFI_GUID gEfiLegacyInterruptProtocolGuid = EFI_LEGACY_INTERRUPT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLegacyInterruptProtocolGuid, "Legacy Interrupt Protocol", "Legacy Interrupt Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h new file mode 100644 index 0000000000..ecbe06af59 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h @@ -0,0 +1,136 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LegacyInterrupt.h + +Abstract: + + This protocol manages the PIRQ for PCI devices + +Revision History + + The EFI Legacy Interrupt Protocol is compliant with CSM spec 0.96. + +--*/ + +#ifndef _EFI_LEGACY_INTERRUPT_H_ +#define _EFI_LEGACY_INTERRUPT_H_ + +#define EFI_LEGACY_INTERRUPT_PROTOCOL_GUID \ + { \ + 0x31ce593d, 0x108a, 0x485d, 0xad, 0xb2, 0x78, 0xf2, 0x1f, 0x29, 0x66, 0xbe \ + } + +EFI_FORWARD_DECLARATION (EFI_LEGACY_INTERRUPT_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_INTERRUPT_GET_NUMBER_PIRQS) ( + IN EFI_LEGACY_INTERRUPT_PROTOCOL * This, + OUT UINT8 *NumberPirqs + ); + +/*++ + + Routine Description: + Return the number of PIRQs this hardware supports. + + Arguments: + This - Protocol instance pointer. + NumberPirsq - Number of PIRQs. + + Returns: + EFI_SUCCESS - Number of PIRQs returned. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_INTERRUPT_GET_LOCATION) ( + IN EFI_LEGACY_INTERRUPT_PROTOCOL * This, + OUT UINT8 *Bus, + OUT UINT8 *Device, + OUT UINT8 *Function + ); + +/*++ + + Routine Description: + Return PCI location of this device. $PIR table requires this info. + + Arguments: + This - Protocol instance pointer. + Bus - PCI Bus + Device - PCI Device + Function - PCI Function + + Returns: + EFI_SUCCESS - Bus/Device/Function returned + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_INTERRUPT_READ_PIRQ) ( + IN EFI_LEGACY_INTERRUPT_PROTOCOL * This, + IN UINT8 PirqNumber, + OUT UINT8 *PirqData + ); + +/*++ + + Routine Description: + Read the PIRQ register and return the data + + Arguments: + This - Protocol instance pointer. + PirqNumber - PIRQ register to read + PirqData - Data read + + Returns: + EFI_SUCCESS - Data was read + EFI_INVALID_PARAMETER - Invalid PIRQ number + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_INTERRUPT_WRITE_PIRQ) ( + IN EFI_LEGACY_INTERRUPT_PROTOCOL * This, + IN UINT8 PirqNumber, + IN UINT8 PirqData + ); + +/*++ + + Routine Description: + Write the specified PIRQ register with the given data. + + Arguments: + This - Protocol instance pointer. + PirqNumber - PIRQ register to read. + PirqData - Data written. + + Returns: + EFI_SUCCESS - Table pointer returned + EFI_INVALID_PARAMETER - Invalid PIRQ number + +--*/ +typedef struct _EFI_LEGACY_INTERRUPT_PROTOCOL { + EFI_LEGACY_INTERRUPT_GET_NUMBER_PIRQS GetNumberPirqs; + EFI_LEGACY_INTERRUPT_GET_LOCATION GetLocation; + EFI_LEGACY_INTERRUPT_READ_PIRQ ReadPirq; + EFI_LEGACY_INTERRUPT_WRITE_PIRQ WritePirq; +} EFI_LEGACY_INTERRUPT_PROTOCOL; + +extern EFI_GUID gEfiLegacyInterruptProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c new file mode 100644 index 0000000000..c4f697eed8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LegacyRegion.c + +Abstract: + + EFI Legacy Region Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (LegacyRegion) + +EFI_GUID gEfiLegacyRegionProtocolGuid = EFI_LEGACY_REGION_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLegacyRegionProtocolGuid, "Legacy Region Protocol", "Legacy Region Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h new file mode 100644 index 0000000000..d70e8ffa2d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h @@ -0,0 +1,82 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LegacyRegion.h + +Abstract: + + This protocol manages the legacy memory regions between 0xc0000 - 0xfffff + +Revision History + + The EFI Legacy Region Protocol is compliant with CSM spec 0.96. + +--*/ + +#ifndef _EFI_LEGACY_REGION_H_ +#define _EFI_LEGACY_REGION_H_ + +#define EFI_LEGACY_REGION_PROTOCOL_GUID \ + { \ + 0xfc9013a, 0x568, 0x4ba9, 0x9b, 0x7e, 0xc9, 0xc3, 0x90, 0xa6, 0x60, 0x9b \ + } + +EFI_FORWARD_DECLARATION (EFI_LEGACY_REGION_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_REGION_DECODE) ( + IN EFI_LEGACY_REGION_PROTOCOL * This, + IN UINT32 Start, + IN UINT32 Length, + IN BOOLEAN *On + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_REGION_LOCK) ( + IN EFI_LEGACY_REGION_PROTOCOL * This, + IN UINT32 Start, + IN UINT32 Length, + OUT UINT32 *Granularity OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_REGION_BOOT_LOCK) ( + IN EFI_LEGACY_REGION_PROTOCOL * This, + IN UINT32 Start, + IN UINT32 Length, + OUT UINT32 *Granularity OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_LEGACY_REGION_UNLOCK) ( + IN EFI_LEGACY_REGION_PROTOCOL * This, + IN UINT32 Start, + IN UINT32 Length, + OUT UINT32 *Granularity OPTIONAL + ); + +typedef struct _EFI_LEGACY_REGION_PROTOCOL { + EFI_LEGACY_REGION_DECODE Decode; + EFI_LEGACY_REGION_LOCK Lock; + EFI_LEGACY_REGION_BOOT_LOCK BootLock; + EFI_LEGACY_REGION_UNLOCK UnLock; +} EFI_LEGACY_REGION_PROTOCOL; + +extern EFI_GUID gEfiLegacyRegionProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c new file mode 100644 index 0000000000..c62ed60785 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHostBridgeResourceAllocation.c + +Abstract: + + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation) + +EFI_GUID gEfiPciHostBridgeResourceAllocationProtocolGuid = EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiPciHostBridgeResourceAllocationProtocolGuid, "PciHostBridgeRresourceAllocation Protocol", + "Pci Host Bridge Resource Allocation Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h new file mode 100644 index 0000000000..6e7e1f0feb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h @@ -0,0 +1,364 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHostBridgeResourceAllocation.h + +Abstract: + + +--*/ + +#ifndef _PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_H_ +#define _PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_H_ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(PciRootBridgeIo) + + +#define EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GUID \ + { 0xCF8034BE,0x6768,0x4d8b,0xB7,0x39,0x7C,0xCE,0x68,0x3A,0x9F,0xBE } + + +EFI_FORWARD_DECLARATION (EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL); + + +// +// EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ATTRIBUTES +// + +// If this bit is set, then the PCI Root Bridge does not +// support separate windows for Non-prefetchable and Prefetchable +// memory. A PCI bus driver needs to include requests for Prefetchable +// memory in the Non-prefetchable memory pool. +// +#define EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM 1 + +// +// If this bit is set, then the PCI Root Bridge supports +// 64 bit memory windows. If this bit is not set, +// the PCI bus driver needs to include requests for 64 bit +// memory address in the corresponding 32 bit memory pool. +// +#define EFI_PCI_HOST_BRIDGE_MEM64_DECODE 2 + + +// +// EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE +// +typedef enum { + EfiPciHostBridgeBeginEnumeration, + EfiPciHostBridgeBeginBusAllocation, + EfiPciHostBridgeEndBusAllocation, + EfiPciHostBridgeBeginResourceAllocation, + EfiPciHostBridgeAllocateResources, + EfiPciHostBridgeSetResources, + EfiPciHostBridgeFreeResources, + EfiPciHostBridgeEndResourceAllocation +} EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE; + +// +// EfiPciHostBridgeBeginEnumeration +// Reset the host bridge PCI apertures and internal data structures. +// PCI enumerator should issue this notification before starting fresh +// enumeration process. Enumeration cannot be restarted after sending +// any other notification such as EfiPciHostBridgeBeginBusAllocation. +// +// EfiPciHostBridgeBeginBusAllocation +// The bus allocation phase is about to begin. No specific action +// is required here. This notification can be used to perform any +// chipset specific programming. +// +// EfiPciHostBridgeEndBusAllocation +// The bus allocation and bus programming phase is complete. No specific +// action is required here. This notification can be used to perform any +// chipset specific programming. +// +// EfiPciHostBridgeBeginResourceAllocation +// The resource allocation phase is about to begin.No specific action is +// required here. This notification can be used to perform any chipset specific programming. +// +// EfiPciHostBridgeAllocateResources +// Allocate resources per previously submitted requests for all the PCI Root +// Bridges. These resource settings are returned on the next call to +// GetProposedResources(). +// +// EfiPciHostBridgeSetResources +// Program the Host Bridge hardware to decode previously allocated resources +// (proposed resources) for all the PCI Root Bridges. +// +// EfiPciHostBridgeFreeResources +// De-allocate previously allocated resources previously for all the PCI +// Root Bridges and reset the I/O and memory apertures to initial state. +// +// EfiPciHostBridgeEndResourceAllocation +// The resource allocation phase is completed. No specific action is required +// here. This notification can be used to perform any chipset specific programming. + + + +// +// EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE +// +typedef enum { + EfiPciBeforeChildBusEnumeration, + EfiPciBeforeResourceCollection +} EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE; + +// +// EfiPciBeforeChildBusEnumeration +// This notification is only applicable to PCI-PCI bridges and +// indicates that the PCI enumerator is about to begin enumerating +// the bus behind the PCI-PCI Bridge. This notification is sent after +// the primary bus number, the secondary bus number and the subordinate +// bus number registers in the PCI-PCI Bridge are programmed to valid +// (not necessary final) values +// +// EfiPciBeforeResourceCollection +// This notification is sent before the PCI enumerator probes BAR registers +// for every valid PCI function. +// + + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_NOTIFY_PHASE) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase + ); +/*++ + +Routine Description: + Enter a certain phase of the PCI enumeration process + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance + Phase -- The phase during enumeration + +Returns: + EFI_SUCCESS - Success + EFI_OUT_OF_RESOURCES - If SubmitResources ( ) could not allocate resources + EFI_NOT_READY - This phase cannot be entered at this time + EFI_DEVICE_ERROR - SetResources failed due to HW error. + +--*/ + + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_NEXT_ROOT_BRIDGE) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN OUT EFI_HANDLE *RootBridgeHandle + ); +/*++ + +Routine Description: + Return the device handle of the next PCI root bridge that is associated with + this Host Bridge + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance + RootBridgeHandle -- Returns the device handle of the next PCI Root Bridge. + On input, it holds the RootBridgeHandle returned by the most + recent call to GetNextRootBridge().The handle for the first + PCI Root Bridge is returned if RootBridgeHandle is NULL on input + +Returns: + EFI_SUCCESS - Success + EFI_INVALID_PARAMETER - RootBridgeHandle is invalid + +--*/ + + +typedef +EFI_STATUS +(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_ATTRIBUTES) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_HANDLE RootBridgeHandle, + OUT UINT64 *Attributes + ); +/*++ + +Routine Description: + Returns the attributes of a PCI Root Bridge. + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance + RootBridgeHandle -- The device handle of the PCI Root Bridge + that the caller is interested in + Attribute -- The pointer to attributes of the PCI Root Bridge + +Returns: + EFI_SUCCESS - Success + EFI_INVALID_PARAMETER - RootBridgeHandle is invalid + EFI_INVALID_PARAMETER - Attributes is NULL + +--*/ + + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_START_BUS_ENUMERATION) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_HANDLE RootBridgeHandle, + OUT VOID **Configuration + ); +/*++ + +Routine Description: + This is the request from the PCI enumerator to set up + the specified PCI Root Bridge for bus enumeration process. + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance + RootBridgeHandle -- The PCI Root Bridge to be set up + Configuration -- Pointer to the pointer to the PCI bus resource descriptor + +Returns: + EFI_SUCCESS - Success + EFI_INVALID_PARAMETER - RootBridgeHandle is invalid + EFI_DEVICE_ERROR - Request failed due to hardware error + EFI_OUT_OF_RESOURCES - Request failed due to lack of resources +--*/ + + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SET_BUS_NUMBERS) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_HANDLE RootBridgeHandle, + IN VOID *Configuration + ); +/*++ + +Routine Description: + This function programs the PCI Root Bridge hardware so that + it decodes the specified PCI bus range + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance + RootBridgeHandle -- The PCI Root Bridge whose bus range is to be programmed + Configuration -- The pointer to the PCI bus resource descriptor + +Returns: + EFI_SUCCESS - Success + EFI_INVALID_PARAMETER - RootBridgeHandle is invalid + EFI_INVALID_PARAMETER - Configuration is NULL + EFI_INVALID_PARAMETER - Configuration does not point to a valid ACPI resource descriptor + EFI_INVALID_PARAMETER - Configuration contains one or more memory or IO ACPI resource descriptor + EFI_INVALID_PARAMETER - Address Range Minimum or Address Range Length fields in Configuration + are invalid for this Root Bridge. + EFI_INVALID_PARAMETER - Configuration contains one or more invalid ACPI resource descriptor + EFI_DEVICE_ERROR - Request failed due to hardware error + EFI_OUT_OF_RESOURCES - Request failed due to lack of resources + +--*/ + + +typedef +EFI_STATUS +(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SUBMIT_RESOURCES) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_HANDLE RootBridgeHandle, + IN VOID *Configuration + ); +/*++ + +Routine Description: + Submits the I/O and memory resource requirements for the specified PCI Root Bridge + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance + RootBridgeHandle -- The PCI Root Bridge whose I/O and memory resource requirements + are being submitted + Configuration -- The pointer to the PCI I/O and PCI memory resource descriptor +Returns: + EFI_SUCCESS - Success + EFI_INVALID_PARAMETER - RootBridgeHandle is invalid + EFI_INVALID_PARAMETER - Configuration is NULL + EFI_INVALID_PARAMETER - Configuration does not point to a valid ACPI resource descriptor + EFI_INVALID_PARAMETER - Configuration includes a resource descriptor of unsupported type + +--*/ + + +typedef +EFI_STATUS +(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_PROPOSED_RESOURCES) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_HANDLE RootBridgeHandle, + OUT VOID **Configuration + ); +/*++ + +Routine Description: + This function returns the proposed resource settings for the specified + PCI Root Bridge + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance + RootBridgeHandle -- The PCI Root Bridge handle + Configuration -- The pointer to the pointer to the PCI I/O + and memory resource descriptor + +Returns: + EFI_SUCCESS - Success + EFI_INVALID_PARAMETER - RootBridgeHandle is invalid + EFI_DEVICE_ERROR - Request failed due to hardware error + EFI_OUT_OF_RESOURCES - Request failed due to lack of resources + +--*/ + + + +typedef +EFI_STATUS +(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_PREPROCESS_CONTROLLER) ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_HANDLE RootBridgeHandle, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress, + IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase + ); +/*++ + +Routine Description: + This function is called for all the PCI controllers that the PCI + bus driver finds. Can be used to Preprogram the controller. + +Arguments: + This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance + RootBridgeHandle -- The PCI Root Bridge handle + PciBusAddress -- Address of the controller on the PCI bus + Phase -- The Phase during resource allocation + +Returns: + EFI_SUCCESS - Success + EFI_INVALID_PARAMETER - RootBridgeHandle is invalid + EFI_DEVICE_ERROR - Device pre-initialization failed due to hardware error. +--*/ + + + +typedef struct _EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL { + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_NOTIFY_PHASE NotifyPhase; + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_NEXT_ROOT_BRIDGE GetNextRootBridge; + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_ATTRIBUTES GetAllocAttributes; + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_START_BUS_ENUMERATION StartBusEnumeration; + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SET_BUS_NUMBERS SetBusNumbers; + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SUBMIT_RESOURCES SubmitResources; + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_PROPOSED_RESOURCES GetProposedResources; + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_PREPROCESS_CONTROLLER PreprocessController; +} EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL; + +extern EFI_GUID gEfiPciHostBridgeResourceAllocationProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c new file mode 100644 index 0000000000..f96e0e35f1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHotPlugInit.c + +Abstract: + + EFI PCI Hot Plug Init Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (PciHotPlugInit) + +EFI_GUID gEfiPciHotPlugInitProtocolGuid = EFI_PCI_HOT_PLUG_INIT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPciHotPlugInitProtocolGuid, "PCI Hot Plug Init Protocol", "PCI Hot Plug Init Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h new file mode 100644 index 0000000000..ff11e86c19 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h @@ -0,0 +1,97 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHotPlugInit.h + +Abstract: + + EFI PCI Hot Plug Init Protocol + +Revision History + +--*/ + +#ifndef _EFI_PCI_HOT_PLUG_INIT_H +#define _EFI_PCI_HOT_PLUG_INIT_H + +// +// Global ID for the PCI Hot Plug Protocol +// +#define EFI_PCI_HOT_PLUG_INIT_PROTOCOL_GUID \ + { 0xaa0e8bc1, 0xdabc, 0x46b0, 0xa8, 0x44, 0x37, 0xb8, 0x16, 0x9b, 0x2b, 0xea } + + +EFI_FORWARD_DECLARATION (EFI_PCI_HOT_PLUG_INIT_PROTOCOL); + +#define EFI_HPC_STATE_INITIALIZED 0x01 +#define EFI_HPC_STATE_ENABLED 0x02 + +typedef UINT16 EFI_HPC_STATE; + + +typedef struct{ + EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath; + EFI_DEVICE_PATH_PROTOCOL *HpbDevicePath; +} EFI_HPC_LOCATION; + + +typedef enum{ + EfiPaddingPciBus, + EfiPaddingPciRootBridge +} EFI_HPC_PADDING_ATTRIBUTES; + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_ROOT_HPC_LIST) ( + IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, + OUT UINTN *HpcCount, + OUT EFI_HPC_LOCATION **HpcList +); + +typedef +EFI_STATUS +(EFIAPI *EFI_INITIALIZE_ROOT_HPC) ( + IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, + IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, + IN UINT64 HpcPciAddress, + IN EFI_EVENT Event, OPTIONAL + OUT EFI_HPC_STATE *HpcState +); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_PCI_HOT_PLUG_PADDING) ( + IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, + IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, + IN UINT64 HpcPciAddress, + OUT EFI_HPC_STATE *HpcState, + OUT VOID **Padding, + OUT EFI_HPC_PADDING_ATTRIBUTES *Attributes +); + + +// +// Prototypes for the PCI Hot Plug Init Protocol +// + + +typedef struct _EFI_PCI_HOT_PLUG_INIT_PROTOCOL { + EFI_GET_ROOT_HPC_LIST GetRootHpcList; + EFI_INITIALIZE_ROOT_HPC InitializeRootHpc; + EFI_GET_PCI_HOT_PLUG_PADDING GetResourcePadding; +} EFI_PCI_HOT_PLUG_INIT_PROTOCOL; + + +extern EFI_GUID gEfiPciHotPlugInitProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c new file mode 100644 index 0000000000..4b3da5cfa9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PciPlatform.c + +Abstract: + This file defines global GUID variables for PlatformOpRom protocols. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_PRODUCER (PciPlatform) + + +EFI_GUID gEfiPciPlatformProtocolGuid = EFI_PCI_PLATFORM_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiPciPlatformProtocolGuid, "Pci Platform Protocol", "Pci Platform Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h new file mode 100644 index 0000000000..38a9b2bceb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h @@ -0,0 +1,211 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PciPlatform.h + +Abstract: + This file declares PlatfromOpRom protocols. + +--*/ + +#ifndef _PCI_PLATFORM_H_ +#define _PCI_PLATFORM_H_ + + +#include "Tiano.h" +#include "TianoTypes.h" + +#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation) +#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo) + +// +// Protocol for GUID. +// + +#define EFI_PCI_PLATFORM_PROTOCOL_GUID \ +{ 0x7d75280, 0x27d4, 0x4d69, 0x90, 0xd0, 0x56, 0x43, 0xe2, 0x38, 0xb3, 0x41} + + +EFI_FORWARD_DECLARATION (EFI_PCI_PLATFORM_PROTOCOL); + +typedef UINT32 EFI_PCI_PLATFORM_POLICY; + + +#define EFI_RESERVE_NONE_IO_ALIAS 0x0000 +#define EFI_RESERVE_ISA_IO_ALIAS 0x0001 +#define EFI_RESERVE_ISA_IO_NO_ALIAS 0x0002 +#define EFI_RESERVE_VGA_IO_ALIAS 0x0004 +#define EFI_RESERVE_VGA_IO_NO_ALIAS 0x0008 + + +typedef enum { + ChipsetEntry, + ChipsetExit, + MaximumChipsetPhase +} EFI_PCI_CHIPSET_EXECUTION_PHASE; + + +typedef +EFI_STATUS +(EFIAPI * EFI_PCI_PLATFORM_PHASE_NOTIFY) ( + IN EFI_PCI_PLATFORM_PROTOCOL *This, + IN EFI_HANDLE HostBridge, + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase, + IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase +) +/*++ + + Routine Description: + The PlatformNotify() function can be used to notify the platform driver so that + it can perform platform-specific actions. No specific actions are required. + Eight notification points are defined at this time. More synchronization points + may be added as required in the future. The PCI bus driver calls the platform driver + twice for every Phase-once before the PCI Host Bridge Resource Allocation Protocol + driver is notified, and once after the PCI Host Bridge Resource Allocation Protocol + driver has been notified. + This member function may not perform any error checking on the input parameters. It + also does not return any error codes. If this member function detects any error condition, + it needs to handle those errors on its own because there is no way to surface any + errors to the caller. + + Arguments: + This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance. + HostBridge - The handle of the host bridge controller. + Phase - The phase of the PCI bus enumeration. + ChipsetPhase - Defines the execution phase of the PCI chipset driver. + + Returns: + EFI_SUCCESS - The function completed successfully. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI * EFI_PCI_PLATFORM_PREPROCESS_CONTROLLER) ( + IN EFI_PCI_PLATFORM_PROTOCOL *This, + IN EFI_HANDLE HostBridge, + IN EFI_HANDLE RootBridge, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress, + IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase, + IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase +) +/*++ + + Routine Description: + The PlatformPrepController() function can be used to notify the platform driver so that + it can perform platform-specific actions. No specific actions are required. + Several notification points are defined at this time. More synchronization points may be + added as required in the future. The PCI bus driver calls the platform driver twice for + every PCI controller-once before the PCI Host Bridge Resource Allocation Protocol driver + is notified, and once after the PCI Host Bridge Resource Allocation Protocol driver has + been notified. + This member function may not perform any error checking on the input parameters. It also + does not return any error codes. If this member function detects any error condition, it + needs to handle those errors on its own because there is no way to surface any errors to + the caller. + + Arguments: + This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance. + HostBridge - The associated PCI host bridge handle. + RootBridge - The associated PCI root bridge handle. + PciAddress - The address of the PCI device on the PCI bus. + Phase - The phase of the PCI controller enumeration. + ChipsetPhase - Defines the execution phase of the PCI chipset driver. + + Returns: + EFI_SUCCESS - The function completed successfully. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI * EFI_PCI_PLATFORM_GET_PLATFORM_POLICY) ( + IN EFI_PCI_PLATFORM_PROTOCOL *This, + OUT EFI_PCI_PLATFORM_POLICY *PciPolicy +) +/*++ + + Routine Description: + The GetPlatformPolicy() function retrieves the platform policy regarding PCI + enumeration. The PCI bus driver and the PCI Host Bridge Resource Allocation Protocol + driver can call this member function to retrieve the policy. + + Arguments: + This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance. + PciPolicy - The platform policy with respect to VGA and ISA aliasing. + + Returns: + EFI_SUCCESS - The function completed successfully. + EFI_INVALID_PARAMETER - PciPolicy is NULL. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_PLATFORM_GET_PCI_ROM) ( + IN EFI_PCI_PLATFORM_PROTOCOL *This, + IN EFI_HANDLE PciHandle, + OUT VOID **RomImage, + OUT UINTN *RomSize +) +/*++ + + Routine Description: + The GetPciRom() function gets the PCI device's option ROM from a platform-specific location. + The option ROM will be loaded into memory. This member function is used to return an image + that is packaged as a PCI 2.2 option ROM. The image may contain both legacy and EFI option + ROMs. See the EFI 1.10 Specification for details. This member function can be used to return + option ROM images for embedded controllers. Option ROMs for embedded controllers are typically + stored in platform-specific storage, and this member function can retrieve it from that storage + and return it to the PCI bus driver. The PCI bus driver will call this member function before + scanning the ROM that is attached to any controller, which allows a platform to specify a ROM + image that is different from the ROM image on a PCI card. + + Arguments: + This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance. + PciHandle - The handle of the PCI device. + RomImage - If the call succeeds, the pointer to the pointer to the option ROM image. + Otherwise, this field is undefined. The memory for RomImage is allocated + by EFI_PCI_PLATFORM_PROTOCOL.GetPciRom() using the EFI Boot Service AllocatePool(). + It is the caller's responsibility to free the memory using the EFI Boot Service + FreePool(), when the caller is done with the option ROM. + RomSize - If the call succeeds, a pointer to the size of the option ROM size. Otherwise, + this field is undefined. + + Returns: + EFI_SUCCESS - The option ROM was available for this device and loaded into memory. + EFI_NOT_FOUND - No option ROM was available for this device. + EFI_OUT_OF_RESOURCES - No memory was available to load the option ROM. + EFI_DEVICE_ERROR - An error occurred in getting the option ROM. + +--*/ +; + + +typedef struct _EFI_PCI_PLATFORM_PROTOCOL { + EFI_PCI_PLATFORM_PHASE_NOTIFY PhaseNotify; + EFI_PCI_PLATFORM_PREPROCESS_CONTROLLER PlatformPrepController; + EFI_PCI_PLATFORM_GET_PLATFORM_POLICY GetPlatformPolicy; + EFI_PCI_PLATFORM_GET_PCI_ROM GetPciRom; +} EFI_PCI_PLATFORM_PROTOCOL; + +extern EFI_GUID gEfiPciPlatformProtocolGuid; + + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c new file mode 100644 index 0000000000..87ee975b14 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SectionExtraction.c + +Abstract: + + Section Extraction protocol as defined in the Tiano File Image Format + specification. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SectionExtraction) + +EFI_GUID gEfiSectionExtractionProtocolGuid = EFI_SECTION_EXTRACTION_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSectionExtractionProtocolGuid, "Section Extraction Protocol", "Tiano Section Extraction Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h new file mode 100644 index 0000000000..849a2c861e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h @@ -0,0 +1,83 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SectionExtraction.h + +Abstract: + + Section extraction protocol as defined in the Tiano File Image Format specification. + + This interface provides a means of decoding a set of sections into a linked list of + leaf sections. This provides for an extensible and flexible file format. + +--*/ + +#ifndef _SECTION_EXTRACTION_PROTOCOL_H +#define _SECTION_EXTRACTION_PROTOCOL_H + +#include "EfiFirmwareFileSystem.h" + +// +// Protocol GUID definition +// +#define EFI_SECTION_EXTRACTION_PROTOCOL_GUID \ + { \ + 0x448F5DA4, 0x6DD7, 0x4FE1, 0x93, 0x07, 0x69, 0x22, 0x41, 0x92, 0x21, 0x5D \ + } + +EFI_FORWARD_DECLARATION (EFI_SECTION_EXTRACTION_PROTOCOL); + +// +// Protocol member functions +// +typedef +EFI_STATUS +(EFIAPI *EFI_OPEN_SECTION_STREAM) ( + IN EFI_SECTION_EXTRACTION_PROTOCOL * This, + IN UINTN SectionStreamLength, + IN VOID *SectionStream, + OUT UINTN *SectionStreamHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_SECTION) ( + IN EFI_SECTION_EXTRACTION_PROTOCOL * This, + IN UINTN SectionStreamHandle, + IN EFI_SECTION_TYPE * SectionType, + IN EFI_GUID * SectionDefinitionGuid, + IN UINTN SectionInstance, + IN VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT UINT32 *AuthenticationStatus + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CLOSE_SECTION_STREAM) ( + IN EFI_SECTION_EXTRACTION_PROTOCOL * This, + IN UINTN SectionStreamHandle + ); + +// +// Protocol definition +// +typedef struct _EFI_SECTION_EXTRACTION_PROTOCOL { + EFI_OPEN_SECTION_STREAM OpenSectionStream; + EFI_GET_SECTION GetSection; + EFI_CLOSE_SECTION_STREAM CloseSectionStream; +} EFI_SECTION_EXTRACTION_PROTOCOL; + +extern EFI_GUID gEfiSectionExtractionProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c new file mode 100644 index 0000000000..5b229b0319 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SecurityPolicy.c + +Abstract: + + Security Policy protocol as defined in the DXE CIS + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SecurityPolicy) + +EFI_GUID gEfiSecurityPolicyProtocolGuid = EFI_SECURITY_POLICY_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSecurityPolicyProtocolGuid, "Security Policy protocol", "Security Policy protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h new file mode 100644 index 0000000000..98a056e610 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SecurityPolicy.h + +Abstract: + + Security Policy protocol as defined in the DXE CIS + +--*/ + +#ifndef _SECURITY_POLICY_H_ +#define _SECURITY_POLICY_H_ + +// +// Security policy protocol GUID definition +// +#define EFI_SECURITY_POLICY_PROTOCOL_GUID \ + {0x78E4D245, 0xCD4D, 0x4a05, 0xA2, 0xBA, 0x47, 0x43, 0xE8, 0x6C, 0xFC, 0xAB} + +extern EFI_GUID gEfiSecurityPolicyProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.c new file mode 100644 index 0000000000..7518d0d5a8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmBus.c + +Abstract: + + EFI SMBUS Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (Smbus) + +EFI_GUID gEfiSmbusProtocolGuid = EFI_SMBUS_HC_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSmbusProtocolGuid, "SMBUS Protocol", "EFI 2.0 SMBUS Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.h new file mode 100644 index 0000000000..f6d27098f8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/Smbus/Smbus.h @@ -0,0 +1,93 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Smbus.h + +Abstract: + + EFI SMBUS Protocol + +--*/ + +#ifndef _EFI_SMBUS_H +#define _EFI_SMBUS_H + +#include "EfiSmbus.h" + +#define EFI_SMBUS_HC_PROTOCOL_GUID \ + { \ + 0xe49d33ed, 0x513d, 0x4634, 0xb6, 0x98, 0x6f, 0x55, 0xaa, 0x75, 0x1c, 0x1b \ + } + +EFI_FORWARD_DECLARATION (EFI_SMBUS_HC_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMBUS_HC_EXECUTE_OPERATION) ( + IN EFI_SMBUS_HC_PROTOCOL * This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMBUS_NOTIFY_FUNCTION) ( + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data + ); + +// +// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional. +// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress +// +typedef +EFI_STATUS +(EFIAPI *EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE) ( + IN EFI_SMBUS_HC_PROTOCOL * This, + IN BOOLEAN ArpAll, + IN EFI_SMBUS_UDID * SmbusUdid, OPTIONAL + IN OUT EFI_SMBUS_DEVICE_ADDRESS * SlaveAddress OPTIONAL + ); + + +typedef +EFI_STATUS +(EFIAPI *EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP) ( + IN EFI_SMBUS_HC_PROTOCOL * This, + IN OUT UINTN *Length, + IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMBUS_HC_PROTOCOL_NOTIFY) ( + IN EFI_SMBUS_HC_PROTOCOL * This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data, + IN EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction + ); + +typedef struct _EFI_SMBUS_HC_PROTOCOL { + EFI_SMBUS_HC_EXECUTE_OPERATION Execute; + EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE ArpDevice; + EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP GetArpMap; + EFI_SMBUS_HC_PROTOCOL_NOTIFY Notify; +} EFI_SMBUS_HC_PROTOCOL; + +extern EFI_GUID gEfiSmbusProtocolGuid; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c new file mode 100644 index 0000000000..9776e25b39 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmAccess.c + +Abstract: + + This file defines SMM SMRAM abstraction protocol defined by the + SMM Component Interface Specification + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmAccess) + +EFI_GUID gEfiSmmAccessProtocolGuid = EFI_SMM_ACCESS_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSmmAccessProtocolGuid, "SMM Access Protocol", "SMM Access protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h new file mode 100644 index 0000000000..24e2cbc720 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h @@ -0,0 +1,79 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmAccess.h + +Abstract: + + This file defines SMM SMRAM Access abstraction protocol defined + by the SMM CIS. + +--*/ + +#ifndef _SMM_ACCESS_H_ +#define _SMM_ACCESS_H_ + +#include EFI_GUID_DEFINITION (SmramMemoryReserve) + +EFI_FORWARD_DECLARATION (EFI_SMM_ACCESS_PROTOCOL); + +#define EFI_SMM_ACCESS_PROTOCOL_GUID \ + { \ + 0x3792095a, 0xe309, 0x4c1e, 0xaa, 0x01, 0x85, 0xf5, 0x65, 0x5a, 0x17, 0xf1 \ + } + +// +// SMM Access specification Data Structures +// +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_OPEN) ( + IN EFI_SMM_ACCESS_PROTOCOL * This, + UINTN DescriptorIndex + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_CLOSE) ( + IN EFI_SMM_ACCESS_PROTOCOL * This, + UINTN DescriptorIndex + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_LOCK) ( + IN EFI_SMM_ACCESS_PROTOCOL * This, + UINTN DescriptorIndex + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_CAPABILITIES) ( + IN EFI_SMM_ACCESS_PROTOCOL * This, + IN OUT UINTN *SmramMapSize, + IN OUT EFI_SMRAM_DESCRIPTOR * SmramMap + ); + +typedef struct _EFI_SMM_ACCESS_PROTOCOL { + EFI_SMM_OPEN Open; + EFI_SMM_CLOSE Close; + EFI_SMM_LOCK Lock; + EFI_SMM_CAPABILITIES GetCapabilities; + BOOLEAN LockState; + BOOLEAN OpenState; +} EFI_SMM_ACCESS_PROTOCOL; + +extern EFI_GUID gEfiSmmAccessProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.c new file mode 100644 index 0000000000..4930f9b985 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.c @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmBase.c + +Abstract: + + This file defines SMM Base abstraction protocol defined by the + SMM Component Interface Specification + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmBase) + +EFI_GUID gEfiSmmBaseProtocolGuid = EFI_SMM_BASE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSmmBaseProtocolGuid, "SMM Base Protocol", "SMM Base protocol"); + +EFI_GUID gEfiSmmCpuIoGuid = EFI_SMM_CPU_IO_GUID; + +EFI_GUID_STRING(&gEfiSmmCpuIoGuid, "SMM CPU IO", "SMM CPU IO"); + +EFI_GUID gEfiSmmCommunicateHeaderGuid = SMM_COMMUNICATE_HEADER_GUID; + +EFI_GUID_STRING(&gEfiSmmCommunicateHeaderGuid, "SMM Communicate Header Guid", "SMM Communicate Header Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.h new file mode 100644 index 0000000000..9cda78765f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmBase/SmmBase.h @@ -0,0 +1,797 @@ +/*++ + +Copyright (c) 1999 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmBase.h + +Abstract: + + This file defines SMM Base abstraction protocol defined by the SMM Architecture + Specification. This is the base level of compatiblity for SMM drivers. + +--*/ + +#ifndef _SMM_BASE_H_ +#define _SMM_BASE_H_ + +#include EFI_PROTOCOL_DEFINITION (DevicePath) + +#define EFI_SMM_BASE_PROTOCOL_GUID \ + { \ + 0x1390954D, 0xda95, 0x4227, 0x93, 0x28, 0x72, 0x82, 0xc2, 0x17, 0xda, 0xa8 \ + } + +#define EFI_SMM_CPU_IO_GUID \ + { \ + 0x5f439a0b, 0x45d8, 0x4682, 0xa4, 0xf4, 0xf0, 0x57, 0x6b, 0x51, 0x34, 0x41 \ + } + +#define SMM_COMMUNICATE_HEADER_GUID \ + { \ + 0xF328E36C, 0x23B6, 0x4a95, 0x85, 0x4B, 0x32, 0xE1, 0x95, 0x34, 0xCD, 0x75 \ + } + +// +// SMM Base specification constant and types +// +#define SMM_SMST_SIGNATURE EFI_SIGNATURE_32 ('S', 'M', 'S', 'T') +#define EFI_SMM_SYSTEM_TABLE_REVISION (0 << 16) | (0x09) + +EFI_FORWARD_DECLARATION (EFI_SMM_BASE_PROTOCOL); +EFI_FORWARD_DECLARATION (EFI_SMM_CPU_IO_INTERFACE); +EFI_FORWARD_DECLARATION (EFI_SMM_CPU_SAVE_STATE); +EFI_FORWARD_DECLARATION (EFI_SMM_OPTIONAL_FP_SAVE_STATE); +EFI_FORWARD_DECLARATION (EFI_SMM_SYSTEM_TABLE); + +// +// ******************************************************* +// EFI_SMM_IO_WIDTH +// ******************************************************* +// +typedef enum { + SMM_IO_UINT8 = 0, + SMM_IO_UINT16 = 1, + SMM_IO_UINT32 = 2, + SMM_IO_UINT64 = 3 +} EFI_SMM_IO_WIDTH; + +// +// ******************************************************* +// EFI_SMM_IO_ACCESS +// ******************************************************* +// +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_CPU_IO) ( + IN EFI_SMM_CPU_IO_INTERFACE * This, + IN EFI_SMM_IO_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + EFI_SMM_CPU_IO Read; + EFI_SMM_CPU_IO Write; +} EFI_SMM_IO_ACCESS; + +typedef struct _EFI_SMM_CPU_IO_INTERFACE { + EFI_SMM_IO_ACCESS Mem; + EFI_SMM_IO_ACCESS Io; +} EFI_SMM_CPU_IO_INTERFACE; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMMCORE_ALLOCATE_POOL) ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN Size, + OUT VOID **Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMMCORE_FREE_POOL) ( + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMMCORE_ALLOCATE_PAGES) ( + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN NumberOfPages, + OUT EFI_PHYSICAL_ADDRESS * Memory + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMMCORE_FREE_PAGES) ( + IN EFI_PHYSICAL_ADDRESS Memory, + IN UINTN NumberOfPages + ); + +typedef +VOID +(EFIAPI *EFI_AP_PROCEDURE) ( + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_STARTUP_THIS_AP) ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN CpuNumber, + IN OUT VOID *ProcArguments OPTIONAL + ); + +typedef struct _EFI_SMM_CPU_SAVE_STATE { + UINT8 Reserved1[248]; + UINT32 SMBASE; + UINT32 SMMRevId; + UINT16 IORestart; + UINT16 AutoHALTRestart; + UINT8 Reserved2[164]; + UINT32 ES; + UINT32 CS; + UINT32 SS; + UINT32 DS; + UINT32 FS; + UINT32 GS; + UINT32 LDTBase; + UINT32 TR; + UINT32 DR7; + UINT32 DR6; + UINT32 EAX; + UINT32 ECX; + UINT32 EDX; + UINT32 EBX; + UINT32 ESP; + UINT32 EBP; + UINT32 ESI; + UINT32 EDI; + UINT32 EIP; + UINT32 EFLAGS; + UINT32 CR3; + UINT32 CR0; +} EFI_SMM_CPU_SAVE_STATE; + +typedef struct { + UINT8 Reserved19[760]; // FC00 + UINT32 SMBASE; // FEF8 + UINT32 REVID; // FEFC + UINT16 HALT_RESTART; // FF00 + UINT16 IO_RESTART; // FF02 + UINT32 Reserved17[22]; // FF58, 54, 50, 4c, 48, 44, 40, 3c, 38, 34, 30, 2c, 28, 24, 20, 1c, 18, 14, 10, 0c, 08, 04 + UINT32 EAX; // FF5C + UINT32 Reserved16; // FF60 + UINT32 ECX; // FF64 + UINT32 Reserved15; // FF68 + UINT32 EDX; // FF6C + UINT32 Reserved14; // FF70 + UINT32 EBX; // FF74 + UINT32 Reserved13; // FF78 + UINT32 ESP; // FF7C + UINT32 Reserved12; // FF80 + UINT32 EBP; // FF84 + UINT32 Reserved11; // FF88 + UINT32 ESI; // FF8C + UINT32 Reserved9; // FF90 + UINT32 EDI; // FF94 + UINT32 Reserved8; // FF98 + UINT32 IO_MEM_ADDR; // FF9C + UINT32 Reserved7; // FFA0 + UINT32 IO_MISC; // FFA4 + UINT32 ES_SEL; // FFA8 + UINT32 CS_SEL; // FFAC + UINT32 SS_SEL; // FFB0 + UINT32 DS_SEL; // FFB4 + UINT32 FS_SEL; // FFB8 + UINT32 GS_SEL; // FFBC + UINT32 LDTR_SEL; // FFC0 + UINT32 TR_SEL; // FFC4 + UINT32 DR7; // FFC8 + UINT32 Reserved6; // FFCC + UINT32 DR6; // FFD0 + UINT32 Reserved5; // FFD4 + UINT32 EIP; // FFD8 + UINT32 Reserved4; // FFDC + UINT32 EFER; // FFE0 + UINT32 Reserved3; // FFE4 + UINT32 EFLAGS; // FFE8 + UINT32 Reserved2; // FFEC + UINT32 CR3; // FFF0 + UINT32 Reserved1; // FFF4 + UINT32 CR0; // FFF8 + UINT32 Reserved0; // FFFC +} EFI_SMM_CPU_CT_SAVE_STATE; + +typedef struct { + UINT8 Reserved26[464]; // FC00 - FDCF + UINT32 GdtrUpperBase; // FDD0 + UINT32 LdtrUpperBase; // FDD4 + UINT32 IdtrUpperBase; // FDD8 + UINT32 Reserved25; // FDDC - FDDF + UINT64 IoRdi; // FDE0 + UINT64 IoRip; // FDE8 + UINT64 IoRcx; // FDF0 + UINT64 IoRsi; // FDF8 + UINT8 Reserved24[64]; // FE00 - FE3F + UINT64 Cr4; // FE40 + UINT8 Reserved23[68]; // FE48 - FE8B + UINT32 GdtrBase; // FE8C + UINT32 Reserved22; // FE90 + UINT32 IdtrBase; // FE94 + UINT32 Reserved21; // FE98 + UINT32 LdtrBase; // FE9C + UINT32 Reserved20; // FEA0 + UINT8 Reserved19[84]; // FEA4 - FEF7 + UINT32 Smbase; // FEF8 + UINT32 RevId; // FEFC + UINT16 IoRestart; // FF00 + UINT16 HaltRestart; // FF02 + UINT8 Reserved18[24]; // FF04 - FF1B + UINT32 R15; // FF1C + UINT32 Reserved17; // FE20 + UINT32 R14; // FF24 + UINT32 Reserved16; // FE28 + UINT32 R13; // FF2C + UINT32 Reserved15; // FE30 + UINT32 R12; // FF34 + UINT32 Reserved14; // FE38 + UINT32 R11; // FF3C + UINT32 Reserved13; // FE40 + UINT32 R10; // FF44 + UINT32 Reserved12; // FE48 + UINT32 R9; // FF4C + UINT32 Reserved11; // FE50 + UINT32 R8; // FF54 + UINT32 Reserved10; // FE58 + UINT32 Rax; // FF5C + UINT32 Reserved9; // FE60 + UINT32 Rcx; // FF64 + UINT32 Reserved8; // FE68 + UINT32 Rdx; // FF6C + UINT32 Reserved7; // FE70 + UINT32 Rbx; // FF74 + UINT32 Reserved6; // FE78 + UINT32 Rsp; // FF7C + UINT32 Reserved5; // FE80 + UINT32 Rbp; // FF84 + UINT32 Reserved4; // FE88 + UINT32 Rsi; // FF8C + UINT32 Reserved3; // FE90 + UINT32 Rdi; // FF94 + UINT32 Reserved2; // FE98 + UINT32 IoMemAddr; // FF9C + UINT32 Reserved1; // FEA0 + UINT32 IoMiscInfo; // FFA4 + UINT32 EsSel; // FFA8 + UINT32 CsSel; // FFAC + UINT32 SsSel; // FFB0 + UINT32 DsSel; // FFB4 + UINT32 FsSel; // FFB8 + UINT32 GsSel; // FFBC + UINT32 LdtrSel; // FFC0 + UINT32 TrSel; // FFC4 + UINT64 Dr7; // FFC8 + UINT64 Dr6; // FFD0 + UINT32 Rip; // FFD8 + UINT32 Reserved0; // FFDC + UINT64 Efr; // FFE0 + UINT64 RFlags; // FFE8 + UINT64 Cr3; // FFF0 + UINT64 Cr0; // FFF8 +} EFI_SMM_CPU_MEROM_SAVE_STATE; + + +typedef struct { + UINT8 Reserved14[0x228]; // FC00-FE28 + UINT32 IO_EIP; // FE28 + UINT8 Reserved13[0x14]; // FE2C-FE40 + UINT32 CR4; // FE40 + UINT8 Reserved12[0x48]; // FE44-FE8C + UINT32 GDT_BASE; // FE8C + UINT8 Reserved11[0xC]; // FE90-FE9C + UINT32 LDT_BASE; // FE9C + UINT8 Reserved10[0x58]; // FEA0-FEF8 + UINT32 SMBASE; + UINT32 REVID; + UINT16 IO_RESTART; + UINT16 HALT_RESTART; + UINT8 Reserved9[0xA4]; + + UINT16 ES; + UINT16 Reserved8; + UINT16 CS; + UINT16 Reserved7; + UINT16 SS; + UINT16 Reserved6; + UINT16 DS; + UINT16 Reserved5; + UINT16 FS; + UINT16 Reserved4; + UINT16 GS; + UINT16 Reserved3; + UINT32 Reserved2; + UINT16 TR; + UINT16 Reserved1; + UINT32 DR7; + UINT32 DR6; + UINT32 EAX; + UINT32 ECX; + UINT32 EDX; + UINT32 EBX; + UINT32 ESP; + UINT32 EBP; + UINT32 ESI; + UINT32 EDI; + UINT32 EIP; + UINT32 EFLAGS; + UINT32 CR3; + UINT32 CR0; +} EFI_SMM_CPU_CT_NOT_ENABLED_SAVE_STATE; + +typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT32 Eip; + UINT16 Cs; + UINT16 Rsvd1; + UINT32 DataOffset; + UINT16 Ds; + UINT8 Rsvd2[10]; + UINT8 St0Mm0[10], Rsvd3[6]; + UINT8 St0Mm1[10], Rsvd4[6]; + UINT8 St0Mm2[10], Rsvd5[6]; + UINT8 St0Mm3[10], Rsvd6[6]; + UINT8 St0Mm4[10], Rsvd7[6]; + UINT8 St0Mm5[10], Rsvd8[6]; + UINT8 St0Mm6[10], Rsvd9[6]; + UINT8 St0Mm7[10], Rsvd10[6]; + UINT8 Rsvd11[22 * 16]; +} EFI_SMM_OPTIONAL_FP_SAVE_STATE; + +typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE32 { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT32 Eip; + UINT16 Cs; + UINT16 Rsvd1; + UINT32 DataOffset; + UINT16 Ds; + UINT8 Reserved2[10]; + UINT8 St0Mm0[10], Rsvd3[6]; + UINT8 St1Mm1[10], Rsvd4[6]; + UINT8 St2Mm2[10], Rsvd5[6]; + UINT8 St3Mm3[10], Rsvd6[6]; + UINT8 St4Mm4[10], Rsvd7[6]; + UINT8 St5Mm5[10], Rsvd8[6]; + UINT8 St6Mm6[10], Rsvd9[6]; + UINT8 St7Mm7[10], Rsvd10[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; + UINT8 Rsvd11[14 * 16]; +} EFI_SMM_OPTIONAL_FP_SAVE_STATE32; + +typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE64 { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT64 Rip; + UINT64 DataOffset; + UINT8 Rsvd1[8]; + UINT8 St0Mm0[10], Rsvd2[6]; + UINT8 St1Mm1[10], Rsvd3[6]; + UINT8 St2Mm2[10], Rsvd4[6]; + UINT8 St3Mm3[10], Rsvd5[6]; + UINT8 St4Mm4[10], Rsvd6[6]; + UINT8 St5Mm5[10], Rsvd7[6]; + UINT8 St6Mm6[10], Rsvd8[6]; + UINT8 St7Mm7[10], Rsvd9[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; + UINT8 Xmm8[16]; + UINT8 Xmm9[16]; + UINT8 Xmm10[16]; + UINT8 Xmm11[16]; + UINT8 Xmm12[16]; + UINT8 Xmm13[16]; + UINT8 Xmm14[16]; + UINT8 Xmm15[16]; + UINT8 Rsvd10[6 * 16]; +} EFI_SMM_OPTIONAL_FP_SAVE_STATE64; + +struct _EFI_SMM_SYSTEM_TABLE; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) ( + IN EFI_SMM_SYSTEM_TABLE * SystemTable, + IN EFI_GUID * Guid, + IN VOID *Table, + IN UINTN TableSize + ) +/*++ + + Routine Description: + The SmmInstallConfigurationTable() function is used to maintain the list + of configuration tables that are stored in the System Management System + Table. The list is stored as an array of (GUID, Pointer) pairs. The list + must be allocated from pool memory with PoolType set to EfiRuntimeServicesData. + + Arguments: + SystemTable - A pointer to the SMM System Table. + Guid - A pointer to the GUID for the entry to add, update, or remove. + Table - A pointer to the buffer of the table to add. + TableSize - The size of the table to install. + + Returns: + EFI_SUCCESS - The (Guid, Table) pair was added, updated, or removed. + EFI_INVALID_PARAMETER - Guid is not valid. + EFI_NOT_FOUND - An attempt was made to delete a non-existent entry. + EFI_OUT_OF_RESOURCES - There is not enough memory available to complete the operation. + +--*/ +; + +// +// System Management System Table (SMST) +// +typedef struct _EFI_SMM_SYSTEM_TABLE { + EFI_TABLE_HEADER Hdr; + + CHAR16 *SmmFirmwareVendor; + UINT32 SmmFirmwareRevision; + + EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable; + + // + // I/O Services + // + EFI_GUID EfiSmmCpuIoGuid; + EFI_SMM_CPU_IO_INTERFACE SmmIo; + + // + // Runtime memory service + // + EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool; + EFI_SMMCORE_FREE_POOL SmmFreePool; + EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages; + EFI_SMMCORE_FREE_PAGES SmmFreePages; + + // + // MP service + // + EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp; + + // + // CPU information records + // + UINTN CurrentlyExecutingCpu; + UINTN NumberOfCpus; + EFI_SMM_CPU_SAVE_STATE *CpuSaveState; + EFI_SMM_OPTIONAL_FP_SAVE_STATE *CpuOptionalFloatingPointState; + + // + // Extensibility table + // + UINTN NumberOfTableEntries; + EFI_CONFIGURATION_TABLE *SmmConfigurationTable; + +} EFI_SMM_SYSTEM_TABLE; + +// +// SMM Handler Definition +// +#define EFI_HANDLER_SUCCESS 0x0000 +#define EFI_HANDLER_CRITICAL_EXIT 0x0001 +#define EFI_HANDLER_SOURCE_QUIESCED 0x0002 +#define EFI_HANDLER_SOURCE_PENDING 0x0003 + +// +// Structure of Communicate Buffer +// +typedef struct { + EFI_GUID HeaderGuid; + UINTN MessageLength; + UINT8 Data[1]; +} EFI_SMM_COMMUNICATE_HEADER; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) ( + IN EFI_HANDLE SmmImageHandle, + IN OUT VOID *CommunicationBuffer OPTIONAL, + IN OUT UINTN *SourceSize OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_CALLBACK_ENTRY_POINT) ( + IN EFI_HANDLE SmmImageHandle, + IN OUT VOID *CommunicationBuffer OPTIONAL, + IN OUT UINTN *SourceSize OPTIONAL + ); + +typedef struct { + EFI_HANDLE SmmHandler; + EFI_DEVICE_PATH_PROTOCOL *HandlerDevicePath; +} EFI_HANDLER_DESCRIPTOR; + +// +// SMM Base Protocol Definition +// +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_REGISTER_HANDLER) ( + IN EFI_SMM_BASE_PROTOCOL * This, + IN EFI_DEVICE_PATH_PROTOCOL * FilePath, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + OUT EFI_HANDLE * ImageHandle, + IN BOOLEAN LegacyIA32Binary OPTIONAL + ) +/*++ + + Routine Description: + Register a given driver into SMRAM. This is the equivalent of performing + the LoadImage/StartImage into System Management Mode. + + Arguments: + This - Protocol instance pointer. + SourceBuffer - Optional source buffer in case of the image file + being in memory. + SourceSize - Size of the source image file, if in memory. + ImageHandle - Pointer to the handle that reflects the driver + loaded into SMM. + LegacyIA32Binary - The binary image to load is legacy 16 bit code. + + Returns: + EFI_SUCCESS - The operation was successful. + EFI_OUT_OF_RESOURCES - There were no additional SMRAM resources to load the handler + EFI_UNSUPPORTED - This platform does not support 16-bit handlers. + EFI_UNSUPPORTED - In runtime. + EFI_INVALID_PARAMETER - The handlers was not the correct image type + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_UNREGISTER_HANDLER) ( + IN EFI_SMM_BASE_PROTOCOL * This, + IN EFI_HANDLE ImageHandle + ) +/*++ + + Routine Description: + Remove a given driver SMRAM. This is the equivalent of performing + the UnloadImage System Management Mode. + + Arguments: + This - Protocol instance pointer. + ImageHandle - Pointer to the handle that reflects the driver + loaded into SMM. + + Returns: + EFI_SUCCESS - The operation was successful + EFI_INVALID_PARAMETER - The handler did not exist + EFI_UNSUPPORTED - In runtime. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_COMMUNICATE) ( + IN EFI_SMM_BASE_PROTOCOL * This, + IN EFI_HANDLE ImageHandle, + IN OUT VOID *CommunicationBuffer, + IN OUT UINTN *SourceSize + ) +/*++ + + Routine Description: + The SMM Inter-module Communicate Service Communicate() function + provides a services to send/received messages from a registered + EFI service. The BASE protocol driver is responsible for doing + any of the copies such that the data lives in boot-service accessible RAM. + + Arguments: + This - Protocol instance pointer. + ImageHandle - Pointer to the handle that reflects the driver + loaded into SMM. + CommunicationBuffer - Pointer to the buffer to convey into SMRAM. + SourceSize - Size of the contents of buffer.. + + Returns: + EFI_SUCCESS - The message was successfully posted + EFI_INVALID_PARAMETER - The buffer was NULL + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_CALLBACK_SERVICE) ( + IN EFI_SMM_BASE_PROTOCOL * This, + IN EFI_HANDLE SmmImageHandle, + IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress, + IN BOOLEAN MakeLast OPTIONAL, + IN BOOLEAN FloatingPointSave OPTIONAL + ) +/*++ + + Routine Description: + Register a callback to execute within SMM. + This allows receipt of messages created with the Boot Service COMMUNICATE. + + Arguments: + This - Protocol instance pointer. + CallbackAddress - Address of the callback service + MakeFirst - If present, will stipulate that the handler is posted + to be the first module executed in the dispatch table. + MakeLast - If present, will stipulate that the handler is posted + to be last executed in the dispatch table. + FloatingPointSave - This is an optional parameter which informs the + EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save + the floating point register state. If any of the handlers + require this, then the state will be saved for all of the handlers. + + Returns: + EFI_SUCCESS - The operation was successful + EFI_OUT_OF_RESOURCES - Not enough space in the dispatch queue + EFI_UNSUPPORTED - In runtime. + EFI_UNSUPPORTED - Not in SMM. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_ALLOCATE_POOL) ( + IN EFI_SMM_BASE_PROTOCOL * This, + IN EFI_MEMORY_TYPE PoolType, + IN UINTN Size, + OUT VOID **Buffer + ) +/*++ + + Routine Description: + The SmmAllocatePool() function allocates a memory region of Size bytes from memory of + type PoolType and returns the address of the allocated memory in the location referenced + by Buffer. This function allocates pages from EFI SMRAM Memory as needed to grow the + requested pool type. All allocations are eight-byte aligned. + + Arguments: + This - Protocol instance pointer. + PoolType - The type of pool to allocate. + The only supported type is EfiRuntimeServicesData; + the interface will internally map this runtime request to SMRAM. + Size - The number of bytes to allocate from the pool. + Buffer - A pointer to a pointer to the allocated buffer if the call + succeeds; undefined otherwise. + + Returns: + EFI_SUCCESS - The requested number of bytes was allocated. + EFI_OUT_OF_RESOURCES - The pool requested could not be allocated. + EFI_INVALID_PARAMETER - PoolType was invalid. + EFI_UNSUPPORTED - In runtime. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_FREE_POOL) ( + IN EFI_SMM_BASE_PROTOCOL * This, + IN VOID *Buffer + ) +/*++ + + Routine Description: + The SmmFreePool() function returns the memory specified by Buffer to the system. + On return, the memory's type is EFI SMRAM Memory. The Buffer that is freed must + have been allocated by SmmAllocatePool(). + + Arguments: + This - Protocol instance pointer. + Buffer - Pointer to the buffer allocation. + + Returns: + EFI_SUCCESS - The memory was returned to the system. + EFI_INVALID_PARAMETER - Buffer was invalid. + EFI_UNSUPPORTED - In runtime. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_INSIDE_OUT) ( + IN EFI_SMM_BASE_PROTOCOL * This, + OUT BOOLEAN *InSmm + ) +/*++ + + Routine Description: + This routine tells caller if execution context is SMM or not. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - The operation was successful + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_GET_SMST_LOCATION) ( + IN EFI_SMM_BASE_PROTOCOL * This, + IN OUT EFI_SMM_SYSTEM_TABLE **Smst + ) +/*++ + + Routine Description: + The GetSmstLocation() function returns the locatin of the System Management + Service Table. The use of the API is such that a driver can discover the + location of the SMST in its entry point and then cache it in some driver + global variable so that the SMST can be invoked in subsequent callbacks. + + Arguments: + This - Protocol instance pointer. + Smst - Pointer to the SMST. + + Returns: + EFI_SUCCESS - The operation was successful + EFI_INVALID_PARAMETER - Smst was invalid. + EFI_UNSUPPORTED - Not in SMM. + +--*/ +; + +typedef struct _EFI_SMM_BASE_PROTOCOL { + EFI_SMM_REGISTER_HANDLER Register; + EFI_SMM_UNREGISTER_HANDLER UnRegister; + EFI_SMM_COMMUNICATE Communicate; + EFI_SMM_CALLBACK_SERVICE RegisterCallback; + EFI_SMM_INSIDE_OUT InSmm; + EFI_SMM_ALLOCATE_POOL SmmAllocatePool; + EFI_SMM_FREE_POOL SmmFreePool; + EFI_SMM_GET_SMST_LOCATION GetSmstLocation; +} EFI_SMM_BASE_PROTOCOL; + +extern EFI_GUID gEfiSmmBaseProtocolGuid; +extern EFI_GUID gEfiSmmCpuIoGuid; +extern EFI_GUID gEfiSmmCommunicateHeaderGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.c new file mode 100644 index 0000000000..d20283d044 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmControl.c + +Abstract: + + This file defines SMM Control abstraction protocol defined by the + SMM Component Interface Specification + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmControl) + +EFI_GUID gEfiSmmControlProtocolGuid = EFI_SMM_CONTROL_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSmmControlProtocolGuid, "SMM Control Protocol", "SMM Control protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.h new file mode 100644 index 0000000000..cf1bff0ccb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmControl/SmmControl.h @@ -0,0 +1,79 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmControl.h + +Abstract: + + This file defines SMM Control abstraction protocol defined + by the SMM CIS. + +--*/ + +#ifndef _SMM_CONTROL_H_ +#define _SMM_CONTROL_H_ + +EFI_FORWARD_DECLARATION (EFI_SMM_CONTROL_PROTOCOL); + +#define EFI_SMM_CONTROL_PROTOCOL_GUID \ + { \ + 0x8d12e231, 0xc667, 0x4fd1, 0x98, 0xf2, 0x24, 0x49, 0xa7, 0xe7, 0xb2, 0xe5 \ + } + +// +// SMM Control specification constant and types +// +// typedef EFI_SMM_PERIOD UINTN +// +// SMM Access specification Data Structures +// +typedef struct { + UINT8 SmiTriggerRegister; + UINT8 SmiDataRegister; +} EFI_SMM_CONTROL_REGISTER; + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_ACTIVATE) ( + IN EFI_SMM_CONTROL_PROTOCOL * This, + IN OUT INT8 *ArgumentBuffer OPTIONAL, + IN OUT UINTN *ArgumentBufferSize OPTIONAL, + IN BOOLEAN Periodic OPTIONAL, + IN UINTN ActivationInterval OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_DEACTIVATE) ( + IN EFI_SMM_CONTROL_PROTOCOL * This, + IN BOOLEAN Periodic OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_GET_REGISTER_INFO) ( + IN EFI_SMM_CONTROL_PROTOCOL * This, + IN OUT EFI_SMM_CONTROL_REGISTER * SmiRegister + ); + +typedef struct _EFI_SMM_CONTROL_PROTOCOL { + EFI_SMM_ACTIVATE Trigger; + EFI_SMM_DEACTIVATE Clear; + EFI_SMM_GET_REGISTER_INFO GetRegisterInfo; + UINTN MinimumTriggerPeriod; +} EFI_SMM_CONTROL_PROTOCOL; + +extern EFI_GUID gEfiSmmControlProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h new file mode 100644 index 0000000000..05cc983347 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h @@ -0,0 +1,150 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + CpuSaveState.h + +Abstract: + + Define data structures used by EFI_SMM_CPU_SAVE_STATE protocol. + +Revision History + +++*/ + +#ifndef _CPUSAVESTATE_H_ +#define _CPUSAVESTATE_H_ + +typedef unsigned char ASM_UINT8; +typedef ASM_UINT8 ASM_BOOL; +typedef unsigned short ASM_UINT16; +typedef unsigned long ASM_UINT32; + +#ifdef _H2INC +typedef double ASM_UINT64; +#else +typedef unsigned __int64 ASM_UINT64; +#endif + +#pragma pack (push) +#pragma pack (1) + +typedef struct _EFI_SMM_CPU_STATE32 { + ASM_UINT8 Reserved1[0xf8]; // fe00h + ASM_UINT32 SMBASE; // fef8h + ASM_UINT32 SMMRevId; // fefch + ASM_UINT16 IORestart; // ff00h + ASM_UINT16 AutoHALTRestart; // ff02h + ASM_UINT32 IEDBASE; // ff04h + ASM_UINT8 Reserved2[0x98]; // ff08h + ASM_UINT32 IOMemAddr; // ffa0h + ASM_UINT32 IOMisc; // ffa4h + ASM_UINT32 _ES; + ASM_UINT32 _CS; + ASM_UINT32 _SS; + ASM_UINT32 _DS; + ASM_UINT32 _FS; + ASM_UINT32 _GS; + ASM_UINT32 _LDTBase; + ASM_UINT32 _TR; + ASM_UINT32 _DR7; + ASM_UINT32 _DR6; + ASM_UINT32 _EAX; + ASM_UINT32 _ECX; + ASM_UINT32 _EDX; + ASM_UINT32 _EBX; + ASM_UINT32 _ESP; + ASM_UINT32 _EBP; + ASM_UINT32 _ESI; + ASM_UINT32 _EDI; + ASM_UINT32 _EIP; + ASM_UINT32 _EFLAGS; + ASM_UINT32 _CR3; + ASM_UINT32 _CR0; +} EFI_SMM_CPU_STATE32; + +typedef struct _EFI_SMM_CPU_STATE64 { + ASM_UINT8 Reserved1[0x1d0]; // fc00h + ASM_UINT32 GdtBaseHiDword; // fdd0h + ASM_UINT32 LdtBaseHiDword; // fdd4h + ASM_UINT32 IdtBaseHiDword; // fdd8h + ASM_UINT8 Reserved2[0xc]; // fddch + ASM_UINT64 IO_EIP; // fde8h + ASM_UINT8 Reserved3[0x50]; // fdf0h + ASM_UINT32 _CR4; // fe40h + ASM_UINT8 Reserved4[0x48]; // fe44h + ASM_UINT32 GdtBaseLoDword; // fe8ch + ASM_UINT32 GdtLimit; // fe90h + ASM_UINT32 IdtBaseLoDword; // fe94h + ASM_UINT32 IdtLimit; // fe98h + ASM_UINT32 LdtBaseLoDword; // fe9ch + ASM_UINT32 LdtLimit; // fea0h + ASM_UINT32 LdtInfo; // fea4h + ASM_UINT8 Reserved5[0x50]; // fea8h + ASM_UINT32 SMBASE; // fef8h + ASM_UINT32 SMMRevId; // fefch + ASM_UINT16 IORestart; // ff00h + ASM_UINT16 AutoHALTRestart; // ff02h + ASM_UINT32 IEDBASE; // ff04h + ASM_UINT8 Reserved6[0x14]; // ff08h + ASM_UINT64 _R15; // ff1ch + ASM_UINT64 _R14; + ASM_UINT64 _R13; + ASM_UINT64 _R12; + ASM_UINT64 _R11; + ASM_UINT64 _R10; + ASM_UINT64 _R9; + ASM_UINT64 _R8; + ASM_UINT64 _RAX; // ff5ch + ASM_UINT64 _RCX; + ASM_UINT64 _RDX; + ASM_UINT64 _RBX; + ASM_UINT64 _RSP; + ASM_UINT64 _RBP; + ASM_UINT64 _RSI; + ASM_UINT64 _RDI; + ASM_UINT64 IOMemAddr; // ff9ch + ASM_UINT32 IOMisc; // ffa4h + ASM_UINT32 _ES; // ffa8h + ASM_UINT32 _CS; + ASM_UINT32 _SS; + ASM_UINT32 _DS; + ASM_UINT32 _FS; + ASM_UINT32 _GS; + ASM_UINT32 _LDTR; // ffc0h + ASM_UINT32 _TR; + ASM_UINT64 _DR7; // ffc8h + ASM_UINT64 _DR6; + ASM_UINT64 _RIP; // ffd8h + ASM_UINT64 IA32_EFER; // ffe0h + ASM_UINT64 _RFLAGS; // ffe8h + ASM_UINT64 _CR3; // fff0h + ASM_UINT64 _CR0; // fff8h +} EFI_SMM_CPU_STATE64; + +#pragma warning (push) +#pragma warning (disable: 4201) +typedef union _EFI_SMM_CPU_STATE { + struct { + ASM_UINT8 Reserved[0x200]; + EFI_SMM_CPU_STATE32 x86; + }; + EFI_SMM_CPU_STATE64 x64; +} EFI_SMM_CPU_STATE; +#pragma warning (pop) + +#pragma pack (pop) + +#define EFI_SMM_MIN_REV_ID_x64 0x30006 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c new file mode 100644 index 0000000000..703b35591d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmCpuState.c + +Abstract: + + Protocol definition for EFI_SMM_CPU_SAVE_STATE protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmCpuState) + +EFI_GUID gEfiSmmCpuSaveStateProtocolGuid = EFI_SMM_CPU_SAVE_STATE_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiSmmCpuSaveStateProtocolGuid, "SMM CPU Save State Protocol", "SMM CPU Save State Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h new file mode 100644 index 0000000000..1a6c79d0ca --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h @@ -0,0 +1,43 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmCpuState.h + +Abstract: + + Protocol definition for EFI_SMM_CPU_SAVE_STATE protocol + +Revision History + +--*/ + +#ifndef _SMMSAVESTATE_H_ +#define _SMMSAVESTATE_H_ + +#include "CpuSaveState.h" + +// +// Global ID for the Sx SMI Protocol +// +// {21F302AD-6E94-471b-84BC-B14800403A1D} +#define EFI_SMM_CPU_SAVE_STATE_PROTOCOL_GUID \ + { 0x21f302ad, 0x6e94, 0x471b, 0x84, 0xbc, 0xb1, 0x48, 0x0, 0x40, 0x3a, 0x1d } + +typedef struct _EFI_SMM_CPU_SAVE_STATE_PROTOCOL { + EFI_SMM_CPU_STATE **CpuSaveState; +} EFI_SMM_CPU_SAVE_STATE_PROTOCOL; + +extern EFI_GUID gEfiSmmCpuSaveStateProtocolGuid; + +#endif // _SMMSAVESTATE_H_ \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c new file mode 100644 index 0000000000..4bf9c73015 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmGpiDispatch.c + +Abstract: + + EFI Smm Gpi Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmGpiDispatch) + +EFI_GUID gEfiSmmGpiDispatchProtocolGuid = EFI_SMM_GPI_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiSmmGpiDispatchProtocolGuid, "SMM GPI SMI Dispatch Protocol", "EFI 2.0 SMM GPI SMI Dispatch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h new file mode 100644 index 0000000000..861418e227 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h @@ -0,0 +1,152 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmGpiDispatch.h + +Abstract: + + EFI Smm Gpi Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_GPI_DISPATCH_H_ +#define _EFI_SMM_GPI_DISPATCH_H_ + +// +// Global ID for the GPI SMI Protocol +// +#define EFI_SMM_GPI_DISPATCH_PROTOCOL_GUID \ + { \ + 0xe0744b81, 0x9513, 0x49cd, 0x8c, 0xea, 0xe9, 0x24, 0x5e, 0x70, 0x39, 0xda \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_GPI_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +// +// GpiMask is a bit mask of 32 possible general purpose inputs that can generate a +// a SMI. Bit 0 corresponds to logical GPI[0], 1 corresponds to logical GPI[1], etc. +// +// The logical GPI index to physical pin on device is described by the GPI device name +// found on the same handle as the GpiSmi child dispatch protocol. The GPI device name +// is defined as protocol with a GUID name and NULL protocol pointer. +// +typedef struct { + UINTN GpiNum; +} EFI_SMM_GPI_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_GPI_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_GPI_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a GPI SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The DispatchContext fields are filled in + by the dispatching driver prior to + invoking this dispatch function. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_GPI_REGISTER) ( + IN EFI_SMM_GPI_DISPATCH_PROTOCOL * This, + IN EFI_SMM_GPI_DISPATCH DispatchFunction, + IN EFI_SMM_GPI_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function the GPI(s) for which the dispatch function + should be invoked. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_DEVICE_ERROR - The driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. The GPI input value + is not within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_GPI_UNREGISTER) ( + IN EFI_SMM_GPI_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + unregistered and the SMI source has been disabled + if there are no other registered child dispatch + functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM GPI SMI Dispatch Protocol +// +typedef struct _EFI_SMM_GPI_DISPATCH_PROTOCOL { + EFI_SMM_GPI_REGISTER Register; + EFI_SMM_GPI_UNREGISTER UnRegister; + UINTN NumSupportedGpis; +} EFI_SMM_GPI_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmGpiDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c new file mode 100644 index 0000000000..a224873995 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmIchnDispatch.c + +Abstract: + + EFI Smm ICH N Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmIchnDispatch) + +EFI_GUID gEfiSmmIchnDispatchProtocolGuid = EFI_SMM_ICHN_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiSmmIchnDispatchProtocolGuid, "SMM ICHn SMI Dispatch Protocol", "EFI 2.0 SMM ICHn SMI Dispatch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h new file mode 100644 index 0000000000..70d92f4620 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h @@ -0,0 +1,204 @@ +/*++ + +Copyright (c) 1999 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmIchnDispatch.h + +Abstract: + + EFI Smm ICH [N] Specific Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_ICHN_DISPATCH_H_ +#define _EFI_SMM_ICHN_DISPATCH_H_ + +// +// Global ID for the ICH SMI Protocol +// +#define EFI_SMM_ICHN_DISPATCH_PROTOCOL_GUID \ + { \ + 0xc50b323e, 0x9075, 0x4f2a, 0xac, 0x8e, 0xd2, 0x59, 0x6a, 0x10, 0x85, 0xcc \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_ICHN_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +// +// ICHN Specific SMIs. These are miscellaneous SMI sources that are supported by the +// ICHN specific SMI implementation. These may change over time. TrapNumber is only +// valid if the Type is Trap. +// +typedef enum { + // + // NOTE: NEVER delete items from this list/enumeration! Doing so will prevent other versions + // of the code from compiling. If the ICH version your driver is written for doesn't support + // some of these SMIs, then simply return EFI_UNSUPPORTED when a child/client tries to register + // for them. + // + IchnMch, + IchnPme, + IchnRtcAlarm, + IchnRingIndicate, + IchnAc97Wake, + IchnSerialIrq, + IchnY2KRollover, + IchnTcoTimeout, + IchnOsTco, + IchnNmi, + IchnIntruderDetect, + IchnBiosWp, + IchnMcSmi, + IchnPmeB0, + IchnThrmSts, + IchnSmBus, + IchnIntelUsb2, + IchnMonSmi7, + IchnMonSmi6, + IchnMonSmi5, + IchnMonSmi4, + IchnDevTrap13, + IchnDevTrap12, + IchnDevTrap11, + IchnDevTrap10, + IchnDevTrap9, + IchnDevTrap8, + IchnDevTrap7, + IchnDevTrap6, + IchnDevTrap5, + IchnDevTrap3, + IchnDevTrap2, + IchnDevTrap1, + IchnDevTrap0, + IchnIoTrap3, + IchnIoTrap2, + IchnIoTrap1, + IchnIoTrap0, + IchnPciExpress, + IchnMonitor, + IchnSpi, + IchnQRT, + IchnGpioUnlock, + // + // INSERT NEW ITEMS JUST BEFORE THIS LINE + // + NUM_ICHN_TYPES // the number of items in this enumeration +} EFI_SMM_ICHN_SMI_TYPE; + +typedef struct { + EFI_SMM_ICHN_SMI_TYPE Type; +} EFI_SMM_ICHN_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_ICHN_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_ICHN_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a ICH n specific SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The DispatchContext fields are filled in + by the dispatching driver prior to + invoking this dispatch function. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_ICHN_REGISTER) ( + IN EFI_SMM_ICHN_DISPATCH_PROTOCOL * This, + IN EFI_SMM_ICHN_DISPATCH DispatchFunction, + IN EFI_SMM_ICHN_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function the ICHN SMI source for which the dispatch + function should be invoked. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_DEVICE_ERROR - The driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. The ICHN input value + is not within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_ICHN_UNREGISTER) ( + IN EFI_SMM_ICHN_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + unregistered and the SMI source has been disabled + if there are no other registered child dispatch + functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM Ich n specific SMI Dispatch Protocol +// +typedef struct _EFI_SMM_ICHN_DISPATCH_PROTOCOL { + EFI_SMM_ICHN_REGISTER Register; + EFI_SMM_ICHN_UNREGISTER UnRegister; +} EFI_SMM_ICHN_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmIchnDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c new file mode 100644 index 0000000000..dc3c69231a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmPeriodicTimerDispatch.c + +Abstract: + + EFI Smm Periodic Timer Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmPeriodicTimerDispatch) + +EFI_GUID gEfiSmmPeriodicTimerDispatchProtocolGuid = EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiSmmPeriodicTimerDispatchProtocolGuid, "SMM Periodic Timer SMI Dispatch Protocol", + "EFI 2.0 SMM Periodic Timer SMI Dispatch Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h new file mode 100644 index 0000000000..9aabb0c671 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h @@ -0,0 +1,205 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmPeriodicTimerDispatch.h + +Abstract: + + EFI Smm Periodic Timer Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_PERIODIC_TIMER_DISPATCH_H_ +#define _EFI_SMM_PERIODIC_TIMER_DISPATCH_H_ + +// +// Global ID for the Periodic Timer SMI Protocol +// +#define EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL_GUID \ + { \ + 0x9cca03fc, 0x4c9e, 0x4a19, 0x9b, 0x6, 0xed, 0x7b, 0x47, 0x9b, 0xde, 0x55 \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +// +// Period is the minimum period of time in 100 nanosecond units that child gets called. +// The child will be called back after a time greater than the time Period. +// +// SmiTickInterval is the period of time interval between SMIs. Children of this interface +// should use this field when registering for periodic timer intervals when a finer +// granularity periodic SMI is desired. Valid values for this field are those returned +// by GetNextInterval. A value of 0 indicates the parent is allowed to use any SMI +// interval period to satisfy the requested period. +// Example: A chipset supports periodic SMIs on every 64ms or 2 seconds. +// A child wishes schedule a period SMI to fire on a period of 3 seconds, there +// are several ways to approach the problem: +// 1. The child may accept a 4 second periodic rate, in which case it registers with +// Period = 40000 +// SmiTickInterval = 20000 +// The resulting SMI will occur every 2 seconds with the child called back on +// every 2nd SMI. +// NOTE: the same result would occur if the child set SmiTickInterval = 0. +// 2. The child may choose the finer granularity SMI (64ms): +// Period = 30000 +// SmiTickInterval = 640 +// The resulting SMI will occur every 64ms with the child called back on +// every 47th SMI. +// NOTE: the child driver should be aware that this will result in more +// SMIs occuring during system runtime which can negatively impact system +// performance. +// +// ElapsedTime is the actual time in 100 nanosecond units elapsed since last called, a +// value of 0 indicates an unknown amount of time. +// +typedef struct { + UINT64 Period; + UINT64 SmiTickInterval; + UINT64 ElapsedTime; +} EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_PERIODIC_TIMER_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a Periodic Timer SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The DispatchContext fields are filled in + by the dispatching driver prior to + invoking this dispatch function. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_PERIODIC_TIMER_INTERVAL) ( + IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL * This, + IN OUT UINT64 **SmiTickInterval + ); + +/*++ + + Routine Description: + Returns the next SMI tick period supported by the chipset. The order + returned is from longest to shortest interval period. + + Arguments: + This - Protocol instance pointer. + SmiTickInterval - Pointer to pointer of next shorter SMI interval + period supported by the child. This parameter + works as a get-first, get-next field. The first + time this function is called, *SmiTickInterval + should be set to NULL to get the longest SMI + interval. The returned *SmiTickInterval should + be passed in on subsequent calls to get + the next shorter interval period until + *SmiTickInterval = NULL. + + Returns: + EFI_SUCCESS + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_PERIODIC_TIMER_REGISTER) ( + IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL * This, + IN EFI_SMM_PERIODIC_TIMER_DISPATCH DispatchFunction, + IN EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function the period at which the dispatch function + should be invoked. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_DEVICE_ERROR - The driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. The period input value + is not within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_PERIODIC_TIMER_UNREGISTER) ( + IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + unregistered and the SMI source has been disabled + if there are no other registered child dispatch + functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM Periodic Timer Dispatch Protocol +// +typedef struct _EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL { + EFI_SMM_PERIODIC_TIMER_REGISTER Register; + EFI_SMM_PERIODIC_TIMER_UNREGISTER UnRegister; + EFI_SMM_PERIODIC_TIMER_INTERVAL GetNextShorterInterval; +} EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmPeriodicTimerDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c new file mode 100644 index 0000000000..5124fca68d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmPowerButtonDispatch.c + +Abstract: + + EFI Smm Power Button Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmPowerButtonDispatch) + +EFI_GUID gEfiSmmPowerButtonDispatchProtocolGuid = EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiSmmPowerButtonDispatchProtocolGuid, "SMM Power Button SMI Dispatch Protocol", + "EFI 2.0 SMM Power Button SMI Dispatch Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h new file mode 100644 index 0000000000..2e53bf583d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h @@ -0,0 +1,153 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmPowerButtonDispatch.h + +Abstract: + + EFI Smm Power Button Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_POWER_BUTTON_DISPATCH_H_ +#define _EFI_SMM_POWER_BUTTON_DISPATCH_H_ + +// +// Global ID for the Power Button SMI Protocol +// +#define EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL_GUID \ + { \ + 0xb709efa0, 0x47a6, 0x4b41, 0xb9, 0x31, 0x12, 0xec, 0xe7, 0xa8, 0xee, 0x56 \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +// +// Power Button. Example, Use for changing LEDs before ACPI OS is on. +// - DXE/BDS Phase +// - OS Install Phase +// +typedef enum { + PowerButtonEntry, + PowerButtonExit +} EFI_POWER_BUTTON_PHASE; + +typedef struct { + EFI_POWER_BUTTON_PHASE Phase; +} EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_POWER_BUTTON_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a Power Button SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The DispatchContext fields are filled in + by the dispatching driver prior to + invoking this dispatch function. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_POWER_BUTTON_REGISTER) ( + IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL * This, + IN EFI_SMM_POWER_BUTTON_DISPATCH DispatchFunction, + IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function the Power Button SMI phase for which the dispatch + function should be invoked. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_DEVICE_ERROR - The driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. The Power Button SMI + phase is not within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_POWER_BUTTON_UNREGISTER) ( + IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + unregistered and the SMI source has been disabled + if there are no other registered child dispatch + functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM Power Button SMI Dispatch Protocol +// +typedef struct _EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL { + EFI_SMM_POWER_BUTTON_REGISTER Register; + EFI_SMM_POWER_BUTTON_UNREGISTER UnRegister; +} EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmPowerButtonDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c new file mode 100644 index 0000000000..0967d3850b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmStandbyButtonDispatch.c + +Abstract: + + EFI Smm Standby Button Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmStandbyButtonDispatch) + +EFI_GUID gEfiSmmStandbyButtonDispatchProtocolGuid = EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiSmmStandbyButtonDispatchProtocolGuid, "SMM Standby Button SMI Dispatch Protocol", + "EFI 2.0 SMM Standby Button SMI Dispatch Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h new file mode 100644 index 0000000000..9426cd4ffa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h @@ -0,0 +1,153 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmStandbyButtonDispatch.h + +Abstract: + + EFI Smm Standby Button Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_STANDBY_BUTTON_DISPATCH_H_ +#define _EFI_SMM_STANDBY_BUTTON_DISPATCH_H_ + +// +// Global ID for the Standby Button SMI Protocol +// +#define EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL_GUID \ + { \ + 0x78965b98, 0xb0bf, 0x449e, 0x8b, 0x22, 0xd2, 0x91, 0x4e, 0x49, 0x8a, 0x98 \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +// +// Standby Button. Example, Use for changing LEDs before ACPI OS is on. +// - DXE/BDS Phase +// - OS Install Phase +// +typedef enum { + Entry, + Exit +} EFI_STANDBY_BUTTON_PHASE; + +typedef struct { + EFI_STANDBY_BUTTON_PHASE Phase; +} EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_STANDBY_BUTTON_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a Standby Button SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The DispatchContext fields are filled in + by the dispatching driver prior to + invoking this dispatch function. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_STANDBY_BUTTON_REGISTER) ( + IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL * This, + IN EFI_SMM_STANDBY_BUTTON_DISPATCH DispatchFunction, + IN EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function the Standby Button SMI phase for which the dispatch + function should be invoked. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_DEVICE_ERROR - The driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. The Standby Button SMI + phase is not within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_STANDBY_BUTTON_UNREGISTER) ( + IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + unregistered and the SMI source has been disabled + if there are no other registered child dispatch + functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM Standby Button SMI Dispatch Protocol +// +typedef struct _EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL { + EFI_SMM_STANDBY_BUTTON_REGISTER Register; + EFI_SMM_STANDBY_BUTTON_UNREGISTER UnRegister; +} EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmStandbyButtonDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c new file mode 100644 index 0000000000..593b40659a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmStatusCode.c + +Abstract: + + SMM Status code Protocol as defined in EFI 2.0 (for Status Code Architectural Protocol) + + This code abstracts Status Code reporting. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmStatusCode) + +EFI_GUID gEfiSmmStatusCodeProtocolGuid = EFI_SMM_STATUS_CODE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSmmStatusCodeProtocolGuid, "SMM Status Code", "SMM Status Code Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h new file mode 100644 index 0000000000..ef9a08918c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmStatusCode.h + +Abstract: + + SMM Status code Protocol as defined in the DXE CIS (Status Code Architectural Protocol) + + This code abstracts SMM Status Code reporting. + +--*/ + +#ifndef _PROTOCOL_SMM_STATUS_CODE_H__ +#define _PROTOCOL_SMM_STATUS_CODE_H__ + +// +// Global ID for the Smm Status Code Protocol +// +#define EFI_SMM_STATUS_CODE_PROTOCOL_GUID \ + { \ + 0x6afd2b77, 0x98c1, 0x4acd, 0xa6, 0xf9, 0x8a, 0x94, 0x39, 0xde, 0xf, 0xb1 \ + } + +extern EFI_GUID gEfiSmmStatusCodeProtocolGuid; + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_SMM_STATUS_CODE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_REPORT_STATUS_CODE) ( + IN EFI_SMM_STATUS_CODE_PROTOCOL * This, + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ); + +typedef struct _EFI_SMM_STATUS_CODE_PROTOCOL { + EFI_SMM_REPORT_STATUS_CODE ReportStatusCode; +} EFI_SMM_STATUS_CODE_PROTOCOL; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c new file mode 100644 index 0000000000..c6ff0aa021 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmSwDispatch.c + +Abstract: + + EFI Smm Software Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmSwDispatch) + +EFI_GUID gEfiSmmSwDispatchProtocolGuid = EFI_SMM_SW_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSmmSwDispatchProtocolGuid, "SMM Sw SMI Dispatch Protocol", "EFI 2.0 SMM Sw SMI Dispatch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h new file mode 100644 index 0000000000..765d1baa29 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h @@ -0,0 +1,151 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmSwDispatch.h + +Abstract: + + EFI Smm Software Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_SW_DISPATCH_H_ +#define _EFI_SMM_SW_DISPATCH_H_ + +// +// Global ID for the SW SMI Protocol +// +#define EFI_SMM_SW_DISPATCH_PROTOCOL_GUID \ + { \ + 0xe541b773, 0xdd11, 0x420c, 0xb0, 0x26, 0xdf, 0x99, 0x36, 0x53, 0xf8, 0xbf \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_SW_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +// +// A particular chipset may not support all possible software SMI input values. +// For example, the ICH supports only values 00h to 0FFh. The parent only allows a single +// child registration for each SwSmiInputValue. +// +typedef struct { + UINTN SwSmiInputValue; +} EFI_SMM_SW_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_SW_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_SW_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a Software SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The SwSmiInputValue field is filled in + by the software dispatch driver prior to + invoking this dispatch function. + The dispatch function will only be called + for input values for which it is registered. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_SW_REGISTER) ( + IN EFI_SMM_SW_DISPATCH_PROTOCOL * This, + IN EFI_SMM_SW_DISPATCH DispatchFunction, + IN EFI_SMM_SW_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function which Software SMI input value the + dispatch function should be invoked for. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_DEVICE_ERROR - The SW driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. The SW SMI input value + is not within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_SW_UNREGISTER) ( + IN EFI_SMM_SW_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + unregistered and the SMI source has been disabled + if there are no other registered child dispatch + functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM Software SMI Dispatch Protocol +// +typedef struct _EFI_SMM_SW_DISPATCH_PROTOCOL { + EFI_SMM_SW_REGISTER Register; + EFI_SMM_SW_UNREGISTER UnRegister; + UINTN MaximumSwiValue; +} EFI_SMM_SW_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmSwDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c new file mode 100644 index 0000000000..8ef15b57b4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmSxDispatch.c + +Abstract: + + EFI Smm Sx Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmSxDispatch) + +EFI_GUID gEfiSmmSxDispatchProtocolGuid = EFI_SMM_SX_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiSmmSxDispatchProtocolGuid, "SMM Sx Dispatch Protocol", "EFI 2.0 SMM Sx Dispatch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h new file mode 100644 index 0000000000..e80272f7f2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h @@ -0,0 +1,170 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmSxDispatch.h + +Abstract: + + EFI Smm Sx Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_SX_DISPATCH_H_ +#define _EFI_SMM_SX_DISPATCH_H_ + +// +// Global ID for the Sx SMI Protocol +// +#define EFI_SMM_SX_DISPATCH_PROTOCOL_GUID \ + { \ + 0x14fc52be, 0x1dc, 0x426c, 0x91, 0xae, 0xa2, 0x3c, 0x3e, 0x22, 0xa, 0xe8 \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_SX_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +typedef enum { + SxS0, + SxS1, + SxS2, + SxS3, + SxS4, + SxS5, + EfiMaximumSleepType +} EFI_SLEEP_TYPE; + +typedef enum { + SxEntry, + SxExit, + EfiMaximumPhase +} EFI_SLEEP_PHASE; + +typedef struct { + EFI_SLEEP_TYPE Type; + EFI_SLEEP_PHASE Phase; +} EFI_SMM_SX_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_SX_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_SX_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a Sx state SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The Type and Phase fields are filled in + by the Sx dispatch driver prior to invoking + this dispatch function. + For this intertace, the Sx driver will call the + dispatch function for all Sx type and phases, + so the Sx state handler(s) must check the Type + and Phase field of the Dispatch context and act + accordingly. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_SX_REGISTER) ( + IN EFI_SMM_SX_DISPATCH_PROTOCOL * This, + IN EFI_SMM_SX_DISPATCH DispatchFunction, + IN EFI_SMM_SX_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function which Sx state type and phase the caller + wishes to be called back on. For this intertace, + the Sx driver will call the registered handlers for + all Sx type and phases, so the Sx state handler(s) + must check the Type and Phase field of the Dispatch + context and act accordingly. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_UNSUPPORTED - The Sx driver or hardware does not support that + Sx Type/Phase. + EFI_DEVICE_ERROR - The Sx driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. Type & Phase are not + within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_SX_UNREGISTER) ( + IN EFI_SMM_SX_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully unregistered and the + SMI source has been disabled if there are no other registered child + dispatch functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM Child Dispatch Protocol +// +typedef struct _EFI_SMM_SX_DISPATCH_PROTOCOL { + EFI_SMM_SX_REGISTER Register; + EFI_SMM_SX_UNREGISTER UnRegister; +} EFI_SMM_SX_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmSxDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c new file mode 100644 index 0000000000..32d1f705d5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmUsbDispatch.c + +Abstract: + + EFI Smm USB Smi Child Protocol + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (SmmUsbDispatch) + +EFI_GUID gEfiSmmUsbDispatchProtocolGuid = EFI_SMM_USB_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiSmmUsbDispatchProtocolGuid, "SMM USB SMI Dispatch Protocol", "EFI 2.0 SMM USB SMI Dispatch Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h new file mode 100644 index 0000000000..386aad23bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h @@ -0,0 +1,149 @@ +/*++ + +Copyright (c) 1999 - 2002, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SmmUsbDispatch.h + +Abstract: + + EFI Smm USB Smi Child Protocol + +Revision History + +--*/ + +#ifndef _EFI_SMM_USB_DISPATCH_H_ +#define _EFI_SMM_USB_DISPATCH_H_ + +// +// Global ID for the USB Protocol +// +#define EFI_SMM_USB_DISPATCH_PROTOCOL_GUID \ + { \ + 0xa05b6ffd, 0x87af, 0x4e42, 0x95, 0xc9, 0x62, 0x28, 0xb6, 0x3c, 0xf3, 0xf3 \ + } + +EFI_FORWARD_DECLARATION (EFI_SMM_USB_DISPATCH_PROTOCOL); + +// +// Related Definitions +// +typedef enum { + UsbLegacy, + UsbWake +} EFI_USB_SMI_TYPE; + +typedef struct { + EFI_USB_SMI_TYPE Type; + EFI_DEVICE_PATH_PROTOCOL *Device; +} EFI_SMM_USB_DISPATCH_CONTEXT; + +// +// Member functions +// +typedef +VOID +(EFIAPI *EFI_SMM_USB_DISPATCH) ( + IN EFI_HANDLE DispatchHandle, + IN EFI_SMM_USB_DISPATCH_CONTEXT * DispatchContext + ); + +/*++ + + Routine Description: + Dispatch function for a USB SMI handler. + + Arguments: + DispatchHandle - Handle of this dispatch function. + DispatchContext - Pointer to the dispatch function's context. + The DispatchContext fields are filled in + by the dispatching driver prior to + invoking this dispatch function. + + Returns: + Nothing + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_USB_REGISTER) ( + IN EFI_SMM_USB_DISPATCH_PROTOCOL * This, + IN EFI_SMM_USB_DISPATCH DispatchFunction, + IN EFI_SMM_USB_DISPATCH_CONTEXT * DispatchContext, + OUT EFI_HANDLE * DispatchHandle + ); + +/*++ + + Routine Description: + Register a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchFunction - Pointer to dispatch function to be invoked for + this SMI source + DispatchContext - Pointer to the dispatch function's context. + The caller fills this context in before calling + the register function to indicate to the register + function the USB SMI types for which the dispatch + function should be invoked. + DispatchHandle - Handle of dispatch function, for when interfacing + with the parent Sx state SMM driver. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + registered and the SMI source has been enabled. + EFI_DEVICE_ERROR - The driver was unable to enable the SMI source. + EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this + child. + EFI_INVALID_PARAMETER - DispatchContext is invalid. The USB SMI type + is not within valid range. + +--*/ +typedef +EFI_STATUS +(EFIAPI *EFI_SMM_USB_UNREGISTER) ( + IN EFI_SMM_USB_DISPATCH_PROTOCOL * This, + IN EFI_HANDLE DispatchHandle + ); + +/*++ + + Routine Description: + Unregister a child SMI source dispatch function with a parent SMM driver + + Arguments: + This - Protocol instance pointer. + DispatchHandle - Handle of dispatch function to deregister. + + Returns: + EFI_SUCCESS - The dispatch function has been successfully + unregistered and the SMI source has been disabled + if there are no other registered child dispatch + functions for this SMI source. + EFI_INVALID_PARAMETER - Handle is invalid. + other - TBD + +--*/ + +// +// Interface structure for the SMM USB SMI Dispatch Protocol +// +typedef struct _EFI_SMM_USB_DISPATCH_PROTOCOL { + EFI_SMM_USB_REGISTER Register; + EFI_SMM_USB_UNREGISTER UnRegister; +} EFI_SMM_USB_DISPATCH_PROTOCOL; + +extern EFI_GUID gEfiSmmUsbDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.c b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.c new file mode 100644 index 0000000000..f5b04ace50 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiDescription.c + +Abstract: + + + GUIDs used for ACPI Description + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (AcpiDescription) + +EFI_GUID gEfiAcpiDescriptionGuid = EFI_ACPI_DESCRIPTION_GUID; + +EFI_GUID_STRING(&gEfiAcpiDescriptionGuid, "ACPI Description", "ACPI Description GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h new file mode 100644 index 0000000000..43adf0191b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h @@ -0,0 +1,127 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiDescription.h + +Abstract: + + + GUIDs used for ACPI Description + +--*/ + +#ifndef _EFI_ACPI_DESCRIPTION_H_ +#define _EFI_ACPI_DESCRIPTION_H_ + +#define EFI_ACPI_DESCRIPTION_GUID \ + { \ + 0x3c699197, 0x93c, 0x4c69, 0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9 \ + } + +typedef struct { + UINT8 AddressSpaceId; + UINT8 RegisterBitWidth; + UINT8 RegisterBitOffset; + UINT8 AccessSize; + UINT64 Address; +} EFI_ACPI_GENERIC_ADDRESS_STRUCTURE; + +#define ACPI_ADDRESS_ID_MEMORY 0 +#define ACPI_ADDRESS_ID_IO 1 +#define ACPI_ADDRESS_ID_PCI 2 +#define ACPI_ADDRESS_ID_EC 3 +#define ACPI_ADDRESS_ID_SMBUS 4 + +#define ACPI_ADDRESS_ACCESS_ANY 0 +#define ACPI_ADDRESS_ACCESS_BYTE 1 +#define ACPI_ADDRESS_ACCESS_WORD 2 +#define ACPI_ADDRESS_ACCESS_DWORD 3 +#define ACPI_ADDRESS_ACCESS_QWORD 4 + +// +// Following structure defines ACPI Description information. +// This information is platform specific, may be consumed by DXE generic driver. +// +#pragma pack(1) +typedef struct _EFI_ACPI_DESCRIPTION { + // + // For Timer + // + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM_TMR_BLK; + UINT8 PM_TMR_LEN; + UINT8 TMR_VAL_EXT; + + // + // For RTC + // + UINT8 DAY_ALRM; + UINT8 MON_ALRM; + UINT8 CENTURY; + + // + // For Reset + // + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE RESET_REG; + UINT8 RESET_VALUE; + + // + // For Shutdown + // + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1a_EVT_BLK; + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1b_EVT_BLK; + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1a_CNT_BLK; + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1b_CNT_BLK; + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM2_CNT_BLK; + UINT8 PM1_EVT_LEN; + UINT8 PM1_CNT_LEN; + UINT8 PM2_CNT_LEN; + UINT8 SLP_TYPa; + UINT8 SLP_TYPb; + + // + // For sleep + // + UINT8 SLP1_TYPa; + UINT8 SLP1_TYPb; + UINT8 SLP2_TYPa; + UINT8 SLP2_TYPb; + UINT8 SLP3_TYPa; + UINT8 SLP3_TYPb; + UINT8 SLP4_TYPa; + UINT8 SLP4_TYPb; + + // + // GPE + // + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE GPE0_BLK; + EFI_ACPI_GENERIC_ADDRESS_STRUCTURE GPE1_BLK; + UINT8 GPE0_BLK_LEN; + UINT8 GPE1_BLK_LEN; + UINT8 GPE1_BASE; + + // + // IAPC Boot Arch + // + UINT16 IAPC_BOOT_ARCH; + + // + // Flags + // + UINT32 Flags; + +} EFI_ACPI_DESCRIPTION; +#pragma pack() + +extern EFI_GUID gEfiAcpiDescriptionGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c b/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c new file mode 100644 index 0000000000..3017b31c0f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AlternateFvBlock.c + +Abstract: + + Tiano Guid used to define the Alternate Firmware Volume Block Guid. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (AlternateFvBlock) + +EFI_GUID gEfiAlternateFvBlockGuid = EFI_ALTERNATE_FV_BLOCK_GUID; + +EFI_GUID_STRING + (&gEfiAlternateFvBlockGuid, "Alternate Firmware Volume Block GUID", "Alternate Firmware Volume Block GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h b/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h new file mode 100644 index 0000000000..53340eaa04 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AlternateFvBlock.h + +Abstract: + + Tiano Guid used to define the Alternate Firmware Volume Block Guid. + +--*/ + +#ifndef _ALT_FVB_GUID_H +#define _ALT_FVB_GUID_H + +#define EFI_ALTERNATE_FV_BLOCK_GUID \ + { \ + 0xf496922d, 0x172f, 0x4bbc, 0xa1, 0xeb, 0xe, 0xeb, 0x94, 0x9c, 0x34, 0x86 \ + } + +extern EFI_GUID gEfiAlternateFvBlockGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c b/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c new file mode 100644 index 0000000000..d62e0fa1a2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Bmp.c + .c + +Abstract: + + GUID used as a filename for the BMP logo + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (Bmp) + +EFI_GUID gEfiDefaultBmpLogoGuid = EFI_DEFAULT_BMP_LOGO_GUID; + +EFI_GUID_STRING (&gEfiDefaultBmpLogoGuid, "Guid for BMP logo", "Guid for BMP logo"); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h b/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h new file mode 100644 index 0000000000..e095d2a929 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/Bmp/Bmp.h @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Bmp.h + +Abstract: + +--*/ + +#ifndef _BMP_GUID_H_ +#define _BMP_GUID_H_ + + +// +// Definitions for BMP files +// +#pragma pack(1) + +typedef struct { + UINT8 Blue; + UINT8 Green; + UINT8 Red; + UINT8 Reserved; +} BMP_COLOR_MAP; + +typedef struct { + CHAR8 CharB; + CHAR8 CharM; + UINT32 Size; + UINT16 Reserved[2]; + UINT32 ImageOffset; + UINT32 HeaderSize; + UINT32 PixelWidth; + UINT32 PixelHeight; + UINT16 Planes; // Must be 1 + UINT16 BitPerPixel; // 1, 4, 8, or 24 + UINT32 CompressionType; + UINT32 ImageSize; // Compressed image size in bytes + UINT32 XPixelsPerMeter; + UINT32 YPixelsPerMeter; + UINT32 NumberOfColors; + UINT32 ImportantColors; +} BMP_IMAGE_HEADER; + +#pragma pack() + +#define EFI_DEFAULT_BMP_LOGO_GUID \ + {0x7BB28B99,0x61BB,0x11d5,0x9A,0x5D,0x00,0x90,0x27,0x3F,0xC1,0x4D} + +extern EFI_GUID gEfiDefaultBmpLogoGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.c b/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.c new file mode 100644 index 0000000000..6e32f780b1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootState.c + +Abstract: + + GUID for use conveying the boot-state to PEI + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (BootState) + +EFI_GUID gEfiBootStateGuid = EFI_BOOT_STATE_VARIABLE_GUID; + +// +// GUID for frequency selection HOB +// +EFI_GUID_STRING(&gEfiBootStateGuid, "Boot State", "Boot State"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.h b/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.h new file mode 100644 index 0000000000..e0aeba41b4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/BootState/BootState.h @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BootState.h + +Abstract: + + Constants and declarations that are common accross PEI and DXE. +--*/ + +#ifndef _BOOT_STATE_H_ +#define _BOOT_STATE_H_ + +#include "Tiano.h" + +// +// BOOT STATE +// + +typedef UINT32 EFI_BOOT_STATE; + +#define BOOT_STATE_VARIABLE_NAME L"BootState" + +#define EFI_BOOT_STATE_VARIABLE_GUID \ + {0x60b5e939, 0xfcf, 0x4227, 0xba, 0x83, 0x6b, 0xbe, 0xd4, 0x5b, 0xc0, 0xe3} + +extern EFI_GUID gEfiBootStateGuid; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.c b/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.c new file mode 100644 index 0000000000..6e167d3b02 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Capsule.c + +Abstract: + + EFI Capsule update Guid data declarations. + +--*/ + +#include "Tiano.h" + +#include EFI_GUID_DEFINITION(Capsule) + +EFI_GUID gEfiCapsuleVendorGuid = EFI_CAPSULE_VENDOR_GUID; + +EFI_GUID_STRING(&gEfiCapsuleVendorGuid, "EFI", "Efi Capsule GUID") + diff --git a/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.h b/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.h new file mode 100644 index 0000000000..8c61f5e725 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/Capsule/Capsule.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Capsule.h + +Abstract: + + Capsule update Guid definitions + +--*/ + +#ifndef _EFI_CAPSULE_VENDOR_GUID_H_ +#define _EFI_CAPSULE_VENDOR_GUID_H_ + +// +// Note -- This guid is used as a vendor GUID (depending on implementation) +// for the capsule variable if the capsule pointer is passes through reset +// via a variable. +// +#define EFI_CAPSULE_VENDOR_GUID \ + { 0x711C703F, 0xC285, 0x4B10, 0xA3, 0xB0, 0x36, 0xEC, 0xBD, 0x3C, 0x8B, 0xE2 } + +extern EFI_GUID gEfiCapsuleVendorGuid; + +#endif // #ifndef _EFI_CAPSULE_VENDOR_GUID_H_ diff --git a/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c b/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c new file mode 100644 index 0000000000..e542d29e8c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CompatibleMemoryTested.c + +Abstract: + + Tiano Guid used for all Compatible Memory Range Tested GUID. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (CompatibleMemoryTested) + +EFI_GUID gEfiCompatibleMemoryTestedGuid = EFI_COMPATIBLE_MEMORY_TESTED_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiCompatibleMemoryTestedGuid, "CompatibleMemoryTested Protocol", "Tiano Generic Memory Test Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h b/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h new file mode 100644 index 0000000000..2223776fb2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CompatibleMemoryTested.h + +Abstract: + + Tiano Guid used for all Compatible Memory Range Tested GUID. + +--*/ + +#ifndef _COMPATIBLE_MEMORY_TESTED_GUID_H_ +#define _COMPATIBLE_MEMORY_TESTED_GUID_H_ + +#define EFI_COMPATIBLE_MEMORY_TESTED_PROTOCOL_GUID \ + { \ + 0x64c475ef, 0x344b, 0x492c, 0x93, 0xad, 0xab, 0x9e, 0xb4, 0x39, 0x50, 0x4 \ + } + +extern EFI_GUID gEfiCompatibleMemoryTestedGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c b/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c new file mode 100644 index 0000000000..7fb5ab09a4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ConsoleInDevice.c + +Abstract: + + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(ConsoleInDevice) + + +EFI_GUID gEfiConsoleInDeviceGuid = EFI_CONSOLE_IN_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiConsoleInDeviceGuid, "Console In Device Guid", "EFI Conosle In Device Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h b/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h new file mode 100644 index 0000000000..7fc1b90594 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ConsoleInDevice.h + +Abstract: + + +--*/ + +#ifndef _CONSOLE_IN_DEVICE_H_ +#define _CONSOLE_IN_DEVICE_H_ + +#define EFI_CONSOLE_IN_DEVICE_GUID \ + { 0xd3b36f2b, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +extern EFI_GUID gEfiConsoleInDeviceGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c b/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c new file mode 100644 index 0000000000..b546f6d574 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ConsoleOutDevice.c + +Abstract: + + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(ConsoleOutDevice) + + +EFI_GUID gEfiConsoleOutDeviceGuid = EFI_CONSOLE_OUT_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiConsoleOutDeviceGuid, "Console Out Device Guid", "EFI Console Out Device Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h b/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h new file mode 100644 index 0000000000..7eff36a842 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ConsoleOutDevice.h + +Abstract: + + +--*/ + +#ifndef _CONSOLE_OUT_DEVICE_H_ +#define _CONSOLE_OUT_DEVICE_H_ + +#define EFI_CONSOLE_OUT_DEVICE_GUID \ + { 0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +extern EFI_GUID gEfiConsoleOutDeviceGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/EdkGuidLib.inf b/EdkCompatibilityPkg/Foundation/Guid/EdkGuidLib.inf new file mode 100644 index 0000000000..c9465c50ec --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/EdkGuidLib.inf @@ -0,0 +1,98 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkGuidLib.inf +# +# Abstract: +# +# Component description file for the Edk Guid library. +# +#--*/ +[defines] +BASE_NAME= EdkGuidLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE) + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + +[nmake.common] + +[sources.common] + AcpiDescription\AcpiDescription.h + AcpiDescription\AcpiDescription.c + AlternateFvBlock\AlternateFvBlock.h + AlternateFvBlock\AlternateFvBlock.c + Bmp\Bmp.h + Bmp\Bmp.c + BootState\BootState.h + BootState\BootState.c + Capsule\Capsule.h + Capsule\Capsule.c + CompatibleMemoryTested\CompatibleMemoryTested.h + CompatibleMemoryTested\CompatibleMemoryTested.c + ConsoleInDevice\ConsoleInDevice.h + ConsoleInDevice\ConsoleInDevice.c + ConsoleOutDevice\ConsoleOutDevice.h + ConsoleOutDevice\ConsoleOutDevice.c + EfiShell\EfiShell.h + EfiShell\EfiShell.c + FlashMapHob\FlashMapHob.h + FlashMapHob\FlashMapHob.c + HotPlugDevice\HotPlugDevice.h + HotPlugDevice\HotPlugDevice.c + IoBaseHob\IoBaseHob.h + IoBaseHob\IoBaseHob.c + MemoryTypeInformation\MemoryTypeInformation.h + MemoryTypeInformation\MemoryTypeInformation.c + PciHotPlugDevice\PciHotPlugDevice.h + PciHotPlugDevice\PciHotPlugDevice.c + PciOptionRomTable\PciOptionRomTable.h + PciOptionRomTable\PciOptionRomTable.c + PciExpressBaseAddress\PciExpressBaseAddress.h + PciExpressBaseAddress\PciExpressBaseAddress.c + PeiFlushInstructionCache\PeiFlushInstructionCache.h + PeiFlushInstructionCache\PeiFlushInstructionCache.c + PeiPeCoffLoader\PeiPeCoffLoader.h + PeiPeCoffLoader\PeiPeCoffLoader.c + PeiPerformanceHob\PeiPerformanceHob.h + PeiPerformanceHob\PeiPerformanceHob.c + PeiTransferControl\PeiTransferControl.h + PeiTransferControl\PeiTransferControl.c + PrimaryConsoleInDevice\PrimaryConsoleInDevice.h + PrimaryConsoleInDevice\PrimaryConsoleInDevice.c + PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.h + PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.c + PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.h + PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.c + StandardErrorDevice\StandardErrorDevice.h + StandardErrorDevice\StandardErrorDevice.c + StatusCode\StatusCode.h + StatusCode\StatusCode.c + StatusCodeCallerId\StatusCodeCallerId.h + StatusCodeCallerId\StatusCodeCallerId.c + SystemNvDataGuid\SystemNvDataGuid.h + SystemNvDataGuid\SystemNvDataGuid.c + EventLegacyBios\EventLegacyBios.h + EventLegacyBios\EventLegacyBios.c + GenericVariable\GenericVariable.h + GenericVariable\GenericVariable.c \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.c b/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.c new file mode 100644 index 0000000000..ee4ddb7c50 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiShell.c + +Abstract: + + FFS Filename for EFI Shell + +--*/ + +#include "Tiano.h" + +#include EFI_GUID_DEFINITION (EfiShell) + +EFI_GUID gEfiShellFileGuid = EFI_SHELL_FILE_GUID; +EFI_GUID gEfiMiniShellFileGuid = EFI_MINI_SHELL_FILE_GUID; + +EFI_GUID_STRING (&gEfiShellFileGuid, "EfiShell", "Efi Shell FFS file name GUID") +EFI_GUID_STRING (&gEfiMiniShellFileGuid, "EfiMiniShell", "Efi Mini-Shell FFS file name GUID") + diff --git a/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.h b/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.h new file mode 100644 index 0000000000..a3b76d3c29 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/EfiShell/EfiShell.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiShell.h + +Abstract: + + FFS Filename for EFI Shell + +--*/ + +#ifndef _EFI_SHELL_H_ +#define _EFI_SHELL_H_ + +#define EFI_SHELL_FILE_GUID \ + { 0xc57ad6b7, 0x0515, 0x40a8, 0x9d, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4e, 0x37 } + +#define EFI_MINI_SHELL_FILE_GUID \ + { 0x86ad232b, 0xd33a, 0x465c, 0xbf, 0x5f, 0x41, 0x37, 0xb, 0xa9, 0x2f, 0xe2 } + +extern EFI_GUID gEfiShellFileGuid; +extern EFI_GUID gEfiMiniShellFileGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.c b/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.c new file mode 100644 index 0000000000..75da46b540 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.c @@ -0,0 +1,23 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiLegacyBios.c + +--*/ +#include "Tiano.h" + +#include EFI_GUID_DEFINITION (EventLegacyBios) + +EFI_GUID gEfiEventLegacyBootGuid = EFI_EVENT_LEGACY_BOOT_GUID; + +EFI_GUID_STRING (&gEfiEventLegacyBootGuid, "EventLegacyBoot", "Event Legacy Boot GUID") diff --git a/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.h b/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.h new file mode 100644 index 0000000000..648e2549f8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/EventLegacyBios/EventLegacyBios.h @@ -0,0 +1,28 @@ +/** @file + GUID is the name of events used with CreateEventEx in order to be notified when the EFI boot manager is about to boot a legacy boot option. Events of this type are notificated just before Int19h is invoked. + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: EventLegacyBios.h + + @par Revision Reference: + GUIDs defined in DXE CIS 0.91b. + +**/ + +#ifndef __EVENT_LEGACY_BIOS_GUID_H__ +#define __EVENT_LEGACY_BIOS_GUID_H__ + +#define EFI_EVENT_LEGACY_BOOT_GUID \ + { 0x2a571201, 0x4966, 0x47f6, 0x8b, 0x86, 0xf3, 0x1e, 0x41, 0xf3, 0x2f, 0x10 } + +extern EFI_GUID gEfiEventLegacyBootGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.c b/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.c new file mode 100644 index 0000000000..2294280348 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FlashMapHob.c + +Abstract: + + GUIDs used for Flash Map HOB entries in the in the HOB list. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (FlashMapHob) + + +EFI_GUID gEfiFlashMapHobGuid = EFI_FLASH_MAP_HOB_GUID; + +EFI_GUID_STRING (&gEfiFlashMapHobGuid, "Flash Map HOB", "Flash Map HOB GUID for HOB list"); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.h b/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.h new file mode 100644 index 0000000000..1676df2a5e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/FlashMapHob/FlashMapHob.h @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FlashMapHob.h + +Abstract: + + GUID used for Flash Map HOB entries in the HOB list. + +--*/ + +#ifndef _FLASH_MAP_HOB_GUID_H_ +#define _FLASH_MAP_HOB_GUID_H_ + +// +// Definitions for Flash Map +// +#define EFI_FLASH_MAP_HOB_GUID \ + { 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 } + +extern EFI_GUID gEfiFlashMapHobGuid; + +#endif // _FLASH_MAP_HOB_GUID_H_ diff --git a/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.c b/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.c new file mode 100644 index 0000000000..e1dc76c1a4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenericVariable.c + +Abstract: + + The variable space Guid to pair with a Unicode string name to tag an EFI variable + +--*/ + +#include "EfiSpec.h" +#include EFI_GUID_DEFINITION (GenericVariable) + +EFI_GUID gEfiGenericVariableGuid = EFI_GENERIC_VARIABLE_GUID; + +EFI_GUID_STRING(&gEfiGenericVariableGuid, "GenericVariable", "Generic Variable GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.h b/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.h new file mode 100644 index 0000000000..d6b4f3e570 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/GenericVariable/GenericVariable.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenericVariable.h + +Abstract: + + The variable space Guid to pair with a Unicode string name to tag an EFI variable + +--*/ + +#ifndef _GENERIC_VARIABLE_H_ +#define _GENERIC_VARIABLE_H_ + +#define EFI_GENERIC_VARIABLE_GUID \ + { \ + 0x59d1c24f, 0x50f1, 0x401a, 0xb1, 0x01, 0xf3, 0x3e, 0x0d, 0xae, 0xd4, 0x43 \ + } + +extern EFI_GUID gEfiGenericVariableGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.c b/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.c new file mode 100644 index 0000000000..fda226a851 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + HotPlugDevice.c + +Abstract: + + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(HotPlugDevice) + + +EFI_GUID gEfiHotPlugDeviceGuid = HOT_PLUG_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiHotPlugDeviceGuid, "Hot Plug Device Guid", "Hot Plug Device Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.h b/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.h new file mode 100644 index 0000000000..0e7ebdea72 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/HotPlugDevice/HotPlugDevice.h @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + HotPlugDevice.h + +Abstract: + + +--*/ + +#ifndef _HOT_PLUG_DEVICE_H_ +#define _HOT_PLUG_DEVICE_H_ + +#define HOT_PLUG_DEVICE_GUID \ + { 0x220ac432, 0x1d43, 0x49e5, 0xa7, 0x4f, 0x4c, 0x9d, 0xa6, 0x7a, 0xd2, 0x3b } + +extern EFI_GUID gEfiHotPlugDeviceGuid; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.c b/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.c new file mode 100644 index 0000000000..f42089b34d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IoBaseHob.c + +Abstract: + + GUIDs used for IoBase HOB entries in the in the HOB list. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(IoBaseHob) + + +EFI_GUID gEfiIoBaseHobGuid = EFI_IOBASE_HOB_GUID; + +EFI_GUID_STRING(&gEfiIoBaseHobGuid, "IOBASE HOB", "IOBASE HOB GUID for HOB list."); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.h b/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.h new file mode 100644 index 0000000000..e55f2b129c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/IoBaseHob/IoBaseHob.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IoBaseHob.h + +Abstract: + + GUID used for IoBase HOB entries in the HOB list. + +--*/ + +#ifndef _IOBASE_GUID_H_ +#define _IOBASE_GUID_H_ + +#define EFI_IOBASE_HOB_GUID \ +{ 0xd4a28a3e, 0xdcf2, 0x43cf, 0xa2, 0xb7, 0xf3, 0x57, 0x2a, 0x7c, 0xab, 0x9 } + +extern EFI_GUID gEfiIoBaseHobGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c b/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c new file mode 100644 index 0000000000..d39f635ae4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemoryTypeInformation.c + +Abstract: + + GUID used for Memory Type Information entries in the HOB list. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(MemoryTypeInformation) + +EFI_GUID gEfiMemoryTypeInformationGuid = EFI_MEMORY_TYPE_INFORMATION_GUID; + +EFI_GUID_STRING(&gEfiMemoryTypeInformationGuid, "Memory Type Information", + "Memory Type Information HOB GUID for HOB list."); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h b/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h new file mode 100644 index 0000000000..d85c84374e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemoryTypeInformation.h + +Abstract: + + GUID used for Memory Type Information entries in the HOB list. + +--*/ + +#ifndef _MEMORY_TYPE_INFORMATION_GUID_H_ +#define _MEMORY_TYPE_INFORMATION_GUID_H_ + +#define EFI_MEMORY_TYPE_INFORMATION_GUID \ + { 0x4c19049f,0x4137,0x4dd3,0x9c,0x10,0x8b,0x97,0xa8,0x3f,0xfd,0xfa } + +#define EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME L"MemoryTypeInformation" + +extern EFI_GUID gEfiMemoryTypeInformationGuid; + +typedef struct { + UINT32 Type; + UINT32 NumberOfPages; +} EFI_MEMORY_TYPE_INFORMATION; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c b/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c new file mode 100644 index 0000000000..d2ae68bf3e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciExpressBaseAddress.c + +Abstract: + + + GUIDs used for PciExpress Base Address + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (PciExpressBaseAddress) + +EFI_GUID gEfiPciExpressBaseAddressGuid = EFI_PCI_EXPRESS_BASE_ADDRESS_GUID; + +EFI_GUID_STRING(&gEfiPciExpressBaseAddressGuid, "PCI Express Base Address", "PCI Express Base Address GUID"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h b/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h new file mode 100644 index 0000000000..0625b3e147 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciExpressBaseAddress.h + +Abstract: + + + GUIDs used for PciExpress Base Address + +--*/ + +#ifndef _EFI_PCI_EXPRESS_BASE_ADDRESS_H_ +#define _EFI_PCI_EXPRESS_BASE_ADDRESS_H_ + +#define EFI_PCI_EXPRESS_BASE_ADDRESS_GUID \ + { \ + 0x3677d529, 0x326f, 0x4603, 0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0 \ + } + +// +// Following structure defines PCI Express Base Address information. +// This information is platform specific, and built into hob in PEI phase. +// It can be consumed by PEI PCI driver and DXE PCI driver. +// +#pragma pack(1) +typedef struct _EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION { + UINT32 HostBridgeNumber; + UINT32 RootBridgeNumber; + UINT64 PciExpressBaseAddress; +} EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION; +#pragma pack() + +extern EFI_GUID gEfiPciExpressBaseAddressGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c new file mode 100644 index 0000000000..a0b884c730 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHotplugDevice.c + +Abstract: + + + GUIDs used to indicate the device is Pccard hotplug device + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PciHotplugDevice) + + +EFI_GUID gEfiPciHotplugDeviceGuid = EFI_PCI_HOTPLUG_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiPciHotplugDeviceGuid, "PCI Hotplug Device", "PCI Hotplug Device GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h new file mode 100644 index 0000000000..dafcf1e6cf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHotplugDevice.h + +Abstract: + + GUIDs used to indicate the device is Pccard hotplug device + +--*/ + +#ifndef _PCI_HOTPLUG_DEVICE_GUID_H_ +#define _PCI_HOTPLUG_DEVICE_GUID_H_ + +#define EFI_PCI_HOTPLUG_DEVICE_GUID \ + { 0x0b280816, 0x52e7, 0x4e51, 0xaa, 0x57, 0x11, 0xbd, 0x41, 0xcb, 0xef, 0xc3 } + +extern EFI_GUID gEfiPciHotplugDeviceGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c new file mode 100644 index 0000000000..436c805b73 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciOptionRomTable.c + +Abstract: + + GUID and data structure used to describe the list of PCI Option ROMs present in a system. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PciOptionRomTable) + +EFI_GUID gEfiPciOptionRomTableGuid = EFI_PCI_OPTION_ROM_TABLE_GUID; + +EFI_GUID_STRING(&gEfiPciOptionRomTableGuid, "PCI Option ROM Table", "PCI Option ROM Table GUID in EFI System Table"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h new file mode 100644 index 0000000000..5055ccc649 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciOptionRomTable.h + +Abstract: + + GUID and data structure used to describe the list of PCI Option ROMs present in a system. + +--*/ + +#ifndef _PCI_OPTION_ROM_TABLE_GUID_H_ + +#define EFI_PCI_OPTION_ROM_TABLE_GUID \ + { 0x7462660f, 0x1cbd, 0x48da, 0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c } + +extern EFI_GUID gEfiPciOptionRomTableGuid; + +typedef struct { + EFI_PHYSICAL_ADDRESS RomAddress; + EFI_MEMORY_TYPE MemoryType; + UINT32 RomLength; + UINT32 Seg; + UINT8 Bus; + UINT8 Dev; + UINT8 Func; + BOOLEAN ExecutedLegacyBiosImage; + BOOLEAN DontLoadEfiRom; +} EFI_PCI_OPTION_ROM_DESCRIPTOR; + +typedef struct { + UINT64 PciOptionRomCount; + EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptors; +} EFI_PCI_OPTION_ROM_TABLE; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c b/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c new file mode 100644 index 0000000000..967f944cf3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiFlushInstructionCache.c + +Abstract: + + GUID for the Instruction Cache Flushing APIs shared between PEI and DXE + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PeiFlushInstructionCache) + +EFI_GUID gEfiPeiFlushInstructionCacheGuid = EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID; + +EFI_GUID_STRING(&gEfiPeiFlushInstructionCacheGuid, "PEI Flush Instruction Cache", + "Flush Instruction Cache APIs from PEI"); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h b/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h new file mode 100644 index 0000000000..7bd6c8956c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiFlushInstructionCache.h + +Abstract: + + GUID for the Instruction Cache Flushing APIs shared between PEI and DXE + +--*/ + +#ifndef _PEI_FLUSH_INSTRUCTION_CACHE_GUID_H_ +#define _PEI_FLUSH_INSTRUCTION_CACHE_GUID_H_ + +#define EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID \ + { 0xd8117cfc, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +EFI_FORWARD_DECLARATION (EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_FLUSH_INSTRUCTION_CACHE_FLUSH) ( + IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ); + +typedef struct _EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL { + EFI_PEI_FLUSH_INSTRUCTION_CACHE_FLUSH Flush; +} EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL; + +extern EFI_GUID gEfiPeiFlushInstructionCacheGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c new file mode 100644 index 0000000000..517ee4aa0e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiPeCoffLoader.c + +Abstract: + + GUID for the PE/COFF Loader APIs shared between PEI and DXE + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PeiPeCoffLoader) + +EFI_GUID gEfiPeiPeCoffLoaderGuid = EFI_PEI_PE_COFF_LOADER_GUID; + +EFI_GUID_STRING(&gEfiPeiPeCoffLoaderGuid, "PE/COFF Loader", "PE/COFF Loader APIs from PEI"); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h new file mode 100644 index 0000000000..3589f31ff6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h @@ -0,0 +1,116 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiPeCoffLoader.h + +Abstract: + + GUID for the PE/COFF Loader APIs shared between PEI and DXE + +--*/ + +#ifndef _PEI_PE_COFF_LOADER_H_ +#define _PEI_PE_COFF_LOADER_H_ + +#include "EfiImage.h" + +#define EFI_PEI_PE_COFF_LOADER_GUID \ + { 0xd8117cff, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +EFI_FORWARD_DECLARATION (EFI_PEI_PE_COFF_LOADER_PROTOCOL); + +#define EFI_IMAGE_ERROR_SUCCESS 0 +#define EFI_IMAGE_ERROR_IMAGE_READ 1 +#define EFI_IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2 +#define EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE 3 +#define EFI_IMAGE_ERROR_INVALID_SUBSYSTEM 4 +#define EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5 +#define EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE 6 +#define EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7 +#define EFI_IMAGE_ERROR_SECTION_NOT_LOADED 8 +#define EFI_IMAGE_ERROR_FAILED_RELOCATION 9 +#define EFI_IMAGE_ERROR_FAILED_ICACHE_FLUSH 10 + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_PE_COFF_LOADER_READ_FILE) ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ); + +typedef struct { + EFI_PHYSICAL_ADDRESS ImageAddress; + UINT64 ImageSize; + EFI_PHYSICAL_ADDRESS DestinationAddress; + EFI_PHYSICAL_ADDRESS EntryPoint; + EFI_PEI_PE_COFF_LOADER_READ_FILE ImageRead; + VOID *Handle; + VOID *FixupData; + UINT32 SectionAlignment; + UINT32 PeCoffHeaderOffset; + UINT32 DebugDirectoryEntryRva; + VOID *CodeView; + CHAR8 *PdbPointer; + UINTN SizeOfHeaders; + UINT32 ImageCodeMemoryType; + UINT32 ImageDataMemoryType; + UINT32 ImageError; + UINTN FixupDataSize; + UINT16 Machine; + UINT16 ImageType; + BOOLEAN RelocationsStripped; + BOOLEAN IsTeImage; +#ifdef EFI_NT_EMULATOR + VOID **ModHandle; +#endif +} EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT; + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO) ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE) ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE) ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE) ( + IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +typedef struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL { + EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo; + EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE LoadImage; + EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage; + EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage; +} EFI_PEI_PE_COFF_LOADER_PROTOCOL; + +extern EFI_GUID gEfiPeiPeCoffLoaderGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c b/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c new file mode 100644 index 0000000000..1906a97f6a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + OemFvHob.c + +Abstract: + + The GUID of the GUIDed HOB that represents the OEM FV block. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (PeiPerformanceHob) + +EFI_GUID gEfiPeiPerformanceHobGuid = EFI_PEI_PERFORMANCE_HOB_GUID; + +EFI_GUID_STRING (&gEfiPeiPerformanceHobGuid, "PEI Performance HOB", + "Guid for PEI Performance Measurement HOB"); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h b/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h new file mode 100644 index 0000000000..7f9104fedf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h @@ -0,0 +1,45 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiPerformanceHob.h + +Abstract: + The PEI performance HOB definition. + +--*/ + +#ifndef _PEI_PERFORMANCE_HOB_GUID_H_ +#define _PEI_PERFORMANCE_HOB_GUID_H_ + + +#define EFI_PEI_PERFORMANCE_HOB_GUID \ +{0x10f432de, 0xdeec, 0x4631, 0x80, 0xcd, 0x47, 0xf6, 0x5d, 0x8f, 0x80, 0xbb} + +#define PEI_PERF_MAX_DESC_STRING 8 + +typedef struct { + UINT64 StartTimeCount; + UINT64 StopTimeCount; + EFI_GUID Name; + UINT16 DescriptionString[PEI_PERF_MAX_DESC_STRING]; +} PEI_PERFORMANCE_MEASURE_LOG_ENTRY; + +typedef struct { + UINT32 NumberOfEntries; + UINT32 Reserved; + PEI_PERFORMANCE_MEASURE_LOG_ENTRY Log[1]; +} EFI_HOB_GUID_DATA_PERFORMANCE_LOG; + +extern EFI_GUID gEfiPeiPerformanceHobGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.c b/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.c new file mode 100644 index 0000000000..ffd2b34cd9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiTransferControl.c + +Abstract: + + GUID for the SetJump()/LongJump() APIs shared between PEI and DXE + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PeiTransferControl) + +EFI_GUID gEfiPeiTransferControlGuid = EFI_PEI_TRANSFER_CONTROL_GUID; + +EFI_GUID_STRING(&gEfiPeiTransferControlGuid, "Transfer Control", "Transfer Control APIs from PEI"); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.h b/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.h new file mode 100644 index 0000000000..0ed5a0d7a8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PeiTransferControl/PeiTransferControl.h @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiTransferControl.h + +Abstract: + + GUID for the SetJump()/LongJump() APIs shared between PEI and DXE + +--*/ + +#ifndef _PEI_TRANSFER_CONTROL_H_ +#define _PEI_TRANSFER_CONTROL_H_ + +#define EFI_PEI_TRANSFER_CONTROL_GUID \ + { 0xd8117d02, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + + +EFI_FORWARD_DECLARATION (EFI_PEI_TRANSFER_CONTROL_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_TRANSFER_CONTROL_SET_JUMP) ( + IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, + OUT VOID *Context + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PEI_TRANSFER_CONTROL_LONG_JUMP) ( + IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, + IN VOID *Context + ); + +typedef struct _EFI_PEI_TRANSFER_CONTROL_PROTOCOL { + EFI_PEI_TRANSFER_CONTROL_LONG_JUMP SetJump; + EFI_PEI_TRANSFER_CONTROL_LONG_JUMP LongJump; + UINT32 JumpContextSize; +} EFI_PEI_TRANSFER_CONTROL_PROTOCOL; + +extern EFI_GUID gEfiPeiTransferControlGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c new file mode 100644 index 0000000000..a59624785e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrimaryConsoleInDevice.c + +Abstract: + + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PrimaryConsoleInDevice) + + +EFI_GUID gEfiPrimaryConsoleInDeviceGuid = EFI_PRIMARY_CONSOLE_IN_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiPrimaryConsoleInDeviceGuid, "Primary Console In Device Guid", + "EFI Primary Conosle In Device Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h new file mode 100644 index 0000000000..3681ef573f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrimaryConsoleInDevice.h + +Abstract: + + +--*/ + +#ifndef _PRIMARY_CONSOLE_IN_DEVICE_H_ +#define _PRIMARY_CONSOLE_IN_DEVICE_H_ + +#define EFI_PRIMARY_CONSOLE_IN_DEVICE_GUID \ + { 0xe451dcbe, 0x96a1, 0x4729, 0xa5, 0xcf, 0x6b, 0x9c, 0x2c, 0xff, 0x47, 0xfd } + +extern EFI_GUID gEfiPrimaryConsoleInDeviceGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c new file mode 100644 index 0000000000..8dd11a1f51 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrimaryConsoleOutDevice.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PrimaryConsoleOutDevice) + +EFI_GUID gEfiPrimaryConsoleOutDeviceGuid = EFI_PRIMARY_CONSOLE_OUT_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiPrimaryConsoleOutDeviceGuid, "Primary Console Out Device Guid", + "EFI Primary Console Out Device Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h new file mode 100644 index 0000000000..d87cbbcdcb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrimaryConsoleOutDevice.h + +Abstract: + +--*/ + +#ifndef _PRIMARY_CONSOLE_OUT_DEVICE_H_ +#define _PRIMARY_CONSOLE_OUT_DEVICE_H_ + +#define EFI_PRIMARY_CONSOLE_OUT_DEVICE_GUID \ + { 0x62bdf38a, 0xe3d5, 0x492c, 0x95, 0xc, 0x23, 0xa7, 0xf6, 0x6e, 0x67, 0x2e } + +extern EFI_GUID gEfiPrimaryConsoleOutDeviceGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c b/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c new file mode 100644 index 0000000000..23e0651493 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrimaryStandardErrorDevice.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(PrimaryStandardErrorDevice) + +EFI_GUID gEfiPrimaryStandardErrorDeviceGuid = EFI_PRIMARY_STANDARD_ERROR_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiPrimaryStandardErrorDeviceGuid, "Primary Standard Error Device Guid", + "EFI Primary Standard Error Device Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h b/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h new file mode 100644 index 0000000000..15d53dfb7e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrimaryStandardErrorDevice.h + +Abstract: + +--*/ + +#ifndef _PRIMARY_STANDARD_ERROR_DEVICE_H_ +#define _PRIMARY_STANDARD_ERROR_DEVICE_H_ + +#define EFI_PRIMARY_STANDARD_ERROR_DEVICE_GUID \ + { 0x5a68191b, 0x9b97, 0x4752, 0x99, 0x46, 0xe3, 0x6a, 0x5d, 0xa9, 0x42, 0xb1 } + +extern EFI_GUID gEfiPrimaryStandardErrorDeviceGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c b/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c new file mode 100644 index 0000000000..8badd8ddb5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StandardErrorDevice.c + +Abstract: + + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(StandardErrorDevice) + + +EFI_GUID gEfiStandardErrorDeviceGuid = EFI_STANDARD_ERROR_DEVICE_GUID; + +EFI_GUID_STRING(&gEfiStandardErrorDeviceGuid, "Standard Error Device Guid", "EFI Standard Error Device Guid"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h b/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h new file mode 100644 index 0000000000..b8cadfdebb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StandardErrorDevice.h + +Abstract: + + +--*/ + +#ifndef _STANDARD_ERROR_DEVICE_H_ +#define _STANDARD_ERROR_DEVICE_H_ + +#define EFI_STANDARD_ERROR_DEVICE_GUID \ + { 0xd3b36f2d, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +extern EFI_GUID gEfiStandardErrorDeviceGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.c b/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.c new file mode 100644 index 0000000000..5c75cf0b28 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCode.c + +Abstract: + + GUIDs used to identify Data Hub records that originate from the Tiano + ReportStatusCode API. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (StatusCode) + +EFI_GUID gEfiStatusCodeGuid = EFI_STATUS_CODE_GUID; + +EFI_GUID_STRING(&gEfiStatusCodeGuid, "Status Code", "Data Hub record for Tiano ReportStatusCode API"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.h b/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.h new file mode 100644 index 0000000000..8953bb040e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/StatusCode/StatusCode.h @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCode.h + +Abstract: + + GUID used to identify Data Hub records that originate from the Tiano + ReportStatusCode API. + +--*/ + +#ifndef _STATUS_CODE_H__ +#define _STATUS_CODE_H__ + +#define EFI_STATUS_CODE_GUID \ + { \ + 0xd083e94c, 0x6560, 0x42e4, 0xb6, 0xd4, 0x2d, 0xf7, 0x5a, 0xdf, 0x6a, 0x2a \ + } + +extern EFI_GUID gEfiStatusCodeGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c b/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c new file mode 100644 index 0000000000..87d979f984 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCodeCallerId.c + +Abstract: + + GUID used to identify id for the caller who is initiating the Status Code. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) + +EFI_GUID gEfiCallerIdGuid = EFI_STANDARD_CALLER_ID_GUID; + +EFI_GUID_STRING(&gEfiCallerIdGuid, "Status Code Caller Id", "Caller Id for Tiano ReportStatusCode API"); diff --git a/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h b/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h new file mode 100644 index 0000000000..964bb83129 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCodeCallerId.h + +Abstract: + + GUID used to identify id for the caller who is initiating the Status Code. + +--*/ + +#ifndef _STATUS_CODE_CALLER_ID_H__ +#define _STATUS_CODE_CALLER_ID_H__ + +#include "EfiStatusCode.h" + +#ifndef EFI_STANDARD_CALLER_ID_GUID + +#define EFI_STANDARD_CALLER_ID_GUID \ + {0xC9DCF469, 0xA7C4, 0x11D5, 0x87, 0xDA, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9} + +#endif + +extern EFI_GUID gEfiCallerIdGuid; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c b/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c new file mode 100644 index 0000000000..59f563372f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SystemNvDataGuid.c + +Abstract: + + GUIDs used for System Non Volatile HOB entries in the in the HOB list and FV Guids carrying + the System specific information. + +--*/ + +#include "Tiano.h" +#include EFI_GUID_DEFINITION(SystemNvDataGuid) + + +EFI_GUID gEfiSystemNvDataHobGuid = EFI_SYSTEM_NV_DATA_HOB_GUID; +EFI_GUID gEfiSystemNvDataFvGuid = EFI_SYSTEM_NV_DATA_FV_GUID; + +EFI_GUID_STRING(&gEfiSystemNvDataHobGuid, "SYSTEM NV DATA HOB", "SYSTEM NV DATA HOB GUID for HOB list."); +EFI_GUID_STRING(&gEfiSystemNvDataFvGuid, "SYSTEM NV DATA FV", "SYSTEM NV DATA FV GUID"); + diff --git a/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h b/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h new file mode 100644 index 0000000000..ce3358d147 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h @@ -0,0 +1,45 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SystemNvDataGuid.h + +Abstract: + + GUIDs used for System Non Volatile HOB entries in the in the HOB list and FV Guids carrying + the System specific information. + +--*/ + +#ifndef _SYSTEM_NV_DATA_GUID_H_ +#define _SYSTEM_NV_DATA_GUID_H_ + +#define EFI_SYSTEM_NV_DATA_FV_GUID \ + {0xfff12b8d, 0x7696, 0x4c8b, 0xa9, 0x85, 0x27, 0x47, 0x7, 0x5b, 0x4f, 0x50} + +#define EFI_SYSTEM_NV_DATA_HOB_GUID \ + {0xd6e5092d, 0xc7b2, 0x4872, 0xaf, 0x66, 0xfd, 0xc0, 0xe6, 0xf9, 0x5e, 0x78} + +typedef struct { + EFI_GUID SystemNvDataHobGuid; + EFI_GUID SystemNvDataFvGuid; + EFI_LBA StartLba; + UINTN StartLbaOffset; + EFI_LBA EndLba; + UINTN EndLbaOffset; + UINT32 DataTypeSignature; +} NV_SYSTEM_DATA_GUID_TYPE; + +extern EFI_GUID gEfiSystemNvDataHobGuid; +extern EFI_GUID gEfiSystemNvDataFvGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h new file mode 100644 index 0000000000..930d589d0f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h @@ -0,0 +1,129 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiBind.h + +Abstract: + + Processor or compiler specific defines and types for EBC. + +--*/ + +#ifndef _EFI_BIND_H_ +#define _EFI_BIND_H_ + +#define EFI_DRIVER_ENTRY_POINT(InitFunction) +#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT + +// +// Disable warning that make it impossible to compile at /W3 +// This only works for Intel EBC Compiler tools +// + +// +// Disabling argument of type "TYPE **" is incompatible with parameter of type "void **" +// +#pragma warning ( disable : 167 ) + +// +// Disabling pointless comparison of unsigned integer with zero +// +#pragma warning ( disable : 186 ) + +// +// Disabling enumerated type mixed with another type +// +#pragma warning ( disable : 188 ) + +// +// Native integer types +// +typedef char int8_t; +typedef unsigned char uint8_t; + +typedef short int16_t; +typedef unsigned short uint16_t; + +typedef int int32_t; +typedef unsigned int uint32_t; + +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + +// +// "long" type scales to the processor native size with EBC compiler +// +typedef long intn_t; +typedef unsigned long uintn_t; + +// +// Scalable macro to set the most significant bit in a natural number +// +#define EFI_MAX_BIT ((UINTN)0x01 << ((sizeof (char *) * 8) - 1)) +#define MAX_2_BITS (EFI_MAX_BIT | (EFI_MAX_BIT >> 1)) + +// +// Maximum legal EBC address +// +#define EFI_MAX_ADDRESS (UINTN)~0 + +// +// Bad pointer value to use in check builds. +// if you see this value you are using uninitialized or free'ed data +// +#define EFI_BAD_POINTER (UINTN)0xAFAFAFAFAFAFAFAF +#define EFI_BAD_POINTER_AS_BYTE (UINTN)0xAF + +// +// _break() is an EBC compiler intrinsic function +// +extern +uint64_t +_break ( + unsigned char BreakCode + ); + +// +// Macro to inject a break point in the code to assist debugging. +// +#define EFI_BREAKPOINT() _break ( 3 ) +#define EFI_DEADLOOP() while (TRUE) + +// +// Memory Fence forces serialization, and is needed to support out of order +// memory transactions. The Memory Fence is mainly used to make sure IO +// transactions complete in a deterministic sequence, and to syncronize locks +// an other MP code. Currently no memory fencing is required. +// +#define MEMORY_FENCE() + +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX. The forward reference is required for +// ANSI compatibility. +// +// The following macro provide a workaround for such cases. +// + + +#ifdef EFI_NO_INTERFACE_DECL + #define EFI_FORWARD_DECLARATION(x) +#else + #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x +#endif + + +#define _EFIAPI + +#endif // ifndef _EFI_BIND_H_ + diff --git a/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiPeOptionalHeader.h new file mode 100644 index 0000000000..0dd66c2789 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiPeOptionalHeader.h @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPeOptionalHeader.h + +Abstract: + Defines the optional header in the PE image per the PE specification. This + file must be included only from within EfiImage.h since + EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined + there. + +--*/ + +#ifndef _EFI_PE_OPTIONAL_HEADER_H_ +#define _EFI_PE_OPTIONAL_HEADER_H_ + +// +// This is just to make sure you can cross compile with the EBC compiiler. +// It does not make sense to have a PE loader coded in EBC. You need to +// understand the basic +// +#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_EBC) + +#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC) + +#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) + +// +// BUGBUG: Is this the correct magic for EBC? +// +#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC + +typedef EFI_IMAGE_OPTIONAL_HEADER32 EFI_IMAGE_OPTIONAL_HEADER; +typedef EFI_IMAGE_NT_HEADERS32 EFI_IMAGE_NT_HEADERS; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ebc/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/Ebc/TianoBind.h new file mode 100644 index 0000000000..027d2478af --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ebc/TianoBind.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoBind.h + +Abstract: + + Tiano's Processor or Compiler specific defines and types for EBC + besides EfiBind.h. + +--*/ + +#ifndef _TIANO_BIND_H_ +#define _TIANO_BIND_H_ + +#include "EfiBind.h" + +#define EFI_DXE_ENTRY_POINT(InitFunction) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiCommon.h b/EdkCompatibilityPkg/Foundation/Include/EfiCommon.h new file mode 100644 index 0000000000..305bfeaf8a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiCommon.h @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCommon.h + +Abstract: + +--*/ + +#ifndef _EFI_COMMON_H_ +#define _EFI_COMMON_H_ + +#include "EfiBind.h" +#include "EfiTypes.h" +#include "EfiStdArg.h" +#include "EfiError.h" + +// +// Define macros for including Protocols and Guids. +// +#define EFI_STRINGIZE(a) #a +#define EFI_PROTOCOL_DEFINITION(a) EFI_STRINGIZE (Protocol/a/a.h) +#define EFI_GUID_DEFINITION(a) EFI_STRINGIZE (Guid/a/a.h) + +// +// These should be used to include protocols. If they are followed, +// intelligent build tools can be created to check dependencies at build +// time. +// +#define EFI_PROTOCOL_PRODUCER(a) EFI_PROTOCOL_DEFINITION (a) +#define EFI_PROTOCOL_CONSUMER(a) EFI_PROTOCOL_DEFINITION (a) +#define EFI_PROTOCOL_DEPENDENCY(a) EFI_PROTOCOL_DEFINITION (a) + +// +// Mechanism to associate a short and long ascii string with a GUID. +// For normal builds the strings are not included. A build utility +// can be constructed to extract the strings and build a table. It may +// be possible to add a build opption to automatically generate a GUID +// string table for a GUID to string utility build. +// +#define EFI_GUID_STRING(guidpointer, shortstring, longstring) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiDebug.h b/EdkCompatibilityPkg/Foundation/Include/EfiDebug.h new file mode 100644 index 0000000000..452fd028c0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiDebug.h @@ -0,0 +1,170 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiDebug.h + +Abstract: + + EFI Debug macros. The work needs tobe done in library. The Debug + macros them selves are standard for all files, including the core. + + There needs to be code linked in that produces the following macros: + + EfiDebugAssert(file, linenumber, assertion string) - worker function for + ASSERT. filename and line number of where this ASSERT() is located + is passed in along with the stringized version of the assertion. + + EfiDebugPrint - Worker function for debug print + + _DEBUG_SET_MEM(address, length, value) - Set memory at address to value + for legnth bytes. This macro is used to initialzed uninitialized memory + or memory that is free'ed, so it will not be used by mistake. + +--*/ + +#ifndef _EFI_DEBUG_H_ +#define _EFI_DEBUG_H_ + +#ifdef EFI_DEBUG + + VOID + EfiDebugAssert ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ); + + VOID + EfiDebugPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ); + + VOID + EfiDebugVPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker + ); + + // + // Define macros for the above functions so we can make them go away + // in non-debug builds. + // + #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker) \ + EfiDebugVPrint(ErrorLevel, Format, Marker) + + #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description) \ + EfiDebugAssert (FileName, LineNumber, Description) + + #define _DEBUG_ASSERT(assertion) \ + EfiDebugAssert (__FILE__, __LINE__, #assertion) + + #define _DEBUG(arg) DebugPrint arg + + // + // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT + // + #define ASSERT(assertion) if(!(assertion)) \ + _DEBUG_ASSERT(assertion) + + #define ASSERT_LOCKED(l) if(!(l)->Lock) _DEBUG_ASSERT(l not locked) + + // + // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do + // the a debug print. + // + #define DEBUG(arg) EfiDebugPrint arg + + #define DEBUG_CODE(code) code + + #define CR(record, TYPE, field, signature) \ + _CR(record, TYPE, field)->Signature != signature ? \ + (TYPE *) (_DEBUG_ASSERT("CR has Bad Signature"), record) : \ + _CR(record, TYPE, field) + + #define _DEBUG_SET_MEM(address, length, data) EfiCommonLibSetMem(address, length, data) + + // + // Generate an ASSERT if the protocol specified by GUID is already installed on Handle. + // If Handle is NULL, then an ASSERT is generated if the protocol specified by GUID + // is present anywhere in the handle database + // + #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \ + DEBUG_CODE ( { \ + VOID *Instance; \ + if (Handle == NULL) { \ + ASSERT(EFI_ERROR(gBS->LocateProtocol (Guid, NULL, &Instance))); \ + } else { \ + ASSERT(EFI_ERROR(gBS->HandleProtocol (Handle, Guid, &Instance))); \ + } } ) + +#else + #define ASSERT(a) + #define ASSERT_LOCKED(l) + #define DEBUG(arg) + #define DEBUG_CODE(code) + #define CR(Record, TYPE, Field, Signature) \ + _CR(Record, TYPE, Field) + #define _DEBUG_SET_MEM(address, length, data) + #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker) + #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description) + #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) +#endif + +// +// Generate an ASSERT if Status is an error code +// +//#define ASSERT_EFI_ERROR(status) ASSERT(!EFI_ERROR(status)) +#define ASSERT_EFI_ERROR(status) if (EFI_ERROR(status)) \ + DEBUG_CODE ( { \ + DEBUG((EFI_D_ERROR, "\nASSERT!Status = 0x%x Info :",status)); \ + ASSERT(!EFI_ERROR(status)); \ + } ) + +#ifdef EFI_DEBUG_CLEAR_MEMORY + #define DEBUG_SET_MEMORY(address,length) \ + _DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE) +#else + #define DEBUG_SET_MEMORY(address,length) +#endif + +#define EFI_D_INIT 0x00000001 // Initialization style messages +#define EFI_D_WARN 0x00000002 // Warnings +#define EFI_D_LOAD 0x00000004 // Load events +#define EFI_D_FS 0x00000008 // EFI File system +#define EFI_D_POOL 0x00000010 // Alloc & Free's +#define EFI_D_PAGE 0x00000020 // Alloc & Free's +#define EFI_D_INFO 0x00000040 // Verbose +#define EFI_D_VARIABLE 0x00000100 // Variable +#define EFI_D_BM 0x00000400 // Boot Manager (BDS) +#define EFI_D_BLKIO 0x00001000 // BlkIo Driver +#define EFI_D_NET 0x00004000 // SNI Driver +#define EFI_D_UNDI 0x00010000 // UNDI Driver +#define EFI_D_LOADFILE 0x00020000 // UNDI Driver +#define EFI_D_EVENT 0x00080000 // Event messages + +#define EFI_D_ERROR 0x80000000 // Error + +#define EFI_D_GENERIC (EFI_D_ERROR | EFI_D_INIT | EFI_D_WARN | EFI_D_INFO | \ + EFI_D_BLKIO | EFI_D_NET | EFI_D_UNDI ) + +#define EFI_D_INTRINSIC ( EFI_D_EVENT | EFI_D_POOL | EFI_D_PAGE | \ + EFI_D_BM | EFI_D_LOAD | EFI_D_VARIABLE ) + +#define EFI_D_RESERVED (EFI_D_GENERIC | EFI_D_INTRINSIC) + +#define EFI_DBUG_MASK (EFI_D_ERROR) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiDepex.h b/EdkCompatibilityPkg/Foundation/Include/EfiDepex.h new file mode 100644 index 0000000000..62a77848d1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiDepex.h @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + EfiDepex.h + +Abstract: + This include file is only used in *.DXS files. Do not use this + include file in normal DXE code. + + Depex - Dependency Expresion + + The BNF grammar is thus: + ::= before GUID + | after GUID + | SOR + | + ::= and + | or + | + ::= not + | + ::= + | + | + | + ::= true + | false + ::= push GUID + ::= end + +--*/ + +#ifndef _EFI_DEPEX_H_ +#define _EFI_DEPEX_H_ + +#include "Tiano.h" + +// +// The Depex grammer needs the string "TRUE" and "FALSE" we must +// undo any pre-processor redefinitions +// +#undef TRUE +#undef FALSE + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiFlashMap.h b/EdkCompatibilityPkg/Foundation/Include/EfiFlashMap.h new file mode 100644 index 0000000000..9b0af35dd4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiFlashMap.h @@ -0,0 +1,128 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiFlashMap.h + +Abstract: + + Defines for the EFI Flash Map functionality + +--*/ + +#ifndef _EFI_FLASHMAP_H_ +#define _EFI_FLASHMAP_H_ + +#include "PeiHob.h" + +// +// Definition for flash map GUIDed HOBs +// +typedef UINT32 EFI_FLASH_AREA_ATTRIBUTES; + +#define EFI_FLASH_AREA_FV 0x0001 +#define EFI_FLASH_AREA_SUBFV 0x0002 +#define EFI_FLASH_AREA_MEMMAPPED_FV 0x0004 +#define EFI_FLASH_AREA_REQUIRED 0x0008 +#define EFI_FLASH_AREA_CORRUPT 0x0010 + +typedef UINT8 EFI_FLASH_AREA_TYPE; + +#define EFI_FLASH_AREA_RECOVERY_BIOS 0x0 // Recovery code +#define EFI_FLASH_AREA_MAIN_BIOS 0x1 // Regular BIOS code +#define EFI_FLASH_AREA_PAL_B 0x2 // PAL-B +#define EFI_FLASH_AREA_RESERVED_03 0x3 // Reserved for backwards compatibility +#define EFI_FLASH_AREA_RESERVED_04 0x4 // Reserved for backwards compatibility +#define EFI_FLASH_AREA_DMI_FRU 0x5 // DMI FRU information +#define EFI_FLASH_AREA_OEM_BINARY 0x6 // OEM Binary Code/data +#define EFI_FLASH_AREA_RESERVED_07 0x7 // Reserved for backwards compatibility +#define EFI_FLASH_AREA_RESERVED_08 0x8 // Reserved for backwards compatibility +#define EFI_FLASH_AREA_RESERVED_09 0x9 // Reserved for backwards compatibility +#define EFI_FLASH_AREA_RESERVED_0A 0x0a // Reserved for backwards compatibility +#define EFI_FLASH_AREA_EFI_VARIABLES 0x0b // EFI variables +#define EFI_FLASH_AREA_MCA_LOG 0x0c // MCA error log +#define EFI_FLASH_AREA_SMBIOS_LOG 0x0d // SMBIOS error log +#define EFI_FLASH_AREA_FTW_BACKUP 0x0e // A backup block during FTW operations +#define EFI_FLASH_AREA_FTW_STATE 0x0f // State information during FTW operations +#define EFI_FLASH_AREA_UNUSED 0x0fd // Not used +#define EFI_FLASH_AREA_GUID_DEFINED 0x0fe // Usage defined by a GUID +#pragma pack(1) +// +// An individual sub-area Entry. +// A single flash area may consist of more than one sub-area. +// +typedef struct { + EFI_FLASH_AREA_ATTRIBUTES Attributes; + UINT32 Reserved; + EFI_PHYSICAL_ADDRESS Base; + EFI_PHYSICAL_ADDRESS Length; + EFI_GUID FileSystem; +} EFI_FLASH_SUBAREA_ENTRY; + +typedef struct { + UINT8 Reserved[3]; + EFI_FLASH_AREA_TYPE AreaType; + EFI_GUID AreaTypeGuid; + UINT32 NumEntries; + EFI_FLASH_SUBAREA_ENTRY Entries[1]; +} EFI_FLASH_MAP_ENTRY_DATA; + +typedef struct { + UINT8 Reserved[3]; + EFI_FLASH_AREA_TYPE AreaType; + EFI_GUID AreaTypeGuid; + UINT32 NumberOfEntries; + EFI_FLASH_SUBAREA_ENTRY Entries[1]; + // + // Extended Hob data. + // + // VolumeId and FilePath indicating a unique file. + // + UINT32 VolumeId; + CHAR16 FilePath[256]; + UINT32 ActuralSize; + UINT32 Offset; +} EFI_FLASH_MAP_FS_ENTRY_DATA; + +typedef struct { + EFI_HOB_GENERIC_HEADER Header; + EFI_GUID Name; + UINT8 Reserved[3]; + EFI_FLASH_AREA_TYPE AreaType; + EFI_GUID AreaTypeGuid; + UINT32 NumEntries; + EFI_FLASH_SUBAREA_ENTRY Entries[1]; +} EFI_HOB_FLASH_MAP_ENTRY_TYPE; + +// +// Internal definitions +// +typedef struct { + UINT8 Reserved[3]; + EFI_FLASH_AREA_TYPE AreaType; + EFI_GUID AreaTypeGuid; + UINT32 NumberOfEntries; + EFI_FLASH_SUBAREA_ENTRY SubAreaData; +} EFI_FLASH_AREA_HOB_DATA; + +typedef struct { + UINTN Base; + UINTN Length; + EFI_FLASH_AREA_ATTRIBUTES Attributes; + EFI_FLASH_AREA_TYPE AreaType; + UINT8 Reserved[3]; + EFI_GUID AreaTypeGuid; +} EFI_FLASH_AREA_DATA; + +#pragma pack() + +#endif // #ifndef _EFI_FLASHMAP_H_ diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiPci.h b/EdkCompatibilityPkg/Foundation/Include/EfiPci.h new file mode 100644 index 0000000000..32014095e7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiPci.h @@ -0,0 +1,64 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPci.h + +Abstract: + Support for EFI PCI specification. + +Revision History + +--*/ + +#ifndef _EFI_PCI_H_ +#define _EFI_PCI_H_ + +//#include "pci22.h" +//#include "pci23.h" +//#include "pci30.h" + +#pragma pack(push, 1) + +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT8 Reserved[4]; +} DEFIO_PCI_ADDR; + +#define EFI_ROOT_BRIDGE_LIST 'eprb' +#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE 0x0EF1 + +typedef struct { + UINT16 Signature; // 0xaa55 + UINT16 InitializationSize; + UINT32 EfiSignature; // 0x0EF1 + UINT16 EfiSubsystem; + UINT16 EfiMachineType; + UINT16 CompressionType; + UINT8 Reserved[8]; + UINT16 EfiImageHeaderOffset; + UINT16 PcirOffset; +} EFI_PCI_EXPANSION_ROM_HEADER; + +typedef union { + UINT8 *Raw; + PCI_EXPANSION_ROM_HEADER *Generic; + EFI_PCI_EXPANSION_ROM_HEADER *Efi; + EFI_LEGACY_EXPANSION_ROM_HEADER *PcAt; +} EFI_PCI_ROM_HEADER; + +#pragma pack(pop) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiPerf.h b/EdkCompatibilityPkg/Foundation/Include/EfiPerf.h new file mode 100644 index 0000000000..55c743f7a7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiPerf.h @@ -0,0 +1,158 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPerf.h + +Abstract: + EfiPerf.h provides performance primitive for the DXE and Shell phase + + +--*/ + +#ifndef _EFI_PERF_H_ +#define _EFI_PERF_H_ + +#include EFI_PROTOCOL_DEFINITION (Performance) + +EFI_STATUS +InitializePerformanceInfrastructure ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ImageHandle - TODO: add argument description + SystemTable - TODO: add argument description + Ticker - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EndMeasure ( + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Handle - TODO: add argument description + Token - TODO: add argument description + Host - TODO: add argument description + Ticker - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +StartMeasure ( + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Handle - TODO: add argument description + Token - TODO: add argument description + Host - TODO: add argument description + Ticker - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +UpdateMeasure ( + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN EFI_HANDLE HandleNew, + IN UINT16 *TokenNew, + IN UINT16 *HostNew + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Handle - TODO: add argument description + Token - TODO: add argument description + Host - TODO: add argument description + HandleNew - TODO: add argument description + TokenNew - TODO: add argument description + HostNew - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +#ifdef EFI_DXE_PERFORMANCE +#define PERF_ENABLE(handle, table, ticker) InitializePerformanceInfrastructure (handle, table, ticker) +#define PERF_START(handle, token, host, ticker) StartMeasure (handle, token, host, ticker) +#define PERF_END(handle, token, host, ticker) EndMeasure (handle, token, host, ticker) +#define PERF_UPDATE(handle, token, host, handlenew, tokennew, hostnew) \ + UpdateMeasure (handle, \ + token, \ + host, \ + handlenew, \ + tokennew, \ + hostnew \ + ) +#define PERF_CODE(code) code +#else +#define PERF_ENABLE(handle, table, ticker) +#define PERF_START(handle, token, host, ticker) +#define PERF_END(handle, token, host, ticker) +#define PERF_UPDATE(handle, token, host, handlenew, tokennew, hostnew) +#define PERF_CODE(code) +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiPxe.h b/EdkCompatibilityPkg/Foundation/Include/EfiPxe.h new file mode 100644 index 0000000000..0ff2252469 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiPxe.h @@ -0,0 +1,1816 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module name: + + EfiPxe.h + +32/64-bit PXE specification: + + alpha-4, 99-Dec-17 + +Abstract: + + This header file contains all of the PXE type definitions, + structure prototypes, global variables and constants that + are needed for porting PXE to EFI. +--*/ + +#ifndef _EFIPXE_H +#define _EFIPXE_H + +#pragma pack(1) + +#define PXE_INTEL_ORDER 1 // Intel order +// #define PXE_NETWORK_ORDER 1 // network order +// +#define PXE_UINT64_SUPPORT 1 // UINT64 supported +// #define PXE_NO_UINT64_SUPPORT 1 // UINT64 not supported +// +#define PXE_BUSTYPE(a, b, c, d) \ + ( \ + (((UINT32) (d) & 0xFF) << 24) | (((UINT32) (c) & 0xFF) << 16) | (((UINT32) (b) & 0xFF) << 8) | \ + ((UINT32) (a) & 0xFF) \ + ) + +// +// UNDI ROM ID and devive ID signature +// +#define PXE_BUSTYPE_PXE PXE_BUSTYPE ('!', 'P', 'X', 'E') + +// +// BUS ROM ID signatures +// +#define PXE_BUSTYPE_PCI PXE_BUSTYPE ('P', 'C', 'I', 'R') +#define PXE_BUSTYPE_PC_CARD PXE_BUSTYPE ('P', 'C', 'C', 'R') +#define PXE_BUSTYPE_USB PXE_BUSTYPE ('U', 'S', 'B', 'R') +#define PXE_BUSTYPE_1394 PXE_BUSTYPE ('1', '3', '9', '4') + +#define PXE_SWAP_UINT16(n) ((((UINT16) (n) & 0x00FF) << 8) | (((UINT16) (n) & 0xFF00) >> 8)) + +#define PXE_SWAP_UINT32(n) \ +((((UINT32)(n) & 0x000000FF) << 24) | \ +(((UINT32)(n) & 0x0000FF00) << 8) | \ +(((UINT32)(n) & 0x00FF0000) >> 8) | \ +(((UINT32)(n) & 0xFF000000) >> 24)) + +#if PXE_UINT64_SUPPORT != 0 +#define PXE_SWAP_UINT64(n) \ +((((UINT64)(n) & 0x00000000000000FF) << 56) | \ +(((UINT64)(n) & 0x000000000000FF00) << 40) | \ +(((UINT64)(n) & 0x0000000000FF0000) << 24) | \ +(((UINT64)(n) & 0x00000000FF000000) << 8) | \ +(((UINT64)(n) & 0x000000FF00000000) >> 8) | \ +(((UINT64)(n) & 0x0000FF0000000000) >> 24) | \ +(((UINT64)(n) & 0x00FF000000000000) >> 40) | \ +(((UINT64)(n) & 0xFF00000000000000) >> 56)) +#endif // PXE_UINT64_SUPPORT +#if PXE_NO_UINT64_SUPPORT != 0 +#define PXE_SWAP_UINT64(n) { \ + UINT32 tmp; \ + tmp = (PXE_UINT64) (n)[1]; \ + (UINT64) (n)[1] = PXE_SWAP_UINT32 ((UINT64) (n)[0]); \ + (UINT64) (n)[0] = tmp; \ + } +#endif // PXE_NO_UINT64_SUPPORT +#define PXE_CPBSIZE_NOT_USED 0 // zero +#define PXE_DBSIZE_NOT_USED 0 // zero +#define PXE_CPBADDR_NOT_USED (PXE_UINT64) 0 // zero +#define PXE_DBADDR_NOT_USED (PXE_UINT64) 0 // zero +#define PXE_CONST const + +#define PXE_VOLATILE volatile + +#if PXE_UINT64_SUPPORT != 0 +// +// typedef unsigned long PXE_UINT64; +// +typedef UINT64 PXE_UINT64; +#endif // PXE_UINT64_SUPPORT +#if PXE_NO_UINT64_SUPPORT != 0 +typedef PXE_UINT32 PXE_UINT64[2]; +#endif // PXE_NO_UINT64_SUPPORT +#define PXE_FALSE 0 // zero +#define PXE_TRUE (!PXE_FALSE) + +typedef UINT16 PXE_OPCODE; + +// +// Return UNDI operational state. +// +#define PXE_OPCODE_GET_STATE 0x0000 + +// +// Change UNDI operational state from Stopped to Started. +// +#define PXE_OPCODE_START 0x0001 + +// +// Change UNDI operational state from Started to Stopped. +// +#define PXE_OPCODE_STOP 0x0002 + +// +// Get UNDI initialization information. +// +#define PXE_OPCODE_GET_INIT_INFO 0x0003 + +// +// Get NIC configuration information. +// +#define PXE_OPCODE_GET_CONFIG_INFO 0x0004 + +// +// Changed UNDI operational state from Started to Initialized. +// +#define PXE_OPCODE_INITIALIZE 0x0005 + +// +// Re-initialize the NIC H/W. +// +#define PXE_OPCODE_RESET 0x0006 + +// +// Change the UNDI operational state from Initialized to Started. +// +#define PXE_OPCODE_SHUTDOWN 0x0007 + +// +// Read & change state of external interrupt enables. +// +#define PXE_OPCODE_INTERRUPT_ENABLES 0x0008 + +// +// Read & change state of packet receive filters. +// +#define PXE_OPCODE_RECEIVE_FILTERS 0x0009 + +// +// Read & change station MAC address. +// +#define PXE_OPCODE_STATION_ADDRESS 0x000A + +// +// Read traffic statistics. +// +#define PXE_OPCODE_STATISTICS 0x000B + +// +// Convert multicast IP address to multicast MAC address. +// +#define PXE_OPCODE_MCAST_IP_TO_MAC 0x000C + +// +// Read or change non-volatile storage on the NIC. +// +#define PXE_OPCODE_NVDATA 0x000D + +// +// Get & clear interrupt status. +// +#define PXE_OPCODE_GET_STATUS 0x000E + +// +// Fill media header in packet for transmit. +// +#define PXE_OPCODE_FILL_HEADER 0x000F + +// +// Transmit packet(s). +// +#define PXE_OPCODE_TRANSMIT 0x0010 + +// +// Receive packet. +// +#define PXE_OPCODE_RECEIVE 0x0011 + +// +// last valid opcode: +// +#define PXE_OPCODE_VALID_MAX 0x0011 + +// +// Last valid PXE UNDI OpCode number. +// +#define PXE_OPCODE_LAST_VALID 0x0011 + +typedef UINT16 PXE_OPFLAGS; + +#define PXE_OPFLAGS_NOT_USED 0x0000 + +// +// ////////////////////////////////////// +// UNDI Get State +// +// No OpFlags + +//////////////////////////////////////// +// UNDI Start +// +// No OpFlags + +//////////////////////////////////////// +// UNDI Stop +// +// No OpFlags + +//////////////////////////////////////// +// UNDI Get Init Info +// +// No Opflags + +//////////////////////////////////////// +// UNDI Get Config Info +// +// No Opflags + +//////////////////////////////////////// +// UNDI Initialize +// +#define PXE_OPFLAGS_INITIALIZE_CABLE_DETECT_MASK 0x0001 +#define PXE_OPFLAGS_INITIALIZE_DETECT_CABLE 0x0000 +#define PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE 0x0001 + +// +// ////////////////////////////////////// +// UNDI Reset +// +#define PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS 0x0001 +#define PXE_OPFLAGS_RESET_DISABLE_FILTERS 0x0002 + +// +// ////////////////////////////////////// +// UNDI Shutdown +// +// No OpFlags + +//////////////////////////////////////// +// UNDI Interrupt Enables +// +// +// Select whether to enable or disable external interrupt signals. +// Setting both enable and disable will return PXE_STATCODE_INVALID_OPFLAGS. +// +#define PXE_OPFLAGS_INTERRUPT_OPMASK 0xC000 +#define PXE_OPFLAGS_INTERRUPT_ENABLE 0x8000 +#define PXE_OPFLAGS_INTERRUPT_DISABLE 0x4000 +#define PXE_OPFLAGS_INTERRUPT_READ 0x0000 + +// +// Enable receive interrupts. An external interrupt will be generated +// after a complete non-error packet has been received. +// +#define PXE_OPFLAGS_INTERRUPT_RECEIVE 0x0001 + +// +// Enable transmit interrupts. An external interrupt will be generated +// after a complete non-error packet has been transmitted. +// +#define PXE_OPFLAGS_INTERRUPT_TRANSMIT 0x0002 + +// +// Enable command interrupts. An external interrupt will be generated +// when command execution stops. +// +#define PXE_OPFLAGS_INTERRUPT_COMMAND 0x0004 + +// +// Generate software interrupt. Setting this bit generates an external +// interrupt, if it is supported by the hardware. +// +#define PXE_OPFLAGS_INTERRUPT_SOFTWARE 0x0008 + +// +// ////////////////////////////////////// +// UNDI Receive Filters +// +// +// Select whether to enable or disable receive filters. +// Setting both enable and disable will return PXE_STATCODE_INVALID_OPCODE. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_OPMASK 0xC000 +#define PXE_OPFLAGS_RECEIVE_FILTER_ENABLE 0x8000 +#define PXE_OPFLAGS_RECEIVE_FILTER_DISABLE 0x4000 +#define PXE_OPFLAGS_RECEIVE_FILTER_READ 0x0000 + +// +// To reset the contents of the multicast MAC address filter list, +// set this OpFlag: +// +#define PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST 0x2000 + +// +// Enable unicast packet receiving. Packets sent to the current station +// MAC address will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_UNICAST 0x0001 + +// +// Enable broadcast packet receiving. Packets sent to the broadcast +// MAC address will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST 0x0002 + +// +// Enable filtered multicast packet receiving. Packets sent to any +// of the multicast MAC addresses in the multicast MAC address filter +// list will be received. If the filter list is empty, no multicast +// +#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004 + +// +// Enable promiscuous packet receiving. All packets will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS 0x0008 + +// +// Enable promiscuous multicast packet receiving. All multicast +// packets will be received. +// +#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST 0x0010 + +// +// ////////////////////////////////////// +// UNDI Station Address +// +#define PXE_OPFLAGS_STATION_ADDRESS_READ 0x0000 +#define PXE_OPFLAGS_STATION_ADDRESS_WRITE 0x0000 +#define PXE_OPFLAGS_STATION_ADDRESS_RESET 0x0001 + +// +// ////////////////////////////////////// +// UNDI Statistics +// +#define PXE_OPFLAGS_STATISTICS_READ 0x0000 +#define PXE_OPFLAGS_STATISTICS_RESET 0x0001 + +// +// ////////////////////////////////////// +// UNDI MCast IP to MAC +// +// +// Identify the type of IP address in the CPB. +// +#define PXE_OPFLAGS_MCAST_IP_TO_MAC_OPMASK 0x0003 +#define PXE_OPFLAGS_MCAST_IPV4_TO_MAC 0x0000 +#define PXE_OPFLAGS_MCAST_IPV6_TO_MAC 0x0001 + +// +// ////////////////////////////////////// +// UNDI NvData +// +// +// Select the type of non-volatile data operation. +// +#define PXE_OPFLAGS_NVDATA_OPMASK 0x0001 +#define PXE_OPFLAGS_NVDATA_READ 0x0000 +#define PXE_OPFLAGS_NVDATA_WRITE 0x0001 + +// +// ////////////////////////////////////// +// UNDI Get Status +// +// +// Return current interrupt status. This will also clear any interrupts +// that are currently set. This can be used in a polling routine. The +// interrupt flags are still set and cleared even when the interrupts +// are disabled. +// +#define PXE_OPFLAGS_GET_INTERRUPT_STATUS 0x0001 + +// +// Return list of transmitted buffers for recycling. Transmit buffers +// must not be changed or unallocated until they have recycled. After +// issuing a transmit command, wait for a transmit complete interrupt. +// When a transmit complete interrupt is received, read the transmitted +// buffers. Do not plan on getting one buffer per interrupt. Some +// NICs and UNDIs may transmit multiple buffers per interrupt. +// +#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS 0x0002 + +// +// ////////////////////////////////////// +// UNDI Fill Header +// +#define PXE_OPFLAGS_FILL_HEADER_OPMASK 0x0001 +#define PXE_OPFLAGS_FILL_HEADER_FRAGMENTED 0x0001 +#define PXE_OPFLAGS_FILL_HEADER_WHOLE 0x0000 + +// +// ////////////////////////////////////// +// UNDI Transmit +// +// +// S/W UNDI only. Return after the packet has been transmitted. A +// transmit complete interrupt will still be generated and the transmit +// buffer will have to be recycled. +// +#define PXE_OPFLAGS_SWUNDI_TRANSMIT_OPMASK 0x0001 +#define PXE_OPFLAGS_TRANSMIT_BLOCK 0x0001 +#define PXE_OPFLAGS_TRANSMIT_DONT_BLOCK 0x0000 + +// +// +// +#define PXE_OPFLAGS_TRANSMIT_OPMASK 0x0002 +#define PXE_OPFLAGS_TRANSMIT_FRAGMENTED 0x0002 +#define PXE_OPFLAGS_TRANSMIT_WHOLE 0x0000 + +// +// ////////////////////////////////////// +// UNDI Receive +// +// No OpFlags +// +typedef UINT16 PXE_STATFLAGS; + +#define PXE_STATFLAGS_INITIALIZE 0x0000 + +// +// ////////////////////////////////////// +// Common StatFlags that can be returned by all commands. +// +// +// The COMMAND_COMPLETE and COMMAND_FAILED status flags must be +// implemented by all UNDIs. COMMAND_QUEUED is only needed by UNDIs +// that support command queuing. +// +#define PXE_STATFLAGS_STATUS_MASK 0xC000 +#define PXE_STATFLAGS_COMMAND_COMPLETE 0xC000 +#define PXE_STATFLAGS_COMMAND_FAILED 0x8000 +#define PXE_STATFLAGS_COMMAND_QUEUED 0x4000 +// +// #define PXE_STATFLAGS_INITIALIZE 0x0000 +// +#define PXE_STATFLAGS_DB_WRITE_TRUNCATED 0x2000 + +// +// ////////////////////////////////////// +// UNDI Get State +// +#define PXE_STATFLAGS_GET_STATE_MASK 0x0003 +#define PXE_STATFLAGS_GET_STATE_INITIALIZED 0x0002 +#define PXE_STATFLAGS_GET_STATE_STARTED 0x0001 +#define PXE_STATFLAGS_GET_STATE_STOPPED 0x0000 + +// +// ////////////////////////////////////// +// UNDI Start +// +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Get Init Info +// +#define PXE_STATFLAGS_CABLE_DETECT_MASK 0x0001 +#define PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED 0x0000 +#define PXE_STATFLAGS_CABLE_DETECT_SUPPORTED 0x0001 + +// +// ////////////////////////////////////// +// UNDI Initialize +// +#define PXE_STATFLAGS_INITIALIZED_NO_MEDIA 0x0001 + +// +// ////////////////////////////////////// +// UNDI Reset +// +#define PXE_STATFLAGS_RESET_NO_MEDIA 0x0001 + +// +// ////////////////////////////////////// +// UNDI Shutdown +// +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Interrupt Enables +// +// +// If set, receive interrupts are enabled. +// +#define PXE_STATFLAGS_INTERRUPT_RECEIVE 0x0001 + +// +// If set, transmit interrupts are enabled. +// +#define PXE_STATFLAGS_INTERRUPT_TRANSMIT 0x0002 + +// +// If set, command interrupts are enabled. +// +#define PXE_STATFLAGS_INTERRUPT_COMMAND 0x0004 + +// +// ////////////////////////////////////// +// UNDI Receive Filters +// +// +// If set, unicast packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_UNICAST 0x0001 + +// +// If set, broadcast packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST 0x0002 + +// +// If set, multicast packets that match up with the multicast address +// filter list will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004 + +// +// If set, all packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS 0x0008 + +// +// If set, all multicast packets will be received. +// +#define PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST 0x0010 + +// +// ////////////////////////////////////// +// UNDI Station Address +// +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Statistics +// +// No additional StatFlags + +//////////////////////////////////////// +// UNDI MCast IP to MAC +// +// No additional StatFlags + +//////////////////////////////////////// +// UNDI NvData +// +// No additional StatFlags + + +//////////////////////////////////////// +// UNDI Get Status +// +// +// Use to determine if an interrupt has occurred. +// +#define PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK 0x000F +#define PXE_STATFLAGS_GET_STATUS_NO_INTERRUPTS 0x0000 + +// +// If set, at least one receive interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_RECEIVE 0x0001 + +// +// If set, at least one transmit interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_TRANSMIT 0x0002 + +// +// If set, at least one command interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_COMMAND 0x0004 + +// +// If set, at least one software interrupt occurred. +// +#define PXE_STATFLAGS_GET_STATUS_SOFTWARE 0x0008 + +// +// This flag is set if the transmitted buffer queue is empty. This flag +// will be set if all transmitted buffer addresses get written into the DB. +// +#define PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY 0x0010 + +// +// This flag is set if no transmitted buffer addresses were written +// into the DB. (This could be because DBsize was too small.) +// +#define PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN 0x0020 + +// +// ////////////////////////////////////// +// UNDI Fill Header +// +// No additional StatFlags + +//////////////////////////////////////// +// UNDI Transmit +// +// No additional StatFlags. + +//////////////////////////////////////// +// UNDI Receive +// +// No additional StatFlags. +// +typedef UINT16 PXE_STATCODE; + +#define PXE_STATCODE_INITIALIZE 0x0000 + +// +// ////////////////////////////////////// +// Common StatCodes returned by all UNDI commands, UNDI protocol functions +// and BC protocol functions. +// +#define PXE_STATCODE_SUCCESS 0x0000 + +#define PXE_STATCODE_INVALID_CDB 0x0001 +#define PXE_STATCODE_INVALID_CPB 0x0002 +#define PXE_STATCODE_BUSY 0x0003 +#define PXE_STATCODE_QUEUE_FULL 0x0004 +#define PXE_STATCODE_ALREADY_STARTED 0x0005 +#define PXE_STATCODE_NOT_STARTED 0x0006 +#define PXE_STATCODE_NOT_SHUTDOWN 0x0007 +#define PXE_STATCODE_ALREADY_INITIALIZED 0x0008 +#define PXE_STATCODE_NOT_INITIALIZED 0x0009 +#define PXE_STATCODE_DEVICE_FAILURE 0x000A +#define PXE_STATCODE_NVDATA_FAILURE 0x000B +#define PXE_STATCODE_UNSUPPORTED 0x000C +#define PXE_STATCODE_BUFFER_FULL 0x000D +#define PXE_STATCODE_INVALID_PARAMETER 0x000E +#define PXE_STATCODE_INVALID_UNDI 0x000F +#define PXE_STATCODE_IPV4_NOT_SUPPORTED 0x0010 +#define PXE_STATCODE_IPV6_NOT_SUPPORTED 0x0011 +#define PXE_STATCODE_NOT_ENOUGH_MEMORY 0x0012 +#define PXE_STATCODE_NO_DATA 0x0013 + +typedef UINT16 PXE_IFNUM; + +// +// This interface number must be passed to the S/W UNDI Start command. +// +#define PXE_IFNUM_START 0x0000 + +// +// This interface number is returned by the S/W UNDI Get State and +// Start commands if information in the CDB, CPB or DB is invalid. +// +#define PXE_IFNUM_INVALID 0x0000 + +typedef UINT16 PXE_CONTROL; + +// +// Setting this flag directs the UNDI to queue this command for later +// execution if the UNDI is busy and it supports command queuing. +// If queuing is not supported, a PXE_STATCODE_INVALID_CONTROL error +// is returned. If the queue is full, a PXE_STATCODE_CDB_QUEUE_FULL +// error is returned. +// +#define PXE_CONTROL_QUEUE_IF_BUSY 0x0002 + +// +// These two bit values are used to determine if there are more UNDI +// CDB structures following this one. If the link bit is set, there +// must be a CDB structure following this one. Execution will start +// on the next CDB structure as soon as this one completes successfully. +// If an error is generated by this command, execution will stop. +// +#define PXE_CONTROL_LINK 0x0001 +#define PXE_CONTROL_LAST_CDB_IN_LIST 0x0000 + +typedef UINT8 PXE_FRAME_TYPE; + +#define PXE_FRAME_TYPE_NONE 0x00 +#define PXE_FRAME_TYPE_UNICAST 0x01 +#define PXE_FRAME_TYPE_BROADCAST 0x02 +#define PXE_FRAME_TYPE_MULTICAST 0x03 +#define PXE_FRAME_TYPE_PROMISCUOUS 0x04 + +typedef UINT32 PXE_IPV4; + +typedef UINT32 PXE_IPV6[4]; +#define PXE_MAC_LENGTH 32 + +typedef UINT8 PXE_MAC_ADDR[PXE_MAC_LENGTH]; + +typedef UINT8 PXE_IFTYPE; +typedef UINT16 PXE_MEDIA_PROTOCOL; + +// +// This information is from the ARP section of RFC 1700. +// +// 1 Ethernet (10Mb) [JBP] +// 2 Experimental Ethernet (3Mb) [JBP] +// 3 Amateur Radio AX.25 [PXK] +// 4 Proteon ProNET Token Ring [JBP] +// 5 Chaos [GXP] +// 6 IEEE 802 Networks [JBP] +// 7 ARCNET [JBP] +// 8 Hyperchannel [JBP] +// 9 Lanstar [TU] +// 10 Autonet Short Address [MXB1] +// 11 LocalTalk [JKR1] +// 12 LocalNet (IBM* PCNet or SYTEK* LocalNET) [JXM] +// 13 Ultra link [RXD2] +// 14 SMDS [GXC1] +// 15 Frame Relay [AGM] +// 16 Asynchronous Transmission Mode (ATM) [JXB2] +// 17 HDLC [JBP] +// 18 Fibre Channel [Yakov Rekhter] +// 19 Asynchronous Transmission Mode (ATM) [Mark Laubach] +// 20 Serial Line [JBP] +// 21 Asynchronous Transmission Mode (ATM) [MXB1] +// +// * Other names and brands may be claimed as the property of others. +// +#define PXE_IFTYPE_ETHERNET 0x01 +#define PXE_IFTYPE_TOKENRING 0x04 +#define PXE_IFTYPE_FIBRE_CHANNEL 0x12 + +typedef struct s_pxe_hw_undi { + UINT32 Signature; // PXE_ROMID_SIGNATURE + UINT8 Len; // sizeof(PXE_HW_UNDI) + UINT8 Fudge; // makes 8-bit cksum equal zero + UINT8 Rev; // PXE_ROMID_REV + UINT8 IFcnt; // physical connector count + UINT8 MajorVer; // PXE_ROMID_MAJORVER + UINT8 MinorVer; // PXE_ROMID_MINORVER + UINT16 reserved; // zero, not used + UINT32 Implementation; // implementation flags + // reserved // vendor use + // UINT32 Status; // status port + // UINT32 Command; // command port + // UINT64 CDBaddr; // CDB address port + // +} PXE_HW_UNDI; + +// +// Status port bit definitions +// +// +// UNDI operation state +// +#define PXE_HWSTAT_STATE_MASK 0xC0000000 +#define PXE_HWSTAT_BUSY 0xC0000000 +#define PXE_HWSTAT_INITIALIZED 0x80000000 +#define PXE_HWSTAT_STARTED 0x40000000 +#define PXE_HWSTAT_STOPPED 0x00000000 + +// +// If set, last command failed +// +#define PXE_HWSTAT_COMMAND_FAILED 0x20000000 + +// +// If set, identifies enabled receive filters +// +#define PXE_HWSTAT_PROMISCUOUS_MULTICAST_RX_ENABLED 0x00001000 +#define PXE_HWSTAT_PROMISCUOUS_RX_ENABLED 0x00000800 +#define PXE_HWSTAT_BROADCAST_RX_ENABLED 0x00000400 +#define PXE_HWSTAT_MULTICAST_RX_ENABLED 0x00000200 +#define PXE_HWSTAT_UNICAST_RX_ENABLED 0x00000100 + +// +// If set, identifies enabled external interrupts +// +#define PXE_HWSTAT_SOFTWARE_INT_ENABLED 0x00000080 +#define PXE_HWSTAT_TX_COMPLETE_INT_ENABLED 0x00000040 +#define PXE_HWSTAT_PACKET_RX_INT_ENABLED 0x00000020 +#define PXE_HWSTAT_CMD_COMPLETE_INT_ENABLED 0x00000010 + +// +// If set, identifies pending interrupts +// +#define PXE_HWSTAT_SOFTWARE_INT_PENDING 0x00000008 +#define PXE_HWSTAT_TX_COMPLETE_INT_PENDING 0x00000004 +#define PXE_HWSTAT_PACKET_RX_INT_PENDING 0x00000002 +#define PXE_HWSTAT_CMD_COMPLETE_INT_PENDING 0x00000001 + +// +// Command port definitions +// +// +// If set, CDB identified in CDBaddr port is given to UNDI. +// If not set, other bits in this word will be processed. +// +#define PXE_HWCMD_ISSUE_COMMAND 0x80000000 +#define PXE_HWCMD_INTS_AND_FILTS 0x00000000 + +// +// Use these to enable/disable receive filters. +// +#define PXE_HWCMD_PROMISCUOUS_MULTICAST_RX_ENABLE 0x00001000 +#define PXE_HWCMD_PROMISCUOUS_RX_ENABLE 0x00000800 +#define PXE_HWCMD_BROADCAST_RX_ENABLE 0x00000400 +#define PXE_HWCMD_MULTICAST_RX_ENABLE 0x00000200 +#define PXE_HWCMD_UNICAST_RX_ENABLE 0x00000100 + +// +// Use these to enable/disable external interrupts +// +#define PXE_HWCMD_SOFTWARE_INT_ENABLE 0x00000080 +#define PXE_HWCMD_TX_COMPLETE_INT_ENABLE 0x00000040 +#define PXE_HWCMD_PACKET_RX_INT_ENABLE 0x00000020 +#define PXE_HWCMD_CMD_COMPLETE_INT_ENABLE 0x00000010 + +// +// Use these to clear pending external interrupts +// +#define PXE_HWCMD_CLEAR_SOFTWARE_INT 0x00000008 +#define PXE_HWCMD_CLEAR_TX_COMPLETE_INT 0x00000004 +#define PXE_HWCMD_CLEAR_PACKET_RX_INT 0x00000002 +#define PXE_HWCMD_CLEAR_CMD_COMPLETE_INT 0x00000001 + +typedef struct s_pxe_sw_undi { + UINT32 Signature; // PXE_ROMID_SIGNATURE + UINT8 Len; // sizeof(PXE_SW_UNDI) + UINT8 Fudge; // makes 8-bit cksum zero + UINT8 Rev; // PXE_ROMID_REV + UINT8 IFcnt; // physical connector count + UINT8 MajorVer; // PXE_ROMID_MAJORVER + UINT8 MinorVer; // PXE_ROMID_MINORVER + UINT16 reserved1; // zero, not used + UINT32 Implementation; // Implementation flags + UINT64 EntryPoint; // API entry point + UINT8 reserved2[3]; // zero, not used + UINT8 BusCnt; // number of bustypes supported + UINT32 BusType[1]; // list of supported bustypes +} PXE_SW_UNDI; + +typedef union u_pxe_undi { + PXE_HW_UNDI hw; + PXE_SW_UNDI sw; +} PXE_UNDI; + +// +// Signature of !PXE structure +// +#define PXE_ROMID_SIGNATURE PXE_BUSTYPE ('!', 'P', 'X', 'E') + +// +// !PXE structure format revision +// +#define PXE_ROMID_REV 0x02 + +// +// UNDI command interface revision. These are the values that get sent +// in option 94 (Client Network Interface Identifier) in the DHCP Discover +// and PXE Boot Server Request packets. +// +#define PXE_ROMID_MAJORVER 0x03 +#define PXE_ROMID_MINORVER 0x00 +#define PXE_ROMID_MINORVER_31 0x10 + +// +// Implementation flags +// +#define PXE_ROMID_IMP_HW_UNDI 0x80000000 +#define PXE_ROMID_IMP_SW_VIRT_ADDR 0x40000000 +#define PXE_ROMID_IMP_64BIT_DEVICE 0x00010000 +#define PXE_ROMID_IMP_FRAG_SUPPORTED 0x00008000 +#define PXE_ROMID_IMP_CMD_LINK_SUPPORTED 0x00004000 +#define PXE_ROMID_IMP_CMD_QUEUE_SUPPORTED 0x00002000 +#define PXE_ROMID_IMP_MULTI_FRAME_SUPPORTED 0x00001000 +#define PXE_ROMID_IMP_NVDATA_SUPPORT_MASK 0x00000C00 +#define PXE_ROMID_IMP_NVDATA_BULK_WRITABLE 0x00000C00 +#define PXE_ROMID_IMP_NVDATA_SPARSE_WRITABLE 0x00000800 +#define PXE_ROMID_IMP_NVDATA_READ_ONLY 0x00000400 +#define PXE_ROMID_IMP_NVDATA_NOT_AVAILABLE 0x00000000 +#define PXE_ROMID_IMP_STATISTICS_SUPPORTED 0x00000200 +#define PXE_ROMID_IMP_STATION_ADDR_SETTABLE 0x00000100 +#define PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED 0x00000080 +#define PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED 0x00000040 +#define PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED 0x00000020 +#define PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED 0x00000010 +#define PXE_ROMID_IMP_SOFTWARE_INT_SUPPORTED 0x00000008 +#define PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED 0x00000004 +#define PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED 0x00000002 +#define PXE_ROMID_IMP_CMD_COMPLETE_INT_SUPPORTED 0x00000001 + +typedef struct s_pxe_cdb { + PXE_OPCODE OpCode; + PXE_OPFLAGS OpFlags; + UINT16 CPBsize; + UINT16 DBsize; + UINT64 CPBaddr; + UINT64 DBaddr; + PXE_STATCODE StatCode; + PXE_STATFLAGS StatFlags; + UINT16 IFnum; + PXE_CONTROL Control; +} PXE_CDB; + +typedef union u_pxe_ip_addr { + PXE_IPV6 IPv6; + PXE_IPV4 IPv4; +} PXE_IP_ADDR; + +typedef union pxe_device { + // + // PCI and PC Card NICs are both identified using bus, device + // and function numbers. For PC Card, this may require PC + // Card services to be loaded in the BIOS or preboot + // environment. + // + struct { + // + // See S/W UNDI ROMID structure definition for PCI and + // PCC BusType definitions. + // + UINT32 BusType; + + // + // Bus, device & function numbers that locate this device. + // + UINT16 Bus; + UINT8 Device; + UINT8 Function; + } + PCI, PCC; + + // + // %%TBD - More information is needed about enumerating + // USB and 1394 devices. + // + struct { + UINT32 BusType; + UINT32 tdb; + } + USB, _1394; +} PXE_DEVICE; + +// +// cpb and db definitions +// +#define MAX_PCI_CONFIG_LEN 64 // # of dwords +#define MAX_EEPROM_LEN 128 // #of dwords +#define MAX_XMIT_BUFFERS 32 // recycling Q length for xmit_done +#define MAX_MCAST_ADDRESS_CNT 8 + +typedef struct s_pxe_cpb_start { + // + // PXE_VOID Delay(UINTN microseconds); + // + // UNDI will never request a delay smaller than 10 microseconds + // and will always request delays in increments of 10 microseconds. + // The Delay() CallBack routine must delay between n and n + 10 + // microseconds before returning control to the UNDI. + // + // This field cannot be set to zero. + // + UINT64 Delay; + + // + // PXE_VOID Block(UINT32 enable); + // + // UNDI may need to block multi-threaded/multi-processor access to + // critical code sections when programming or accessing the network + // device. To this end, a blocking service is needed by the UNDI. + // When UNDI needs a block, it will call Block() passing a non-zero + // value. When UNDI no longer needs a block, it will call Block() + // with a zero value. When called, if the Block() is already enabled, + // do not return control to the UNDI until the previous Block() is + // disabled. + // + // This field cannot be set to zero. + // + UINT64 Block; + + // + // PXE_VOID Virt2Phys(UINT64 virtual, UINT64 physical_ptr); + // + // UNDI will pass the virtual address of a buffer and the virtual + // address of a 64-bit physical buffer. Convert the virtual address + // to a physical address and write the result to the physical address + // buffer. If virtual and physical addresses are the same, just + // copy the virtual address to the physical address buffer. + // + // This field can be set to zero if virtual and physical addresses + // are equal. + // + UINT64 Virt2Phys; + // + // PXE_VOID Mem_IO(UINT8 read_write, UINT8 len, UINT64 port, + // UINT64 buf_addr); + // + // UNDI will read or write the device io space using this call back + // function. It passes the number of bytes as the len parameter and it + // will be either 1,2,4 or 8. + // + // This field can not be set to zero. + // + UINT64 Mem_IO; +} PXE_CPB_START; + +typedef struct s_pxe_cpb_start_31 { + // + // PXE_VOID Delay(UINT64 UnqId, UINTN microseconds); + // + // UNDI will never request a delay smaller than 10 microseconds + // and will always request delays in increments of 10 microseconds. + // The Delay() CallBack routine must delay between n and n + 10 + // microseconds before returning control to the UNDI. + // + // This field cannot be set to zero. + // + UINT64 Delay; + + // + // PXE_VOID Block(UINT64 unq_id, UINT32 enable); + // + // UNDI may need to block multi-threaded/multi-processor access to + // critical code sections when programming or accessing the network + // device. To this end, a blocking service is needed by the UNDI. + // When UNDI needs a block, it will call Block() passing a non-zero + // value. When UNDI no longer needs a block, it will call Block() + // with a zero value. When called, if the Block() is already enabled, + // do not return control to the UNDI until the previous Block() is + // disabled. + // + // This field cannot be set to zero. + // + UINT64 Block; + + // + // PXE_VOID Virt2Phys(UINT64 UnqId, UINT64 virtual, UINT64 physical_ptr); + // + // UNDI will pass the virtual address of a buffer and the virtual + // address of a 64-bit physical buffer. Convert the virtual address + // to a physical address and write the result to the physical address + // buffer. If virtual and physical addresses are the same, just + // copy the virtual address to the physical address buffer. + // + // This field can be set to zero if virtual and physical addresses + // are equal. + // + UINT64 Virt2Phys; + // + // PXE_VOID Mem_IO(UINT64 UnqId, UINT8 read_write, UINT8 len, UINT64 port, + // UINT64 buf_addr); + // + // UNDI will read or write the device io space using this call back + // function. It passes the number of bytes as the len parameter and it + // will be either 1,2,4 or 8. + // + // This field can not be set to zero. + // + UINT64 Mem_IO; + // + // PXE_VOID Map_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size, + // UINT32 Direction, UINT64 mapped_addr); + // + // UNDI will pass the virtual address of a buffer, direction of the data + // flow from/to the mapped buffer (the constants are defined below) + // and a place holder (pointer) for the mapped address. + // This call will Map the given address to a physical DMA address and write + // the result to the mapped_addr pointer. If there is no need to + // map the given address to a lower address (i.e. the given address is + // associated with a physical address that is already compatible to be + // used with the DMA, it converts the given virtual address to it's + // physical address and write that in the mapped address pointer. + // + // This field can be set to zero if there is no mapping service available + // + UINT64 Map_Mem; + + // + // PXE_VOID UnMap_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size, + // UINT32 Direction, UINT64 mapped_addr); + // + // UNDI will pass the virtual and mapped addresses of a buffer + // This call will un map the given address + // + // This field can be set to zero if there is no unmapping service available + // + UINT64 UnMap_Mem; + + // + // PXE_VOID Sync_Mem(UINT64 unq_id, UINT64 virtual, + // UINT32 size, UINT32 Direction, UINT64 mapped_addr); + // + // UNDI will pass the virtual and mapped addresses of a buffer + // This call will synchronize the contents of both the virtual and mapped + // buffers for the given Direction. + // + // This field can be set to zero if there is no service available + // + UINT64 Sync_Mem; + + // + // protocol driver can provide anything for this Unique_ID, UNDI remembers + // that as just a 64bit value assocaited to the interface specified by + // the ifnum and gives it back as a parameter to all the call-back routines + // when calling for that interface! + // + UINT64 Unique_ID; + // +} PXE_CPB_START_31; + +#define TO_AND_FROM_DEVICE 0 +#define FROM_DEVICE 1 +#define TO_DEVICE 2 + +#define PXE_DELAY_MILLISECOND 1000 +#define PXE_DELAY_SECOND 1000000 +#define PXE_IO_READ 0 +#define PXE_IO_WRITE 1 +#define PXE_MEM_READ 2 +#define PXE_MEM_WRITE 4 + +typedef struct s_pxe_db_get_init_info { + // + // Minimum length of locked memory buffer that must be given to + // the Initialize command. Giving UNDI more memory will generally + // give better performance. + // + // If MemoryRequired is zero, the UNDI does not need and will not + // use system memory to receive and transmit packets. + // + UINT32 MemoryRequired; + + // + // Maximum frame data length for Tx/Rx excluding the media header. + // + UINT32 FrameDataLen; + + // + // Supported link speeds are in units of mega bits. Common ethernet + // values are 10, 100 and 1000. Unused LinkSpeeds[] entries are zero + // filled. + // + UINT32 LinkSpeeds[4]; + + // + // Number of non-volatile storage items. + // + UINT32 NvCount; + + // + // Width of non-volatile storage item in bytes. 0, 1, 2 or 4 + // + UINT16 NvWidth; + + // + // Media header length. This is the typical media header length for + // this UNDI. This information is needed when allocating receive + // and transmit buffers. + // + UINT16 MediaHeaderLen; + + // + // Number of bytes in the NIC hardware (MAC) address. + // + UINT16 HWaddrLen; + + // + // Maximum number of multicast MAC addresses in the multicast + // MAC address filter list. + // + UINT16 MCastFilterCnt; + + // + // Default number and size of transmit and receive buffers that will + // be allocated by the UNDI. If MemoryRequired is non-zero, this + // allocation will come out of the memory buffer given to the Initialize + // command. If MemoryRequired is zero, this allocation will come out of + // memory on the NIC. + // + UINT16 TxBufCnt; + UINT16 TxBufSize; + UINT16 RxBufCnt; + UINT16 RxBufSize; + + // + // Hardware interface types defined in the Assigned Numbers RFC + // and used in DHCP and ARP packets. + // See the PXE_IFTYPE typedef and PXE_IFTYPE_xxx macros. + // + UINT8 IFtype; + + // + // Supported duplex. See PXE_DUPLEX_xxxxx #defines below. + // + UINT8 Duplex; + + // + // Supported loopback options. See PXE_LOOPBACK_xxxxx #defines below. + // + UINT8 LoopBack; +} PXE_DB_GET_INIT_INFO; + +#define PXE_MAX_TXRX_UNIT_ETHER 1500 + +#define PXE_HWADDR_LEN_ETHER 0x0006 +#define PXE_MAC_HEADER_LEN_ETHER 0x000E + +#define PXE_DUPLEX_ENABLE_FULL_SUPPORTED 1 +#define PXE_DUPLEX_FORCE_FULL_SUPPORTED 2 + +#define PXE_LOOPBACK_INTERNAL_SUPPORTED 1 +#define PXE_LOOPBACK_EXTERNAL_SUPPORTED 2 + +typedef struct s_pxe_pci_config_info { + // + // This is the flag field for the PXE_DB_GET_CONFIG_INFO union. + // For PCI bus devices, this field is set to PXE_BUSTYPE_PCI. + // + UINT32 BusType; + + // + // This identifies the PCI network device that this UNDI interface + // is bound to. + // + UINT16 Bus; + UINT8 Device; + UINT8 Function; + + // + // This is a copy of the PCI configuration space for this + // network device. + // + union { + UINT8 Byte[256]; + UINT16 Word[128]; + UINT32 Dword[64]; + } Config; +} PXE_PCI_CONFIG_INFO; + +typedef struct s_pxe_pcc_config_info { + // + // This is the flag field for the PXE_DB_GET_CONFIG_INFO union. + // For PCC bus devices, this field is set to PXE_BUSTYPE_PCC. + // + UINT32 BusType; + + // + // This identifies the PCC network device that this UNDI interface + // is bound to. + // + UINT16 Bus; + UINT8 Device; + UINT8 Function; + + // + // This is a copy of the PCC configuration space for this + // network device. + // + union { + UINT8 Byte[256]; + UINT16 Word[128]; + UINT32 Dword[64]; + } Config; +} PXE_PCC_CONFIG_INFO; + +typedef struct s_pxe_usb_config_info { + UINT32 BusType; + // + // %%TBD What should we return here... + // +} PXE_USB_CONFIG_INFO; + +typedef struct s_pxe_1394_config_info { + UINT32 BusType; + // + // %%TBD What should we return here... + // +} PXE_1394_CONFIG_INFO; + +typedef union u_pxe_db_get_config_info { + PXE_PCI_CONFIG_INFO pci; + PXE_PCC_CONFIG_INFO pcc; + PXE_USB_CONFIG_INFO usb; + PXE_1394_CONFIG_INFO _1394; +} PXE_DB_GET_CONFIG_INFO; + +typedef struct s_pxe_cpb_initialize { + // + // Address of first (lowest) byte of the memory buffer. This buffer must + // be in contiguous physical memory and cannot be swapped out. The UNDI + // will be using this for transmit and receive buffering. + // + UINT64 MemoryAddr; + + // + // MemoryLength must be greater than or equal to MemoryRequired + // returned by the Get Init Info command. + // + UINT32 MemoryLength; + + // + // Desired link speed in Mbit/sec. Common ethernet values are 10, 100 + // and 1000. Setting a value of zero will auto-detect and/or use the + // default link speed (operation depends on UNDI/NIC functionality). + // + UINT32 LinkSpeed; + + // + // Suggested number and size of receive and transmit buffers to + // allocate. If MemoryAddr and MemoryLength are non-zero, this + // allocation comes out of the supplied memory buffer. If MemoryAddr + // and MemoryLength are zero, this allocation comes out of memory + // on the NIC. + // + // If these fields are set to zero, the UNDI will allocate buffer + // counts and sizes as it sees fit. + // + UINT16 TxBufCnt; + UINT16 TxBufSize; + UINT16 RxBufCnt; + UINT16 RxBufSize; + + // + // The following configuration parameters are optional and must be zero + // to use the default values. + // + UINT8 Duplex; + + UINT8 LoopBack; +} PXE_CPB_INITIALIZE; + +#define PXE_DUPLEX_DEFAULT 0x00 +#define PXE_FORCE_FULL_DUPLEX 0x01 +#define PXE_ENABLE_FULL_DUPLEX 0x02 +#define PXE_FORCE_HALF_DUPLEX 0x04 +#define PXE_DISABLE_FULL_DUPLEX 0x08 + +#define LOOPBACK_NORMAL 0 +#define LOOPBACK_INTERNAL 1 +#define LOOPBACK_EXTERNAL 2 + +typedef struct s_pxe_db_initialize { + // + // Actual amount of memory used from the supplied memory buffer. This + // may be less that the amount of memory suppllied and may be zero if + // the UNDI and network device do not use external memory buffers. + // + // Memory used by the UNDI and network device is allocated from the + // lowest memory buffer address. + // + UINT32 MemoryUsed; + + // + // Actual number and size of receive and transmit buffers that were + // allocated. + // + UINT16 TxBufCnt; + UINT16 TxBufSize; + UINT16 RxBufCnt; + UINT16 RxBufSize; +} PXE_DB_INITIALIZE; + +typedef struct s_pxe_cpb_receive_filters { + // + // List of multicast MAC addresses. This list, if present, will + // replace the existing multicast MAC address filter list. + // + PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT]; +} PXE_CPB_RECEIVE_FILTERS; + +typedef struct s_pxe_db_receive_filters { + // + // Filtered multicast MAC address list. + // + PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT]; +} PXE_DB_RECEIVE_FILTERS; + +typedef struct s_pxe_cpb_station_address { + // + // If supplied and supported, the current station MAC address + // will be changed. + // + PXE_MAC_ADDR StationAddr; +} PXE_CPB_STATION_ADDRESS; + +typedef struct s_pxe_dpb_station_address { + // + // Current station MAC address. + // + PXE_MAC_ADDR StationAddr; + + // + // Station broadcast MAC address. + // + PXE_MAC_ADDR BroadcastAddr; + + // + // Permanent station MAC address. + // + PXE_MAC_ADDR PermanentAddr; +} PXE_DB_STATION_ADDRESS; + +typedef struct s_pxe_db_statistics { + // + // Bit field identifying what statistic data is collected by the + // UNDI/NIC. + // If bit 0x00 is set, Data[0x00] is collected. + // If bit 0x01 is set, Data[0x01] is collected. + // If bit 0x20 is set, Data[0x20] is collected. + // If bit 0x21 is set, Data[0x21] is collected. + // Etc. + // + UINT64 Supported; + + // + // Statistic data. + // + UINT64 Data[64]; +} PXE_DB_STATISTICS; + +// +// Total number of frames received. Includes frames with errors and +// dropped frames. +// +#define PXE_STATISTICS_RX_TOTAL_FRAMES 0x00 + +// +// Number of valid frames received and copied into receive buffers. +// +#define PXE_STATISTICS_RX_GOOD_FRAMES 0x01 + +// +// Number of frames below the minimum length for the media. +// This would be <64 for ethernet. +// +#define PXE_STATISTICS_RX_UNDERSIZE_FRAMES 0x02 + +// +// Number of frames longer than the maxminum length for the +// media. This would be >1500 for ethernet. +// +#define PXE_STATISTICS_RX_OVERSIZE_FRAMES 0x03 + +// +// Valid frames that were dropped because receive buffers were full. +// +#define PXE_STATISTICS_RX_DROPPED_FRAMES 0x04 + +// +// Number of valid unicast frames received and not dropped. +// +#define PXE_STATISTICS_RX_UNICAST_FRAMES 0x05 + +// +// Number of valid broadcast frames received and not dropped. +// +#define PXE_STATISTICS_RX_BROADCAST_FRAMES 0x06 + +// +// Number of valid mutlicast frames received and not dropped. +// +#define PXE_STATISTICS_RX_MULTICAST_FRAMES 0x07 + +// +// Number of frames w/ CRC or alignment errors. +// +#define PXE_STATISTICS_RX_CRC_ERROR_FRAMES 0x08 + +// +// Total number of bytes received. Includes frames with errors +// and dropped frames. +// +#define PXE_STATISTICS_RX_TOTAL_BYTES 0x09 + +// +// Transmit statistics. +// +#define PXE_STATISTICS_TX_TOTAL_FRAMES 0x0A +#define PXE_STATISTICS_TX_GOOD_FRAMES 0x0B +#define PXE_STATISTICS_TX_UNDERSIZE_FRAMES 0x0C +#define PXE_STATISTICS_TX_OVERSIZE_FRAMES 0x0D +#define PXE_STATISTICS_TX_DROPPED_FRAMES 0x0E +#define PXE_STATISTICS_TX_UNICAST_FRAMES 0x0F +#define PXE_STATISTICS_TX_BROADCAST_FRAMES 0x10 +#define PXE_STATISTICS_TX_MULTICAST_FRAMES 0x11 +#define PXE_STATISTICS_TX_CRC_ERROR_FRAMES 0x12 +#define PXE_STATISTICS_TX_TOTAL_BYTES 0x13 + +// +// Number of collisions detection on this subnet. +// +#define PXE_STATISTICS_COLLISIONS 0x14 + +// +// Number of frames destined for unsupported protocol. +// +#define PXE_STATISTICS_UNSUPPORTED_PROTOCOL 0x15 + +typedef struct s_pxe_cpb_mcast_ip_to_mac { + // + // Multicast IP address to be converted to multicast MAC address. + // + PXE_IP_ADDR IP; +} PXE_CPB_MCAST_IP_TO_MAC; + +typedef struct s_pxe_db_mcast_ip_to_mac { + // + // Multicast MAC address. + // + PXE_MAC_ADDR MAC; +} PXE_DB_MCAST_IP_TO_MAC; + +typedef struct s_pxe_cpb_nvdata_sparse { + // + // NvData item list. Only items in this list will be updated. + // + struct { + // + // Non-volatile storage address to be changed. + // + UINT32 Addr; + + // + // Data item to write into above storage address. + // + union { + UINT8 Byte; + UINT16 Word; + UINT32 Dword; + } Data; + } Item[MAX_EEPROM_LEN]; +} +PXE_CPB_NVDATA_SPARSE; + +// +// When using bulk update, the size of the CPB structure must be +// the same size as the non-volatile NIC storage. +// +typedef union u_pxe_cpb_nvdata_bulk { + // + // Array of byte-wide data items. + // + UINT8 Byte[MAX_EEPROM_LEN << 2]; + + // + // Array of word-wide data items. + // + UINT16 Word[MAX_EEPROM_LEN << 1]; + + // + // Array of dword-wide data items. + // + UINT32 Dword[MAX_EEPROM_LEN]; +} PXE_CPB_NVDATA_BULK; + +typedef struct s_pxe_db_nvdata { + // + // Arrays of data items from non-volatile storage. + // + union { + // + // Array of byte-wide data items. + // + UINT8 Byte[MAX_EEPROM_LEN << 2]; + + // + // Array of word-wide data items. + // + UINT16 Word[MAX_EEPROM_LEN << 1]; + + // + // Array of dword-wide data items. + // + UINT32 Dword[MAX_EEPROM_LEN]; + } Data; +} PXE_DB_NVDATA; + +typedef struct s_pxe_db_get_status { + // + // Length of next receive frame (header + data). If this is zero, + // there is no next receive frame available. + // + UINT32 RxFrameLen; + + // + // Reserved, set to zero. + // + UINT32 reserved; + + // + // Addresses of transmitted buffers that need to be recycled. + // + UINT64 TxBuffer[MAX_XMIT_BUFFERS]; +} PXE_DB_GET_STATUS; + +typedef struct s_pxe_cpb_fill_header { + // + // Source and destination MAC addresses. These will be copied into + // the media header without doing byte swapping. + // + PXE_MAC_ADDR SrcAddr; + PXE_MAC_ADDR DestAddr; + + // + // Address of first byte of media header. The first byte of packet data + // follows the last byte of the media header. + // + UINT64 MediaHeader; + + // + // Length of packet data in bytes (not including the media header). + // + UINT32 PacketLen; + + // + // Protocol type. This will be copied into the media header without + // doing byte swapping. Protocol type numbers can be obtained from + // the Assigned Numbers RFC 1700. + // + UINT16 Protocol; + + // + // Length of the media header in bytes. + // + UINT16 MediaHeaderLen; +} PXE_CPB_FILL_HEADER; + +#define PXE_PROTOCOL_ETHERNET_IP 0x0800 +#define PXE_PROTOCOL_ETHERNET_ARP 0x0806 +#define MAX_XMIT_FRAGMENTS 16 + +typedef struct s_pxe_cpb_fill_header_fragmented { + // + // Source and destination MAC addresses. These will be copied into + // the media header without doing byte swapping. + // + PXE_MAC_ADDR SrcAddr; + PXE_MAC_ADDR DestAddr; + + // + // Length of packet data in bytes (not including the media header). + // + UINT32 PacketLen; + + // + // Protocol type. This will be copied into the media header without + // doing byte swapping. Protocol type numbers can be obtained from + // the Assigned Numbers RFC 1700. + // + PXE_MEDIA_PROTOCOL Protocol; + + // + // Length of the media header in bytes. + // + UINT16 MediaHeaderLen; + + // + // Number of packet fragment descriptors. + // + UINT16 FragCnt; + + // + // Reserved, must be set to zero. + // + UINT16 reserved; + + // + // Array of packet fragment descriptors. The first byte of the media + // header is the first byte of the first fragment. + // + struct { + // + // Address of this packet fragment. + // + UINT64 FragAddr; + + // + // Length of this packet fragment. + // + UINT32 FragLen; + + // + // Reserved, must be set to zero. + // + UINT32 reserved; + } FragDesc[MAX_XMIT_FRAGMENTS]; +} +PXE_CPB_FILL_HEADER_FRAGMENTED; + +typedef struct s_pxe_cpb_transmit { + // + // Address of first byte of frame buffer. This is also the first byte + // of the media header. + // + UINT64 FrameAddr; + + // + // Length of the data portion of the frame buffer in bytes. Do not + // include the length of the media header. + // + UINT32 DataLen; + + // + // Length of the media header in bytes. + // + UINT16 MediaheaderLen; + + // + // Reserved, must be zero. + // + UINT16 reserved; +} PXE_CPB_TRANSMIT; + +typedef struct s_pxe_cpb_transmit_fragments { + // + // Length of packet data in bytes (not including the media header). + // + UINT32 FrameLen; + + // + // Length of the media header in bytes. + // + UINT16 MediaheaderLen; + + // + // Number of packet fragment descriptors. + // + UINT16 FragCnt; + + // + // Array of frame fragment descriptors. The first byte of the first + // fragment is also the first byte of the media header. + // + struct { + // + // Address of this frame fragment. + // + UINT64 FragAddr; + + // + // Length of this frame fragment. + // + UINT32 FragLen; + + // + // Reserved, must be set to zero. + // + UINT32 reserved; + } FragDesc[MAX_XMIT_FRAGMENTS]; +} +PXE_CPB_TRANSMIT_FRAGMENTS; + +typedef struct s_pxe_cpb_receive { + // + // Address of first byte of receive buffer. This is also the first byte + // of the frame header. + // + UINT64 BufferAddr; + + // + // Length of receive buffer. This must be large enough to hold the + // received frame (media header + data). If the length of smaller than + // the received frame, data will be lost. + // + UINT32 BufferLen; + + // + // Reserved, must be set to zero. + // + UINT32 reserved; +} PXE_CPB_RECEIVE; + +typedef struct s_pxe_db_receive { + // + // Source and destination MAC addresses from media header. + // + PXE_MAC_ADDR SrcAddr; + PXE_MAC_ADDR DestAddr; + + // + // Length of received frame. May be larger than receive buffer size. + // The receive buffer will not be overwritten. This is how to tell + // if data was lost because the receive buffer was too small. + // + UINT32 FrameLen; + + // + // Protocol type from media header. + // + PXE_MEDIA_PROTOCOL Protocol; + + // + // Length of media header in received frame. + // + UINT16 MediaHeaderLen; + + // + // Type of receive frame. + // + PXE_FRAME_TYPE Type; + + // + // Reserved, must be zero. + // + UINT8 reserved[7]; + +} PXE_DB_RECEIVE; + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h b/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h new file mode 100644 index 0000000000..633c595db0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiSpec.h + +Abstract: + + EFI master include file. + + This is the main include file for EFI components. There should be + no defines or macros added to this file, other than the EFI version + information already in this file. + + Don't add include files to the list for convenience, only add things + that are architectural. Don't add Protocols or GUID include files here + +--*/ + +#ifndef _EFI_SPEC_H_ +#define _EFI_SPEC_H_ + +#include "EfiCommon.h" +#include "EfiApi.h" +#include "EfiDevicePath.h" + +// +// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined. +// +#if !defined(EFI_SPECIFICATION_VERSION) + #error EFI_SPECIFICATION_VERSION not defined +#elif !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif (TIANO_RELEASE_VERSION == 0) +// +// UEFI mode with no Tiano extensions is legal +// +#elif ((TIANO_RELEASE_VERSION < 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000)) + #error Illegal combination of EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION versions +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h b/EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h new file mode 100644 index 0000000000..d125cedac7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiStdArg.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiStdArg.h + +Abstract: + + Support for variable length argument lists using the ANSI standard. + + Since we are using the ANSI standard we used the standard nameing and + did not folow the coding convention + + VA_LIST - typedef for argument list. + VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use. + VA_END (VA_LIST Marker) - Clear Marker + VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from + the ... list. You must know the size and pass it in this macro. + + example: + + UINTN + ExampleVarArg ( + IN UINTN NumberOfArgs, + ... + ) + { + VA_LIST Marker; + UINTN Index; + UINTN Result; + + // + // Initialize the Marker + // + VA_START (Marker, NumberOfArgs); + for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) { + // + // The ... list is a series of UINTN values, so average them up. + // + Result += VA_ARG (Marker, UINTN); + } + + VA_END (Marker); + return Result + } + +--*/ + +#ifndef _EFISTDARG_H_ +#define _EFISTDARG_H_ + +#define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1)) + +// +// Also support coding convention rules for var arg macros +// +#ifndef VA_START + +typedef CHAR8 *VA_LIST; +#define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v)) +#define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t))) +#define VA_END(ap) (ap = (VA_LIST) 0) + +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h b/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h new file mode 100644 index 0000000000..67379aa42d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiTpm.h + +Abstract: + + EFI definition according to TCG_EFI_Platform_1_20_Final + + See http://trustedcomputinggroup.org for latest specification updates + +--*/ + +#ifndef _EFI_TPM_H_ +#define _EFI_TPM_H_ + +#include + +// +// The start of TPM return codes +// +#define TPM_BASE (EFI_MAX_BIT + (EFI_MAX_BIT >> 1)) +#include + +// +// Standard event types +// +#define EV_POST_CODE ((TCG_EVENTTYPE) 0x00000001) +#define EV_SEPARATOR ((TCG_EVENTTYPE) 0x00000004) +#define EV_S_CRTM_CONTENTS ((TCG_EVENTTYPE) 0x00000007) +#define EV_S_CRTM_VERSION ((TCG_EVENTTYPE) 0x00000008) + +// +// EFI specific event types +// +#define EV_EFI_EVENT_BASE ((TCG_EVENTTYPE) 0x80000000) +#define EV_EFI_VARIABLE_DRIVER_CONFIG (EV_EFI_EVENT_BASE + 1) +#define EV_EFI_VARIABLE_BOOT (EV_EFI_EVENT_BASE + 2) +#define EV_EFI_BOOT_SERVICES_APPLICATION (EV_EFI_EVENT_BASE + 3) +#define EV_EFI_BOOT_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 4) +#define EV_EFI_RUNTIME_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 5) +#define EV_EFI_GPT_EVENT (EV_EFI_EVENT_BASE + 6) +#define EV_EFI_ACTION (EV_EFI_EVENT_BASE + 7) +#define EV_EFI_PLATFORM_FIRMWARE_BLOB (EV_EFI_EVENT_BASE + 8) +#define EV_EFI_HANDOFF_TABLES (EV_EFI_EVENT_BASE + 9) + +// +// Set structure alignment to 1-byte +// +#pragma pack (push, 1) + +typedef UINT32 TCG_EVENTTYPE; + +#define TCG_DIGEST TPM_DIGEST +#define TCG_PCRINDEX TPM_PCRINDEX + +// +// TCG_PCR_EVENT +// +typedef struct tdTCG_PCR_EVENT { + TCG_PCRINDEX PCRIndex; // PCRIndex event extended to + TCG_EVENTTYPE EventType; // TCG EFI event type + TCG_DIGEST Digest; // Value extended into PCRIndex + UINT32 EventSize; // Size of the event data + UINT8 Event[1]; // The event data +} TCG_PCR_EVENT; + +// +// TCG_PCR_EVENT_HDR +// +typedef struct tdTCG_PCR_EVENT_HDR { + TCG_PCRINDEX PCRIndex; + TCG_EVENTTYPE EventType; + TCG_DIGEST Digest; + UINT32 EventSize; +} TCG_PCR_EVENT_HDR; + +// +// EFI_PLATFORM_FIRMWARE_BLOB +// +// BlobLength should be of type UINTN but we use UINT64 here +// because PEI is 32-bit while DXE is 64-bit on x64 platforms +// +typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB { + EFI_PHYSICAL_ADDRESS BlobBase; + UINT64 BlobLength; +} EFI_PLATFORM_FIRMWARE_BLOB; + +// +// EFI_IMAGE_LOAD_EVENT +// +// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION, +// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER +// +typedef struct tdEFI_IMAGE_LOAD_EVENT { + EFI_PHYSICAL_ADDRESS ImageLocationInMemory; + UINTN ImageLengthInMemory; + UINTN ImageLinkTimeAddress; + UINTN LengthOfDevicePath; + EFI_DEVICE_PATH_PROTOCOL DevicePath[1]; +} EFI_IMAGE_LOAD_EVENT; + +// +// EFI_HANDOFF_TABLE_POINTERS +// +// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate +// the measurement of given configuration tables. +// +typedef struct tdEFI_HANDOFF_TABLE_POINTERS { + UINTN NumberOfTables; + EFI_CONFIGURATION_TABLE TableEntry[1]; +} EFI_HANDOFF_TABLE_POINTERS; + +// +// EFI_VARIABLE_DATA +// +// This structure serves as the header for measuring variables. The name of the +// variable (in Unicode format) should immediately follow, then the variable +// data. +// +typedef struct tdEFI_VARIABLE_DATA { + EFI_GUID VariableName; + UINTN UnicodeNameLength; + UINTN VariableDataLength; + CHAR16 UnicodeName[1]; + INT8 VariableData[1]; // Driver or platform-specific data +} EFI_VARIABLE_DATA; + +// +// Restore original structure alignment +// +#pragma pack (pop) + +#endif // _EFI_TPM_H_ diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiVariable.h b/EdkCompatibilityPkg/Foundation/Include/EfiVariable.h new file mode 100644 index 0000000000..b2a96f4a48 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiVariable.h @@ -0,0 +1,85 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiVariable.h + +Abstract: + + Header file for EFI Variable Services + +--*/ + +#ifndef _EFI_VARIABLE_H_ +#define _EFI_VARIABLE_H_ + +#define VARIABLE_STORE_SIGNATURE EFI_SIGNATURE_32 ('$', 'V', 'S', 'S') + +#define MAX_VARIABLE_SIZE 1024 + +// +// Enlarges the hardware error record maximum variable size to 32K bytes +// +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#define MAX_HARDWARE_ERROR_VARIABLE_SIZE 0x8000 +#endif + +#define VARIABLE_DATA 0x55AA + +// +// Variable Store Header flags +// +#define VARIABLE_STORE_FORMATTED 0x5a +#define VARIABLE_STORE_HEALTHY 0xfe + +// +// Variable Store Status +// +typedef enum { + EfiRaw, + EfiValid, + EfiInvalid, + EfiUnknown +} VARIABLE_STORE_STATUS; + +// +// Variable State flags +// +#define VAR_IN_DELETED_TRANSITION 0xfe // Variable is in obsolete transistion +#define VAR_DELETED 0xfd // Variable is obsolete +#define VAR_ADDED 0x7f // Variable has been completely added +#define IS_VARIABLE_STATE(_c, _Mask) (BOOLEAN) (((~_c) & (~_Mask)) != 0) + +#pragma pack(1) + +typedef struct { + UINT32 Signature; + UINT32 Size; + UINT8 Format; + UINT8 State; + UINT16 Reserved; + UINT32 Reserved1; +} VARIABLE_STORE_HEADER; + +typedef struct { + UINT16 StartId; + UINT8 State; + UINT8 Reserved; + UINT32 Attributes; + UINT32 NameSize; + UINT32 DataSize; + EFI_GUID VendorGuid; +} VARIABLE_HEADER; + +#pragma pack() + +#endif // _EFI_VARIABLE_H_ diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiWorkingBlockHeader.h b/EdkCompatibilityPkg/Foundation/Include/EfiWorkingBlockHeader.h new file mode 100644 index 0000000000..a67d041218 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/EfiWorkingBlockHeader.h @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiWorkingBlockHeader.h + +Abstract: + + Defines data structure that is the headers found at the runtime + updatable firmware volumes, such as the FileSystemGuid of the + working block, the header structure of the variable block, FTW + working block, or event log block. + +--*/ + +#ifndef _EFI_WORKING_BLOCK_HEADER_H_ +#define _EFI_WORKING_BLOCK_HEADER_H_ + +// +// EFI Fault tolerant working block header +// The header is immediately followed by the write queue. +// +typedef struct { + EFI_GUID Signature; + UINT32 Crc; + UINT8 WorkingBlockValid : 1; + UINT8 WorkingBlockInvalid : 1; +#define WORKING_BLOCK_VALID 0x1 +#define WORKING_BLOCK_INVALID 0x2 + UINT8 Reserved : 6; + UINT8 Reserved3[3]; + UINT64 WriteQueueSize; + // + // UINT8 WriteQueue[WriteQueueSize]; + // +} EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h new file mode 100644 index 0000000000..ae60a28e27 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiBind.h @@ -0,0 +1,269 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiBind.h + +Abstract: + + Processor or Compiler specific defines and types for IA-32. + We are using the ANSI C 2000 _t type definitions for basic types. + This it technically a violation of the coding standard, but they + are used to make EfiTypes.h portable. Code other than EfiTypes.h + should never use any ANSI C 2000 _t integer types. + +--*/ + +#ifndef _EFI_BIND_H_ +#define _EFI_BIND_H_ + +#ifdef EFI_DEBUG + +#ifdef EFI_NT_EMULATOR + +#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ + EFI_STATUS \ + EFIAPI \ + InitFunction ( \ + EFI_HANDLE ImageHandle, \ + EFI_SYSTEM_TABLE *SystemTable \ + ); \ + \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + VOID *ImageHandle, \ + VOID *SystemTable \ + ) \ + { \ + return InitFunction(ImageHandle, SystemTable); \ + } + +#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT + +#else + +#define EFI_DRIVER_ENTRY_POINT(InitFunction) +#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT + +#endif + +#else + +#define EFI_DRIVER_ENTRY_POINT(InitFunction) +#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT + +#endif + + + + + +// +// Make sure we are useing the correct packing rules per EFI specification +// +#pragma pack() + +#if _MSC_EXTENSIONS + +// +// Disable warning that make it impossible to compile at /W4 +// This only works for Microsoft* tools +// + +// +// Disabling bitfield type checking warnings. +// +#pragma warning ( disable : 4214 ) + +// +// Disabling the unreferenced formal parameter warnings. +// +#pragma warning ( disable : 4100 ) + +// +// Disable slightly different base types warning as CHAR8 * can not be set +// to a constant string. +// +#pragma warning ( disable : 4057 ) + +// +// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning +// +#pragma warning ( disable : 4127 ) + +// +// Int64ShllMod32 unreferenced inline function +// +#pragma warning ( disable : 4514 ) + +// +// Unreferenced formal parameter - We are object oriented, so we pass This even +// if we don't need them. +// +#pragma warning ( disable : 4100 ) + +// +// This warning is caused by empty (after preprocessing) souce file. +// +#pragma warning ( disable : 4206 ) + + +#endif + + +#if (__STDC_VERSION__ < 199901L) + // + // No ANSI C 2000 stdint.h integer width declarations, so define equivalents + // + + #if _MSC_EXTENSIONS + + // + // use Microsoft* C complier dependent interger width types + // + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; + typedef unsigned __int32 uint32_t; + typedef __int32 int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + + // + // Assume standard IA-32 alignment. + // BugBug: Need to check portability of long long + // + typedef unsigned long long uint64_t; + typedef long long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #endif +#else + // + // Use ANSI C 2000 stdint.h integer width declarations + // + #include "stdint.h" +#endif + +// +// Native integer size in stdint.h +// +typedef uint32_t uintn_t; +typedef int32_t intn_t; + +// +// Processor specific defines +// +#define EFI_MAX_BIT 0x80000000 +#define MAX_2_BITS 0xC0000000 + +// +// Maximum legal IA-32 address +// +#define EFI_MAX_ADDRESS 0xFFFFFFFF + +// +// Bad pointer value to use in check builds. +// if you see this value you are using uninitialized or free'ed data +// +#define EFI_BAD_POINTER 0xAFAFAFAF +#define EFI_BAD_POINTER_AS_BYTE 0xAF + +// +// Inject a break point in the code to assist debugging for NT Emulation Environment +// For real hardware, just put in a halt loop. Don't do a while(1) because the +// compiler will optimize away the rest of the function following, so that you run out in +// the weeds if you skip over it with a debugger. +// +#define EFI_BREAKPOINT() __asm { int 3 } +#define EFI_DEADLOOP() { volatile UINTN __iii; __iii = 1; while (__iii); } + +// +// Memory Fence forces serialization, and is needed to support out of order +// memory transactions. The Memory Fence is mainly used to make sure IO +// transactions complete in a deterministic sequence, and to syncronize locks +// an other MP code. Currently no memory fencing is required. +// +#define MEMORY_FENCE() + +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX. The forward reference is required for +// ANSI compatibility. +// +// The following macro provide a workaround for such cases. +// + + +#ifdef EFI_NO_INTERFACE_DECL + #define EFI_FORWARD_DECLARATION(x) +#else + #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x +#endif + + +// +// Some C compilers optimize the calling conventions to increase performance. +// _EFIAPI is used to make all public APIs follow the standard C calling +// convention. +// +#if _MSC_EXTENSIONS + // + // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C. + // + + #define _EFIAPI __cdecl +#else + #define _EFIAPI +#endif + + +#ifdef _EFI_WINNT + + #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( disable : 4142 ) + + #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( default : 4142 ) +#else + + #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( disable : 4068 ) + + #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( default : 4068 ) + +#endif + + + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiPeOptionalHeader.h new file mode 100644 index 0000000000..549d9f4fc4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ia32/EfiPeOptionalHeader.h @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPeOptionalHeader.h + +Abstract: + Defines the optional header in the PE image per the PE specification. This + file must be included only from within EfiImage.h since + EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined + there. + +--*/ + +#ifndef _EFI_PE_OPTIONAL_HEADER_H_ +#define _EFI_PE_OPTIONAL_HEADER_H_ + +#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_IA32) + +#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ + (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC)) + +#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64) + +#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC +typedef EFI_IMAGE_OPTIONAL_HEADER32 EFI_IMAGE_OPTIONAL_HEADER; +typedef EFI_IMAGE_NT_HEADERS32 EFI_IMAGE_NT_HEADERS; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ia32/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/Ia32/TianoBind.h new file mode 100644 index 0000000000..edf599a27f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ia32/TianoBind.h @@ -0,0 +1,102 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoBind.h + +Abstract: + + Tiano's Processor or Compiler specific defines and types for IA-32 + besides EfiBind.h. + +--*/ + +#ifndef _TIANO_BIND_H_ +#define _TIANO_BIND_H_ + +#include "EfiBind.h" + +#ifdef EFI_DEBUG + +#ifdef EFI_NT_EMULATOR + +#define EFI_DXE_ENTRY_POINT(InitFunction) \ + VOID \ + EFIAPI \ + InitFunction ( \ + IN VOID *HobStart \ + ); \ + \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + VOID \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + VOID *Hob \ + ) \ + { \ + InitFunction(Hob); \ + } + + + + +#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction) \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + VOID *ImageHandle, \ + VOID *Smst, \ + VOID *CommunicationBuffer, \ + UINTN *SourceSize \ + ) \ + { \ + return InitFunction(ImageHandle, Smst, CommunicationBuffer, SourceSize); \ + } + +#else + +#define EFI_DXE_ENTRY_POINT(InitFunction) +#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction) + +#endif + +#else + +#define EFI_DXE_ENTRY_POINT(InitFunction) +#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction) + +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi.h new file mode 100644 index 0000000000..6a7246f72e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi.h @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Acpi.h + +Abstract: + + This file contains some basic ACPI definitions that are consumed by drivers + that do not care about ACPI versions. + +--*/ + +#ifndef _ACPI_H_ +#define _ACPI_H_ + +#include "AcpiCommon.h" +#include "Acpi1_0.h" +#include "Acpi2_0.h" +#include "Acpi3_0.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi1_0.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi1_0.h new file mode 100644 index 0000000000..84c4147cc6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi1_0.h @@ -0,0 +1,299 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Acpi1_0.h + +Abstract: + + ACPI 1.0b definitions from the ACPI Specification, revision 1.0b + +--*/ + +#ifndef _ACPI_1_0_H_ +#define _ACPI_1_0_H_ + +// +// Statements that include other files +// +#include "AcpiCommon.h" + +// +// Ensure proper structure formats +// +#pragma pack(1) +// +// ACPI 1.0b table structures +// +// +// Root System Description Pointer Structure +// +typedef struct { + UINT64 Signature; + UINT8 Checksum; + UINT8 OemId[6]; + UINT8 Reserved; + UINT32 RsdtAddress; +} EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER; + +// +// Root System Description Table +// No definition needed as it is a common description table header followed by a +// variable number of UINT32 table pointers. +// +// +// RSDT Revision (as defined in ACPI 1.0b spec.) +// +#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Fixed ACPI Description Table Structure (FADT) +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 FirmwareCtrl; + UINT32 Dsdt; + UINT8 IntModel; + UINT8 Reserved1; + UINT16 SciInt; + UINT32 SmiCmd; + UINT8 AcpiEnable; + UINT8 AcpiDisable; + UINT8 S4BiosReq; + UINT8 Reserved2; + UINT32 Pm1aEvtBlk; + UINT32 Pm1bEvtBlk; + UINT32 Pm1aCntBlk; + UINT32 Pm1bCntBlk; + UINT32 Pm2CntBlk; + UINT32 PmTmrBlk; + UINT32 Gpe0Blk; + UINT32 Gpe1Blk; + UINT8 Pm1EvtLen; + UINT8 Pm1CntLen; + UINT8 Pm2CntLen; + UINT8 PmTmLen; + UINT8 Gpe0BlkLen; + UINT8 Gpe1BlkLen; + UINT8 Gpe1Base; + UINT8 Reserved3; + UINT16 PLvl2Lat; + UINT16 PLvl3Lat; + UINT16 FlushSize; + UINT16 FlushStride; + UINT8 DutyOffset; + UINT8 DutyWidth; + UINT8 DayAlrm; + UINT8 MonAlrm; + UINT8 Century; + UINT8 Reserved4; + UINT8 Reserved5; + UINT8 Reserved6; + UINT32 Flags; +} EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE; + +// +// FADT Version (as defined in ACPI 1.0b spec.) +// +#define EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Fixed ACPI Description Table Fixed Feature Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_1_0_WBINVD (1 << 0) +#define EFI_ACPI_1_0_WBINVD_FLUSH (1 << 1) +#define EFI_ACPI_1_0_PROC_C1 (1 << 2) +#define EFI_ACPI_1_0_P_LVL2_UP (1 << 3) +#define EFI_ACPI_1_0_PWR_BUTTON (1 << 4) +#define EFI_ACPI_1_0_SLP_BUTTON (1 << 5) +#define EFI_ACPI_1_0_FIX_RTC (1 << 6) +#define EFI_ACPI_1_0_RTC_S4 (1 << 7) +#define EFI_ACPI_1_0_TMR_VAL_EXT (1 << 8) +#define EFI_ACPI_1_0_DCK_CAP (1 << 9) + +// +// Firmware ACPI Control Structure +// +typedef struct { + UINT32 Signature; + UINT32 Length; + UINT32 HardwareSignature; + UINT32 FirmwareWakingVector; + UINT32 GlobalLock; + UINT32 Flags; + UINT8 Reserved[40]; +} EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE; + +// +// Firmware Control Structure Feature Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_1_0_S4BIOS_F (1 << 0) + +// +// Multiple APIC Description Table header definition. The rest of the table +// must be defined in a platform specific manner. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 LocalApicAddress; + UINT32 Flags; +} EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER; + +// +// MADT Revision (as defined in ACPI 1.0b spec.) +// +#define EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Multiple APIC Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_1_0_PCAT_COMPAT (1 << 0) + +// +// Multiple APIC Description Table APIC structure types +// All other values between 0x09 an 0xFF are reserved and +// will be ignored by OSPM. +// +#define EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC 0x00 +#define EFI_ACPI_1_0_IO_APIC 0x01 +#define EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE 0x02 +#define EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE 0x03 +#define EFI_ACPI_1_0_LOCAL_APIC_NMI 0x04 + +// +// APIC Structure Definitions +// +// +// Processor Local APIC Structure Definition +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT8 ApicId; + UINT32 Flags; +} EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE; + +// +// Local APIC Flags. All other bits are reserved and must be 0. +// +#define EFI_ACPI_1_0_LOCAL_APIC_ENABLED (1 << 0) + +// +// IO APIC Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 IoApicId; + UINT8 Reserved; + UINT32 IoApicAddress; + UINT32 SystemVectorBase; +} EFI_ACPI_1_0_IO_APIC_STRUCTURE; + +// +// Interrupt Source Override Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 Bus; + UINT8 Source; + UINT32 GlobalSystemInterruptVector; + UINT16 Flags; +} EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE; + +// +// Non-Maskable Interrupt Source Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Flags; + UINT32 GlobalSystemInterruptVector; +} EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE; + +// +// Local APIC NMI Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT16 Flags; + UINT8 LocalApicInti; +} EFI_ACPI_1_0_LOCAL_APIC_NMI_STRUCTURE; + +// +// Smart Battery Description Table (SBST) +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 WarningEnergyLevel; + UINT32 LowEnergyLevel; + UINT32 CriticalEnergyLevel; +} EFI_ACPI_1_0_SMART_BATTERY_DESCRIPTION_TABLE; + +// +// Known table signatures +// +// +// "RSD PTR " Root System Description Pointer +// +#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE 0x2052545020445352 + +// +// "APIC" Multiple APIC Description Table +// +#define EFI_ACPI_1_0_APIC_SIGNATURE 0x43495041 + +// +// "DSDT" Differentiated System Description Table +// +#define EFI_ACPI_1_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445344 + +// +// "FACS" Firmware ACPI Control Structure +// +#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE 0x53434146 + +// +// "FACP" Fixed ACPI Description Table +// +#define EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146 + +// +// "PSDT" Persistent System Description Table +// +#define EFI_ACPI_1_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445350 + +// +// "RSDT" Root System Description Table +// +#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445352 + +// +// "SBST" Smart Battery Specification Table +// +#define EFI_ACPI_1_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE 0x54534253 + +// +// "SSDT" Secondary System Description Table +// +#define EFI_ACPI_1_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353 + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi2_0.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi2_0.h new file mode 100644 index 0000000000..60c2e40e5c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi2_0.h @@ -0,0 +1,513 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Acpi2_0.h + +Abstract: + + ACPI 2.0 definitions from the ACPI Specification, revision 2.0 + +--*/ + +#ifndef _ACPI_2_0_H_ +#define _ACPI_2_0_H_ + +// +// Statements that include other files +// +#include "AcpiCommon.h" + +// +// Ensure proper structure formats +// +#pragma pack(1) +// +// ACPI Specification Revision +// +#define EFI_ACPI_2_0_REVISION 0x02 + +// +// ACPI 2.0 Generic Address Space definition +// +typedef struct { + UINT8 AddressSpaceId; + UINT8 RegisterBitWidth; + UINT8 RegisterBitOffset; + UINT8 Reserved; + UINT64 Address; +} EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE; + +// +// Generic Address Space Address IDs +// +#define EFI_ACPI_2_0_SYSTEM_MEMORY 0 +#define EFI_ACPI_2_0_SYSTEM_IO 1 +#define EFI_ACPI_2_0_PCI_CONFIGURATION_SPACE 2 +#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER 3 +#define EFI_ACPI_2_0_SMBUS 4 +#define EFI_ACPI_2_0_FUNCTIONAL_FIXED_HARDWARE 0x7F + +// +// ACPI 2.0 table structures +// +// +// Root System Description Pointer Structure +// +typedef struct { + UINT64 Signature; + UINT8 Checksum; + UINT8 OemId[6]; + UINT8 Revision; + UINT32 RsdtAddress; + UINT32 Length; + UINT64 XsdtAddress; + UINT8 ExtendedChecksum; + UINT8 Reserved[3]; +} EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER; + +// +// RSD_PTR Revision (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION 0x02 + +// +// Common table header, this prefaces all ACPI tables, including FACS, but +// excluding the RSD PTR structure +// +typedef struct { + UINT32 Signature; + UINT32 Length; +} EFI_ACPI_2_0_COMMON_HEADER; + +// +// Root System Description Table +// No definition needed as it is a common description table header followed by a +// variable number of UINT32 table pointers. +// +// +// RSDT Revision (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Extended System Description Table +// No definition needed as it is a common description table header followed by a +// variable number of UINT64 table pointers. +// +// +// XSDT Revision (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Fixed ACPI Description Table Structure (FADT) +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 FirmwareCtrl; + UINT32 Dsdt; + UINT8 Reserved0; + UINT8 PreferredPmProfile; + UINT16 SciInt; + UINT32 SmiCmd; + UINT8 AcpiEnable; + UINT8 AcpiDisable; + UINT8 S4BiosReq; + UINT8 PstateCnt; + UINT32 Pm1aEvtBlk; + UINT32 Pm1bEvtBlk; + UINT32 Pm1aCntBlk; + UINT32 Pm1bCntBlk; + UINT32 Pm2CntBlk; + UINT32 PmTmrBlk; + UINT32 Gpe0Blk; + UINT32 Gpe1Blk; + UINT8 Pm1EvtLen; + UINT8 Pm1CntLen; + UINT8 Pm2CntLen; + UINT8 PmTmrLen; + UINT8 Gpe0BlkLen; + UINT8 Gpe1BlkLen; + UINT8 Gpe1Base; + UINT8 CstCnt; + UINT16 PLvl2Lat; + UINT16 PLvl3Lat; + UINT16 FlushSize; + UINT16 FlushStride; + UINT8 DutyOffset; + UINT8 DutyWidth; + UINT8 DayAlrm; + UINT8 MonAlrm; + UINT8 Century; + UINT16 IaPcBootArch; + UINT8 Reserved1; + UINT32 Flags; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE ResetReg; + UINT8 ResetValue; + UINT8 Reserved2[3]; + UINT64 XFirmwareCtrl; + UINT64 XDsdt; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XGpe0Blk; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XGpe1Blk; +} EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE; + +// +// FADT Version (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION 0x03 + +// +// Fixed ACPI Description Table Boot Architecture Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_2_0_LEGACY_DEVICES (1 << 0) +#define EFI_ACPI_2_0_8042 (1 << 1) + +// +// Fixed ACPI Description Table Fixed Feature Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_2_0_WBINVD (1 << 0) +#define EFI_ACPI_2_0_WBINVD_FLUSH (1 << 1) +#define EFI_ACPI_2_0_PROC_C1 (1 << 2) +#define EFI_ACPI_2_0_P_LVL2_UP (1 << 3) +#define EFI_ACPI_2_0_PWR_BUTTON (1 << 4) +#define EFI_ACPI_2_0_SLP_BUTTON (1 << 5) +#define EFI_ACPI_2_0_FIX_RTC (1 << 6) +#define EFI_ACPI_2_0_RTC_S4 (1 << 7) +#define EFI_ACPI_2_0_TMR_VAL_EXT (1 << 8) +#define EFI_ACPI_2_0_DCK_CAP (1 << 9) +#define EFI_ACPI_2_0_RESET_REG_SUP (1 << 10) +#define EFI_ACPI_2_0_SEALED_CASE (1 << 11) +#define EFI_ACPI_2_0_HEADLESS (1 << 12) +#define EFI_ACPI_2_0_CPU_SW_SLP (1 << 13) + +// +// Firmware ACPI Control Structure +// +typedef struct { + UINT32 Signature; + UINT32 Length; + UINT32 HardwareSignature; + UINT32 FirmwareWakingVector; + UINT32 GlobalLock; + UINT32 Flags; + UINT64 XFirmwareWakingVector; + UINT8 Version; + UINT8 Reserved[31]; +} EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE; + +// +// FACS Version (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x01 + +// +// Firmware Control Structure Feature Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_2_0_S4BIOS_F (1 << 0) + +// +// Multiple APIC Description Table header definition. The rest of the table +// must be defined in a platform specific manner. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 LocalApicAddress; + UINT32 Flags; +} EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER; + +// +// MADT Revision (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Multiple APIC Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_2_0_PCAT_COMPAT (1 << 0) + +// +// Multiple APIC Description Table APIC structure types +// All other values between 0x09 an 0xFF are reserved and +// will be ignored by OSPM. +// +#define EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC 0x00 +#define EFI_ACPI_2_0_IO_APIC 0x01 +#define EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE 0x02 +#define EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE 0x03 +#define EFI_ACPI_2_0_LOCAL_APIC_NMI 0x04 +#define EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE 0x05 +#define EFI_ACPI_2_0_IO_SAPIC 0x06 +#define EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC 0x07 +#define EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES 0x08 + +// +// APIC Structure Definitions +// +// +// Processor Local APIC Structure Definition +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT8 ApicId; + UINT32 Flags; +} EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC_STRUCTURE; + +// +// Local APIC Flags. All other bits are reserved and must be 0. +// +#define EFI_ACPI_2_0_LOCAL_APIC_ENABLED (1 << 0) + +// +// IO APIC Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 IoApicId; + UINT8 Reserved; + UINT32 IoApicAddress; + UINT32 GlobalSystemInterruptBase; +} EFI_ACPI_2_0_IO_APIC_STRUCTURE; + +// +// Interrupt Source Override Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 Bus; + UINT8 Source; + UINT32 GlobalSystemInterrupt; + UINT16 Flags; +} EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE; + +// +// Non-Maskable Interrupt Source Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Flags; + UINT32 GlobalSystemInterrupt; +} EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE; + +// +// Local APIC NMI Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT16 Flags; + UINT8 LocalApicLint; +} EFI_ACPI_2_0_LOCAL_APIC_NMI_STRUCTURE; + +// +// Local APIC Address Override Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Reserved; + UINT64 LocalApicAddress; +} EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE; + +// +// IO SAPIC Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 IoApicId; + UINT8 Reserved; + UINT32 GlobalSystemInterruptBase; + UINT64 IoSapicAddress; +} EFI_ACPI_2_0_IO_SAPIC_STRUCTURE; + +// +// Local SAPIC Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT8 LocalSapicId; + UINT8 LocalSapicEid; + UINT8 Reserved[3]; + UINT32 Flags; +} EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE; + +// +// Platform Interrupt Sources Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Flags; + UINT8 InterruptType; + UINT8 ProcessorId; + UINT8 ProcessorEid; + UINT8 IoSapicVector; + UINT32 GlobalSystemInterrupt; + UINT32 Reserved; +} EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE; + +// +// Smart Battery Description Table (SBST) +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 WarningEnergyLevel; + UINT32 LowEnergyLevel; + UINT32 CriticalEnergyLevel; +} EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE; + +// +// SBST Version (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Embedded Controller Boot Resources Table (ECDT) +// The table is followed by a null terminated ASCII string that contains +// a fully qualified reference to the name space object. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EcControl; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EcData; + UINT32 Uid; + UINT8 GpeBit; +} EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE; + +// +// ECDT Version (as defined in ACPI 2.0 spec.) +// +#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION 0x01 + +// +// Known table signatures +// +// +// "RSD PTR " Root System Description Pointer +// +#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE 0x2052545020445352 + +// +// "SPIC" Multiple SAPIC Description Table +// +// BUGBUG: Don't know where this came from except SR870BN4 uses it. +// #define EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE 0x43495053 +// +#define EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE 0x43495041 + +// +// "BOOT" MS Simple Boot Spec +// +#define EFI_ACPI_2_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE 0x544F4F42 + +// +// "DBGP" MS Bebug Port Spec +// +#define EFI_ACPI_2_0_DEBUG_PORT_TABLE_SIGNATURE 0x50474244 + +// +// "DSDT" Differentiated System Description Table +// +#define EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445344 + +// +// "ECDT" Embedded Controller Boot Resources Table +// +#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE 0x54444345 + +// +// "ETDT" Event Timer Description Table +// +#define EFI_ACPI_2_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE 0x54445445 + +// +// "FACS" Firmware ACPI Control Structure +// +#define EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE 0x53434146 + +// +// "FACP" Fixed ACPI Description Table +// +#define EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146 + +// +// "APIC" Multiple APIC Description Table +// +#define EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE 0x43495041 + +// +// "PSDT" Persistent System Description Table +// +#define EFI_ACPI_2_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445350 + +// +// "RSDT" Root System Description Table +// +#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445352 + +// +// "SBST" Smart Battery Specification Table +// +#define EFI_ACPI_2_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE 0x54534253 + +// +// "SLIT" System Locality Information Table +// +#define EFI_ACPI_2_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE 0x54494C53 + +// +// "SPCR" Serial Port Concole Redirection Table +// +#define EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE 0x52435053 + +// +// "SRAT" Static Resource Affinity Table +// +#define EFI_ACPI_2_0_STATIC_RESOURCE_AFFINITY_TABLE_SIGNATURE 0x54415253 + +// +// "SSDT" Secondary System Description Table +// +#define EFI_ACPI_2_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353 + +// +// "SPMI" Server Platform Management Interface Table +// +#define EFI_ACPI_2_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_SIGNATURE 0x494D5053 + +// +// "XSDT" Extended System Description Table +// +#define EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445358 + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi3_0.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi3_0.h new file mode 100644 index 0000000000..be4483ac68 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Acpi3_0.h @@ -0,0 +1,681 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Acpi3_0.h + +Abstract: + + ACPI 3.0 definitions from the ACPI Specification Revision 3.0 + +--*/ + +#ifndef _ACPI_3_0_H_ +#define _ACPI_3_0_H_ + +// +// Statements that include other files +// +#include "AcpiCommon.h" + +// +// Ensure proper structure formats +// +#pragma pack(1) +// +// ACPI Specification Revision +// +#define EFI_ACPI_3_0_REVISION 0x03 + +// +// ACPI 3.0 Generic Address Space definition +// +typedef struct { + UINT8 AddressSpaceId; + UINT8 RegisterBitWidth; + UINT8 RegisterBitOffset; + UINT8 AccessSize; + UINT64 Address; +} EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE; + +// +// Generic Address Space Address IDs +// +#define EFI_ACPI_3_0_SYSTEM_MEMORY 0 +#define EFI_ACPI_3_0_SYSTEM_IO 1 +#define EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE 2 +#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER 3 +#define EFI_ACPI_3_0_SMBUS 4 +#define EFI_ACPI_3_0_FUNCTIONAL_FIXED_HARDWARE 0x7F + +// +// Generic Address Space Access Sizes +// +#define EFI_ACPI_3_0_UNDEFINED 0 +#define EFI_ACPI_3_0_BYTE 1 +#define EFI_ACPI_3_0_WORD 2 +#define EFI_ACPI_3_0_DWORD 3 +#define EFI_ACPI_3_0_QWORD 4 + +// +// ACPI 3.0 table structures +// +// +// Root System Description Pointer Structure +// +typedef struct { + UINT64 Signature; + UINT8 Checksum; + UINT8 OemId[6]; + UINT8 Revision; + UINT32 RsdtAddress; + UINT32 Length; + UINT64 XsdtAddress; + UINT8 ExtendedChecksum; + UINT8 Reserved[3]; +} EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER; + +// +// RSD_PTR Revision (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION 0x02 // ACPISpec30 (Revision 3.0) says current value is 2 +// +// Common table header, this prefaces all ACPI tables, including FACS, but +// excluding the RSD PTR structure +// +typedef struct { + UINT32 Signature; + UINT32 Length; +} EFI_ACPI_3_0_COMMON_HEADER; + +// +// Root System Description Table +// No definition needed as it is a common description table header followed by a +// variable number of UINT32 table pointers. +// +// +// RSDT Revision (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Extended System Description Table +// No definition needed as it is a common description table header followed by a +// variable number of UINT64 table pointers. +// +// +// XSDT Revision (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Fixed ACPI Description Table Structure (FADT) +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 FirmwareCtrl; + UINT32 Dsdt; + UINT8 Reserved0; + UINT8 PreferredPmProfile; + UINT16 SciInt; + UINT32 SmiCmd; + UINT8 AcpiEnable; + UINT8 AcpiDisable; + UINT8 S4BiosReq; + UINT8 PstateCnt; + UINT32 Pm1aEvtBlk; + UINT32 Pm1bEvtBlk; + UINT32 Pm1aCntBlk; + UINT32 Pm1bCntBlk; + UINT32 Pm2CntBlk; + UINT32 PmTmrBlk; + UINT32 Gpe0Blk; + UINT32 Gpe1Blk; + UINT8 Pm1EvtLen; + UINT8 Pm1CntLen; + UINT8 Pm2CntLen; + UINT8 PmTmrLen; + UINT8 Gpe0BlkLen; + UINT8 Gpe1BlkLen; + UINT8 Gpe1Base; + UINT8 CstCnt; + UINT16 PLvl2Lat; + UINT16 PLvl3Lat; + UINT16 FlushSize; + UINT16 FlushStride; + UINT8 DutyOffset; + UINT8 DutyWidth; + UINT8 DayAlrm; + UINT8 MonAlrm; + UINT8 Century; + UINT16 IaPcBootArch; + UINT8 Reserved1; + UINT32 Flags; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE ResetReg; + UINT8 ResetValue; + UINT8 Reserved2[3]; + UINT64 XFirmwareCtrl; + UINT64 XDsdt; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XGpe0Blk; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XGpe1Blk; +} EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE; + +// +// FADT Version (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION 0x04 + +// +// Fixed ACPI Description Table Preferred Power Management Profile +// +#define EFI_ACPI_3_0_PM_PROFILE_UNSPECIFIED 0 +#define EFI_ACPI_3_0_PM_PROFILE_DESKTOP 1 +#define EFI_ACPI_3_0_PM_PROFILE_MOBILE 2 +#define EFI_ACPI_3_0_PM_PROFILE_WORKSTATION 3 +#define EFI_ACPI_3_0_PM_PROFILE_ENTERPRISE_SERVER 4 +#define EFI_ACPI_3_0_PM_PROFILE_SOHO_SERVER 5 +#define EFI_ACPI_3_0_PM_PROFILE_APPLIANCE_PC 6 +#define EFI_ACPI_3_0_PM_PROFILE_PERFORMANCE_SERVER 7 + +// +// Fixed ACPI Description Table Boot Architecture Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_3_0_LEGACY_DEVICES (1 << 0) +#define EFI_ACPI_3_0_8042 (1 << 1) +#define EFI_ACPI_3_0_VGA_NOT_PRESENT (1 << 2) +#define EFI_ACPI_3_0_MSI_NOT_SUPPORTED (1 << 3) +#define EFI_ACPI_3_0_PCIE_ASPM_CONTROLS (1 << 4) +// +// Fixed ACPI Description Table Fixed Feature Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_3_0_WBINVD (1 << 0) +#define EFI_ACPI_3_0_WBINVD_FLUSH (1 << 1) +#define EFI_ACPI_3_0_PROC_C1 (1 << 2) +#define EFI_ACPI_3_0_P_LVL2_UP (1 << 3) +#define EFI_ACPI_3_0_PWR_BUTTON (1 << 4) +#define EFI_ACPI_3_0_SLP_BUTTON (1 << 5) +#define EFI_ACPI_3_0_FIX_RTC (1 << 6) +#define EFI_ACPI_3_0_RTC_S4 (1 << 7) +#define EFI_ACPI_3_0_TMR_VAL_EXT (1 << 8) +#define EFI_ACPI_3_0_DCK_CAP (1 << 9) +#define EFI_ACPI_3_0_RESET_REG_SUP (1 << 10) +#define EFI_ACPI_3_0_SEALED_CASE (1 << 11) +#define EFI_ACPI_3_0_HEADLESS (1 << 12) +#define EFI_ACPI_3_0_CPU_SW_SLP (1 << 13) +#define EFI_ACPI_3_0_PCI_EXP_WAK (1 << 14) +#define EFI_ACPI_3_0_USE_PLATFORM_CLOCK (1 << 15) +#define EFI_ACPI_3_0_S4_RTC_STS_VALID (1 << 16) +#define EFI_ACPI_3_0_REMOTE_POWER_ON_CAPABLE (1 << 17) +#define EFI_ACPI_3_0_FORCE_APIC_CLUSTER_MODEL (1 << 18) +#define EFI_ACPI_3_0_FORCE_APIC_PHYSICAL_DESTINATION_MODE (1 << 19) + +// +// Firmware ACPI Control Structure +// +typedef struct { + UINT32 Signature; + UINT32 Length; + UINT32 HardwareSignature; + UINT32 FirmwareWakingVector; + UINT32 GlobalLock; + UINT32 Flags; + UINT64 XFirmwareWakingVector; + UINT8 Version; + UINT8 Reserved[31]; +} EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE; + +// +// FACS Version (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x01 + +// +// Firmware Control Structure Feature Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_3_0_S4BIOS_F (1 << 0) + +// +// Differentiated System Description Table, +// Secondary System Description Table +// and Persistent System Description Table, +// no definition needed as they are common description table header followed by a +// definition block. +// +#define EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x02 +#define EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_REVISION 0x02 + +// +// Multiple APIC Description Table header definition. The rest of the table +// must be defined in a platform specific manner. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 LocalApicAddress; + UINT32 Flags; +} EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER; + +// +// MADT Revision (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x02 + +// +// Multiple APIC Flags +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_3_0_PCAT_COMPAT (1 << 0) + +// +// Multiple APIC Description Table APIC structure types +// All other values between 0x09 an 0xFF are reserved and +// will be ignored by OSPM. +// +#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC 0x00 +#define EFI_ACPI_3_0_IO_APIC 0x01 +#define EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE 0x02 +#define EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE 0x03 +#define EFI_ACPI_3_0_LOCAL_APIC_NMI 0x04 +#define EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE 0x05 +#define EFI_ACPI_3_0_IO_SAPIC 0x06 +#define EFI_ACPI_3_0_LOCAL_SAPIC 0x07 +#define EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES 0x08 + +// +// APIC Structure Definitions +// +// +// Processor Local APIC Structure Definition +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT8 ApicId; + UINT32 Flags; +} EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE; + +// +// Local APIC Flags. All other bits are reserved and must be 0. +// +#define EFI_ACPI_3_0_LOCAL_APIC_ENABLED (1 << 0) + +// +// IO APIC Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 IoApicId; + UINT8 Reserved; + UINT32 IoApicAddress; + UINT32 GlobalSystemInterruptBase; +} EFI_ACPI_3_0_IO_APIC_STRUCTURE; + +// +// Interrupt Source Override Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 Bus; + UINT8 Source; + UINT32 GlobalSystemInterrupt; + UINT16 Flags; +} EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE; + +// +// Platform Interrupt Sources Structure Definition +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Flags; + UINT8 InterruptType; + UINT8 ProcessorId; + UINT8 ProcessorEid; + UINT8 IoSapicVector; + UINT32 GlobalSystemInterrupt; + UINT32 PlatformInterruptSourceFlags; + UINT8 CpeiProcessorOverride; + UINT8 Reserved[31]; +} EFI_ACPI_3_0_PLATFORM_INTERRUPT_APIC_STRUCTURE; + +// +// MPS INTI flags. +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_3_0_POLARITY (3 << 0) +#define EFI_ACPI_3_0_TRIGGER_MODE (3 << 2) + +// +// Non-Maskable Interrupt Source Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Flags; + UINT32 GlobalSystemInterrupt; +} EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE; + +// +// Local APIC NMI Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT16 Flags; + UINT8 LocalApicLint; +} EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE; + +// +// Local APIC Address Override Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Reserved; + UINT64 LocalApicAddress; +} EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE; + +// +// IO SAPIC Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 IoApicId; + UINT8 Reserved; + UINT32 GlobalSystemInterruptBase; + UINT64 IoSapicAddress; +} EFI_ACPI_3_0_IO_SAPIC_STRUCTURE; + +// +// Local SAPIC Structure +// This struct followed by a null-terminated ASCII string - ACPI Processor UID String +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 AcpiProcessorId; + UINT8 LocalSapicId; + UINT8 LocalSapicEid; + UINT8 Reserved[3]; + UINT32 Flags; + UINT32 ACPIProcessorUIDValue; +} EFI_ACPI_3_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE; + +// +// Platform Interrupt Sources Structure +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Flags; + UINT8 InterruptType; + UINT8 ProcessorId; + UINT8 ProcessorEid; + UINT8 IoSapicVector; + UINT32 GlobalSystemInterrupt; + UINT32 PlatformInterruptSourceFlags; +} EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE; + +// +// Platform Interrupt Source Flags. +// All other bits are reserved and must be set to 0. +// +#define EFI_ACPI_3_0_CPEI_PROCESSOR_OVERRIDE (1 << 0) + +// +// Smart Battery Description Table (SBST) +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 WarningEnergyLevel; + UINT32 LowEnergyLevel; + UINT32 CriticalEnergyLevel; +} EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE; + +// +// SBST Version (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Embedded Controller Boot Resources Table (ECDT) +// The table is followed by a null terminated ASCII string that contains +// a fully qualified reference to the name space object. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE EcControl; + EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE EcData; + UINT32 Uid; + UINT8 GpeBit; +} EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE; + +// +// ECDT Version (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION 0x01 + +// +// System Resource Affinity Table (SRAT. The rest of the table +// must be defined in a platform specific manner. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Reserved1; // Must be set to 1 + UINT64 Reserved2; +} EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER; + +// +// SRAT Version (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_REVISION 0x02 + +// +// SRAT structure types. +// All other values between 0x02 an 0xFF are reserved and +// will be ignored by OSPM. +// +#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY 0x00 +#define EFI_ACPI_3_0_MEMORY_AFFINITY 0x01 + +// +// Processor Local APIC/SAPIC Affinity Structure Definition +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT8 ProximityDomain7To0; + UINT8 ApicId; + UINT32 Flags; + UINT8 LocalSapicEid; + UINT8 ProximityDomain31To8[3]; + UINT8 Reserved[4]; +} EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY_STRUCTURE; + +// +// Local APIC/SAPIC Flags. All other bits are reserved and must be 0. +// +#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_ENABLED (1 << 0) + +// +// Memory Affinity Structure Definition +// +typedef struct { + UINT8 Type; + UINT8 Length; + UINT32 ProximityDomain; + UINT16 Reserved1; + UINT32 AddressBaseLow; + UINT32 AddressBaseHigh; + UINT32 LengthLow; + UINT32 LengthHigh; + UINT32 Reserved2; + UINT32 Flags; + UINT64 Reserved3; +} EFI_ACPI_3_0_MEMORY_AFFINITY_STRUCTURE; + +// +// Memory Flags. All other bits are reserved and must be 0. +// +#define EFI_ACPI_3_0_MEMORY_ENABLED (1 << 0) +#define EFI_ACPI_3_0_MEMORY_HOT_PLUGGABLE (1 << 1) +#define EFI_ACPI_3_0_MEMORY_NONVOLATILE (1 << 2) + +// +// System Locality Distance Information Table (SLIT). +// The rest of the table is a matrix. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 NumberOfSystemLocalities; +} EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_HEADER; + +// +// SLIT Version (as defined in ACPI 3.0 spec.) +// +#define EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_REVISION 0x01 + +// +// Known table signatures +// +// +// "RSD PTR " Root System Description Pointer +// +#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE 0x2052545020445352 + +// +// "APIC" Multiple APIC Description Table +// +#define EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE 0x43495041 + +// +// "DSDT" Differentiated System Description Table +// +#define EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445344 + +// +// "ECDT" Embedded Controller Boot Resources Table +// +#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE 0x54444345 + +// +// "FACP" Fixed ACPI Description Table +// +#define EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146 + +// +// "FACS" Firmware ACPI Control Structure +// +#define EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE 0x53434146 + +// +// "PSDT" Persistent System Description Table +// +#define EFI_ACPI_3_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445350 + +// +// "RSDT" Root System Description Table +// +#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445352 + +// +// "SBST" Smart Battery Specification Table +// +#define EFI_ACPI_3_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE 0x54534253 + +// +// "SLIT" System Locality Information Table +// +#define EFI_ACPI_3_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE 0x54494C53 + +// +// "SRAT" System Resource Affinity Table +// +#define EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE 0x54415253 + +// +// "SSDT" Secondary System Description Table +// +#define EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353 + +// +// "XSDT" Extended System Description Table +// +#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445358 + +// +// "BOOT" MS Simple Boot Spec +// +#define EFI_ACPI_3_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE 0x544F4F42 + +// +// "CPEP" Corrected Platform Error Polling Table +// See +// +#define EFI_ACPI_3_0_CORRECTED_PLATFORM_ERROR_POLLING_TABLE_SIGNATURE 0x50455043 + +// +// "DBGP" MS Debug Port Spec +// +#define EFI_ACPI_3_0_DEBUG_PORT_TABLE_SIGNATURE 0x50474244 + +// +// "ETDT" Event Timer Description Table +// +#define EFI_ACPI_3_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE 0x54445445 + +// +// "HPET" IA-PC High Precision Event Timer Table +// +#define EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE 0x54455048 + +// +// "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table +// +#define EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE 0x4746434D + +// +// "SPCR" Serial Port Concole Redirection Table +// +#define EFI_ACPI_3_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE 0x52435053 + +// +// "SPMI" Server Platform Management Interface Table +// +#define EFI_ACPI_3_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE 0x494D5053 + +// +// "TCPA" Trusted Computing Platform Alliance Capabilities Table +// +#define EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE 0x41504354 + +// +// "WDRT" Watchdog Resource Table +// +#define EFI_ACPI_3_0_WATCHDOG_RESOURCE_TABLE_SIGNATURE 0x54524457 + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AcpiCommon.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AcpiCommon.h new file mode 100644 index 0000000000..945e787788 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AcpiCommon.h @@ -0,0 +1,98 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AcpiCommon.h + +Abstract: + + This file contains some basic ACPI definitions that are consumed by drivers + that do not care about ACPI versions. + +--*/ + +#ifndef _ACPI_COMMON_H_ +#define _ACPI_COMMON_H_ + +#include "Tiano.h" + +// +// Common table header, this prefaces all ACPI tables, including FACS, but +// excluding the RSD PTR structure +// +typedef struct { + UINT32 Signature; + UINT32 Length; +} EFI_ACPI_COMMON_HEADER; + +// +// Common ACPI description table header. This structure prefaces most ACPI tables. +// +#pragma pack(1) + +typedef struct { + UINT32 Signature; + UINT32 Length; + UINT8 Revision; + UINT8 Checksum; + UINT8 OemId[6]; + UINT64 OemTableId; + UINT32 OemRevision; + UINT32 CreatorId; + UINT32 CreatorRevision; +} EFI_ACPI_DESCRIPTION_HEADER; + +#pragma pack() +// +// Define for Pci Host Bridge Resource Allocation +// +#define ACPI_ADDRESS_SPACE_DESCRIPTOR 0x8A +#define ACPI_END_TAG_DESCRIPTOR 0x79 + +#define ACPI_ADDRESS_SPACE_TYPE_MEM 0x00 +#define ACPI_ADDRESS_SPACE_TYPE_IO 0x01 +#define ACPI_ADDRESS_SPACE_TYPE_BUS 0x02 + +// +// Make sure structures match spec +// +#pragma pack(1) + +typedef struct { + UINT8 Desc; + UINT16 Len; + UINT8 ResType; + UINT8 GenFlag; + UINT8 SpecificFlag; + UINT64 AddrSpaceGranularity; + UINT64 AddrRangeMin; + UINT64 AddrRangeMax; + UINT64 AddrTranslationOffset; + UINT64 AddrLen; +} EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR; + +typedef struct { + UINT8 Desc; + UINT8 Checksum; +} EFI_ACPI_END_TAG_DESCRIPTOR; + +// +// General use definitions +// +#define EFI_ACPI_RESERVED_BYTE 0x00 +#define EFI_ACPI_RESERVED_WORD 0x0000 +#define EFI_ACPI_RESERVED_DWORD 0x00000000 +#define EFI_ACPI_RESERVED_QWORD 0x0000000000000000 + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h new file mode 100644 index 0000000000..f750a63b40 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h @@ -0,0 +1,123 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + AlertStandardFormatTable.h + +Abstract: + + ACPI Alert Standard Format Description Table ASF! as described + in the ASF2.0 Specification + +--*/ + +#ifndef _ALERT_STANDARD_FORMAT_TABLE_H +#define _ALERT_STANDARD_FORMAT_TABLE_H + +#include "Acpi2_0.h" + +// +// Ensure proper structure formats +// +#pragma pack (1) + +// +// Information Record header that appears at the beginning of each record +// +typedef struct { + UINT8 Type; + UINT8 Reserved; + UINT16 RecordLength; +} EFI_ACPI_ASF_RECORD_HEADER; + +// +// This structure contains information that identifies the system type +// and configuration +// +typedef struct { + EFI_ACPI_ASF_RECORD_HEADER RecordHeader; + UINT8 MinWatchDogResetValue; + UINT8 MinPollingInterval; + UINT16 SystemID; + UINT32 IANAManufactureID; + UINT8 FeatureFlags; + UINT8 Reserved[3]; +} EFI_ACPI_ASF_INFO; + +// +// Alert sensors definition +// +#define ASF_ALRT_SENSOR_ARRAY_LENGTH 36 + +typedef struct { + EFI_ACPI_ASF_RECORD_HEADER RecordHeader; + UINT8 AssertionEventBitMask; + UINT8 DeassertionEventBitMask; + UINT8 NumberOfAlerts; + UINT8 ArrayElementLength; + UINT8 DeviceArray[ASF_ALRT_SENSOR_ARRAY_LENGTH]; +} EFI_ACPI_ASF_ALRT; + +// +// Alert Remote Control System Actions +// +#define ASF_RCTL_DEVICES_ARRAY_LENGTH 16 +typedef struct { + EFI_ACPI_ASF_RECORD_HEADER RecordHeader; + UINT8 NumberOfControls; + UINT8 ArrayElementLength; + UINT16 RctlReserved; + UINT8 ControlArray[ASF_RCTL_DEVICES_ARRAY_LENGTH]; +} EFI_ACPI_ASF_RCTL; + +// +// Remote Control Capabilities +// +typedef struct { + EFI_ACPI_ASF_RECORD_HEADER RecordHeader; + UINT8 RemoteControlCapabilities[7]; + UINT8 RMCPCompletionCode; + UINT32 RMCPIANA; + UINT8 RMCPSpecialCommand; + UINT8 RMCPSpecialCommandParameter[2]; + UINT8 RMCPBootOptions[2]; + UINT8 RMCPOEMParameters[2]; +} EFI_ACPI_ASF_RMCP; + +// +// SMBus Devices with fixed addresses +// +#define ASF_ADDR_DEVICE_ARRAY_LENGTH 16 +typedef struct { + EFI_ACPI_ASF_RECORD_HEADER RecordHeader; + UINT8 SEEPROMAddress; + UINT8 NumberOfDevices; + UINT8 FixedSmbusAddresses[ASF_ADDR_DEVICE_ARRAY_LENGTH]; +} EFI_ACPI_ASF_ADDR; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + EFI_ACPI_ASF_INFO AsfInfo; + EFI_ACPI_ASF_ALRT AsfAlert; + EFI_ACPI_ASF_RCTL AsfRctl; + EFI_ACPI_ASF_RMCP AsfRmcp; + EFI_ACPI_ASF_ADDR AsfAddr; +} EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE; + +// +// "ASF!" ASF Description Table Signature +// +#define EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE_SIGNATURE 0x21465341 + +#pragma pack () + +#endif // _ALERT_STANDARD_FORMAT_TABLE_H diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h new file mode 100644 index 0000000000..78162c4196 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h @@ -0,0 +1,202 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DMARemappingReportingTable.h + +Abstract: + + The definition for ACPI DMA-Remapping Reporting (DMAR) Table. + It is defined in "Intel VT for Direct IO Architecture Specification". + +--*/ + +#ifndef _EFI_DMA_REMAPPING_REPORTING_TABLE_H_ +#define _EFI_DMA_REMAPPING_REPORTING_TABLE_H_ + +#include "AcpiCommon.h" + +// +// "DMAR" DMAR Description Table Signature +// +#define EFI_ACPI_DMAR_DESCRIPTION_TABLE_SIGNATURE 0x52414d44 + +// +// DMAR Revision +// +#define EFI_ACPI_DMAR_DESCRIPTION_TABLE_REVISION 0x01 + +// +// Ensure proper structure formats +// +#pragma pack (1) + +// +// Definition for DMA Remapping Structure Types +// +#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_DRHD 0 +#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_RMRR 1 +#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_ATSR 2 + +// +// Definition for DMA Remapping Structure Header +// +typedef struct { + UINT16 Type; + UINT16 Length; +} EFI_ACPI_DMAR_STRUCTURE_HEADER; + +// +// Definition for DMA-Remapping PCI Path +// +typedef struct { + UINT8 Device; + UINT8 Function; +} EFI_ACPI_DMAR_PCI_PATH; + +// +// Definition for DMA-Remapping Device Scope Entry Structure +// +#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_ENDPOINT 0x01 +#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_BRIDGE 0x02 +#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_IOAPIC 0x03 +#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_MSI_CAPABLE_HPET 0x04 +typedef struct { + UINT8 DeviceScopeEntryType; + UINT8 Length; + UINT16 Reserved_2; + UINT8 EnumerationID; + UINT8 StartingBusNumber; +} EFI_ACPI_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE; + +// +// Definition for DMA-Remapping Hardware Definition (DRHD) Structure +// +#define EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_ALL_SET 0x1 +#define EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_ALL_CLEAR 0x0 +typedef struct { + UINT16 Type; + UINT16 Length; + UINT8 Flags; + UINT8 Reserved_5; + UINT16 SegmentNumber; + UINT64 RegisterBaseAddress; +} EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE; + +// +// Definition for Reserved Memory Region Reporting (RMRR) Structure +// +typedef struct { + UINT16 Type; + UINT16 Length; + UINT8 Reserved_4[2]; + UINT16 SegmentNumber; + UINT64 ReservedMemoryRegionBaseAddress; + UINT64 ReservedMemoryRegionLimitAddress; +} EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE; + +// +// Definition for Root Port ATS Capability Reporting (ATSR) Structure +// +#define EFI_ACPI_DMAR_ATSR_FLAGS_ALL_PORTS_SET 0x1 +#define EFI_ACPI_DMAR_ATSR_FLAGS_ALL_PORTS_CLEAR 0x0 +typedef struct { + UINT16 Type; + UINT16 Length; + UINT8 Flags; + UINT8 Reserved_5; + UINT16 SegmentNumber; +} EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE; + +// +// Definition for DMA Remapping Structure +// +typedef union { + EFI_ACPI_DMAR_STRUCTURE_HEADER DMARStructureHeader; + EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE DMARHardwareUnitDefinition; + EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE DMARReservedMemoryRegionReporting; + EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE DMARRootPortATSCapabilityReporting; +} EFI_ACPI_DMA_REMAPPING_STRUCTURE; + +// +// Definition for DMA-Remapping Reporting ACPI Table +// +#define EFI_ACPI_DMAR_TABLE_FLAGS_INTR_REMAP_SET 0x01 +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT8 HostAddressWidth; + UINT8 Flags; + UINT8 Reserved_38[10]; +} EFI_ACPI_DMAR_DESCRIPTION_TABLE; + +// +// The Platform specific definition can be as follows: +// NOTE: we use /**/ as comment for user convenience to copy it. +// + +/* + +// +// Dmar.h +// + +#define EFI_ACPI_MAX_NUM_PCI_PATH_ENTRIES 0x01 // user need to update +typedef struct { + EFI_ACPI_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE Header; + EFI_ACPI_DMAR_PCI_PATH PciPath[EFI_ACPI_MAX_NUM_PCI_PATH_ENTRIES]; +} EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE; + +#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_DHRD_ENTRY 0x01 // user need to update +typedef struct { + EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE Header; + EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_DHRD_ENTRY]; +} EFI_ACPI_3_0_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE; + +#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_RMRR_ENTRY 0x01 // user need to update +typedef struct { + EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE Header; + EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_RMRR_ENTRY]; +} EFI_ACPI_3_0_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE; + +#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_ATSR_ENTRY 0x01 // user need to update +typedef struct { + EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE Header; + EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_ATSR_ENTRY]; +} EFI_ACPI_3_0_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE; + +#define EFI_ACPI_DMAR_DHRD_ENTRY_COUNT 0x1 // user need to update +#define EFI_ACPI_DMAR_RMRR_ENTRY_COUNT 0x1 // user need to update +#define EFI_ACPI_DMAR_ATSR_ENTRY_COUNT 0x1 // user need to update + +typedef struct { + EFI_ACPI_DMAR_DESCRIPTION_TABLE Header; + +#if EFI_ACPI_3_0_DMAR_DHRD_ENTRY_COUNT > 0 + EFI_ACPI_3_0_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE Dhrd[EFI_ACPI_DMAR_DHRD_ENTRY_COUNT]; +#endif + +#if EFI_ACPI_3_0_DMAR_RMRR_ENTRY_COUNT > 0 + EFI_ACPI_3_0_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE Rmrr[EFI_ACPI_DMAR_RMRR_ENTRY_COUNT]; +#endif + +#if EFI_ACPI_3_0_DMAR_ATSR_ENTRY_COUNT > 0 + EFI_ACPI_3_0_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE Atsr[EFI_ACPI_DMAR_ATSR_ENTRY_COUNT]; +#endif + +} EFI_ACPI_3_0_DMA_REMAPPING_REPORTING_TABLE; + +*/ + +#pragma pack() + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h new file mode 100644 index 0000000000..ee23907633 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + HighPrecisionEventTimerTable.h + +Abstract: + + ACPI high precision event timer table definition, defined at + Intel IA-PC HPET (High Precision Event Timers) Specification. + +--*/ + +#ifndef _HIGH_PRECISION_EVENT_TIMER_TABLE_H_ +#define _HIGH_PRECISION_EVENT_TIMER_TABLE_H_ + +// +// Include files +// +#include "Acpi2_0.h" + +// +// Ensure proper structure formats +// +#pragma pack(1) +// +// High Precision Event Timer Table header definition. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 EventTimerBlockId; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE BaseAddressLower32Bit; + UINT8 HpetNumber; + UINT16 MainCounterMinimumClockTickInPeriodicMode; + UINT8 PageProtectionAndOemAttribute; +} EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER; + +// +// HPET Revision (defined in spec) +// +#define EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_REVISION 0x01 + +// +// Page protection setting +// Values 3 through 15 are reserved for use by the specification +// +#define EFI_ACPI_NO_PAGE_PROTECTION 0 +#define EFI_ACPI_4KB_PAGE_PROTECTION 1 +#define EFI_ACPI_64KB_PAGE_PROTECTION 2 + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h new file mode 100644 index 0000000000..bf484a7541 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h @@ -0,0 +1,283 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LegacyBiosMpTable.h + +Abstract: + Defives data structures per Multi Processor Specification Ver 1.4. + +--*/ + +#ifndef LEGACY_BIOS_MPTABLE_H_ +#define LEGACY_BIOS_MPTABLE_H_ + +#include "Tiano.h" + +#define EFI_LEGACY_MP_TABLE_REV_1_4 0x04 + +// +// Define MP table structures. All are packed. +// +#pragma pack(push, 1) + +#define EFI_LEGACY_MP_TABLE_FLOATING_POINTER_SIGNATURE EFI_SIGNATURE_32 ('_', 'M', 'P', '_') +typedef struct { + UINT32 Signature; + UINT32 PhysicalAddress; + UINT8 Length; + UINT8 SpecRev; + UINT8 Checksum; + UINT8 FeatureByte1; + struct { + UINT32 Reserved1 : 6; + UINT32 MutipleClk : 1; + UINT32 Imcr : 1; + UINT32 Reserved2 : 24; + } FeatureByte2_5; +} EFI_LEGACY_MP_TABLE_FLOATING_POINTER; + +#define EFI_LEGACY_MP_TABLE_HEADER_SIGNATURE EFI_SIGNATURE_32 ('P', 'C', 'M', 'P') +typedef struct { + UINT32 Signature; + UINT16 BaseTableLength; + UINT8 SpecRev; + UINT8 Checksum; + CHAR8 OemId[8]; + CHAR8 OemProductId[12]; + UINT32 OemTablePointer; + UINT16 OemTableSize; + UINT16 EntryCount; + UINT32 LocalApicAddress; + UINT16 ExtendedTableLength; + UINT8 ExtendedChecksum; + UINT8 Reserved; +} EFI_LEGACY_MP_TABLE_HEADER; + +typedef struct { + UINT8 EntryType; +} EFI_LEGACY_MP_TABLE_ENTRY_TYPE; + +// +// Entry Type 0: Processor. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_PROCESSOR 0x00 +typedef struct { + UINT8 EntryType; + UINT8 Id; + UINT8 Ver; + struct { + UINT8 Enabled : 1; + UINT8 Bsp : 1; + UINT8 Reserved : 6; + } Flags; + struct { + UINT32 Stepping : 4; + UINT32 Model : 4; + UINT32 Family : 4; + UINT32 Reserved : 20; + } Signature; + struct { + UINT32 Fpu : 1; + UINT32 Reserved1 : 6; + UINT32 Mce : 1; + UINT32 Cx8 : 1; + UINT32 Apic : 1; + UINT32 Reserved2 : 22; + } Features; + UINT32 Reserved1; + UINT32 Reserved2; +} EFI_LEGACY_MP_TABLE_ENTRY_PROCESSOR; + +// +// Entry Type 1: Bus. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_BUS 0x01 +typedef struct { + UINT8 EntryType; + UINT8 Id; + CHAR8 TypeString[6]; +} EFI_LEGACY_MP_TABLE_ENTRY_BUS; + +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_CBUS "CBUS " // Corollary CBus +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_CBUSII "CBUSII" // Corollary CBUS II +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_EISA "EISA " // Extended ISA +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_FUTURE "FUTURE" // IEEE FutureBus +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_INTERN "INTERN" // Internal bus +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_ISA "ISA " // Industry Standard Architecture +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MBI "MBI " // Multibus I +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MBII "MBII " // Multibus II +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MCA "MCA " // Micro Channel Architecture +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MPI "MPI " // MPI +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MPSA "MPSA " // MPSA +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_NUBUS "NUBUS " // Apple Macintosh NuBus +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_PCI "PCI " // Peripheral Component Interconnect +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_PCMCIA "PCMCIA" // PC Memory Card International Assoc. +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_TC "TC " // DEC TurboChannel +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_VL "VL " // VESA Local Bus +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_VME "VME " // VMEbus +#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_XPRESS "XPRESS" // Express System Bus +// +// Entry Type 2: I/O APIC. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_IOAPIC 0x02 +typedef struct { + UINT8 EntryType; + UINT8 Id; + UINT8 Ver; + struct { + UINT8 Enabled : 1; + UINT8 Reserved : 7; + } Flags; + UINT32 Address; +} EFI_LEGACY_MP_TABLE_ENTRY_IOAPIC; + +// +// Entry Type 3: I/O Interrupt Assignment. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_IO_INT 0x03 +typedef struct { + UINT8 EntryType; + UINT8 IntType; + struct { + UINT16 Polarity : 2; + UINT16 Trigger : 2; + UINT16 Reserved : 12; + } Flags; + UINT8 SourceBusId; + union { + struct { + UINT8 IntNo : 2; + UINT8 Dev : 5; + UINT8 Reserved : 1; + } fields; + UINT8 byte; + } SourceBusIrq; + UINT8 DestApicId; + UINT8 DestApicIntIn; +} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT; + +typedef enum { + EfiLegacyMpTableEntryIoIntTypeInt = 0, + EfiLegacyMpTableEntryIoIntTypeNmi = 1, + EfiLegacyMpTableEntryIoIntTypeSmi = 2, + EfiLegacyMpTableEntryIoIntTypeExtInt= 3, +} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_TYPE; + +typedef enum { + EfiLegacyMpTableEntryIoIntFlagsPolaritySpec = 0x0, + EfiLegacyMpTableEntryIoIntFlagsPolarityActiveHigh = 0x1, + EfiLegacyMpTableEntryIoIntFlagsPolarityReserved = 0x2, + EfiLegacyMpTableEntryIoIntFlagsPolarityActiveLow = 0x3, +} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_FLAGS_POLARITY; + +typedef enum { + EfiLegacyMpTableEntryIoIntFlagsTriggerSpec = 0x0, + EfiLegacyMpTableEntryIoIntFlagsTriggerEdge = 0x1, + EfiLegacyMpTableEntryIoIntFlagsTriggerReserved = 0x2, + EfiLegacyMpTableEntryIoIntFlagsTriggerLevel = 0x3, +} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_FLAGS_TRIGGER; + +// +// Entry Type 4: Local Interrupt Assignment. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_LOCAL_INT 0x04 +typedef struct { + UINT8 EntryType; + UINT8 IntType; + struct { + UINT16 Polarity : 2; + UINT16 Trigger : 2; + UINT16 Reserved : 12; + } Flags; + UINT8 SourceBusId; + UINT8 SourceBusIrq; + UINT8 DestApicId; + UINT8 DestApicIntIn; +} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT; + +typedef enum { + EfiLegacyMpTableEntryLocalIntTypeInt = 0, + EfiLegacyMpTableEntryLocalIntTypeNmi = 1, + EfiLegacyMpTableEntryLocalIntTypeSmi = 2, + EfiLegacyMpTableEntryLocalIntTypeExtInt = 3, +} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_TYPE; + +typedef enum { + EfiLegacyMpTableEntryLocalIntFlagsPolaritySpec = 0x0, + EfiLegacyMpTableEntryLocalIntFlagsPolarityActiveHigh= 0x1, + EfiLegacyMpTableEntryLocalIntFlagsPolarityReserved = 0x2, + EfiLegacyMpTableEntryLocalIntFlagsPolarityActiveLow = 0x3, +} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_FLAGS_POLARITY; + +typedef enum { + EfiLegacyMpTableEntryLocalIntFlagsTriggerSpec = 0x0, + EfiLegacyMpTableEntryLocalIntFlagsTriggerEdge = 0x1, + EfiLegacyMpTableEntryLocalIntFlagsTriggerReserved = 0x2, + EfiLegacyMpTableEntryLocalIntFlagsTriggerLevel = 0x3, +} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_FLAGS_TRIGGER; + +// +// Entry Type 128: System Address Space Mapping. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_SYS_ADDR_SPACE_MAPPING 0x80 +typedef struct { + UINT8 EntryType; + UINT8 Length; + UINT8 BusId; + UINT8 AddressType; + UINT64 AddressBase; + UINT64 AddressLength; +} EFI_LEGACY_MP_TABLE_ENTRY_EXT_SYS_ADDR_SPACE_MAPPING; + +typedef enum { + EfiLegacyMpTableEntryExtSysAddrSpaceMappingIo = 0, + EfiLegacyMpTableEntryExtSysAddrSpaceMappingMemory = 1, + EfiLegacyMpTableEntryExtSysAddrSpaceMappingPrefetch = 2, +} EFI_LEGACY_MP_TABLE_ENTRY_EXT_SYS_ADDR_SPACE_MAPPING_TYPE; + +// +// Entry Type 129: Bus Hierarchy. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_BUS_HIERARCHY 0x81 +typedef struct { + UINT8 EntryType; + UINT8 Length; + UINT8 BusId; + struct { + UINT8 SubtractiveDecode : 1; + UINT8 Reserved : 7; + } BusInfo; + UINT8 ParentBus; + UINT8 Reserved1; + UINT8 Reserved2; + UINT8 Reserved3; +} EFI_LEGACY_MP_TABLE_ENTRY_EXT_BUS_HIERARCHY; + +// +// Entry Type 130: Compatibility Bus Address Space Modifier. +// +#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_COMPAT_BUS_ADDR_SPACE_MODIFIER 0x82 +typedef struct { + UINT8 EntryType; + UINT8 Length; + UINT8 BusId; + struct { + UINT8 RangeMode : 1; + UINT8 Reserved : 7; + } AddrMode; + UINT32 PredefinedRangeList; +} EFI_LEGACY_MP_TABLE_ENTRY_EXT_COMPAT_BUS_ADDR_SPACE_MODIFIER; + +#pragma pack(pop) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h new file mode 100644 index 0000000000..5bbc05957e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h @@ -0,0 +1,56 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemoryMappedConfigurationSpaceAccessTable.h + +Abstract: + + ACPI memory mapped configuration space access table definition, defined at + in the PCI Firmware Specification, version 3.0. + Specification is available at http://www.pcisig.com. + +--*/ + +#ifndef _MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_H_ +#define _MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_H_ + +// +// Include files +// +#include "AcpiCommon.h" + +// +// Ensure proper structure formats +// +#pragma pack(1) +// +// Memory Mapped Configuration Space Access Table (MCFG) +// This table is a basic description table header followed by +// a number of base address allocation structures. +// +typedef struct { + UINT64 BaseAddress; + UINT16 PciSegmentGroupNumber; + UINT8 StartBusNumber; + UINT8 EndBusNumber; + UINT32 Reserved; +} EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE; + +// +// MCFG Revision (defined in spec) +// +#define EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION 0x01 + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/SdramSpd.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/SdramSpd.h new file mode 100644 index 0000000000..f8ca8485d4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/SdramSpd.h @@ -0,0 +1,73 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SdramSpd.h + +Abstract: + + This file contains definitions for the SPD fields on an SDRAM. + +--*/ + +#ifndef _SDRAM_SPD_H +#define _SDRAM_SPD_H + +// +// SDRAM SPD field definitions +// +#define SPD_MEMORY_TYPE 2 +#define SPD_SDRAM_ROW_ADDR 3 +#define SPD_SDRAM_COL_ADDR 4 +#define SPD_SDRAM_MODULE_ROWS 5 +#define SPD_SDRAM_MODULE_DATA_WIDTH_LSB 6 +#define SPD_SDRAM_MODULE_DATA_WIDTH_MSB 7 +#define SPD_SDRAM_ECC_SUPPORT 11 +#define SPD_SDRAM_REFRESH 12 +#define SPD_SDRAM_WIDTH 13 +#define SPD_SDRAM_ERROR_WIDTH 14 +#define SPD_SDRAM_BURST_LENGTH 16 +#define SPD_SDRAM_NO_OF_BANKS 17 +#define SPD_SDRAM_CAS_LATENCY 18 +#define SPD_SDRAM_MODULE_ATTR 21 + +#define SPD_SDRAM_TCLK1_PULSE 9 // cycle time for highest cas latency +#define SPD_SDRAM_TAC1_PULSE 10 // access time for highest cas latency +#define SPD_SDRAM_TCLK2_PULSE 23 // cycle time for 2nd highest cas latency +#define SPD_SDRAM_TAC2_PULSE 24 // access time for 2nd highest cas latency +#define SPD_SDRAM_TCLK3_PULSE 25 // cycle time for 3rd highest cas latency +#define SPD_SDRAM_TAC3_PULSE 26 // access time for 3rd highest cas latency +#define SPD_SDRAM_MIN_PRECHARGE 27 +#define SPD_SDRAM_ACTIVE_MIN 28 +#define SPD_SDRAM_RAS_CAS 29 +#define SPD_SDRAM_RAS_PULSE 30 +#define SPD_SDRAM_DENSITY 31 + +// +// Memory Type Definitions +// +#define SPD_VAL_SDR_TYPE 4 // SDR SDRAM memory +#define SPD_VAL_DDR_TYPE 7 // DDR SDRAM memory +#define SPD_VAL_DDR2_TYPE 8 // DDR2 SDRAM memory +// +// ECC Type Definitions +// +#define SPD_ECC_TYPE_NONE 0x00 // No error checking +#define SPD_ECC_TYPE_PARITY 0x01 // No error checking +#define SPD_ECC_TYPE_ECC 0x02 // Error checking only +// +// Module Attributes (Bit positions) +// +#define SPD_BUFFERED 0x01 +#define SPD_REGISTERED 0x02 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h new file mode 100644 index 0000000000..2c2a925e60 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h @@ -0,0 +1,80 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ServerProcessorManagementInterfaceTable.h + +Abstract: + + ACPI Server Processor Management Interface Table SPMI as described + in the IPMI2.0 Specification Revistion 1.5 + +--*/ + +#ifndef _SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_H_ +#define _SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_H_ + +#include "Acpi2_0.h" + +// +// Ensure proper structure formats +// +#pragma pack (1) + +// +// Server Processor Management Interface Table definition. +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT8 Reserved_36; + UINT8 InterfaceType; + UINT16 SpecificationRevision; + UINT8 InterruptType; + UINT8 GPE; + UINT8 Reserved_42; + UINT8 PCIDeviceFlag; + UINT32 GlobalSystemInterrupt; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE BaseAddress; + UINT8 PCISegmentGroup_UID1; + UINT8 PCIBusNumber_UID2; + UINT8 PCIDeviceNumber_UID3; + UINT8 PCIFunctionNumber_UID4; +} EFI_ACPI_SERVER_PROCESSOR_MANAGEMENT_INTERFACE_DESCRIPTION_TABLE; + +#pragma pack () + +// +// SPMI Revision +// +#define EFI_ACPI_SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_REVISION 0x05 + +// +// Interface Type +// +#define EFI_ACPI_SPMI_INTERFACE_TYPE_RESERVED 0 +#define EFI_ACPI_SPMI_INTERFACE_TYPE_KCS 1 +#define EFI_ACPI_SPMI_INTERFACE_TYPE_SMIC 2 +#define EFI_ACPI_SPMI_INTERFACE_TYPE_BT 3 +#define EFI_ACPI_SPMI_INTERFACE_TYPE_SSIF 4 + +// +// SPMI Specfication Revision +// +#define EFI_ACPI_SPMI_SPECIFICATION_REVISION 0x0150 + +// +// SPMI Interrupt Type +// +#define EFI_ACPI_SPMI_INTERRUPT_TYPE_SCI 0x1 +#define EFI_ACPI_SPMI_INTERRUPT_TYPE_IOAPIC 0x2 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h new file mode 100644 index 0000000000..10ef37ddf7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h @@ -0,0 +1,576 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Smbios.h + +Abstract: + +--*/ + +#ifndef _SMBIOS_TABLE_H_ +#define _SMBIOS_TABLE_H_ + +#include "Tiano.h" + +#pragma pack(1) + +typedef UINT8 SMBIOS_TABLE_STRING; + +typedef struct { + UINT8 AnchorString[4]; + UINT8 EntryPointStructureChecksum; + UINT8 EntryPointLength; + UINT8 MajorVersion; + UINT8 MinorVersion; + UINT16 MaxStructureSize; + UINT8 EntryPointRevision; + UINT8 FormattedArea[5]; + UINT8 IntermediateAnchorString[5]; + UINT8 IntermediateChecksum; + UINT16 TableLength; + UINT32 TableAddress; + UINT16 NumberOfSmbiosStructures; + UINT8 SmbiosBcdRevision; +} SMBIOS_TABLE_STRUCTURE; + +typedef struct { + UINT8 Type; + UINT8 Length; + UINT16 Handle; +} SMBIOS_TABLE_HEADER; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Vendor; + SMBIOS_TABLE_STRING BiosVersion; + UINT16 BiosSegment; + SMBIOS_TABLE_STRING BiosReleaseDate; + UINT8 BiosSize; + UINT64 BiosCharacteristics; + UINT8 BIOSCharacteristicsExtensionBytes[2]; + UINT8 SystemBiosMajorRelease; + UINT8 SystemBiosMinorRelease; + UINT8 EmbeddedControllerFirmwareMajorRelease; + UINT8 EmbeddedControllerFirmwareMinorRelease; +} SMBIOS_TABLE_TYPE0; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Manufacturer; + SMBIOS_TABLE_STRING ProductName; + SMBIOS_TABLE_STRING Version; + SMBIOS_TABLE_STRING SerialNumber; + EFI_GUID Uuid; + UINT8 WakeUpType; + SMBIOS_TABLE_STRING SKUNumber; + SMBIOS_TABLE_STRING Family; +} SMBIOS_TABLE_TYPE1; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Manufacturer; + SMBIOS_TABLE_STRING ProductName; + SMBIOS_TABLE_STRING Version; + SMBIOS_TABLE_STRING SerialNumber; + SMBIOS_TABLE_STRING AssetTag; + UINT8 FeatureFlag; + SMBIOS_TABLE_STRING LocationInChassis; + UINT16 ChassisHandle; + UINT8 BoardType; + UINT8 NumberOfContainedObjectHandles; + UINT16 ContainedObjectHandles[1]; +} SMBIOS_TABLE_TYPE2; + +typedef struct { + UINT8 ContainedElementType; + UINT8 ContainedElementMinimum; + UINT8 ContainedElementMaximum; +} CONTAINED_ELEMENT; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Manufacturer; + UINT8 Type; + SMBIOS_TABLE_STRING Version; + SMBIOS_TABLE_STRING SerialNumber; + SMBIOS_TABLE_STRING AssetTag; + UINT8 BootupState; + UINT8 PowerSupplyState; + UINT8 ThermalState; + UINT8 SecurityStatus; + UINT8 OemDefined[4]; + UINT8 Height; + UINT8 NumberofPowerCords; + UINT8 ContainedElementCount; + UINT8 ContainedElementRecordLength; + CONTAINED_ELEMENT ContainedElements[1]; +} SMBIOS_TABLE_TYPE3; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 Socket; + UINT8 ProcessorType; + UINT8 ProcessorFamily; + SMBIOS_TABLE_STRING ProcessorManufacture; + UINT8 ProcessorId[8]; + SMBIOS_TABLE_STRING ProcessorVersion; + UINT8 Voltage; + UINT16 ExternalClock; + UINT16 MaxSpeed; + UINT16 CurrentSpeed; + UINT8 Status; + UINT8 ProcessorUpgrade; + UINT16 L1CacheHandle; + UINT16 L2CacheHandle; + UINT16 L3CacheHandle; + SMBIOS_TABLE_STRING SerialNumber; + SMBIOS_TABLE_STRING AssetTag; + SMBIOS_TABLE_STRING PartNumber; +} SMBIOS_TABLE_TYPE4; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 ErrDetectMethod; + UINT8 ErrCorrectCapability; + UINT8 SupportInterleave; + UINT8 CurrentInterleave; + UINT8 MaxMemoryModuleSize; + UINT16 SupportSpeed; + UINT16 SupportMemoryType; + UINT8 MemoryModuleVoltage; + UINT8 AssociatedMemorySlotNum; + UINT16 MemoryModuleConfigHandles[1]; +// UINT8 EnableErrCorrectCapabilities; +} SMBIOS_TABLE_TYPE5; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING SocketDesignation; + UINT8 BankConnections; + UINT8 CurrentSpeed; + UINT16 CurrentMemoryType; + UINT8 InstalledSize; + UINT8 EnabledSize; + UINT8 ErrorStatus; +} SMBIOS_TABLE_TYPE6; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING SocketDesignation; + UINT16 CacheConfiguration; + UINT16 MaximumCacheSize; + UINT16 InstalledSize; + UINT16 SupportedSRAMType; + UINT16 CurrentSRAMType; + UINT8 CacheSpeed; + UINT8 ErrorCorrectionType; + UINT8 SystemCacheType; + UINT8 Associativity; +} SMBIOS_TABLE_TYPE7; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING InternalReferenceDesignator; + UINT8 InternalConnectorType; + SMBIOS_TABLE_STRING ExternalReferenceDesignator; + UINT8 ExternalConnectorType; + UINT8 PortType; +} SMBIOS_TABLE_TYPE8; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING SlotDesignation; + UINT8 SlotType; + UINT8 SlotDataBusWidth; + UINT8 CurrentUsage; + UINT8 SlotLength; + UINT16 SlotID; + UINT8 SlotCharacteristics1; + UINT8 SlotCharacteristics2; +} SMBIOS_TABLE_TYPE9; + +typedef struct { + UINT8 DeviceType; + SMBIOS_TABLE_STRING DescriptionString; +} DEVICE_STRUCT; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + DEVICE_STRUCT Device[1]; +} SMBIOS_TABLE_TYPE10; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 StringCount; +} SMBIOS_TABLE_TYPE11; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 StringCount; +} SMBIOS_TABLE_TYPE12; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 InstallableLanguages; + UINT8 Flags; + UINT8 reserved[15]; + SMBIOS_TABLE_STRING CurrentLanguages; +} SMBIOS_TABLE_TYPE13; + +typedef struct { + UINT8 ItemType; + UINT16 ItemHandle; +} GROUP_STRUCT; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING GroupName; + GROUP_STRUCT Group[1]; +} SMBIOS_TABLE_TYPE14; + +typedef struct { + UINT8 LogType; + UINT8 DataFormatType; +} EVENT_LOG_TYPE; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT16 LogAreaLength; + UINT16 LogHeaderStartOffset; + UINT16 LogDataStartOffset; + UINT8 AccessMethod; + UINT8 LogStatus; + UINT32 LogChangeToken; + UINT32 AccessMethodAddress; + UINT8 LogHeaderFormat; + UINT8 NumberOfSupportedLogTypeDescriptors; + UINT8 LengthOfLogTypeDescriptor; + EVENT_LOG_TYPE EventLogTypeDescriptors[1]; +} SMBIOS_TABLE_TYPE15; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 Location; + UINT8 Use; + UINT8 MemoryErrorCorrection; + UINT32 MaximumCapacity; + UINT16 MemoryErrorInformationHandle; + UINT16 NumberOfMemoryDevices; +} SMBIOS_TABLE_TYPE16; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT16 MemoryArrayHandle; + UINT16 MemoryErrorInformationHandle; + UINT16 TotalWidth; + UINT16 DataWidth; + UINT16 Size; + UINT8 FormFactor; + UINT8 DeviceSet; + SMBIOS_TABLE_STRING DeviceLocator; + SMBIOS_TABLE_STRING BankLocator; + UINT8 MemoryType; + UINT16 TypeDetail; + UINT16 Speed; + SMBIOS_TABLE_STRING Manufacturer; + SMBIOS_TABLE_STRING SerialNumber; + SMBIOS_TABLE_STRING AssetTag; + SMBIOS_TABLE_STRING PartNumber; +} SMBIOS_TABLE_TYPE17; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 ErrorType; + UINT8 ErrorGranularity; + UINT8 ErrorOperation; + UINT32 VendorSyndrome; + UINT32 MemoryArrayErrorAddress; + UINT32 DeviceErrorAddress; + UINT32 ErrorResolution; +} SMBIOS_TABLE_TYPE18; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT32 StartingAddress; + UINT32 EndingAddress; + UINT16 MemoryArrayHandle; + UINT8 PartitionWidth; +} SMBIOS_TABLE_TYPE19; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT32 StartingAddress; + UINT32 EndingAddress; + UINT16 MemoryDeviceHandle; + UINT16 MemoryArrayMappedAddressHandle; + UINT8 PartitionRowPosition; + UINT8 InterleavePosition; + UINT8 InterleavedDataDepth; +} SMBIOS_TABLE_TYPE20; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 Type; + UINT8 Interface; + UINT8 NumberOfButtons; +} SMBIOS_TABLE_TYPE21; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Location; + SMBIOS_TABLE_STRING Manufacturer; + SMBIOS_TABLE_STRING ManufactureDate; + SMBIOS_TABLE_STRING SerialNumber; + SMBIOS_TABLE_STRING DeviceName; + UINT8 DeviceChemistry; + UINT16 DeviceCapacity; + UINT16 DesignVoltage; + SMBIOS_TABLE_STRING SBDSVersionNumber; + UINT8 MaximumErrorInBatteryData; + UINT16 SBDSSerialNumber; + UINT16 SBDSManufactureDate; + SMBIOS_TABLE_STRING SBDSDeviceChemistry; + UINT8 DesignCapacityMultiplier; + UINT32 OEMSpecific; +} SMBIOS_TABLE_TYPE22; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 Capabilities; + UINT16 ResetCount; + UINT16 ResetLimit; + UINT16 TimerInterval; + UINT16 Timeout; +} SMBIOS_TABLE_TYPE23; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 HardwareSecuritySettings; +} SMBIOS_TABLE_TYPE24; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 NextScheduledPowerOnMonth; + UINT8 NextScheduledPowerOnDayOfMonth; + UINT8 NextScheduledPowerOnHour; + UINT8 NextScheduledPowerOnMinute; + UINT8 NextScheduledPowerOnSecond; +} SMBIOS_TABLE_TYPE25; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Description; + UINT8 LocationAndStatus; + UINT16 MaximumValue; + UINT16 MinimumValue; + UINT16 Resolution; + UINT16 Tolerance; + UINT16 Accuracy; + UINT32 OEMDefined; + UINT16 NominalValue; +} SMBIOS_TABLE_TYPE26; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT16 TemperatureProbeHandle; + UINT8 DeviceTypeAndStatus; + UINT8 CoolingUnitGroup; + UINT32 OEMDefined; + UINT16 NominalSpeed; +} SMBIOS_TABLE_TYPE27; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Description; + UINT8 LocationAndStatus; + UINT16 MaximumValue; + UINT16 MinimumValue; + UINT16 Resolution; + UINT16 Tolerance; + UINT16 Accuracy; + UINT32 OEMDefined; + UINT16 NominalValue; +} SMBIOS_TABLE_TYPE28; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Description; + UINT8 LocationAndStatus; + UINT16 MaximumValue; + UINT16 MinimumValue; + UINT16 Resolution; + UINT16 Tolerance; + UINT16 Accuracy; + UINT32 OEMDefined; + UINT16 NominalValue; +} SMBIOS_TABLE_TYPE29; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING ManufacturerName; + UINT8 Connections; +} SMBIOS_TABLE_TYPE30; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 Checksum; + UINT8 Reserved1; + UINT16 Reserved2; + UINT32 BisEntry16; + UINT32 BisEntry32; + UINT64 Reserved3; + UINT32 Reserved4; +} SMBIOS_TABLE_TYPE31; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 Reserved[6]; + UINT8 BootStatus[1]; +} SMBIOS_TABLE_TYPE32; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 ErrorType; + UINT8 ErrorGranularity; + UINT8 ErrorOperation; + UINT32 VendorSyndrome; + UINT64 MemoryArrayErrorAddress; + UINT64 DeviceErrorAddress; + UINT32 ErrorResolution; +} SMBIOS_TABLE_TYPE33; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Description; + UINT8 Type; + UINT32 Address; + UINT8 AddressType; +} SMBIOS_TABLE_TYPE34; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + SMBIOS_TABLE_STRING Description; + UINT16 ManagementDeviceHandle; + UINT16 ComponentHandle; + UINT16 ThresholdHandle; +} SMBIOS_TABLE_TYPE35; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT16 LowerThresholdNonCritical; + UINT16 UpperThresholdNonCritical; + UINT16 LowerThresholdCritical; + UINT16 UpperThresholdCritical; + UINT16 LowerThresholdNonRecoverable; + UINT16 UpperThresholdNonRecoverable; +} SMBIOS_TABLE_TYPE36; + +typedef struct { + UINT8 DeviceLoad; + UINT16 DeviceHandle; +} MEMORY_DEVICE; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 ChannelType; + UINT8 MaximumChannelLoad; + UINT8 MemoryDeviceCount; + MEMORY_DEVICE MemoryDevice[1]; +} SMBIOS_TABLE_TYPE37; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 InterfaceType; + UINT8 IPMISpecificationRevision; + UINT8 I2CSlaveAddress; + UINT8 NVStorageDeviceAddress; + UINT64 BaseAddress; + UINT8 BaseAddressModifier_InterruptInfo; + UINT8 InterruptNumber; +} SMBIOS_TABLE_TYPE38; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; + UINT8 PowerUnitGroup; + SMBIOS_TABLE_STRING Location; + SMBIOS_TABLE_STRING DeviceName; + SMBIOS_TABLE_STRING Manufacturer; + SMBIOS_TABLE_STRING SerialNumber; + SMBIOS_TABLE_STRING AssetTagNumber; + SMBIOS_TABLE_STRING ModelPartNumber; + SMBIOS_TABLE_STRING RevisionLevel; + UINT16 MaxPowerCapacity; + UINT16 PowerSupplyCharacteristics; + UINT16 InputVoltageProbeHandle; + UINT16 CoolingDeviceHandle; + UINT16 InputCurrentProbeHandle; +} SMBIOS_TABLE_TYPE39; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; +} SMBIOS_TABLE_TYPE126; + +typedef struct { + SMBIOS_TABLE_HEADER Hdr; +} SMBIOS_TABLE_TYPE127; + +typedef union { + SMBIOS_TABLE_HEADER *Hdr; + SMBIOS_TABLE_TYPE0 *Type0; + SMBIOS_TABLE_TYPE1 *Type1; + SMBIOS_TABLE_TYPE2 *Type2; + SMBIOS_TABLE_TYPE3 *Type3; + SMBIOS_TABLE_TYPE4 *Type4; + SMBIOS_TABLE_TYPE5 *Type5; + SMBIOS_TABLE_TYPE6 *Type6; + SMBIOS_TABLE_TYPE7 *Type7; + SMBIOS_TABLE_TYPE8 *Type8; + SMBIOS_TABLE_TYPE9 *Type9; + SMBIOS_TABLE_TYPE10 *Type10; + SMBIOS_TABLE_TYPE11 *Type11; + SMBIOS_TABLE_TYPE12 *Type12; + SMBIOS_TABLE_TYPE13 *Type13; + SMBIOS_TABLE_TYPE14 *Type14; + SMBIOS_TABLE_TYPE15 *Type15; + SMBIOS_TABLE_TYPE16 *Type16; + SMBIOS_TABLE_TYPE17 *Type17; + SMBIOS_TABLE_TYPE18 *Type18; + SMBIOS_TABLE_TYPE19 *Type19; + SMBIOS_TABLE_TYPE20 *Type20; + SMBIOS_TABLE_TYPE21 *Type21; + SMBIOS_TABLE_TYPE22 *Type22; + SMBIOS_TABLE_TYPE23 *Type23; + SMBIOS_TABLE_TYPE24 *Type24; + SMBIOS_TABLE_TYPE25 *Type25; + SMBIOS_TABLE_TYPE26 *Type26; + SMBIOS_TABLE_TYPE27 *Type27; + SMBIOS_TABLE_TYPE28 *Type28; + SMBIOS_TABLE_TYPE29 *Type29; + SMBIOS_TABLE_TYPE30 *Type30; + SMBIOS_TABLE_TYPE31 *Type31; + SMBIOS_TABLE_TYPE32 *Type32; + SMBIOS_TABLE_TYPE33 *Type33; + SMBIOS_TABLE_TYPE34 *Type34; + SMBIOS_TABLE_TYPE35 *Type35; + SMBIOS_TABLE_TYPE36 *Type36; + SMBIOS_TABLE_TYPE37 *Type37; + SMBIOS_TABLE_TYPE38 *Type38; + SMBIOS_TABLE_TYPE39 *Type39; + SMBIOS_TABLE_TYPE126 *Type126; + SMBIOS_TABLE_TYPE127 *Type127; + UINT8 *Raw; +} SMBIOS_STRUCTURE_POINTER; + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h new file mode 100644 index 0000000000..077498a51d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h @@ -0,0 +1,1847 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Tpm12.h + +Abstract: + + TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 94) + + See http://trustedcomputinggroup.org for latest specification updates + +--*/ + +#ifndef _TPM12_H_ +#define _TPM12_H_ + +// +// Structures are all packed on 1-byte alignment +// + +#pragma pack (push) +#pragma pack (1) + +// +// Part 2, section 2.2: Basic types & Helper redefinitions +// +typedef UINT8 TPM_AUTH_DATA_USAGE; +typedef UINT8 TPM_PAYLOAD_TYPE; +typedef UINT8 TPM_VERSION_BYTE; +typedef UINT16 TPM_TAG; +typedef UINT16 TPM_PROTOCOL_ID; +typedef UINT16 TPM_STARTUP_TYPE; +typedef UINT16 TPM_ENC_SCHEME; +typedef UINT16 TPM_SIG_SCHEME; +typedef UINT16 TPM_MIGRATE_SCHEME; +typedef UINT16 TPM_PHYSICAL_PRESENCE; +typedef UINT16 TPM_ENTITY_TYPE; +typedef UINT16 TPM_KEY_USAGE; +typedef UINT16 TPM_EK_TYPE; +typedef UINT16 TPM_STRUCTURE_TAG; +typedef UINT16 TPM_PLATFORM_SPECIFIC; +typedef UINT32 TPM_COMMAND_CODE; +typedef UINT32 TPM_CAPABILITY_AREA; +typedef UINT32 TPM_KEY_FLAGS; +typedef UINT32 TPM_ALGORITHM_ID; +typedef UINT32 TPM_MODIFIER_INDICATOR; +typedef UINT32 TPM_ACTUAL_COUNT; +typedef UINT32 TPM_TRANSPORT_ATTRIBUTES; +typedef UINT32 TPM_AUTHHANDLE; +typedef UINT32 TPM_DIRINDEX; +typedef UINT32 TPM_KEY_HANDLE; +typedef UINT32 TPM_PCRINDEX; +typedef UINT32 TPM_RESULT; +typedef UINT32 TPM_RESOURCE_TYPE; +typedef UINT32 TPM_KEY_CONTROL; +typedef UINT32 TPM_NV_INDEX; +typedef UINT32 TPM_FAMILY_ID; +typedef UINT32 TPM_FAMILY_VERIFICATION; +typedef UINT32 TPM_STARTUP_EFFECTS; +typedef UINT32 TPM_SYM_MODE; +typedef UINT32 TPM_FAMILY_FLAGS; +typedef UINT32 TPM_DELEGATE_INDEX; +typedef UINT32 TPM_CMK_DELEGATE; +typedef UINT32 TPM_COUNT_ID; +typedef UINT32 TPM_REDIT_COMMAND; +typedef UINT32 TPM_TRANSHANDLE; +typedef UINT32 TPM_HANDLE; +typedef UINT32 TPM_FAMILY_OPERATION; + +// +// Part 2, section 2.2.4: Vendor specific +// The following defines allow for the quick specification of a +// vendor specific item. +// +#define TPM_Vendor_Specific32 ((UINT32) 0x00000400) +#define TPM_Vendor_Specific8 ((UINT8) 0x80) + +// +// Part 2, section 3.1: Structure TAGs +// +#define TPM_TAG_CONTEXTBLOB ((TPM_STRUCTURE_TAG) 0x0001) +#define TPM_TAG_CONTEXT_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0002) +#define TPM_TAG_CONTEXTPOINTER ((TPM_STRUCTURE_TAG) 0x0003) +#define TPM_TAG_CONTEXTLIST ((TPM_STRUCTURE_TAG) 0x0004) +#define TPM_TAG_SIGNINFO ((TPM_STRUCTURE_TAG) 0x0005) +#define TPM_TAG_PCR_INFO_LONG ((TPM_STRUCTURE_TAG) 0x0006) +#define TPM_TAG_PERSISTENT_FLAGS ((TPM_STRUCTURE_TAG) 0x0007) +#define TPM_TAG_VOLATILE_FLAGS ((TPM_STRUCTURE_TAG) 0x0008) +#define TPM_TAG_PERSISTENT_DATA ((TPM_STRUCTURE_TAG) 0x0009) +#define TPM_TAG_VOLATILE_DATA ((TPM_STRUCTURE_TAG) 0x000A) +#define TPM_TAG_SV_DATA ((TPM_STRUCTURE_TAG) 0x000B) +#define TPM_TAG_EK_BLOB ((TPM_STRUCTURE_TAG) 0x000C) +#define TPM_TAG_EK_BLOB_AUTH ((TPM_STRUCTURE_TAG) 0x000D) +#define TPM_TAG_COUNTER_VALUE ((TPM_STRUCTURE_TAG) 0x000E) +#define TPM_TAG_TRANSPORT_INTERNAL ((TPM_STRUCTURE_TAG) 0x000F) +#define TPM_TAG_TRANSPORT_LOG_IN ((TPM_STRUCTURE_TAG) 0x0010) +#define TPM_TAG_TRANSPORT_LOG_OUT ((TPM_STRUCTURE_TAG) 0x0011) +#define TPM_TAG_AUDIT_EVENT_IN ((TPM_STRUCTURE_TAG) 0x0012) +#define TPM_TAG_AUDIT_EVENT_OUT ((TPM_STRUCTURE_TAG) 0x0013) +#define TPM_TAG_CURRENT_TICKS ((TPM_STRUCTURE_TAG) 0x0014) +#define TPM_TAG_KEY ((TPM_STRUCTURE_TAG) 0x0015) +#define TPM_TAG_STORED_DATA12 ((TPM_STRUCTURE_TAG) 0x0016) +#define TPM_TAG_NV_ATTRIBUTES ((TPM_STRUCTURE_TAG) 0x0017) +#define TPM_TAG_NV_DATA_PUBLIC ((TPM_STRUCTURE_TAG) 0x0018) +#define TPM_TAG_NV_DATA_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0019) +#define TPM_TAG_DELEGATIONS ((TPM_STRUCTURE_TAG) 0x001A) +#define TPM_TAG_DELEGATE_PUBLIC ((TPM_STRUCTURE_TAG) 0x001B) +#define TPM_TAG_DELEGATE_TABLE_ROW ((TPM_STRUCTURE_TAG) 0x001C) +#define TPM_TAG_TRANSPORT_AUTH ((TPM_STRUCTURE_TAG) 0x001D) +#define TPM_TAG_TRANSPORT_PUBLIC ((TPM_STRUCTURE_TAG) 0x001E) +#define TPM_TAG_PERMANENT_FLAGS ((TPM_STRUCTURE_TAG) 0x001F) +#define TPM_TAG_STCLEAR_FLAGS ((TPM_STRUCTURE_TAG) 0x0020) +#define TPM_TAG_STANY_FLAGS ((TPM_STRUCTURE_TAG) 0x0021) +#define TPM_TAG_PERMANENT_DATA ((TPM_STRUCTURE_TAG) 0x0022) +#define TPM_TAG_STCLEAR_DATA ((TPM_STRUCTURE_TAG) 0x0023) +#define TPM_TAG_STANY_DATA ((TPM_STRUCTURE_TAG) 0x0024) +#define TPM_TAG_FAMILY_TABLE_ENTRY ((TPM_STRUCTURE_TAG) 0x0025) +#define TPM_TAG_DELEGATE_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0026) +#define TPM_TAG_DELG_KEY_BLOB ((TPM_STRUCTURE_TAG) 0x0027) +#define TPM_TAG_KEY12 ((TPM_STRUCTURE_TAG) 0x0028) +#define TPM_TAG_CERTIFY_INFO2 ((TPM_STRUCTURE_TAG) 0x0029) +#define TPM_TAG_DELEGATE_OWNER_BLOB ((TPM_STRUCTURE_TAG) 0x002A) +#define TPM_TAG_EK_BLOB_ACTIVATE ((TPM_STRUCTURE_TAG) 0x002B) +#define TPM_TAG_DAA_BLOB ((TPM_STRUCTURE_TAG) 0x002C) +#define TPM_TAG_DAA_CONTEXT ((TPM_STRUCTURE_TAG) 0x002D) +#define TPM_TAG_DAA_ENFORCE ((TPM_STRUCTURE_TAG) 0x002E) +#define TPM_TAG_DAA_ISSUER ((TPM_STRUCTURE_TAG) 0x002F) +#define TPM_TAG_CAP_VERSION_INFO ((TPM_STRUCTURE_TAG) 0x0030) +#define TPM_TAG_DAA_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0031) +#define TPM_TAG_DAA_TPM ((TPM_STRUCTURE_TAG) 0x0032) +#define TPM_TAG_CMK_MIGAUTH ((TPM_STRUCTURE_TAG) 0x0033) +#define TPM_TAG_CMK_SIGTICKET ((TPM_STRUCTURE_TAG) 0x0034) +#define TPM_TAG_CMK_MA_APPROVAL ((TPM_STRUCTURE_TAG) 0x0035) +#define TPM_TAG_QUOTE_INFO2 ((TPM_STRUCTURE_TAG) 0x0036) + +// +// Part 2, section 4: TPM Types +// + +// +// Part 2, section 4.1: TPM_RESOURCE_TYPE +// +#define TPM_RT_KEY ((TPM_RESOURCE_TYPE) 0x00000001) // The handle is a key handle and is the result of a LoadKey type operation +#define TPM_RT_AUTH ((TPM_RESOURCE_TYPE) 0x00000002) // The handle is an authorization handle. Auth handles come from TPM_OIAP, TPM_OSAP and TPM_DSAP +#define TPM_RT_HASH ((TPM_RESOURCE_TYPE) 0x00000003) // Reserved for hashes +#define TPM_RT_TRANS ((TPM_RESOURCE_TYPE) 0x00000004) // The handle is for a transport session. Transport handles come from TPM_EstablishTransport +#define TPM_RT_CONTEXT ((TPM_RESOURCE_TYPE) 0x00000005) // Resource wrapped and held outside the TPM using the context save/restore commands +#define TPM_RT_COUNTER ((TPM_RESOURCE_TYPE) 0x00000006) // Reserved for counters +#define TPM_RT_DELEGATE ((TPM_RESOURCE_TYPE) 0x00000007) // The handle is for a delegate row. These are the internal rows held in NV storage by the TPM +#define TPM_RT_DAA_TPM ((TPM_RESOURCE_TYPE) 0x00000008) // The value is a DAA TPM specific blob +#define TPM_RT_DAA_V0 ((TPM_RESOURCE_TYPE) 0x00000009) // The value is a DAA V0 parameter +#define TPM_RT_DAA_V1 ((TPM_RESOURCE_TYPE) 0x0000000A) // The value is a DAA V1 parameter + +// +// Part 2, section 4.2: TPM_PAYLOAD_TYPE +// +#define TPM_PT_ASYM ((TPM_PAYLOAD_TYPE) 0x01) // The entity is an asymmetric key +#define TPM_PT_BIND ((TPM_PAYLOAD_TYPE) 0x02) // The entity is bound data +#define TPM_PT_MIGRATE ((TPM_PAYLOAD_TYPE) 0x03) // The entity is a migration blob +#define TPM_PT_MAINT ((TPM_PAYLOAD_TYPE) 0x04) // The entity is a maintenance blob +#define TPM_PT_SEAL ((TPM_PAYLOAD_TYPE) 0x05) // The entity is sealed data +#define TPM_PT_MIGRATE_RESTRICTED ((TPM_PAYLOAD_TYPE) 0x06) // The entity is a restricted-migration asymmetric key +#define TPM_PT_MIGRATE_EXTERNAL ((TPM_PAYLOAD_TYPE) 0x07) // The entity is a external migratable key +#define TPM_PT_CMK_MIGRATE ((TPM_PAYLOAD_TYPE) 0x08) // The entity is a CMK migratable blob +#define TPM_PT_VENDOR_SPECIFIC ((TPM_PAYLOAD_TYPE) 0x80) // 0x80 - 0xFF Vendor specific payloads + +// +// Part 2, section 4.3: TPM_ENTIRY_TYPE +// +#define TPM_ET_KEYHANDLE ((UINT16) 0x0001) // The entity is a keyHandle or key +#define TPM_ET_OWNER ((UINT16) 0x0002) // The entity is the TPM Owner +#define TPM_ET_DATA ((UINT16) 0x0003) // The entity is some data +#define TPM_ET_SRK ((UINT16) 0x0004) // The entity is the SRK +#define TPM_ET_KEY ((UINT16) 0x0005) // The entity is a key or keyHandle +#define TPM_ET_REVOKE ((UINT16) 0x0006) // The entity is the RevokeTrust value +#define TPM_ET_DEL_OWNER_BLOB ((UINT16) 0x0007) // The entity is a delegate owner blob +#define TPM_ET_DEL_ROW ((UINT16) 0x0008) // The entity is a delegate row +#define TPM_ET_DEL_KEY_BLOB ((UINT16) 0x0009) // The entity is a delegate key blob +#define TPM_ET_COUNTER ((UINT16) 0x000A) // The entity is a counter +#define TPM_ET_NV ((UINT16) 0x000B) // The entity is a NV index +#define TPM_ET_RESERVED_HANDLE ((UINT16) 0x0040) // Reserved. This value avoids collisions with the handle MSB setting. +// +// TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable +// +#define TPM_ET_XOR ((UINT16) 0x0000) // ADIP encryption scheme: XOR +#define TPM_ET_AES128 ((UINT16) 0x0006) // ADIP encryption scheme: AES 128 bits + +// +// Part 2, section 4.4.1: Reserved Key Handles +// +#define TPM_KH_SRK ((TPM_KEY_HANDLE) 0x40000000) // The handle points to the SRK +#define TPM_KH_OWNER ((TPM_KEY_HANDLE) 0x40000001) // The handle points to the TPM Owner +#define TPM_KH_REVOKE ((TPM_KEY_HANDLE) 0x40000002) // The handle points to the RevokeTrust value +#define TPM_KH_TRANSPORT ((TPM_KEY_HANDLE) 0x40000003) // The handle points to the EstablishTransport static authorization +#define TPM_KH_OPERATOR ((TPM_KEY_HANDLE) 0x40000004) // The handle points to the Operator auth +#define TPM_KH_ADMIN ((TPM_KEY_HANDLE) 0x40000005) // The handle points to the delegation administration auth +#define TPM_KH_EK ((TPM_KEY_HANDLE) 0x40000006) // The handle points to the PUBEK, only usable with TPM_OwnerReadInternalPub + +// +// Part 2, section 4.5: TPM_STARTUP_TYPE +// +#define TPM_ST_CLEAR ((TPM_STARTUP_TYPE) 0x0001) // The TPM is starting up from a clean state +#define TPM_ST_STATE ((TPM_STARTUP_TYPE) 0x0002) // The TPM is starting up from a saved state +#define TPM_ST_DEACTIVATED ((TPM_STARTUP_TYPE) 0x0003) // The TPM is to startup and set the deactivated flag to TRUE + +// +// Part 2, section 4.6: TPM_STATUP_EFFECTS +// The table makeup is still an open issue. +// + +// +// Part 2, section 4.7: TPM_PROTOCOL_ID +// +#define TPM_PID_OIAP ((TPM_PROTOCOL_ID) 0x0001) // The OIAP protocol. +#define TPM_PID_OSAP ((TPM_PROTOCOL_ID) 0x0002) // The OSAP protocol. +#define TPM_PID_ADIP ((TPM_PROTOCOL_ID) 0x0003) // The ADIP protocol. +#define TPM_PID_ADCP ((TPM_PROTOCOL_ID) 0x0004) // The ADCP protocol. +#define TPM_PID_OWNER ((TPM_PROTOCOL_ID) 0x0005) // The protocol for taking ownership of a TPM. +#define TPM_PID_DSAP ((TPM_PROTOCOL_ID) 0x0006) // The DSAP protocol +#define TPM_PID_TRANSPORT ((TPM_PROTOCOL_ID) 0x0007) // The transport protocol + +// +// Part 2, section 4.8: TPM_ALGORITHM_ID +// The TPM MUST support the algorithms TPM_ALG_RSA, TPM_ALG_SHA, TPM_ALG_HMAC, +// TPM_ALG_MGF1 +// +#define TPM_ALG_RSA ((TPM_ALGORITHM_ID) 0x00000001) // The RSA algorithm. +#define TPM_ALG_DES ((TPM_ALGORITHM_ID) 0x00000002) // The DES algorithm +#define TPM_ALG_3DES ((TPM_ALGORITHM_ID) 0x00000003) // The 3DES algorithm in EDE mode +#define TPM_ALG_SHA ((TPM_ALGORITHM_ID) 0x00000004) // The SHA1 algorithm +#define TPM_ALG_HMAC ((TPM_ALGORITHM_ID) 0x00000005) // The RFC 2104 HMAC algorithm +#define TPM_ALG_AES128 ((TPM_ALGORITHM_ID) 0x00000006) // The AES algorithm, key size 128 +#define TPM_ALG_MGF1 ((TPM_ALGORITHM_ID) 0x00000007) // The XOR algorithm using MGF1 to create a string the size of the encrypted block +#define TPM_ALG_AES192 ((TPM_ALGORITHM_ID) 0x00000008) // AES, key size 192 +#define TPM_ALG_AES256 ((TPM_ALGORITHM_ID) 0x00000009) // AES, key size 256 +#define TPM_ALG_XOR ((TPM_ALGORITHM_ID) 0x0000000A) // XOR using the rolling nonces + +// +// Part 2, section 4.9: TPM_PHYSICAL_PRESENCE +// +#define TPM_PHYSICAL_PRESENCE_HW_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0200) // Sets the physicalPresenceHWEnable to FALSE +#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0100) // Sets the physicalPresenceCMDEnable to FALSE +#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0080) // Sets the physicalPresenceLifetimeLock to TRUE +#define TPM_PHYSICAL_PRESENCE_HW_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0040) // Sets the physicalPresenceHWEnable to TRUE +#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0020) // Sets the physicalPresenceCMDEnable to TRUE +#define TPM_PHYSICAL_PRESENCE_NOTPRESENT ((TPM_PHYSICAL_PRESENCE) 0x0010) // Sets PhysicalPresence = FALSE +#define TPM_PHYSICAL_PRESENCE_PRESENT ((TPM_PHYSICAL_PRESENCE) 0x0008) // Sets PhysicalPresence = TRUE +#define TPM_PHYSICAL_PRESENCE_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0004) // Sets PhysicalPresenceLock = TRUE + +// +// Part 2, section 4.10: TPM_MIGRATE_SCHEME +// +#define TPM_MS_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0001) // A public key that can be used with all TPM migration commands other than 'ReWrap' mode. +#define TPM_MS_REWRAP ((TPM_MIGRATE_SCHEME) 0x0002) // A public key that can be used for the ReWrap mode of TPM_CreateMigrationBlob. +#define TPM_MS_MAINT ((TPM_MIGRATE_SCHEME) 0x0003) // A public key that can be used for the Maintenance commands +#define TPM_MS_RESTRICT_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0004) // The key is to be migrated to a Migration Authority. +#define TPM_MS_RESTRICT_APPROVE_DOUBLE ((TPM_MIGRATE_SCHEME) 0x0005) // The key is to be migrated to an entity approved by a Migration Authority using double wrapping + +// +// Part 2, section 4.11: TPM_EK_TYPE +// +#define TPM_EK_TYPE_ACTIVATE ((TPM_EK_TYPE) 0x0001) // The blob MUST be TPM_EK_BLOB_ACTIVATE +#define TPM_EK_TYPE_AUTH ((TPM_EK_TYPE) 0x0002) // The blob MUST be TPM_EK_BLOB_AUTH + +// +// Part 2, section 4.12: TPM_PLATFORM_SPECIFIC +// +#define TPM_PS_PC_11 ((TPM_PLATFORM_SPECIFIC) 0x0001) // PC Specific version 1.1 +#define TPM_PS_PC_12 ((TPM_PLATFORM_SPECIFIC) 0x0002) // PC Specific version 1.2 +#define TPM_PS_PDA_12 ((TPM_PLATFORM_SPECIFIC) 0x0003) // PDA Specific version 1.2 +#define TPM_PS_Server_12 ((TPM_PLATFORM_SPECIFIC) 0x0004) // Server Specific version 1.2 +#define TPM_PS_Mobile_12 ((TPM_PLATFORM_SPECIFIC) 0x0005) // Mobil Specific version 1.2 + +// +// Part 2, section 5: Basic Structures +// + +// +// Part 2, section 5.1: TPM_STRUCT_VER +// +typedef struct tdTPM_STRUCT_VER { + UINT8 major; + UINT8 minor; + UINT8 revMajor; + UINT8 revMinor; +} TPM_STRUCT_VER; + +// +// Part 2, section 5.3: TPM_VERSION +// +typedef struct tdTPM_VERSION { + TPM_VERSION_BYTE major; + TPM_VERSION_BYTE minor; + UINT8 revMajor; + UINT8 revMinor; +} TPM_VERSION; + +// +// Part 2, section 5.4: TPM_DIGEST +// +#define TPM_SHA1_160_HASH_LEN 0x14 +#define TPM_SHA1BASED_NONCE_LEN TPM_SHA1_160_HASH_LEN + +typedef struct tdTPM_DIGEST{ + UINT8 digest[TPM_SHA1_160_HASH_LEN]; +} TPM_DIGEST; + +typedef TPM_DIGEST TPM_CHOSENID_HASH; // This SHALL be the digest of the chosen identityLabel and privacyCA for a new TPM identity. +typedef TPM_DIGEST TPM_COMPOSITE_HASH; // This SHALL be the hash of a list of PCR indexes and PCR values that a key or data is bound to. +typedef TPM_DIGEST TPM_DIRVALUE; // This SHALL be the value of a DIR register +typedef TPM_DIGEST TPM_HMAC; +typedef TPM_DIGEST TPM_PCRVALUE; // The value inside of the PCR +typedef TPM_DIGEST TPM_AUDITDIGEST; // This SHALL be the value of the current internal audit state +typedef TPM_DIGEST TPM_DAA_TPM_SEED; // This SHALL be a random value generated by a TPM immediately after the EK is installed in that TPM, whenever an EK is installed in that TPM +typedef TPM_DIGEST TPM_DAA_CONTEXT_SEED; // This SHALL be a random value + +// +// Part 2, section 5.5: TPM_NONCE +// +typedef struct tdTPM_NONCE{ + UINT8 nonce[20]; +} TPM_NONCE; + +// +// Part 2, section 5.6: TPM_AUTHDATA +// +typedef UINT8 tdTPM_AUTHDATA[20]; +typedef tdTPM_AUTHDATA TPM_AUTHDATA; +typedef TPM_AUTHDATA TPM_SECRET; +typedef TPM_AUTHDATA TPM_ENCAUTH; + +// +// Part 2, section 5.7: TPM_KEY_HANDLE_LIST +// Size of handle is loaded * sizeof(TPM_KEY_HANDLE) +// +typedef struct tdTPM_KEY_HANDLE_LIST { + UINT16 loaded; + TPM_KEY_HANDLE handle[1]; +} TPM_KEY_HANDLE_LIST; + +// +// Part 2, section 5.8: TPM_KEY_USAGE values +// + +#define TPM_KEY_SIGNING ((UINT16) 0x0010) +// TPM_KEY_SIGNING SHALL indicate a signing key. The [private] key SHALL be +// used for signing operations, only. This means that it MUST be a leaf of the +// Protected Storage key hierarchy. + +#define TPM_KEY_STORAGE ((UINT16) 0x0011) +// TPM_KEY_STORAGE SHALL indicate a storage key. The key SHALL be used to wrap +// and unwrap other keys in the Protected Storage hierarchy + +#define TPM_KEY_IDENTITY ((UINT16) 0x0012) +// TPM_KEY_IDENTITY SHALL indicate an identity key. The key SHALL be used for +// operations that require a TPM identity, only. + +#define TPM_KEY_AUTHCHANGE ((UINT16) 0x0013) +// TPM_KEY_AUTHCHANGE SHALL indicate an ephemeral key that is in use during +// the ChangeAuthAsym process, only. + +#define TPM_KEY_BIND ((UINT16) 0x0014) +// TPM_KEY_BIND SHALL indicate a key that can be used for TPM_Bind and +// TPM_Unbind operations only. + +#define TPM_KEY_LEGACY ((UINT16) 0x0015) +// TPM_KEY_LEGACY SHALL indicate a key that can perform signing and binding +// operations. The key MAY be used for both signing and binding operations. +// The TPM_KEY_LEGACY key type is to allow for use by applications where both +// signing and encryption operations occur with the same key. The use of this +// key type is not recommended TPM_KEY_MIGRATE 0x0016 This SHALL indicate a +// key in use for TPM_MigrateKey + +#define TPM_KEY_MIGRATE ((UINT16) 0x0016) +// TPM_KEY_MIGRAGE SHALL indicate a key in use for TPM_MigrateKey + +// +// Part 2, section 5.8.1: Encryption/Signature schemes +// + +#define TPM_ES_NONE ((TPM_ENC_SCHEME) 0x0001) +#define TPM_ES_RSAESPKCSv15 ((TPM_ENC_SCHEME) 0x0002) +#define TPM_ES_RSAESOAEP_SHA1_MGF1 ((TPM_ENC_SCHEME) 0x0003) +#define TPM_ES_SYM_CNT ((TPM_ENC_SCHEME) 0x0004) +#define TPM_ES_SYM_OFB ((TPM_ENC_SCHEME) 0x0005) + +#define TPM_SS_NONE ((TPM_SIG_SCHEME) 0x0001) +#define TPM_SS_RSASSAPKCS1v15_SHA1 ((TPM_SIG_SCHEME) 0x0002) +#define TPM_SS_RSASSAPKCS1v15_DER ((TPM_SIG_SCHEME) 0x0003) +#define TPM_SS_RSASSAPKCS1v15_INFO ((TPM_SIG_SCHEME) 0x0004) + +// +// Part 2, section 5.9: TPM_AUTH_DATA_USAGE values +// +#define TPM_AUTH_NEVER ((TPM_AUTH_DATA_USAGE) 0x00) +#define TPM_AUTH_ALWAYS ((TPM_AUTH_DATA_USAGE) 0x01) +#define TPM_AUTH_PRIV_USE_ONLY ((TPM_AUTH_DATA_USAGE) 0x03) + +// +// Part 2, section 5.10: TPM_KEY_FLAGS +// +enum tdTPM_KEY_FLAGS { + redirection = 0x00000001, + migratable = 0x00000002, + isVolatile = 0x00000004, + pcrIgnoredOnRead = 0x00000008, + migrateAuthority = 0x00000010 +}; + +// +// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE +// +typedef struct tdTPM_CHANGEAUTH_VALIDATE { + TPM_SECRET newAuthSecret; + TPM_NONCE n1; +} TPM_CHANGEAUTH_VALIDATE; + +// +// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH +// decalared after section 10 to catch declaration of TPM_PUBKEY +// +// Part 2 section 10.1: TPM_KEY_PARMS +// [size_is(parmSize)] BYTE* parms; +// +typedef struct tdTPM_KEY_PARMS { + TPM_ALGORITHM_ID algorithmID; + TPM_ENC_SCHEME encScheme; + TPM_SIG_SCHEME sigScheme; + UINT32 parmSize; + UINT8 *parms; +} TPM_KEY_PARMS; + +// +// Part 2, section 10.4: TPM_STORE_PUBKEY +// +typedef struct tdTPM_STORE_PUBKEY { + UINT32 keyLength; + UINT8 key[1]; +} TPM_STORE_PUBKEY; + +// +// Part 2, section 10.5: TPM_PUBKEY +// +typedef struct tdTPM_PUBKEY{ + TPM_KEY_PARMS algorithmParms; + TPM_STORE_PUBKEY pubKey; +} TPM_PUBKEY; + +// +// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH +// +typedef struct tdTPM_MIGRATIONKEYAUTH{ + TPM_PUBKEY migrationKey; + TPM_MIGRATE_SCHEME migrationScheme; + TPM_DIGEST digest; +} TPM_MIGRATIONKEYAUTH; + +// +// Part 2, section 5.13: TPM_COUNTER_VALUE +// +typedef struct tdTPM_COUNTER_VALUE{ + TPM_STRUCTURE_TAG tag; + UINT8 label[4]; + TPM_ACTUAL_COUNT counter; +} TPM_COUNTER_VALUE; + +// +// Part 2, section 5.14: TPM_SIGN_INFO +// Size of data indicated by dataLen +// +typedef struct tdTPM_SIGN_INFO { + TPM_STRUCTURE_TAG tag; + UINT8 fixed[4]; + TPM_NONCE replay; + UINT32 dataLen; + UINT8 *data; +} TPM_SIGN_INFO; + +// +// Part 2, section 5.15: TPM_MSA_COMPOSITE +// Number of migAuthDigest indicated by MSAlist +// +typedef struct tdTPM_MSA_COMPOSITE { + UINT32 MSAlist; + TPM_DIGEST migAuthDigest[1]; +} TPM_MSA_COMPOSITE; + +// +// Part 2, section 5.16: TPM_CMK_AUTH +// +typedef struct tdTPM_CMK_AUTH{ + TPM_DIGEST migrationAuthorityDigest; + TPM_DIGEST destinationKeyDigest; + TPM_DIGEST sourceKeyDigest; +} TPM_CMK_AUTH; + +// +// Part 2, section 5.17: TPM_CMK_DELEGATE +// +#define TPM_CMK_DELEGATE_SIGNING (((TPM_CMK_DELEGATE)1) << 31) +#define TPM_CMK_DELEGATE_STORAGE (((TPM_CMK_DELEGATE)1) << 30) +#define TPM_CMK_DELEGATE_BIND (((TPM_CMK_DELEGATE)1) << 29) +#define TPM_CMK_DELEGATE_LEGACY (((TPM_CMK_DELEGATE)1) << 28) +#define TPM_CMK_DELEGATE_MIGRATE (((TPM_CMK_DELEGATE)1) << 27) + +// +// Part 2, section 5.18: TPM_SELECT_SIZE +// +typedef struct tdTPM_SELECT_SIZE { + UINT8 major; + UINT8 minor; + UINT16 reqSize; +} TPM_SELECT_SIZE; + +// +// Part 2, section 5,19: TPM_CMK_MIGAUTH +// +typedef struct tdTPM_CMK_MIGAUTH{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST msaDigest; + TPM_DIGEST pubKeyDigest; +} TPM_CMK_MIGAUTH; + +// +// Part 2, section 5.20: TPM_CMK_SIGTICKET +// +typedef struct tdTPM_CMK_SIGTICKET{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST verKeyDigest; + TPM_DIGEST signedData; +} TPM_CMK_SIGTICKET; + +// +// Part 2, section 5.21: TPM_CMK_MA_APPROVAL +// +typedef struct tdTPM_CMK_MA_APPROVAL{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST migrationAuthorityDigest; +} TPM_CMK_MA_APPROVAL; + +// +// Part 2, section 6: Command Tags +// +#define TPM_TAG_RQU_COMMAND ((TPM_STRUCTURE_TAG) 0x00C1) +#define TPM_TAG_RQU_AUTH1_COMMAND ((TPM_STRUCTURE_TAG) 0x00C2) +#define TPM_TAG_RQU_AUTH2_COMMAND ((TPM_STRUCTURE_TAG) 0x00C3) +#define TPM_TAG_RSP_COMMAND ((TPM_STRUCTURE_TAG) 0x00C4) +#define TPM_TAG_RSP_AUTH1_COMMAND ((TPM_STRUCTURE_TAG) 0x00C5) +#define TPM_TAG_RSP_AUTH2_COMMAND ((TPM_STRUCTURE_TAG) 0x00C6) + +// +// Part 2, section 7.1: TPM_PERMANENT_FLAGS +// +typedef struct tdTPM_PERMANENT_FLAGS{ + TPM_STRUCTURE_TAG tag; + BOOLEAN disable; + BOOLEAN ownership; + BOOLEAN deactivated; + BOOLEAN readPubek; + BOOLEAN disableOwnerClear; + BOOLEAN allowMaintenance; + BOOLEAN physicalPresenceLifetimeLock; + BOOLEAN physicalPresenceHWEnable; + BOOLEAN physicalPresenceCMDEnable; + BOOLEAN CEKPUsed; + BOOLEAN TPMpost; + BOOLEAN TPMpostLock; + BOOLEAN FIPS; + BOOLEAN operator; + BOOLEAN enableRevokeEK; + BOOLEAN nvLocked; + BOOLEAN readSRKPub; + BOOLEAN tpmEstablished; + BOOLEAN maintenanceDone; +} TPM_PERMANENT_FLAGS; + +// +// Part 2, section 7.1.1: PERMANENT_FLAGS Subcap for SetCapability +// +#define TPM_PF_DISABLE ((TPM_CAPABILITY_AREA) 1) +#define TPM_PF_OWNERSHIP ((TPM_CAPABILITY_AREA) 2) +#define TPM_PF_DEACTIVATED ((TPM_CAPABILITY_AREA) 3) +#define TPM_PF_READPUBEK ((TPM_CAPABILITY_AREA) 4) +#define TPM_PF_DISABLEOWNERCLEAR ((TPM_CAPABILITY_AREA) 5) +#define TPM_PF_ALLOWMAINTENANCE ((TPM_CAPABILITY_AREA) 6) +#define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((TPM_CAPABILITY_AREA) 7) +#define TPM_PF_PHYSICALPRESENCEHWENABLE ((TPM_CAPABILITY_AREA) 8) +#define TPM_PF_PHYSICALPRESENCECMDENABLE ((TPM_CAPABILITY_AREA) 9) +#define TPM_PF_CEKPUSED ((TPM_CAPABILITY_AREA) 10) +#define TPM_PF_TPMPOST ((TPM_CAPABILITY_AREA) 11) +#define TPM_PF_TPMPOSTLOCK ((TPM_CAPABILITY_AREA) 12) +#define TPM_PF_FIPS ((TPM_CAPABILITY_AREA) 13) +#define TPM_PF_OPERATOR ((TPM_CAPABILITY_AREA) 14) +#define TPM_PF_ENABLEREVOKEEK ((TPM_CAPABILITY_AREA) 15) +#define TPM_PF_NV_LOCKED ((TPM_CAPABILITY_AREA) 16) +#define TPM_PF_READSRKPUB ((TPM_CAPABILITY_AREA) 17) +#define TPM_PF_TPMESTABLISHED ((TPM_CAPABILITY_AREA) 18) +#define TPM_PF_MAINTENANCEDONE ((TPM_CAPABILITY_AREA) 19) + +// +// Part 2, section 7.2: TPM_STCLEAR_FLAGS +// +typedef struct tdTPM_STCLEAR_FLAGS{ + TPM_STRUCTURE_TAG tag; + BOOLEAN deactivated; + BOOLEAN disableForceClear; + BOOLEAN physicalPresence; + BOOLEAN physicalPresenceLock; + BOOLEAN bGlobalLock; +} TPM_STCLEAR_FLAGS; + +// +// Part 2, section 7.2.1: STCLEAR_FLAGS Subcap for SetCapability +// +#define TPM_SF_DEACTIVATED ((TPM_CAPABILITY_AREA) 1) +#define TPM_SF_DISABLEFORCECLEAR ((TPM_CAPABILITY_AREA) 2) +#define TPM_SF_PHYSICALPRESENCE ((TPM_CAPABILITY_AREA) 3) +#define TPM_SF_PHYSICALPRESENCELOCK ((TPM_CAPABILITY_AREA) 4) +#define TPM_SF_BGLOBALLOCK ((TPM_CAPABILITY_AREA) 5) + +// +// Part 2, section 7.3: TPM_STANY_FLAGS +// +typedef struct tdTPM_STANY_FLAGS{ + TPM_STRUCTURE_TAG tag; + BOOLEAN postInitialise; + TPM_MODIFIER_INDICATOR localityModifier; + BOOLEAN transportExclusive; + BOOLEAN TOSPresent; +} TPM_STANY_FLAGS; + +// +// Part 2, section 7.3.1: STANY_FLAGS Subcap for SetCapability +// +#define TPM_AF_POSTINITIALISE ((TPM_CAPABILITY_AREA) 1) +#define TPM_AF_LOCALITYMODIFIER ((TPM_CAPABILITY_AREA) 2) +#define TPM_AF_TRANSPORTEXCLUSIVE ((TPM_CAPABILITY_AREA) 3) +#define TPM_AF_TOSPRESENT ((TPM_CAPABILITY_AREA) 4) + +// +// All those structures (section 7.4, 7.5, 7.6) are not normative and +// thus no definitions here +// +// Part 2, section 7.4: TPM_PERMANENT_DATA +// +//#define TPM_MIN_COUNTERS 4 // the minimum number of counters is 4 +//#define TPM_DELEGATE_KEY TPM_KEY +//#define TPM_NUM_PCR 16 +//#define TPM_MAX_NV_WRITE_NOOWNER 64 +//typedef struct tdTPM_PERMANENT_DATA +//{ +// TPM_STRUCTURE_TAG tag; +// UINT8 revMajor; +// UINT8 revMinor; +// TPM_NONCE tpmProof; +// TPM_NONCE ekReset; +// TPM_SECRET ownerAuth; +// TPM_SECRET operatorAuth; +// TPM_DIRVALUE authDIR[1]; +// TPM_PUBKEY manuMaintPub; +// TPM_KEY endorsementKey; +// TPM_KEY srk; +// TPM_KEY contextKey; +// TPM_KEY delegateKey; +// TPM_COUNTER_VALUE auditMonotonicCounter; +// TPM_COUNTER_VALUE monitonicCounter[TPM_MIN_COUNTERS]; +// TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR]; +// UINT8 ordinalAuditStatus[]; +// UINT8 *rngState; +// TPM_FAMILY_TABLE familyTable; +// TPM_DELEGATE_TABLE delegateTable; +// UINT32 maxNVBufSize; +// UINT32 lastFamilyID; +// UINT32 noOwnerNVWrite; +// TPM_CMK_DELEGATE restrictDelegate; +// TPM_DAA_TPM_SEED tpmDAASeed; +//} TPM_PERMANENT_DATA; + +// +// Part 2, section 7.5: TPM_STCLEAR_DATA +// available inside TPM only +// +//typedef struct tdTPM_STCLEAR_DATA +//{ +// TPM_STRUCTURE_TAG tag; +// TPM_NONCE contextNonceKey; +// TPM_COUNT_ID countID; +// UINT32 ownerReference; +// BOOLEAN disableResetLock; +//} TPM_STCLEAR_DATA; + +// +// Part 2, section 7.6: TPM_STANY_DATA +// available inside TPM only +// +//typedef struct tdTPM_STANY_DATA +//{ +// TPM_STRUCTURE_TAG tag; +// TPM_NONCE contextNonceSession; +// TPM_DIGEST auditDigest; +// TPM_CURRENT_TICKS currentTicks; +// UINT32 contextCount; +// UINT32 contextList[TPM_MIN_SESSION_LIST]; +// TPM_SESSION_DATA sessions[TPM_MIN_SESSIONS]; +//} TPM_STANY_DATA; + +// +// Part 2, section 8: PCR Structures +// + +// +// Part 2, section 8.1: TPM_PCR_SELECTION +// Size of pcrSelect[] indicated by sizeOfSelect +// +typedef struct tdTPM_PCR_SELECTION { + UINT16 sizeOfSelect; + UINT8 pcrSelect[1]; +} TPM_PCR_SELECTION; + +// +// Part 2, section 8.2: TPM_PCR_COMPOSITE +// Size of pcrValue[] indicated by valueSize +// +typedef struct tdTPM_PCR_COMPOSITE { + TPM_PCR_SELECTION select; + UINT32 valueSize; + TPM_PCRVALUE pcrValue[1]; +} TPM_PCR_COMPOSITE; + +// +// Part 2, section 8.3: TPM_PCR_INFO +// +typedef struct tdTPM_PCR_INFO { + TPM_PCR_SELECTION pcrSelection; + TPM_COMPOSITE_HASH digestAtRelease; + TPM_COMPOSITE_HASH digestAtCreation; +} TPM_PCR_INFO; + +// +// Part 2, section 8.6: TPM_LOCALITY_SELECTION +// +typedef UINT8 TPM_LOCALITY_SELECTION; + +#define TPM_LOC_FOUR ((UINT8) 0x10) +#define TPM_LOC_THREE ((UINT8) 0x08) +#define TPM_LOC_TWO ((UINT8) 0x04) +#define TPM_LOC_ONE ((UINT8) 0x02) +#define TPM_LOC_ZERO ((UINT8) 0x01) + +// +// Part 2, section 8.4: TPM_PCR_INFO_LONG +// +typedef struct tdTPM_PCR_INFO_LONG { + TPM_STRUCTURE_TAG tag; + TPM_LOCALITY_SELECTION localityAtCreation; + TPM_LOCALITY_SELECTION localityAtRelease; + TPM_PCR_SELECTION creationPCRSelection; + TPM_PCR_SELECTION releasePCRSelection; + TPM_COMPOSITE_HASH digestAtCreation; + TPM_COMPOSITE_HASH digestAtRelease; +} TPM_PCR_INFO_LONG; + +// +// Part 2, section 8.5: TPM_PCR_INFO_SHORT +// +typedef struct tdTPM_PCR_INFO_SHORT{ + TPM_PCR_SELECTION pcrSelection; + TPM_LOCALITY_SELECTION localityAtRelease; + TPM_COMPOSITE_HASH digestAtRelease; +} TPM_PCR_INFO_SHORT; + +// +// Part 2, section 8.8: TPM_PCR_ATTRIBUTES +// +typedef struct tdTPM_PCR_ATTRIBUTES{ + BOOLEAN pcrReset; + TPM_LOCALITY_SELECTION pcrExtendLocal; + TPM_LOCALITY_SELECTION pcrResetLocal; +} TPM_PCR_ATTRIBUTES; + +// +// Part 2, section 9: Storage Structures +// + +// +// Part 2, section 9.1: TPM_STORED_DATA +// [size_is(sealInfoSize)] BYTE* sealInfo; +// [size_is(encDataSize)] BYTE* encData; +// +typedef struct tdTPM_STORED_DATA { + TPM_STRUCT_VER ver; + UINT32 sealInfoSize; + UINT8 *sealInfo; + UINT32 encDataSize; + UINT8 *encData; +} TPM_STORED_DATA; + +// +// Part 2, section 9.2: TPM_STORED_DATA12 +// [size_is(sealInfoSize)] BYTE* sealInfo; +// [size_is(encDataSize)] BYTE* encData; +// +typedef struct tdTPM_STORED_DATA12 { + TPM_STRUCTURE_TAG tag; + TPM_ENTITY_TYPE et; + UINT32 sealInfoSize; + UINT8 *sealInfo; + UINT32 encDataSize; + UINT8 *encData; +} TPM_STORED_DATA12; + +// +// Part 2, section 9.3: TPM_SEALED_DATA +// [size_is(dataSize)] BYTE* data; +// +typedef struct tdTPM_SEALED_DATA { + TPM_PAYLOAD_TYPE payload; + TPM_SECRET authData; + TPM_NONCE tpmProof; + TPM_DIGEST storedDigest; + UINT32 dataSize; + UINT8 *data; +} TPM_SEALED_DATA; + +// +// Part 2, section 9.4: TPM_SYMMETRIC_KEY +// [size_is(size)] BYTE* data; +// +typedef struct tdTPM_SYMMETRIC_KEY { + TPM_ALGORITHM_ID algId; + TPM_ENC_SCHEME encScheme; + UINT16 dataSize; + UINT8 *data; +} TPM_SYMMETRIC_KEY; + +// +// Part 2, section 9.5: TPM_BOUND_DATA +// +typedef struct tdTPM_BOUND_DATA { + TPM_STRUCT_VER ver; + TPM_PAYLOAD_TYPE payload; + UINT8 payloadData[1]; +} TPM_BOUND_DATA; + +// +// Part 2 section 10: TPM_KEY complex +// + +// +// Part 2, section 10.2: TPM_KEY +// [size_is(encDataSize)] BYTE* encData; +// +typedef struct tdTPM_KEY{ + TPM_STRUCT_VER ver; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + UINT32 PCRInfoSize; + UINT8 *PCRInfo; + TPM_STORE_PUBKEY pubKey; + UINT32 encDataSize; + UINT8 *encData; +} TPM_KEY; + +// +// Part 2, section 10.3: TPM_KEY12 +// [size_is(encDataSize)] BYTE* encData; +// +typedef struct tdTPM_KEY12{ + TPM_STRUCTURE_TAG tag; + UINT16 fill; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + UINT32 PCRInfoSize; + UINT8 *PCRInfo; + TPM_STORE_PUBKEY pubKey; + UINT32 encDataSize; + UINT8 *encData; +} TPM_KEY12; + +// +// Part 2, section 10.7: TPM_STORE_PRIVKEY +// [size_is(keyLength)] BYTE* key; +// +typedef struct tdTPM_STORE_PRIVKEY { + UINT32 keyLength; + UINT8 *key; +} TPM_STORE_PRIVKEY; + +// +// Part 2, section 10.6: TPM_STORE_ASYMKEY +// +typedef struct tdTPM_STORE_ASYMKEY { // pos len total + TPM_PAYLOAD_TYPE payload; // 0 1 1 + TPM_SECRET usageAuth; // 1 20 21 + TPM_SECRET migrationAuth; // 21 20 41 + TPM_DIGEST pubDataDigest; // 41 20 61 + TPM_STORE_PRIVKEY privKey; // 61 132-151 193-214 +} TPM_STORE_ASYMKEY; + +// +// Part 2, section 10.8: TPM_MIGRATE_ASYMKEY +// [size_is(partPrivKeyLen)] BYTE* partPrivKey; +// +typedef struct tdTPM_MIGRATE_ASYMKEY { // pos len total + TPM_PAYLOAD_TYPE payload; // 0 1 1 + TPM_SECRET usageAuth; // 1 20 21 + TPM_DIGEST pubDataDigest; // 21 20 41 + UINT32 partPrivKeyLen; // 41 4 45 + UINT8 *partPrivKey; // 45 112-127 157-172 +} TPM_MIGRATE_ASYMKEY; + +// +// Part 2, section 10.9: TPM_KEY_CONTROL +// +#define TPM_KEY_CONTROL_OWNER_EVICT ((UINT32) 0x00000001) + +// +// Part 2, section 11: Signed Structures +// + +typedef struct tdTPM_CERTIFY_INFO +{ + TPM_STRUCT_VER version; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + TPM_DIGEST pubkeyDigest; + TPM_NONCE data; + BOOLEAN parentPCRStatus; + UINT32 PCRInfoSize; + UINT8 *PCRInfo; +} TPM_CERTIFY_INFO; + +typedef struct tdTPM_CERTIFY_INFO2 +{ + TPM_STRUCTURE_TAG tag; + UINT8 fill; + TPM_PAYLOAD_TYPE payloadType; + TPM_KEY_USAGE keyUsage; + TPM_KEY_FLAGS keyFlags; + TPM_AUTH_DATA_USAGE authDataUsage; + TPM_KEY_PARMS algorithmParms; + TPM_DIGEST pubkeyDigest; + TPM_NONCE data; + BOOLEAN parentPCRStatus; + UINT32 PCRInfoSize; + UINT8 *PCRInfo; + UINT32 migrationAuthoritySize; + UINT8 *migrationAuthority; +} TPM_CERTIFY_INFO2; + +typedef struct tdTPM_QUOTE_INFO +{ + TPM_STRUCT_VER version; + UINT8 fixed[4]; + TPM_COMPOSITE_HASH digestValue; + TPM_NONCE externalData; +} TPM_QUOTE_INFO; + +typedef struct tdTPM_QUOTE_INFO2 +{ + TPM_STRUCTURE_TAG tag; + UINT8 fixed[4]; + TPM_NONCE externalData; + TPM_PCR_INFO_SHORT infoShort; +} TPM_QUOTE_INFO2; + +// +// Part 2, section 12: Identity Structures +// + +typedef struct tdTPM_EK_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_EK_TYPE ekType; + UINT32 blobSize; + UINT8 *blob; +} TPM_EK_BLOB; + +typedef struct tdTPM_EK_BLOB_ACTIVATE +{ + TPM_STRUCTURE_TAG tag; + TPM_SYMMETRIC_KEY sessionKey; + TPM_DIGEST idDigest; + TPM_PCR_INFO_SHORT pcrInfo; +} TPM_EK_BLOB_ACTIVATE; + +typedef struct tdTPM_EK_BLOB_AUTH +{ + TPM_STRUCTURE_TAG tag; + TPM_SECRET authValue; +} TPM_EK_BLOB_AUTH; + + +// TPM_CHOSENID_HASH = SHA(identityLabel || privacyCA) +typedef TPM_DIGEST TPM_CHOSENID_HASH; + +typedef struct tdTPM_IDENTITY_CONTENTS +{ + TPM_STRUCT_VER ver; + UINT32 ordinal; + TPM_CHOSENID_HASH labelPrivCADigest; + TPM_PUBKEY identityPubKey; +} TPM_IDENTITY_CONTENTS; + +typedef struct tdTPM_IDENTITY_REQ +{ + UINT32 asymSize; + UINT32 symSize; + TPM_KEY_PARMS asymAlgorithm; + TPM_KEY_PARMS symAlgorithm; + UINT8 *asymBlob; + UINT8 *symBlob; +} TPM_IDENTITY_REQ; + +typedef struct tdTPM_IDENTITY_PROOF +{ + TPM_STRUCT_VER ver; + UINT32 labelSize; + UINT32 identityBindingSize; + UINT32 endorsementSize; + UINT32 platformSize; + UINT32 conformanceSize; + TPM_PUBKEY identityKey; + UINT8 *labelArea; + UINT8 *identityBinding; + UINT8 *endorsementCredential; + UINT8 *platformCredential; + UINT8 *conformanceCredential; +} TPM_IDENTITY_PROOF; + +typedef struct tdTPM_ASYM_CA_CONTENTS +{ + TPM_SYMMETRIC_KEY sessionKey; + TPM_DIGEST idDigest; +} TPM_ASYM_CA_CONTENTS; + +typedef struct tdTPM_SYM_CA_ATTESTATION +{ + UINT32 credSize; + TPM_KEY_PARMS algorithm; + UINT8 *credential; +} TPM_SYM_CA_ATTESTATION; + +// +// Part 2, section 15: TPM_CURRENT_TICKS +// Placed here out of order because definitions are used in section 13. +// +typedef struct tdTPM_CURRENT_TICKS { + TPM_STRUCTURE_TAG tag; + UINT64 currentTicks; + UINT16 tickRate; + TPM_NONCE tickNonce; +} TPM_CURRENT_TICKS; + +// +// Part 2, section 13: Transport structures +// + +#define TPM_TRANSPORT_ENCRYPT ((UINT32)0x00000001) +#define TPM_TRANSPORT_LOG ((UINT32)0x00000002) +#define TPM_TRANSPORT_EXCLUSIVE ((UINT32)0x00000004) + +typedef struct tdTPM_TRANSPORT_PUBLIC +{ + TPM_STRUCTURE_TAG tag; + TPM_TRANSPORT_ATTRIBUTES transAttributes; + TPM_ALGORITHM_ID algId; + TPM_ENC_SCHEME encScheme; +} TPM_TRANSPORT_PUBLIC; + +typedef struct tdTPM_TRANSPORT_INTERNAL +{ + TPM_STRUCTURE_TAG tag; + TPM_AUTHDATA authData; + TPM_TRANSPORT_PUBLIC transPublic; + TPM_TRANSHANDLE transHandle; + TPM_NONCE transNonceEven; + TPM_DIGEST transDigest; +} TPM_TRANSPORT_INTERNAL; + +typedef struct tdTPM_TRANSPORT_LOG_IN +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST parameters; + TPM_DIGEST pubKeyHash; +} TPM_TRANSPORT_LOG_IN; + +typedef struct tdTPM_TRANSPORT_LOG_OUT +{ + TPM_STRUCTURE_TAG tag; + TPM_CURRENT_TICKS currentTicks; + TPM_DIGEST parameters; + TPM_MODIFIER_INDICATOR locality; +} TPM_TRANSPORT_LOG_OUT; + +typedef struct tdTPM_TRANSPORT_AUTH +{ + TPM_STRUCTURE_TAG tag; + TPM_AUTHDATA authData; +} TPM_TRANSPORT_AUTH; + +// +// Part 2, section 14: Audit Structures +// + +typedef struct tdTPM_AUDIT_EVENT_IN +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST inputParms; + TPM_COUNTER_VALUE auditCount; +} TPM_AUDIT_EVENT_IN; + +typedef struct tdTPM_AUDIT_EVENT_OUT +{ + TPM_STRUCTURE_TAG tag; + TPM_COMMAND_CODE ordinal; + TPM_DIGEST outputParms; + TPM_COUNTER_VALUE auditCount; + TPM_RESULT returnCode; +} TPM_AUDIT_EVENT_OUT; + +// +// Part 2, section 16: Return Codes +// +#ifndef TPM_BASE +#error "TPM Error Codes require definition of TPM_BASE" +#endif + +#define TPM_VENDOR_ERROR TPM_Vendor_Specific32 +#define TPM_NON_FATAL 0x00000800 + +#define TPM_SUCCESS ((TPM_RESULT) TPM_BASE) +#define TPM_AUTHFAIL ((TPM_RESULT) (TPM_BASE + 1)) +#define TPM_BADINDEX ((TPM_RESULT) (TPM_BASE + 2)) +#define TPM_BAD_PARAMETER ((TPM_RESULT) (TPM_BASE + 3)) +#define TPM_AUDITFAILURE ((TPM_RESULT) (TPM_BASE + 4)) +#define TPM_CLEAR_DISABLED ((TPM_RESULT) (TPM_BASE + 5)) +#define TPM_DEACTIVATED ((TPM_RESULT) (TPM_BASE + 6)) +#define TPM_DISABLED ((TPM_RESULT) (TPM_BASE + 7)) +#define TPM_DISABLED_CMD ((TPM_RESULT) (TPM_BASE + 8)) +#define TPM_FAIL ((TPM_RESULT) (TPM_BASE + 9)) +#define TPM_BAD_ORDINAL ((TPM_RESULT) (TPM_BASE + 10)) +#define TPM_INSTALL_DISABLED ((TPM_RESULT) (TPM_BASE + 11)) +#define TPM_INVALID_KEYHANDLE ((TPM_RESULT) (TPM_BASE + 12)) +#define TPM_KEYNOTFOUND ((TPM_RESULT) (TPM_BASE + 13)) +#define TPM_INAPPROPRIATE_ENC ((TPM_RESULT) (TPM_BASE + 14)) +#define TPM_MIGRATEFAIL ((TPM_RESULT) (TPM_BASE + 15)) +#define TPM_INVALID_PCR_INFO ((TPM_RESULT) (TPM_BASE + 16)) +#define TPM_NOSPACE ((TPM_RESULT) (TPM_BASE + 17)) +#define TPM_NOSRK ((TPM_RESULT) (TPM_BASE + 18)) +#define TPM_NOTSEALED_BLOB ((TPM_RESULT) (TPM_BASE + 19)) +#define TPM_OWNER_SET ((TPM_RESULT) (TPM_BASE + 20)) +#define TPM_RESOURCES ((TPM_RESULT) (TPM_BASE + 21)) +#define TPM_SHORTRANDOM ((TPM_RESULT) (TPM_BASE + 22)) +#define TPM_SIZE ((TPM_RESULT) (TPM_BASE + 23)) +#define TPM_WRONGPCRVAL ((TPM_RESULT) (TPM_BASE + 24)) +#define TPM_BAD_PARAM_SIZE ((TPM_RESULT) (TPM_BASE + 25)) +#define TPM_SHA_THREAD ((TPM_RESULT) (TPM_BASE + 26)) +#define TPM_SHA_ERROR ((TPM_RESULT) (TPM_BASE + 27)) +#define TPM_FAILEDSELFTEST ((TPM_RESULT) (TPM_BASE + 28)) +#define TPM_AUTH2FAIL ((TPM_RESULT) (TPM_BASE + 29)) +#define TPM_BADTAG ((TPM_RESULT) (TPM_BASE + 30)) +#define TPM_IOERROR ((TPM_RESULT) (TPM_BASE + 31)) +#define TPM_ENCRYPT_ERROR ((TPM_RESULT) (TPM_BASE + 32)) +#define TPM_DECRYPT_ERROR ((TPM_RESULT) (TPM_BASE + 33)) +#define TPM_INVALID_AUTHHANDLE ((TPM_RESULT) (TPM_BASE + 34)) +#define TPM_NO_ENDORSEMENT ((TPM_RESULT) (TPM_BASE + 35)) +#define TPM_INVALID_KEYUSAGE ((TPM_RESULT) (TPM_BASE + 36)) +#define TPM_WRONG_ENTITYTYPE ((TPM_RESULT) (TPM_BASE + 37)) +#define TPM_INVALID_POSTINIT ((TPM_RESULT) (TPM_BASE + 38)) +#define TPM_INAPPROPRIATE_SIG ((TPM_RESULT) (TPM_BASE + 39)) +#define TPM_BAD_KEY_PROPERTY ((TPM_RESULT) (TPM_BASE + 40)) +#define TPM_BAD_MIGRATION ((TPM_RESULT) (TPM_BASE + 41)) +#define TPM_BAD_SCHEME ((TPM_RESULT) (TPM_BASE + 42)) +#define TPM_BAD_DATASIZE ((TPM_RESULT) (TPM_BASE + 43)) +#define TPM_BAD_MODE ((TPM_RESULT) (TPM_BASE + 44)) +#define TPM_BAD_PRESENCE ((TPM_RESULT) (TPM_BASE + 45)) +#define TPM_BAD_VERSION ((TPM_RESULT) (TPM_BASE + 46)) +#define TPM_NO_WRAP_TRANSPORT ((TPM_RESULT) (TPM_BASE + 47)) +#define TPM_AUDITFAIL_UNSUCCESSFUL ((TPM_RESULT) (TPM_BASE + 48)) +#define TPM_AUDITFAIL_SUCCESSFUL ((TPM_RESULT) (TPM_BASE + 49)) +#define TPM_NOTRESETABLE ((TPM_RESULT) (TPM_BASE + 50)) +#define TPM_NOTLOCAL ((TPM_RESULT) (TPM_BASE + 51)) +#define TPM_BAD_TYPE ((TPM_RESULT) (TPM_BASE + 52)) +#define TPM_INVALID_RESOURCE ((TPM_RESULT) (TPM_BASE + 53)) +#define TPM_NOTFIPS ((TPM_RESULT) (TPM_BASE + 54)) +#define TPM_INVALID_FAMILY ((TPM_RESULT) (TPM_BASE + 55)) +#define TPM_NO_NV_PERMISSION ((TPM_RESULT) (TPM_BASE + 56)) +#define TPM_REQUIRES_SIGN ((TPM_RESULT) (TPM_BASE + 57)) +#define TPM_KEY_NOTSUPPORTED ((TPM_RESULT) (TPM_BASE + 58)) +#define TPM_AUTH_CONFLICT ((TPM_RESULT) (TPM_BASE + 59)) +#define TPM_AREA_LOCKED ((TPM_RESULT) (TPM_BASE + 60)) +#define TPM_BAD_LOCALITY ((TPM_RESULT) (TPM_BASE + 61)) +#define TPM_READ_ONLY ((TPM_RESULT) (TPM_BASE + 62)) +#define TPM_PER_NOWRITE ((TPM_RESULT) (TPM_BASE + 63)) +#define TPM_FAMILYCOUNT ((TPM_RESULT) (TPM_BASE + 64)) +#define TPM_WRITE_LOCKED ((TPM_RESULT) (TPM_BASE + 65)) +#define TPM_BAD_ATTRIBUTES ((TPM_RESULT) (TPM_BASE + 66)) +#define TPM_INVALID_STRUCTURE ((TPM_RESULT) (TPM_BASE + 67)) +#define TPM_KEY_OWNER_CONTROL ((TPM_RESULT) (TPM_BASE + 68)) +#define TPM_BAD_COUNTER ((TPM_RESULT) (TPM_BASE + 69)) +#define TPM_NOT_FULLWRITE ((TPM_RESULT) (TPM_BASE + 70)) +#define TPM_CONTEXT_GAP ((TPM_RESULT) (TPM_BASE + 71)) +#define TPM_MAXNVWRITES ((TPM_RESULT) (TPM_BASE + 72)) +#define TPM_NOOPERATOR ((TPM_RESULT) (TPM_BASE + 73)) +#define TPM_RESOURCEMISSING ((TPM_RESULT) (TPM_BASE + 74)) +#define TPM_DELEGATE_LOCK ((TPM_RESULT) (TPM_BASE + 75)) +#define TPM_DELEGATE_FAMILY ((TPM_RESULT) (TPM_BASE + 76)) +#define TPM_DELEGATE_ADMIN ((TPM_RESULT) (TPM_BASE + 77)) +#define TPM_TRANSPORT_NOTEXCLUSIVE ((TPM_RESULT) (TPM_BASE + 78)) +#define TPM_OWNER_CONTROL ((TPM_RESULT) (TPM_BASE + 79)) +#define TPM_DAA_RESOURCES ((TPM_RESULT) (TPM_BASE + 80)) +#define TPM_DAA_INPUT_DATA0 ((TPM_RESULT) (TPM_BASE + 81)) +#define TPM_DAA_INPUT_DATA1 ((TPM_RESULT) (TPM_BASE + 82)) +#define TPM_DAA_ISSUER_SETTINGS ((TPM_RESULT) (TPM_BASE + 83)) +#define TPM_DAA_TPM_SETTINGS ((TPM_RESULT) (TPM_BASE + 84)) +#define TPM_DAA_STAGE ((TPM_RESULT) (TPM_BASE + 85)) +#define TPM_DAA_ISSUER_VALIDITY ((TPM_RESULT) (TPM_BASE + 86)) +#define TPM_DAA_WRONG_W ((TPM_RESULT) (TPM_BASE + 87)) +#define TPM_BAD_HANDLE ((TPM_RESULT) (TPM_BASE + 88)) +#define TPM_BAD_DELEGATE ((TPM_RESULT) (TPM_BASE + 89)) +#define TPM_BADCONTEXT ((TPM_RESULT) (TPM_BASE + 90)) +#define TPM_TOOMANYCONTEXTS ((TPM_RESULT) (TPM_BASE + 91)) +#define TPM_MA_TICKET_SIGNATURE ((TPM_RESULT) (TPM_BASE + 92)) +#define TPM_MA_DESTINATION ((TPM_RESULT) (TPM_BASE + 93)) +#define TPM_MA_SOURCE ((TPM_RESULT) (TPM_BASE + 94)) +#define TPM_MA_AUTHORITY ((TPM_RESULT) (TPM_BASE + 95)) +#define TPM_PERMANENTEK ((TPM_RESULT) (TPM_BASE + 97)) +#define TPM_BAD_SIGNATURE ((TPM_RESULT) (TPM_BASE + 98)) +#define TPM_NOCONTEXTSPACE ((TPM_RESULT) (TPM_BASE + 99)) + +#define TPM_RETRY ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL)) +#define TPM_NEEDS_SELFTEST ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 1)) +#define TPM_DOING_SELFTEST ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 2)) +#define TPM_DEFEND_LOCK_RUNNING ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 3)) + +// +// Part 2, section 17: Ordinals +// +// Ordinals are 32 bit values. The upper byte contains values that serve as +// flag indicators, the next byte contains values indicating what committee +// designated the ordinal, and the final two bytes contain the Command +// Ordinal Index. +// 3 2 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |P|C|V| Reserved| Purview | Command Ordinal Index | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// +// Where: +// +// * P is Protected/Unprotected command. When 0 the command is a Protected +// command, when 1 the command is an Unprotected command. +// +// * C is Non-Connection/Connection related command. When 0 this command +// passes through to either the protected (TPM) or unprotected (TSS) +// components. +// +// * V is TPM/Vendor command. When 0 the command is TPM defined, when 1 the +// command is vendor defined. +// +// * All reserved area bits are set to 0. +// + +#define TPM_ORD_ActivateIdentity ((TPM_COMMAND_CODE) 0x0000007A) +#define TPM_ORD_AuthorizeMigrationKey ((TPM_COMMAND_CODE) 0x0000002B) +#define TPM_ORD_CertifyKey ((TPM_COMMAND_CODE) 0x00000032) +#define TPM_ORD_CertifyKey2 ((TPM_COMMAND_CODE) 0x00000033) +#define TPM_ORD_CertifySelfTest ((TPM_COMMAND_CODE) 0x00000052) +#define TPM_ORD_ChangeAuth ((TPM_COMMAND_CODE) 0x0000000C) +#define TPM_ORD_ChangeAuthAsymFinish ((TPM_COMMAND_CODE) 0x0000000F) +#define TPM_ORD_ChangeAuthAsymStart ((TPM_COMMAND_CODE) 0x0000000E) +#define TPM_ORD_ChangeAuthOwner ((TPM_COMMAND_CODE) 0x00000010) +#define TPM_ORD_CMK_ApproveMA ((TPM_COMMAND_CODE) 0x0000001D) +#define TPM_ORD_CMK_ConvertMigration ((TPM_COMMAND_CODE) 0x00000024) +#define TPM_ORD_CMK_CreateBlob ((TPM_COMMAND_CODE) 0x0000001B) +#define TPM_ORD_CMK_CreateKey ((TPM_COMMAND_CODE) 0x00000013) +#define TPM_ORD_CMK_CreateTicket ((TPM_COMMAND_CODE) 0x00000012) +#define TPM_ORD_CMK_SetRestrictions ((TPM_COMMAND_CODE) 0x0000001C) +#define TPM_ORD_ContinueSelfTest ((TPM_COMMAND_CODE) 0x00000053) +#define TPM_ORD_ConvertMigrationBlob ((TPM_COMMAND_CODE) 0x0000002A) +#define TPM_ORD_CreateCounter ((TPM_COMMAND_CODE) 0x000000DC) +#define TPM_ORD_CreateEndorsementKeyPair ((TPM_COMMAND_CODE) 0x00000078) +#define TPM_ORD_CreateMaintenanceArchive ((TPM_COMMAND_CODE) 0x0000002C) +#define TPM_ORD_CreateMigrationBlob ((TPM_COMMAND_CODE) 0x00000028) +#define TPM_ORD_CreateRevocableEK ((TPM_COMMAND_CODE) 0x0000007F) +#define TPM_ORD_CreateWrapKey ((TPM_COMMAND_CODE) 0x0000001F) +#define TPM_ORD_DAA_JOIN ((TPM_COMMAND_CODE) 0x00000029) +#define TPM_ORD_DAA_SIGN ((TPM_COMMAND_CODE) 0x00000031) +#define TPM_ORD_Delegate_CreateKeyDelegation ((TPM_COMMAND_CODE) 0x000000D4) +#define TPM_ORD_Delegate_CreateOwnerDelegation ((TPM_COMMAND_CODE) 0x000000D5) +#define TPM_ORD_Delegate_LoadOwnerDelegation ((TPM_COMMAND_CODE) 0x000000D8) +#define TPM_ORD_Delegate_Manage ((TPM_COMMAND_CODE) 0x000000D2) +#define TPM_ORD_Delegate_ReadTable ((TPM_COMMAND_CODE) 0x000000DB) +#define TPM_ORD_Delegate_UpdateVerification ((TPM_COMMAND_CODE) 0x000000D1) +#define TPM_ORD_Delegate_VerifyDelegation ((TPM_COMMAND_CODE) 0x000000D6) +#define TPM_ORD_DirRead ((TPM_COMMAND_CODE) 0x0000001A) +#define TPM_ORD_DirWriteAuth ((TPM_COMMAND_CODE) 0x00000019) +#define TPM_ORD_DisableForceClear ((TPM_COMMAND_CODE) 0x0000005E) +#define TPM_ORD_DisableOwnerClear ((TPM_COMMAND_CODE) 0x0000005C) +#define TPM_ORD_DisablePubekRead ((TPM_COMMAND_CODE) 0x0000007E) +#define TPM_ORD_DSAP ((TPM_COMMAND_CODE) 0x00000011) +#define TPM_ORD_EstablishTransport ((TPM_COMMAND_CODE) 0x000000E6) +#define TPM_ORD_EvictKey ((TPM_COMMAND_CODE) 0x00000022) +#define TPM_ORD_ExecuteTransport ((TPM_COMMAND_CODE) 0x000000E7) +#define TPM_ORD_Extend ((TPM_COMMAND_CODE) 0x00000014) +#define TPM_ORD_FieldUpgrade ((TPM_COMMAND_CODE) 0x000000AA) +#define TPM_ORD_FlushSpecific ((TPM_COMMAND_CODE) 0x000000BA) +#define TPM_ORD_ForceClear ((TPM_COMMAND_CODE) 0x0000005D) +#define TPM_ORD_GetAuditDigest ((TPM_COMMAND_CODE) 0x00000085) +#define TPM_ORD_GetAuditDigestSigned ((TPM_COMMAND_CODE) 0x00000086) +#define TPM_ORD_GetAuditEvent ((TPM_COMMAND_CODE) 0x00000082) +#define TPM_ORD_GetAuditEventSigned ((TPM_COMMAND_CODE) 0x00000083) +#define TPM_ORD_GetCapability ((TPM_COMMAND_CODE) 0x00000065) +#define TPM_ORD_GetCapabilityOwner ((TPM_COMMAND_CODE) 0x00000066) +#define TPM_ORD_GetCapabilitySigned ((TPM_COMMAND_CODE) 0x00000064) +#define TPM_ORD_GetOrdinalAuditStatus ((TPM_COMMAND_CODE) 0x0000008C) +#define TPM_ORD_GetPubKey ((TPM_COMMAND_CODE) 0x00000021) +#define TPM_ORD_GetRandom ((TPM_COMMAND_CODE) 0x00000046) +#define TPM_ORD_GetTestResult ((TPM_COMMAND_CODE) 0x00000054) +#define TPM_ORD_GetTicks ((TPM_COMMAND_CODE) 0x000000F1) +#define TPM_ORD_IncrementCounter ((TPM_COMMAND_CODE) 0x000000DD) +#define TPM_ORD_Init ((TPM_COMMAND_CODE) 0x00000097) +#define TPM_ORD_KeyControlOwner ((TPM_COMMAND_CODE) 0x00000023) +#define TPM_ORD_KillMaintenanceFeature ((TPM_COMMAND_CODE) 0x0000002E) +#define TPM_ORD_LoadAuthContext ((TPM_COMMAND_CODE) 0x000000B7) +#define TPM_ORD_LoadContext ((TPM_COMMAND_CODE) 0x000000B9) +#define TPM_ORD_LoadKey ((TPM_COMMAND_CODE) 0x00000020) +#define TPM_ORD_LoadKey2 ((TPM_COMMAND_CODE) 0x00000041) +#define TPM_ORD_LoadKeyContext ((TPM_COMMAND_CODE) 0x000000B5) +#define TPM_ORD_LoadMaintenanceArchive ((TPM_COMMAND_CODE) 0x0000002D) +#define TPM_ORD_LoadManuMaintPub ((TPM_COMMAND_CODE) 0x0000002F) +#define TPM_ORD_MakeIdentity ((TPM_COMMAND_CODE) 0x00000079) +#define TPM_ORD_MigrateKey ((TPM_COMMAND_CODE) 0x00000025) +#define TPM_ORD_NV_DefineSpace ((TPM_COMMAND_CODE) 0x000000CC) +#define TPM_ORD_NV_ReadValue ((TPM_COMMAND_CODE) 0x000000CF) +#define TPM_ORD_NV_ReadValueAuth ((TPM_COMMAND_CODE) 0x000000D0) +#define TPM_ORD_NV_WriteValue ((TPM_COMMAND_CODE) 0x000000CD) +#define TPM_ORD_NV_WriteValueAuth ((TPM_COMMAND_CODE) 0x000000CE) +#define TPM_ORD_OIAP ((TPM_COMMAND_CODE) 0x0000000A) +#define TPM_ORD_OSAP ((TPM_COMMAND_CODE) 0x0000000B) +#define TPM_ORD_OwnerClear ((TPM_COMMAND_CODE) 0x0000005B) +#define TPM_ORD_OwnerReadInternalPub ((TPM_COMMAND_CODE) 0x00000081) +#define TPM_ORD_OwnerReadPubek ((TPM_COMMAND_CODE) 0x0000007D) +#define TPM_ORD_OwnerSetDisable ((TPM_COMMAND_CODE) 0x0000006E) +#define TPM_ORD_PCR_Reset ((TPM_COMMAND_CODE) 0x000000C8) +#define TPM_ORD_PcrRead ((TPM_COMMAND_CODE) 0x00000015) +#define TPM_ORD_PhysicalDisable ((TPM_COMMAND_CODE) 0x00000070) +#define TPM_ORD_PhysicalEnable ((TPM_COMMAND_CODE) 0x0000006F) +#define TPM_ORD_PhysicalSetDeactivated ((TPM_COMMAND_CODE) 0x00000072) +#define TPM_ORD_Quote ((TPM_COMMAND_CODE) 0x00000016) +#define TPM_ORD_Quote2 ((TPM_COMMAND_CODE) 0x0000003E) +#define TPM_ORD_ReadCounter ((TPM_COMMAND_CODE) 0x000000DE) +#define TPM_ORD_ReadManuMaintPub ((TPM_COMMAND_CODE) 0x00000030) +#define TPM_ORD_ReadPubek ((TPM_COMMAND_CODE) 0x0000007C) +#define TPM_ORD_ReleaseCounter ((TPM_COMMAND_CODE) 0x000000DF) +#define TPM_ORD_ReleaseCounterOwner ((TPM_COMMAND_CODE) 0x000000E0) +#define TPM_ORD_ReleaseTransportSigned ((TPM_COMMAND_CODE) 0x000000E8) +#define TPM_ORD_Reset ((TPM_COMMAND_CODE) 0x0000005A) +#define TPM_ORD_ResetLockValue ((TPM_COMMAND_CODE) 0x00000040) +#define TPM_ORD_RevokeTrust ((TPM_COMMAND_CODE) 0x00000080) +#define TPM_ORD_SaveAuthContext ((TPM_COMMAND_CODE) 0x000000B6) +#define TPM_ORD_SaveContext ((TPM_COMMAND_CODE) 0x000000B8) +#define TPM_ORD_SaveKeyContext ((TPM_COMMAND_CODE) 0x000000B4) +#define TPM_ORD_SaveState ((TPM_COMMAND_CODE) 0x00000098) +#define TPM_ORD_Seal ((TPM_COMMAND_CODE) 0x00000017) +#define TPM_ORD_Sealx ((TPM_COMMAND_CODE) 0x0000003D) +#define TPM_ORD_SelfTestFull ((TPM_COMMAND_CODE) 0x00000050) +#define TPM_ORD_SetCapability ((TPM_COMMAND_CODE) 0x0000003F) +#define TPM_ORD_SetOperatorAuth ((TPM_COMMAND_CODE) 0x00000074) +#define TPM_ORD_SetOrdinalAuditStatus ((TPM_COMMAND_CODE) 0x0000008D) +#define TPM_ORD_SetOwnerInstall ((TPM_COMMAND_CODE) 0x00000071) +#define TPM_ORD_SetOwnerPointer ((TPM_COMMAND_CODE) 0x00000075) +#define TPM_ORD_SetRedirection ((TPM_COMMAND_CODE) 0x0000009A) +#define TPM_ORD_SetTempDeactivated ((TPM_COMMAND_CODE) 0x00000073) +#define TPM_ORD_SHA1Complete ((TPM_COMMAND_CODE) 0x000000A2) +#define TPM_ORD_SHA1CompleteExtend ((TPM_COMMAND_CODE) 0x000000A3) +#define TPM_ORD_SHA1Start ((TPM_COMMAND_CODE) 0x000000A0) +#define TPM_ORD_SHA1Update ((TPM_COMMAND_CODE) 0x000000A1) +#define TPM_ORD_Sign ((TPM_COMMAND_CODE) 0x0000003C) +#define TPM_ORD_Startup ((TPM_COMMAND_CODE) 0x00000099) +#define TPM_ORD_StirRandom ((TPM_COMMAND_CODE) 0x00000047) +#define TPM_ORD_TakeOwnership ((TPM_COMMAND_CODE) 0x0000000D) +#define TPM_ORD_Terminate_Handle ((TPM_COMMAND_CODE) 0x00000096) +#define TPM_ORD_TickStampBlob ((TPM_COMMAND_CODE) 0x000000F2) +#define TPM_ORD_UnBind ((TPM_COMMAND_CODE) 0x0000001E) +#define TPM_ORD_Unseal ((TPM_COMMAND_CODE) 0x00000018) +#define TSC_ORD_PhysicalPresence ((TPM_COMMAND_CODE) 0x4000000A) +#define TSC_ORD_ResetEstablishmentBit ((TPM_COMMAND_CODE) 0x4000000B) + +// +// Part 2, section 18: Context structures +// + +typedef struct tdTPM_CONTEXT_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_RESOURCE_TYPE resourceType; + TPM_HANDLE handle; + UINT8 label[16]; + UINT32 contextCount; + TPM_DIGEST integrityDigest; + UINT32 additionalSize; + UINT8 *additionalData; + UINT32 sensitiveSize; + UINT8 *sensitiveData; +} TPM_CONTEXT_BLOB; + +typedef struct tdTPM_CONTEXT_SENSITIVE +{ + TPM_STRUCTURE_TAG tag; + TPM_NONCE contextNonce; + UINT32 internalSize; + UINT8 *internalData; +} TPM_CONTEXT_SENSITIVE; + +// +// Part 2, section 19: NV Structures +// + +#define TPM_NV_INDEX_LOCK ((UINT32)0xffffffff) +#define TPM_NV_INDEX0 ((UINT32)0x00000000) +#define TPM_NV_INDEX_DIR ((UINT32)0x10000001) +#define TPM_NV_INDEX_EKCert ((UINT32)0x0000f000) +#define TPM_NV_INDEX_TPM_CC ((UINT32)0x0000f001) +#define TPM_NV_INDEX_PlatformCert ((UINT32)0x0000f002) +#define TPM_NV_INDEX_Platform_CC ((UINT32)0x0000f003) +// The following define ranges of reserved indices. +#define TPM_NV_INDEX_TSS_BASE ((UINT32)0x00011100) +#define TPM_NV_INDEX_PC_BASE ((UINT32)0x00011200) +#define TPM_NV_INDEX_SERVER_BASE ((UINT32)0x00011300) +#define TPM_NV_INDEX_MOBILE_BASE ((UINT32)0x00011400) +#define TPM_NV_INDEX_PERIPHERAL_BASE ((UINT32)0x00011500) +#define TPM_NV_INDEX_GROUP_RESV_BASE ((UINT32)0x00010000) + +typedef UINT32 TPM_NV_PER_ATTRIBUTES; +// The typedefs TPM_NV_PER_ATTRIBUTES (not present in TPM 1.2 Spec. have been added +// and structure fields that were to hold the following values +#define TPM_NV_PER_READ_STCLEAR (((UINT32)1)<<31) +#define TPM_NV_PER_AUTHREAD (((UINT32)1)<<18) +#define TPM_NV_PER_OWNERREAD (((UINT32)1)<<17) +#define TPM_NV_PER_PPREAD (((UINT32)1)<<16) +#define TPM_NV_PER_GLOBALLOCK (((UINT32)1)<<15) +#define TPM_NV_PER_WRITE_STCLEAR (((UINT32)1)<<14) +#define TPM_NV_PER_WRITEDEFINE (((UINT32)1)<<13) +#define TPM_NV_PER_WRITEALL (((UINT32)1)<<12) +#define TPM_NV_PER_AUTHWRITE (((UINT32)1)<<2) +#define TPM_NV_PER_OWNERWRITE (((UINT32)1)<<1) +#define TPM_NV_PER_PPWRITE (((UINT32)1)<<0) + +typedef struct tdTPM_NV_ATTRIBUTES +{ + TPM_STRUCTURE_TAG tag; + TPM_NV_PER_ATTRIBUTES attributes; +} TPM_NV_ATTRIBUTES; + + +typedef struct tdTPM_NV_DATA_PUBLIC +{ + TPM_STRUCTURE_TAG tag; + TPM_NV_INDEX nvIndex; + TPM_PCR_INFO_SHORT pcrInfoRead; + TPM_PCR_INFO_SHORT pcrInfoWrite; + TPM_NV_ATTRIBUTES permission; + BOOLEAN bReadSTClear; + BOOLEAN bWriteSTClear; + BOOLEAN bWriteDefine; + UINT32 dataSize; +} TPM_NV_DATA_PUBLIC; + + + +// Internal to TPM: +//typedef struct tdTPM_NV_DATA_SENSITIVE +//{ +// TPM_STRUCTURE_TAG tag; +// TPM_NV_DATA_PUBLIC pubInfo; +// TPM_AUTHDATA authValue; +// UINT8 *data; +//} TPM_NV_DATA_SENSITIVE; + + +// +// Part 2, section 20: Delegation +// + +// +// Part 2, section 20.3: Owner Permissions Settings for per1 bits +// +#define TPM_DELEGATE_SetOrdinalAuditStatus (((UINT32)1)<<30) +#define TPM_DELEGATE_DirWriteAuth (((UINT32)1)<<29) +#define TPM_DELEGATE_CMK_ApproveMA (((UINT32)1)<<28) +#define TPM_DELEGATE_CMK_CreateTicket (((UINT32)1)<<26) +#define TPM_DELEGATE_Delegate_LoadOwnerDelegation (((UINT32)1)<<24) +#define TPM_DELEGATE_DAA_Join (((UINT32)1)<<23) +#define TPM_DELEGATE_AuthorizeMigrationKey (((UINT32)1)<<22) +#define TPM_DELEGATE_CreateMaintenanceArchive (((UINT32)1)<<21) +#define TPM_DELEGATE_LoadMaintenanceArchive (((UINT32)1)<<20) +#define TPM_DELEGATE_KillMaintenanceFeature (((UINT32)1)<<19) +#define TPM_DELEGATE_OwnerReadInteralPub (((UINT32)1)<<18) +#define TPM_DELEGATE_ResetLockValue (((UINT32)1)<<17) +#define TPM_DELEGATE_OwnerClear (((UINT32)1)<<16) +#define TPM_DELEGATE_DisableOwnerClear (((UINT32)1)<<15) +#define TPM_DELEGATE_OwnerSetDisable (((UINT32)1)<<13) +#define TPM_DELEGATE_SetCapability (((UINT32)1)<<12) +#define TPM_DELEGATE_MakeIdentity (((UINT32)1)<<11) +#define TPM_DELEGATE_ActivateIdentity (((UINT32)1)<<10) +#define TPM_DELEGATE_OwnerReadPubek (((UINT32)1)<<9) +#define TPM_DELEGATE_DisablePubekRead (((UINT32)1)<<8) +#define TPM_DELEGATE_SetRedirection (((UINT32)1)<<7) +#define TPM_DELEGATE_FieldUpgrade (((UINT32)1)<<6) +#define TPM_DELEGATE_Delegate_UpdateVerification (((UINT32)1)<<5) +#define TPM_DELEGATE_CreateCounter (((UINT32)1)<<4) +#define TPM_DELEGATE_ReleaseCounterOwner (((UINT32)1)<<3) +#define TPM_DELEGATE_DelegateManage (((UINT32)1)<<2) +#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1) +#define TPM_DELEGATE_DAA_Sign (((UINT32)1)<<0) + +// +// Part 2, section 20.3: Key Permissions Settings for per1 bits +// +#define TPM_KEY_DELEGATE_CMK_ConvertMigration (((UINT32)1)<<28) +#define TPM_KEY_DELEGATE_TickStampBlob (((UINT32)1)<<27) +#define TPM_KEY_DELEGATE_ChangeAuthAsymStart (((UINT32)1)<<26) +#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish (((UINT32)1)<<25) +#define TPM_KEY_DELEGATE_CMK_CreateKey (((UINT32)1)<<24) +#define TPM_KEY_DELEGATE_MigrateKey (((UINT32)1)<<23) +#define TPM_KEY_DELEGATE_LoadKey2 (((UINT32)1)<<22) +#define TPM_KEY_DELEGATE_EstablishTransport (((UINT32)1)<<21) +#define TPM_KEY_DELEGATE_ReleaseTransportSigned (((UINT32)1)<<20) +#define TPM_KEY_DELEGATE_Quote2 (((UINT32)1)<<19) +#define TPM_KEY_DELEGATE_Sealx (((UINT32)1)<<18) +#define TPM_KEY_DELEGATE_MakeIdentity (((UINT32)1)<<17) +#define TPM_KEY_DELEGATE_ActivateIdentity (((UINT32)1)<<16) +#define TPM_KEY_DELEGATE_GetAuditDigestSigned (((UINT32)1)<<15) +#define TPM_KEY_DELEGATE_Sign (((UINT32)1)<<14) +#define TPM_KEY_DELEGATE_CertifyKey2 (((UINT32)1)<<13) +#define TPM_KEY_DELEGATE_CertifyKey (((UINT32)1)<<12) +#define TPM_KEY_DELEGATE_CreateWrapKey (((UINT32)1)<<11) +#define TPM_KEY_DELEGATE_CMK_CreateBlob (((UINT32)1)<<10) +#define TPM_KEY_DELEGATE_CreateMigrationBlob (((UINT32)1)<<9) +#define TPM_KEY_DELEGATE_ConvertMigrationBlob (((UINT32)1)<<8) +#define TPM_KEY_DELEGATE_CreateKeyDelegation (((UINT32)1)<<7) +#define TPM_KEY_DELEGATE_ChangeAuth (((UINT32)1)<<6) +#define TPM_KEY_DELEGATE_GetPubKey (((UINT32)1)<<5) +#define TPM_KEY_DELEGATE_UnBind (((UINT32)1)<<4) +#define TPM_KEY_DELEGATE_Quote (((UINT32)1)<<3) +#define TPM_KEY_DELEGATE_Unseal (((UINT32)1)<<2) +#define TPM_KEY_DELEGATE_Seal (((UINT32)1)<<1) +#define TPM_KEY_DELEGATE_LoadKey (((UINT32)1)<<0) + +#define TPM_FAMILY_CREATE ((UINT32)0x00000001) +#define TPM_FAMILY_ENABLE ((UINT32)0x00000002) +#define TPM_FAMILY_ADMIN ((UINT32)0x00000003) +#define TPM_FAMILY_INVALIDATE ((UINT32)0x00000004) + +#define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK (((UINT32)1)<<1) +#define TPM_FAMFLAG_ENABLE (((UINT32)1)<<0) + +typedef struct tdTPM_FAMILY_LABEL +{ + UINT8 label; +} TPM_FAMILY_LABEL; + +typedef struct tdTPM_FAMILY_TABLE_ENTRY +{ + TPM_STRUCTURE_TAG tag; + TPM_FAMILY_LABEL label; + TPM_FAMILY_ID familyID; + TPM_FAMILY_VERIFICATION verificationCount; + TPM_FAMILY_FLAGS flags; +} TPM_FAMILY_TABLE_ENTRY; + +#define TPM_FAMILY_TABLE_ENTRY_MIN 8 +//typedef struct tdTPM_FAMILY_TABLE +//{ +// TPM_FAMILY_TABLE_ENTRY FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN]; +//} TPM_FAMILY_TABLE; + + +typedef struct tdTPM_DELEGATE_LABEL +{ + UINT8 label; +} TPM_DELEGATE_LABEL; + + +typedef UINT32 TPM_DELEGATE_TYPE; +#define TPM_DEL_OWNER_BITS ((UINT32)0x00000001) +#define TPM_DEL_KEY_BITS ((UINT32)0x00000002) + +typedef struct tdTPM_DELEGATIONS +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_TYPE delegateType; + UINT32 per1; + UINT32 per2; +} TPM_DELEGATIONS; + +typedef struct tdTPM_DELEGATE_PUBLIC +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_LABEL label; + TPM_PCR_INFO_SHORT pcrInfo; + TPM_DELEGATIONS permissions; + TPM_FAMILY_ID familyID; + TPM_FAMILY_VERIFICATION verificationCount; +} TPM_DELEGATE_PUBLIC; + +typedef struct tdTPM_DELEGATE_TABLE_ROW +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_SECRET authValue; +} TPM_DELEGATE_TABLE_ROW; + + +#define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2 +//typedef struct tdTPM_DELEGATE_TABLE +//{ +// TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN]; +//} TPM_DELEGATE_TABLE; + +typedef struct tdTPM_DELEGATE_SENSITIVE +{ + TPM_STRUCTURE_TAG tag; + TPM_SECRET authValue; +} TPM_DELEGATE_SENSITIVE; + +typedef struct tdTPM_DELEGATE_OWNER_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_DIGEST integrityDigest; + UINT32 additionalSize; + UINT8 *additionalArea; + UINT32 sensitiveSize; + UINT8 *sensitiveArea; +} TPM_DELEGATE_OWNER_BLOB; + +typedef struct tdTPM_DELEGATE_KEY_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_DELEGATE_PUBLIC pub; + TPM_DIGEST integrityDigest; + TPM_DIGEST pubKeyDigest; + UINT32 additionalSize; + UINT8 *additionalArea; + UINT32 sensitiveSize; + UINT8 *sensitiveArea; +} TPM_DELEGATE_KEY_BLOB; + +// +// Part 2, section 21.1: TPM_CAPABILITY_AREA for GetCapability +// +#define TPM_CAP_ORD ((TPM_CAPABILITY_AREA) 0x00000001) +#define TPM_CAP_ALG ((TPM_CAPABILITY_AREA) 0x00000002) +#define TPM_CAP_PID ((TPM_CAPABILITY_AREA) 0x00000003) +#define TPM_CAP_FLAG ((TPM_CAPABILITY_AREA) 0x00000004) +#define TPM_CAP_PROPERTY ((TPM_CAPABILITY_AREA) 0x00000005) +#define TPM_CAP_VERSION ((TPM_CAPABILITY_AREA) 0x00000006) +#define TPM_CAP_KEY_HANDLE ((TPM_CAPABILITY_AREA) 0x00000007) +#define TPM_CAP_CHECK_LOADED ((TPM_CAPABILITY_AREA) 0x00000008) +#define TPM_CAP_SYM_MODE ((TPM_CAPABILITY_AREA) 0x00000009) +#define TPM_CAP_KEY_STATUS ((TPM_CAPABILITY_AREA) 0x0000000C) +#define TPM_CAP_NV_LIST ((TPM_CAPABILITY_AREA) 0x0000000D) +#define TPM_CAP_MFR ((TPM_CAPABILITY_AREA) 0x00000010) +#define TPM_CAP_NV_INDEX ((TPM_CAPABILITY_AREA) 0x00000011) +#define TPM_CAP_TRANS_ALG ((TPM_CAPABILITY_AREA) 0x00000012) +#define TPM_CAP_HANDLE ((TPM_CAPABILITY_AREA) 0x00000014) +#define TPM_CAP_TRANS_ES ((TPM_CAPABILITY_AREA) 0x00000015) +#define TPM_CAP_AUTH_ENCRYPT ((TPM_CAPABILITY_AREA) 0x00000017) +#define TPM_CAP_SELECT_SIZE ((TPM_CAPABILITY_AREA) 0x00000018) +#define TPM_CAP_VERSION_VAL ((TPM_CAPABILITY_AREA) 0x0000001A) + +#define TPM_CAP_FLAG_PERMANENT ((TPM_CAPABILITY_AREA) 0x00000108) +#define TPM_CAP_FLAG_VOLATILE ((TPM_CAPABILITY_AREA) 0x00000109) + +// +// Part 2, section 21.2: CAP_PROPERTY Subcap values for GetCapability +// +#define TPM_CAP_PROP_PCR ((TPM_CAPABILITY_AREA) 0x00000101) +#define TPM_CAP_PROP_DIR ((TPM_CAPABILITY_AREA) 0x00000102) +#define TPM_CAP_PROP_MANUFACTURER ((TPM_CAPABILITY_AREA) 0x00000103) +#define TPM_CAP_PROP_KEYS ((TPM_CAPABILITY_AREA) 0x00000104) +#define TPM_CAP_PROP_MIN_COUNTER ((TPM_CAPABILITY_AREA) 0x00000107) +#define TPM_CAP_PROP_AUTHSESS ((TPM_CAPABILITY_AREA) 0x0000010A) +#define TPM_CAP_PROP_TRANSESS ((TPM_CAPABILITY_AREA) 0x0000010B) +#define TPM_CAP_PROP_COUNTERS ((TPM_CAPABILITY_AREA) 0x0000010C) +#define TPM_CAP_PROP_MAX_AUTHSESS ((TPM_CAPABILITY_AREA) 0x0000010D) +#define TPM_CAP_PROP_MAX_TRANSESS ((TPM_CAPABILITY_AREA) 0x0000010E) +#define TPM_CAP_PROP_MAX_COUNTERS ((TPM_CAPABILITY_AREA) 0x0000010F) +#define TPM_CAP_PROP_MAX_KEYS ((TPM_CAPABILITY_AREA) 0x00000110) +#define TPM_CAP_PROP_OWNER ((TPM_CAPABILITY_AREA) 0x00000111) +#define TPM_CAP_PROP_CONTEXT ((TPM_CAPABILITY_AREA) 0x00000112) +#define TPM_CAP_PROP_MAX_CONTEXT ((TPM_CAPABILITY_AREA) 0x00000113) +#define TPM_CAP_PROP_FAMILYROWS ((TPM_CAPABILITY_AREA) 0x00000114) +#define TPM_CAP_PROP_TIS_TIMEOUT ((TPM_CAPABILITY_AREA) 0x00000115) +#define TPM_CAP_PROP_STARTUP_EFFECT ((TPM_CAPABILITY_AREA) 0x00000116) +#define TPM_CAP_PROP_DELEGATE_ROW ((TPM_CAPABILITY_AREA) 0x00000117) +#define TPM_CAP_PROP_DAA_MAX ((TPM_CAPABILITY_AREA) 0x00000119) +#define CAP_PROP_SESSION_DAA ((TPM_CAPABILITY_AREA) 0x0000011A) +#define TPM_CAP_PROP_CONTEXT_DIST ((TPM_CAPABILITY_AREA) 0x0000011B) +#define TPM_CAP_PROP_DAA_INTERRUPT ((TPM_CAPABILITY_AREA) 0x0000011C) +#define TPM_CAP_PROP_SESSIONS ((TPM_CAPABILITY_AREA) 0x0000011D) +#define TPM_CAP_PROP_MAX_SESSIONS ((TPM_CAPABILITY_AREA) 0x0000011E) +#define TPM_CAP_PROP_CMK_RESTRICTION ((TPM_CAPABILITY_AREA) 0x0000011F) +#define TPM_CAP_PROP_DURATION ((TPM_CAPABILITY_AREA) 0x00000120) +#define TPM_CAP_PROP_ACTIVE_COUNTER ((TPM_CAPABILITY_AREA) 0x00000122) +#define TPM_CAP_PROP_MAX_NV_AVAILABLE ((TPM_CAPABILITY_AREA) 0x00000123) +#define TPM_CAP_PROP_INPUT_BUFFER ((TPM_CAPABILITY_AREA) 0x00000124) + +// +// Part 2, section 21.6: TPM_CAP_VERSION_INFO +// [size_is(vendorSpecificSize)] BYTE* vendorSpecific; +// +typedef struct tdTPM_CAP_VERSION_INFO { + TPM_STRUCTURE_TAG tag; + TPM_VERSION version; + UINT16 specLevel; + UINT8 errataRev; + UINT8 tpmVendorID[4]; + UINT16 vendorSpecificSize; + UINT8 *vendorSpecific; +} TPM_CAP_VERSION_INFO; + +// +// Part 2, section 22: DAA Structures +// + +#define TPM_DAA_SIZE_r0 (43) +#define TPM_DAA_SIZE_r1 (43) +#define TPM_DAA_SIZE_r2 (128) +#define TPM_DAA_SIZE_r3 (168) +#define TPM_DAA_SIZE_r4 (219) +#define TPM_DAA_SIZE_NT (20) +#define TPM_DAA_SIZE_v0 (128) +#define TPM_DAA_SIZE_v1 (192) +#define TPM_DAA_SIZE_NE (256) +#define TPM_DAA_SIZE_w (256) +#define TPM_DAA_SIZE_issuerModulus (256) +#define TPM_DAA_power0 (104) +#define TPM_DAA_power1 (1024) + +typedef struct tdTPM_DAA_ISSUER +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digest_R0; + TPM_DIGEST DAA_digest_R1; + TPM_DIGEST DAA_digest_S0; + TPM_DIGEST DAA_digest_S1; + TPM_DIGEST DAA_digest_n; + TPM_DIGEST DAA_digest_gamma; + UINT8 DAA_generic_q[26]; +} TPM_DAA_ISSUER; + + +typedef struct tdTPM_DAA_TPM +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digestIssuer; + TPM_DIGEST DAA_digest_v0; + TPM_DIGEST DAA_digest_v1; + TPM_DIGEST DAA_rekey; + UINT32 DAA_count; +} TPM_DAA_TPM; + +typedef struct tdTPM_DAA_CONTEXT +{ + TPM_STRUCTURE_TAG tag; + TPM_DIGEST DAA_digestContext; + TPM_DIGEST DAA_digest; + TPM_DAA_CONTEXT_SEED DAA_contextSeed; + UINT8 DAA_scratch[256]; + UINT8 DAA_stage; +} TPM_DAA_CONTEXT; + +typedef struct tdTPM_DAA_JOINDATA +{ + UINT8 DAA_join_u0[128]; + UINT8 DAA_join_u1[138]; + TPM_DIGEST DAA_digest_n0; +} TPM_DAA_JOINDATA; + +typedef struct tdTPM_DAA_BLOB +{ + TPM_STRUCTURE_TAG tag; + TPM_RESOURCE_TYPE resourceType; + UINT8 label[16]; + TPM_DIGEST blobIntegrity; + UINT32 additionalSize; + UINT8 *additionalData; + UINT32 sensitiveSize; + UINT8 *sensitiveData; +} TPM_DAA_BLOB; + +typedef struct tdTPM_DAA_SENSITIVE +{ + TPM_STRUCTURE_TAG tag; + UINT32 internalSize; + UINT8 *internalData; +} TPM_DAA_SENSITIVE; + + +// +// Part 2, section 23: Redirection +// + +// This section of the TPM spec defines exactly one value but does not +// give it a name. The definition of TPM_SetRedirection in Part3 +// refers to exactly one name but does not give its value. We join +// them here. +#define TPM_REDIR_GPIO (0x00000001) + +// +// TPM Command & Response Headers +// +typedef struct tdTPM_RQU_COMMAND_HDR { + TPM_STRUCTURE_TAG tag; + UINT32 paramSize; + TPM_COMMAND_CODE ordinal; +} TPM_RQU_COMMAND_HDR; + +typedef struct tdTPM_RSP_COMMAND_HDR { + TPM_STRUCTURE_TAG tag; + UINT32 paramSize; + TPM_RESULT returnCode; +} TPM_RSP_COMMAND_HDR; + +#pragma pack (pop) + +#endif // _TPM12_H_ diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h new file mode 100644 index 0000000000..8a23e7e07e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h @@ -0,0 +1,94 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WatchdogDescriptionTable.h + +Abstract: + + ACPI Watchdog Description Table as defined in Intel + ICH Family Watchdog Timer (WDT) Application Note (AP-725) + +--*/ + +#ifndef _WATCH_DOG_DESCRIPTION_TABLE_H_ +#define _WATCH_DOG_DESCRIPTION_TABLE_H_ + +// +// Include files +// +#include "Acpi2_0.h" + +// +// Ensure proper structure formats +// +#pragma pack(1) +// +// WDDT structure +// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT16 SpecVersion; + UINT16 TableVersion; + UINT16 Vid; + EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE BaseAddress; + UINT16 TimerMaxCount; + UINT16 TimerMinCount; + UINT16 TimerCountPeriod; + UINT16 Status; + UINT16 Capability; +} EFI_ACPI_1_0_WATCH_DOG_DESCRIPTION_TABLE; + +// +// "WDDT" Watchdog Description Table signatures +// +#define EFI_ACPI_1_0_WDDT_SIGNATURE 0x54444457 + +#pragma pack() + +// +// WDDT Revision +// +#define EFI_ACPI_WATCHDOG_DESCRIPTION_1_0_TABLE_REVISION 0x01 + +// +// WDDT Spec Version +// +#define EFI_ACPI_WDDT_SPEC_1_0_VERSION 0x01 + +// +// WDDT Description Table Version +// +#define EFI_ACPI_WDDT_TABLE_1_0_VERSION 0x01 + +// +// WDT Status +// +#define EFI_ACPI_WDDT_STATUS_AVAILABLE 0x0001 +#define EFI_ACPI_WDDT_STATUS_ACTIVE 0x0002 +#define EFI_ACPI_WDDT_STATUS_OWNED_BY_BIOS 0x0000 +#define EFI_ACPI_WDDT_STATUS_OWNED_BY_OS 0x0004 +#define EFI_ACPI_WDDT_STATUS_USER_RESET_EVENT 0x0800 +#define EFI_ACPI_WDDT_STATUS_WDT_EVENT 0x1000 +#define EFI_ACPI_WDDT_STATUS_POWER_FAIL_EVENT 0x2000 +#define EFI_ACPI_WDDT_STATUS_UNKNOWN_RESET_EVENT 0x4000 + +// +// WDT Capability +// +#define EFI_ACPI_WDDT_CAPABILITY_AUTO_RESET 0x0001 +#define EFI_ACPI_WDDT_CAPABILITY_ALERT_SUPPORT 0x0002 +#define EFI_ACPI_WDDT_CAPABILITY_PLATFORM_SHUTDOWN 0x0004 +#define EFI_ACPI_WDDT_CAPABILITY_IMMEDIATE_SHUTDOWN 0x0008 +#define EFI_ACPI_WDDT_CAPABILITY_BIOS_HANDOFF_SUPPORT 0x0010 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/atapi.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/atapi.h new file mode 100644 index 0000000000..3fcc287a5a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/atapi.h @@ -0,0 +1,331 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Atapi.h + +Abstract: + + +Revision History +--*/ + +#ifndef _ATAPI_H +#define _ATAPI_H + +#include "Tiano.h" + +#pragma pack(1) + +typedef struct { + UINT16 config; /* General Configuration */ + UINT16 cylinders; /* Number of Cylinders */ + UINT16 reserved_2; + UINT16 heads; /* Number of logical heads */ + UINT16 vendor_data1; + UINT16 vendoe_data2; + UINT16 sectors_per_track; + UINT16 vendor_specific_7_9[3]; + CHAR8 SerialNo[20]; /* ASCII */ + UINT16 vendor_specific_20_21[2]; + UINT16 ecc_bytes_available; + CHAR8 FirmwareVer[8]; /* ASCII */ + CHAR8 ModelName[40]; /* ASCII */ + UINT16 multi_sector_cmd_max_sct_cnt; + UINT16 reserved_48; + UINT16 capabilities; + UINT16 reserved_50; + UINT16 pio_cycle_timing; + UINT16 reserved_52; + UINT16 field_validity; + UINT16 current_cylinders; + UINT16 current_heads; + UINT16 current_sectors; + UINT16 CurrentCapacityLsb; + UINT16 CurrentCapacityMsb; + UINT16 reserved_59; + UINT16 user_addressable_sectors_lo; + UINT16 user_addressable_sectors_hi; + UINT16 reserved_62; + UINT16 multi_word_dma_mode; + UINT16 advanced_pio_modes; + UINT16 min_multi_word_dma_cycle_time; + UINT16 rec_multi_word_dma_cycle_time; + UINT16 min_pio_cycle_time_without_flow_control; + UINT16 min_pio_cycle_time_with_flow_control; + UINT16 reserved_69_79[11]; + UINT16 major_version_no; + UINT16 minor_version_no; + UINT16 reserved_82_127[46]; + UINT16 security_status; + UINT16 vendor_data_129_159[31]; + UINT16 reserved_160_255[96]; +} IDENTIFY; + +typedef struct { + UINT8 peripheral_type; + UINT8 RMB; + UINT8 version; + UINT8 response_data_format; + UINT8 addnl_length; + UINT8 reserved_5; + UINT8 reserved_6; + UINT8 reserved_7; + UINT8 vendor_info[8]; + UINT8 product_id[12]; + UINT8 eeprom_product_code[4]; + UINT8 firmware_rev_level[4]; + UINT8 firmware_sub_rev_level[1]; + UINT8 reserved_37; + UINT8 reserved_38; + UINT8 reserved_39; + UINT8 max_capacity_hi; + UINT8 max_capacity_mid; + UINT8 max_capacity_lo; + UINT8 reserved_43_95[95 - 43 + 1]; + UINT8 vendor_id[20]; + UINT8 eeprom_drive_sno[12]; +} INQUIRY_DATA; + +typedef struct { + UINT8 error_code : 7; + UINT8 valid : 1; + UINT8 reserved_1; + UINT8 sense_key : 4; + UINT8 reserved_21 : 1; + UINT8 ILI : 1; + UINT8 reserved_22 : 2; + UINT8 vendor_specific_3; + UINT8 vendor_specific_4; + UINT8 vendor_specific_5; + UINT8 vendor_specific_6; + UINT8 addnl_sense_length; // n - 7 + UINT8 vendor_specific_8; + UINT8 vendor_specific_9; + UINT8 vendor_specific_10; + UINT8 vendor_specific_11; + UINT8 addnl_sense_code; // mandatory + UINT8 addnl_sense_code_qualifier; // mandatory + UINT8 field_replaceable_unit_code; // optional + UINT8 reserved_15; + UINT8 reserved_16; + UINT8 reserved_17; + // + // Followed by additional sense bytes : FIXME + // +} REQUEST_SENSE_DATA; + +typedef struct { + UINT8 LastLba3; + UINT8 LastLba2; + UINT8 LastLba1; + UINT8 LastLba0; + UINT8 BlockSize3; + UINT8 BlockSize2; + UINT8 BlockSize1; + UINT8 BlockSize0; +} READ_CAPACITY_DATA; + +typedef struct { + UINT8 reserved_0; + UINT8 reserved_1; + UINT8 reserved_2; + UINT8 Capacity_Length; + UINT8 LastLba3; + UINT8 LastLba2; + UINT8 LastLba1; + UINT8 LastLba0; + UINT8 DesCode : 2; + UINT8 reserved_9 : 6; + UINT8 BlockSize2; + UINT8 BlockSize1; + UINT8 BlockSize0; +} READ_FORMAT_CAPACITY_DATA; + +#pragma pack() +// +// ATAPI Command +// +#define ATAPI_SOFT_RESET_CMD 0x08 +#define PACKET_CMD 0xA0 +#define ATAPI_IDENTIFY_DEVICE_CMD 0xA1 +#define ATAPI_SERVICE_CMD 0xA2 + +// +// ATAPI Packet Command +// +#pragma pack(1) + +typedef struct { + UINT8 opcode; + UINT8 reserved_1; + UINT8 reserved_2; + UINT8 reserved_3; + UINT8 reserved_4; + UINT8 reserved_5; + UINT8 reserved_6; + UINT8 reserved_7; + UINT8 reserved_8; + UINT8 reserved_9; + UINT8 reserved_10; + UINT8 reserved_11; +} TEST_UNIT_READY_CMD; + +typedef struct { + UINT8 opcode; + UINT8 reserved_1 : 4; + UINT8 lun : 4; + UINT8 page_code; + UINT8 reserved_3; + UINT8 allocation_length; + UINT8 reserved_5; + UINT8 reserved_6; + UINT8 reserved_7; + UINT8 reserved_8; + UINT8 reserved_9; + UINT8 reserved_10; + UINT8 reserved_11; +} INQUIRY_CMD; + +typedef struct { + UINT8 opcode; + UINT8 reserved_1 : 4; + UINT8 lun : 4; + UINT8 reserved_2; + UINT8 reserved_3; + UINT8 allocation_length; + UINT8 reserved_5; + UINT8 reserved_6; + UINT8 reserved_7; + UINT8 reserved_8; + UINT8 reserved_9; + UINT8 reserved_10; + UINT8 reserved_11; +} REQUEST_SENSE_CMD; + +typedef struct { + UINT8 opcode; + UINT8 reserved_1 : 5; + UINT8 lun : 3; + UINT8 Lba0; + UINT8 Lba1; + UINT8 Lba2; + UINT8 Lba3; + UINT8 reserved_6; + UINT8 TranLen0; + UINT8 TranLen1; + UINT8 reserved_9; + UINT8 reserved_10; + UINT8 reserved_11; +} READ10_CMD; + +typedef struct { + UINT8 opcode; + UINT8 reserved_1; + UINT8 reserved_2; + UINT8 reserved_3; + UINT8 reserved_4; + UINT8 reserved_5; + UINT8 reserved_6; + UINT8 allocation_length_hi; + UINT8 allocation_length_lo; + UINT8 reserved_9; + UINT8 reserved_10; + UINT8 reserved_11; +} READ_FORMAT_CAP_CMD; + +typedef struct { + UINT8 peripheral_type; + UINT8 RMB; + UINT8 version; + UINT8 response_data_format; + UINT8 addnl_length; + UINT8 reserved_5; + UINT8 reserved_6; + UINT8 reserved_7; + UINT8 vendor_info[8]; + UINT8 product_id[12]; + UINT8 eeprom_product_code[4]; + UINT8 firmware_rev_level[4]; +} USB_INQUIRY_DATA; + +typedef union { + UINT16 Data16[6]; + TEST_UNIT_READY_CMD TestUnitReady; + READ10_CMD Read10; + REQUEST_SENSE_CMD RequestSence; + INQUIRY_CMD Inquiry; + READ_FORMAT_CAP_CMD ReadFormatCapacity; +} ATAPI_PACKET_COMMAND; + +#pragma pack() +// +// Packet Command Code +// +#define TEST_UNIT_READY 0x00 +#define REQUEST_SENSE 0x03 +#define INQUIRY 0x12 +#define READ_FORMAT_CAPACITY 0x23 +#define READ_CAPACITY 0x25 +#define READ_10 0x28 + +#define DEFAULT_CTL (0x0a) // default content of device control register, disable INT +#define DEFAULT_CMD (0xa0) + +#define MAX_ATAPI_BYTE_COUNT (0xfffe) + +// +// Sense Key +// +#define REQUEST_SENSE_ERROR (0x70) +#define SK_NO_SENSE (0x0) +#define SK_RECOVERY_ERROR (0x1) +#define SK_NOT_READY (0x2) +#define SK_MEDIUM_ERROR (0x3) +#define SK_HARDWARE_ERROR (0x4) +#define SK_ILLEGAL_REQUEST (0x5) +#define SK_UNIT_ATTENTION (0x6) +#define SK_DATA_PROTECT (0x7) +#define SK_BLANK_CHECK (0x8) +#define SK_VENDOR_SPECIFIC (0x9) +#define SK_RESERVED_A (0xA) +#define SK_ABORT (0xB) +#define SK_RESERVED_C (0xC) +#define SK_OVERFLOW (0xD) +#define SK_MISCOMPARE (0xE) +#define SK_RESERVED_F (0xF) + +// +// Additional Sense Codes +// +#define ASC_NOT_READY (0x04) +#define ASC_MEDIA_ERR1 (0x10) +#define ASC_MEDIA_ERR2 (0x11) +#define ASC_MEDIA_ERR3 (0x14) +#define ASC_MEDIA_ERR4 (0x30) +#define ASC_MEDIA_UPSIDE_DOWN (0x06) +#define ASC_INVALID_CMD (0x20) +#define ASC_LBA_OUT_OF_RANGE (0x21) +#define ASC_INVALID_FIELD (0x24) +#define ASC_WRITE_PROTECTED (0x27) +#define ASC_MEDIA_CHANGE (0x28) +#define ASC_RESET (0x29) /* Power On Reset or Bus Reset occurred */ +#define ASC_ILLEGAL_FIELD (0x26) +#define ASC_NO_MEDIA (0x3A) +#define ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64) + +// +// Additional Sense Code Qualifier +// +#define ASCQ_IN_PROGRESS (0x01) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci.h new file mode 100644 index 0000000000..aa0668b9dc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci.h @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + pci.h + +Abstract: + Support for PCI standard. + +Revision History + +--*/ + +#ifndef _PCI_H +#define _PCI_H + +#include "pci22.h" +#include "pci23.h" +#include "pci30.h" +#include "EfiPci.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci22.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci22.h new file mode 100644 index 0000000000..77aebb69e6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci22.h @@ -0,0 +1,555 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + pci22.h + +Abstract: + Support for PCI 2.2 standard. + +Revision History + +--*/ + +#ifndef _PCI22_H +#define _PCI22_H + +#define PCI_MAX_SEGMENT 0 + +#define PCI_MAX_BUS 255 + +#define PCI_MAX_DEVICE 31 +#define PCI_MAX_FUNC 7 + +// +// Command +// +#define PCI_VGA_PALETTE_SNOOP_DISABLED 0x20 + +#pragma pack(push, 1) +typedef struct { + UINT16 VendorId; + UINT16 DeviceId; + UINT16 Command; + UINT16 Status; + UINT8 RevisionID; + UINT8 ClassCode[3]; + UINT8 CacheLineSize; + UINT8 LatencyTimer; + UINT8 HeaderType; + UINT8 BIST; +} PCI_DEVICE_INDEPENDENT_REGION; + +typedef struct { + UINT32 Bar[6]; + UINT32 CISPtr; + UINT16 SubsystemVendorID; + UINT16 SubsystemID; + UINT32 ExpansionRomBar; + UINT8 CapabilityPtr; + UINT8 Reserved1[3]; + UINT32 Reserved2; + UINT8 InterruptLine; + UINT8 InterruptPin; + UINT8 MinGnt; + UINT8 MaxLat; +} PCI_DEVICE_HEADER_TYPE_REGION; + +typedef struct { + PCI_DEVICE_INDEPENDENT_REGION Hdr; + PCI_DEVICE_HEADER_TYPE_REGION Device; +} PCI_TYPE00; + +typedef struct { + UINT32 Bar[2]; + UINT8 PrimaryBus; + UINT8 SecondaryBus; + UINT8 SubordinateBus; + UINT8 SecondaryLatencyTimer; + UINT8 IoBase; + UINT8 IoLimit; + UINT16 SecondaryStatus; + UINT16 MemoryBase; + UINT16 MemoryLimit; + UINT16 PrefetchableMemoryBase; + UINT16 PrefetchableMemoryLimit; + UINT32 PrefetchableBaseUpper32; + UINT32 PrefetchableLimitUpper32; + UINT16 IoBaseUpper16; + UINT16 IoLimitUpper16; + UINT8 CapabilityPtr; + UINT8 Reserved[3]; + UINT32 ExpansionRomBAR; + UINT8 InterruptLine; + UINT8 InterruptPin; + UINT16 BridgeControl; +} PCI_BRIDGE_CONTROL_REGISTER; + +typedef struct { + PCI_DEVICE_INDEPENDENT_REGION Hdr; + PCI_BRIDGE_CONTROL_REGISTER Bridge; +} PCI_TYPE01; + +typedef union { + PCI_TYPE00 Device; + PCI_TYPE01 Bridge; +} PCI_TYPE_GENERIC; + +typedef struct { + UINT32 CardBusSocketReg; // Cardus Socket/ExCA Base + // Address Register + // + UINT16 Reserved; + UINT16 SecondaryStatus; // Secondary Status + UINT8 PciBusNumber; // PCI Bus Number + UINT8 CardBusBusNumber; // CardBus Bus Number + UINT8 SubordinateBusNumber; // Subordinate Bus Number + UINT8 CardBusLatencyTimer; // CardBus Latency Timer + UINT32 MemoryBase0; // Memory Base Register 0 + UINT32 MemoryLimit0; // Memory Limit Register 0 + UINT32 MemoryBase1; + UINT32 MemoryLimit1; + UINT32 IoBase0; + UINT32 IoLimit0; // I/O Base Register 0 + UINT32 IoBase1; // I/O Limit Register 0 + UINT32 IoLimit1; + UINT8 InterruptLine; // Interrupt Line + UINT8 InterruptPin; // Interrupt Pin + UINT16 BridgeControl; // Bridge Control +} PCI_CARDBUS_CONTROL_REGISTER; + +// +// Definitions of PCI class bytes and manipulation macros. +// +#define PCI_CLASS_OLD 0x00 +#define PCI_CLASS_OLD_OTHER 0x00 +#define PCI_CLASS_OLD_VGA 0x01 + +#define PCI_CLASS_MASS_STORAGE 0x01 +#define PCI_CLASS_MASS_STORAGE_SCSI 0x00 +#define PCI_CLASS_MASS_STORAGE_IDE 0x01 // obsolete +#define PCI_CLASS_IDE 0x01 +#define PCI_CLASS_MASS_STORAGE_FLOPPY 0x02 +#define PCI_CLASS_MASS_STORAGE_IPI 0x03 +#define PCI_CLASS_MASS_STORAGE_RAID 0x04 +#define PCI_CLASS_MASS_STORAGE_OTHER 0x80 + +#define PCI_CLASS_NETWORK 0x02 +#define PCI_CLASS_NETWORK_ETHERNET 0x00 +#define PCI_CLASS_ETHERNET 0x00 // obsolete +#define PCI_CLASS_NETWORK_TOKENRING 0x01 +#define PCI_CLASS_NETWORK_FDDI 0x02 +#define PCI_CLASS_NETWORK_ATM 0x03 +#define PCI_CLASS_NETWORK_ISDN 0x04 +#define PCI_CLASS_NETWORK_OTHER 0x80 + +#define PCI_CLASS_DISPLAY 0x03 +#define PCI_CLASS_DISPLAY_CTRL 0x03 // obsolete +#define PCI_CLASS_DISPLAY_VGA 0x00 +#define PCI_CLASS_VGA 0x00 // obsolete +#define PCI_CLASS_DISPLAY_XGA 0x01 +#define PCI_CLASS_DISPLAY_3D 0x02 +#define PCI_CLASS_DISPLAY_OTHER 0x80 +#define PCI_CLASS_DISPLAY_GFX 0x80 +#define PCI_CLASS_GFX 0x80 // obsolete + +#define PCI_CLASS_BRIDGE 0x06 +#define PCI_CLASS_BRIDGE_HOST 0x00 +#define PCI_CLASS_BRIDGE_ISA 0x01 +#define PCI_CLASS_ISA 0x01 // obsolete +#define PCI_CLASS_BRIDGE_EISA 0x02 +#define PCI_CLASS_BRIDGE_MCA 0x03 +#define PCI_CLASS_BRIDGE_P2P 0x04 +#define PCI_CLASS_BRIDGE_PCMCIA 0x05 +#define PCI_CLASS_BRIDGE_NUBUS 0x06 +#define PCI_CLASS_BRIDGE_CARDBUS 0x07 +#define PCI_CLASS_BRIDGE_RACEWAY 0x08 +#define PCI_CLASS_BRIDGE_ISA_PDECODE 0x80 +#define PCI_CLASS_ISA_POSITIVE_DECODE 0x80 // obsolete + +#define PCI_CLASS_SCC 0x07 // Simple communications controllers +#define PCI_SUBCLASS_SERIAL 0x00 +#define PCI_IF_GENERIC_XT 0x00 +#define PCI_IF_16450 0x01 +#define PCI_IF_16550 0x02 +#define PCI_IF_16650 0x03 +#define PCI_IF_16750 0x04 +#define PCI_IF_16850 0x05 +#define PCI_IF_16950 0x06 +#define PCI_SUBCLASS_PARALLEL 0x01 +#define PCI_IF_PARALLEL_PORT 0x00 +#define PCI_IF_BI_DIR_PARALLEL_PORT 0x01 +#define PCI_IF_ECP_PARALLEL_PORT 0x02 +#define PCI_IF_1284_CONTROLLER 0x03 +#define PCI_IF_1284_DEVICE 0xFE +#define PCI_SUBCLASS_MULTIPORT_SERIAL 0x02 +#define PCI_SUBCLASS_MODEM 0x03 +#define PCI_IF_GENERIC_MODEM 0x00 +#define PCI_IF_16450_MODEM 0x01 +#define PCI_IF_16550_MODEM 0x02 +#define PCI_IF_16650_MODEM 0x03 +#define PCI_IF_16750_MODEM 0x04 +#define PCI_SUBCLASS_OTHER 0x80 + +#define PCI_CLASS_SYSTEM_PERIPHERAL 0x08 +#define PCI_SUBCLASS_PIC 0x00 +#define PCI_IF_8259_PIC 0x00 +#define PCI_IF_ISA_PIC 0x01 +#define PCI_IF_EISA_PIC 0x02 +#define PCI_IF_APIC_CONTROLLER 0x10 // I/O APIC interrupt controller , 32 bye none-prefectable memory. +#define PCI_IF_APIC_CONTROLLER2 0x20 +#define PCI_SUBCLASS_TIMER 0x02 +#define PCI_IF_8254_TIMER 0x00 +#define PCI_IF_ISA_TIMER 0x01 +#define PCI_EISA_TIMER 0x02 +#define PCI_SUBCLASS_RTC 0x03 +#define PCI_IF_GENERIC_RTC 0x00 +#define PCI_IF_ISA_RTC 0x00 +#define PCI_SUBCLASS_PNP_CONTROLLER 0x04 // HotPlug Controller + +#define PCI_CLASS_INPUT_DEVICE 0x09 +#define PCI_SUBCLASS_KEYBOARD 0x00 +#define PCI_SUBCLASS_PEN 0x01 +#define PCI_SUBCLASS_MOUSE_CONTROLLER 0x02 +#define PCI_SUBCLASS_SCAN_CONTROLLER 0x03 +#define PCI_SUBCLASS_GAMEPORT 0x04 + +#define PCI_CLASS_DOCKING_STATION 0x0A + +#define PCI_CLASS_PROCESSOR 0x0B +#define PCI_SUBCLASS_PROC_386 0x00 +#define PCI_SUBCLASS_PROC_486 0x01 +#define PCI_SUBCLASS_PROC_PENTIUM 0x02 +#define PCI_SUBCLASS_PROC_ALPHA 0x10 +#define PCI_SUBCLASS_PROC_POWERPC 0x20 +#define PCI_SUBCLASS_PROC_MIPS 0x30 +#define PCI_SUBCLASS_PROC_CO_PORC 0x40 // Co-Processor + +#define PCI_CLASS_SERIAL 0x0C +#define PCI_CLASS_SERIAL_FIREWIRE 0x00 +#define PCI_CLASS_SERIAL_ACCESS_BUS 0x01 +#define PCI_CLASS_SERIAL_SSA 0x02 +#define PCI_CLASS_SERIAL_USB 0x03 +#define PCI_IF_EHCI 0x20 +#define PCI_CLASS_SERIAL_FIBRECHANNEL 0x04 +#define PCI_CLASS_SERIAL_SMB 0x05 + +#define PCI_CLASS_WIRELESS 0x0D +#define PCI_SUBCLASS_IRDA 0x00 +#define PCI_SUBCLASS_IR 0x01 +#define PCI_SUBCLASS_RF 0x02 + +#define PCI_CLASS_INTELLIGENT_IO 0x0E + +#define PCI_CLASS_SATELLITE 0x0F +#define PCI_SUBCLASS_TV 0x01 +#define PCI_SUBCLASS_AUDIO 0x02 +#define PCI_SUBCLASS_VOICE 0x03 +#define PCI_SUBCLASS_DATA 0x04 + +#define PCI_SECURITY_CONTROLLER 0x10 // Encryption and decryption controller +#define PCI_SUBCLASS_NET_COMPUT 0x00 +#define PCI_SUBCLASS_ENTERTAINMENT 0x10 + +#define PCI_CLASS_DPIO 0x11 + +#define IS_CLASS1(_p, c) ((_p)->Hdr.ClassCode[2] == (c)) +#define IS_CLASS2(_p, c, s) (IS_CLASS1 (_p, c) && ((_p)->Hdr.ClassCode[1] == (s))) +#define IS_CLASS3(_p, c, s, p) (IS_CLASS2 (_p, c, s) && ((_p)->Hdr.ClassCode[0] == (p))) + +#define IS_PCI_DISPLAY(_p) IS_CLASS1 (_p, PCI_CLASS_DISPLAY) +#define IS_PCI_VGA(_p) IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 0) +#define IS_PCI_8514(_p) IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 1) +#define IS_PCI_GFX(_p) IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_GFX, 0) +#define IS_PCI_OLD(_p) IS_CLASS1 (_p, PCI_CLASS_OLD) +#define IS_PCI_OLD_VGA(_p) IS_CLASS2 (_p, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) +#define IS_PCI_IDE(_p) IS_CLASS2 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_IDE) +#define IS_PCI_SCSI(_p) IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_SCSI, 0) +#define IS_PCI_RAID(_p) IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_RAID, 0) +#define IS_PCI_LPC(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA, 0) +#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0) +#define IS_PCI_P2P(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 0) +#define IS_PCI_P2P_SUB(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 1) +#define IS_PCI_16550_SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550) +#define IS_PCI_USB(_p) IS_CLASS2 (_p, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB) + +#define HEADER_TYPE_DEVICE 0x00 +#define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01 +#define HEADER_TYPE_CARDBUS_BRIDGE 0x02 + +#define HEADER_TYPE_MULTI_FUNCTION 0x80 +#define HEADER_LAYOUT_CODE 0x7f + +#define IS_PCI_BRIDGE(_p) (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_PCI_TO_PCI_BRIDGE)) +#define IS_CARDBUS_BRIDGE(_p) (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_CARDBUS_BRIDGE)) +#define IS_PCI_MULTI_FUNC(_p) ((_p)->Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) + +#define PCI_DEVICE_ROMBAR 0x30 +#define PCI_BRIDGE_ROMBAR 0x38 + +#define PCI_MAX_BAR 0x0006 +#define PCI_MAX_CONFIG_OFFSET 0x0100 + +#define PCI_VENDOR_ID_OFFSET 0x00 +#define PCI_DEVICE_ID_OFFSET 0x02 +#define PCI_COMMAND_OFFSET 0x04 +#define PCI_PRIMARY_STATUS_OFFSET 0x06 +#define PCI_REVISION_ID_OFFSET 0x08 +#define PCI_CLASSCODE_OFFSET 0x09 +#define PCI_SUBCLASSCODE_OFFSET 0x0A +#define PCI_CACHELINE_SIZE_OFFSET 0x0C +#define PCI_LATENCY_TIMER_OFFSET 0x0D +#define PCI_HEADER_TYPE_OFFSET 0x0E +#define PCI_BIST_OFFSET 0x0F +#define PCI_BASE_ADDRESSREG_OFFSET 0x10 +#define PCI_CARDBUS_CIS_OFFSET 0x28 +#define PCI_SVID_OFFSET 0x2C // SubSystem Vendor id +#define PCI_SUBSYSTEM_VENDOR_ID_OFFSET 0x2C +#define PCI_SID_OFFSET 0x2E // SubSystem ID +#define PCI_SUBSYSTEM_ID_OFFSET 0x2E +#define PCI_EXPANSION_ROM_BASE 0x30 +#define PCI_CAPBILITY_POINTER_OFFSET 0x34 +#define PCI_INT_LINE_OFFSET 0x3C // Interrupt Line Register +#define PCI_INT_PIN_OFFSET 0x3D // Interrupt Pin Register +#define PCI_MAXGNT_OFFSET 0x3E // Max Grant Register +#define PCI_MAXLAT_OFFSET 0x3F // Max Latency Register + +#define PCI_BRIDGE_CONTROL_REGISTER_OFFSET 0x3E +#define PCI_BRIDGE_STATUS_REGISTER_OFFSET 0x1E + +#define PCI_BRIDGE_PRIMARY_BUS_REGISTER_OFFSET 0x18 +#define PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET 0x19 +#define PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET 0x1a + +// +// Interrupt Line "Unknown" or "No connection" value defined for x86 based system +// +#define PCI_INT_LINE_UNKNOWN 0xFF + + +typedef struct { + UINT32 Reg : 8; + UINT32 Func : 3; + UINT32 Dev : 5; + UINT32 Bus : 8; + UINT32 Reserved : 7; + UINT32 Enable : 1; +} PCI_CONFIG_ACCESS_CF8; + +#pragma pack() + +#define PCI_EXPANSION_ROM_HEADER_SIGNATURE 0xaa55 +#define PCI_DATA_STRUCTURE_SIGNATURE EFI_SIGNATURE_32 ('P', 'C', 'I', 'R') +#define PCI_CODE_TYPE_PCAT_IMAGE 0x00 +#define PCI_CODE_TYPE_EFI_IMAGE 0x03 +#define EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED 0x0001 + +#define EFI_PCI_COMMAND_IO_SPACE 0x0001 +#define EFI_PCI_COMMAND_MEMORY_SPACE 0x0002 +#define EFI_PCI_COMMAND_BUS_MASTER 0x0004 +#define EFI_PCI_COMMAND_SPECIAL_CYCLE 0x0008 +#define EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE 0x0010 +#define EFI_PCI_COMMAND_VGA_PALETTE_SNOOP 0x0020 +#define EFI_PCI_COMMAND_PARITY_ERROR_RESPOND 0x0040 +#define EFI_PCI_COMMAND_STEPPING_CONTROL 0x0080 +#define EFI_PCI_COMMAND_SERR 0x0100 +#define EFI_PCI_COMMAND_FAST_BACK_TO_BACK 0x0200 + +#define EFI_PCI_BRIDGE_CONTROL_PARITY_ERROR_RESPONSE 0x0001 +#define EFI_PCI_BRIDGE_CONTROL_SERR 0x0002 +#define EFI_PCI_BRIDGE_CONTROL_ISA 0x0004 +#define EFI_PCI_BRIDGE_CONTROL_VGA 0x0008 +#define EFI_PCI_BRIDGE_CONTROL_VGA_16 0x0010 +#define EFI_PCI_BRIDGE_CONTROL_MASTER_ABORT 0x0020 +#define EFI_PCI_BRIDGE_CONTROL_RESET_SECONDARY_BUS 0x0040 +#define EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK 0x0080 +#define EFI_PCI_BRIDGE_CONTROL_PRIMARY_DISCARD_TIMER 0x0100 +#define EFI_PCI_BRIDGE_CONTROL_SECONDARY_DISCARD_TIMER 0x0200 +#define EFI_PCI_BRIDGE_CONTROL_TIMER_STATUS 0x0400 +#define EFI_PCI_BRIDGE_CONTROL_DISCARD_TIMER_SERR 0x0800 + +// +// Following are the PCI-CARDBUS bridge control bit +// +#define EFI_PCI_BRIDGE_CONTROL_IREQINT_ENABLE 0x0080 +#define EFI_PCI_BRIDGE_CONTROL_RANGE0_MEMORY_TYPE 0x0100 +#define EFI_PCI_BRIDGE_CONTROL_RANGE1_MEMORY_TYPE 0x0200 +#define EFI_PCI_BRIDGE_CONTROL_WRITE_POSTING_ENABLE 0x0400 + +// +// Following are the PCI status control bit +// +#define EFI_PCI_STATUS_CAPABILITY 0x0010 +#define EFI_PCI_STATUS_66MZ_CAPABLE 0x0020 +#define EFI_PCI_FAST_BACK_TO_BACK_CAPABLE 0x0080 +#define EFI_PCI_MASTER_DATA_PARITY_ERROR 0x0100 + +#define EFI_PCI_CAPABILITY_PTR 0x34 +#define EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR 0x14 + +#pragma pack(1) +typedef struct { + UINT16 Signature; // 0xaa55 + UINT8 Reserved[0x16]; + UINT16 PcirOffset; +} PCI_EXPANSION_ROM_HEADER; + +typedef struct { + UINT16 Signature; // 0xaa55 + UINT8 Size512; + UINT8 InitEntryPoint[3]; + UINT8 Reserved[0x12]; + UINT16 PcirOffset; +} EFI_LEGACY_EXPANSION_ROM_HEADER; + +typedef struct { + UINT32 Signature; // "PCIR" + UINT16 VendorId; + UINT16 DeviceId; + UINT16 Reserved0; + UINT16 Length; + UINT8 Revision; + UINT8 ClassCode[3]; + UINT16 ImageLength; + UINT16 CodeRevision; + UINT8 CodeType; + UINT8 Indicator; + UINT16 Reserved1; +} PCI_DATA_STRUCTURE; + +// +// PCI Capability List IDs and records +// +#define EFI_PCI_CAPABILITY_ID_PMI 0x01 +#define EFI_PCI_CAPABILITY_ID_AGP 0x02 +#define EFI_PCI_CAPABILITY_ID_VPD 0x03 +#define EFI_PCI_CAPABILITY_ID_SLOTID 0x04 +#define EFI_PCI_CAPABILITY_ID_MSI 0x05 +#define EFI_PCI_CAPABILITY_ID_HOTPLUG 0x06 +#define EFI_PCI_CAPABILITY_ID_PCIX 0x07 + +typedef struct { + UINT8 CapabilityID; + UINT8 NextItemPtr; +} EFI_PCI_CAPABILITY_HDR; + +// +// Capability EFI_PCI_CAPABILITY_ID_PMI +// +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT16 PMC; + UINT16 PMCSR; + UINT8 BridgeExtention; + UINT8 Data; +} EFI_PCI_CAPABILITY_PMI; + +// +// Capability EFI_PCI_CAPABILITY_ID_AGP +// +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT8 Rev; + UINT8 Reserved; + UINT32 Status; + UINT32 Command; +} EFI_PCI_CAPABILITY_AGP; + +// +// Capability EFI_PCI_CAPABILITY_ID_VPD +// +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT16 AddrReg; + UINT32 DataReg; +} EFI_PCI_CAPABILITY_VPD; + +// +// Capability EFI_PCI_CAPABILITY_ID_SLOTID +// +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT8 ExpnsSlotReg; + UINT8 ChassisNo; +} EFI_PCI_CAPABILITY_SLOTID; + +// +// Capability EFI_PCI_CAPABILITY_ID_MSI +// +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT16 MsgCtrlReg; + UINT32 MsgAddrReg; + UINT16 MsgDataReg; +} EFI_PCI_CAPABILITY_MSI32; + +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT16 MsgCtrlReg; + UINT32 MsgAddrRegLsdw; + UINT32 MsgAddrRegMsdw; + UINT16 MsgDataReg; +} EFI_PCI_CAPABILITY_MSI64; + +// +// Capability EFI_PCI_CAPABILITY_ID_HOTPLUG +// +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + // + // not finished - fields need to go here + // +} EFI_PCI_CAPABILITY_HOTPLUG; + +// +// Capability EFI_PCI_CAPABILITY_ID_PCIX +// +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT16 CommandReg; + UINT32 StatusReg; +} EFI_PCI_CAPABILITY_PCIX; + +typedef struct { + EFI_PCI_CAPABILITY_HDR Hdr; + UINT16 SecStatusReg; + UINT32 StatusReg; + UINT32 SplitTransCtrlRegUp; + UINT32 SplitTransCtrlRegDn; +} EFI_PCI_CAPABILITY_PCIX_BRDG; + +#define DEVICE_ID_NOCARE 0xFFFF + +#define PCI_ACPI_UNUSED 0 +#define PCI_BAR_NOCHANGE 0 +#define PCI_BAR_OLD_ALIGN 0xFFFFFFFFFFFFFFFF +#define PCI_BAR_EVEN_ALIGN 0xFFFFFFFFFFFFFFFE +#define PCI_BAR_SQUAD_ALIGN 0xFFFFFFFFFFFFFFFD +#define PCI_BAR_DQUAD_ALIGN 0xFFFFFFFFFFFFFFFC + +#define PCI_BAR_IDX0 0x00 +#define PCI_BAR_IDX1 0x01 +#define PCI_BAR_IDX2 0x02 +#define PCI_BAR_IDX3 0x03 +#define PCI_BAR_IDX4 0x04 +#define PCI_BAR_IDX5 0x05 +#define PCI_BAR_ALL 0xFF + +#pragma pack(pop) + +// +// NOTE: The following header files are included here for +// compatibility consideration. +// +#include "EfiPci.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h new file mode 100644 index 0000000000..c42991f38c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + pci23.h + +Abstract: + Support for PCI 2.3 standard. + +Revision History + +--*/ + +#ifndef _PCI23_H +#define _PCI23_H + +#include "pci22.h" + +#define PCI_EXP_MAX_CONFIG_OFFSET 0x1000 +#define EFI_PCI_CAPABILITY_ID_PCIEXP 0x10 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci30.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci30.h new file mode 100644 index 0000000000..1a9219b377 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci30.h @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + pci30.h + +Abstract: + Support for PCI 3.0 standard. + +Revision History + +--*/ + +#ifndef _PCI30_H +#define _PCI30_H + +#include "pci23.h" + +#define PCI_CLASS_MASS_STORAGE_SATADPA 0x06 +#define PCI_CLASS_MASS_STORAGE_AHCI PCI_CLASS_MASS_STORAGE_SATADPA + +#pragma pack(push, 1) + +typedef struct { + UINT32 Signature; // "PCIR" + UINT16 VendorId; + UINT16 DeviceId; + UINT16 DeviceListOffset; + UINT16 Length; + UINT8 Revision; + UINT8 ClassCode[3]; + UINT16 ImageLength; + UINT16 CodeRevision; + UINT8 CodeType; + UINT8 Indicator; + UINT16 MaxRuntimeImageLength; + UINT16 ConfigUtilityCodeHeaderOffset; + UINT16 DMTFCLPEntryPointOffset; +} PCI_3_0_DATA_STRUCTURE; + +#pragma pack(pop) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h new file mode 100644 index 0000000000..70a6b23833 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h @@ -0,0 +1,292 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + scsi.h + +Abstract: + support for SCSI standard + +Revision History +--*/ + +#ifndef _SCSI_H +#define _SCSI_H + +// +// SCSI command OP Code +// +// +// Commands for all device types +// +#define EFI_SCSI_OP_CHANGE_DEFINITION 0x40 +#define EFI_SCSI_OP_COMPARE 0x39 +#define EFI_SCSI_OP_COPY 0x18 +#define EFI_SCSI_OP_COPY_VERIFY 0x3a +#define EFI_SCSI_OP_INQUIRY 0x12 +#define EFI_SCSI_OP_LOG_SELECT 0x4c +#define EFI_SCSI_OP_LOG_SENSE 0x4d +#define EFI_SCSI_OP_MODE_SEL6 0x15 +#define EFI_SCSI_OP_MODE_SEL10 0x55 +#define EFI_SCSI_OP_MODE_SEN6 0x1a +#define EFI_SCSI_OP_MODE_SEN10 0x5a +#define EFI_SCSI_OP_READ_BUFFER 0x3c +#define EFI_SCSI_OP_REQUEST_SENSE 0x03 +#define EFI_SCSI_OP_SEND_DIAG 0x1d +#define EFI_SCSI_OP_TEST_UNIT_READY 0x00 +#define EFI_SCSI_OP_WRITE_BUFF 0x3b + +// +// Commands unique to Direct Access Devices +// +#define EFI_SCSI_OP_COMPARE 0x39 +#define EFI_SCSI_OP_FORMAT 0x04 +#define EFI_SCSI_OP_LOCK_UN_CACHE 0x36 +#define EFI_SCSI_OP_PREFETCH 0x34 +#define EFI_SCSI_OP_MEDIA_REMOVAL 0x1e +#define EFI_SCSI_OP_READ6 0x08 +#define EFI_SCSI_OP_READ10 0x28 +#define EFI_SCSI_OP_READ_CAPACITY 0x25 +#define EFI_SCSI_OP_READ_DEFECT 0x37 +#define EFI_SCSI_OP_READ_LONG 0x3e +#define EFI_SCSI_OP_REASSIGN_BLK 0x07 +#define EFI_SCSI_OP_RECEIVE_DIAG 0x1c +#define EFI_SCSI_OP_RELEASE 0x17 +#define EFI_SCSI_OP_REZERO 0x01 +#define EFI_SCSI_OP_SEARCH_DATA_E 0x31 +#define EFI_SCSI_OP_SEARCH_DATA_H 0x30 +#define EFI_SCSI_OP_SEARCH_DATA_L 0x32 +#define EFI_SCSI_OP_SEEK6 0x0b +#define EFI_SCSI_OP_SEEK10 0x2b +#define EFI_SCSI_OP_SEND_DIAG 0x1d +#define EFI_SCSI_OP_SET_LIMIT 0x33 +#define EFI_SCSI_OP_START_STOP_UNIT 0x1b +#define EFI_SCSI_OP_SYNC_CACHE 0x35 +#define EFI_SCSI_OP_VERIFY 0x2f +#define EFI_SCSI_OP_WRITE6 0x0a +#define EFI_SCSI_OP_WRITE10 0x2a +#define EFI_SCSI_OP_WRITE_VERIFY 0x2e +#define EFI_SCSI_OP_WRITE_LONG 0x3f +#define EFI_SCSI_OP_WRITE_SAME 0x41 + +// +// Commands unique to Sequential Access Devices +// +#define EFI_SCSI_OP_ERASE 0x19 +#define EFI_SCSI_OP_LOAD_UNLOAD 0x1b +#define EFI_SCSI_OP_LOCATE 0x2b +#define EFI_SCSI_OP_READ_BLOCK_LIMIT 0x05 +#define EFI_SCSI_OP_READ_POS 0x34 +#define EFI_SCSI_OP_READ_REVERSE 0x0f +#define EFI_SCSI_OP_RECOVER_BUF_DATA 0x14 +#define EFI_SCSI_OP_RESERVE_UNIT 0x16 +#define EFI_SCSI_OP_REWIND 0x01 +#define EFI_SCSI_OP_SPACE 0x11 +#define EFI_SCSI_OP_VERIFY_TAPE 0x13 +#define EFI_SCSI_OP_WRITE_FILEMARK 0x10 + +// +// Commands unique to Printer Devices +// +#define EFI_SCSI_OP_PRINT 0x0a +#define EFI_SCSI_OP_SLEW_PRINT 0x0b +#define EFI_SCSI_OP_STOP_PRINT 0x1b +#define EFI_SCSI_OP_SYNC_BUFF 0x10 + +// +// Commands unique to Processor Devices +// +#define EFI_SCSI_OP_RECEIVE 0x08 +#define EFI_SCSI_OP_SEND 0x0a + +// +// Commands unique to Write-Once Devices +// +#define EFI_SCSI_OP_MEDIUM_SCAN 0x38 +#define EFI_SCSI_OP_SEARCH_DAT_E10 0x31 +#define EFI_SCSI_OP_SEARCH_DAT_E12 0xb1 +#define EFI_SCSI_OP_SEARCH_DAT_H10 0x30 +#define EFI_SCSI_OP_SEARCH_DAT_H12 0xb0 +#define EFI_SCSI_OP_SEARCH_DAT_L10 0x32 +#define EFI_SCSI_OP_SEARCH_DAT_L12 0xb2 +#define EFI_SCSI_OP_SET_LIMIT10 0x33 +#define EFI_SCSI_OP_SET_LIMIT12 0xb3 +#define EFI_SCSI_OP_VERIFY10 0x2f +#define EFI_SCSI_OP_VERIFY12 0xaf +#define EFI_SCSI_OP_WRITE12 0xaa +#define EFI_SCSI_OP_WRITE_VERIFY10 0x2e +#define EFI_SCSI_OP_WRITE_VERIFY12 0xae + +// +// Commands unique to CD-ROM Devices +// +#define EFI_SCSI_OP_PLAY_AUD_10 0x45 +#define EFI_SCSI_OP_PLAY_AUD_12 0xa5 +#define EFI_SCSI_OP_PLAY_AUD_MSF 0x47 +#define EFI_SCSI_OP_PLAY_AUD_TKIN 0x48 +#define EFI_SCSI_OP_PLAY_TK_REL10 0x49 +#define EFI_SCSI_OP_PLAY_TK_REL12 0xa9 +#define EFI_SCSI_OP_READ_CD_CAPACITY 0x25 +#define EFI_SCSI_OP_READ_HEADER 0x44 +#define EFI_SCSI_OP_READ_SUB_CHANNEL 0x42 +#define EFI_SCSI_OP_READ_TOC 0x43 + +// +// Commands unique to Scanner Devices +// +#define EFI_SCSI_OP_GET_DATABUFF_STAT 0x34 +#define EFI_SCSI_OP_GET_WINDOW 0x25 +#define EFI_SCSI_OP_OBJECT_POS 0x31 +#define EFI_SCSI_OP_SCAN 0x1b +#define EFI_SCSI_OP_SET_WINDOW 0x24 + +// +// Commands unique to Optical Memory Devices +// +#define EFI_SCSI_OP_UPDATE_BLOCK 0x3d + +// +// Commands unique to Medium Changer Devices +// +#define EFI_SCSI_OP_EXCHANGE_MEDIUM 0xa6 +#define EFI_SCSI_OP_INIT_ELEMENT_STAT 0x07 +#define EFI_SCSI_OP_POS_TO_ELEMENT 0x2b +#define EFI_SCSI_OP_REQUEST_VE_ADDR 0xb5 +#define EFI_SCSI_OP_SEND_VOL_TAG 0xb6 + +// +// Commands unique to Communition Devices +// +#define EFI_SCSI_OP_GET_MESSAGE6 0x08 +#define EFI_SCSI_OP_GET_MESSAGE10 0x28 +#define EFI_SCSI_OP_GET_MESSAGE12 0xa8 +#define EFI_SCSI_OP_SEND_MESSAGE6 0x0a +#define EFI_SCSI_OP_SEND_MESSAGE10 0x2a +#define EFI_SCSI_OP_SEND_MESSAGE12 0xaa + +// +// SCSI Data Transfer Direction +// +#define EFI_SCSI_DATA_IN 0 +#define EFI_SCSI_DATA_OUT 1 + +// +// Peripheral Device Type Definitions +// +#define EFI_SCSI_TYPE_DISK 0x00 // Disk device +#define EFI_SCSI_TYPE_TAPE 0x01 // Tape device +#define EFI_SCSI_TYPE_PRINTER 0x02 // Printer +#define EFI_SCSI_TYPE_PROCESSOR 0x03 // Processor +#define EFI_SCSI_TYPE_WORM 0x04 // Write-once read-multiple +#define EFI_SCSI_TYPE_CDROM 0x05 // CD-ROM device +#define EFI_SCSI_TYPE_SCANNER 0x06 // Scanner device +#define EFI_SCSI_TYPE_OPTICAL 0x07 // Optical memory device +#define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08 // Medium Changer device +#define EFI_SCSI_TYPE_COMMUNICATION 0x09 // Communications device +#define EFI_SCSI_TYPE_RESERVED_LOW 0x0A // Reserved (low) +#define EFI_SCSI_TYPE_RESERVED_HIGH 0x1E // Reserved (high) +#define EFI_SCSI_TYPE_UNKNOWN 0x1F // Unknown or no device type +#pragma pack(1) +// +// Data structures for scsi command use +// +typedef struct { + UINT8 Peripheral_Type : 5; + UINT8 Peripheral_Qualifier : 3; + UINT8 DeviceType_Modifier : 7; + UINT8 RMB : 1; + UINT8 Version; + UINT8 Response_Data_Format; + UINT8 Addnl_Length; + UINT8 Reserved_5_95[95 - 5 + 1]; +} EFI_SCSI_INQUIRY_DATA; + +typedef struct { + UINT8 Error_Code : 7; + UINT8 Valid : 1; + UINT8 Segment_Number; + UINT8 Sense_Key : 4; + UINT8 Reserved_21 : 1; + UINT8 ILI : 1; + UINT8 Reserved_22 : 2; + UINT8 Information_3_6[4]; + UINT8 Addnl_Sense_Length; // n - 7 + UINT8 Vendor_Specific_8_11[4]; + UINT8 Addnl_Sense_Code; // mandatory + UINT8 Addnl_Sense_Code_Qualifier; // mandatory + UINT8 Field_Replaceable_Unit_Code; // optional + UINT8 Reserved_15_17[3]; +} EFI_SCSI_SENSE_DATA; + +typedef struct { + UINT8 LastLba3; + UINT8 LastLba2; + UINT8 LastLba1; + UINT8 LastLba0; + UINT8 BlockSize3; + UINT8 BlockSize2; + UINT8 BlockSize1; + UINT8 BlockSize0; +} EFI_SCSI_DISK_CAPACITY_DATA; + +#pragma pack() +// +// Sense Key +// +#define EFI_SCSI_REQUEST_SENSE_ERROR (0x70) +#define EFI_SCSI_SK_NO_SENSE (0x0) +#define EFI_SCSI_SK_RECOVERY_ERROR (0x1) +#define EFI_SCSI_SK_NOT_READY (0x2) +#define EFI_SCSI_SK_MEDIUM_ERROR (0x3) +#define EFI_SCSI_SK_HARDWARE_ERROR (0x4) +#define EFI_SCSI_SK_ILLEGAL_REQUEST (0x5) +#define EFI_SCSI_SK_UNIT_ATTENTION (0x6) +#define EFI_SCSI_SK_DATA_PROTECT (0x7) +#define EFI_SCSI_SK_BLANK_CHECK (0x8) +#define EFI_SCSI_SK_VENDOR_SPECIFIC (0x9) +#define EFI_SCSI_SK_RESERVED_A (0xA) +#define EFI_SCSI_SK_ABORT (0xB) +#define EFI_SCSI_SK_RESERVED_C (0xC) +#define EFI_SCSI_SK_OVERFLOW (0xD) +#define EFI_SCSI_SK_MISCOMPARE (0xE) +#define EFI_SCSI_SK_RESERVED_F (0xF) + +// +// Additional Sense Codes +// +#define EFI_SCSI_ASC_NOT_READY (0x04) +#define EFI_SCSI_ASC_MEDIA_ERR1 (0x10) +#define EFI_SCSI_ASC_MEDIA_ERR2 (0x11) +#define EFI_SCSI_ASC_MEDIA_ERR3 (0x14) +#define EFI_SCSI_ASC_MEDIA_ERR4 (0x30) +#define EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN (0x06) +#define EFI_SCSI_ASC_INVALID_CMD (0x20) +#define EFI_SCSI_ASC_LBA_OUT_OF_RANGE (0x21) +#define EFI_SCSI_ASC_INVALID_FIELD (0x24) +#define EFI_SCSI_ASC_WRITE_PROTECTED (0x27) +#define EFI_SCSI_ASC_MEDIA_CHANGE (0x28) +#define EFI_SCSI_ASC_RESET (0x29) /* Power On Reset or Bus Reset occurred */ +#define EFI_SCSI_ASC_ILLEGAL_FIELD (0x26) +#define EFI_SCSI_ASC_NO_MEDIA (0x3A) +#define EFI_SCSI_ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64) + +// +// Additional Sense Code Qualifier +// +#define EFI_SCSI_ASCQ_IN_PROGRESS (0x01) + +// +// Max bytes needed to represent ID of a SCSI device +// +#define EFI_SCSI_TARGET_MAX_BYTES (0x10) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h new file mode 100644 index 0000000000..8ccfd11ea8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h @@ -0,0 +1,293 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + usb.h + +Abstract: + Support for USB 1.1 standard. + + + + +Revision History + +--*/ + +#ifndef _USB_H +#define _USB_H +// +// USB Descriptor types +// +#define USB_DT_DEVICE 0x01 +#define USB_DT_CONFIG 0x02 +#define USB_DT_STRING 0x03 +#define USB_DT_INTERFACE 0x04 +#define USB_DT_ENDPOINT 0x05 +#define USB_DT_HUB 0x29 +#define USB_DT_HID 0x21 + +// +// USB request type +// +#define USB_TYPE_STANDARD (0x00 << 5) +#define USB_TYPE_CLASS (0x01 << 5) +#define USB_TYPE_VENDOR (0x02 << 5) +#define USB_TYPE_RESERVED (0x03 << 5) + +// +// USB request targer device +// +#define USB_RECIP_DEVICE 0x00 +#define USB_RECIP_INTERFACE 0x01 +#define USB_RECIP_ENDPOINT 0x02 +#define USB_RECIP_OTHER 0x03 + +// +// Request target types. +// +#define USB_RT_DEVICE 0x00 +#define USB_RT_INTERFACE 0x01 +#define USB_RT_ENDPOINT 0x02 +#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE) +#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER) + +// +// USB Transfer Results +// +#define EFI_USB_NOERROR 0x00 +#define EFI_USB_ERR_NOTEXECUTE 0x01 +#define EFI_USB_ERR_STALL 0x02 +#define EFI_USB_ERR_BUFFER 0x04 +#define EFI_USB_ERR_BABBLE 0x08 +#define EFI_USB_ERR_NAK 0x10 +#define EFI_USB_ERR_CRC 0x20 +#define EFI_USB_ERR_TIMEOUT 0x40 +#define EFI_USB_ERR_BITSTUFF 0x80 +#define EFI_USB_ERR_SYSTEM 0x100 + +// +//Use 200 ms to increase the error handling response time +// +#define EFI_USB_INTERRUPT_DELAY 2000000 + +// +// USB transation direction +// +typedef enum { + EfiUsbDataIn, + EfiUsbDataOut, + EfiUsbNoData +} EFI_USB_DATA_DIRECTION; + +// +// Usb Data recipient type +// +typedef enum { + EfiUsbDevice, + EfiUsbInterface, + EfiUsbEndpoint +} EFI_USB_RECIPIENT; + +typedef enum { + EfiUsbEndpointHalt, + EfiUsbDeviceRemoteWakeup +} EFI_USB_STANDARD_FEATURE_SELECTOR; + +#pragma pack(1) +// +// Usb device request structure +// +typedef struct { + UINT8 RequestType; + UINT8 Request; + UINT16 Value; + UINT16 Index; + UINT16 Length; +} EFI_USB_DEVICE_REQUEST; + +// +// Standard USB request +// +#define USB_DEV_GET_STATUS 0x00 + +#define USB_DEV_CLEAR_FEATURE 0x01 + +#define USB_DEV_SET_FEATURE 0x03 + +#define USB_DEV_SET_ADDRESS 0x05 +#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00 + +#define USB_DEV_GET_DESCRIPTOR 0x06 +#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80 + +#define USB_DEV_SET_DESCRIPTOR 0x07 +#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00 + +#define USB_DEV_GET_CONFIGURATION 0x08 +#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80 + +#define USB_DEV_SET_CONFIGURATION 0x09 +#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00 + +#define USB_DEV_GET_INTERFACE 0x0A +#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81 + +#define USB_DEV_SET_INTERFACE 0x0B +#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01 + +#define USB_DEV_SYNCH_FRAME 0x0C +#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82 + +// +// Device descriptor. refer USB1.1 +// +typedef struct usb_device_descriptor { + UINT8 Length; + UINT8 DescriptorType; + UINT16 BcdUSB; + UINT8 DeviceClass; + UINT8 DeviceSubClass; + UINT8 DeviceProtocol; + UINT8 MaxPacketSize0; + UINT16 IdVendor; + UINT16 IdProduct; + UINT16 BcdDevice; + UINT8 StrManufacturer; + UINT8 StrProduct; + UINT8 StrSerialNumber; + UINT8 NumConfigurations; +} EFI_USB_DEVICE_DESCRIPTOR; + +// +// Endpoint descriptor +// +typedef struct { + UINT8 Length; + UINT8 DescriptorType; + UINT8 EndpointAddress; + UINT8 Attributes; + UINT16 MaxPacketSize; + UINT8 Interval; +} EFI_USB_ENDPOINT_DESCRIPTOR; + +// +// Interface descriptor +// +typedef struct { + UINT8 Length; + UINT8 DescriptorType; + UINT8 InterfaceNumber; + UINT8 AlternateSetting; + UINT8 NumEndpoints; + UINT8 InterfaceClass; + UINT8 InterfaceSubClass; + UINT8 InterfaceProtocol; + UINT8 Interface; +} EFI_USB_INTERFACE_DESCRIPTOR; + +// +// USB alternate setting +// +typedef struct { + EFI_USB_INTERFACE_DESCRIPTOR *Interface; +} USB_ALT_SETTING; + +// +// Configuration descriptor +// +typedef struct { + UINT8 Length; + UINT8 DescriptorType; + UINT16 TotalLength; + UINT8 NumInterfaces; + UINT8 ConfigurationValue; + UINT8 Configuration; + UINT8 Attributes; + UINT8 MaxPower; +} EFI_USB_CONFIG_DESCRIPTOR; + +// +// Supported String Languages +// +typedef struct { + UINT8 Length; + UINT8 DescriptorType; + UINT16 SupportedLanID[1]; +} EFI_USB_SUPPORTED_LANGUAGES; + +// +// String descriptor +// +typedef struct { + UINT8 Length; + UINT8 DescriptorType; + CHAR16 String[1]; +} EFI_USB_STRING_DESCRIPTOR; + +// +// Hub descriptor +// +#define MAXBYTES 8 +typedef struct { + UINT8 Length; + UINT8 DescriptorType; + UINT8 NbrPorts; + UINT8 HubCharacteristics[2]; + UINT8 PwrOn2PwrGood; + UINT8 HubContrCurrent; + UINT8 Filler[MAXBYTES]; +} EFI_USB_HUB_DESCRIPTOR; + +typedef struct { + UINT16 PortStatus; + UINT16 PortChangeStatus; +} EFI_USB_PORT_STATUS; + +// +// Constant value for Port Status & Port Change Status +// +#define USB_PORT_STAT_CONNECTION 0x0001 +#define USB_PORT_STAT_ENABLE 0x0002 +#define USB_PORT_STAT_SUSPEND 0x0004 +#define USB_PORT_STAT_OVERCURRENT 0x0008 +#define USB_PORT_STAT_RESET 0x0010 +#define USB_PORT_STAT_POWER 0x0100 +#define USB_PORT_STAT_LOW_SPEED 0x0200 +#define USB_PORT_STAT_HIGH_SPEED 0x0400 +#define USB_PORT_STAT_OWNER 0x0800 + +#define USB_PORT_STAT_C_CONNECTION 0x0001 +#define USB_PORT_STAT_C_ENABLE 0x0002 +#define USB_PORT_STAT_C_SUSPEND 0x0004 +#define USB_PORT_STAT_C_OVERCURRENT 0x0008 +#define USB_PORT_STAT_C_RESET 0x0010 + +// +// Used for set/clear port feature request +// +typedef enum { + EfiUsbPortEnable = 1, + EfiUsbPortSuspend = 2, + EfiUsbPortReset = 4, + EfiUsbPortPower = 8, + EfiUsbPortOwner = 13, + EfiUsbPortConnectChange = 16, + EfiUsbPortEnableChange = 17, + EfiUsbPortSuspendChange = 18, + EfiUsbPortOverCurrentChange = 19, + EfiUsbPortResetChange = 20 +} EFI_USB_PORT_FEATURE; + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiBind.h new file mode 100644 index 0000000000..cad7ca1de8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiBind.h @@ -0,0 +1,247 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiBind.h + +Abstract: + + Processor or Compiler specific defines and types for Intel Itanium(TM). + We are using the ANSI C 2000 _t type definitions for basic types. + This it technically a violation of the coding standard, but they + are used to make EfiTypes.h portable. Code other than EfiTypes.h + should never use any ANSI C 2000 _t integer types. + +--*/ + +#ifndef _EFI_BIND_H_ +#define _EFI_BIND_H_ + + +#define EFI_DRIVER_ENTRY_POINT(InitFunction) + +#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT + + + + +// +// Make sure we are useing the correct packing rules per EFI specification +// +#pragma pack() + + +#if _MSC_EXTENSIONS + +// +// Disable warning that make it impossible to compile at /W4 +// This only works for Microsoft tools. Copied from the +// IA-32 version of efibind.h +// + +// +// Disabling bitfield type checking warnings. +// +#pragma warning ( disable : 4214 ) + + +// Disabling the unreferenced formal parameter warnings. +// +#pragma warning ( disable : 4100 ) + +// +// Disable slightly different base types warning as CHAR8 * can not be set +// to a constant string. +// +#pragma warning ( disable : 4057 ) + +// +// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning +// +#pragma warning ( disable : 4127 ) + +// +// Can not cast a function pointer to a data pointer. We need to do this on +// IPF to get access to the PLABEL. +// +#pragma warning ( disable : 4514 ) + +// +// Int64ShllMod32 unreferenced inline function +// +#pragma warning ( disable : 4054 ) + +// +// Unreferenced formal parameter - We are object oriented, so we pass This even +// if we don't need them. +// +#pragma warning ( disable : 4100 ) + +// +// This warning is caused by empty (after preprocessing) souce file. +// +#pragma warning ( disable : 4206 ) + +// +// Warning: The result of the unary '&' operator may be unaligned. Ignore it. +// +#pragma warning ( disable : 4366 ) + +#endif + + +#if (__STDC_VERSION__ < 199901L) + // + // No ANSI C 2000 stdint.h integer width declarations, so define equivalents + // + + #if _MSC_EXTENSIONS + + + // + // use Microsoft C complier dependent interger width types + // + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; + typedef unsigned __int32 uint32_t; + typedef __int32 int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + #ifdef _EFI_P64 + // + // P64 - is Intel Itanium(TM) speak for pointers being 64-bit and longs and ints + // are 32-bits + // + typedef unsigned long long uint64_t; + typedef long long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + // + // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit. + // + typedef unsigned long uint64_t; + typedef long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #endif + #endif +#else + // + // Use ANSI C 2000 stdint.h integer width declarations + // + #include "stdint.h" +#endif + +// +// Native integer size in stdint.h +// +typedef uint64_t uintn_t; +typedef int64_t intn_t; + +// +// Processor specific defines +// +#define EFI_MAX_BIT 0x8000000000000000 +#define MAX_2_BITS 0xC000000000000000 + +// +// Maximum legal Itanium-based address +// +#define EFI_MAX_ADDRESS 0xFFFFFFFFFFFFFFFF + +// +// Bad pointer value to use in check builds. +// if you see this value you are using uninitialized or free'ed data +// +#define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAF +#define EFI_BAD_POINTER_AS_BYTE 0xAF + +// +// Inject a break point in the code to assist debugging. +// +#pragma intrinsic (__break) +#define EFI_BREAKPOINT() __break(0) +#define EFI_DEADLOOP() while(TRUE) + +// +// Memory Fence forces serialization, and is needed to support out of order +// memory transactions. The Memory Fence is mainly used to make sure IO +// transactions complete in a deterministic sequence, and to syncronize locks +// an other MP code. Intel Itanium(TM) processors require explicit memory fence instructions +// after every IO. Need to find a way of doing that in the function _mf. +// +void __mfa (void); +#pragma intrinsic (__mfa) +#define MEMORY_FENCE() __mfa() + + +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX. The forward reference is required for +// ANSI compatibility. +// +// The following macro provide a workaround for such cases. +// + + +#ifdef EFI_NO_INTERFACE_DECL + #define EFI_FORWARD_DECLARATION(x) +#else + #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x +#endif + +// +// Some C compilers optimize the calling conventions to increase performance. +// _EFIAPI is used to make all public APIs follow the standard C calling +// convention. +// + +#if _MSC_EXTENSIONS + #define _EFIAPI __cdecl +#else + #define _EFIAPI +#endif + + +#ifdef _EFI_WINNT + + #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( disable : 4142 ) + + #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( default : 4142 ) +#else + + #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( disable : 4068 ) + + #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( default : 4068 ) + + +#endif + + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiPeOptionalHeader.h new file mode 100644 index 0000000000..53de8aaa7e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ipf/EfiPeOptionalHeader.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPeOptionalHeader.h + +Abstract: + Defines the optional header in the PE image per the PE specification. This + file must be included only from within EfiImage.h since + EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined + there. + +--*/ + +#ifndef _EFI_PE_OPTIONAL_HEADER_H_ +#define _EFI_PE_OPTIONAL_HEADER_H_ + +#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_IA64) + +#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ + (((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC)) + +#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) + +#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC +typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER; +typedef EFI_IMAGE_NT_HEADERS64 EFI_IMAGE_NT_HEADERS; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfDefines.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfDefines.h new file mode 100644 index 0000000000..0fe1407525 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfDefines.h @@ -0,0 +1,556 @@ +// ++ + +// TODO: fix comment to start with /*++ +// +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// IpfDefines.h +// +// Abstract: +// +// IPF Processor Defines. +// NOTE: This file is included by assembly files as well. +// +// -- +// +#ifndef _IPFDEFINES_H +#define _IPFDEFINES_H + +// +// IPI DElivery Methods +// +#define IPI_INT_DELIVERY 0x0 +#define IPI_PMI_DELIVERY 0x2 +#define IPI_NMI_DELIVERY 0x4 +#define IPI_INIT_DELIVERY 0x5 +#define IPI_ExtINT_DELIVERY 0x7 + +// +// Define Itanium-based system registers. +// +// Define Itanium-based system register bit field offsets. +// +// Processor Status Register (PSR) Bit positions +// +// User / System mask +// +#define PSR_RV0 0 +#define PSR_BE 1 +#define PSR_UP 2 +#define PSR_AC 3 +#define PSR_MFL 4 +#define PSR_MFH 5 + +// +// PSR bits 6-12 reserved (must be zero) +// +#define PSR_MBZ0 6 +#define PSR_MBZ0_V 0x1ffUL L + +// +// System only mask +// +#define PSR_IC 13 +#define PSR_IC_MASK (1 << 13) +#define PSR_I 14 +#define PSR_PK 15 +#define PSR_MBZ1 16 +#define PSR_MBZ1_V 0x1UL L +#define PSR_DT 17 +#define PSR_DFL 18 +#define PSR_DFH 19 +#define PSR_SP 20 +#define PSR_PP 21 +#define PSR_DI 22 +#define PSR_SI 23 +#define PSR_DB 24 +#define PSR_LP 25 +#define PSR_TB 26 +#define PSR_RT 27 + +// +// PSR bits 28-31 reserved (must be zero) +// +#define PSR_MBZ2 28 +#define PSR_MBZ2_V 0xfUL L + +// +// Neither mask +// +#define PSR_CPL 32 +#define PSR_CPL_LEN 2 +#define PSR_IS 34 +#define PSR_MC 35 +#define PSR_IT 36 +#define PSR_IT_MASK 0x1000000000 +#define PSR_ID 37 +#define PSR_DA 38 +#define PSR_DD 39 +#define PSR_SS 40 +#define PSR_RI 41 +#define PSR_RI_LEN 2 +#define PSR_ED 43 +#define PSR_BN 44 + +// +// PSR bits 45-63 reserved (must be zero) +// +#define PSR_MBZ3 45 +#define PSR_MBZ3_V 0xfffffUL L + +// +// Floating Point Status Register (FPSR) Bit positions +// +// +// Traps +// +#define FPSR_VD 0 +#define FPSR_DD 1 +#define FPSR_ZD 2 +#define FPSR_OD 3 +#define FPSR_UD 4 +#define FPSR_ID 5 + +// +// Status Field 0 - Controls +// +#define FPSR0_FTZ0 6 +#define FPSR0_WRE0 7 +#define FPSR0_PC0 8 +#define FPSR0_RC0 10 +#define FPSR0_TD0 12 + +// +// Status Field 0 - Flags +// +#define FPSR0_V0 13 +#define FPSR0_D0 14 +#define FPSR0_Z0 15 +#define FPSR0_O0 16 +#define FPSR0_U0 17 +#define FPSR0_I0 18 + +// +// Status Field 1 - Controls +// +#define FPSR1_FTZ0 19 +#define FPSR1_WRE0 20 +#define FPSR1_PC0 21 +#define FPSR1_RC0 23 +#define FPSR1_TD0 25 + +// +// Status Field 1 - Flags +// +#define FPSR1_V0 26 +#define FPSR1_D0 27 +#define FPSR1_Z0 28 +#define FPSR1_O0 29 +#define FPSR1_U0 30 +#define FPSR1_I0 31 + +// +// Status Field 2 - Controls +// +#define FPSR2_FTZ0 32 +#define FPSR2_WRE0 33 +#define FPSR2_PC0 34 +#define FPSR2_RC0 36 +#define FPSR2_TD0 38 + +// +// Status Field 2 - Flags +// +#define FPSR2_V0 39 +#define FPSR2_D0 40 +#define FPSR2_Z0 41 +#define FPSR2_O0 42 +#define FPSR2_U0 43 +#define FPSR2_I0 44 + +// +// Status Field 3 - Controls +// +#define FPSR3_FTZ0 45 +#define FPSR3_WRE0 46 +#define FPSR3_PC0 47 +#define FPSR3_RC0 49 +#define FPSR3_TD0 51 + +// +// Status Field 0 - Flags +// +#define FPSR3_V0 52 +#define FPSR3_D0 53 +#define FPSR3_Z0 54 +#define FPSR3_O0 55 +#define FPSR3_U0 56 +#define FPSR3_I0 57 + +// +// FPSR bits 58-63 Reserved -- Must be zero +// +#define FPSR_MBZ0 58 +#define FPSR_MBZ0_V 0x3fUL L + +// +// For setting up FPSR on kernel entry +// All traps are disabled. +// +#define FPSR_FOR_KERNEL 0x3f + +#define FP_REG_SIZE 16 // 16 byte spill size +#define HIGHFP_REGS_LENGTH (96 * 16) + +// +// Define hardware Task Priority Register (TPR) +// +// +// TPR bit positions +// +#define TPR_MIC 4 // Bits 0 - 3 ignored +#define TPR_MIC_LEN 4 +#define TPR_MMI 16 // Mask Maskable Interrupt +// +// Define hardware Interrupt Status Register (ISR) +// +// +// ISR bit positions +// +#define ISR_CODE 0 +#define ISR_CODE_LEN 16 +#define ISR_CODE_MASK 0xFFFF +#define ISR_IA_VECTOR 16 +#define ISR_IA_VECTOR_LEN 8 +#define ISR_MBZ0 24 +#define ISR_MBZ0_V 0xff +#define ISR_X 32 +#define ISR_W 33 +#define ISR_R 34 +#define ISR_NA 35 +#define ISR_SP 36 +#define ISR_RS 37 +#define ISR_IR 38 +#define ISR_NI 39 +#define ISR_MBZ1 40 +#define ISR_EI 41 +#define ISR_ED 43 +#define ISR_MBZ2 44 +#define ISR_MBZ2_V 0xfffff + +// +// ISR codes +// +// For General exceptions: ISR{3:0} +// +#define ISR_ILLEGAL_OP 0 // Illegal operation fault +#define ISR_PRIV_OP 1 // Privileged operation fault +#define ISR_PRIV_REG 2 // Privileged register fauls +#define ISR_RESVD_REG 3 // Reserved register/field flt +#define ISR_ILLEGAL_ISA 4 // Disabled instruction set transition fault +// +// Define hardware Default Control Register (DCR) +// +// +// DCR bit positions +// +#define DCR_PP 0 +#define DCR_BE 1 +#define DCR_LC 2 +#define DCR_MBZ0 4 +#define DCR_MBZ0_V 0xf +#define DCR_DM 8 +#define DCR_DP 9 +#define DCR_DK 10 +#define DCR_DX 11 +#define DCR_DR 12 +#define DCR_DA 13 +#define DCR_DD 14 +#define DCR_DEFER_ALL 0x7f00 +#define DCR_MBZ1 2 +#define DCR_MBZ1_V 0xffffffffffffUL L + +// +// Define hardware RSE Configuration Register +// +// RS Configuration (RSC) bit field positions +// +#define RSC_MODE 0 +#define RSC_PL 2 +#define RSC_BE 4 +#define RSC_MBZ0 5 +#define RSC_MBZ0_V 0x3ff +#define RSC_LOADRS 16 +#define RSC_LOADRS_LEN 14 +#define RSC_MBZ1 30 +#define RSC_MBZ1_V 0x3ffffffffUL L + +// +// RSC modes +// +#define RSC_MODE_LY (0x0) // Lazy +#define RSC_MODE_SI (0x1) // Store intensive +#define RSC_MODE_LI (0x2) // Load intensive +#define RSC_MODE_EA (0x3) // Eager +// +// RSC Endian bit values +// +#define RSC_BE_LITTLE 0 +#define RSC_BE_BIG 1 + +// +// Define Interruption Function State (IFS) Register +// +// IFS bit field positions +// +#define IFS_IFM 0 +#define IFS_IFM_LEN 38 +#define IFS_MBZ0 38 +#define IFS_MBZ0_V 0x1ffffff +#define IFS_V 63 +#define IFS_V_LEN 1 + +// +// IFS is valid when IFS_V = IFS_VALID +// +#define IFS_VALID 1 + +// +// Define Page Table Address (PTA) +// +#define PTA_VE 0 +#define PTA_VF 8 +#define PTA_SIZE 2 +#define PTA_SIZE_LEN 6 +#define PTA_BASE 15 + +// +// Define Region Register (RR) +// +// +// RR bit field positions +// +#define RR_VE 0 +#define RR_MBZ0 1 +#define RR_PS 2 +#define RR_PS_LEN 6 +#define RR_RID 8 +#define RR_RID_LEN 24 +#define RR_MBZ1 32 + +// +// SAL uses region register 0 and RID of 1000 +// +#define SAL_RID 0x1000 +#define SAL_RR_REG 0x0 +#define SAL_TR 0x0 + +// +// Total number of region registers +// +#define RR_SIZE 8 + +// +// Define Protection Key Register (PKR) +// +// PKR bit field positions +// +#define PKR_V 0 +#define PKR_WD 1 +#define PKR_RD 2 +#define PKR_XD 3 +#define PKR_MBZ0 4 +#define PKR_KEY 8 +#define PKR_KEY_LEN 24 +#define PKR_MBZ1 32 + +#define PKR_VALID (1 << PKR_V) + +// +// Number of protection key registers +// +#define PKRNUM 8 + +// +// Define Interruption TLB Insertion register (ITIR) +// +// +// Define Translation Insertion Format (TR) +// +// PTE0 bit field positions +// +#define PTE0_P 0 +#define PTE0_MBZ0 1 +#define PTE0_MA 2 +#define PTE0_A 5 +#define PTE0_D 6 +#define PTE0_PL 7 +#define PTE0_AR 9 +#define PTE0_PPN 12 +#define PTE0_MBZ1 48 +#define PTE0_ED 52 +#define PTE0_IGN0 53 + +// +// ITIR bit field positions +// +#define ITIR_MBZ0 0 +#define ITIR_PS 2 +#define ITIR_PS_LEN 6 +#define ITIR_KEY 8 +#define ITIR_KEY_LEN 24 +#define ITIR_MBZ1 32 +#define ITIR_MBZ1_LEN 16 +#define ITIR_PPN 48 +#define ITIR_PPN_LEN 15 +#define ITIR_MBZ2 63 + +#define ATTR_IPAGE 0x661 // Access Rights = RWX (bits 11-9=011), PL 0(8-7=0) +#define ATTR_DEF_BITS 0x661 // Access Rights = RWX (bits 11-9=010), PL 0(8-7=0) +// Dirty (bit 6=1), Accessed (bit 5=1), +// MA WB (bits 4-2=000), Present (bit 0=1) +// +// Memory access rights +// +#define AR_UR_KR 0x0 // user/kernel read +#define AR_URX_KRX 0x1 // user/kernel read and execute +#define AR_URW_KRW 0x2 // user/kernel read & write +#define AR_URWX_KRWX 0x3 // user/kernel read,write&execute +#define AR_UR_KRW 0x4 // user read/kernel read,write +#define AR_URX_KRWX 0x5 // user read/execute, kernel all +#define AR_URWX_KRW 0x6 // user all, kernel read & write +#define AR_UX_KRX 0x7 // user execute only, kernel read and execute +// +// Memory attribute values +// +// +// The next 4 are all cached, non-sequential & speculative, coherent +// +#define MA_WBU 0x0 // Write back, unordered +// +// The next 3 are all non-cached, sequential & non-speculative +// +#define MA_UC 0x4 // Non-coalescing, sequential & non-speculative +#define MA_UCE 0x5 // Non-coalescing, sequential, non-speculative +// & fetchadd exported +// +#define MA_WC 0x6 // Non-cached, Coalescing, non-seq., spec. +#define MA_NAT 0xf // NaT page +// +// Definition of the offset of TRAP/INTERRUPT/FAULT handlers from the +// base of IVA (Interruption Vector Address) +// +#define IVT_SIZE 0x8000 +#define EXTRA_ALIGNMENT 0x1000 + +#define OFF_VHPTFLT 0x0000 // VHPT Translation fault +#define OFF_ITLBFLT 0x0400 // Instruction TLB fault +#define OFF_DTLBFLT 0x0800 // Data TLB fault +#define OFF_ALTITLBFLT 0x0C00 // Alternate ITLB fault +#define OFF_ALTDTLBFLT 0x1000 // Alternate DTLB fault +#define OFF_NESTEDTLBFLT 0x1400 // Nested TLB fault +#define OFF_IKEYMISSFLT 0x1800 // Inst Key Miss fault +#define OFF_DKEYMISSFLT 0x1C00 // Data Key Miss fault +#define OFF_DIRTYBITFLT 0x2000 // Dirty-Bit fault +#define OFF_IACCESSBITFLT 0x2400 // Inst Access-Bit fault +#define OFF_DACCESSBITFLT 0x2800 // Data Access-Bit fault +#define OFF_BREAKFLT 0x2C00 // Break Inst fault +#define OFF_EXTINT 0x3000 // External Interrupt +// +// Offset 0x3400 to 0x0x4C00 are reserved +// +#define OFF_PAGENOTPFLT 0x5000 // Page Not Present fault +#define OFF_KEYPERMFLT 0x5100 // Key Permission fault +#define OFF_IACCESSRTFLT 0x5200 // Inst Access-Rights flt +#define OFF_DACCESSRTFLT 0x5300 // Data Access-Rights fault +#define OFF_GPFLT 0x5400 // General Exception fault +#define OFF_FPDISFLT 0x5500 // Disable-FP fault +#define OFF_NATFLT 0x5600 // NAT Consumption fault +#define OFF_SPECLNFLT 0x5700 // Speculation fault +#define OFF_DBGFLT 0x5900 // Debug fault +#define OFF_ALIGNFLT 0x5A00 // Unaligned Reference fault +#define OFF_LOCKDREFFLT 0x5B00 // Locked Data Reference fault +#define OFF_FPFLT 0x5C00 // Floating Point fault +#define OFF_FPTRAP 0x5D00 // Floating Point Trap +#define OFF_LOPRIVTRAP 0x5E00 // Lower-Privilege Transfer Trap +#define OFF_TAKENBRTRAP 0x5F00 // Taken Branch Trap +#define OFF_SSTEPTRAP 0x6000 // Single Step Trap +// +// Offset 0x6100 to 0x6800 are reserved +// +#define OFF_IA32EXCEPTN 0x6900 // iA32 Exception +#define OFF_IA32INTERCEPT 0x6A00 // iA32 Intercept +#define OFF_IA32INT 0x6B00 // iA32 Interrupt +#define NUMBER_OF_VECTORS 0x100 +// +// Privilege levels +// +#define PL_KERNEL 0 +#define PL_USER 3 + +// +// Instruction set (IS) bits +// +#define IS_IA64 0 +#define IS_IA 1 + +// +// RSC while in kernel: enabled, little endian, PL = 0, eager mode +// +#define RSC_KERNEL ((RSC_MODE_EA << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE)) + +// +// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode +// +#define RSC_KERNEL_LAZ ((RSC_MODE_LY << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE)) + +// +// RSE disabled: disabled, PL = 0, little endian, eager mode +// +#define RSC_KERNEL_DISABLED ((RSC_MODE_LY << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE)) + +#define NAT_BITS_PER_RNAT_REG 63 + +// +// Macros for generating PTE0 and PTE1 value +// +#define PTE0(ed, ppn12_47, ar, pl, d, a, ma, p) \ + ( ( ed << PTE0_ED ) | \ + ( ppn12_47 << PTE0_PPN ) | \ + ( ar << PTE0_AR ) | \ + ( pl << PTE0_PL ) | \ + ( d << PTE0_D ) | \ + ( a << PTE0_A ) | \ + ( ma << PTE0_MA ) | \ + ( p << PTE0_P ) \ + ) + +#define ITIR(ppn48_63, key, ps) \ + ( ( ps << ITIR_PS ) | \ + ( key << ITIR_KEY ) | \ + ( ppn48_63 << ITIR_PPN ) \ + ) + +// +// Macro to generate mask value from bit position. The result is a +// 64-bit. +// +#define BITMASK(bp, value) (value << bp) + +#define BUNDLE_SIZE 16 +#define SPURIOUS_INT 0xF + +#define FAST_DISABLE_INTERRUPTS rsm BITMASK (PSR_I, 1);; + +#define FAST_ENABLE_INTERRUPTS ssm BITMASK (PSR_I, 1);; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfMacro.i b/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfMacro.i new file mode 100644 index 0000000000..68c5f8c540 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ipf/IpfMacro.i @@ -0,0 +1,66 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// IpfMacro.i +// +// Abstract: +// +// Contains the macros needed for calling procedures in Itanium-based assembly code. +// +// +// Revision History: +// +//-- + +#ifndef _IA64PROC_I +#define _IA64PROC_I + + +#define PROCEDURE_ENTRY(name) .##text; \ + .##type name, @function; \ + .##proc name; \ +name:: + +#define PROCEDURE_EXIT(name) .##endp name + +// Note: use of NESTED_SETUP requires number of locals (l) >= 3 + +#define NESTED_SETUP(i,l,o,r) \ + alloc loc1=ar##.##pfs,i,l,o,r ;\ + mov loc0=b0 + +#define NESTED_RETURN \ + mov b0=loc0 ;\ + mov ar##.##pfs=loc1 ;;\ + br##.##ret##.##dpnt b0;; + + +#define INTERRUPT_HANDLER_BEGIN(name) \ +PROCEDURE_ENTRY(name##HandlerBegin) \ +;; \ +PROCEDURE_EXIT(name##HandlerBegin) + +#define INTERRUPT_HANDLER_END(name) \ +PROCEDURE_ENTRY(name##HandlerEnd) \ +;; \ +PROCEDURE_EXIT(name##HandlerEnd) + + +#define INTERRUPT_HANDLER_BLOCK_BEGIN \ +INTERRUPT_HANDLER_BEGIN(First) + +#define INTERRUPT_HANDLER_BLOCK_END \ +INTERRUPT_HANDLER_END(Last) + + + +#endif // _IA64PROC_I diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/PalApi.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/PalApi.h new file mode 100644 index 0000000000..aaa6a64022 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ipf/PalApi.h @@ -0,0 +1,133 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PalApi.h + +Abstract: + + Main PAL API's defined in PAL specification. + + +Revision History: + +--*/ + +#ifndef _PALPROC_H +#define _PALPROC_H + +#include "Tiano.h" + +#define PAL_CACHE_FLUSH 0x0001 +#define PAL_CACHE_INFO 0x0002 +#define PAL_CACHE_INIT 0x0003 +#define PAL_CACHE_SUMMARY 0x0004 +#define PAL_MEM_ATTRIB 0x0005 +#define PAL_PTCE_INFO 0x0006 +#define PAL_VM_INFO 0x0007 +#define PAL_VM_SUMMARY 0x0008 +#define PAL_BUS_GET_FEATURES 0x0009 +#define PAL_BUS_SET_FEATURES 0x000a +#define PAL_DEBUG_INFO 0x000b +#define PAL_FIXED_ADDR 0x000c +#define PAL_FREQ_BASE 0x000d +#define PAL_FREQ_RATIOS 0x000e +#define PAL_PERF_MON_INFO 0x000f +#define PAL_PLATFORM_ADDR 0x0010 +#define PAL_PROC_GET_FEATURES 0x0011 +#define PAL_PROC_SET_FEATURES 0x0012 +#define PAL_RSE_INFO 0x0013 +#define PAL_VERSION 0x0014 + +#define PAL_MC_CLEAR_LOG 0x0015 +#define PAL_MC_DRAIN 0x0016 +#define PAL_MC_EXPECTED 0x0017 +#define PAL_MC_DYNAMIC_STATE 0x0018 +#define PAL_MC_ERROR_INFO 0x0019 +#define PAL_MC_RESUME 0x001a +#define PAL_MC_REGISTER_MEM 0x001b +#define PAL_HALT 0x001c +#define PAL_HALT_LIGHT 0x001d +#define PAL_COPY_INFO 0x001e +#define PAL_SHUTDOWN 0x002c +#define PAL_AUTH 0x0209 +#define PAL_SINGL_DISPERSAL 0x0226 // dec. 550 +#define PAL_HALT_INFO 0x0101 +#define PAL_CACHE_LINE_INIT 0x001f +#define PAL_PMI_ENTRYPOINT 0x0020 +#define PAL_ENTER_IA_32_ENV 0x0021 +#define PAL_VM_PAGE_SIZE 0x0022 +#define PAL_MEM_FOR_TEST 0x0025 +#define PAL_CACHE_PROT_INFO 0x0026 + +#define PAL_COPY_PAL 0x0100 +#define PAL_CACHE_READ 0x0103 +#define PAL_CACHE_WRITE 0x0104 +#define PAL_TEST_PROC 0x0102 + +#define PAL_DEBUG_FEATURE 0x0063 // vp1 +typedef UINT64 EFI_PAL_STATUS; + +// +// Return values from PAL +// +typedef struct { + EFI_PAL_STATUS Status; // register r8 + UINT64 r9; + UINT64 r10; + UINT64 r11; +} PAL_RETURN_REGS; + +// +// PAL equates for other parameters. +// +#define PAL_SUCCESS 0x0 +#define PAL_CALL_ERROR 0xfffffffffffffffd +#define PAL_CALL_UNIMPLEMENTED 0xffffffffffffffff +#define PAL_CACHE_TYPE_I 0x1 +#define PAL_CACHE_TYPE_D 0x2 +#define PAL_CACHE_TYPE_I_AND_D 0x3 +#define PAL_CACHE_NO_INT 0x0 +#define PAL_CACHE_INT 0x2 +// +// #define PAL_CACHE_PLAT_ACK 0x4 +// +#define PAL_CACHE_NO_PLAT_ACK 0x0 +#define PAL_CACHE_INVALIDATE 0x1 +#define PAL_CACHE_NO_INVALIDATE 0x0 +#define PAL_CACHE_ALL_LEVELS - 0x1 + +#define PAL_FEATURE_ENABLE 0x1 +#define PAL_ENABLE_BERR_BIT 63 +#define PAL_ENABLE_MCA_BINIT_BIT 61 +#define PAL_ENABLE_CMCI_MCA_BIT 60 +#define PAL_CACHE_DISABLE_BIT 59 +#define PAL_DISABLE_COHERENCY_BIT 58 + +#define PAL_DIS_BUS_DATA_ERR_CHECK_BIT 63 +#define PAL_DIS_BUS_ADDR_ERR_CHECK_BIT 61 +#define PAL_DIS_BUS_INIT_EVENT_SIGNAL_BIT 60 +#define PAL_DIS_BUS_REQ_ERR_SIGNAL_BIT 58 +#define PAL_DIS_BUS_REQ_INT_ERR_SIGNAL_BIT 57 +#define PAL_DIS_BUS_REQ_ERR_CHECK_BIT 56 +#define PAL_DIS_BUS_RESP_ERR_CHECK_BIT 55 + +#define PAL_COPY_BSP_TOKEN 0x0 +#define PAL_COPY_AP_TOKEN 0x1 + +#define PAL_CODE_TOKEN 0x0 +#define PAL_IA32EMU_CODE_TOKEN 0x1 + +#define PAL_INTERRUPT_BLOCK_TOKEN 0x0 +#define PAL_IO_BLOCK_TOKEN 0x1 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/SalApi.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/SalApi.h new file mode 100644 index 0000000000..a6a7e4d838 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ipf/SalApi.h @@ -0,0 +1,724 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SalApi.h + +Abstract: + + Main SAL API's defined in SAL 3.0 specification. + + +Revision History: + +--*/ + +#ifndef _SAL_API_H_ +#define _SAL_API_H_ + +typedef UINTN EFI_SAL_STATUS; + +// +// EFI_SAL_STATUS defines +// +#define EFI_SAL_SUCCESS ((EFI_SAL_STATUS) 0) +#define EFI_SAL_MORE_RECORDS ((EFI_SAL_STATUS) 3) +#define EFI_SAL_NOT_IMPLEMENTED ((EFI_SAL_STATUS) - 1) +#define EFI_SAL_INVALID_ARGUMENT ((EFI_SAL_STATUS) - 2) +#define EFI_SAL_ERROR ((EFI_SAL_STATUS) - 3) +#define EFI_SAL_VIRTUAL_ADDRESS_ERROR ((EFI_SAL_STATUS) - 4) +#define EFI_SAL_NO_INFORMATION ((EFI_SAL_STATUS) - 5) +#define EFI_SAL_NOT_ENOUGH_SCRATCH ((EFI_SAL_STATUS) - 9) + +// +// Delivery Mode of IPF CPU. +// +typedef enum { + INT, + MPreserved1, + PMI, + MPreserved2, + NMI, + INIT, + MPreserved3, + ExtINT +} EFI_DELIVERY_MODE; + +// +// Return values from SAL +// +typedef struct { + EFI_SAL_STATUS Status; // register r8 + UINTN r9; + UINTN r10; + UINTN r11; +} SAL_RETURN_REGS; + +typedef SAL_RETURN_REGS (EFIAPI *SAL_PROC) + ( + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ); + +// +// SAL Procedure FunctionId definition +// +#define EFI_SAL_SET_VECTORS 0x01000000 +#define EFI_SAL_GET_STATE_INFO 0x01000001 +#define EFI_SAL_GET_STATE_INFO_SIZE 0x01000002 +#define EFI_SAL_CLEAR_STATE_INFO 0x01000003 +#define EFI_SAL_MC_RENDEZ 0x01000004 +#define EFI_SAL_MC_SET_PARAMS 0x01000005 +#define EFI_SAL_REGISTER_PHYSICAL_ADDR 0x01000006 +#define EFI_SAL_CACHE_FLUSH 0x01000008 +#define EFI_SAL_CACHE_INIT 0x01000009 +#define EFI_SAL_PCI_CONFIG_READ 0x01000010 +#define EFI_SAL_PCI_CONFIG_WRITE 0x01000011 +#define EFI_SAL_FREQ_BASE 0x01000012 +#define EFI_SAL_UPDATE_PAL 0x01000020 + +#define EFI_SAL_FUNCTION_ID_MASK 0x0000ffff +#define EFI_SAL_MAX_SAL_FUNCTION_ID 0x00000021 + +// +// SAL Procedure parameter definitions +// Not much point in using typedefs or enums because all params +// are UINT64 and the entry point is common +// +// EFI_SAL_SET_VECTORS +// +#define EFI_SAL_SET_MCA_VECTOR 0x0 +#define EFI_SAL_SET_INIT_VECTOR 0x1 +#define EFI_SAL_SET_BOOT_RENDEZ_VECTOR 0x2 + +typedef struct { + UINT64 Length : 32; + UINT64 ChecksumValid : 1; + UINT64 Reserved1 : 7; + UINT64 ByteChecksum : 8; + UINT64 Reserved2 : 16; +} SAL_SET_VECTORS_CS_N; + +// +// EFI_SAL_GET_STATE_INFO, EFI_SAL_GET_STATE_INFO_SIZE, +// EFI_SAL_CLEAR_STATE_INFO +// +#define EFI_SAL_MCA_STATE_INFO 0x0 +#define EFI_SAL_INIT_STATE_INFO 0x1 +#define EFI_SAL_CMC_STATE_INFO 0x2 +#define EFI_SAL_CP_STATE_INFO 0x3 + +// +// EFI_SAL_MC_SET_PARAMS +// +#define EFI_SAL_MC_SET_RENDEZ_PARAM 0x1 +#define EFI_SAL_MC_SET_WAKEUP_PARAM 0x2 +#define EFI_SAL_MC_SET_CPE_PARAM 0x3 + +#define EFI_SAL_MC_SET_INTR_PARAM 0x1 +#define EFI_SAL_MC_SET_MEM_PARAM 0x2 + +// +// EFI_SAL_REGISTER_PAL_PHYSICAL_ADDR +// +#define EFI_SAL_REGISTER_PAL_ADDR 0x0 + +// +// EFI_SAL_CACHE_FLUSH +// +#define EFI_SAL_FLUSH_I_CACHE 0x01 +#define EFI_SAL_FLUSH_D_CACHE 0x02 +#define EFI_SAL_FLUSH_BOTH_CACHE 0x03 +#define EFI_SAL_FLUSH_MAKE_COHERENT 0x04 + +// +// EFI_SAL_PCI_CONFIG_READ, EFI_SAL_PCI_CONFIG_WRITE +// +#define EFI_SAL_PCI_CONFIG_ONE_BYTE 0x1 +#define EFI_SAL_PCI_CONFIG_TWO_BYTES 0x2 +#define EFI_SAL_PCI_CONFIG_FOUR_BYTES 0x4 + +typedef struct { + UINT64 Register : 8; + UINT64 Function : 3; + UINT64 Device : 5; + UINT64 Bus : 8; + UINT64 Segment : 8; + UINT64 Reserved : 32; +} SAL_PCI_ADDRESS; + +// +// EFI_SAL_FREQ_BASE +// +#define EFI_SAL_CPU_INPUT_FREQ_BASE 0x0 +#define EFI_SAL_PLATFORM_IT_FREQ_BASE 0x1 +#define EFI_SAL_PLATFORM_RTC_FREQ_BASE 0x2 + +// +// EFI_SAL_UPDATE_PAL +// +#define EFI_SAL_UPDATE_BAD_PAL_VERSION ((UINT64) -1) +#define EFI_SAL_UPDATE_PAL_AUTH_FAIL ((UINT64) -2) +#define EFI_SAL_UPDATE_PAL_BAD_TYPE ((UINT64) -3) +#define EFI_SAL_UPDATE_PAL_READONLY ((UINT64) -4) +#define EFI_SAL_UPDATE_PAL_WRITE_FAIL ((UINT64) -10) +#define EFI_SAL_UPDATE_PAL_ERASE_FAIL ((UINT64) -11) +#define EFI_SAL_UPDATE_PAL_READ_FAIL ((UINT64) -12) +#define EFI_SAL_UPDATE_PAL_CANT_FIT ((UINT64) -13) + +typedef struct { + UINT32 Size; + UINT32 MmddyyyyDate; + UINT16 Version; + UINT8 Type; + UINT8 Reserved[5]; + UINT64 FwVendorId; +} SAL_UPDATE_PAL_DATA_BLOCK; + +typedef struct _SAL_UPDATE_PAL_INFO_BLOCK { + struct _SAL_UPDATE_PAL_INFO_BLOCK *Next; + struct SAL_UPDATE_PAL_DATA_BLOCK *DataBlock; + UINT8 StoreChecksum; + UINT8 Reserved[15]; +} SAL_UPDATE_PAL_INFO_BLOCK; + +// +// SAL System Table Definitions +// +#pragma pack(1) +typedef struct { + UINT32 Signature; + UINT32 Length; + UINT16 SalRevision; + UINT16 EntryCount; + UINT8 CheckSum; + UINT8 Reserved[7]; + UINT16 SalAVersion; + UINT16 SalBVersion; + UINT8 OemId[32]; + UINT8 ProductId[32]; + UINT8 Reserved2[8]; +} SAL_SYSTEM_TABLE_HEADER; +#pragma pack() + +#define EFI_SAL_ST_HEADER_SIGNATURE "SST_" +#define EFI_SAL_REVISION 0x0300 +// +// SAL System Types +// +#define EFI_SAL_ST_ENTRY_POINT 0 +#define EFI_SAL_ST_MEMORY_DESCRIPTOR 1 +#define EFI_SAL_ST_PLATFORM_FEATURES 2 +#define EFI_SAL_ST_TR_USAGE 3 +#define EFI_SAL_ST_PTC 4 +#define EFI_SAL_ST_AP_WAKEUP 5 + +#pragma pack(1) +typedef struct { + UINT8 Type; // Type == 0 + UINT8 Reserved[7]; + UINT64 PalProcEntry; + UINT64 SalProcEntry; + UINT64 SalGlobalDataPointer; + UINT64 Reserved2[2]; +} SAL_ST_ENTRY_POINT_DESCRIPTOR; + +// +// Not needed for Itanium-based OS boot +// +typedef struct { + UINT8 Type; // Type == 1 + UINT8 NeedVirtualRegistration; + UINT8 MemoryAttributes; + UINT8 PageAccessRights; + UINT8 SupportedAttributes; + UINT8 Reserved; + UINT8 MemoryType; + UINT8 MemoryUsage; + UINT64 PhysicalMemoryAddress; + UINT32 Length; + UINT32 Reserved1; + UINT64 OemReserved; +} SAL_ST_MEMORY_DESCRIPTOR_ENTRY; + +#pragma pack() +// +// Memory Attributes +// +#define SAL_MDT_ATTRIB_WB 0x00 +// +// #define SAL_MDT_ATTRIB_UC 0x02 +// +#define SAL_MDT_ATTRIB_UC 0x04 +#define SAL_MDT_ATTRIB_UCE 0x05 +#define SAL_MDT_ATTRIB_WC 0x06 + +// +// Supported memory Attributes +// +#define SAL_MDT_SUPPORT_WB 0x1 +#define SAL_MDT_SUPPORT_UC 0x2 +#define SAL_MDT_SUPPORT_UCE 0x4 +#define SAL_MDT_SUPPORT_WC 0x8 + +// +// Virtual address registration +// +#define SAL_MDT_NO_VA 0x00 +#define SAL_MDT_NEED_VA 0x01 +// +// MemoryType info +// +#define SAL_REGULAR_MEMORY 0x0000 +#define SAL_MMIO_MAPPING 0x0001 +#define SAL_SAPIC_IPI_BLOCK 0x0002 +#define SAL_IO_PORT_MAPPING 0x0003 +#define SAL_FIRMWARE_MEMORY 0x0004 +#define SAL_BLACK_HOLE 0x000A +// +// Memory Usage info +// +#define SAL_MDT_USAGE_UNSPECIFIED 0x00 +#define SAL_PAL_CODE 0x01 +#define SAL_BOOTSERVICE_CODE 0x02 +#define SAL_BOOTSERVICE_DATA 0x03 +#define SAL_RUNTIMESERVICE_CODE 0x04 +#define SAL_RUNTIMESERVICE_DATA 0x05 +#define SAL_IA32_OPTIONROM 0x06 +#define SAL_IA32_SYSTEMROM 0x07 +#define SAL_PMI_CODE 0x0a +#define SAL_PMI_DATA 0x0b + +#pragma pack(1) +typedef struct { + UINT8 Type; // Type == 2 + UINT8 PlatformFeatures; + UINT8 Reserved[14]; +} SAL_ST_PLATFORM_FEATURES; +#pragma pack() + +#define SAL_PLAT_FEAT_BUS_LOCK 0x01 +#define SAL_PLAT_FEAT_PLAT_IPI_HINT 0x02 +#define SAL_PLAT_FEAT_PROC_IPI_HINT 0x04 + +#pragma pack(1) +typedef struct { + UINT8 Type; // Type == 3 + UINT8 TRType; + UINT8 TRNumber; + UINT8 Reserved[5]; + UINT64 VirtualAddress; + UINT64 EncodedPageSize; + UINT64 Reserved1; +} SAL_ST_TR_DECRIPTOR; +#pragma pack() + +#define EFI_SAL_ST_TR_USAGE_INSTRUCTION 00 +#define EFI_SAL_ST_TR_USAGE_DATA 01 + +#pragma pack(1) +typedef struct { + UINT64 NumberOfProcessors; + UINT64 LocalIDRegister; +} SAL_COHERENCE_DOMAIN_INFO; +#pragma pack() + +#pragma pack(1) +typedef struct { + UINT8 Type; // Type == 4 + UINT8 Reserved[3]; + UINT32 NumberOfDomains; + SAL_COHERENCE_DOMAIN_INFO *DomainInformation; +} SAL_ST_CACHE_COHERENCE_DECRIPTOR; +#pragma pack() + +#pragma pack(1) +typedef struct { + UINT8 Type; // Type == 5 + UINT8 WakeUpType; + UINT8 Reserved[6]; + UINT64 ExternalInterruptVector; +} SAL_ST_AP_WAKEUP_DECRIPTOR; +#pragma pack() +// +// FIT Entry +// +#define EFI_SAL_FIT_ENTRY_PTR (0x100000000 - 32) // 4GB - 24 +#define EFI_SAL_FIT_PALA_ENTRY (0x100000000 - 48) // 4GB - 32 +#define EFI_SAL_FIT_PALB_TYPE 01 + +typedef struct { + UINT64 Address; + UINT8 Size[3]; + UINT8 Reserved; + UINT16 Revision; + UINT8 Type : 7; + UINT8 CheckSumValid : 1; + UINT8 CheckSum; +} EFI_SAL_FIT_ENTRY; + +// +// SAL Common Record Header +// +typedef struct { + UINT16 Length; + UINT8 Data[1024]; +} SAL_OEM_DATA; + +typedef struct { + UINT8 Seconds; + UINT8 Minutes; + UINT8 Hours; + UINT8 Reserved; + UINT8 Day; + UINT8 Month; + UINT8 Year; + UINT8 Century; +} SAL_TIME_STAMP; + +typedef struct { + UINT64 RecordId; + UINT16 Revision; + UINT8 ErrorSeverity; + UINT8 ValidationBits; + UINT32 RecordLength; + SAL_TIME_STAMP TimeStamp; + UINT8 OemPlatformId[16]; +} SAL_RECORD_HEADER; + +typedef struct { + EFI_GUID Guid; + UINT16 Revision; + UINT8 ErrorRecoveryInfo; + UINT8 Reserved; + UINT32 SectionLength; +} SAL_SEC_HEADER; + +// +// SAL Processor Record +// +#define SAL_PROCESSOR_ERROR_RECORD_INFO \ + { \ + 0xe429faf1, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define CHECK_INFO_VALID_BIT_MASK 0x1 +#define REQUESTOR_ID_VALID_BIT_MASK 0x2 +#define RESPONDER_ID_VALID_BIT_MASK 0x4 +#define TARGER_ID_VALID_BIT_MASK 0x8 +#define PRECISE_IP_VALID_BIT_MASK 0x10 + +typedef struct { + UINT64 InfoValid : 1; + UINT64 ReqValid : 1; + UINT64 RespValid : 1; + UINT64 TargetValid : 1; + UINT64 IpValid : 1; + UINT64 Reserved : 59; + UINT64 Info; + UINT64 Req; + UINT64 Resp; + UINT64 Target; + UINT64 Ip; +} MOD_ERROR_INFO; + +typedef struct { + UINT8 CpuidInfo[40]; + UINT8 Reserved; +} CPUID_INFO; + +typedef struct { + UINT64 FrLow; + UINT64 FrHigh; +} FR_STRUCT; + +#define MIN_STATE_VALID_BIT_MASK 0x1 +#define BR_VALID_BIT_MASK 0x2 +#define CR_VALID_BIT_MASK 0x4 +#define AR_VALID_BIT_MASK 0x8 +#define RR_VALID_BIT_MASK 0x10 +#define FR_VALID_BIT_MASK 0x20 + +typedef struct { + UINT64 ValidFieldBits; + UINT8 MinStateInfo[1024]; + UINT64 Br[8]; + UINT64 Cr[128]; + UINT64 Ar[128]; + UINT64 Rr[8]; + FR_STRUCT Fr[128]; +} PSI_STATIC_STRUCT; + +#define PROC_ERROR_MAP_VALID_BIT_MASK 0x1 +#define PROC_STATE_PARAMETER_VALID_BIT_MASK 0x2 +#define PROC_CR_LID_VALID_BIT_MASK 0x4 +#define PROC_STATIC_STRUCT_VALID_BIT_MASK 0x8 +#define CPU_INFO_VALID_BIT_MASK 0x1000000 + +typedef struct { + SAL_SEC_HEADER SectionHeader; + UINT64 ValidationBits; + UINT64 ProcErrorMap; + UINT64 ProcStateParameter; + UINT64 ProcCrLid; + MOD_ERROR_INFO CacheError[15]; + MOD_ERROR_INFO TlbError[15]; + MOD_ERROR_INFO BusError[15]; + MOD_ERROR_INFO RegFileCheck[15]; + MOD_ERROR_INFO MsCheck[15]; + CPUID_INFO CpuInfo; + PSI_STATIC_STRUCT PsiValidData; +} SAL_PROCESSOR_ERROR_RECORD; + +// +// Sal Platform memory Error Record +// +#define SAL_MEMORY_ERROR_RECORD_INFO \ + { \ + 0xe429faf2, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define MEMORY_ERROR_STATUS_VALID_BIT_MASK 0x1 +#define MEMORY_PHYSICAL_ADDRESS_VALID_BIT_MASK 0x2 +#define MEMORY_ADDR_BIT_MASK 0x4 +#define MEMORY_NODE_VALID_BIT_MASK 0x8 +#define MEMORY_CARD_VALID_BIT_MASK 0x10 +#define MEMORY_MODULE_VALID_BIT_MASK 0x20 +#define MEMORY_BANK_VALID_BIT_MASK 0x40 +#define MEMORY_DEVICE_VALID_BIT_MASK 0x80 +#define MEMORY_ROW_VALID_BIT_MASK 0x100 +#define MEMORY_COLUMN_VALID_BIT_MASK 0x200 +#define MEMORY_BIT_POSITION_VALID_BIT_MASK 0x400 +#define MEMORY_PLATFORM_REQUESTOR_ID_VALID_BIT_MASK 0x800 +#define MEMORY_PLATFORM_RESPONDER_ID_VALID_BIT_MASK 0x1000 +#define MEMORY_PLATFORM_TARGET_VALID_BIT_MASK 0x2000 +#define MEMORY_PLATFORM_BUS_SPECIFIC_DATA_VALID_BIT_MASK 0x4000 +#define MEMORY_PLATFORM_OEM_ID_VALID_BIT_MASK 0x8000 +#define MEMORY_PLATFORM_OEM_DATA_STRUCT_VALID_BIT_MASK 0x10000 + +typedef struct { + SAL_SEC_HEADER SectionHeader; + UINT64 ValidationBits; + UINT64 MemErrorStatus; + UINT64 MemPhysicalAddress; + UINT64 MemPhysicalAddressMask; + UINT16 MemNode; + UINT16 MemCard; + UINT16 MemModule; + UINT16 MemBank; + UINT16 MemDevice; + UINT16 MemRow; + UINT16 MemColumn; + UINT16 MemBitPosition; + UINT64 ModRequestorId; + UINT64 ModResponderId; + UINT64 ModTargetId; + UINT64 BusSpecificData; + UINT8 MemPlatformOemId[16]; +} SAL_MEMORY_ERROR_RECORD; + +// +// PCI BUS Errors +// +#define SAL_PCI_BUS_ERROR_RECORD_INFO \ + { \ + 0xe429faf4, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define PCI_BUS_ERROR_STATUS_VALID_BIT_MASK 0x1 +#define PCI_BUS_ERROR_TYPE_VALID_BIT_MASK 0x2 +#define PCI_BUS_ID_VALID_BIT_MASK 0x4 +#define PCI_BUS_ADDRESS_VALID_BIT_MASK 0x8 +#define PCI_BUS_DATA_VALID_BIT_MASK 0x10 +#define PCI_BUS_CMD_VALID_BIT_MASK 0x20 +#define PCI_BUS_REQUESTOR_ID_VALID_BIT_MASK 0x40 +#define PCI_BUS_RESPONDER_ID_VALID_BIT_MASK 0x80 +#define PCI_BUS_TARGET_VALID_BIT_MASK 0x100 +#define PCI_BUS_OEM_ID_VALID_BIT_MASK 0x200 +#define PCI_BUS_OEM_DATA_STRUCT_VALID_BIT_MASK 0x400 + +typedef enum { + Unknown, + DataParityError, + SystemError, + MasterAbort, + BusTimeout, + MasterDataParityError, + AddressParityError, + CommandParityError +} PCI_BUS_ERROR_TYPE; + +typedef struct { + UINT8 BusNumber; + UINT8 SegmentNumber; +} PCI_BUS_ID; + +typedef struct { + SAL_SEC_HEADER SectionHeader; + UINT64 ValidationBits; + UINT64 PciBusErrorStatus; + UINT16 PciBusErrorType; + PCI_BUS_ID PciBusId; + UINT32 Reserved; + UINT64 PciBusAddress; + UINT64 PciBusData; + UINT64 PciBusCommand; + UINT64 PciBusRequestorId; + UINT64 PciBusResponderId; + UINT64 PciBusTargetId; + UINT8 PciBusOemId[16]; +} SAL_PCI_BUS_ERROR_RECORD; + +// +// PCI Component Errors +// +#define SAL_PCI_COMP_ERROR_RECORD_INFO \ + { \ + 0xe429faf6, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define PCI_COMP_ERROR_STATUS_VALID_BIT_MASK 0x1 +#define PCI_COMP_INFO_VALID_BIT_MASK 0x2 +#define PCI_COMP_MEM_NUM_VALID_BIT_MASK 0x4 +#define PCI_COMP_IO_NUM_VALID_BIT_MASK 0x8 +#define PCI_COMP_REG_DATA_PAIR_VALID_BIT_MASK 0x10 +#define PCI_COMP_OEM_DATA_STRUCT_VALID_BIT_MASK 0x20 + +typedef struct { + UINT16 VendorId; + UINT16 DeviceId; + UINT8 ClassCode[3]; + UINT8 FunctionNumber; + UINT8 DeviceNumber; + UINT8 BusNumber; + UINT8 SegmentNumber; + UINT8 Reserved[5]; +} PCI_COMP_INFO; + +typedef struct { + SAL_SEC_HEADER SectionHeader; + UINT64 ValidationBits; + UINT64 PciComponentErrorStatus; + PCI_COMP_INFO PciComponentInfo; + UINT32 PciComponentMemNum; + UINT32 PciComponentIoNum; + UINT8 PciBusOemId[16]; +} SAL_PCI_COMPONENT_ERROR_RECORD; + +// +// Sal Device Errors Info. +// +#define SAL_DEVICE_ERROR_RECORD_INFO \ + { \ + 0xe429faf3, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define SEL_RECORD_ID_VALID_BIT_MASK 0x1; +#define SEL_RECORD_TYPE_VALID_BIT_MASK 0x2; +#define SEL_GENERATOR_ID_VALID_BIT_MASK 0x4; +#define SEL_EVM_REV_VALID_BIT_MASK 0x8; +#define SEL_SENSOR_TYPE_VALID_BIT_MASK 0x10; +#define SEL_SENSOR_NUM_VALID_BIT_MASK 0x20; +#define SEL_EVENT_DIR_TYPE_VALID_BIT_MASK 0x40; +#define SEL_EVENT_DATA1_VALID_BIT_MASK 0x80; +#define SEL_EVENT_DATA2_VALID_BIT_MASK 0x100; +#define SEL_EVENT_DATA3_VALID_BIT_MASK 0x200; + +typedef struct { + SAL_SEC_HEADER SectionHeader; + UINT64 ValidationBits; + UINT16 SelRecordId; + UINT8 SelRecordType; + UINT32 TimeStamp; + UINT16 GeneratorId; + UINT8 EvmRevision; + UINT8 SensorType; + UINT8 SensorNum; + UINT8 EventDirType; + UINT8 Data1; + UINT8 Data2; + UINT8 Data3; +} SAL_DEVICE_ERROR_RECORD; + +// +// Sal SMBIOS Device Errors Info. +// +#define SAL_SMBIOS_ERROR_RECORD_INFO \ + { \ + 0xe429faf5, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define SMBIOS_EVENT_TYPE_VALID_BIT_MASK 0x1 +#define SMBIOS_LENGTH_VALID_BIT_MASK 0x2 +#define SMBIOS_TIME_STAMP_VALID_BIT_MASK 0x4 +#define SMBIOS_DATA_VALID_BIT_MASK 0x8 + +typedef struct { + SAL_SEC_HEADER SectionHeader; + UINT64 ValidationBits; + UINT8 SmbiosEventType; + UINT8 SmbiosLength; + UINT8 SmbiosBcdTimeStamp[6]; +} SAL_SMBIOS_DEVICE_ERROR_RECORD; + +// +// Sal Platform Specific Errors Info. +// +#define SAL_PLATFORM_ERROR_RECORD_INFO \ + { \ + 0xe429faf7, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +#define PLATFORM_ERROR_STATUS_VALID_BIT_MASK 0x1 +#define PLATFORM_REQUESTOR_ID_VALID_BIT_MASK 0x2 +#define PLATFORM_RESPONDER_ID_VALID_BIT_MASK 0x4 +#define PLATFORM_TARGET_VALID_BIT_MASK 0x8 +#define PLATFORM_SPECIFIC_DATA_VALID_BIT_MASK 0x10 +#define PLATFORM_OEM_ID_VALID_BIT_MASK 0x20 +#define PLATFORM_OEM_DATA_STRUCT_VALID_BIT_MASK 0x40 +#define PLATFORM_OEM_DEVICE_PATH_VALID_BIT_MASK 0x80 + +typedef struct { + SAL_SEC_HEADER SectionHeader; + UINT64 ValidationBits; + UINT64 PlatformErrorStatus; + UINT64 PlatformRequestorId; + UINT64 PlatformResponderId; + UINT64 PlatformTargetId; + UINT64 PlatformBusSpecificData; + UINT8 OemComponentId[16]; +} SAL_PLATFORM_SPECIFIC_ERROR_RECORD; + +// +// Union of all the possible Sal Record Types +// +typedef union { + SAL_RECORD_HEADER *RecordHeader; + SAL_PROCESSOR_ERROR_RECORD *SalProcessorRecord; + SAL_PCI_BUS_ERROR_RECORD *SalPciBusRecord; + SAL_PCI_COMPONENT_ERROR_RECORD *SalPciComponentRecord; + SAL_DEVICE_ERROR_RECORD *ImpiRecord; + SAL_SMBIOS_DEVICE_ERROR_RECORD *SmbiosRecord; + SAL_PLATFORM_SPECIFIC_ERROR_RECORD *PlatformRecord; + SAL_MEMORY_ERROR_RECORD *MemoryRecord; + UINT8 *Raw; +} SAL_ERROR_RECORDS_POINTERS; + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Ipf/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/Ipf/TianoBind.h new file mode 100644 index 0000000000..dc51e1d37e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Ipf/TianoBind.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoBind.h + +Abstract: + + Tiano's Processor or Compiler specific defines and types for Intel?Itanium(TM) + besides EfiBind.h. + +--*/ + +#ifndef _TIANO_BIND_H_ +#define _TIANO_BIND_H_ + +#include "EfiBind.h" + +#define EFI_DXE_ENTRY_POINT(InitFunction) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Pei/Pei.h b/EdkCompatibilityPkg/Foundation/Include/Pei/Pei.h new file mode 100644 index 0000000000..cef364b1bf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Pei/Pei.h @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Pei.h + +Abstract: + + Framework PEI master include file. + + This is the main include file for Framework PEI components. There should be + no defines or macros added to this file, other than the EFI version + information already in this file. + + Don't add include files to the list for convenience, only add things + that are architectural. Don't add Protocols or GUID include files here + +--*/ + +#ifndef _PEI_H_ +#define _PEI_H_ + +// +// PEI Specification Revision information +// +#include "TianoCommon.h" + +#include "PeiBind.h" +#include "PeiApi.h" +#include "EfiDebug.h" +#include "PeiDebug.h" + +// +// Enable code sharing with DXE by removing ASSERT and DEBUG +// +// #define ASSERT(a) +// #define DEBUG (a) +// + +#ifdef EFI_PEI_REPORT_STATUS_CODE_ON +#define PEI_REPORT_STATUS_CODE_CODE(Code) Code +#define PEI_REPORT_STATUS_CODE(PeiServices, CodeType, Value, Instance, CallerId, Data) \ + (*PeiServices)->PeiReportStatusCode (PeiServices, CodeType, Value, Instance, CallerId, Data) +#else +#define PEI_REPORT_STATUS_CODE_CODE(Code) +#define PEI_REPORT_STATUS_CODE(PeiServices, CodeType, Value, Instance, CallerId, Data) +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Pei/PeiBind.h b/EdkCompatibilityPkg/Foundation/Include/Pei/PeiBind.h new file mode 100644 index 0000000000..a3cdb7b776 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Pei/PeiBind.h @@ -0,0 +1,160 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiBind.h + +Abstract: + + Tiano PEI core and PEIM binding macros + +--*/ + +#ifndef _PEI_BIND_H_ +#define _PEI_BIND_H_ + +#ifdef EFI_DEBUG + +#ifdef EFI_NT_EMULATOR + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + +#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup \ + ) \ + { \ + return InitFunction(PeiStartup); \ + } + +#else +#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, \ + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList \ + ) \ + { \ + return InitFunction(SecCoreData, PpiList); \ + } + +#endif + +#define EFI_PEIM_ENTRY_POINT(InitFunction) \ + UINTN \ + __stdcall \ + _DllMainCRTStartup ( \ + UINTN Inst, \ + UINTN reason_for_call, \ + VOID *rserved \ + ) \ + { \ + return 1; \ + } \ + \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + IN EFI_FFS_FILE_HEADER *FfsHeader, \ + IN EFI_PEI_SERVICES **PeiServices \ + ) \ + { \ + return InitFunction(FfsHeader, PeiServices); \ + } + +#else + +#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) +#define EFI_PEIM_ENTRY_POINT(InitFunction) + +#endif + +#else + +#ifdef EFI_NT_EMULATOR + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + +#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup \ + ) \ + { \ + return InitFunction(PeiStartup); \ + } + +#else +#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, \ + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList \ + ) \ + { \ + return InitFunction(SecCoreData, PpiList); \ + } + +#endif + + +#define EFI_PEIM_ENTRY_POINT(InitFunction) \ + EFI_STATUS \ + __declspec( dllexport ) \ + __cdecl \ + InitializeDriver ( \ + IN EFI_FFS_FILE_HEADER *FfsHeader, \ + IN EFI_PEI_SERVICES **PeiServices \ + ) \ + { \ + return InitFunction(FfsHeader, PeiServices); \ + } +#else + +#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) +#define EFI_PEIM_ENTRY_POINT(InitFunction) + +#endif +#endif +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Pei/PeiDebug.h b/EdkCompatibilityPkg/Foundation/Include/Pei/PeiDebug.h new file mode 100644 index 0000000000..a957c2b521 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Pei/PeiDebug.h @@ -0,0 +1,104 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiDebug.h + +Abstract: + + PEI Debug macros. The work needs to be done in library. The Debug + macros them selves are standard for all files, including the core. + + There needs to be code linked in that produces the following macros: + + PeiDebugAssert(file, linenumber, assertion string) - worker function for + ASSERT. filename and line number of where this ASSERT() is located + is passed in along with the stringized version of the assertion. + + PeiDebugPrint - Worker function for debug print + + _DEBUG_SET_MEM(address, length, value) - Set memory at address to value + for legnth bytes. This macro is used to initialzed uninitialized memory + or memory that is free'ed, so it will not be used by mistake. + +--*/ + +#ifndef _PEIDEBUG_H_ +#define _PEIDEBUG_H_ + +#ifdef EFI_DEBUG + + VOID + PeiDebugAssert ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ); + + VOID + PeiDebugPrint ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ); + + #define _PEI_DEBUG_ASSERT(PeiST, assertion) \ + PeiDebugAssert (PeiST, __FILE__, __LINE__, #assertion) + + #define _PEI_DEBUG(PeiST, arg) PeiDebugPrint (PeiST, arg) + + // + // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT + // + #define PEI_ASSERT(PeiST, assertion) if(!(assertion)) \ + _PEI_DEBUG_ASSERT(PeiST, assertion) + + #define PEI_ASSERT_LOCKED(PeiST, l) if(!(l)->Lock) _PEI_DEBUG_ASSERT(PeiST, l not locked) + + // + // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do + // the a debug print. + // + + #define PEI_DEBUG(arg) PeiDebugPrint arg + + #define PEI_DEBUG_CODE(code) code + + #define PEI_CR(Record, TYPE, Field, Signature) \ + _CR(Record, TYPE, Field) + + + #define _PEI_DEBUG_SET_MEM(address, length, data) SetMem(address, length, data) + +#else + #define PEI_ASSERT(PeiST, a) + #define PEI_ASSERT_LOCKED(PeiST, l) + #define PEI_DEBUG(arg) + #define PEI_DEBUG_CODE(code) + #define PEI_CR(Record, TYPE, Field, Signature) \ + _CR(Record, TYPE, Field) + #define _PEI_DEBUG_SET_MEM(address, length, data) +#endif + +#define ASSERT_PEI_ERROR(PeiST, status) PEI_ASSERT(PeiST, !EFI_ERROR(status)) + +#ifdef EFI_DEBUG_CLEAR_MEMORY + #define PEI_DEBUG_SET_MEMORY(address,length) \ + _PEI_DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE) +#else + #define PEI_DEBUG_SET_MEMORY(address,length) +#endif + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/Tiano.h b/EdkCompatibilityPkg/Foundation/Include/Tiano.h new file mode 100644 index 0000000000..55790c2eab --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/Tiano.h @@ -0,0 +1,56 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Tiano.h + +Abstract: + + Tiano master include file. + + This is the main include file for Tiano components. + + Don't add include files to the list for convenience, only add things + that are architectural. Don't add Protocols or GUID include files here + +--*/ + +#ifndef _TIANO_H_ +#define _TIANO_H_ + +// +// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined. +// +#if !defined(EFI_SPECIFICATION_VERSION) + #error EFI_SPECIFICATION_VERSION not defined +#elif !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif (TIANO_RELEASE_VERSION == 0) + #error TIANO_RELEASE_VERSION can not be zero +#elif (EFI_SPECIFICATION_VERSION <= 0x00020000) + #define TIANO_EXTENSION_FLAG +#endif + +#include "TianoCommon.h" +#include "TianoApi.h" +#include "EfiDebug.h" +#include "TianoDevicePath.h" +#include "EfiSpec.h" + +// +// EFI Revision information +// +#define EFI_FIRMWARE_MAJOR_REVISION 0x1000 +#define EFI_FIRMWARE_MINOR_REVISION 1 +#define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION << 16) | (EFI_FIRMWARE_MINOR_REVISION)) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoApi.h b/EdkCompatibilityPkg/Foundation/Include/TianoApi.h new file mode 100644 index 0000000000..da1ca7c912 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/TianoApi.h @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoApi.h + +Abstract: + + Tiano intrinsic definitions. + + +--*/ + +#ifndef _TIANO_API_H_ +#define _TIANO_API_H_ + +#include "EfiApi.h" +#include "TianoSpecApi.h" + +// +// Pointer to internal runtime function +// +#define EFI_INTERNAL_FUNCTION 0x00000002 + +// +// Pointer to internal runtime pointer +// +#define EFI_INTERNAL_POINTER 0x00000004 + +// +// Pointer to internal runtime pointer +// +#define EFI_IPF_GP_POINTER 0x00000008 + +#define EFI_TPL_DRIVER 6 + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoCommon.h b/EdkCompatibilityPkg/Foundation/Include/TianoCommon.h new file mode 100644 index 0000000000..c2a87c73dd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/TianoCommon.h @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoCommon.h + +Abstract: + + Tiano specific common definitions besides EfiCommon.h + +--*/ + +#ifndef _TIANO_COMMON_H_ +#define _TIANO_COMMON_H_ + +#include "TianoBind.h" +#include "TianoTypes.h" +#include "EfiStdArg.h" +#include "TianoError.h" +#include "EfiStatusCode.h" +#include "EfiCommon.h" + +// +// Define macros for including Architectural Protocols and PPIs +// +#define EFI_ARCH_PROTOCOL_DEFINITION(a) EFI_STRINGIZE (ArchProtocol/a/a.h) +#define EFI_PPI_DEFINITION(a) EFI_STRINGIZE (Ppi/a/a.h) + +// +// These should be used to include protocols. If they are followed, +// intelligent build tools can be created to check dependencies at build +// time. +// +#define EFI_ARCH_PROTOCOL_PRODUCER(a) EFI_ARCH_PROTOCOL_DEFINITION (a) +#define EFI_ARCH_PROTOCOL_CONSUMER(a) EFI_ARCH_PROTOCOL_DEFINITION (a) +#define EFI_ARCH_PROTOCOL_DEPENDENCY(a) EFI_ARCH_PROTOCOL_DEFINITION (a) + +#define EFI_PPI_PRODUCER(a) EFI_PPI_DEFINITION (a) +#define EFI_PPI_CONSUMER(a) EFI_PPI_DEFINITION (a) +#define EFI_PPI_DEPENDENCY(a) EFI_PPI_DEFINITION (a) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoDevicePath.h b/EdkCompatibilityPkg/Foundation/Include/TianoDevicePath.h new file mode 100644 index 0000000000..445a075c13 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/TianoDevicePath.h @@ -0,0 +1,130 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoDevicePath.h + +Abstract: + + Tiano Device Path definitions + +--*/ + +#ifndef _TIANO_DEVICE_PATH_H +#define _TIANO_DEVICE_PATH_H + +#include "EfiDevicePath.h" +#include "TianoSpecDevicePath.h" + +#pragma pack(1) + +typedef struct _USB_PORT_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH PciBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} USB_PORT_DEVICE_PATH; + +// +// IDE +// +typedef struct _IDE_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH PciBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} IDE_DEVICE_PATH; + +// +// RMC Connector +// +typedef struct _RMC_CONN_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH PciBridgeDevicePath; + PCI_DEVICE_PATH PciBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} RMC_CONN_DEVICE_PATH; + +// +// RIDE +// +typedef struct _RIDE_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH PciBridgeDevicePath; + PCI_DEVICE_PATH PciBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} RIDE_DEVICE_PATH; + +// +// Gigabit NIC +// +typedef struct _GB_NIC_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH PciBridgeDevicePath; + PCI_DEVICE_PATH PciXBridgeDevicePath; + PCI_DEVICE_PATH PciXBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} GB_NIC_DEVICE_PATH; + +// +// P/S2 Connector +// +typedef struct _PS2_CONN_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH LpcBridgeDevicePath; + ACPI_HID_DEVICE_PATH LpcBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} PS2_CONN_DEVICE_PATH; + +// +// Serial Port Connector +// +typedef struct _SERIAL_CONN_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH LpcBridgeDevicePath; + ACPI_HID_DEVICE_PATH LpcBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} SERIAL_CONN_DEVICE_PATH; + +// +// Parallel Port Connector +// +typedef struct _PARALLEL_CONN_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH LpcBridgeDevicePath; + ACPI_HID_DEVICE_PATH LpcBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} PARALLEL_CONN_DEVICE_PATH; + +// +// Floopy Connector +// +typedef struct _FLOOPY_CONN_DEVICE_PATH { + ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath; + PCI_DEVICE_PATH LpcBridgeDevicePath; + ACPI_HID_DEVICE_PATH LpcBusDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} FLOOPY_CONN_DEVICE_PATH; + +typedef union _EFI_MISC_PORT_DEVICE_PATH { + USB_PORT_DEVICE_PATH UsbDevicePath; + IDE_DEVICE_PATH IdeDevicePath; + RMC_CONN_DEVICE_PATH RmcConnDevicePath; + RIDE_DEVICE_PATH RideDevicePath; + GB_NIC_DEVICE_PATH GbNicDevicePath; + PS2_CONN_DEVICE_PATH Ps2ConnDevicePath; + SERIAL_CONN_DEVICE_PATH SerialConnDevicePath; + PARALLEL_CONN_DEVICE_PATH ParallelConnDevicePath; + FLOOPY_CONN_DEVICE_PATH FloppyConnDevicePath; +} EFI_MISC_PORT_DEVICE_PATH; + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoError.h b/EdkCompatibilityPkg/Foundation/Include/TianoError.h new file mode 100644 index 0000000000..93cccf7ea9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/TianoError.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoError.h + +Abstract: + + Tiano error levels and their associated defines + +--*/ + +#ifndef _TIANO_ERROR_H_ +#define _TIANO_ERROR_H_ + +#include "EfiError.h" +#include "TianoSpecError.h" + +#define EFI_WARN_RETURN_FROM_LONG_JUMP EFIWARN (5) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoTypes.h b/EdkCompatibilityPkg/Foundation/Include/TianoTypes.h new file mode 100644 index 0000000000..de52e4fde8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/TianoTypes.h @@ -0,0 +1,48 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoTypes.h + +Abstract: + + Tiano specific part besides EfiTypes.h + +--*/ + +#ifndef _TIANO_TYPES_H_ +#define _TIANO_TYPES_H_ + +#include "EfiTypes.h" +#include "TianoSpecTypes.h" + +// +// attributes for reserved memory before it is promoted to system memory +// +#define EFI_MEMORY_PRESENT 0x0100000000000000 +#define EFI_MEMORY_INITIALIZED 0x0200000000000000 +#define EFI_MEMORY_TESTED 0x0400000000000000 + +// +// range for memory mapped port I/O on IPF +// +#define EFI_MEMORY_PORT_IO 0x4000000000000000 + +// +// A pointer to a function in IPF points to a plabel. +// +typedef struct { + UINT64 EntryPoint; + UINT64 GP; +} EFI_PLABEL; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Include/x64/EfiBind.h b/EdkCompatibilityPkg/Foundation/Include/x64/EfiBind.h new file mode 100644 index 0000000000..2b51b66948 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/x64/EfiBind.h @@ -0,0 +1,222 @@ +/*++ + +Copyright (c) 2005 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiBind.h + +Abstract: + + Processor or Compiler specific defines and types for x64. + We are using the ANSI C 2000 _t type definitions for basic types. + This it technically a violation of the coding standard, but they + are used to make EfiTypes.h portable. Code other than EfiTypes.h + should never use any ANSI C 2000 _t integer types. + +--*/ + +#ifndef _EFI_BIND_H_ +#define _EFI_BIND_H_ + + +#define EFI_DRIVER_ENTRY_POINT(InitFunction) +#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT + + + +// +// Make sure we are useing the correct packing rules per EFI specification +// +#pragma pack() + +#if _MSC_EXTENSIONS + +// +// Disable warning that make it impossible to compile at /W4 +// This only works for Microsoft* tools +// + +// +// Disabling bitfield type checking warnings. +// +#pragma warning ( disable : 4214 ) + +// +// Disabling the unreferenced formal parameter warnings. +// +#pragma warning ( disable : 4100 ) + +// +// Disable slightly different base types warning as CHAR8 * can not be set +// to a constant string. +// +#pragma warning ( disable : 4057 ) + +// +// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning +// +#pragma warning ( disable : 4127 ) + +// +// Int64ShllMod32 unreferenced inline function +// +#pragma warning ( disable : 4514 ) + +// +// Unreferenced formal parameter - We are object oriented, so we pass This even +// if we don't need them. +// +#pragma warning ( disable : 4100 ) + +// +// This warning is caused by empty (after preprocessing) souce file. +// +#pragma warning ( disable : 4206 ) + +// +// Warning: The result of the unary '&' operator may be unaligned. Ignore it. +// +#pragma warning ( disable : 4366 ) + +#endif + + +#if (__STDC_VERSION__ < 199901L) + // + // No ANSI C 2000 stdint.h integer width declarations, so define equivalents + // + + #if _MSC_EXTENSIONS + + // + // use Microsoft* C complier dependent interger width types + // + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; + typedef unsigned __int32 uint32_t; + typedef __int32 int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #else + + // + // Assume standard IA-32 alignment. + // BugBug: Need to check portability of long long + // + typedef unsigned long long uint64_t; + typedef long long int64_t; + typedef unsigned int uint32_t; + typedef int int32_t; + typedef unsigned short uint16_t; + typedef short int16_t; + typedef unsigned char uint8_t; + typedef char int8_t; + #endif +#else + // + // Use ANSI C 2000 stdint.h integer width declarations + // + #include "stdint.h" +#endif + +// +// Native integer size in stdint.h +// +typedef uint64_t uintn_t; +typedef int64_t intn_t; + +// +// Processor specific defines +// +#define EFI_MAX_BIT 0x8000000000000000 +#define MAX_2_BITS 0xC000000000000000 + +// +// Maximum legal IA-32 address +// +#define EFI_MAX_ADDRESS 0xFFFFFFFFFFFFFFFF + +// +// Bad pointer value to use in check builds. +// if you see this value you are using uninitialized or free'ed data +// +#define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAF +#define EFI_BAD_POINTER_AS_BYTE 0xAF + +// +// Inject a break point in the code to assist debugging. +// +#define EFI_DEADLOOP() { volatile int __iii; __iii = 1; while (__iii); } +#define EFI_BREAKPOINT() __debugbreak() + +// +// Memory Fence forces serialization, and is needed to support out of order +// memory transactions. The Memory Fence is mainly used to make sure IO +// transactions complete in a deterministic sequence, and to syncronize locks +// an other MP code. Currently no memory fencing is required. +// +#define MEMORY_FENCE() + +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX. The forward reference is required for +// ANSI compatibility. +// +// The following macro provide a workaround for such cases. +// + + +#ifdef EFI_NO_INTERFACE_DECL + #define EFI_FORWARD_DECLARATION(x) +#else + #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x +#endif + + +// +// Some C compilers optimize the calling conventions to increase performance. +// _EFIAPI is used to make all public APIs follow the standard C calling +// convention. +// +#if _MSC_EXTENSIONS + // + // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C. + // + + #define _EFIAPI __cdecl +#else + #define _EFIAPI +#endif + + +#ifdef _EFI_WINNT + + #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( disable : 4142 ) + + #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( default : 4142 ) +#else + + #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( disable : 4068 ) + + #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \ + warning ( default : 4068 ) + +#endif + + + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Include/x64/EfiPeOptionalHeader.h b/EdkCompatibilityPkg/Foundation/Include/x64/EfiPeOptionalHeader.h new file mode 100644 index 0000000000..03d1dc2957 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/x64/EfiPeOptionalHeader.h @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPeOptionalHeader.h + +Abstract: + Defines the optional header in the PE image per the PE specification. This + file must be included only from within EfiImage.h since + EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined + there. + +--*/ + +#ifndef _EFI_PE_OPTIONAL_HEADER_H_ +#define _EFI_PE_OPTIONAL_HEADER_H_ + +#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_X64) + +#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \ + (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC)) + +#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32) + +// +// Assume we can use IPF values +// +#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC +typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER; +typedef EFI_IMAGE_NT_HEADERS64 EFI_IMAGE_NT_HEADERS; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Include/x64/TianoBind.h b/EdkCompatibilityPkg/Foundation/Include/x64/TianoBind.h new file mode 100644 index 0000000000..45fe2119ac --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Include/x64/TianoBind.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoBind.h + +Abstract: + + Tiano's Processor or Compiler specific defines and types for Intel?Itanium(TM) + besides EfiBind.h. + +--*/ + +#ifndef _TIANO_BIND_H_ +#define _TIANO_BIND_H_ + +#include "EfiBind.h" + +#define EFI_DXE_ENTRY_POINT(InitFunction) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf new file mode 100644 index 0000000000..b80e6faca3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf @@ -0,0 +1,61 @@ +#/*++ +# +# Copyright (c) 2006 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CompilerStubLib.inf +# +# Abstract: +# +# Component description file for the CompilerStub. +# +#--*/ + +[defines] +BASE_NAME = CompilerStub +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + Ia32\memcpy.asm + Ia32\memset.asm + +[sources.x64] + x64\memcpy.asm + x64\memset.asm + +[sources.Ipf] + memcpy.c + memset.c + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE) + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo + $(EDK_SOURCE)\Foundation\Framework + +[libraries.common] + +[nmake.common] + +[nmake.ia32,nmake.x64] + C_FLAGS= $(C_FLAGS) /GL- diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm new file mode 100644 index 0000000000..37b505678a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm @@ -0,0 +1,81 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CopyMem.asm +; +; Abstract: +; +; memcpy function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID * +; memcpy ( +; IN VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +memcpy PROC USES esi edi + mov esi, [esp + 16] ; esi <- Source + mov edi, [esp + 12] ; edi <- Destination + mov edx, [esp + 20] ; edx <- Count + lea eax, [esi + edx - 1] ; eax <- End of Source + cmp esi, edi + je @CopyMemDone + cmp edx, 0 + je @CopyMemDone + cmp esi, edi + jae @F + cmp eax, edi ; Overlapped? + jae @CopyBackward ; Copy backward if overlapped +@@: + mov ecx, edx + and edx, 7 + shr ecx, 3 ; ecx <- # of Qwords to copy + jz @CopyBytes + push eax + push eax + movq [esp], mm0 ; save mm0 +@@: + movq mm0, [esi] + movq [edi], mm0 + add esi, 8 + add edi, 8 + loop @B + movq mm0, [esp] ; restore mm0 + pop ecx ; stack cleanup + pop ecx ; stack cleanup + jmp @CopyBytes +@CopyBackward: + mov esi, eax ; esi <- Last byte in Source + lea edi, [edi + edx - 1] ; edi <- Last byte in Destination + std +@CopyBytes: + mov ecx, edx + rep movsb + cld +@CopyMemDone: + mov eax, [esp + 12] + ret +memcpy ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm new file mode 100644 index 0000000000..5ae5752a57 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm @@ -0,0 +1,86 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CopyMem.asm +; +; Abstract: +; +; memcpy function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID * +; memcpy ( +; IN VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +memcpy PROC USES esi edi + mov esi, [esp + 16] ; esi <- Source + mov edi, [esp + 12] ; edi <- Destination + mov edx, [esp + 20] ; edx <- Count + lea eax, [esi + edx - 1] ; eax <- End of Source + cmp esi, edi + je @CopyMemDone + cmp edx, 0 + je @CopyMemDone + cmp esi, edi + jae @F + cmp eax, edi ; Overlapped? + jae @CopyBackward ; Copy backward if overlapped +@@: + xor ecx, ecx + sub ecx, edi + and ecx, 15 ; ecx + edi aligns on 16-byte boundary + jz @F + cmp ecx, edx + cmova ecx, edx + sub edx, ecx ; edx <- remaining bytes to copy + rep movsb +@@: + mov ecx, edx + and edx, 15 + shr ecx, 4 ; ecx <- # of DQwords to copy + jz @CopyBytes + add esp, -16 +@@: + movdqu xmm0, [esi] ; esi may not be 16-bytes aligned + movdqa [edi], xmm0 ; edi should be 16-bytes aligned + add esi, 16 + add edi, 16 + loop @B + add esp, 16 ; stack cleanup + jmp @CopyBytes +@CopyBackward: + mov esi, eax ; esi <- Last byte in Source + lea edi, [edi + edx - 1] ; edi <- Last byte in Destination + std +@CopyBytes: + mov ecx, edx + rep movsb + cld +@CopyMemDone: + mov eax, [esp + 12] + ret +memcpy ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm new file mode 100644 index 0000000000..3dbf920da8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm @@ -0,0 +1,72 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetMem.asm +; +; Abstract: +; +; memset function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID * +; memset ( +; OUT VOID *Buffer, +; IN UINT8 Value, +; IN UINTN Count +; ) +;------------------------------------------------------------------------------ +memset PROC USES edi + mov al, [esp + 12] + mov ah, al + shrd edx, eax, 16 + shld eax, edx, 16 + mov ecx, [esp + 16] ; ecx <- Count + cmp ecx, 0 ; if Count == 0, do nothing + je @SetDone + mov edi, [esp + 8] ; edi <- Buffer + mov edx, ecx + and edx, 7 + shr ecx, 3 ; # of Qwords to set + jz @SetBytes + add esp, -10h + movq [esp], mm0 ; save mm0 + movq [esp + 8], mm1 ; save mm1 + movd mm0, eax + movd mm1, eax + psllq mm0, 32 + por mm0, mm1 ; fill mm0 with 8 Value's +@@: + movq [edi], mm0 + add edi, 8 + loop @B + movq mm0, [esp] ; restore mm0 + movq mm1, [esp + 8] ; restore mm1 + add esp, 10h ; stack cleanup +@SetBytes: + mov ecx, edx + rep stosb +@SetDone: + mov eax, [esp + 8] ; eax <- Buffer as return value + ret +memset ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memsetSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memsetSSE2.asm new file mode 100644 index 0000000000..ce9ba64fea --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memsetSSE2.asm @@ -0,0 +1,74 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetMem.asm +; +; Abstract: +; +; memset function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID * +; memset ( +; OUT VOID *Buffer, +; IN UINT8 Value, +; IN UINTN Count +; ) +;------------------------------------------------------------------------------ +memset PROC USES edi + mov edx, [esp + 16] ; edx <- Count + cmp edx, 0 ; if Count == 0, do nothing + je @SetDone + mov edi, [esp + 8] ; edi <- Buffer + mov al, [esp + 12] ; al <- Value + xor ecx, ecx + sub ecx, edi + and ecx, 15 ; ecx + edi aligns on 16-byte boundary + jz @F + cmp ecx, edx + cmova ecx, edx + sub edx, ecx + rep stosb +@@: + mov ecx, edx + and edx, 15 + shr ecx, 4 ; ecx <- # of DQwords to set + jz @SetBytes + mov ah, al ; ax <- Value | (Value << 8) + add esp, -16 + movd xmm0, eax + pshuflw xmm0, xmm0, 0 ; xmm0[0..63] <- Value repeats 8 times + movlhps xmm0, xmm0 ; xmm0 <- Value repeats 16 times +@@: + movdqa [edi], xmm0 ; edi should be 16-byte aligned + add edi, 16 + loop @B + add esp, 16 ; stack cleanup +@SetBytes: + mov ecx, edx + rep stosb +@SetDone: + mov eax, [esp + 8] ; eax <- Buffer as return value + ret +memset ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memcpy.c b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memcpy.c new file mode 100644 index 0000000000..300724a132 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memcpy.c @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + memcpy.c + +Abstract: + + The Microsoft compiler inlines memcpy and we can not stop it. + These routines allow the code to link! + + There is no *.h definition of these modules as they are well known by the + compiler. See Microsoft documentation for more details! + + volatile is used to prevent the compiler from trying to implement these + C functions as inline functions. + +--*/ + +#include "Tiano.h" + +VOID * +memcpy ( + OUT VOID *Dest, + IN const VOID *Src, + IN UINTN Count + ) +{ + volatile UINT8 *Ptr; + const UINT8 *Source; + + for (Ptr = Dest, Source = Src; Count > 0; Count--, Source++, Ptr++) { + *Ptr = *Source; + } + + return Dest; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memset.c b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memset.c new file mode 100644 index 0000000000..0f0f40db97 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/memset.c @@ -0,0 +1,45 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + memset.c + +Abstract: + + The Microsoft compiler inlines memset and we can not stop it. + These routines allow the code to link! + + There is no *.h definition of these modules as they are well known by the + compiler. See Microsoft documentation for more details! + + volatile is used to prevent the compiler from trying to implement these + C functions as inline functions. + +--*/ + +#include "Tiano.h" + +VOID * +memset ( + OUT VOID *Dest, + IN UINTN Char, + IN UINTN Count + ) +{ + volatile UINT8 *Ptr; + + for (Ptr = Dest; Count > 0; Count--, Ptr++) { + *Ptr = (UINT8) Char; + } + + return Dest; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpy.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpy.asm new file mode 100644 index 0000000000..7e04431459 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpy.asm @@ -0,0 +1,73 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CopyMem.asm +; +; Abstract: +; +; memcpy function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; memcpy ( +; OUT VOID *DestinationBuffer, +; IN CONST VOID *SourceBuffer, +; IN UINTN Length +; ); +;------------------------------------------------------------------------------ +memcpy PROC USES rsi rdi + mov rax, rcx ; rax <- Destination as return value + cmp rdx, rcx ; if Source == Destination, do nothing + je @CopyMemDone + cmp r8, 0 ; if Count == 0, do nothing + je @CopyMemDone + mov rsi, rdx ; rsi <- Source + mov rdi, rcx ; rdi <- Destination + lea r9, [rsi + r8 - 1] ; r9 <- End of Source + cmp rsi, rdi + jae @F + cmp r9, rdi + jae @CopyBackward ; Copy backward if overlapped +@@: + mov rcx, r8 + and r8, 7 + shr rcx, 3 ; rcx <- # of Qwords to copy + jz @CopyBytes + DB 49h, 0fh, 7eh, 0c2h ; movd r10, mm0 (Save mm0 in r10) +@@: + DB 0fh, 6fh, 06h ; movd mm0, [rsi] + DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0 + add rsi, 8 + add rdi, 8 + loop @B + DB 49h, 0fh, 6eh, 0c2h ; movd mm0, r10 (Restore mm0) + jmp @CopyBytes +@CopyBackward: + mov rsi, r9 ; rsi <- End of Source + lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination + std ; set direction flag +@CopyBytes: + mov rcx, r8 + rep movsb ; Copy bytes backward + cld +@CopyMemDone: + ret +memcpy ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpySSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpySSE2.asm new file mode 100644 index 0000000000..15bdf37ffb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memcpySSE2.asm @@ -0,0 +1,80 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CopyMem.asm +; +; Abstract: +; +; memcpy function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; memcpy ( +; OUT VOID *DestinationBuffer, +; IN CONST VOID *SourceBuffer, +; IN UINTN Length +; ); +;------------------------------------------------------------------------------ +memcpy PROC USES rsi rdi + mov rax, rcx ; rax <- Destination as return value + cmp rdx, rcx ; if Source == Destination, do nothing + je @CopyMemDone + cmp r8, 0 ; if Count == 0, do nothing + je @CopyMemDone + mov rsi, rdx ; rsi <- Source + mov rdi, rcx ; rdi <- Destination + lea r9, [rsi + r8 - 1] ; r9 <- Last byte of Source + cmp rsi, rdi + jae @F ; Copy forward if Source > Destination + cmp r9, rdi ; Overlapped? + jae @CopyBackward ; Copy backward if overlapped +@@: + xor rcx, rcx + sub rcx, rdi ; rcx <- -rdi + and rcx, 15 ; rcx + rsi should be 16 bytes aligned + jz @F ; skip if rcx == 0 + cmp rcx, r8 + cmova rcx, r8 + sub r8, rcx + rep movsb +@@: + mov rcx, r8 + and r8, 15 + shr rcx, 4 ; rcx <- # of DQwords to copy + jz @CopyBytes +@@: + movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned + movdqa [rdi], xmm0 ; rdi should be 16-byte aligned + add rsi, 16 + add rdi, 16 + loop @B + jmp @CopyBytes ; copy remaining bytes +@CopyBackward: + mov rsi, r9 ; rsi <- Last byte of Source + lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination + std +@CopyBytes: + mov rcx, r8 + rep movsb + cld +@CopyMemDone: + ret +memcpy ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memset.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memset.asm new file mode 100644 index 0000000000..134700d912 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memset.asm @@ -0,0 +1,62 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetMem.asm +; +; Abstract: +; +; memset function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; memset ( +; OUT VOID *Buffer, --> rcx +; IN UINT8 Value, --> rdx +; IN UINTN Length --> r8 +; ); +;------------------------------------------------------------------------------ +memset PROC USES rdi + mov rax, rcx + cmp r8, 0 ; if Size == 0, do nothing + je @SetDone + mov rax, rdx ; rdx <-> r8 + mov rdx, r8 ; rdx <- Length + mov r8, rax ; r8 <- Value + mov ah, al + DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax + mov r8, rcx + mov rdi, r8 ; rdi <- Buffer + mov rcx, rdx + and edx, 7 + shr rcx, 3 + jz @SetBytes + DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h +@@: + DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0 + add rdi, 8 + loop @B +@SetBytes: + mov ecx, edx + rep stosb + mov rax, r8 +@SetDone: + ret +memset ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memsetSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memsetSSE2.asm new file mode 100644 index 0000000000..0370c9be71 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/x64/memsetSSE2.asm @@ -0,0 +1,74 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetMem.asm +; +; Abstract: +; +; memset function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; memset ( +; OUT VOID *Buffer, --> rcx +; IN UINT8 Value, --> rdx +; IN UINTN Length --> r8 +; ); +;------------------------------------------------------------------------------ +memset PROC USES rdi + mov rax, rcx + cmp r8, 0 ; if Size == 0, do nothing + je @SetDone + mov rax, rdx ; rdx <-> r8 + mov rdx, r8 ; rdx <- Length + mov r8, rax ; r8 <- Value + + mov rdi, rcx ; rdi <- Buffer + mov al, r8b ; al <- Value + mov r9, rdi ; r9 <- Buffer as return value + xor rcx, rcx + sub rcx, rdi + and rcx, 15 ; rcx + rdi aligns on 16-byte boundary + jz @F + cmp rcx, rdx + cmova rcx, rdx + sub rdx, rcx + rep stosb +@@: + mov rcx, rdx + and rdx, 15 + shr rcx, 4 + jz @SetBytes + mov ah, al ; ax <- Value repeats twice + movd xmm0, eax ; xmm0[0..16] <- Value repeats twice + pshuflw xmm0, xmm0, 0 ; xmm0[0..63] <- Value repeats 8 times + movlhps xmm0, xmm0 ; xmm0 <- Value repeats 16 times +@@: + movdqa [rdi], xmm0 ; rdi should be 16-byte aligned + add rdi, 16 + loop @B +@SetBytes: + mov ecx, edx ; high 32 bits of rcx are always zero + rep stosb + mov rax, r9 ; rax <- Return value +@SetDone: + ret +memset ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c new file mode 100644 index 0000000000..20f7d6acca --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c @@ -0,0 +1,122 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CustomizedDecompress.c + +Abstract: + + Implementation file for Customized decompression routine + +--*/ +#include "TianoCommon.h" +#include "CustomizedDecompress.h" + +EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL mCustomizedDecompress = { + CustomizedGetInfo, + CustomizedDecompress +}; + +EFI_STATUS +InstallCustomizedDecompress ( + EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL **This + ) +/*++ + +Routine Description: + + Install customeized decompress protocol. + +Arguments: + + This - The protocol that needs to be installed. + +Returns: + + EFI_SUCCESS - Always success + +--*/ +{ + *This = &mCustomizedDecompress; + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +CustomizedGetInfo ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation of Customized GetInfo(). + +Arguments: + This - The EFI customized decompress protocol + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + EFI_UNSUPPORTED - Not supported + +--*/ +{ + return EFI_UNSUPPORTED; +} + +EFI_STATUS +EFIAPI +CustomizedDecompress ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation of Customized Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + EFI_UNSUPPORTED - Not supported + +--*/ +{ + return EFI_UNSUPPORTED; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h new file mode 100644 index 0000000000..047c3d3883 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h @@ -0,0 +1,113 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CustomizedDecompress.h + +Abstract: + + Header file for Customized decompression routine + +--*/ +#ifndef _CUSTOMIZED_DECOMPRESS_LIB_H_ +#define _CUSTOMIZED_DECOMPRESS_LIB_H_ + +#include EFI_PROTOCOL_DEFINITION (CustomizedDecompress) + +EFI_STATUS +EFIAPI +CustomizedGetInfo ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation of Customized GetInfo(). + +Arguments: + This - The EFI customized decompress protocol + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + EFI_UNSUPPORTED - Not supported + +--*/ +; + +EFI_STATUS +EFIAPI +CustomizedDecompress ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation of Customized Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + EFI_UNSUPPORTED - Not supported + +--*/ +; + +EFI_STATUS +InstallCustomizedDecompress ( + EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL **This + ) +/*++ + +Routine Description: + + Install customeized decompress protocol. + +Arguments: + + This - The protocol that needs to be installed. + +Returns: + + EFI_SUCCESS - Always success + +--*/ +; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf new file mode 100644 index 0000000000..151a4736a9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf @@ -0,0 +1,39 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CustomizedDecompress.inf +# +# Abstract: +# +# Component description file for the Customized Decompress library. +# +#--*/ + +[defines] +BASE_NAME = CustomizedDecompress +COMPONENT_TYPE = LIBRARY + +[sources.common] + CustomizedDecompress.c + CustomizedDecompress.h + +[includes.common] + . + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Include + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c new file mode 100644 index 0000000000..a968f407b7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c @@ -0,0 +1,172 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Debug.c + +Abstract: + + Support for Debug primatives. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "EfiPrintLib.h" +#include "EfiStatusCode.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) +#include EFI_PROTOCOL_DEFINITION (DEBUGMASK) + +// +// You would think you should divid by sizeof (UINT64), but EBC does not like +// that! +// +#define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8) + +VOID +EfiDebugAssert ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ) +/*++ + +Routine Description: + + Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded BREAKPOINT(). + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + FileName - File name of failing routine. + + LineNumber - Line number of failing ASSERT(). + + Description - Descritption, usally the assertion, + +Returns: + + None + +--*/ +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; + + EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer); + + EfiLibReportStatusCode ( + (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), + 0, + &gEfiCallerIdGuid, + (EFI_STATUS_CODE_DATA *) Buffer + ); + + // + // Put break point in module that contained the error. + // + EFI_BREAKPOINT (); +} + +VOID +EfiDebugVPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + Marker - VarArgs + +Returns: + + None + +--*/ +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; + UINTN ImageDebugMask; + + // + // Check driver debug mask value and global mask + // + if (gDebugMaskInterface != NULL) { + gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask); + if (!(ErrorLevel & ImageDebugMask)) { + return ; + } + } else if (!(gErrorLevel & ErrorLevel)) { + return ; + } + + EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer); + + EfiLibReportStatusCode ( + EFI_DEBUG_CODE, + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED), + (UINT32) ErrorLevel, + &gEfiCallerIdGuid, + (EFI_STATUS_CODE_DATA *) Buffer + ); + + return ; +} + +VOID +EfiDebugPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Wrapper for EfiDebugVPrint () + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + ... - Print arguments. + + +Returns: + + None + +--*/ +{ + VA_LIST Marker; + + VA_START (Marker, Format); + EfiDebugVPrint (ErrorLevel, Format, Marker); + VA_END (Marker); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c new file mode 100644 index 0000000000..1a827c1935 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c @@ -0,0 +1,607 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DevicePath.c + +Abstract: + + Device Path services. The thing to remember is device paths are built out of + nodes. The device path is terminated by an end node that is length + sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL) + all over this file. + + The only place where multi-instance device paths are supported is in + environment varibles. Multi-instance device paths should never be placed + on a Handle. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include EFI_PROTOCOL_DEFINITION (DevicePath) + +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Function retrieves the next device path instance from a device path data structure. + +Arguments: + DevicePath - A pointer to a device path data structure. + + Size - A pointer to the size of a device path instance in bytes. + +Returns: + + This function returns a pointer to the current device path instance. + In addition, it returns the size in bytes of the current device path instance in Size, + and a pointer to the next device path instance in DevicePath. + If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *DevPath; + EFI_DEVICE_PATH_PROTOCOL *ReturnValue; + UINT8 Temp; + + if (*DevicePath == NULL) { + if (Size != NULL) { + *Size = 0; + } + + return NULL; + } + + // + // Find the end of the device path instance + // + DevPath = *DevicePath; + while (!IsDevicePathEndType (DevPath)) { + DevPath = NextDevicePathNode (DevPath); + } + + // + // Compute the size of the device path instance + // + if (Size != NULL) { + *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL); + } + + // + // Make a copy and return the device path instance + // + Temp = DevPath->SubType; + DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; + ReturnValue = EfiDuplicateDevicePath (*DevicePath); + DevPath->SubType = Temp; + + // + // If DevPath is the end of an entire device path, then another instance + // does not follow, so *DevicePath is set to NULL. + // + if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) { + *DevicePath = NULL; + } else { + *DevicePath = NextDevicePathNode (DevPath); + } + + return ReturnValue; +} + +BOOLEAN +EfiIsDevicePathMultiInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + Return TRUE is this is a multi instance device path. + +Arguments: + DevicePath - A pointer to a device path data structure. + + +Returns: + TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi + instance. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *Node; + + if (DevicePath == NULL) { + return FALSE; + } + + Node = DevicePath; + while (!EfiIsDevicePathEnd (Node)) { + if (EfiIsDevicePathEndInstance (Node)) { + return TRUE; + } + + Node = EfiNextDevicePathNode (Node); + } + + return FALSE; +} + +UINTN +EfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + + Calculate the space size of a device path. + +Arguments: + + DevicePath - A specified device path + +Returns: + + The size. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *Start; + + if (DevicePath == NULL) { + return 0; + } + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Compute the size and add back in the size of the end device path structure + // + return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); +} + +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +/*++ + +Routine Description: + + Get the device path protocol interface installed on a specified handle. + +Arguments: + + Handle - a specified handle + +Returns: + + The device path protocol interface installed on that handle. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + DevicePath = NULL; + gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *) &DevicePath + ); + return DevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +EfiDuplicateDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + + Duplicate a device path structure. + +Arguments: + + DevicePath - The device path to duplicated. + +Returns: + + The duplicated device path. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN Size; + + if (DevicePath == NULL) { + return NULL; + } + + // + // Compute the size + // + Size = EfiDevicePathSize (DevicePath); + if (Size == 0) { + return NULL; + } + + // + // Allocate space for duplicate device path + // + NewDevicePath = EfiLibAllocateCopyPool (Size, DevicePath); + + return NewDevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a Src1 and Src2 together. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + + A pointer to the new device path is returned. + NULL is returned if space for the new device path could not be allocated from pool. + It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed. + +--*/ +{ + UINTN Size; + UINTN Size1; + UINTN Size2; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath; + + // + // If there's only 1 path, just duplicate it + // + if (!Src1) { + ASSERT (!IsDevicePathUnpacked (Src2)); + return EfiDuplicateDevicePath (Src2); + } + + if (!Src2) { + ASSERT (!IsDevicePathUnpacked (Src1)); + return EfiDuplicateDevicePath (Src1); + } + + // + // Allocate space for the combined device path. It only has one end node of + // length EFI_DEVICE_PATH_PROTOCOL + // + Size1 = EfiDevicePathSize (Src1); + Size2 = EfiDevicePathSize (Src2); + Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); + + NewDevicePath = EfiLibAllocateCopyPool (Size, Src1); + + if (NewDevicePath != NULL) { + + // + // Over write Src1 EndNode and do the copy + // + SecondDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + EfiCopyMem (SecondDevicePath, Src2, Size2); + } + + return NewDevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Node + ) +/*++ + +Routine Description: + Function is used to append a device path node to the end of another device path. + +Arguments: + Src1 - A pointer to a device path data structure. + + Node - A pointer to a device path data structure. + +Returns: + This function returns a pointer to the new device path. + If there is not enough temporary pool memory available to complete this function, + then NULL is returned. + + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *Temp; + EFI_DEVICE_PATH_PROTOCOL *NextNode; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN NodeLength; + + // + // Build a Node that has a terminator on it + // + NodeLength = DevicePathNodeLength (Node); + + Temp = EfiLibAllocateCopyPool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL), Node); + if (Temp == NULL) { + return NULL; + } + + // + // Add and end device path node to convert Node to device path + // + NextNode = NextDevicePathNode (Temp); + SetDevicePathEndNode (NextNode); + + // + // Append device paths + // + NewDevicePath = EfiAppendDevicePath (Src1, Temp); + gBS->FreePool (Temp); + return NewDevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +EfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ) +/*++ + +Routine Description: + + This function allocates a device path for a file and appends it to an existiong + device path. + +Arguments: + Device - A pointer to a device handle. + + FileName - A pointer to a Null-terminated Unicodestring. + +Returns: + A device path contain the file name. + +--*/ +{ + UINTN Size; + FILEPATH_DEVICE_PATH *FilePath; + EFI_DEVICE_PATH_PROTOCOL *Eop; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + for (Size = 0; FileName[Size] != 0; Size++) + ; + Size = (Size + 1) * 2; + + FilePath = EfiLibAllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL)); + + DevicePath = NULL; + + if (FilePath != NULL) { + + // + // Build a file path + // + FilePath->Header.Type = MEDIA_DEVICE_PATH; + FilePath->Header.SubType = MEDIA_FILEPATH_DP; + SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH); + EfiCopyMem (FilePath->PathName, FileName, Size); + Eop = NextDevicePathNode (&FilePath->Header); + SetDevicePathEndNode (Eop); + + // + // Append file path to device's device path + // + + DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath; + if (Device != NULL) { + DevicePath = EfiAppendDevicePath ( + EfiDevicePathFromHandle (Device), + DevicePath + ); + + gBS->FreePool (FilePath); + } + } + + return DevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *Src, + IN EFI_DEVICE_PATH_PROTOCOL *Instance + ) +/*++ + +Routine Description: + + Append a device path instance to another. + +Arguments: + + Src - The device path instance to be appended with. + Instance - The device path instance appending the other. + +Returns: + + The contaction of these two. + +--*/ +{ + UINT8 *Ptr; + EFI_DEVICE_PATH_PROTOCOL *DevPath; + UINTN SrcSize; + UINTN InstanceSize; + + if (Src == NULL) { + return EfiDuplicateDevicePath (Instance); + } + + SrcSize = EfiDevicePathSize (Src); + InstanceSize = EfiDevicePathSize (Instance); + + Ptr = EfiLibAllocateCopyPool (SrcSize + InstanceSize, Src); + if (Ptr != NULL) { + + DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr; + + while (!IsDevicePathEnd (DevPath)) { + DevPath = NextDevicePathNode (DevPath); + } + // + // Convert the End to an End Instance, since we are + // appending another instacne after this one its a good + // idea. + // + DevPath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; + + DevPath = NextDevicePathNode (DevPath); + EfiCopyMem (DevPath, Instance, InstanceSize); + } + + return (EFI_DEVICE_PATH_PROTOCOL *) Ptr; +} + +VOID +EFIAPI +EfiInitializeFwVolDevicepathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN EFI_GUID *NameGuid + ) +/*++ + +Routine Description: + + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + +Arguments: + + FvDevicePathNode - Pointer to a FV device path node to initialize + NameGuid - FV file name to use in FvDevicePathNode + +Returns: + + None + +--*/ +{ +#if (EFI_SPECIFICATION_VERSION != 0x00020000) + // + // Use old Device Path + // + FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + +#else + // + // Use the new Device path that does not conflict with the UEFI 2.0 + // + FvDevicePathNode->Piwg.Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Piwg.Header.SubType = MEDIA_VENDOR_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + + // + // Add the GUID for generic PIWG device paths + // + EfiCopyMem (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid, sizeof(EFI_GUID)); + + // + // Add in the FW Vol File Path PIWG defined inforation + // + FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE; + +#endif + EfiCopyMem (&FvDevicePathNode->NameGuid, NameGuid, sizeof(EFI_GUID)); +} + +EFI_GUID * +EFIAPI +EfiGetNameGuidFromFwVolDevicePathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ) +/*++ + +Routine Description: + + Check to see if the Firmware Volume (FV) Media Device Path is valid. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. The return value to this + function points to a location in FvDevicePathNode and it does not allocate + new memory for the GUID pointer that is returned. + +Arguments: + + FvDevicePathNode - Pointer to FV device path to check + +Returns: + + NULL - FvDevicePathNode is not valid. + Other - FvDevicePathNode is valid and pointer to NameGuid was returned. + +--*/ +{ +#if (EFI_SPECIFICATION_VERSION != 0x00020000) + // + // Use old Device Path + // + if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) { + return &FvDevicePathNode->NameGuid; + } + +#else + // + // Use the new Device path that does not conflict with the UEFI 2.0 + // + if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) { + if (EfiCompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) { + if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) { + return &FvDevicePathNode->NameGuid; + } + } + } +#endif + return NULL; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c new file mode 100644 index 0000000000..ecce5f05e6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c @@ -0,0 +1,56 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DxeDriverLib.c + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +EFI_STATUS +DxeInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - Standard EFI Image entry parameter + + SystemTable - Standard EFI Image entry parameter + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +{ + EFI_STATUS Status; + + Status = EfiInitializeDriverLib (ImageHandle, SystemTable); + if (!EFI_ERROR (Status)) { + Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); + } + + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c new file mode 100644 index 0000000000..bfe034975f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PerformancePrimitives.c + +Abstract: + + Support for Performance library + +--*/ + +#include "Tiano.h" // for ASSERT macro +#include "TianoCommon.h" + +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ) +/*++ + +Routine Description: + + Set TimerValue to 0, which is not expected to be run. + +Arguments: + + TimerValue - Timer value for output + +Returns: + + EFI_SUCCESS - Should not be reached. + +--*/ +{ + // + // Should not be used for EBC, so assert. + // + *TimerValue = 0; + ASSERT (FALSE); + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c new file mode 100644 index 0000000000..f1af8cc74d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c @@ -0,0 +1,429 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiDriverLib.c + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +// +// Global Interface for Debug Mask Protocol +// +EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface = NULL; + +EFI_STATUS +EfiInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - Standard EFI Image entry parameter + + SystemTable - Standard EFI Image entry parameter + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +{ + gST = SystemTable; + + ASSERT (gST != NULL); + + gBS = gST->BootServices; + gRT = gST->RuntimeServices; + + ASSERT (gBS != NULL); + ASSERT (gRT != NULL); + + // + // Get driver debug mask protocol interface + // +#ifdef EFI_DEBUG + gBS->HandleProtocol ( + ImageHandle, + &gEfiDebugMaskProtocolGuid, + (VOID *) &gDebugMaskInterface + ); +#endif + // + // Should be at EFI_D_INFO, but lets us know things are running + // + DEBUG ((EFI_D_INFO, "EfiInitializeDriverLib: Started\n")); + + return EFI_SUCCESS; +} + +BOOLEAN +EfiLibCompareLanguage ( + IN CHAR8 *Language1, + IN CHAR8 *Language2 + ) +/*++ + +Routine Description: + + Compare whether two names of languages are identical. + +Arguments: + + Language1 - Name of language 1 + Language2 - Name of language 2 + +Returns: + + TRUE - same + FALSE - not same + +--*/ +{ + UINTN Index; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) { + if (Language1[Index] != Language2[Index]) { + return FALSE; + } + } + + if (((Language1[Index] == 0) && (Language2[Index] == 0)) || + ((Language1[Index] == 0) && (Language2[Index] != ';')) || + ((Language1[Index] == ';') && (Language2[Index] != 0)) || + ((Language1[Index] == ';') && (Language2[Index] != ';'))) { + return TRUE; + } + + return FALSE; +#else + for (Index = 0; Index < 3; Index++) { + if (Language1[Index] != Language2[Index]) { + return FALSE; + } + } + + return TRUE; +#endif +} + +STATIC +CHAR8 * +NextSupportedLanguage ( + IN CHAR8 *Languages + ) +{ +#ifdef LANGUAGE_RFC_3066 // LANGUAGE_RFC_3066 + for (; (*Languages != 0) && (*Languages != ';'); Languages++) + ; + return Languages; +#else // LANGUAGE_ISO_639_2 + return (Languages + 3); +#endif +} + +EFI_STATUS +EfiLibLookupUnicodeString ( + IN CHAR8 *Language, + IN CHAR8 *SupportedLanguages, + IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + OUT CHAR16 **UnicodeString + ) +/*++ + +Routine Description: + + Translate a unicode string to a specified language if supported. + +Arguments: + + Language - The name of language to translate to + SupportedLanguages - Supported languages set + UnicodeStringTable - Pointer of one item in translation dictionary + UnicodeString - The translated string + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + EFI_UNSUPPORTED - System not supported this language or this string translation + EFI_SUCCESS - String successfully translated + +--*/ +{ + // + // Make sure the parameters are valid + // + if (Language == NULL || UnicodeString == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, or the Unicode String Table is empty, then the + // Unicode String specified by Language is not supported by this Unicode String Table + // + if (SupportedLanguages == NULL || UnicodeStringTable == NULL) { + return EFI_UNSUPPORTED; + } + + // + // Make sure Language is in the set of Supported Languages + // + while (*SupportedLanguages != 0) { + if (EfiLibCompareLanguage (Language, SupportedLanguages)) { + + // + // Search the Unicode String Table for the matching Language specifier + // + while (UnicodeStringTable->Language != NULL) { + if (EfiLibCompareLanguage (Language, UnicodeStringTable->Language)) { + + // + // A matching string was found, so return it + // + *UnicodeString = UnicodeStringTable->UnicodeString; + return EFI_SUCCESS; + } + + UnicodeStringTable++; + } + + return EFI_UNSUPPORTED; + } + + SupportedLanguages = NextSupportedLanguage(SupportedLanguages); + } + + return EFI_UNSUPPORTED; +} + +EFI_STATUS +EfiLibAddUnicodeString ( + IN CHAR8 *Language, + IN CHAR8 *SupportedLanguages, + IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + IN CHAR16 *UnicodeString + ) +/*++ + +Routine Description: + + Add an translation to the dictionary if this language if supported. + +Arguments: + + Language - The name of language to translate to + SupportedLanguages - Supported languages set + UnicodeStringTable - Translation dictionary + UnicodeString - The corresponding string for the language to be translated to + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + EFI_UNSUPPORTED - System not supported this language + EFI_ALREADY_STARTED - Already has a translation item of this language + EFI_OUT_OF_RESOURCES - No enough buffer to be allocated + EFI_SUCCESS - String successfully translated + +--*/ +{ + UINTN NumberOfEntries; + EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable; + EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable; + UINTN UnicodeStringLength; + + // + // Make sure the parameter are valid + // + if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, then a Unicode String can not be added + // + if (SupportedLanguages == NULL) { + return EFI_UNSUPPORTED; + } + + // + // If the Unicode String is empty, then a Unicode String can not be added + // + if (UnicodeString[0] == 0) { + return EFI_INVALID_PARAMETER; + } + + // + // Make sure Language is a member of SupportedLanguages + // + while (*SupportedLanguages != 0) { + if (EfiLibCompareLanguage (Language, SupportedLanguages)) { + + // + // Determine the size of the Unicode String Table by looking for a NULL Language entry + // + NumberOfEntries = 0; + if (*UnicodeStringTable != NULL) { + OldUnicodeStringTable = *UnicodeStringTable; + while (OldUnicodeStringTable->Language != NULL) { + if (EfiLibCompareLanguage (Language, OldUnicodeStringTable->Language)) { + return EFI_ALREADY_STARTED; + } + + OldUnicodeStringTable++; + NumberOfEntries++; + } + } + + // + // Allocate space for a new Unicode String Table. It must hold the current number of + // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table + // marker + // + NewUnicodeStringTable = EfiLibAllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE)); + if (NewUnicodeStringTable == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // If the current Unicode String Table contains any entries, then copy them to the + // newly allocated Unicode String Table. + // + if (*UnicodeStringTable != NULL) { + EfiCopyMem ( + NewUnicodeStringTable, + *UnicodeStringTable, + NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE) + ); + } + + // + // Allocate space for a copy of the Language specifier + // + NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrLen(Language) + 1, Language); + if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) { + gBS->FreePool (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Compute the length of the Unicode String + // + for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) + ; + + // + // Allocate space for a copy of the Unicode String + // + NewUnicodeStringTable[NumberOfEntries].UnicodeString = EfiLibAllocateCopyPool ( + (UnicodeStringLength + 1) * sizeof (CHAR16), + UnicodeString + ); + if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) { + gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language); + gBS->FreePool (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Mark the end of the Unicode String Table + // + NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL; + NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL; + + // + // Free the old Unicode String Table + // + if (*UnicodeStringTable != NULL) { + gBS->FreePool (*UnicodeStringTable); + } + + // + // Point UnicodeStringTable at the newly allocated Unicode String Table + // + *UnicodeStringTable = NewUnicodeStringTable; + + return EFI_SUCCESS; + } + + SupportedLanguages = NextSupportedLanguage(SupportedLanguages); + } + + return EFI_UNSUPPORTED; +} + +EFI_STATUS +EfiLibFreeUnicodeStringTable ( + IN OUT EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ) +/*++ + +Routine Description: + + Free a string table. + +Arguments: + + UnicodeStringTable - The string table to be freed. + +Returns: + + EFI_SUCCESS - The table successfully freed. + +--*/ +{ + UINTN Index; + + // + // If the Unicode String Table is NULL, then it is already freed + // + if (UnicodeStringTable == NULL) { + return EFI_SUCCESS; + } + + // + // Loop through the Unicode String Table until we reach the end of table marker + // + for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) { + + // + // Free the Language string from the Unicode String Table + // + gBS->FreePool (UnicodeStringTable[Index].Language); + + // + // Free the Unicode String from the Unicode String Table + // + if (UnicodeStringTable[Index].UnicodeString != NULL) { + gBS->FreePool (UnicodeStringTable[Index].UnicodeString); + } + } + + // + // Free the Unicode String Table itself + // + gBS->FreePool (UnicodeStringTable); + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf new file mode 100644 index 0000000000..32425744aa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf @@ -0,0 +1,88 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiDriverLib.inf +# +# Abstract: +# +# Component description file for the EFI driver library. +# +#--*/ + +[defines] +BASE_NAME = EfiDriverLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + Debug.c + DevicePath.c + EfiDriverLib.c + DxeDriverLib.c + EfiGetConfigTable.c + EfiDriverModelLib.c + Event.c + Handle.c + LibGlobalSt.c + LibGlobalDs.c + LibGlobalErrorLevel.c + Lock.c + EfiLibAllocate.c + Perf.c + ReportStatusCode.c + GetImage.c + + ..\hob\hob.c + +[sources.ia32] + ia32\PerformancePrimitives.c + +[sources.x64] + x64\PerformancePrimitives.c + +[sources.ipf] + ipf\PerformancePrimitives.s + +[sources.ebc] + Ebc\PerformancePrimitives.c + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkGuidLib + EdkProtocolLib + EdkFrameworkProtocolLib + EfiGuidLib + EfiProtocolLib + ArchProtocolLib + EfiCommonLib + +[libraries.ia32] + CpuIA32Lib + +[libraries.x64] + CpuIA32Lib + +[libraries.ipf] + CpuIA64Lib + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c new file mode 100644 index 0000000000..5c2b47b66e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c @@ -0,0 +1,289 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiDriverModelLib.c + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +EFI_STATUS +EfiLibInstallDriverBinding ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle + ) +/*++ + +Routine Description: + + Intialize a driver by installing the Driver Binding Protocol onto the + driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. This function also initializes the EFI Driver + Library that initializes the global variables gST, gBS, gRT. + +Arguments: + + ImageHandle - The image handle of the driver + + SystemTable - The EFI System Table that was passed to the driver's entry point + + DriverBinding - A Driver Binding Protocol instance that this driver is producing + + DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + +Returns: + + EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle + + Otherwise, then return status from gBS->InstallProtocolInterface() + +--*/ +{ + EfiInitializeDriverLib (ImageHandle, SystemTable); + + DriverBinding->ImageHandle = ImageHandle; + + DriverBinding->DriverBindingHandle = DriverBindingHandle; + + return gBS->InstallProtocolInterface ( + &DriverBinding->DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, + EFI_NATIVE_INTERFACE, + DriverBinding + ); +} + +EFI_STATUS +EfiLibInstallAllDriverProtocols ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE * SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding, + IN EFI_HANDLE DriverBindingHandle, +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + IN EFI_COMPONENT_NAME2_PROTOCOL * ComponentName, OPTIONAL +#else + IN EFI_COMPONENT_NAME_PROTOCOL * ComponentName, OPTIONAL +#endif + IN EFI_DRIVER_CONFIGURATION_PROTOCOL * DriverConfiguration, OPTIONAL + IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL * DriverDiagnostics OPTIONAL + ) +/*++ + +Routine Description: + + Intialize a driver by installing the Driver Binding Protocol onto the + driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. This function also initializes the EFI Driver + Library that initializes the global variables gST, gBS, gRT. + +Arguments: + + ImageHandle - The image handle of the driver + + SystemTable - The EFI System Table that was passed to the driver's entry point + + DriverBinding - A Driver Binding Protocol instance that this driver is producing + + DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + + ComponentName - A Component Name Protocol instance that this driver is producing + + DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing + + DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing + +Returns: + + EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle + + Otherwise, then return status from gBS->InstallProtocolInterface() + +--*/ +{ + EFI_STATUS Status; + + Status = EfiLibInstallDriverBinding (ImageHandle, SystemTable, DriverBinding, DriverBindingHandle); + if (EFI_ERROR (Status)) { + return Status; + } + + if (ComponentName != NULL) { + Status = gBS->InstallProtocolInterface ( + &DriverBinding->DriverBindingHandle, +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + &gEfiComponentName2ProtocolGuid, +#else + &gEfiComponentNameProtocolGuid, +#endif + EFI_NATIVE_INTERFACE, + ComponentName + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (DriverConfiguration != NULL) { + Status = gBS->InstallProtocolInterface ( + &DriverBinding->DriverBindingHandle, + &gEfiDriverConfigurationProtocolGuid, + EFI_NATIVE_INTERFACE, + DriverConfiguration + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + if (DriverDiagnostics != NULL) { + Status = gBS->InstallProtocolInterface ( + &DriverBinding->DriverBindingHandle, + &gEfiDriverDiagnosticsProtocolGuid, + EFI_NATIVE_INTERFACE, + DriverDiagnostics + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiLibTestManagedDevice ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE DriverBindingHandle, + IN EFI_GUID *ManagedProtocolGuid + ) +/*++ + +Routine Description: + + Test to see if the controller is managed by a specific driver. + +Arguments: + + ControllerHandle - Handle for controller to test + + DriverBindingHandle - Driver binding handle for controller + + ManagedProtocolGuid - The protocol guid the driver opens on controller + +Returns: + + EFI_SUCCESS - The controller is managed by the driver + + EFI_UNSUPPORTED - The controller is not managed by the driver + +--*/ +{ + EFI_STATUS Status; + VOID *ManagedInterface; + + Status = gBS->OpenProtocol ( + ControllerHandle, + ManagedProtocolGuid, + &ManagedInterface, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (!EFI_ERROR (Status)) { + gBS->CloseProtocol ( + ControllerHandle, + ManagedProtocolGuid, + DriverBindingHandle, + ControllerHandle + ); + return EFI_UNSUPPORTED; + } + + if (Status != EFI_ALREADY_STARTED) { + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiLibTestChildHandle ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle, + IN EFI_GUID *ConsumedGuid + ) +/*++ + +Routine Description: + + Test to see if the child handle is the child of the controller + +Arguments: + + ControllerHandle - Handle for controller (parent) + + ChildHandle - Child handle to test + + ConsumsedGuid - Protocol guid consumed by child from controller + +Returns: + + EFI_SUCCESS - The child handle is the child of the controller + + EFI_UNSUPPORTED - The child handle is not the child of the controller + +--*/ +{ + EFI_STATUS Status; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; + UINTN EntryCount; + UINTN Index; + + // + // Retrieve the list of agents that are consuming one of the protocols + // on ControllerHandle that the children consume + // + Status = gBS->OpenProtocolInformation ( + ControllerHandle, + ConsumedGuid, + &OpenInfoBuffer, + &EntryCount + ); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + // + // See if one of the agents is ChildHandle + // + Status = EFI_UNSUPPORTED; + for (Index = 0; Index < EntryCount; Index++) { + if (OpenInfoBuffer[Index].ControllerHandle == ChildHandle && + OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) { + Status = EFI_SUCCESS; + } + } + gBS->FreePool (OpenInfoBuffer); + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c new file mode 100644 index 0000000000..7fdbb8d8f4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c @@ -0,0 +1,61 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiGetConfigTable.c + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ) +/*++ + +Routine Description: + + Get table from configuration table by name + +Arguments: + + TableGuid - Table name to search + + Table - Pointer to the table caller wants + +Returns: + + EFI_NOT_FOUND - Not found the table + + EFI_SUCCESS - Found the table + +--*/ +{ + UINTN Index; + + *Table = NULL; + for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { + if (EfiCompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) { + *Table = gST->ConfigurationTable[Index].VendorTable; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c new file mode 100644 index 0000000000..6558e3da0e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c @@ -0,0 +1,233 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiLibAllocate.c + +Abstract: + + Support routines for memory allocation routines for use with drivers. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +VOID * +EfiLibAllocatePool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool. + +Arguments: + + AllocationSize - The size to allocate + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = NULL; + gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory); + return Memory; +} + +VOID * +EfiLibAllocateRuntimePool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate RuntimeServicesData pool. + +Arguments: + + AllocationSize - The size to allocate + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = NULL; + gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory); + return Memory; +} + +VOID * +EfiLibAllocateZeroPool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool and zero it. + +Arguments: + + AllocationSize - The size to allocate + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = EfiLibAllocatePool (AllocationSize); + if (Memory != NULL) { + gBS->SetMem (Memory, AllocationSize, 0); + } + + return Memory; +} + +VOID * +EfiLibAllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate RuntimeServicesData pool and zero it. + +Arguments: + + AllocationSize - The size to allocate + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = EfiLibAllocateRuntimePool (AllocationSize); + if (Memory != NULL) { + gBS->SetMem (Memory, AllocationSize, 0); + } + + return Memory; +} + +VOID * +EfiLibAllocateCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool and use a buffer provided by + caller to fill it. + +Arguments: + + AllocationSize - The size to allocate + + Buffer - Buffer that will be filled into the buffer allocated + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = NULL; + gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory); + if (Memory != NULL) { + gBS->CopyMem (Memory, Buffer, AllocationSize); + } + + return Memory; +} + +VOID * +EfiLibAllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Allocate RuntimeServicesData pool and use a buffer provided by + caller to fill it. + +Arguments: + + AllocationSize - The size to allocate + + Buffer - Buffer that will be filled into the buffer allocated + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = NULL; + gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory); + if (Memory != NULL) { + gBS->CopyMem (Memory, Buffer, AllocationSize); + } + + return Memory; +} + + +VOID +EfiLibSafeFreePool ( + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Free pool safely (without setting back Buffer to NULL). + +Arguments: + + Buffer - The allocated pool entry to free + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + if (Buffer != NULL) { + gBS->FreePool (Buffer); + } +} \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Event.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Event.c new file mode 100644 index 0000000000..3cb668e966 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Event.c @@ -0,0 +1,371 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Event.c + +Abstract: + + Support for Event lib fucntions. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +EFI_EVENT +EfiLibCreateProtocolNotifyEvent ( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT VOID **Registration + ) +/*++ + +Routine Description: + + Create a protocol notification event and return it. + +Arguments: + + ProtocolGuid - Protocol to register notification event on. + + NotifyTpl - Maximum TPL to single the NotifyFunction. + + NotifyFunction - EFI notification routine. + + NotifyContext - Context passed into Event when it is created. + + Registration - Registration key returned from RegisterProtocolNotify(). + +Returns: + + The EFI_EVENT that has been registered to be signaled when a ProtocolGuid + is added to the system. + +--*/ +{ + EFI_STATUS Status; + EFI_EVENT Event; + + // + // Create the event + // + + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &Event + ); + ASSERT (!EFI_ERROR (Status)); + + // + // Register for protocol notifactions on this event + // + + Status = gBS->RegisterProtocolNotify ( + ProtocolGuid, + Event, + Registration + ); + + ASSERT (!EFI_ERROR (Status)); + + // + // Kick the event so we will perform an initial pass of + // current installed drivers + // + + gBS->SignalEvent (Event); + return Event; +} + +EFI_STATUS +EfiLibNamedEventListen ( + IN EFI_GUID * Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext + ) +/*++ + +Routine Description: + Listenes to signals on the name. + EfiLibNamedEventSignal() signals the event. + + NOTE: For now, the named listening/signalling is implemented + on a protocol interface being installed and uninstalled. + In the future, this maybe implemented based on a dedicated mechanism. + +Arguments: + Name - Name to register the listener on. + NotifyTpl - Maximum TPL to singnal the NotifyFunction. + NotifyFunction - The listener routine. + NotifyContext - Context passed into the listener routine. + +Returns: + EFI_SUCCESS if successful. + +--*/ +{ + EFI_STATUS Status; + EFI_EVENT Event; + VOID *RegistrationLocal; + + // + // Create event + // + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &Event + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->RegisterProtocolNotify ( + Name, + Event, + &RegistrationLocal + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiLibNamedEventSignal ( + IN EFI_GUID *Name + ) +/*++ + +Routine Description: + Signals a named event. All registered listeners will run. + The listeners should register using EfiLibNamedEventListen() function. + + NOTE: For now, the named listening/signalling is implemented + on a protocol interface being installed and uninstalled. + In the future, this maybe implemented based on a dedicated mechanism. + +Arguments: + Name - Name to perform the signaling on. The name is a GUID. + +Returns: + EFI_SUCCESS if successfull. + +--*/ +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + Name, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->UninstallProtocolInterface ( + Handle, + Name, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +static +VOID +EFIAPI +EventNotifySignalAllNullEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // This null event is a size efficent way to enusre that + // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly. + // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into + // CreateEventEx() and this function is used to make the + // old error checking in CreateEvent() for Tiano extensions + // function. + // + return; +} + +#endif + +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +{ + EFI_STATUS Status; + UINT32 EventType; + EFI_EVENT_NOTIFY WorkerNotifyFunction; + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + + if (NotifyFunction == NULL) { + EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL; + } else { + EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT; + } + WorkerNotifyFunction = NotifyFunction; + + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + LegacyBootEvent + ); +#else + + EventType = EFI_EVENT_NOTIFY_SIGNAL; + if (NotifyFunction == NULL) { + // + // CreatEventEx will check NotifyFunction is NULL or not + // + WorkerNotifyFunction = EventNotifySignalAllNullEvent; + } else { + WorkerNotifyFunction = NotifyFunction; + } + + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + &gEfiEventLegacyBootGuid, + LegacyBootEvent + ); +#endif + return Status; +} + +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +{ + EFI_STATUS Status; + UINT32 EventType; + EFI_EVENT_NOTIFY WorkerNotifyFunction; + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + + if (NotifyFunction == NULL) { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL; + } else { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT; + } + WorkerNotifyFunction = NotifyFunction; + + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + ReadyToBootEvent + ); +#else + + EventType = EFI_EVENT_NOTIFY_SIGNAL; + if (NotifyFunction == NULL) { + // + // CreatEventEx will check NotifyFunction is NULL or not + // + WorkerNotifyFunction = EventNotifySignalAllNullEvent; + } else { + WorkerNotifyFunction = NotifyFunction; + } + + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + &gEfiEventReadyToBootGuid, + ReadyToBootEvent + ); +#endif + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/GetImage.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/GetImage.c new file mode 100644 index 0000000000..3d44562ecf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/GetImage.c @@ -0,0 +1,220 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GetImage.c + +Abstract: + + Image data extraction support for common use. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "EfiImageFormat.h" + +#include EFI_PROTOCOL_CONSUMER (LoadedImage) + +EFI_STATUS +GetImageFromFv ( +#if (PI_SPECIFICATION_VERSION < 0x00010000) + IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv, +#else + IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, +#endif + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size + ) +{ + EFI_STATUS Status; + EFI_FV_FILETYPE FileType; + EFI_FV_FILE_ATTRIBUTES Attributes; + UINT32 AuthenticationStatus; + + // + // Read desired section content in NameGuid file + // + *Buffer = NULL; + *Size = 0; + Status = Fv->ReadSection ( + Fv, + NameGuid, + SectionType, + 0, + Buffer, + Size, + &AuthenticationStatus + ); + + if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) { + // + // Try reading PE32 section, since the TE section does not exist + // + *Buffer = NULL; + *Size = 0; + Status = Fv->ReadSection ( + Fv, + NameGuid, + EFI_SECTION_PE32, + 0, + Buffer, + Size, + &AuthenticationStatus + ); + } + + if (EFI_ERROR (Status) && + ((SectionType == EFI_SECTION_TE) || (SectionType == EFI_SECTION_PE32))) { + // + // Try reading raw file, since the desired section does not exist + // + *Buffer = NULL; + *Size = 0; + Status = Fv->ReadFile ( + Fv, + NameGuid, + Buffer, + Size, + &FileType, + &Attributes, + &AuthenticationStatus + ); + } + + return Status; +} + +EFI_STATUS +GetImage ( + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size + ) +{ + return GetImageEx (NULL, NameGuid, SectionType, Buffer, Size, FALSE); +} + +EFI_STATUS +GetImageEx ( + IN EFI_HANDLE ImageHandle, + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size, + BOOLEAN WithinImageFv + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_FIRMWARE_VOLUME_PROTOCOL *ImageFv; + EFI_FIRMWARE_VOLUME_PROTOCOL *Fv; +#else + EFI_FIRMWARE_VOLUME2_PROTOCOL *ImageFv; + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; +#endif + + if (ImageHandle == NULL && WithinImageFv) { + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_FOUND; + ImageFv = NULL; + if (ImageHandle != NULL) { + Status = gBS->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + &LoadedImage + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status = gBS->HandleProtocol ( + LoadedImage->DeviceHandle, + #if (PI_SPECIFICATION_VERSION < 0x00010000) + &gEfiFirmwareVolumeProtocolGuid, + #else + &gEfiFirmwareVolume2ProtocolGuid, + #endif + &ImageFv + ); + if (!EFI_ERROR (Status)) { + Status = GetImageFromFv (ImageFv, NameGuid, SectionType, Buffer, Size); + } + } + + if (Status == EFI_SUCCESS || WithinImageFv) { + return Status; + } + + Status = gBS->LocateHandleBuffer ( + ByProtocol, + #if (PI_SPECIFICATION_VERSION < 0x00010000) + &gEfiFirmwareVolumeProtocolGuid, + #else + &gEfiFirmwareVolume2ProtocolGuid, + #endif + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Find desired image in all Fvs + // + for (Index = 0; Index < HandleCount; ++Index) { + Status = gBS->HandleProtocol ( + HandleBuffer[Index], + #if (PI_SPECIFICATION_VERSION < 0x00010000) + &gEfiFirmwareVolumeProtocolGuid, + #else + &gEfiFirmwareVolume2ProtocolGuid, + #endif + (VOID**)&Fv + ); + + if (EFI_ERROR (Status)) { + gBS->FreePool(HandleBuffer); + return Status; + } + + if (ImageFv != NULL && Fv == ImageFv) { + continue; + } + + Status = GetImageFromFv (Fv, NameGuid, SectionType, Buffer, Size); + + if (!EFI_ERROR (Status)) { + break; + } + } + gBS->FreePool(HandleBuffer); + + // + // Not found image + // + if (Index == HandleCount) { + return EFI_NOT_FOUND; + } + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c new file mode 100644 index 0000000000..179079d3db --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c @@ -0,0 +1,176 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Handle.c + +Abstract: + + Support for Handle lib fucntions. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +EFI_STATUS +EfiLibLocateHandleProtocolByProtocols ( + IN OUT EFI_HANDLE * Handle, OPTIONAL + OUT VOID **Interface, OPTIONAL + ... + ) +/*++ +Routine Description: + + Function locates Protocol and/or Handle on which all Protocols specified + as a variable list are installed. + It supports continued search. The caller must assure that no handles are added + or removed while performing continued search, by e.g., rising the TPL and not + calling any handle routines. Otherwise the behavior is undefined. + +Arguments: + + Handle - The address of handle to receive the handle on which protocols + indicated by the variable list are installed. + If points to NULL, all handles are searched. If pointing to a + handle returned from previous call, searches starting from next handle. + If NULL, the parameter is ignored. + + Interface - The address of a pointer to a protocol interface that will receive + the interface indicated by first variable argument. + If NULL, the parameter is ignored. + + ... - A variable argument list containing protocol GUIDs. Must end with NULL. + +Returns: + + EFI_SUCCESS - All the protocols where found on same handle. + EFI_NOT_FOUND - A Handle with all the protocols installed was not found. + Other values as may be returned from LocateHandleBuffer() or HandleProtocol(). + +--*/ +{ + VA_LIST args; + EFI_STATUS Status; + EFI_GUID *Protocol; + EFI_GUID *ProtocolFirst; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; + UINTN Idx; + VOID *AnInterface; + + AnInterface = NULL; + VA_START (args, Interface); + ProtocolFirst = VA_ARG (args, EFI_GUID *); + + // + // Get list of all handles that support the first protocol. + // + Status = gBS->LocateHandleBuffer ( + ByProtocol, + ProtocolFirst, + NULL, + &NumberOfHandles, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Check if this is a countinuation of handle searching. + // + Idx = 0; + if ((Handle != NULL) && (*Handle != NULL)) { + // + // Leave the Idx just beyond the matching handle. + // + for (; Idx < NumberOfHandles;) { + if (*Handle == HandleBuffer[Idx++]) { + break; + } + } + } + + // + // Iterate handles testing for presence of remaining protocols. + // + for (; Idx < NumberOfHandles; Idx++) { + + // + // Start with the second protocol, the first one is sure on this handle. + // + VA_START (args, Interface); + VA_ARG (args, EFI_GUID *); + + // + // Iterate protocols from the variable list. + // + while (TRUE) { + + Protocol = VA_ARG (args, EFI_GUID *); + + if (Protocol == NULL) { + + // + // If here, the list was iterated successfully + // finding each protocol on a single handle. + // + + Status = EFI_SUCCESS; + + // + // OPTIONAL parameter returning the Handle. + // + if (Handle != NULL) { + *Handle = HandleBuffer[Idx]; + } + + // + // OPTIONAL parameter returning the first rotocol's Interface. + // + if (Interface != NULL) { + Status = gBS->HandleProtocol ( + HandleBuffer[Idx], + ProtocolFirst, + Interface + ); + } + + goto lbl_out; + } + + Status = gBS->HandleProtocol ( + HandleBuffer[Idx], + Protocol, + &AnInterface + ); + if (EFI_ERROR (Status)) { + + // + // This handle does not have the iterated protocol. + // + break; + } + } + + } + + // + // If here, no handle that bears all the protocols was found. + // + Status = EFI_NOT_FOUND; + +lbl_out: + gBS->FreePool (HandleBuffer); + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s new file mode 100644 index 0000000000..5814bb71b7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s @@ -0,0 +1,61 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// PerformancePrimitives.s +// +// Abstract: +// +// +// Revision History: +// +//-- + +.file "PerformancePrimitives.s" + +#include "IpfMacro.i" + +//----------------------------------------------------------------------------- +//++ +// GetTimerValue +// +// Implementation of CPU-based time service +// +// On Entry : +// EFI_STATUS +// GetTimerValue ( +// OUT UINT64 *TimerValue +// ) +// +// Return Value: +// r8 = Status +// r9 = 0 +// r10 = 0 +// r11 = 0 +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (GetTimerValue) + + NESTED_SETUP (1,8,0,0) + mov r8 = ar.itc;; + st8 [r32]= r8 + mov r8 = r0 + mov r9 = r0 + mov r10 = r0 + mov r11 = r0 + NESTED_RETURN + +PROCEDURE_EXIT (GetTimerValue) +//--------------------------------------------------------------------------- + diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c new file mode 100644 index 0000000000..328e465e45 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LibGlobalDs.c + +Abstract: + + Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c. + Each seperatly linked module has it's own copy of these globals. + + gBS - Boot Services table pointer + gRT - Runt Time services table pointer + gST - System Table pointer + + gErrorLevel - Debug error level. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +EFI_DXE_SERVICES *gDS = NULL; diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c new file mode 100644 index 0000000000..64ed94ced4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LibGlobalErrorLevel.c + +Abstract: + + Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c. + Each seperatly linked module has it's own copy of these globals. + + gBS - Boot Services table pointer + gRT - Runt Time services table pointer + gST - System Table pointer + + gErrorLevel - Debug error level. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +UINTN gErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD; diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c new file mode 100644 index 0000000000..5a6528588f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LibGlobalSt.c + +Abstract: + + Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c. + Each seperatly linked module has it's own copy of these globals. + + gBS - Boot Services table pointer + gRT - Runt Time services table pointer + gST - System Table pointer + + gErrorLevel - Debug error level. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +EFI_SYSTEM_TABLE *gST = NULL; +EFI_BOOT_SERVICES *gBS = NULL; +EFI_RUNTIME_SERVICES *gRT = NULL; diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Lock.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Lock.c new file mode 100644 index 0000000000..5667a34020 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Lock.c @@ -0,0 +1,159 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Lock.c + +Abstract: + + Support for locking lib services. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + Note on a check build ASSERT()s are used to ensure proper + lock usage. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - The task priority level of the lock + + +Returns: + + An initialized Efi Lock structure. + +--*/ +{ + Lock->Tpl = Priority; + Lock->OwnerTpl = 0; + Lock->Lock = 0; +} + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +{ + if (Lock->Lock != 0) { + // + // Lock is already owned, so bail out + // + return EFI_ACCESS_DENIED; + } + + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + + Lock->Lock += 1; + return EFI_SUCCESS; +} + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + Lock owned + +--*/ +{ + EFI_STATUS Status; + + Status = EfiAcquireLockOrFail (Lock); + + // + // Lock was already locked. + // + ASSERT_EFI_ERROR (Status); +} + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + +Arguments: + + Lock - The lock to release + +Returns: + + Lock unowned + +--*/ +{ + EFI_TPL Tpl; + + Tpl = Lock->OwnerTpl; + + ASSERT (Lock->Lock == 1); + Lock->Lock -= 1; + + gBS->RestoreTPL (Tpl); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c new file mode 100644 index 0000000000..55d1a1d14e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c @@ -0,0 +1,861 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Perf.c + +Abstract: + + Support for Performance primatives. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include EFI_PROTOCOL_DEFINITION (Performance) +#include EFI_PROTOCOL_DEFINITION (LoadedImage) +#include EFI_GUID_DEFINITION (Hob) +#include EFI_GUID_DEFINITION (PeiPerformanceHob) +#include "linkedlist.h" +#include "EfiHobLib.h" +#include "EfiImage.h" + +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ); + +EFI_STATUS +GetPeiPerformance ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN UINT64 Ticker + ); + +#define EFI_PERFORMANCE_DATA_SIGNATURE EFI_SIGNATURE_32 ('P', 'E', 'D', 'A') + +typedef struct { + UINT32 Signature; + EFI_LIST_ENTRY Link; + EFI_GAUGE_DATA GaugeData; +} EFI_PERF_DATA_LIST; + +#define GAUGE_DATA_FROM_LINK(_link) \ + CR(_link, EFI_PERF_DATA_LIST, Link, EFI_PERFORMANCE_DATA_SIGNATURE) + +#define GAUGE_DATA_FROM_GAUGE(_GaugeData) \ + CR(_GaugeData, EFI_PERF_DATA_LIST, GaugeData, EFI_PERFORMANCE_DATA_SIGNATURE) + +#define EFI_PERFORMANCE_SIGNATURE EFI_SIGNATURE_32 ('P', 'E', 'R', 'F') + +// +// Performance protocol instance data structure +// +typedef struct { + UINTN Signature; + EFI_HANDLE Handle; + EFI_PERFORMANCE_PROTOCOL Perf; + UINT8 Phase; +} EFI_PERFORMANCE_INSTANCE; + +// +// Performace protocol instance containing record macro +// + +#define EFI_PERFORMANCE_FROM_THIS(a) \ + CR(a, EFI_PERFORMANCE_INSTANCE, Perf, EFI_PERFORMANCE_SIGNATURE) + +EFI_LIST_ENTRY mPerfDataHead = INITIALIZE_LIST_HEAD_VARIABLE(mPerfDataHead); + +STATIC +VOID +GetShortPdbFileName ( + CHAR8 *PdbFileName, + CHAR8 *GaugeString + ) +/*++ + +Routine Description: + +Arguments: + +Returns: + +--*/ +{ + UINTN Index; + UINTN Index1; + UINTN StartIndex; + UINTN EndIndex; + + if (PdbFileName == NULL) { + EfiAsciiStrCpy (GaugeString, " "); + } else { + StartIndex = 0; + for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) + ; + + for (Index = 0; PdbFileName[Index] != 0; Index++) { + if (PdbFileName[Index] == '\\') { + StartIndex = Index + 1; + } + + if (PdbFileName[Index] == '.') { + EndIndex = Index; + } + } + + Index1 = 0; + for (Index = StartIndex; Index < EndIndex; Index++) { + GaugeString[Index1] = PdbFileName[Index]; + Index1++; + if (Index1 == EFI_PERF_PDBFILENAME_LENGTH - 1) { + break; + } + } + + GaugeString[Index1] = 0; + } + + return ; +} + +STATIC +CHAR8 * +GetPdbPath ( + VOID *ImageBase + ) +/*++ + +Routine Description: + + Located PDB path name in PE image + +Arguments: + + ImageBase - base of PE to search + +Returns: + + Pointer into image at offset of PDB file name if PDB file name is found, + Otherwise a pointer to an empty string. + +--*/ +{ + CHAR8 *PdbPath; + UINT32 DirCount; + EFI_IMAGE_DOS_HEADER *DosHdr; + EFI_IMAGE_NT_HEADERS *NtHdr; + UINT16 Magic; + EFI_IMAGE_OPTIONAL_HEADER32 *OptionalHdr32; + EFI_IMAGE_OPTIONAL_HEADER64 *OptionalHdr64; + EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; + VOID *CodeViewEntryPointer; + + CodeViewEntryPointer = NULL; + PdbPath = NULL; + DosHdr = ImageBase; + if (DosHdr && DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + NtHdr = (EFI_IMAGE_NT_HEADERS *) ((UINT8 *) DosHdr + DosHdr->e_lfanew); + // + // NOTE: We use Machine to identify PE32/PE32+, instead of Magic. + // It is for backward-compatibility consideration, because + // some system will generate PE32+ image with PE32 Magic. + // + if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; + } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else { + Magic = NtHdr->OptionalHeader.Magic; + } + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + OptionalHdr32 = (VOID *) &NtHdr->OptionalHeader; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } else { + OptionalHdr64 = (VOID *) &NtHdr->OptionalHeader; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } + + if (DirectoryEntry->VirtualAddress != 0) { + for (DirCount = 0; + (DirCount < DirectoryEntry->Size / sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) && CodeViewEntryPointer == NULL; + DirCount++ + ) { + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (DirectoryEntry->VirtualAddress + (UINTN) ImageBase + DirCount * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)); + if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageBase); + switch (*(UINT32 *) CodeViewEntryPointer) { + case CODEVIEW_SIGNATURE_NB10: + PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY); + break; + + case CODEVIEW_SIGNATURE_RSDS: + PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY); + break; + + default: + break; + } + } + } + } + } + + return PdbPath; +} + +STATIC +VOID +GetNameFromHandle ( + IN EFI_HANDLE Handle, + OUT CHAR8 *GaugeString + ) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *Image; + CHAR8 *PdbFileName; + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + + EfiAsciiStrCpy (GaugeString, " "); + + // + // Get handle name from image protocol + // + Status = gBS->HandleProtocol ( + Handle, + &gEfiLoadedImageProtocolGuid, + (VOID**)&Image + ); + + if (EFI_ERROR (Status)) { + Status = gBS->OpenProtocol ( + Handle, + &gEfiDriverBindingProtocolGuid, + (VOID **) &DriverBinding, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return ; + } + // + // Get handle name from image protocol + // + Status = gBS->HandleProtocol ( + DriverBinding->ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID**)&Image + ); + } + + PdbFileName = GetPdbPath (Image->ImageBase); + + if (PdbFileName != NULL) { + GetShortPdbFileName (PdbFileName, GaugeString); + } + + return ; +} + +EFI_PERF_DATA_LIST * +CreateDataNode ( + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host + ) +/*++ + +Routine Description: + + Create a EFI_PERF_DATA_LIST data node. + +Arguments: + + Handle - Handle of gauge data + Token - Token of gauge data + Host - Host of gauge data + +Returns: + + Pointer to a data node created. + +--*/ +{ + EFI_PERF_DATA_LIST *Node; + + // + // Al\ a new image structure + // + Node = EfiLibAllocateZeroPool (sizeof (EFI_PERF_DATA_LIST)); + if (Node != NULL) { + + Node->Signature = EFI_PERFORMANCE_DATA_SIGNATURE; + + Node->GaugeData.Handle = Handle; + + if (Token != NULL) { + EfiStrCpy ((Node->GaugeData).Token, Token); + } + + if (Host != NULL) { + EfiStrCpy ((Node->GaugeData).Host, Host); + } + + if (Handle != NULL) { + GetNameFromHandle (Handle, Node->GaugeData.PdbFileName); + } + } + + return Node; +} + + +EFI_PERF_DATA_LIST * +GetDataNode ( + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN EFI_GUID *GuidName, + IN EFI_GAUGE_DATA *PrevGauge + ) +/*++ + +Routine Description: + + Search gauge node list to find one node with matched handle, token, host and Guid name. + +Arguments: + + Handle - Handle to match + Token - Token to match + Host - Host to match + GuidName - Guid name to match + PrevGauge - Start node, start from list head if NULL + +Returns: + + Return pointer to the node found, NULL if not found. + +--*/ +{ + EFI_PERF_DATA_LIST *Node; + EFI_PERF_DATA_LIST *Temp; + EFI_PERF_DATA_LIST *Temp2; + EFI_LIST_ENTRY *CurrentLink; + EFI_GUID NullGuid = EFI_NULL_GUID; + + Node = NULL; + Temp = NULL; + Temp2 = NULL; + + if (PrevGauge == NULL) { + CurrentLink = mPerfDataHead.ForwardLink; + } else { + Temp2 = GAUGE_DATA_FROM_GAUGE (PrevGauge); + CurrentLink = (Temp2->Link).ForwardLink; + } + + while (CurrentLink && CurrentLink != &mPerfDataHead) { + Node = GAUGE_DATA_FROM_LINK (CurrentLink); + + if (Handle == 0 && Token == NULL && Host == NULL && GuidName == NULL) { + return Node; + } + + if (Handle != (Node->GaugeData).Handle) { + CurrentLink = CurrentLink->ForwardLink; + continue; + } + + if (GuidName == NULL && !EfiCompareGuid (&((Node->GaugeData).GuidName), &NullGuid)) { + CurrentLink = CurrentLink->ForwardLink; + continue; + } + + if (GuidName && !EfiCompareGuid (&((Node->GaugeData).GuidName), GuidName)) { + CurrentLink = CurrentLink->ForwardLink; + continue; + } + + if (Token == NULL && EfiStrCmp (Node->GaugeData.Token, L"")) { + CurrentLink = CurrentLink->ForwardLink; + continue; + } + + if (Token && EfiStrCmp (Node->GaugeData.Token, Token)) { + CurrentLink = CurrentLink->ForwardLink; + continue; + } + + if (Host == NULL && EfiStrCmp (Node->GaugeData.Host, L"")) { + CurrentLink = CurrentLink->ForwardLink; + continue; + } + + if (Host && EfiStrCmp (Node->GaugeData.Host, Host)) { + CurrentLink = CurrentLink->ForwardLink; + continue; + } + + Temp = Node; + break; + } + + return Temp; +} + + +EFI_STATUS +EFIAPI +StartGauge ( + IN EFI_PERFORMANCE_PROTOCOL *This, + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + Create a guage data node and initialized it. + +Arguments: + + This - Calling context + Handle - Handle of gauge data + Token - Token of gauge data + Host - Host of gauge data + Ticker - Set gauge data's StartTick. If 0, StartTick is current timer. + +Returns: + + EFI_SUCCESS - Successfully create and initialized a guage data node. + EFI_OUT_OF_RESOURCES - No enough resource to create a guage data node. + +--*/ +{ + EFI_PERFORMANCE_INSTANCE *PerfInstance; + EFI_PERF_DATA_LIST *Node; + UINT64 TimerValue; + + TimerValue = 0; + PerfInstance = EFI_PERFORMANCE_FROM_THIS (This); + + Node = CreateDataNode (Handle, Token, Host); + if (!Node) { + return EFI_OUT_OF_RESOURCES; + } + + if (Ticker != 0) { + TimerValue = Ticker; + } else { + GetTimerValue (&TimerValue); + } + + Node->GaugeData.StartTick = TimerValue; + + if (!EfiStrCmp (Token, DXE_TOK)) { + PerfInstance->Phase = DXE_PHASE; + } + + if (!EfiStrCmp (Token, SHELL_TOK)) { + PerfInstance->Phase = SHELL_PHASE; + } + + Node->GaugeData.Phase = PerfInstance->Phase; + + InsertTailList (&mPerfDataHead, &(Node->Link)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +EFIAPI +EndGauge ( + IN EFI_PERFORMANCE_PROTOCOL *This, + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + End all unfinished gauge data node that match specified handle, token and host. + +Arguments: + + This - Calling context + Handle - Handle to stop + Token - Token to stop + Host - Host to stop + Ticker - End tick, if 0 then get current timer + +Returns: + + EFI_NOT_FOUND - Node not found + EFI_SUCCESS - Gauge data node successfully ended. + +--*/ +{ + EFI_PERFORMANCE_INSTANCE *PerfInstance; + EFI_PERF_DATA_LIST *Node; + UINT64 TimerValue; + + TimerValue = 0; + PerfInstance = EFI_PERFORMANCE_FROM_THIS (This); + + Node = GetDataNode (Handle, Token, Host, NULL, NULL); + if (!Node) { + return EFI_NOT_FOUND; + } + + while (Node->GaugeData.EndTick != 0) { + Node = GetDataNode (Handle, Token, Host, NULL, &(Node->GaugeData)); + if (!Node) { + return EFI_NOT_FOUND; + } + } + + if (Ticker != 0) { + TimerValue = Ticker; + } else { + GetTimerValue (&TimerValue); + } + + Node->GaugeData.EndTick = TimerValue; + + return EFI_SUCCESS; +} + + +EFI_GAUGE_DATA * +EFIAPI +GetGauge ( + IN EFI_PERFORMANCE_PROTOCOL *This, + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN EFI_GAUGE_DATA *PrevGauge + ) +/*++ + +Routine Description: + Get gauge. + +Arguments: + This - A pointer to the EFI_PERFORMANCE_PROTOCOL. + Handle - A pointer of a efi handle. + Token - A pointer to the token. + Host - A pointer to the host. + PrevGauge - A pointer to the EFI_GAUGE_DATA structure. + + +Returns: + Status code. + +--*/ +{ + EFI_PERFORMANCE_INSTANCE *PerfInstance; + EFI_PERF_DATA_LIST *Node; + + PerfInstance = EFI_PERFORMANCE_FROM_THIS (This); + + Node = GetDataNode (Handle, Token, Host, NULL, PrevGauge); + if (Node != NULL) { + return &(Node->GaugeData); + } else { + return NULL; + } +} + +// +// Driver entry point +// +EFI_STATUS +InitializePerformanceInfrastructure ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + Install gEfiPerformanceProtocolGuid protocol and transfer PEI performance to gauge data nodes. + +Arguments: + + ImageHandle - Standard driver entry point parameter + SystemTable - Standard driver entry point parameter + Ticker - End tick for PEI performance + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + EFI_SUCCESS - Protocol installed. + +--*/ +{ + EFI_STATUS Status; + EFI_PERFORMANCE_INSTANCE *PerfInstance; + + // + // Allocate a new image structure + // + PerfInstance = EfiLibAllocateZeroPool (sizeof (EFI_PERFORMANCE_INSTANCE)); + if (PerfInstance == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + PerfInstance->Signature = EFI_PERFORMANCE_SIGNATURE; + PerfInstance->Perf.StartGauge = StartGauge; + PerfInstance->Perf.EndGauge = EndGauge; + PerfInstance->Perf.GetGauge = GetGauge; + + // + // Install the protocol interfaces + // + Status = gBS->InstallProtocolInterface ( + &PerfInstance->Handle, + &gEfiPerformanceProtocolGuid, + EFI_NATIVE_INTERFACE, + &PerfInstance->Perf + ); + + if (!EFI_ERROR (Status)) { + GetPeiPerformance (ImageHandle, SystemTable, Ticker); + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +StartMeasure ( + EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + Start to gauge on a specified handle, token and host, with Ticker as start tick. + +Arguments: + + Handle - Handle to measure + Token - Token to measure + Host - Host to measure + Ticker - Ticker as start tick + +Returns: + + Status code. + +--*/ +{ + EFI_STATUS Status; + EFI_PERFORMANCE_PROTOCOL *Perf; + + Status = gBS->LocateProtocol (&gEfiPerformanceProtocolGuid, NULL, (VOID **) &Perf); + if (EFI_ERROR (Status)) { + return Status; + } + + return Perf->StartGauge (Perf, Handle, Token, Host, Ticker); + +} + + +EFI_STATUS +EndMeasure ( + EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + End gauging on a specified handle, token and host, with Ticker as end tick. + +Arguments: + + Handle - Handle to stop + Token - Token to stop + Host - Host to stop + Ticker - Ticker as end tick + +Returns: + + Status code. + +--*/ +{ + EFI_STATUS Status; + EFI_PERFORMANCE_PROTOCOL *Perf; + + Status = gBS->LocateProtocol (&gEfiPerformanceProtocolGuid, NULL, (VOID **) &Perf); + if (Status != EFI_SUCCESS) { + return Status; + } + + return (Perf->EndGauge( Perf, Handle, Token, Host, Ticker)) ; +} + + +EFI_STATUS +UpdateMeasure ( + EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + EFI_HANDLE HandleNew, + IN UINT16 *TokenNew, + IN UINT16 *HostNew + ) +/*++ + +Routine Description: + Update measure. + +Arguments: + Handle - A pointer of an efi handle. + Token - A pointer to the token. + Host - A pointer to the host. + HandleNew - A pointer of an new efi handle. + TokenNew - A pointer to the new token. + HostNew - A pointer to the new host. + +Returns: + Status code. + + EFI_NOT_FOUND - The speicified gauge data node not found. + + EFI_SUCCESS - Update successfully. + +--*/ +{ + EFI_STATUS Status; + EFI_GAUGE_DATA *GaugeData; + EFI_PERFORMANCE_PROTOCOL *Perf; + + Status = gBS->LocateProtocol (&gEfiPerformanceProtocolGuid, NULL, (VOID **) &Perf); + if (EFI_ERROR (Status)) { + return Status; + } + + GaugeData = Perf->GetGauge (Perf, Handle, Token, Host, NULL); + if (!GaugeData) { + return EFI_NOT_FOUND; + } + + GaugeData->Handle = HandleNew; + if (HostNew != NULL) { + EfiStrCpy (GaugeData->Host, HostNew); + } else { + EfiStrCpy (GaugeData->Host, L""); + } + + if (TokenNew != NULL) { + EfiStrCpy (GaugeData->Token, TokenNew); + } else { + EfiStrCpy (GaugeData->Token, L""); + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +GetPeiPerformance ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN UINT64 Ticker + ) +/*++ + +Routine Description: + + Transfer PEI performance data to gauge data node. + +Arguments: + + ImageHandle - Standard entry point parameter + SystemTable - Standard entry point parameter + Ticker - Start tick + +Returns: + + EFI_OUT_OF_RESOURCES - No enough resource to create data node. + EFI_SUCCESS - Transfer done successfully. + +--*/ +{ + EFI_STATUS Status; + VOID *HobList; + EFI_HOB_GUID_DATA_PERFORMANCE_LOG *LogHob; + PEI_PERFORMANCE_MEASURE_LOG_ENTRY *LogEntry; + UINT32 Index; + EFI_PERF_DATA_LIST *Node; + UINT64 TimerValue; + + Node = CreateDataNode (0, PEI_TOK, NULL); + if (!Node) { + return EFI_OUT_OF_RESOURCES; + } + + if (Ticker != 0) { + TimerValue = Ticker; + } else { + GetTimerValue (&TimerValue); + } + (Node->GaugeData).EndTick = TimerValue; + + InsertTailList (&mPerfDataHead, &(Node->Link)); + + EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList); + do { + Status = GetNextGuidHob (&HobList, &gEfiPeiPerformanceHobGuid, (VOID **) &LogHob, NULL); + if (EFI_ERROR (Status)) { + break; + } + + for (Index = 0; Index < LogHob->NumberOfEntries; Index++) { + LogEntry = &(LogHob->Log[Index]); + Node = CreateDataNode (0, LogEntry->DescriptionString, NULL); + if (!Node) { + return EFI_OUT_OF_RESOURCES; + } + (Node->GaugeData).StartTick = LogEntry->StartTimeCount; + + EfiCopyMem (&(Node->GaugeData.GuidName), &LogEntry->Name, sizeof (EFI_GUID)); + + InsertTailList (&mPerfDataHead, &(Node->Link)); + + (Node->GaugeData).EndTick = LogEntry->StopTimeCount; + } + } while (!EFI_ERROR (Status)); + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c new file mode 100644 index 0000000000..72efa4c45d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c @@ -0,0 +1,141 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ReportStatusCode.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include EFI_PROTOCOL_DEFINITION (DevicePath) +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) +#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +STATIC EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL; +#endif + +EFI_STATUS +EfiLibReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +/*++ + +Routine Description: + + Report device path through status code. + +Arguments: + + Type - Code type + Value - Code value + Instance - Instance number + CallerId - Caller name + DevicePath - Device path that to be reported + +Returns: + + Status code. + + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + +--*/ +{ + EFI_STATUS Status; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + if (gStatusCode == NULL) { + if (gBS == NULL) { + return EFI_UNSUPPORTED; + } + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status) || gStatusCode == NULL) { + return EFI_UNSUPPORTED; + } + } + Status = gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data); + return Status; +#else + if (gRT == NULL) { + return EFI_UNSUPPORTED; + } + // + // Check whether EFI_RUNTIME_SERVICES has Tiano Extension + // + Status = EFI_UNSUPPORTED; + if (gRT->Hdr.Revision == EFI_SPECIFICATION_VERSION && + gRT->Hdr.HeaderSize == sizeof (EFI_RUNTIME_SERVICES) && + gRT->ReportStatusCode != NULL) { + Status = gRT->ReportStatusCode (Type, Value, Instance, CallerId, Data); + } + return Status; +#endif +} + +EFI_STATUS +ReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId OPTIONAL, + IN EFI_DEVICE_PATH_PROTOCOL * DevicePath + ) +/*++ + +Routine Description: + + Report device path through status code. + +Arguments: + + Type - Code type + Value - Code value + Instance - Instance number + CallerId - Caller name + DevicePath - Device path that to be reported + +Returns: + + Status code. + + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + +--*/ +{ + UINT16 Size; + UINT16 DevicePathSize; + EFI_STATUS_CODE_DATA *ExtendedData; + EFI_DEVICE_PATH_PROTOCOL *ExtendedDevicePath; + EFI_STATUS Status; + + DevicePathSize = (UINT16) EfiDevicePathSize (DevicePath); + Size = DevicePathSize + sizeof (EFI_STATUS_CODE_DATA); + ExtendedData = (EFI_STATUS_CODE_DATA *) EfiLibAllocatePool (Size); + if (ExtendedData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ExtendedDevicePath = EfiConstructStatusCodeData (Size, &gEfiStatusCodeSpecificDataGuid, ExtendedData); + EfiCopyMem (ExtendedDevicePath, DevicePath, DevicePathSize); + + Status = EfiLibReportStatusCode (Type, Value, Instance, CallerId, (EFI_STATUS_CODE_DATA *) ExtendedData); + + gBS->FreePool (ExtendedData); + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ia32/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ia32/PerformancePrimitives.c new file mode 100644 index 0000000000..02d5ff8d81 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ia32/PerformancePrimitives.c @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PerformancePrimitives.c + +Abstract: + + Support for Performance library + +--*/ + +#include "TianoCommon.h" +#include "CpuIA32.h" + +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ) +/*++ + +Routine Description: + + Set TimerValue with current tick. + +Arguments: + + TimerValue - Timer value to be set + +Returns: + + EFI_SUCCESS - TimerValue is set. + +--*/ +{ + *TimerValue = EfiReadTsc (); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c new file mode 100644 index 0000000000..929ddf1807 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PerformancePrimitives.c + +Abstract: + + Support for Performance library + +--*/ + +#include "TianoCommon.h" +#include "CpuIA32.h" + +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ) +/*++ + +Routine Description: + + Set TimerValue with current tick. + +Arguments: + + TimerValue - Timer value to be set + +Returns: + + EFI_SUCCESS - TimerValue is set. + +--*/ +{ + *TimerValue = EfiReadTsc (); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf new file mode 100644 index 0000000000..a4cc0aea81 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf @@ -0,0 +1,51 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiIfrSupportLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = EfiIfrSupportLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + IfrCommon.c + IfrOnTheFly.c + IfrOpCodeCreation.c + IfrLibrary.h + IfrVariable.c + +[includes.common] + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation + . + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiDriverLib + +[libraries.common] + EfiGuidLib + EdkFrameworkProtocolLib + + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c new file mode 100644 index 0000000000..030ab14c5a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c @@ -0,0 +1,1031 @@ +/*++ +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + IfrCommon.c + +Abstract: + + Common Library Routines to assist in IFR creation on-the-fly + +--*/ + +#include "IfrLibrary.h" + +EFI_STATUS +GetCurrentLanguage ( + OUT CHAR16 *Lang + ) +/*++ + +Routine Description: + + Determine what is the current language setting + +Arguments: + + Lang - Pointer of system language + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + UINTN Size; + UINTN Index; + CHAR8 Language[4]; + + // + // Getting the system language and placing it into our Global Data + // + Size = sizeof (Language); + + Status = gRT->GetVariable ( + L"Lang", + &gEfiGlobalVariableGuid, + NULL, + &Size, + Language + ); + + if (EFI_ERROR (Status)) { + EfiAsciiStrCpy (Language, "eng"); + } + + for (Index = 0; Index < 3; Index++) { + // + // Bitwise AND ascii value with 0xDF yields an uppercase value. + // Sign extend into a unicode value + // + Lang[Index] = (CHAR16) (Language[Index] & 0xDF); + } + + // + // Null-terminate the value + // + Lang[3] = (CHAR16) 0; + + return Status; +} + + +EFI_STATUS +AddString ( + IN VOID *StringBuffer, + IN CHAR16 *Language, + IN CHAR16 *String, + IN OUT STRING_REF *StringToken + ) +/*++ + +Routine Description: + + Add a string to the incoming buffer and return the token and offset data + +Arguments: + + StringBuffer - The incoming buffer + + Language - Currrent language + + String - The string to be added + + StringToken - The index where the string placed + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - String successfully added to the incoming buffer + +--*/ +{ + EFI_HII_STRING_PACK *StringPack; + EFI_HII_STRING_PACK *StringPackBuffer; + VOID *NewBuffer; + RELOFST *PackSource; + RELOFST *PackDestination; + UINT8 *Source; + UINT8 *Destination; + UINTN Index; + BOOLEAN Finished; + + StringPack = (EFI_HII_STRING_PACK *) StringBuffer; + Finished = FALSE; + + // + // Pre-allocate a buffer sufficient for us to work on. + // We will use it as a destination scratch pad to build data on + // and when complete shift the data back to the original buffer + // + NewBuffer = EfiLibAllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE); + if (NewBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + StringPackBuffer = (EFI_HII_STRING_PACK *) NewBuffer; + + // + // StringPack is terminated with a length 0 entry + // + for (; StringPack->Header.Length != 0;) { + // + // If this stringpack's language is same as CurrentLanguage, use it + // + if (EfiCompareMem ((VOID *) ((CHAR8 *) (StringPack) + StringPack->LanguageNameString), Language, 3) == 0) { + // + // We have some data in this string pack, copy the string package up to the string data + // + EfiCopyMem (&StringPackBuffer->Header, &StringPack->Header, sizeof (StringPack)); + + // + // These are references in the structure to tokens, need to increase them by the space occupied by an additional StringPointer + // + StringPackBuffer->LanguageNameString = (UINT16) (StringPackBuffer->LanguageNameString + (UINT16) sizeof (RELOFST)); + StringPackBuffer->PrintableLanguageName = (UINT16) (StringPackBuffer->PrintableLanguageName + (UINT16) sizeof (RELOFST)); + + PackSource = (RELOFST *) (StringPack + 1); + PackDestination = (RELOFST *) (StringPackBuffer + 1); + for (Index = 0; PackSource[Index] != 0x0000; Index++) { + // + // Copy the stringpointers from old to new buffer + // remember that we are adding a string, so the string offsets will all go up by sizeof (RELOFST) + // + PackDestination[Index] = (UINT16) (PackDestination[Index] + sizeof (RELOFST)); + } + + // + // Add a new stringpointer in the new buffer since we are adding a string. Null terminate it + // + PackDestination[Index] = (UINT16)(PackDestination[Index-1] + + EfiStrSize((CHAR16 *)((CHAR8 *)(StringPack) + PackSource[Index-1]))); + PackDestination[Index + 1] = (UINT16) 0; + + // + // Index is the token value for the new string + // + *StringToken = (UINT16) Index; + + // + // Source now points to the beginning of the old buffer strings + // Destination now points to the beginning of the new buffer strings + // + Source = (UINT8 *) &PackSource[Index + 1]; + Destination = (UINT8 *) &PackDestination[Index + 2]; + + // + // This should copy all the strings from the old buffer to the new buffer + // + for (; Index != 0; Index--) { + // + // Copy Source string to destination buffer + // + EfiStrCpy ((CHAR16 *) Destination, (CHAR16 *) Source); + + // + // Adjust the source/destination to the next string location + // + Destination = Destination + EfiStrSize ((CHAR16 *) Source); + Source = Source + EfiStrSize ((CHAR16 *) Source); + } + + // + // This copies the new string to the destination buffer + // + EfiStrCpy ((CHAR16 *) Destination, (CHAR16 *) String); + + // + // Adjust the size of the changed string pack by adding the size of the new string + // along with the size of the additional offset entry for the new string + // + StringPackBuffer->Header.Length = (UINT32) ((UINTN) StringPackBuffer->Header.Length + EfiStrSize (String) + sizeof (RELOFST)); + + // + // Advance the buffers to point to the next spots. + // + StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPackBuffer->Header.Length); + StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length); + Finished = TRUE; + continue; + } + // + // This isn't the language of the stringpack we were asked to add a string to + // so we need to copy it to the new buffer. + // + EfiCopyMem (&StringPackBuffer->Header, &StringPack->Header, StringPack->Header.Length); + + // + // Advance the buffers to point to the next spots. + // + StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPack->Header.Length); + StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length); + } + + // + // If we didn't copy the new data to a stringpack yet + // + if (!Finished) { + PackDestination = (RELOFST *) (StringPackBuffer + 1); + // + // Pointing to a new string pack location + // + StringPackBuffer->Header.Length = (UINT32) + ( + sizeof (EFI_HII_STRING_PACK) - + sizeof (EFI_STRING) + + sizeof (RELOFST) + + sizeof (RELOFST) + + EfiStrSize (Language) + + EfiStrSize (String) + ); + StringPackBuffer->Header.Type = EFI_HII_STRING; + StringPackBuffer->LanguageNameString = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); + StringPackBuffer->PrintableLanguageName = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); + StringPackBuffer->Attributes = 0; + PackDestination[0] = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer); + PackDestination[1] = (UINT16) (PackDestination[0] + EfiStrSize (Language)); + PackDestination[2] = (UINT16) 0; + + // + // The first string location will be set to destination. The minimum number of strings + // associated with a stringpack will always be token 0 stored as the languagename (e.g. ENG, SPA, etc) + // and token 1 as the new string being added and and null entry for the stringpointers + // + Destination = (CHAR8 *) &PackDestination[3]; + + // + // Copy the language name string to the new buffer + // + EfiStrCpy ((CHAR16 *) Destination, Language); + + // + // Advance the destination to the new empty spot + // + Destination = Destination + EfiStrSize (Language); + + // + // Copy the string to the new buffer + // + EfiStrCpy ((CHAR16 *) Destination, String); + + // + // Since we are starting with a new string pack - we know the new string is token 1 + // + *StringToken = (UINT16) 1; + } + + // + // Zero out the original buffer and copy the updated data in the new buffer to the old buffer + // + EfiZeroMem (StringBuffer, DEFAULT_STRING_BUFFER_SIZE); + EfiCopyMem (StringBuffer, NewBuffer, DEFAULT_STRING_BUFFER_SIZE); + + // + // Free the newly created buffer since we don't need it anymore + // + gBS->FreePool (NewBuffer); + return EFI_SUCCESS; +} + + +EFI_STATUS +AddOpCode ( + IN VOID *FormBuffer, + IN OUT VOID *OpCodeData + ) +/*++ + +Routine Description: + + Add op-code data to the FormBuffer + +Arguments: + + FormBuffer - Form buffer to be inserted to + + OpCodeData - Op-code data to be inserted + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Op-code data successfully inserted + +--*/ +{ + EFI_HII_PACK_HEADER *NewBuffer; + UINT8 *Source; + UINT8 *Destination; + + // + // Pre-allocate a buffer sufficient for us to work on. + // We will use it as a destination scratch pad to build data on + // and when complete shift the data back to the original buffer + // + NewBuffer = EfiLibAllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE); + if (NewBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Source = (UINT8 *) FormBuffer; + Destination = (UINT8 *) NewBuffer; + + // + // Copy the IFR Package header to the new buffer + // + EfiCopyMem (Destination, Source, sizeof (EFI_HII_PACK_HEADER)); + + // + // Advance Source and Destination to next op-code + // + Source = Source + sizeof (EFI_HII_PACK_HEADER); + Destination = Destination + sizeof (EFI_HII_PACK_HEADER); + + // + // Copy data to the new buffer until we run into the end_form + // + for (; ((EFI_IFR_OP_HEADER *) Source)->OpCode != EFI_IFR_END_FORM_OP;) { + // + // If the this opcode is an end_form_set we better be creating and endform + // Nonetheless, we will add data before the end_form_set. This also provides + // for interesting behavior in the code we will run, but has no bad side-effects + // since we will possibly do a 0 byte copy in this particular end-case. + // + if (((EFI_IFR_OP_HEADER *) Source)->OpCode == EFI_IFR_END_FORM_SET_OP) { + break; + } + + // + // Copy data to new buffer + // + EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); + + // + // Adjust Source/Destination to next op-code location + // + Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + } + + // + // Prior to the end_form is where we insert the new op-code data + // + EfiCopyMem (Destination, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length); + Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) OpCodeData)->Length; + + NewBuffer->Length = (UINT32) (NewBuffer->Length + (UINT32) (((EFI_IFR_OP_HEADER *) OpCodeData)->Length)); + + // + // Copy end-form data to new buffer + // + EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); + + // + // Adjust Source/Destination to next op-code location + // + Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length; + + // + // Copy end-formset data to new buffer + // + EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length); + + // + // Zero out the original buffer and copy the updated data in the new buffer to the old buffer + // + EfiZeroMem (FormBuffer, DEFAULT_FORM_BUFFER_SIZE); + EfiCopyMem (FormBuffer, NewBuffer, DEFAULT_FORM_BUFFER_SIZE); + + // + // Free the newly created buffer since we don't need it anymore + // + gBS->FreePool (NewBuffer); + return EFI_SUCCESS; +} + + +EFI_STATUS +GetHiiInterface ( + OUT EFI_HII_PROTOCOL **Hii + ) +/*++ + +Routine Description: + + Get the HII protocol interface + +Arguments: + + Hii - HII protocol interface + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + + // + // There should only be one HII protocol + // + Status = gBS->LocateProtocol ( + &gEfiHiiProtocolGuid, + NULL, + (VOID **) Hii + ); + + return Status;; +} + + +EFI_STATUS +ExtractDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + IN OUT UINT16 *ImageLength, + OUT UINT8 *DefaultImage, + OUT EFI_GUID *Guid + ) +/*++ + +Routine Description: + + Extract information pertaining to the HiiHandle + +Arguments: + + HiiHandle - Hii handle + + ImageLength - For input, length of DefaultImage; + For output, length of actually required + + DefaultImage - Image buffer prepared by caller + + Guid - Guid information about the form + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength + + EFI_SUCCESS - Successfully extract data from Hii database. + + +--*/ +{ + EFI_STATUS Status; + EFI_HII_PROTOCOL *Hii; + UINTN DataLength; + UINT8 *RawData; + UINT8 *OldData; + UINTN Index; + UINTN Temp; + UINTN SizeOfNvStore; + UINTN CachedStart; + + DataLength = DEFAULT_FORM_BUFFER_SIZE; + SizeOfNvStore = 0; + CachedStart = 0; + + Status = GetHiiInterface (&Hii); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Allocate space for retrieval of IFR data + // + RawData = EfiLibAllocateZeroPool ((UINTN) DataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData); + + if (EFI_ERROR (Status)) { + gBS->FreePool (RawData); + + // + // Allocate space for retrieval of IFR data + // + RawData = EfiLibAllocateZeroPool ((UINTN) DataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData); + } + + OldData = RawData; + + // + // Point RawData to the beginning of the form data + // + RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER)); + + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_FORM_SET_OP: + // + // Copy the GUID information from this handle + // + EfiCopyMem (Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID)); + break; + + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_CHECKBOX_OP: + case EFI_IFR_NUMERIC_OP: + case EFI_IFR_DATE_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_PASSWORD_OP: + case EFI_IFR_STRING_OP: + // + // Remember, multiple op-codes may reference the same item, so let's keep a running + // marker of what the highest QuestionId that wasn't zero length. This will accurately + // maintain the Size of the NvStore + // + if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) { + Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + if (SizeOfNvStore < Temp) { + SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + } + } + } + + Index = RawData[Index + 1] + Index; + } + + // + // Return an error if buffer is too small + // + if (SizeOfNvStore > *ImageLength) { + gBS->FreePool (OldData); + *ImageLength = (UINT16) SizeOfNvStore; + return EFI_BUFFER_TOO_SMALL; + } + + EfiZeroMem (DefaultImage, SizeOfNvStore); + + // + // Copy the default image information to the user's buffer + // + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_ONE_OF_OP: + CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId; + break; + + case EFI_IFR_ONE_OF_OPTION_OP: + if (((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Flags & EFI_IFR_FLAG_DEFAULT) { + EfiCopyMem (&DefaultImage[CachedStart], &((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value, 2); + } + break; + + case EFI_IFR_CHECKBOX_OP: + DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId] = ((EFI_IFR_CHECK_BOX *) &RawData[Index])->Flags; + break; + + case EFI_IFR_NUMERIC_OP: + EfiCopyMem ( + &DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId], + &((EFI_IFR_NUMERIC *) &RawData[Index])->Default, + 2 + ); + break; + + } + + Index = RawData[Index + 1] + Index; + } + + *ImageLength = (UINT16) SizeOfNvStore; + + // + // Free our temporary repository of form data + // + gBS->FreePool (OldData); + + return EFI_SUCCESS; +} + + +EFI_HII_HANDLE +FindHiiHandle ( + IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL + IN EFI_GUID *Guid + ) +/*++ + +Routine Description: + Finds HII handle for given pack GUID previously registered with the HII. + +Arguments: + HiiProtocol - pointer to pointer to HII protocol interface. + If NULL, the interface will be found but not returned. + If it points to NULL, the interface will be found and + written back to the pointer that is pointed to. + Guid - The GUID of the pack that registered with the HII. + +Returns: + Handle to the HII pack previously registered by the memory driver. + +--*/ +{ + EFI_STATUS Status; + + EFI_HII_HANDLE *HiiHandleBuffer; + EFI_HII_HANDLE HiiHandle; + UINT16 HiiHandleBufferLength; + UINT32 NumberOfHiiHandles; + EFI_GUID HiiGuid; + EFI_HII_PROTOCOL *HiiProt; + UINT32 Index; + UINT16 Length; + + HiiHandle = 0; + if ((HiiProtocol != NULL) && (*HiiProtocol != NULL)) { + // + // The protocol has been passed in + // + HiiProt = *HiiProtocol; + } else { + gBS->LocateProtocol ( + &gEfiHiiProtocolGuid, + NULL, + (VOID **) &HiiProt + ); + if (HiiProt == NULL) { + return HiiHandle; + } + + if (HiiProtocol != NULL) { + // + // Return back the HII protocol for the caller as promissed + // + *HiiProtocol = HiiProt; + } + } + // + // Allocate buffer + // + HiiHandleBufferLength = 10; + HiiHandleBuffer = EfiLibAllocatePool (HiiHandleBufferLength); + ASSERT (HiiHandleBuffer != NULL); + + // + // Get the Handles of the packages that were registered with Hii + // + Status = HiiProt->FindHandles ( + HiiProt, + &HiiHandleBufferLength, + HiiHandleBuffer + ); + + // + // Get a bigger bugffer if this one is to small, and try again + // + if (Status == EFI_BUFFER_TOO_SMALL) { + + gBS->FreePool (HiiHandleBuffer); + + HiiHandleBuffer = EfiLibAllocatePool (HiiHandleBufferLength); + ASSERT (HiiHandleBuffer != NULL); + + Status = HiiProt->FindHandles ( + HiiProt, + &HiiHandleBufferLength, + HiiHandleBuffer + ); + } + + if (EFI_ERROR (Status)) { + goto lbl_exit; + } + + NumberOfHiiHandles = HiiHandleBufferLength / sizeof (EFI_HII_HANDLE); + + // + // Iterate Hii handles and look for the one that matches our Guid + // + for (Index = 0; Index < NumberOfHiiHandles; Index++) { + + Length = 0; + ExtractDataFromHiiHandle (HiiHandleBuffer[Index], &Length, NULL, &HiiGuid); + + if (EfiCompareGuid (&HiiGuid, Guid)) { + + HiiHandle = HiiHandleBuffer[Index]; + break; + } + } + +lbl_exit: + gBS->FreePool (HiiHandleBuffer); + return HiiHandle; +} + + +EFI_STATUS +ValidateDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + OUT BOOLEAN *Results + ) +/*++ + +Routine Description: + + Validate that the data associated with the HiiHandle in NVRAM is within + the reasonable parameters for that FormSet. Values for strings and passwords + are not verified due to their not having the equivalent of valid range settings. + +Arguments: + + HiiHandle - Handle of the HII database entry to query + + Results - If return Status is EFI_SUCCESS, Results provides valid data + TRUE = NVRAM Data is within parameters + FALSE = NVRAM Data is NOT within parameters + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Data successfully validated +--*/ +{ + EFI_STATUS Status; + EFI_HII_PROTOCOL *Hii; + EFI_GUID Guid; + UINT8 *RawData; + UINT8 *OldData; + UINTN RawDataLength; + UINT8 *VariableData; + UINTN Index; + UINTN Temp; + UINTN SizeOfNvStore; + UINTN CachedStart; + BOOLEAN GotMatch; + + RawDataLength = DEFAULT_FORM_BUFFER_SIZE; + SizeOfNvStore = 0; + CachedStart = 0; + GotMatch = FALSE; + *Results = TRUE; + + Status = GetHiiInterface (&Hii); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Allocate space for retrieval of IFR data + // + RawData = EfiLibAllocateZeroPool (RawDataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData); + + if (EFI_ERROR (Status)) { + gBS->FreePool (RawData); + + // + // Allocate space for retrieval of IFR data + // + RawData = EfiLibAllocateZeroPool (RawDataLength); + if (RawData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get all the forms associated with this HiiHandle + // + Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData); + } + + OldData = RawData; + + // + // Point RawData to the beginning of the form data + // + RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER)); + + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + if (RawData[Index] == EFI_IFR_FORM_SET_OP) { + EfiCopyMem (&Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID)); + break; + } + + Index = RawData[Index + 1] + Index; + } + + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_FORM_SET_OP: + break; + + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_CHECKBOX_OP: + case EFI_IFR_NUMERIC_OP: + case EFI_IFR_DATE_OP: + case EFI_IFR_TIME_OP: + case EFI_IFR_PASSWORD_OP: + case EFI_IFR_STRING_OP: + // + // Remember, multiple op-codes may reference the same item, so let's keep a running + // marker of what the highest QuestionId that wasn't zero length. This will accurately + // maintain the Size of the NvStore + // + if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) { + Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + if (SizeOfNvStore < Temp) { + SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width; + } + } + } + + Index = RawData[Index + 1] + Index; + } + + // + // Allocate memory for our File Form Tags + // + VariableData = EfiLibAllocateZeroPool (SizeOfNvStore); + if (VariableData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = gRT->GetVariable ( + L"Setup", + &Guid, + NULL, + &SizeOfNvStore, + (VOID *) VariableData + ); + + if (EFI_ERROR (Status)) { + + // + // If there is a variable that exists already and it is larger than what we calculated the + // storage needs to be, we must assume the variable size from GetVariable is correct and not + // allow the truncation of the variable. It is very possible that the user who created the IFR + // we are cracking is not referring to a variable that was in a previous map, however we cannot + // allow it's truncation. + // + if (Status == EFI_BUFFER_TOO_SMALL) { + // + // Free the buffer that was allocated that was too small + // + gBS->FreePool (VariableData); + + VariableData = EfiLibAllocatePool (SizeOfNvStore); + if (VariableData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status = gRT->GetVariable ( + L"Setup", + &Guid, + NULL, + &SizeOfNvStore, + (VOID *) VariableData + ); + } + } + + // + // Walk through the form and see that the variable data it refers to is ok. + // This allows for the possibility of stale (obsoleted) data in the variable + // can be overlooked without causing an error + // + for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) { + switch (RawData[Index]) { + case EFI_IFR_ONE_OF_OP: + // + // A one_of has no data, its the option that does - cache the storage Id + // + CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId; + break; + + case EFI_IFR_ONE_OF_OPTION_OP: + // + // A one_of_option can be any value + // + if (VariableData[CachedStart] == ((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value) { + GotMatch = TRUE; + } + break; + + case EFI_IFR_END_ONE_OF_OP: + // + // At this point lets make sure that the data value in the NVRAM matches one of the options + // + if (!GotMatch) { + *Results = FALSE; + return EFI_SUCCESS; + } + break; + + case EFI_IFR_CHECKBOX_OP: + // + // A checkbox is a boolean, so 0 and 1 are valid + // Remember, QuestionId corresponds to the offset location of the data in the variable + // + if (VariableData[((EFI_IFR_CHECK_BOX *) &RawData[Index])->QuestionId] > 1) { + *Results = FALSE; + return EFI_SUCCESS; + } + break; + + case EFI_IFR_NUMERIC_OP: + if ((VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] < ((EFI_IFR_NUMERIC *)&RawData[Index])->Minimum) || + (VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] > ((EFI_IFR_NUMERIC *)&RawData[Index])->Maximum)) { + *Results = FALSE; + return EFI_SUCCESS; + } + break; + + } + + Index = RawData[Index + 1] + Index; + } + + // + // Free our temporary repository of form data + // + gBS->FreePool (OldData); + gBS->FreePool (VariableData); + + return EFI_SUCCESS; +} + +EFI_HII_PACKAGES * +PreparePackages ( + IN UINTN NumberOfPackages, + IN EFI_GUID *GuidId, + ... + ) +/*++ + +Routine Description: + + Assemble EFI_HII_PACKAGES according to the passed in packages. + +Arguments: + + NumberOfPackages - Number of packages. + GuidId - Package GUID. + +Returns: + + Pointer of EFI_HII_PACKAGES. + +--*/ +{ + VA_LIST args; + EFI_HII_PACKAGES *HiiPackages; + VOID **Package; + UINTN Index; + + ASSERT (NumberOfPackages > 0); + + HiiPackages = EfiLibAllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *)); + + HiiPackages->GuidId = GuidId; + HiiPackages->NumberOfPackages = NumberOfPackages; + Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES)); + + VA_START (args, GuidId); + + for (Index = 0; Index < NumberOfPackages; Index++) { + *Package = VA_ARG (args, VOID *); + Package++; + } + + VA_END (args); + + return HiiPackages; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h new file mode 100644 index 0000000000..a99bfc0e24 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h @@ -0,0 +1,1299 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IfrLibrary.h + +Abstract: + The file contain all library function for Ifr Operations. + +--*/ + +#ifndef _IFRLIBRARY_H +#define _IFRLIBRARY_H + +#include "Tiano.h" +#include "EfiDriverLib.h" + +#include EFI_PROTOCOL_DEFINITION (Hii) +#include EFI_GUID_DEFINITION (GlobalVariable) + +#define DEFAULT_FORM_BUFFER_SIZE 0xFFFF +#define DEFAULT_STRING_BUFFER_SIZE 0xFFFF + +#pragma pack(1) +typedef struct { + CHAR16 *OptionString; // Passed in string to generate a token for in a truly dynamic form creation + STRING_REF StringToken; // This is used when creating a single op-code without generating a StringToken (have one already) + UINT16 Value; + UINT8 Flags; + UINT16 Key; +} IFR_OPTION; +#pragma pack() + +EFI_STATUS +GetCurrentLanguage ( + OUT CHAR16 *Lang + ) +/*++ + +Routine Description: + + Determine what is the current language setting + +Arguments: + + Lang - Pointer of system language + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +AddString ( + IN VOID *StringBuffer, + IN CHAR16 *Language, + IN CHAR16 *String, + IN OUT STRING_REF *StringToken + ) +/*++ + +Routine Description: + + Add a string to the incoming buffer and return the token and offset data + +Arguments: + + StringBuffer - The incoming buffer + + Language - Currrent language + + String - The string to be added + + StringToken - The index where the string placed + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - String successfully added to the incoming buffer + +--*/ +; + +EFI_STATUS +AddOpCode ( + IN VOID *FormBuffer, + IN OUT VOID *OpCodeData + ) +/*++ + +Routine Description: + + Add op-code data to the FormBuffer + +Arguments: + + FormBuffer - Form buffer to be inserted to + + OpCodeData - Op-code data to be inserted + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Op-code data successfully inserted + +--*/ +; + +EFI_STATUS +CreateFormSet ( + IN CHAR16 *FormSetTitle, + IN EFI_GUID *Guid, + IN UINT8 Class, + IN UINT8 SubClass, + IN OUT VOID **FormBuffer, + IN OUT VOID **StringBuffer + ) +/*++ + +Routine Description: + + Create a formset + +Arguments: + + FormSetTitle - Title of formset + + Guid - Guid of formset + + Class - Class of formset + + SubClass - Sub class of formset + + FormBuffer - Pointer of the formset created + + StringBuffer - Pointer of FormSetTitile string created + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Formset successfully created + +--*/ +; + +EFI_STATUS +CreateForm ( + IN CHAR16 *FormTitle, + IN UINT16 FormId, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a form + +Arguments: + + FormTitle - Title of the form + + FormId - Id of the form + + FormBuffer - Pointer of the form created + + StringBuffer - Pointer of FormTitil string created + +Returns: + + EFI_SUCCESS - Form successfully created + +--*/ +; + +EFI_STATUS +CreateSubTitle ( + IN CHAR16 *SubTitle, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle + +Arguments: + + SubTitle - Sub title to be created + + FormBuffer - Where this subtitle to add to + + StringBuffer - String buffer created for subtitle + +Returns: + + EFI_SUCCESS - Subtitle successfully created + +--*/ +; + +EFI_STATUS +CreateText ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN CHAR16 *String3, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a line of text + +Arguments: + + String - First string of the text + + String2 - Second string of the text + + String3 - Help string of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - The form where this text adds to + + StringBuffer - String buffer created for String, String2 and String3 + +Returns: + + EFI_SUCCESS - Text successfully created + +--*/ +; + +EFI_STATUS +CreateGoto ( + IN UINT16 FormId, + IN CHAR16 *Prompt, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink + +Arguments: + + FormId - Form ID of the hyperlink + + Prompt - Prompt of the hyperlink + + FormBuffer - The form where this hyperlink adds to + + StringBuffer - String buffer created for Prompt + +Returns: + + EFI_SUCCESS - Hyperlink successfully created + +--*/ +; + +EFI_STATUS +CreateOneOf ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + Prompt - Prompt of the one-of box + + Help - Help of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - The form where this one-of box adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - One-Of box successfully created. + +--*/ +; + +EFI_STATUS +CreateOrderedList ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + Prompt - Prompt of the ordered list + + Help - Help of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - The form where this ordered list adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_SUCCESS - Ordered list successfully created. + +--*/ +; + +EFI_STATUS +CreateCheckBox ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 Flags, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a checkbox + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + Prompt - Prompt of the check box + + Help - Help of the check box + + Flags - Flags of the check box + + FormBuffer - The form where this check box adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 1 + + EFI_SUCCESS - Check box successfully created + +--*/ +; + +EFI_STATUS +CreateNumeric ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a numeric + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + Prompt - Prompt of the numeric + + Help - Help of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - The form where this numeric adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - Numeric is successfully created + +--*/ +; + +EFI_STATUS +CreateString ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a string + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + Prompt - Prompt of the string + + Help - Help of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - The form where this string adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_SUCCESS - String successfully created. + +--*/ +; + +EFI_STATUS +ExtractDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + IN OUT UINT16 *ImageLength, + OUT UINT8 *DefaultImage, + OUT EFI_GUID *Guid + ) +/*++ + +Routine Description: + + Extract information pertaining to the HiiHandle + +Arguments: + + HiiHandle - Hii handle + + ImageLength - For input, length of DefaultImage; + For output, length of actually required + + DefaultImage - Image buffer prepared by caller + + Guid - Guid information about the form + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength + + EFI_SUCCESS - Successfully extract data from Hii database. + + +--*/ +; + +EFI_HII_HANDLE +FindHiiHandle ( + IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL + IN EFI_GUID *Guid + ) +/*++ + +Routine Description: + Finds HII handle for given pack GUID previously registered with the HII. + +Arguments: + HiiProtocol - pointer to pointer to HII protocol interface. + If NULL, the interface will be found but not returned. + If it points to NULL, the interface will be found and + written back to the pointer that is pointed to. + Guid - The GUID of the pack that registered with the HII. + +Returns: + Handle to the HII pack previously registered by the memory driver. + +--*/ +; + +EFI_STATUS +CreateSubTitleOpCode ( + IN STRING_REF StringToken, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - StringToken of the subtitle + + FormBuffer - Output of subtitle as a form + +Returns: + + EFI_SUCCESS - Subtitle created to be a form + +--*/ +; + +EFI_STATUS +CreateTextOpCode ( + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN STRING_REF StringTokenThree, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a Text opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - First string token of the text + + StringTokenTwo - Second string token of the text + + StringTokenThree - Help string token of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - Output of text as a form + +Returns: + + EFI_SUCCESS - Text created to be a form + +--*/ +; + +EFI_STATUS +CreateGotoOpCode ( + IN UINT16 FormId, + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + FormId - Form ID of the hyperlink + + StringToken - Prompt string token of the hyperlink + + StringTokenTwo - Help string token of the hyperlink + + Flags - Flags of the hyperlink + + Key - Key of the hyperlink + + FormBuffer - Output of hyperlink as a form + +Returns: + + EFI_SUCCESS - Hyperlink created to be a form + +--*/ +; + +EFI_STATUS +CreateOneOfOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a one-of opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + PromptToken - Prompt string token of the one-of box + + HelpToken - Help string token of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - Output of One-Of box as a form + +Returns: + + EFI_SUCCESS - One-Of box created to be a form + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +; + +EFI_STATUS +CreateOrderedListOpCode ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a ordered list opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + PromptToken - Prompt string token of the ordered list + + HelpToken - Help string token of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - Output of ordered list as a form + +Returns: + + EFI_SUCCESS - Ordered list created to be a form + +--*/ +; + +EFI_STATUS +CreateCheckBoxOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a checkbox opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + PromptToken - Prompt string token of the check box + + HelpToken - Help string token of the check box + + Flags - Flags of the check box + + Key - Key of the check box + + FormBuffer - Output of the check box as a form + +Returns: + + EFI_SUCCESS - Checkbox created to be a form + + EFI_DEVICE_ERROR - DataWidth > 1 + +--*/ +; + +EFI_STATUS +CreateNumericOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + PromptToken - Prompt string token of the numeric + + HelpToken - Help string token of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value of the numeric + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - Output of the numeric as a form + +Returns: + + EFI_SUCCESS - The numeric created to be a form. + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +; + +EFI_STATUS +CreateStringOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + PromptToken - Prompt token of the string + + HelpToken - Help token of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - Output of the string as a form + +Returns: + + EFI_SUCCESS - String created to be a form. + +--*/ +; + +EFI_STATUS +ValidateDataFromHiiHandle ( + IN EFI_HII_HANDLE HiiHandle, + OUT BOOLEAN *Results + ) +/*++ + +Routine Description: + + Validate that the data associated with the HiiHandle in NVRAM is within + the reasonable parameters for that FormSet. Values for strings and passwords + are not verified due to their not having the equivalent of valid range settings. + +Arguments: + + HiiHandle - Handle of the HII database entry to query + + Results - If return Status is EFI_SUCCESS, Results provides valid data + TRUE = NVRAM Data is within parameters + FALSE = NVRAM Data is NOT within parameters + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Data successfully validated +--*/ +; + +EFI_STATUS +CreateBannerOpCode ( + IN UINT16 Title, + IN UINT16 LineNumber, + IN UINT8 Alignment, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a banner opcode. This is primarily used by the FrontPage implementation from BDS. + +Arguments: + + Title - Title of the banner + + LineNumber - LineNumber of the banner + + Alignment - Alignment of the banner + + FormBuffer - Output of banner as a form + +Returns: + + EFI_SUCCESS - Banner created to be a form. + +--*/ +; + +EFI_HII_PACKAGES * +PreparePackages ( + IN UINTN NumberOfPackages, + IN EFI_GUID *GuidId, + ... + ) +/*++ + +Routine Description: + + Assemble EFI_HII_PACKAGES according to the passed in packages. + +Arguments: + + NumberOfPackages - Number of packages. + GuidId - Package GUID. + +Returns: + + Pointer of EFI_HII_PACKAGES. + +--*/ +; + +VOID +EfiLibHiiVariablePackGetMap ( + IN EFI_HII_VARIABLE_PACK *Pack, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, OPTIONAL + OUT UINTN *Size OPTIONAL + ) +/*++ + +Routine Description: + + Extracts a variable form a Pack. + +Arguments: + + Pack - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + VOID. + +--*/ +; + +UINTN +EfiLibHiiVariablePackListGetMapCnt ( + IN EFI_HII_VARIABLE_PACK_LIST *List + ) +/*++ + +Routine Description: + + Finds a count of the variables/maps in the List. + +Arguments: + + List - List of variables + +Returns: + + Number of Map in the variable pack list. + +--*/ +; + +typedef VOID (EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK) ( + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINT16 Id, + IN VOID *Var, + IN UINTN Size + ) +/*++ + +Routine Description: + + type definition for the callback to be + used with EfiLibHiiVariablePackListForEachVar(). + +Arguments: + + Id - Variable/Map ID + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + VOID + +--*/ +; + +VOID +EfiLibHiiVariablePackListForEachVar ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback + ) +/*++ + +Routine Description: + + Will iterate all variable/maps as appearing + in List and for each, it will call the Callback. + +Arguments: + + List - List of variables + Callback - Routine to be called for each iterated variable. + +Returns: + + VOID + +--*/ +; + +EFI_STATUS +EfiLibHiiVariablePackListGetMapByIdx ( + IN UINTN Idx, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + Finds a variable form List given + the order number as appears in the List. + +Arguments: + + Idx - The index of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ +; + +EFI_STATUS +EfiLibHiiVariablePackListGetMapById ( + IN UINT16 Id, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + Finds a variable form List given the + order number as appears in the List. + +Arguments: + + Id - The ID of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ +; + +EFI_STATUS +EfiLibHiiVariablePackListGetMap ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + OUT UINT16 *Id, + OUT VOID **Var, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID. + +Arguments: + + List - List of variables + Name - Name of the variable/map to be found + Guid - GUID of the variable/map to be found + Var - Pointer to the variable/map found + Size - Size of the variable/map in bytes found + +Returns: + + EFI_SUCCESS - variable is found, OUT parameters are valid + EFI_NOT_FOUND - variable is not found, OUT parameters are not valid + +--*/ +; + +EFI_STATUS +EfiLibHiiVariableRetrieveFromNv ( + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID **Var + ) +/*++ + +Routine Description: + Finds out if a variable of specific Name/Guid/Size exists in NV. + If it does, it will retrieve it into the Var. + +Arguments: + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into buffer pointed by this pointer. + If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer. +Returns: + EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +; + +//// +//// Variable override support. +//// + +EFI_STATUS +EfiLibHiiVariableOverrideIfSuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the Name ends with specified Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride", + the Suffix matches the end of Name, so the variable will be loaded from NV + provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the Name should end with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_INVALID_PARAMETER - The name of the variable does not end with . + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +; + +EFI_STATUS +EfiLibHiiVariableOverrideBySuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the NV contains the same variable with Name is appended with Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetup", + the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride" + will be loaded from NV provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the variable will be appended with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. + +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c new file mode 100644 index 0000000000..51abde7cf0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c @@ -0,0 +1,974 @@ +/*++ +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + IfrOnTheFly.c + +Abstract: + + Library Routines to create IFR on-the-fly + +Revision History: + +--*/ + +#include "IfrLibrary.h" + +EFI_STATUS +CreateFormSet ( + IN CHAR16 *FormSetTitle, + IN EFI_GUID *Guid, + IN UINT8 Class, + IN UINT8 SubClass, + IN OUT VOID **FormBuffer, + IN OUT VOID **StringBuffer + ) +/*++ + +Routine Description: + + Create a formset + +Arguments: + + FormSetTitle - Title of formset + + Guid - Guid of formset + + Class - Class of formset + + SubClass - Sub class of formset + + FormBuffer - Pointer of the formset created + + StringBuffer - Pointer of FormSetTitile string created + +Returns: + + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + + EFI_SUCCESS - Formset successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_HII_IFR_PACK IfrPack; + EFI_IFR_FORM_SET FormSet; + EFI_IFR_END_FORM_SET EndFormSet; + UINT8 *Destination; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Pre-allocate a buffer sufficient for us to work from. + // + FormBuffer = EfiLibAllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE); + if (FormBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Pre-allocate a buffer sufficient for us to work from. + // + StringBuffer = EfiLibAllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE); + if (StringBuffer == NULL) { + gBS->FreePool (FormBuffer); + return EFI_OUT_OF_RESOURCES; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add the FormSetTitle to the string buffer and get the StringToken + // + Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Initialize the Ifr Package header data + // + IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (EFI_IFR_FORM_SET) + sizeof (EFI_IFR_END_FORM_SET); + IfrPack.Header.Type = EFI_HII_IFR; + + // + // Initialize FormSet with the appropriate information + // + FormSet.Header.OpCode = EFI_IFR_FORM_SET_OP; + FormSet.Header.Length = sizeof (EFI_IFR_FORM_SET); + FormSet.FormSetTitle = StringToken; + FormSet.Class = Class; + FormSet.SubClass = SubClass; + EfiCopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID)); + + // + // Initialize the end formset data + // + EndFormSet.Header.Length = sizeof (EFI_IFR_END_FORM_SET); + EndFormSet.Header.OpCode = EFI_IFR_END_FORM_SET_OP; + + Destination = (CHAR8 *) *FormBuffer; + + // + // Copy the formset/endformset data to the form buffer + // + EfiCopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER)); + + Destination = Destination + sizeof (EFI_HII_PACK_HEADER); + + EfiCopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET)); + + Destination = Destination + sizeof (EFI_IFR_FORM_SET); + + EfiCopyMem (Destination, &EndFormSet, sizeof (EFI_IFR_END_FORM_SET)); + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateForm ( + IN CHAR16 *FormTitle, + IN UINT16 FormId, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a form + +Arguments: + + FormTitle - Title of the form + + FormId - Id of the form + + FormBuffer - Pointer of the form created + + StringBuffer - Pointer of FormTitil string created + +Returns: + + EFI_SUCCESS - Form successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_FORM Form; + EFI_IFR_END_FORM EndForm; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Form.Header.OpCode = EFI_IFR_FORM_OP; + Form.Header.Length = sizeof (EFI_IFR_FORM); + Form.FormId = FormId; + Form.FormTitle = StringToken; + + Status = AddOpCode (FormBuffer, &Form); + + if (EFI_ERROR (Status)) { + return Status; + } + + EndForm.Header.OpCode = EFI_IFR_END_FORM_OP; + EndForm.Header.Length = sizeof (EFI_IFR_END_FORM); + + Status = AddOpCode (FormBuffer, &EndForm); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateSubTitle ( + IN CHAR16 *SubTitle, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle + +Arguments: + + SubTitle - Sub title to be created + + FormBuffer - Where this subtitle to add to + + StringBuffer - String buffer created for subtitle + +Returns: + + EFI_SUCCESS - Subtitle successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_SUBTITLE Subtitle; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP; + Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE); + Subtitle.SubTitle = StringToken; + + Status = AddOpCode (FormBuffer, &Subtitle); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateText ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN CHAR16 *String3, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a line of text + +Arguments: + + String - First string of the text + + String2 - Second string of the text + + String3 - Help string of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - The form where this text adds to + + StringBuffer - String buffer created for String, String2 and String3 + +Returns: + + EFI_SUCCESS - Text successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_TEXT Text; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Text.Header.OpCode = EFI_IFR_TEXT_OP; + Text.Header.Length = sizeof (EFI_IFR_TEXT); + Text.Text = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Text.TextTwo = StringToken; + + Text.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + Text.Key = Key; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Text.Help = StringToken; + + Status = AddOpCode (FormBuffer, &Text); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateGoto ( + IN UINT16 FormId, + IN CHAR16 *Prompt, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink + +Arguments: + + FormId - Form ID of the hyperlink + + Prompt - Prompt of the hyperlink + + FormBuffer - The form where this hyperlink adds to + + StringBuffer - String buffer created for Prompt + +Returns: + + EFI_SUCCESS - Hyperlink successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_REF Hyperlink; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Hyperlink.Header.OpCode = EFI_IFR_REF_OP; + Hyperlink.Header.Length = sizeof (EFI_IFR_REF); + Hyperlink.FormId = FormId; + Hyperlink.Prompt = StringToken; + + Status = AddOpCode (FormBuffer, &Hyperlink); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateOneOf ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + Prompt - Prompt of the one-of box + + Help - Help of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - The form where this one-of box adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - One-Of box successfully created. + +--*/ +{ + EFI_STATUS Status; + UINTN Index; + EFI_IFR_ONE_OF OneOf; + EFI_IFR_ONE_OF_OPTION OneOfOption; + EFI_IFR_END_ONE_OF EndOneOf; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // We do not create op-code storage widths for one-of in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP; + OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF); + OneOf.QuestionId = QuestionId; + OneOf.Width = DataWidth; + OneOf.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OneOf.Help = StringToken; + + Status = AddOpCode (FormBuffer, &OneOf); + + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < OptionCount; Index++) { + OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + + // + // Add string and get token back + // + Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken); + + OneOfOption.Option = StringToken; + OneOfOption.Value = OptionsList[Index].Value; + OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED); + OneOfOption.Key = OptionsList[Index].Key; + + Status = AddOpCode (FormBuffer, &OneOfOption); + + if (EFI_ERROR (Status)) { + return Status; + } + } + + EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + Status = AddOpCode (FormBuffer, &EndOneOf); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateOrderedList ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a one-of question with a set of options to choose from. The + OptionsList is a pointer to a null-terminated list of option descriptions. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + Prompt - Prompt of the ordered list + + Help - Help of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - The form where this ordered list adds to + + StringBuffer - String buffer created for Prompt, Help and Option strings + +Returns: + + EFI_SUCCESS - Ordered list successfully created. + +--*/ +{ + EFI_STATUS Status; + UINTN Index; + EFI_IFR_ORDERED_LIST OrderedList; + EFI_IFR_ONE_OF_OPTION OrderedListOption; + EFI_IFR_END_ONE_OF EndOrderedList; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP; + OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST); + OrderedList.QuestionId = QuestionId; + OrderedList.MaxEntries = MaxEntries; + OrderedList.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + OrderedList.Help = StringToken; + + Status = AddOpCode (FormBuffer, &OrderedList); + + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index = 0; Index < OptionCount; Index++) { + OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + + // + // Add string and get token back + // + Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken); + + OrderedListOption.Option = StringToken; + OrderedListOption.Value = OptionsList[Index].Value; + OrderedListOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED); + OrderedListOption.Key = OptionsList[Index].Key; + + Status = AddOpCode (FormBuffer, &OrderedListOption); + + if (EFI_ERROR (Status)) { + return Status; + } + } + + EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + Status = AddOpCode (FormBuffer, &EndOrderedList); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateCheckBox ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 Flags, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a checkbox + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + Prompt - Prompt of the check box + + Help - Help of the check box + + Flags - Flags of the check box + + FormBuffer - The form where this check box adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 1 + + EFI_SUCCESS - Check box successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_CHECK_BOX CheckBox; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // We do not create op-code storage widths for checkbox in excess of 8 bits for now + // + if (DataWidth > 1) { + return EFI_DEVICE_ERROR; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP; + CheckBox.Header.Length = sizeof (EFI_IFR_CHECK_BOX); + CheckBox.QuestionId = QuestionId; + CheckBox.Width = DataWidth; + CheckBox.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + CheckBox.Help = StringToken; + CheckBox.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + + Status = AddOpCode (FormBuffer, &CheckBox); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateNumeric ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a numeric + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + Prompt - Prompt of the numeric + + Help - Help of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - The form where this numeric adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_DEVICE_ERROR - DataWidth > 2 + + EFI_SUCCESS - Numeric is successfully created + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_NUMERIC Numeric; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // We do not create op-code storage widths for numerics in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP; + Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC); + Numeric.QuestionId = QuestionId; + Numeric.Width = DataWidth; + Numeric.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + Numeric.Help = StringToken; + Numeric.Minimum = Minimum; + Numeric.Maximum = Maximum; + Numeric.Step = Step; + Numeric.Default = Default; + Numeric.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + Numeric.Key = Key; + + Status = AddOpCode (FormBuffer, &Numeric); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateString ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN CHAR16 *Prompt, + IN CHAR16 *Help, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer, + IN OUT VOID *StringBuffer + ) +/*++ + +Routine Description: + + Create a string + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + Prompt - Prompt of the string + + Help - Help of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - The form where this string adds to + + StringBuffer - String buffer created for Prompt and Help. + +Returns: + + EFI_SUCCESS - String successfully created. + +--*/ +{ + EFI_STATUS Status; + EFI_IFR_STRING String; + CHAR16 CurrentLanguage[4]; + STRING_REF StringToken; + + // + // Obtain current language value + // + GetCurrentLanguage (CurrentLanguage); + + // + // Add first string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + String.Header.OpCode = EFI_IFR_STRING_OP; + String.Header.Length = sizeof (EFI_IFR_STRING); + String.QuestionId = QuestionId; + String.Width = DataWidth; + String.Prompt = StringToken; + + // + // Add second string, get first string's token + // + Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken); + + if (EFI_ERROR (Status)) { + return Status; + } + + String.Help = StringToken; + String.MinSize = MinSize; + String.MaxSize = MaxSize; + String.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED); + String.Key = Key; + + Status = AddOpCode (FormBuffer, &String); + + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c new file mode 100644 index 0000000000..424163785f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c @@ -0,0 +1,615 @@ +/*++ +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + IfrOpCodeCreation.c + +Abstract: + + Library Routines to create IFR independent of string data - assume tokens already exist + Primarily to be used for exporting op-codes at a label in pre-defined forms. + +Revision History: + +--*/ + +#include "IfrLibrary.h" + +EFI_STATUS +CreateSubTitleOpCode ( + IN STRING_REF StringToken, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a SubTitle opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - StringToken of the subtitle + + FormBuffer - Output of subtitle as a form + +Returns: + + EFI_SUCCESS - Subtitle created to be a form + +--*/ +{ + EFI_IFR_SUBTITLE Subtitle; + + Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP; + Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE); + Subtitle.SubTitle = StringToken; + + EfiCopyMem (FormBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE)); + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateTextOpCode ( + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN STRING_REF StringTokenThree, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a Text opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + StringToken - First string token of the text + + StringTokenTwo - Second string token of the text + + StringTokenThree - Help string token of the text + + Flags - Flag of the text + + Key - Key of the text + + FormBuffer - Output of text as a form + +Returns: + + EFI_SUCCESS - Text created to be a form + +--*/ +{ + EFI_IFR_TEXT Text; + + Text.Header.OpCode = EFI_IFR_TEXT_OP; + Text.Header.Length = sizeof (EFI_IFR_TEXT); + Text.Text = StringToken; + + Text.TextTwo = StringTokenTwo; + Text.Help = StringTokenThree; + Text.Flags = Flags; + Text.Key = Key; + + EfiCopyMem (FormBuffer, &Text, sizeof (EFI_IFR_TEXT)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateGotoOpCode ( + IN UINT16 FormId, + IN STRING_REF StringToken, + IN STRING_REF StringTokenTwo, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a hyperlink opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + FormId - Form ID of the hyperlink + + StringToken - Prompt string token of the hyperlink + + StringTokenTwo - Help string token of the hyperlink + + Flags - Flags of the hyperlink + + Key - Key of the hyperlink + + FormBuffer - Output of hyperlink as a form + +Returns: + + EFI_SUCCESS - Hyperlink created to be a form + +--*/ +{ + EFI_IFR_REF Hyperlink; + + Hyperlink.Header.OpCode = EFI_IFR_REF_OP; + Hyperlink.Header.Length = sizeof (EFI_IFR_REF); + Hyperlink.FormId = FormId; + Hyperlink.Prompt = StringToken; + Hyperlink.Help = StringTokenTwo; + Hyperlink.Key = Key; + Hyperlink.Flags = Flags; + + EfiCopyMem (FormBuffer, &Hyperlink, sizeof (EFI_IFR_REF)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateOneOfOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a one-of opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the one-of box + + DataWidth - DataWidth of the one-of box + + PromptToken - Prompt string token of the one-of box + + HelpToken - Help string token of the one-of box + + OptionsList - Each string in it is an option of the one-of box + + OptionCount - Option string count + + FormBuffer - Output of One-Of box as a form + +Returns: + + EFI_SUCCESS - One-Of box created to be a form + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +{ + UINTN Index; + EFI_IFR_ONE_OF OneOf; + EFI_IFR_ONE_OF_OPTION OneOfOption; + EFI_IFR_END_ONE_OF EndOneOf; + UINT8 *LocalBuffer; + + // + // We do not create op-code storage widths for one-of in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP; + OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF); + OneOf.QuestionId = QuestionId; + OneOf.Width = DataWidth; + OneOf.Prompt = PromptToken; + + OneOf.Help = HelpToken; + + LocalBuffer = (CHAR8 *) FormBuffer; + + EfiCopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF)); + + LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF)); + + for (Index = 0; Index < OptionCount; Index++) { + OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + + OneOfOption.Option = OptionsList[Index].StringToken; + OneOfOption.Value = OptionsList[Index].Value; + OneOfOption.Flags = OptionsList[Index].Flags; + OneOfOption.Key = OptionsList[Index].Key; + + EfiCopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION)); + + LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION)); + } + + EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + EfiCopyMem (LocalBuffer, &EndOneOf, sizeof (EFI_IFR_END_ONE_OF)); + + LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF)); + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateOrderedListOpCode ( + IN UINT16 QuestionId, + IN UINT8 MaxEntries, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN IFR_OPTION *OptionsList, + IN UINTN OptionCount, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a ordered list opcode with a set of option op-codes to choose from independent of string creation. + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + + OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken + has been filled in since this routine will not generate StringToken values. + +Arguments: + + QuestionId - Question ID of the ordered list + + MaxEntries - MaxEntries of the ordered list + + PromptToken - Prompt string token of the ordered list + + HelpToken - Help string token of the ordered list + + OptionsList - Each string in it is an option of the ordered list + + OptionCount - Option string count + + FormBuffer - Output of ordered list as a form + +Returns: + + EFI_SUCCESS - Ordered list created to be a form + +--*/ +{ + UINTN Index; + EFI_IFR_ORDERED_LIST OrderedList; + EFI_IFR_ONE_OF_OPTION OrderedListOption; + EFI_IFR_END_ONE_OF EndOrderedList; + UINT8 *LocalBuffer; + + OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP; + OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST); + OrderedList.QuestionId = QuestionId; + OrderedList.MaxEntries = MaxEntries; + OrderedList.Prompt = PromptToken; + + OrderedList.Help = HelpToken; + + LocalBuffer = (CHAR8 *) FormBuffer; + + EfiCopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST)); + + LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ORDERED_LIST)); + + for (Index = 0; Index < OptionCount; Index++) { + OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP; + OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION); + + OrderedListOption.Option = OptionsList[Index].StringToken; + OrderedListOption.Value = OptionsList[Index].Value; + OrderedListOption.Flags = OptionsList[Index].Flags; + OrderedListOption.Key = OptionsList[Index].Key; + + EfiCopyMem (LocalBuffer, &OrderedListOption, sizeof (EFI_IFR_ONE_OF_OPTION)); + + LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION)); + } + + EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF); + EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP; + + EfiCopyMem (LocalBuffer, &EndOrderedList, sizeof (EFI_IFR_END_ONE_OF)); + + LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF)); + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateCheckBoxOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a checkbox opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the check box + + DataWidth - DataWidth of the check box + + PromptToken - Prompt string token of the check box + + HelpToken - Help string token of the check box + + Flags - Flags of the check box + + Key - Key of the check box + + FormBuffer - Output of the check box as a form + +Returns: + + EFI_SUCCESS - Checkbox created to be a form + + EFI_DEVICE_ERROR - DataWidth > 1 + +--*/ +{ + EFI_IFR_CHECK_BOX CheckBox; + + // + // We do not create op-code storage widths for checkbox in excess of 8 bits for now + // + if (DataWidth > 1) { + return EFI_DEVICE_ERROR; + } + + CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP; + CheckBox.Header.Length = sizeof (EFI_IFR_CHECK_BOX); + CheckBox.QuestionId = QuestionId; + CheckBox.Width = DataWidth; + CheckBox.Prompt = PromptToken; + + CheckBox.Help = HelpToken; + CheckBox.Flags = Flags; + CheckBox.Key = Key; + + EfiCopyMem (FormBuffer, &CheckBox, sizeof (EFI_IFR_CHECK_BOX)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateNumericOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT16 Minimum, + IN UINT16 Maximum, + IN UINT16 Step, + IN UINT16 Default, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the numeric + + DataWidth - DataWidth of the numeric + + PromptToken - Prompt string token of the numeric + + HelpToken - Help string token of the numeric + + Minimum - Minumun boundary of the numeric + + Maximum - Maximum boundary of the numeric + + Step - Step of the numeric + + Default - Default value of the numeric + + Flags - Flags of the numeric + + Key - Key of the numeric + + FormBuffer - Output of the numeric as a form + +Returns: + + EFI_SUCCESS - The numeric created to be a form. + + EFI_DEVICE_ERROR - DataWidth > 2 + +--*/ +{ + EFI_IFR_NUMERIC Numeric; + + // + // We do not create op-code storage widths for numerics in excess of 16 bits for now + // + if (DataWidth > 2) { + return EFI_DEVICE_ERROR; + } + + Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP; + Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC); + Numeric.QuestionId = QuestionId; + Numeric.Width = DataWidth; + Numeric.Prompt = PromptToken; + + Numeric.Help = HelpToken; + Numeric.Minimum = Minimum; + Numeric.Maximum = Maximum; + Numeric.Step = Step; + Numeric.Default = Default; + Numeric.Flags = Flags; + Numeric.Key = Key; + + EfiCopyMem (FormBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateStringOpCode ( + IN UINT16 QuestionId, + IN UINT8 DataWidth, + IN STRING_REF PromptToken, + IN STRING_REF HelpToken, + IN UINT8 MinSize, + IN UINT8 MaxSize, + IN UINT8 Flags, + IN UINT16 Key, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a numeric opcode independent of string creation + This is used primarily by users who need to create just one particular valid op-code and the string + data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label + location to pre-defined forms in HII) + +Arguments: + + QuestionId - Question ID of the string + + DataWidth - DataWidth of the string + + PromptToken - Prompt token of the string + + HelpToken - Help token of the string + + MinSize - Min size boundary of the string + + MaxSize - Max size boundary of the string + + Flags - Flags of the string + + Key - Key of the string + + FormBuffer - Output of the string as a form + +Returns: + + EFI_SUCCESS - String created to be a form. + +--*/ +{ + EFI_IFR_STRING String; + + String.Header.OpCode = EFI_IFR_STRING_OP; + String.Header.Length = sizeof (EFI_IFR_STRING); + String.QuestionId = QuestionId; + String.Width = DataWidth; + String.Prompt = PromptToken; + + String.Help = HelpToken; + String.MinSize = MinSize; + String.MaxSize = MaxSize; + String.Flags = Flags; + String.Key = Key; + + EfiCopyMem (FormBuffer, &String, sizeof (EFI_IFR_STRING)); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CreateBannerOpCode ( + IN UINT16 Title, + IN UINT16 LineNumber, + IN UINT8 Alignment, + IN OUT VOID *FormBuffer + ) +/*++ + +Routine Description: + + Create a banner opcode. This is primarily used by the FrontPage implementation from BDS. + +Arguments: + + Title - Title of the banner + + LineNumber - LineNumber of the banner + + Alignment - Alignment of the banner + + FormBuffer - Output of banner as a form + +Returns: + + EFI_SUCCESS - Banner created to be a form. + +--*/ +{ + EFI_IFR_BANNER Banner; + + Banner.Header.OpCode = EFI_IFR_BANNER_OP; + Banner.Header.Length = sizeof (EFI_IFR_BANNER); + EfiCopyMem (&Banner.Title, &Title, sizeof (UINT16)); + EfiCopyMem (&Banner.LineNumber, &LineNumber, sizeof (UINT16)); + Banner.Alignment = Alignment; + + EfiCopyMem (FormBuffer, &Banner, sizeof (EFI_IFR_BANNER)); + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c new file mode 100644 index 0000000000..1340daf044 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c @@ -0,0 +1,488 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + IfrVariable.c + +Abstract: + Variable/Map manipulations routines + +--*/ + +#include "IfrLibrary.h" + +VOID +EfiLibHiiVariablePackGetMap ( + IN EFI_HII_VARIABLE_PACK *Pack, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, OPTIONAL + OUT UINTN *Size OPTIONAL + ) +/*++ + +Routine Description: + + Extracts a variable form a Pack. + +Arguments: + + Pack - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + VOID + +--*/ +{ + if (NULL != Name) { + *Name = (VOID *) (Pack + 1); + } + + if (NULL != Guid) { + *Guid = &Pack->VariableGuid; + } + + + if (NULL != Id) { + *Id = Pack->VariableId; + } + + if (NULL != Var) { + *Var = (VOID *) ((CHAR8 *) (Pack + 1) + Pack->VariableNameLength); + } + + if (NULL != Size) { + *Size = Pack->Header.Length - sizeof (*Pack) - Pack->VariableNameLength; + } +} + + +UINTN +EfiLibHiiVariablePackListGetMapCnt ( + IN EFI_HII_VARIABLE_PACK_LIST *List + ) + +/*++ + +Routine Description: + + Finds a count of the variables/maps in the List. + +Arguments: + + List - List of variables + +Returns: + + UINTN - The number of map count. + +--*/ + +{ + UINTN Cnt = 0; + while (NULL != List) { + Cnt++; + List = List->NextVariablePack; + } + return Cnt; +} + + +VOID +EfiLibHiiVariablePackListForEachVar ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback + ) +/*++ + +Routine Description: + + Will iterate all variable/maps as appearing + in List and for each, it will call the Callback. + +Arguments: + + List - List of variables + Callback - Routine to be called for each iterated variable. + +Returns: + + VOID + +--*/ + +{ + CHAR16 *MapName; + EFI_GUID *MapGuid; + UINT16 MapId; + VOID *Map; + UINTN MapSize; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + // + // call the callback + // + Callback (MapName, MapGuid, MapId, Map, MapSize); + List = List->NextVariablePack; + } +} + + +EFI_STATUS +EfiLibHiiVariablePackListGetMapByIdx ( + IN UINTN Idx, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT UINT16 *Id, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) + +/*++ + +Routine Description: + + Finds a variable form List given + the order number as appears in the List. + +Arguments: + + Idx - The index of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ +{ + CHAR16 *MapName; + EFI_GUID *MapGuid; + UINT16 MapId; + VOID *Map; + UINTN MapSize; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + if (0 == Idx--) { + *Var = Map; + *Size = MapSize; + + if (NULL != Name) { + *Name = MapName; + } + + if (NULL != Guid) { + *Guid = MapGuid; + } + + if (NULL != Id) { + *Id = MapId; + } + + return EFI_SUCCESS; // Map found + } + List = List->NextVariablePack; + } + // + // If here, the map is not found + // + return EFI_NOT_FOUND; +} + + +EFI_STATUS +EfiLibHiiVariablePackListGetMapById ( + IN UINT16 Id, + IN EFI_HII_VARIABLE_PACK_LIST *List, + OUT CHAR16 **Name, OPTIONAL + OUT EFI_GUID **Guid, OPTIONAL + OUT VOID **Var, + OUT UINTN *Size + ) + +/*++ + +Routine Description: + + Finds a variable form List given the + order number as appears in the List. + +Arguments: + + Id - The ID of the variable/map to retrieve + List - List of variables + Name - Name of the variable/map + Guid - GUID of the variable/map + Var - Pointer to the variable/map + Size - Size of the variable/map in bytes + +Returns: + + EFI_SUCCESS - Variable is found, OUT parameters are valid + EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid + +--*/ + +{ + CHAR16 *MapName; + EFI_GUID *MapGuid; + UINT16 MapId; + VOID *Map; + UINTN MapSize; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + if (MapId == Id) { + *Var = Map; + *Size = MapSize; + if (NULL != Name) { + *Name = MapName; + } + if (NULL != Guid) { + *Guid = MapGuid; + } + // + // Map found + // + return EFI_SUCCESS; + } + List = List->NextVariablePack; + } + // + // If here, the map is not found + // + return EFI_NOT_FOUND; +} + + +EFI_STATUS +EfiLibHiiVariablePackListGetMap ( + IN EFI_HII_VARIABLE_PACK_LIST *List, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + OUT UINT16 *Id, + OUT VOID **Var, + OUT UINTN *Size + ) + +/*++ + +Routine Description: + + Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID. + +Arguments: + + List - List of variables + Name - Name of the variable/map to be found + Guid - GUID of the variable/map to be found + Var - Pointer to the variable/map found + Size - Size of the variable/map in bytes found + +Returns: + + EFI_SUCCESS - variable is found, OUT parameters are valid + EFI_NOT_FOUND - variable is not found, OUT parameters are not valid + +--*/ + +{ + VOID *Map; + UINTN MapSize; + UINT16 MapId; + CHAR16 *MapName; + EFI_GUID *MapGuid; + + while (NULL != List) { + EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize); + if ((0 == EfiStrCmp (Name, MapName)) && EfiCompareGuid (Guid, MapGuid)) { + *Id = MapId; + *Var = Map; + *Size = MapSize; + return EFI_SUCCESS; + } + List = List->NextVariablePack; + } + // + // If here, the map is not found + // + return EFI_NOT_FOUND; +} + +EFI_STATUS +EfiLibHiiVariableRetrieveFromNv ( + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID **Var + ) +/*++ + +Routine Description: + Finds out if a variable of specific Name/Guid/Size exists in NV. + If it does, it will retrieve it into the Var. + +Arguments: + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into buffer pointed by this pointer. + If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer. +Returns: + EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +{ + EFI_STATUS Status; + UINTN SizeNv; + + // + // Test for existence of the variable. + // + SizeNv = 0; + Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, NULL); + if (EFI_BUFFER_TOO_SMALL != Status) { + ASSERT (EFI_SUCCESS != Status); + return EFI_NOT_FOUND; + } + if (SizeNv != Size) { + // + // The variable is considered corrupt, as it has different size from expected. + // + return EFI_LOAD_ERROR; + } + + if (NULL == *Var) { + *Var = EfiLibAllocatePool (Size); + ASSERT (NULL != *Var); + } + SizeNv = Size; + // + // Final read into the Var + // + Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, *Var); + // + // No tolerance for random failures. Such behavior is undetermined and not validated. + // + ASSERT_EFI_ERROR (Status); + ASSERT (SizeNv == Size); + return EFI_SUCCESS; +} + + + +EFI_STATUS +EfiLibHiiVariableOverrideIfSuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the Name ends with specified Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride", + the Suffix matches the end of Name, so the variable will be loaded from NV + provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the Name should end with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_INVALID_PARAMETER - The name of the variable does not end with . + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +{ + UINTN StrLen; + UINTN StrLenSuffix; + + StrLen = EfiStrLen (Name); + StrLenSuffix = EfiStrLen (Suffix); + if ((StrLen <= StrLenSuffix) || (0 != EfiStrCmp (Suffix, &Name[StrLen - StrLenSuffix]))) { + // + // Not ending with . + // + return EFI_INVALID_PARAMETER; + } + return EfiLibHiiVariableRetrieveFromNv (Name, Guid, Size, &Var); +} + + + +EFI_STATUS +EfiLibHiiVariableOverrideBySuffix ( + IN CHAR16 *Suffix, + IN CHAR16 *Name, + IN EFI_GUID *Guid, + IN UINTN Size, + OUT VOID *Var + ) +/*++ + +Routine Description: + Overrrides the variable with NV data if found. + But it only does it if the NV contains the same variable with Name is appended with Suffix. + For example, if Suffix="MyOverride" and the Name="XyzSetup", + the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride" + will be loaded from NV provided the variable exists and the GUID and Size matches. + +Arguments: + Suffix - Suffix the variable will be appended with. + Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly. + Var - Variable will be retrieved into this buffer. + Caller is responsible for providing storage of exactly Size size in bytes. + +Returns: + EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size. + EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV. + EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error. + +--*/ +{ + EFI_STATUS Status; + CHAR16 *NameSuffixed; + + // + // enough to concatenate both strings. + // + NameSuffixed = EfiLibAllocateZeroPool ((EfiStrLen (Name) + EfiStrLen (Suffix) + 1) * sizeof (CHAR16)); + + EfiStrCpy (NameSuffixed, Name); + EfiStrCat (NameSuffixed, Suffix); + + Status = EfiLibHiiVariableRetrieveFromNv (NameSuffixed, Guid, Size, &Var); + gBS->FreePool (NameSuffixed); + + return Status; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c new file mode 100644 index 0000000000..49720ecbf1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c @@ -0,0 +1,597 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiScriptLib.c + +Abstract: + + Support for EFI script. + +--*/ + +#include "EfiScriptLib.h" + +EFI_BOOT_SCRIPT_SAVE_PROTOCOL *mBootScriptSave; + +EFI_STATUS +BootScriptSaveInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Boot Script Lib if it has not yet been initialized. + +Arguments: + + (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +// GC_TODO: ImageHandle - add argument and description to function comment +// GC_TODO: SystemTable - add argument and description to function comment +{ + EFI_STATUS Status; + EFI_BOOT_SERVICES *BS; + + BS = SystemTable->BootServices; + + Status = BS->LocateProtocol (&gEfiBootScriptSaveGuid, NULL, &mBootScriptSave); + if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { + mBootScriptSave = NULL; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSaveIoWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI IO write script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: Width - add argument and description to function comment +// GC_TODO: Address - add argument and description to function comment +// GC_TODO: Count - add argument and description to function comment +// GC_TODO: Buffer - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, + Width, + Address, + Count, + Buffer + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSaveIoReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI IO read write script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: Width - add argument and description to function comment +// GC_TODO: Address - add argument and description to function comment +// GC_TODO: Data - add argument and description to function comment +// GC_TODO: DataMask - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE, + Width, + Address, + Data, + DataMask + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSaveMemWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI MEM write script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: Width - add argument and description to function comment +// GC_TODO: Address - add argument and description to function comment +// GC_TODO: Count - add argument and description to function comment +// GC_TODO: Buffer - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE, + Width, + Address, + Count, + Buffer + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSaveMemReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI MEM read write script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: Width - add argument and description to function comment +// GC_TODO: Address - add argument and description to function comment +// GC_TODO: Data - add argument and description to function comment +// GC_TODO: DataMask - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE, + Width, + Address, + Data, + DataMask + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSavePciCfgWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI PCI write script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: Width - add argument and description to function comment +// GC_TODO: Address - add argument and description to function comment +// GC_TODO: Count - add argument and description to function comment +// GC_TODO: Buffer - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE, + Width, + Address, + Count, + Buffer + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSavePciCfgReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI PCI read write script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: Width - add argument and description to function comment +// GC_TODO: Address - add argument and description to function comment +// GC_TODO: Data - add argument and description to function comment +// GC_TODO: DataMask - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE, + Width, + Address, + Data, + DataMask + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSaveSmbusExecute ( + IN UINT16 TableName, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN UINTN *Length, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI Smbus execute script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: SlaveAddress - add argument and description to function comment +// GC_TODO: Command - add argument and description to function comment +// GC_TODO: Operation - add argument and description to function comment +// GC_TODO: PecCheck - add argument and description to function comment +// GC_TODO: Length - add argument and description to function comment +// GC_TODO: Buffer - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE, + SlaveAddress, + Command, + Operation, + PecCheck, + Length, + Buffer + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSaveStall ( + IN UINT16 TableName, + IN UINTN Duration + ) +/*++ + +Routine Description: + + Save I/O write to boot script + +Arguments: + + TableName - Desired boot script table + + (Standard EFI stall script parameter) + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +// GC_TODO: Duration - add argument and description to function comment +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_STALL_OPCODE, + Duration + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +BootScriptSaveDispatch ( + IN UINT16 TableName, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + TableName - GC_TODO: add argument description + EntryPoint - GC_TODO: add argument description + +Returns: + + EFI_NOT_FOUND - GC_TODO: Add description for return value + EFI_SUCCESS - GC_TODO: Add description for return value + +--*/ +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_DISPATCH_OPCODE, + EntryPoint + ); + + return EFI_SUCCESS; + +} + +EFI_STATUS +EFIAPI +BootScriptSaveInformation ( + IN UINT16 TableName, + IN UINT32 Length, + IN EFI_PHYSICAL_ADDRESS Buffer + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName + +Arguments: + + TableName - Desired boot script table + Length - Length of information in bytes + Buffer - Content of information that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +{ + if (mBootScriptSave == NULL) { + return EFI_NOT_FOUND; + } + + mBootScriptSave->Write ( + mBootScriptSave, + TableName, + EFI_BOOT_SCRIPT_INFORMATION_OPCODE, + Length, + Buffer + ); + + return EFI_SUCCESS; + +} + +EFI_STATUS +EFIAPI +BootScriptSaveInformationUnicodeString ( + IN UINT16 TableName, + IN CHAR16 *String + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName, the information + is a unicode string. + +Arguments: + + TableName - Desired boot script table + String - The string that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +{ + return BootScriptSaveInformation ( + TableName, + (UINT32) EfiStrLen (String) * 2 + 2, + (EFI_PHYSICAL_ADDRESS)String + ); +} + +EFI_STATUS +EFIAPI +BootScriptSaveInformationAsciiString ( + IN UINT16 TableName, + IN CHAR8 *String + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName, the information + is a ascii string. + +Arguments: + + TableName - Desired boot script table + String - The string that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +{ + return BootScriptSaveInformation ( + TableName, + (UINT32) EfiAsciiStrLen (String) + 1, + (EFI_PHYSICAL_ADDRESS)String + ); +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf new file mode 100644 index 0000000000..645e04694e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf @@ -0,0 +1,46 @@ +#/*++ +# +# Copyright (c) 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiScriptLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = EfiScriptLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + EfiScriptLib.c + + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EFI_SOURCE)\Framework + . + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EFI_SOURCE) + $(EDK_SOURCE)\Foundation\Core\Dxe + +[libraries.common] + EdkFrameworkProtocolLib + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c new file mode 100644 index 0000000000..69fc8f7afe --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c @@ -0,0 +1,492 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + EfiUiLib.c + +Abstract: + Collection of usefull UI functions. + +Revision History: + +--*/ + +#include "EfiUiLib.h" + +#define IS_DIGIT(Ch) (((Ch) >= L'0') && ((Ch) <= L'9')) + +STATIC +EFI_STATUS +EfiStringToValue ( + OUT UINT64 *Val, + IN CHAR16 *String, + OUT UINT8 *EndIdx OPTIONAL + ) +/*++ + +Routine Description: + Parses and converts Unicode string to decimal value. + The returned value is 64-bit. + The string is expected in decimal format, + the string is parsed and format verified. + This function is missing from the libs. One day it maybe + replaced with a lib function when it'll become available. + +Arguments: + Val - pointer to the variable to store the value to + String - string that contains the value to parse and convert + EndIdx - index on which the parsing stopped. It points to the + first character that was not part of the returned Val. + It's valid only if the function returns success. + It's optional and it could be NULL. + +Returns: + EFI_SUCCESS - if successful + EFI_INVALID_PARAMETER - if String is in unexpected format + +--*/ +{ + UINT8 i; + UINT64 TempVal; + + TempVal = 0; + // + // Iterate upto 20 digits, only so many could fit in the UINT64 + // + for (i = 0; i <= 20; i++) { + // + // test if the next character is not a digit + // + if (!IS_DIGIT (String[i])) { + // + // If here, there is no more digits, + // return with success if there was at least one to process + // + if (i == 0) { + break; + } + + *Val = TempVal; + + if (EndIdx != NULL) { + *EndIdx = i; + } + + return EFI_SUCCESS; + } + // + // If here, there is a digit to process + // + TempVal = MultU64x32 (TempVal, 10) + String[i] - L'0'; + } + // + // if here, there was some sort of format error + // + return EFI_INVALID_PARAMETER; +} + +CHAR16 * +StrHzToString ( + OUT CHAR16 *String, + IN UINT64 Val + ) +/*++ + +Routine Description: + Converts frequency in Hz to Unicode string. + Three significant digits are delivered. + Used for things like processor info display. + +Arguments: + String - string that will contain the frequency. + Val - value to convert, minimum is 100000 i.e., 0.1 MHz. + +--*/ +// GC_TODO: function comment is missing 'Returns:' +{ + CHAR16 HlpStr[8]; + UINT32 i; + UINT32 IdxPoint; + UINT32 IdxUnits; + static CHAR16 *FreqUnits[] = { L" Hz", L" kHz", L" MHz", L" GHz", L" THz", L" PHz" }; + + // + // Normalize to 9999 or less. + // + i = 0; + while (Val >= 10000) { + Val = DivU64x32 (Val, 10, NULL); + i++; + } + // + // Make it rounded to the nearest, but only by + // a .3. This assures that .6 is not rounded. + // + if (Val >= 1000) { + Val += 3; + Val = DivU64x32 (Val, 10, NULL); + i++; + } + + EfiValueToString (String, Val, 0, 0); + + // + // Get rid of that cursed number! + // + if (!EfiStrCmp (&String[1], L"66")) { + String[2] = L'7'; + } + // + // Compute index to the units substrings. + // + IdxUnits = (i + 2) / 3; + + if (IdxUnits >= (sizeof (FreqUnits) / sizeof (FreqUnits)[0])) { + // + // Frequency is too high. + // + EfiStrCpy (String, L"OVERFLOW"); + return String; + } + // + // Compute the position of the decimal point. + // + IdxPoint = i % 3; + + // + // Test if decimal point needs to be inserted. + // + if (IdxPoint != 0) { + // + // Save the part after decimal point. + // + EfiStrCpy (HlpStr, &String[IdxPoint]); + + // + // Insert the point. + // + String[IdxPoint] = L'.'; + + // + // Reattach the saved part. + // + EfiStrCpy (&String[IdxPoint + 1], HlpStr); + + // + // Clear the insignificant zero. + // + if (String[3] == L'0') { + String[4 - IdxPoint] = L'\0'; + } + } + // + // Attach units. + // + EfiStrCat (String, FreqUnits[IdxUnits]); + + return String; +} + +CHAR16 * +StrBytesToString ( + OUT CHAR16 *String, + IN UINT64 Val + ) +/*++ + +Routine Description: + Converts size in bytes to Unicode string. + Used for memory/cache size display. + +Arguments: + String - string that will contain the value + Val - value to convert in bytes + +--*/ +// GC_TODO: function comment is missing 'Returns:' +{ + UINTN i; + UINTN Rem; + static CHAR16 *SizeUnits[] = { L" B", L" kB", L" MB", L" GB", L" TB", L" PB" }; + + for (i = 0; i < (sizeof (SizeUnits) / sizeof (SizeUnits)[0]); i++) { + + DivU64x32 (Val, 1024, &Rem); + + // + // Done if: + // 1. less than 1k + // 2. less than 8k and there are fractions of 1k + // + if ((Val < 1024) || ((Val < 8192) && (Rem != 0))) { + + EfiValueToString (String, Val, 0, 0); + + // + // attach units + // + EfiStrCat (String, SizeUnits[i]); + return String; + } + // + // prescale down by 1k with rounding to the nearest + // + Val = DivU64x32 (Val + 511, 1024, NULL); + } + + EfiStrCpy (String, L"OVERFLOW"); + + return String; +} + +CHAR16 * +StrVersionToString ( + OUT CHAR16 *String, + IN UINT8 Version + ) +/*++ + +Routine Description: + Converts 8 bit version value to Unicode string. + The upper nibble contains the upper part, the lower nibble contains the minor part. + The output format is .. + +Arguments: + String - string that will contain the value + Version - value to convert + +--*/ +// GC_TODO: function comment is missing 'Returns:' +{ + CHAR16 HlpStr[4]; + + EfiValueToString (String, 0x0F & Version, 0, 0); + EfiStrCat (String, L"."); + EfiValueToString (HlpStr, 0x0F & (Version >> 4), 0, 0); + EfiStrCat (String, HlpStr); + + return String; +} + +CHAR16 * +StrMacToString ( + OUT CHAR16 *String, + IN EFI_MAC_ADDRESS *MacAddr, + IN UINT32 AddrSize + ) +/*++ + +Routine Description: + Converts MAC address to Unicode string. + The value is 64-bit and the resulting string will be 12 + digit hex number in pairs of digits separated by dashes. + +Arguments: + String - string that will contain the value + Val - value to convert + +--*/ +// GC_TODO: function comment is missing 'Returns:' +// GC_TODO: MacAddr - add argument and description to function comment +// GC_TODO: AddrSize - add argument and description to function comment +{ + UINT32 i; + + for (i = 0; i < AddrSize; i++) { + + EfiValueToHexStr ( + &String[2 * i], + MacAddr->Addr[i] & 0xFF, + PREFIX_ZERO, + 2 + ); + } + // + // Terminate the string. + // + String[2 * AddrSize] = L'\0'; + + return String; +} + +CHAR16 * +StrIp4AdrToString ( + OUT CHAR16 *String, + IN EFI_IPv4_ADDRESS *Ip4Addr + ) +/*++ + +Routine Description: + Converts IP v4 address to Unicode string. + The value is 64-bit and the resulting string will + be four decimal values 0-255 separated by dots. + +Arguments: + String - string that will contain the value + Ip4Addr - value to convert from + +--*/ +// GC_TODO: function comment is missing 'Returns:' +{ + INT32 i; + CHAR16 HlpStr[4]; + + String[0] = L'\0'; + + for (i = 0; i < 4; i++) { + + EfiValueToString (HlpStr, Ip4Addr->Addr[i], 0, 0); + EfiStrCat (String, HlpStr); + + if (i < 3) { + EfiStrCat (String, L"."); + } + } + + return String; +} + +EFI_STATUS +StrStringToIp4Adr ( + OUT EFI_IPv4_ADDRESS *Ip4Addr, + IN CHAR16 *String + ) +/*++ + +Routine Description: + Parses and converts Unicode string to IP v4 address. + The value will 64-bit. + The string must be four decimal values 0-255 separated by dots. + The string is parsed and format verified. + +Arguments: + Ip4Addr - pointer to the variable to store the value to + String - string that contains the value to parse and convert + +Returns: + EFI_SUCCESS - if successful + EFI_INVALID_PARAMETER - if String contains invalid IP v4 format + +--*/ +{ + EFI_STATUS Status; + + EFI_IPv4_ADDRESS RetVal; + UINT64 TempVal; + UINT8 Idx; + UINT8 i; + + // + // Iterate the decimal values separated by dots + // + for (i = 0; i < 4; i++) { + // + // get the value of a decimal + // + Status = EfiStringToValue (&TempVal, String, &Idx); + if ((EFI_ERROR (Status)) || (TempVal > 255)) { + break; + } + + RetVal.Addr[i] = (UINT8) TempVal; + String += Idx; + + // + // test if it is the last decimal value + // + if (i == 3) { + if (String[0] != L'\0') { + // + // the string must end with string termination character + // + break; + } + + *Ip4Addr = RetVal; + return EFI_SUCCESS; + } + // + // Test for presence of a dot, it is required between the values + // + if (String++[0] != L'.') { + break; + } + } + + return EFI_INVALID_PARAMETER; +} + +CHAR16 * +Ascii2Unicode ( + OUT CHAR16 *UnicodeStr, + IN CHAR8 *AsciiStr + ) +/*++ + +Routine Description: + Converts ASCII characters to Unicode. + +Arguments: + UnicodeStr - the Unicode string to be written to. The buffer must be large enough. + AsciiStr - The ASCII string to be converted. + +Returns: + The address to the Unicode string - same as UnicodeStr. + +--*/ +{ + CHAR16 *Str; + + Str = UnicodeStr; + + while (TRUE) { + + *(UnicodeStr++) = (CHAR16) *AsciiStr; + + if (*(AsciiStr++) == '\0') { + return Str; + } + } +} + +CHAR8 * +Unicode2Ascii ( + OUT CHAR8 *AsciiStr, + IN CHAR16 *UnicodeStr + ) +/*++ + +Routine Description: + Converts ASCII characters to Unicode. + Assumes that the Unicode characters are only these defined in the ASCII set. + +Arguments: + AsciiStr - The ASCII string to be written to. The buffer must be large enough. + UnicodeStr - the Unicode string to be converted. + +Returns: + The address to the ASCII string - same as AsciiStr. + +--*/ +{ + CHAR8 *Str; + + Str = AsciiStr; + + while (TRUE) { + + *AsciiStr = (CHAR8) *(UnicodeStr++); + + if (*(AsciiStr++) == '\0') { + return Str; + } + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.inf new file mode 100644 index 0000000000..87af7f77a0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.inf @@ -0,0 +1,43 @@ +#/*++ +# +# Copyright (c) 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiUiLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = EfiUiLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + EfiUiLib.c + + +[includes.common] + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + +[libraries.common] + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h new file mode 100644 index 0000000000..65087c1ed1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Ascii + STRING_W is "" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR8 CHAR_W; +#define STRING_W(_s) _s + +#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +UINTN +UvSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN StrLen, + IN CONST CHAR16 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + StartOfBuffer - Wide char buffer to print the results of the parsing of Format into. + StrLen - Maximum number of characters to put into buffer. + Format - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c new file mode 100644 index 0000000000..7c44ad57ce --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +UvSPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + AsciiFormat[Index] = (CHAR8) FormatString[Index]; + } + + AsciiFormat[Index] = '\0'; + + Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR16) AsciiResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c new file mode 100644 index 0000000000..80d9b72835 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c @@ -0,0 +1,619 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Graphics.c + +Abstract: + + Support for Basic Graphics operations. + + BugBug: Currently *.BMP files are supported. This will be replaced + when Tiano graphics format is supported. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "GraphicsLib.h" + +EFI_STATUS +GetGraphicsBitMapFromFV ( + IN EFI_GUID *FileNameGuid, + OUT VOID **Image, + OUT UINTN *ImageSize + ) +/*++ + +Routine Description: + + Return the graphics image file named FileNameGuid into Image and return it's + size in ImageSize. All Firmware Volumes (FV) in the system are searched for the + file name. + +Arguments: + + FileNameGuid - File Name of graphics file in the FV(s). + + Image - Pointer to pointer to return graphics image. If NULL, a + buffer will be allocated. + + ImageSize - Size of the graphics Image in bytes. Zero if no image found. + + +Returns: + + EFI_SUCCESS - Image and ImageSize are valid. + EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size + EFI_NOT_FOUND - FileNameGuid not found + +--*/ +{ + return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize); +} + +EFI_STATUS +GetGraphicsBitMapFromFVEx ( + IN EFI_HANDLE ImageHandle, + IN EFI_GUID *FileNameGuid, + OUT VOID **Image, + OUT UINTN *ImageSize + ) +/*++ + +Routine Description: + + Return the graphics image file named FileNameGuid into Image and return it's + size in ImageSize. All Firmware Volumes (FV) in the system are searched for the + file name. + +Arguments: + + ImageHandle - The driver image handle of the caller. The parameter is used to + optimize the loading of the image file so that the FV from which + the driver image is loaded will be tried first. + + FileNameGuid - File Name of graphics file in the FV(s). + + Image - Pointer to pointer to return graphics image. If NULL, a + buffer will be allocated. + + ImageSize - Size of the graphics Image in bytes. Zero if no image found. + + +Returns: + + EFI_SUCCESS - Image and ImageSize are valid. + EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size + EFI_NOT_FOUND - FileNameGuid not found + +--*/ +{ + return GetImageEx ( + ImageHandle, + &gEfiDefaultBmpLogoGuid, + EFI_SECTION_RAW, + Image, + ImageSize, + FALSE + ); +} + + +EFI_STATUS +ConvertBmpToGopBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT VOID **GopBlt, + IN OUT UINTN *GopBltSize, + OUT UINTN *PixelHeight, + OUT UINTN *PixelWidth + ) +/*++ + +Routine Description: + + Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer + is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt + buffer is passed in it will be used if it is big enough. + +Arguments: + + BmpImage - Pointer to BMP file + + BmpImageSize - Number of bytes in BmpImage + + GopBlt - Buffer containing GOP version of BmpImage. + + GopBltSize - Size of GopBlt in bytes. + + PixelHeight - Height of GopBlt/BmpImage in pixels + + PixelWidth - Width of GopBlt/BmpImage in pixels + + +Returns: + + EFI_SUCCESS - GopBlt and GopBltSize are returned. + EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image + EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough. + GopBltSize will contain the required size. + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + +--*/ +{ + UINT8 *Image; + UINT8 *ImageHeader; + BMP_IMAGE_HEADER *BmpHeader; + BMP_COLOR_MAP *BmpColorMap; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; + UINTN BltBufferSize; + UINTN Index; + UINTN Height; + UINTN Width; + UINTN ImageIndex; + BOOLEAN IsAllocated; + + BmpHeader = (BMP_IMAGE_HEADER *) BmpImage; + if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') { + return EFI_UNSUPPORTED; + } + + if (BmpHeader->CompressionType != 0) { + return EFI_UNSUPPORTED; + } + + // + // Calculate Color Map offset in the image. + // + Image = BmpImage; + BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER)); + + // + // Calculate graphics image data address in the image + // + Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset; + ImageHeader = Image; + + BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); + IsAllocated = FALSE; + if (*GopBlt == NULL) { + *GopBltSize = BltBufferSize; + *GopBlt = EfiLibAllocatePool (*GopBltSize); + IsAllocated = TRUE; + if (*GopBlt == NULL) { + return EFI_OUT_OF_RESOURCES; + } + } else { + if (*GopBltSize < BltBufferSize) { + *GopBltSize = BltBufferSize; + return EFI_BUFFER_TOO_SMALL; + } + } + + *PixelWidth = BmpHeader->PixelWidth; + *PixelHeight = BmpHeader->PixelHeight; + + // + // Convert image from BMP to Blt buffer format + // + BltBuffer = *GopBlt; + for (Height = 0; Height < BmpHeader->PixelHeight; Height++) { + Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth]; + for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) { + switch (BmpHeader->BitPerPixel) { + case 1: + // + // Convert 1bit BMP to 24-bit color + // + for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) { + Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red; + Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green; + Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue; + Blt++; + Width++; + } + + Blt --; + Width --; + break; + + case 4: + // + // Convert BMP Palette to 24-bit color + // + Index = (*Image) >> 4; + Blt->Red = BmpColorMap[Index].Red; + Blt->Green = BmpColorMap[Index].Green; + Blt->Blue = BmpColorMap[Index].Blue; + if (Width < (BmpHeader->PixelWidth - 1)) { + Blt++; + Width++; + Index = (*Image) & 0x0f; + Blt->Red = BmpColorMap[Index].Red; + Blt->Green = BmpColorMap[Index].Green; + Blt->Blue = BmpColorMap[Index].Blue; + } + break; + + case 8: + // + // Convert BMP Palette to 24-bit color + // + Blt->Red = BmpColorMap[*Image].Red; + Blt->Green = BmpColorMap[*Image].Green; + Blt->Blue = BmpColorMap[*Image].Blue; + break; + + case 24: + Blt->Blue = *Image++; + Blt->Green = *Image++; + Blt->Red = *Image; + break; + + default: + if (IsAllocated) { + gBS->FreePool (*GopBlt); + *GopBlt = NULL; + } + return EFI_UNSUPPORTED; + break; + }; + + } + + ImageIndex = (UINTN) (Image - ImageHeader); + if ((ImageIndex % 4) != 0) { + // + // Bmp Image starts each row on a 32-bit boundary! + // + Image = Image + (4 - (ImageIndex % 4)); + } + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +LockKeyboards ( + IN CHAR16 *Password + ) +/*++ + +Routine Description: + Use Console Control Protocol to lock the Console In Spliter virtual handle. + This is the ConInHandle and ConIn handle in the EFI system table. All key + presses will be ignored until the Password is typed in. The only way to + disable the password is to type it in to a ConIn device. + +Arguments: + Password - Password used to lock ConIn device + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + EFI_STATUS Status; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl; + + Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + Status = ConsoleControl->LockStdIn (ConsoleControl, Password); + return Status; +} + +EFI_STATUS +EnableQuietBoot ( + IN EFI_GUID *LogoFile + ) +/*++ + +Routine Description: + + Use Console Control to turn off UGA based Simple Text Out consoles from going + to the UGA device. Put up LogoFile on every UGA device that is a console + +Arguments: + + LogoFile - File name of logo to display on the center of the screen. + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + return EnableQuietBootEx (LogoFile, NULL); +} + +EFI_STATUS +EnableQuietBootEx ( + IN EFI_GUID *LogoFile, + IN EFI_HANDLE ImageHandle + ) +/*++ + +Routine Description: + + Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going + to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console + +Arguments: + + LogoFile - File name of logo to display on the center of the screen. + ImageHandle - The driver image handle of the caller. The parameter is used to + optimize the loading of the logo file so that the FV from which + the driver image is loaded will be tried first. + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + EFI_STATUS Status; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl; + EFI_OEM_BADGING_PROTOCOL *Badging; + UINT32 SizeOfX; + UINT32 SizeOfY; + INTN DestX; + INTN DestY; + UINT8 *ImageData; + UINTN ImageSize; + UINTN BltSize; + UINT32 Instance; + EFI_BADGING_FORMAT Format; + EFI_BADGING_DISPLAY_ATTRIBUTE Attribute; + UINTN CoordinateX; + UINTN CoordinateY; + UINTN Height; + UINTN Width; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; + EFI_UGA_DRAW_PROTOCOL *UgaDraw; + UINT32 ColorDepth; + UINT32 RefreshRate; + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + + Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + UgaDraw = NULL; + // + // Try to open GOP first + // + Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID**)&GraphicsOutput); + if (EFI_ERROR (Status)) { + GraphicsOutput = NULL; + // + // Open GOP failed, try to open UGA + // + Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID**)&UgaDraw); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + } + + Badging = NULL; + Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID**)&Badging); + + ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics); + + if (GraphicsOutput != NULL) { + SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution; + SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution; + } else { + Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + } + + Instance = 0; + while (1) { + ImageData = NULL; + ImageSize = 0; + + if (Badging != NULL) { + Status = Badging->GetImage ( + Badging, + &Instance, + &Format, + &ImageData, + &ImageSize, + &Attribute, + &CoordinateX, + &CoordinateY + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Currently only support BMP format + // + if (Format != EfiBadgingFormatBMP) { + gBS->FreePool (ImageData); + continue; + } + } else { + Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, &ImageData, &ImageSize); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + CoordinateX = 0; + CoordinateY = 0; + Attribute = EfiBadgingDisplayAttributeCenter; + } + + Blt = NULL; + Status = ConvertBmpToGopBlt ( + ImageData, + ImageSize, + (VOID**)&Blt, + &BltSize, + &Height, + &Width + ); + if (EFI_ERROR (Status)) { + gBS->FreePool (ImageData); + if (Badging == NULL) { + return Status; + } else { + continue; + } + } + + switch (Attribute) { + case EfiBadgingDisplayAttributeLeftTop: + DestX = CoordinateX; + DestY = CoordinateY; + break; + + case EfiBadgingDisplayAttributeCenterTop: + DestX = (SizeOfX - Width) / 2; + DestY = CoordinateY; + break; + + case EfiBadgingDisplayAttributeRightTop: + DestX = (SizeOfX - Width - CoordinateX); + DestY = CoordinateY;; + break; + + case EfiBadgingDisplayAttributeCenterRight: + DestX = (SizeOfX - Width - CoordinateX); + DestY = (SizeOfY - Height) / 2; + break; + + case EfiBadgingDisplayAttributeRightBottom: + DestX = (SizeOfX - Width - CoordinateX); + DestY = (SizeOfY - Height - CoordinateY); + break; + + case EfiBadgingDisplayAttributeCenterBottom: + DestX = (SizeOfX - Width) / 2; + DestY = (SizeOfY - Height - CoordinateY); + break; + + case EfiBadgingDisplayAttributeLeftBottom: + DestX = CoordinateX; + DestY = (SizeOfY - Height - CoordinateY); + break; + + case EfiBadgingDisplayAttributeCenterLeft: + DestX = CoordinateX; + DestY = (SizeOfY - Height) / 2; + break; + + case EfiBadgingDisplayAttributeCenter: + DestX = (SizeOfX - Width) / 2; + DestY = (SizeOfY - Height) / 2; + break; + + default: + DestX = CoordinateX; + DestY = CoordinateY; + break; + } + + if ((DestX >= 0) && (DestY >= 0)) { + if (GraphicsOutput != NULL) { + Status = GraphicsOutput->Blt ( + GraphicsOutput, + Blt, + EfiBltBufferToVideo, + 0, + 0, + (UINTN) DestX, + (UINTN) DestY, + Width, + Height, + Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + ); + } else { + Status = UgaDraw->Blt ( + UgaDraw, + (EFI_UGA_PIXEL *) Blt, + EfiUgaBltBufferToVideo, + 0, + 0, + (UINTN) DestX, + (UINTN) DestY, + Width, + Height, + Width * sizeof (EFI_UGA_PIXEL) + ); + } + } + + gBS->FreePool (ImageData); + gBS->FreePool (Blt); + + if (Badging == NULL) { + break; + } + } + + return Status; +} + + +EFI_STATUS +DisableQuietBoot ( + VOID + ) +/*++ + +Routine Description: + + Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA + Simple Text Out screens will now be synced up with all non GOP/UGA output devices + +Arguments: + + NONE + +Returns: + + EFI_SUCCESS - GOP/UGA devices are back in text mode and synced up. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + EFI_STATUS Status; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl; + + Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.inf new file mode 100644 index 0000000000..2e0cd207f7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.inf @@ -0,0 +1,50 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Graphics.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = Graphics +COMPONENT_TYPE = LIBRARY + +[sources.common] + Graphics.c + Print.c + Print.h + Unicode\PrintWidth.h + Unicode\Sprint.c + + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Graphics\Unicode + $(EDK_SOURCE)\Foundation\Core\Dxe + +[libraries.common] + EfiDriverLib + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c new file mode 100644 index 0000000000..5cbcb53c22 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c @@ -0,0 +1,889 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "TianoCommon.h" +#include "EfiCommonLib.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" +#include EFI_PROTOCOL_DEFINITION (Hii) + +STATIC +CHAR_W * +GetFlagsAndWidth ( + IN CHAR_W *Format, + OUT UINTN *Flags, + OUT UINTN *Width, + IN OUT VA_LIST *Marker + ); + +STATIC +UINTN +GuidToString ( + IN EFI_GUID *Guid, + IN OUT CHAR_W *Buffer, + IN UINTN BufferSize + ); + +STATIC +UINTN +TimeToString ( + IN EFI_TIME *Time, + IN OUT CHAR_W *Buffer, + IN UINTN BufferSize + ); + +STATIC +UINTN +EfiStatusToString ( + IN EFI_STATUS Status, + OUT CHAR_W *Buffer, + IN UINTN BufferSize + ); + +static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = { + 0x00, 0x00, 0x00, 0x00, + 0x98, 0x00, 0x00, 0x00, + 0x00, 0x98, 0x00, 0x00, + 0x98, 0x98, 0x00, 0x00, + 0x00, 0x00, 0x98, 0x00, + 0x98, 0x00, 0x98, 0x00, + 0x00, 0x98, 0x98, 0x00, + 0x98, 0x98, 0x98, 0x00, + 0x10, 0x10, 0x10, 0x00, + 0xff, 0x10, 0x10, 0x00, + 0x10, 0xff, 0x10, 0x00, + 0xff, 0xff, 0x10, 0x00, + 0x10, 0x10, 0xff, 0x00, + 0xf0, 0x10, 0xff, 0x00, + 0x10, 0xff, 0xff, 0x00, + 0xff, 0xff, 0xff, 0x00, +}; + + +UINTN +_IPrint ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput, + IN EFI_UGA_DRAW_PROTOCOL *UgaDraw, + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto, + IN UINTN X, + IN UINTN Y, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background, + IN CHAR16 *fmt, + IN VA_LIST args + ) +/*++ + +Routine Description: + + Display string worker for: Print, PrintAt, IPrint, IPrintAt + +Arguments: + + GraphicsOutput - Graphics output protocol interface + + UgaDraw - UGA draw protocol interface + + Sto - Simple text out protocol interface + + X - X coordinate to start printing + + Y - Y coordinate to start printing + + Foreground - Foreground color + + Background - Background color + + fmt - Format string + + args - Print arguments + +Returns: + + EFI_SUCCESS - success + EFI_OUT_OF_RESOURCES - out of resources + +--*/ +{ + VOID *Buffer; + EFI_STATUS Status; + UINT16 GlyphWidth; + UINT32 GlyphStatus; + UINT16 StringIndex; + UINTN Index; + CHAR16 *UnicodeWeight; + EFI_NARROW_GLYPH *Glyph; + EFI_HII_PROTOCOL *Hii; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer; + UINT32 HorizontalResolution; + UINT32 VerticalResolution; + UINT32 ColorDepth; + UINT32 RefreshRate; + UINTN BufferLen; + UINTN LineBufferLen; + + GlyphStatus = 0; + + // + // For now, allocate an arbitrarily long buffer + // + Buffer = EfiLibAllocateZeroPool (0x10000); + if (Buffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (GraphicsOutput != NULL) { + HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution; + VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution; + } else { + UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); + } + ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0)); + + LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT; + LineBuffer = EfiLibAllocatePool (LineBufferLen); + if (LineBuffer == NULL) { + gBS->FreePool (Buffer); + return EFI_OUT_OF_RESOURCES; + } + + Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID**)&Hii); + if (EFI_ERROR (Status)) { + goto Error; + } + + VSPrint (Buffer, 0x10000, fmt, args); + + UnicodeWeight = (CHAR16 *) Buffer; + + for (Index = 0; UnicodeWeight[Index] != 0; Index++) { + if (UnicodeWeight[Index] == CHAR_BACKSPACE || + UnicodeWeight[Index] == CHAR_LINEFEED || + UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) { + UnicodeWeight[Index] = 0; + } + } + + BufferLen = EfiStrLen (Buffer); + + if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) { + Status = EFI_INVALID_PARAMETER; + goto Error; + } + + for (Index = 0; Index < BufferLen; Index++) { + StringIndex = (UINT16) Index; + Status = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus); + if (EFI_ERROR (Status)) { + goto Error; + } + + if (Foreground == NULL || Background == NULL) { + Status = Hii->GlyphToBlt ( + Hii, + (UINT8 *) Glyph, + mEfiColors[Sto->Mode->Attribute & 0x0f], + mEfiColors[Sto->Mode->Attribute >> 4], + BufferLen, + GlyphWidth, + GLYPH_HEIGHT, + &LineBuffer[Index * GLYPH_WIDTH] + ); + } else { + Status = Hii->GlyphToBlt ( + Hii, + (UINT8 *) Glyph, + *Foreground, + *Background, + BufferLen, + GlyphWidth, + GLYPH_HEIGHT, + &LineBuffer[Index * GLYPH_WIDTH] + ); + } + } + + // + // Blt a character to the screen + // + if (GraphicsOutput != NULL) { + Status = GraphicsOutput->Blt ( + GraphicsOutput, + LineBuffer, + EfiBltBufferToVideo, + 0, + 0, + X, + Y, + GLYPH_WIDTH * BufferLen, + GLYPH_HEIGHT, + GLYPH_WIDTH * BufferLen * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + ); + } else { + Status = UgaDraw->Blt ( + UgaDraw, + (EFI_UGA_PIXEL *) LineBuffer, + EfiUgaBltBufferToVideo, + 0, + 0, + X, + Y, + GLYPH_WIDTH * BufferLen, + GLYPH_HEIGHT, + GLYPH_WIDTH * BufferLen * sizeof (EFI_UGA_PIXEL) + ); + } + +Error: + gBS->FreePool (LineBuffer); + gBS->FreePool (Buffer); + return Status; +} + + +UINTN +PrintXY ( + IN UINTN X, + IN UINTN Y, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL + IN CHAR_W *Fmt, + ... + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to the default console + +Arguments: + + X - X coordinate to start printing + + Y - Y coordinate to start printing + + ForeGround - Foreground color + + BackGround - Background color + + Fmt - Format string + + ... - Print arguments + +Returns: + + Length of string printed to the console + +--*/ +{ + EFI_HANDLE Handle; + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + EFI_UGA_DRAW_PROTOCOL *UgaDraw; + EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto; + EFI_STATUS Status; + VA_LIST Args; + + VA_START (Args, Fmt); + + Handle = gST->ConsoleOutHandle; + + Status = gBS->HandleProtocol ( + Handle, + &gEfiGraphicsOutputProtocolGuid, + (VOID**)&GraphicsOutput + ); + + UgaDraw = NULL; + if (EFI_ERROR (Status)) { + GraphicsOutput = NULL; + + Status = gBS->HandleProtocol ( + Handle, + &gEfiUgaDrawProtocolGuid, + (VOID**)&UgaDraw + ); + + if (EFI_ERROR (Status)) { + return Status; + } + } + + Status = gBS->HandleProtocol ( + Handle, + &gEfiSimpleTextOutProtocolGuid, + (VOID**)&Sto + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args); +} + + +UINTN +SPrint ( + OUT CHAR_W *Buffer, + IN UINTN BufferSize, + IN CONST CHAR_W *Format, + ... + ) +/*++ + +Routine Description: + + SPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + +UINTN +VSPrint ( + OUT CHAR_W *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR_W *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + +Arguments: + + StartOfBuffer - Unicode buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means + no limit. + + FormatString - Unicode format string see file header for more details. + + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE]; + CHAR_W *Buffer; + CHAR8 *AsciiStr; + CHAR16 *UnicodeStr; + CHAR_W *Format; + UINTN Index; + UINTN Flags; + UINTN Width; + UINTN Count; + UINTN NumberOfCharacters; + UINTN BufferLeft; + UINT64 Value; + EFI_GUID *TmpGUID; + + // + // Process the format string. Stop if Buffer is over run. + // + + Buffer = StartOfBuffer; + Format = (CHAR_W *) FormatString; + NumberOfCharacters = BufferSize / sizeof (CHAR_W); + BufferLeft = BufferSize; + for (Index = 0; (*Format != '\0') && (Index < NumberOfCharacters - 1); Format++) { + if (*Format != '%') { + if ((*Format == '\n') && (Index < NumberOfCharacters - 2)) { + // + // If carage return add line feed + // + Buffer[Index++] = '\r'; + BufferLeft -= sizeof (CHAR_W); + } + + Buffer[Index++] = *Format; + BufferLeft -= sizeof (CHAR_W); + } else { + + // + // Now it's time to parse what follows after % + // + Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker); + switch (*Format) { + case 'X': + Flags |= PREFIX_ZERO; + Width = sizeof (UINT64) * 2; + + // + // break skiped on purpose + // + case 'x': + if ((Flags & LONG_TYPE) == LONG_TYPE) { + Value = VA_ARG (Marker, UINT64); + } else { + Value = VA_ARG (Marker, UINTN); + } + + EfiValueToHexStr (TempBuffer, Value, Flags, Width); + UnicodeStr = TempBuffer; + + for (; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) { + Buffer[Index++] = *UnicodeStr; + } + break; + + case 'd': + if ((Flags & LONG_TYPE) == LONG_TYPE) { + Value = VA_ARG (Marker, UINT64); + } else { + Value = (UINTN) VA_ARG (Marker, UINTN); + } + + EfiValueToString (TempBuffer, Value, Flags, Width); + UnicodeStr = TempBuffer; + + for (; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) { + Buffer[Index++] = *UnicodeStr; + } + break; + + case 's': + case 'S': + UnicodeStr = (CHAR16 *) VA_ARG (Marker, CHAR_W *); + if (UnicodeStr == NULL) { + UnicodeStr = L""; + } + + for (Count = 0; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++, Count++) { + Buffer[Index++] = *UnicodeStr; + } + // + // Add padding if needed + // + for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) { + Buffer[Index++] = ' '; + } + + break; + + case 'a': + AsciiStr = (CHAR8 *) VA_ARG (Marker, CHAR8 *); + if (AsciiStr == NULL) { + AsciiStr = ""; + } + + for (Count = 0; (*AsciiStr != '\0') && (Index < NumberOfCharacters - 1); AsciiStr++, Count++) { + Buffer[Index++] = (CHAR_W) * AsciiStr; + } + // + // Add padding if needed + // + for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) { + Buffer[Index++] = ' '; + } + break; + + case 'c': + Buffer[Index++] = (CHAR_W) VA_ARG (Marker, UINTN); + break; + + case 'g': + TmpGUID = VA_ARG (Marker, EFI_GUID *); + if (TmpGUID != NULL) { + Index += GuidToString ( + TmpGUID, + &Buffer[Index], + BufferLeft + ); + } + break; + + case 't': + Index += TimeToString ( + VA_ARG (Marker, EFI_TIME *), + &Buffer[Index], + BufferLeft + ); + break; + + case 'r': + Index += EfiStatusToString ( + VA_ARG (Marker, EFI_STATUS), + &Buffer[Index], + BufferLeft + ); + break; + + case '%': + Buffer[Index++] = *Format; + break; + + default: + // + // if the type is unknown print it to the screen + // + Buffer[Index++] = *Format; + } + + BufferLeft = BufferSize - Index * sizeof (CHAR_W); + } + } + + Buffer[Index++] = '\0'; + + return &Buffer[Index] - StartOfBuffer; +} + +STATIC +CHAR_W * +GetFlagsAndWidth ( + IN CHAR_W *Format, + OUT UINTN *Flags, + OUT UINTN *Width, + IN OUT VA_LIST *Marker + ) +/*++ + +Routine Description: + + VSPrint worker function that parses flag and width information from the + Format string and returns the next index into the Format string that needs + to be parsed. See file headed for details of Flag and Width. + +Arguments: + + Format - Current location in the VSPrint format string. + + Flags - Returns flags + + Width - Returns width of element + + Marker - Vararg list that may be paritally consumed and returned. + +Returns: + + Pointer indexed into the Format string for all the information parsed + by this routine. + +--*/ +{ + UINTN Count; + BOOLEAN Done; + + *Flags = 0; + *Width = 0; + for (Done = FALSE; !Done;) { + Format++; + + switch (*Format) { + + case '-': + *Flags |= LEFT_JUSTIFY; + break; + + case '+': + *Flags |= PREFIX_SIGN; + break; + + case ' ': + *Flags |= PREFIX_BLANK; + break; + + case ',': + *Flags |= COMMA_TYPE; + break; + + case 'L': + case 'l': + *Flags |= LONG_TYPE; + break; + + case '*': + *Width = VA_ARG (*Marker, UINTN); + break; + + case '0': + *Flags |= PREFIX_ZERO; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + Count = 0; + do { + Count = (Count * 10) +*Format - '0'; + Format++; + } while ((*Format >= '0') && (*Format <= '9')); + Format--; + *Width = Count; + break; + + default: + Done = TRUE; + } + } + + return Format; +} + +STATIC +UINTN +GuidToString ( + IN EFI_GUID *Guid, + IN CHAR_W *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + VSPrint worker function that prints an EFI_GUID. + +Arguments: + + Guid - Pointer to GUID to print. + + Buffer - Buffe to print Guid into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + + Size = SPrint ( + Buffer, + BufferSize, + STRING_W ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"), + (UINTN)Guid->Data1, + (UINTN)Guid->Data2, + (UINTN)Guid->Data3, + (UINTN)Guid->Data4[0], + (UINTN)Guid->Data4[1], + (UINTN)Guid->Data4[2], + (UINTN)Guid->Data4[3], + (UINTN)Guid->Data4[4], + (UINTN)Guid->Data4[5], + (UINTN)Guid->Data4[6], + (UINTN)Guid->Data4[7] + ); + + // + // SPrint will null terminate the string. The -1 skips the null + // + return Size - 1; +} + + +STATIC +UINTN +TimeToString ( + IN EFI_TIME *Time, + OUT CHAR_W *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + VSPrint worker function that prints EFI_TIME. + +Arguments: + + Time - Pointer to EFI_TIME sturcture to print. + + Buffer - Buffer to print Time into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + + Size = SPrint ( + Buffer, + BufferSize, + STRING_W ("%02d/%02d/%04d %02d:%02d"), + (UINTN)Time->Month, + (UINTN)Time->Day, + (UINTN)Time->Year, + (UINTN)Time->Hour, + (UINTN)Time->Minute + ); + + // + // SPrint will null terminate the string. The -1 skips the null + // + return Size - 1; +} + +STATIC +UINTN +EfiStatusToString ( + IN EFI_STATUS Status, + OUT CHAR_W *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + VSPrint worker function that prints EFI_STATUS as a string. If string is + not known a hex value will be printed. + +Arguments: + + Status - EFI_STATUS sturcture to print. + + Buffer - Buffer to print EFI_STATUS message string into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + CHAR8 *Desc; + + Desc = NULL; + + // + // Can't use global Status String Array as UINTN is not constant for EBC + // + if (Status == EFI_SUCCESS) { Desc = "Success"; } else + if (Status == EFI_LOAD_ERROR) { Desc = "Load Error"; } else + if (Status == EFI_INVALID_PARAMETER) { Desc = "Invalid Parameter"; } else + if (Status == EFI_UNSUPPORTED) { Desc = "Unsupported"; } else + if (Status == EFI_BAD_BUFFER_SIZE) { Desc = "Bad Buffer Size"; } else + if (Status == EFI_BUFFER_TOO_SMALL) { Desc = "Buffer Too Small"; } else + if (Status == EFI_NOT_READY) { Desc = "Not Ready"; } else + if (Status == EFI_DEVICE_ERROR) { Desc = "Device Error"; } else + if (Status == EFI_WRITE_PROTECTED) { Desc = "Write Protected"; } else + if (Status == EFI_OUT_OF_RESOURCES) { Desc = "Out of Resources"; } else + if (Status == EFI_VOLUME_CORRUPTED) { Desc = "Volume Corrupt"; } else + if (Status == EFI_VOLUME_FULL) { Desc = "Volume Full"; } else + if (Status == EFI_NO_MEDIA) { Desc = "No Media"; } else + if (Status == EFI_MEDIA_CHANGED) { Desc = "Media changed"; } else + if (Status == EFI_NOT_FOUND) { Desc = "Not Found"; } else + if (Status == EFI_ACCESS_DENIED) { Desc = "Access Denied"; } else + if (Status == EFI_NO_RESPONSE) { Desc = "No Response"; } else + if (Status == EFI_NO_MAPPING) { Desc = "No mapping"; } else + if (Status == EFI_TIMEOUT) { Desc = "Time out"; } else + if (Status == EFI_NOT_STARTED) { Desc = "Not started"; } else + if (Status == EFI_ALREADY_STARTED) { Desc = "Already started"; } else + if (Status == EFI_ABORTED) { Desc = "Aborted"; } else + if (Status == EFI_ICMP_ERROR) { Desc = "ICMP Error"; } else + if (Status == EFI_TFTP_ERROR) { Desc = "TFTP Error"; } else + if (Status == EFI_PROTOCOL_ERROR) { Desc = "Protocol Error"; } else + if (Status == EFI_WARN_UNKNOWN_GLYPH) { Desc = "Warning Unknown Glyph"; } else + if (Status == EFI_WARN_DELETE_FAILURE) { Desc = "Warning Delete Failure"; } else + if (Status == EFI_WARN_WRITE_FAILURE) { Desc = "Warning Write Failure"; } else + if (Status == EFI_WARN_BUFFER_TOO_SMALL) { Desc = "Warning Buffer Too Small"; } + + // + // If we found a match, copy the message to the user's buffer. Otherwise + // sprint the hex status code to their buffer. + // + if (Desc != NULL) { + Size = SPrint (Buffer, BufferSize, STRING_W ("%a"), Desc); + } else { + Size = SPrint (Buffer, BufferSize, STRING_W ("%X"), Status); + } + + return Size - 1; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.h new file mode 100644 index 0000000000..7d4394e53a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.h + +Abstract: + + Private data for Print.c + +--*/ + +#ifndef _PRINT_H_ +#define _PRINT_H_ + +#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +#define PREFIX_ZERO 0x20 + +// +// Largest number of characters that can be printed out. +// +#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h new file mode 100644 index 0000000000..14052f0fd4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Unicode + STRING_W is L"" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR16 CHAR_W; +#define STRING_W(_s) L##_s + +#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +#include "EfiCommonLib.h" +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c new file mode 100644 index 0000000000..6b70aa6544 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = AvSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +AvSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of ASPrint. + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + UnicodeFormat[Index] = (CHAR16) FormatString[Index]; + } + + UnicodeFormat[Index] = '\0'; + + Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR8) UnicodeResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h new file mode 100644 index 0000000000..65087c1ed1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Ascii + STRING_W is "" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR8 CHAR_W; +#define STRING_W(_s) _s + +#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +UINTN +UvSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN StrLen, + IN CONST CHAR16 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + StartOfBuffer - Wide char buffer to print the results of the parsing of Format into. + StrLen - Maximum number of characters to put into buffer. + Format - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c new file mode 100644 index 0000000000..7c44ad57ce --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +UvSPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + AsciiFormat[Index] = (CHAR8) FormatString[Index]; + } + + AsciiFormat[Index] = '\0'; + + Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR16) AsciiResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c new file mode 100644 index 0000000000..0cae8e9ca4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c @@ -0,0 +1,618 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Graphics.c + +Abstract: + + Support for Basic Graphics operations. + + BugBug: Currently *.BMP files are supported. This will be replaced + when Tiano graphics format is supported. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "GraphicsLib.h" + + +EFI_STATUS +GetGraphicsBitMapFromFV ( + IN EFI_GUID *FileNameGuid, + OUT VOID **Image, + OUT UINTN *ImageSize + ) +/*++ + +Routine Description: + + Return the graphics image file named FileNameGuid into Image and return it's + size in ImageSize. All Firmware Volumes (FV) in the system are searched for the + file name. + +Arguments: + + FileNameGuid - File Name of graphics file in the FV(s). + + Image - Pointer to pointer to return graphics image. If NULL, a + buffer will be allocated. + + ImageSize - Size of the graphics Image in bytes. Zero if no image found. + + +Returns: + + EFI_SUCCESS - Image and ImageSize are valid. + EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size + EFI_NOT_FOUND - FileNameGuid not found + +--*/ +{ + return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize); +} + +EFI_STATUS +GetGraphicsBitMapFromFVEx ( + IN EFI_HANDLE ImageHandle, + IN EFI_GUID *FileNameGuid, + OUT VOID **Image, + OUT UINTN *ImageSize + ) +/*++ + +Routine Description: + + Return the graphics image file named FileNameGuid into Image and return it's + size in ImageSize. All Firmware Volumes (FV) in the system are searched for the + file name. + +Arguments: + + ImageHandle - The driver image handle of the caller. The parameter is used to + optimize the loading of the image file so that the FV from which + the driver image is loaded will be tried first. + + FileNameGuid - File Name of graphics file in the FV(s). + + Image - Pointer to pointer to return graphics image. If NULL, a + buffer will be allocated. + + ImageSize - Size of the graphics Image in bytes. Zero if no image found. + + +Returns: + + EFI_SUCCESS - Image and ImageSize are valid. + EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size + EFI_NOT_FOUND - FileNameGuid not found + +--*/ +{ + return GetImageEx ( + ImageHandle, + &gEfiDefaultBmpLogoGuid, + EFI_SECTION_RAW, + Image, + ImageSize, + FALSE + ); +} + + +EFI_STATUS +ConvertBmpToGopBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT VOID **GopBlt, + IN OUT UINTN *GopBltSize, + OUT UINTN *PixelHeight, + OUT UINTN *PixelWidth + ) +/*++ + +Routine Description: + + Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer + is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt + buffer is passed in it will be used if it is big enough. + +Arguments: + + BmpImage - Pointer to BMP file + + BmpImageSize - Number of bytes in BmpImage + + GopBlt - Buffer containing GOP version of BmpImage. + + GopBltSize - Size of GopBlt in bytes. + + PixelHeight - Height of GopBlt/BmpImage in pixels + + PixelWidth - Width of GopBlt/BmpImage in pixels + + +Returns: + + EFI_SUCCESS - GopBlt and GopBltSize are returned. + EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image + EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough. + GopBltSize will contain the required size. + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + +--*/ +{ + UINT8 *Image; + UINT8 *ImageHeader; + BMP_IMAGE_HEADER *BmpHeader; + BMP_COLOR_MAP *BmpColorMap; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; + UINTN BltBufferSize; + UINTN Index; + UINTN Height; + UINTN Width; + UINTN ImageIndex; + BOOLEAN IsAllocated; + + BmpHeader = (BMP_IMAGE_HEADER *) BmpImage; + if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') { + return EFI_UNSUPPORTED; + } + + if (BmpHeader->CompressionType != 0) { + return EFI_UNSUPPORTED; + } + + // + // Calculate Color Map offset in the image. + // + Image = BmpImage; + BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER)); + + // + // Calculate graphics image data address in the image + // + Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset; + ImageHeader = Image; + + BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); + IsAllocated = FALSE; + if (*GopBlt == NULL) { + *GopBltSize = BltBufferSize; + *GopBlt = EfiLibAllocatePool (*GopBltSize); + IsAllocated = TRUE; + if (*GopBlt == NULL) { + return EFI_OUT_OF_RESOURCES; + } + } else { + if (*GopBltSize < BltBufferSize) { + *GopBltSize = BltBufferSize; + return EFI_BUFFER_TOO_SMALL; + } + } + + *PixelWidth = BmpHeader->PixelWidth; + *PixelHeight = BmpHeader->PixelHeight; + + // + // Convert image from BMP to Blt buffer format + // + BltBuffer = *GopBlt; + for (Height = 0; Height < BmpHeader->PixelHeight; Height++) { + Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth]; + for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) { + switch (BmpHeader->BitPerPixel) { + case 1: + // + // Convert 1bit BMP to 24-bit color + // + for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) { + Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red; + Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green; + Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue; + Blt++; + Width++; + } + + Blt --; + Width --; + break; + + case 4: + // + // Convert BMP Palette to 24-bit color + // + Index = (*Image) >> 4; + Blt->Red = BmpColorMap[Index].Red; + Blt->Green = BmpColorMap[Index].Green; + Blt->Blue = BmpColorMap[Index].Blue; + if (Width < (BmpHeader->PixelWidth - 1)) { + Blt++; + Width++; + Index = (*Image) & 0x0f; + Blt->Red = BmpColorMap[Index].Red; + Blt->Green = BmpColorMap[Index].Green; + Blt->Blue = BmpColorMap[Index].Blue; + } + break; + + case 8: + // + // Convert BMP Palette to 24-bit color + // + Blt->Red = BmpColorMap[*Image].Red; + Blt->Green = BmpColorMap[*Image].Green; + Blt->Blue = BmpColorMap[*Image].Blue; + break; + + case 24: + Blt->Blue = *Image++; + Blt->Green = *Image++; + Blt->Red = *Image; + break; + + default: + if (IsAllocated) { + gBS->FreePool (*GopBlt); + *GopBlt = NULL; + } + return EFI_UNSUPPORTED; + break; + }; + + } + + ImageIndex = (UINTN) (Image - ImageHeader); + if ((ImageIndex % 4) != 0) { + // + // Bmp Image starts each row on a 32-bit boundary! + // + Image = Image + (4 - (ImageIndex % 4)); + } + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +LockKeyboards ( + IN CHAR16 *Password + ) +/*++ + +Routine Description: + Use Console Control Protocol to lock the Console In Spliter virtual handle. + This is the ConInHandle and ConIn handle in the EFI system table. All key + presses will be ignored until the Password is typed in. The only way to + disable the password is to type it in to a ConIn device. + +Arguments: + Password - Password used to lock ConIn device + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + EFI_STATUS Status; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl; + + Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + Status = ConsoleControl->LockStdIn (ConsoleControl, Password); + return Status; +} + +EFI_STATUS +EnableQuietBoot ( + IN EFI_GUID *LogoFile + ) +/*++ + +Routine Description: + + Use Console Control to turn off UGA based Simple Text Out consoles from going + to the UGA device. Put up LogoFile on every UGA device that is a console + +Arguments: + + LogoFile - File name of logo to display on the center of the screen. + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + return EnableQuietBootEx (LogoFile, NULL); +} + + +EFI_STATUS +EnableQuietBootEx ( + IN EFI_GUID *LogoFile, + IN EFI_HANDLE ImageHandle + ) +/*++ + +Routine Description: + + Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going + to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console + +Arguments: + + LogoFile - File name of logo to display on the center of the screen. + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + EFI_STATUS Status; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl; + EFI_OEM_BADGING_PROTOCOL *Badging; + UINT32 SizeOfX; + UINT32 SizeOfY; + INTN DestX; + INTN DestY; + UINT8 *ImageData; + UINTN ImageSize; + UINTN BltSize; + UINT32 Instance; + EFI_BADGING_FORMAT Format; + EFI_BADGING_DISPLAY_ATTRIBUTE Attribute; + UINTN CoordinateX; + UINTN CoordinateY; + UINTN Height; + UINTN Width; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; + EFI_UGA_DRAW_PROTOCOL *UgaDraw; + UINT32 ColorDepth; + UINT32 RefreshRate; + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + + Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + UgaDraw = NULL; + // + // Try to open GOP first + // + Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, &GraphicsOutput); + if (EFI_ERROR (Status)) { + GraphicsOutput = NULL; + // + // Open GOP failed, try to open UGA + // + Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, &UgaDraw); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + } + + Badging = NULL; + Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, &Badging); + + ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics); + + if (GraphicsOutput != NULL) { + SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution; + SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution; + } else { + Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + } + + Instance = 0; + while (1) { + ImageData = NULL; + ImageSize = 0; + + if (Badging != NULL) { + Status = Badging->GetImage ( + Badging, + &Instance, + &Format, + &ImageData, + &ImageSize, + &Attribute, + &CoordinateX, + &CoordinateY + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Currently only support BMP format + // + if (Format != EfiBadgingFormatBMP) { + gBS->FreePool (ImageData); + continue; + } + } else { + Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, &ImageData, &ImageSize); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + CoordinateX = 0; + CoordinateY = 0; + Attribute = EfiBadgingDisplayAttributeCenter; + } + + Blt = NULL; + Status = ConvertBmpToGopBlt ( + ImageData, + ImageSize, + &Blt, + &BltSize, + &Height, + &Width + ); + if (EFI_ERROR (Status)) { + gBS->FreePool (ImageData); + if (Badging == NULL) { + return Status; + } else { + continue; + } + } + + switch (Attribute) { + case EfiBadgingDisplayAttributeLeftTop: + DestX = CoordinateX; + DestY = CoordinateY; + break; + + case EfiBadgingDisplayAttributeCenterTop: + DestX = (SizeOfX - Width) / 2; + DestY = CoordinateY; + break; + + case EfiBadgingDisplayAttributeRightTop: + DestX = (SizeOfX - Width - CoordinateX); + DestY = CoordinateY;; + break; + + case EfiBadgingDisplayAttributeCenterRight: + DestX = (SizeOfX - Width - CoordinateX); + DestY = (SizeOfY - Height) / 2; + break; + + case EfiBadgingDisplayAttributeRightBottom: + DestX = (SizeOfX - Width - CoordinateX); + DestY = (SizeOfY - Height - CoordinateY); + break; + + case EfiBadgingDisplayAttributeCenterBottom: + DestX = (SizeOfX - Width) / 2; + DestY = (SizeOfY - Height - CoordinateY); + break; + + case EfiBadgingDisplayAttributeLeftBottom: + DestX = CoordinateX; + DestY = (SizeOfY - Height - CoordinateY); + break; + + case EfiBadgingDisplayAttributeCenterLeft: + DestX = CoordinateX; + DestY = (SizeOfY - Height) / 2; + break; + + case EfiBadgingDisplayAttributeCenter: + DestX = (SizeOfX - Width) / 2; + DestY = (SizeOfY - Height) / 2; + break; + + default: + DestX = CoordinateX; + DestY = CoordinateY; + break; + } + + if ((DestX >= 0) && (DestY >= 0)) { + if (GraphicsOutput != NULL) { + Status = GraphicsOutput->Blt ( + GraphicsOutput, + Blt, + EfiBltBufferToVideo, + 0, + 0, + (UINTN) DestX, + (UINTN) DestY, + Width, + Height, + Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + ); + } else { + Status = UgaDraw->Blt ( + UgaDraw, + (EFI_UGA_PIXEL *) Blt, + EfiUgaBltBufferToVideo, + 0, + 0, + (UINTN) DestX, + (UINTN) DestY, + Width, + Height, + Width * sizeof (EFI_UGA_PIXEL) + ); + } + } + + gBS->FreePool (ImageData); + gBS->FreePool (Blt); + + if (Badging == NULL) { + break; + } + } + + return Status; +} + + +EFI_STATUS +DisableQuietBoot ( + VOID + ) +/*++ + +Routine Description: + + Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA + Simple Text Out screens will now be synced up with all non GOP/UGA output devices + +Arguments: + + NONE + +Returns: + + EFI_SUCCESS - GOP/UGA devices are back in text mode and synced up. + EFI_UNSUPPORTED - Logo not found + +--*/ +{ + EFI_STATUS Status; + EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl; + + Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.inf new file mode 100644 index 0000000000..02df84a020 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.inf @@ -0,0 +1,50 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Graphics.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = GraphicsLite +COMPONENT_TYPE = LIBRARY + +[sources.common] + Graphics.c + Print.c + Print.h + Unicode\PrintWidth.h + Unicode\Sprint.c + + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Graphics\Unicode + $(EDK_SOURCE)\Foundation\Core\Dxe + +[libraries.common] + EfiDriverLib + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c new file mode 100644 index 0000000000..94a1adb81c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c @@ -0,0 +1,436 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "TianoCommon.h" +#include "EfiCommonLib.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" +#include EFI_PROTOCOL_DEFINITION (Hii) + +static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = { + 0x00, 0x00, 0x00, 0x00, + 0x98, 0x00, 0x00, 0x00, + 0x00, 0x98, 0x00, 0x00, + 0x98, 0x98, 0x00, 0x00, + 0x00, 0x00, 0x98, 0x00, + 0x98, 0x00, 0x98, 0x00, + 0x00, 0x98, 0x98, 0x00, + 0x98, 0x98, 0x98, 0x00, + 0x10, 0x10, 0x10, 0x00, + 0xff, 0x10, 0x10, 0x00, + 0x10, 0xff, 0x10, 0x00, + 0xff, 0xff, 0x10, 0x00, + 0x10, 0x10, 0xff, 0x00, + 0xf0, 0x10, 0xff, 0x00, + 0x10, 0xff, 0xff, 0x00, + 0xff, 0xff, 0xff, 0x00, +}; + + +UINTN +_IPrint ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput, + IN EFI_UGA_DRAW_PROTOCOL *UgaDraw, + IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto, + IN UINTN X, + IN UINTN Y, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background, + IN CHAR16 *fmt, + IN VA_LIST args + ) +/*++ + +Routine Description: + + Display string worker for: Print, PrintAt, IPrint, IPrintAt + +Arguments: + + GraphicsOutput - Graphics output protocol interface + + UgaDraw - UGA draw protocol interface + + Sto - Simple text out protocol interface + + X - X coordinate to start printing + + Y - Y coordinate to start printing + + Foreground - Foreground color + + Background - Background color + + fmt - Format string + + args - Print arguments + +Returns: + + EFI_SUCCESS - success + EFI_OUT_OF_RESOURCES - out of resources + +--*/ +{ + VOID *Buffer; + EFI_STATUS Status; + UINT16 GlyphWidth; + UINT32 GlyphStatus; + UINT16 StringIndex; + UINTN Index; + CHAR16 *UnicodeWeight; + EFI_NARROW_GLYPH *Glyph; + EFI_HII_PROTOCOL *Hii; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer; + UINT32 HorizontalResolution; + UINT32 VerticalResolution; + UINT32 ColorDepth; + UINT32 RefreshRate; + UINTN BufferLen; + UINTN LineBufferLen; + + GlyphStatus = 0; + + // + // For now, allocate an arbitrarily long buffer + // + Buffer = EfiLibAllocateZeroPool (0x10000); + if (Buffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (GraphicsOutput != NULL) { + HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution; + VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution; + } else { + UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); + } + ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0)); + + LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT; + LineBuffer = EfiLibAllocatePool (LineBufferLen); + if (LineBuffer == NULL) { + gBS->FreePool (Buffer); + return EFI_OUT_OF_RESOURCES; + } + + Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, &Hii); + if (EFI_ERROR (Status)) { + goto Error; + } + + VSPrint (Buffer, 0x10000, fmt, args); + + UnicodeWeight = (CHAR16 *) Buffer; + + for (Index = 0; UnicodeWeight[Index] != 0; Index++) { + if (UnicodeWeight[Index] == CHAR_BACKSPACE || + UnicodeWeight[Index] == CHAR_LINEFEED || + UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) { + UnicodeWeight[Index] = 0; + } + } + + BufferLen = EfiStrLen (Buffer); + + if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) { + Status = EFI_INVALID_PARAMETER; + goto Error; + } + + for (Index = 0; Index < BufferLen; Index++) { + StringIndex = (UINT16) Index; + Status = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus); + if (EFI_ERROR (Status)) { + goto Error; + } + + if (Foreground == NULL || Background == NULL) { + Status = Hii->GlyphToBlt ( + Hii, + (UINT8 *) Glyph, + mEfiColors[Sto->Mode->Attribute & 0x0f], + mEfiColors[Sto->Mode->Attribute >> 4], + BufferLen, + GlyphWidth, + GLYPH_HEIGHT, + &LineBuffer[Index * GLYPH_WIDTH] + ); + } else { + Status = Hii->GlyphToBlt ( + Hii, + (UINT8 *) Glyph, + *Foreground, + *Background, + BufferLen, + GlyphWidth, + GLYPH_HEIGHT, + &LineBuffer[Index * GLYPH_WIDTH] + ); + } + } + + // + // Blt a character to the screen + // + if (GraphicsOutput != NULL) { + Status = GraphicsOutput->Blt ( + GraphicsOutput, + LineBuffer, + EfiBltBufferToVideo, + 0, + 0, + X, + Y, + GLYPH_WIDTH * BufferLen, + GLYPH_HEIGHT, + GLYPH_WIDTH * BufferLen * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + ); + } else { + Status = UgaDraw->Blt ( + UgaDraw, + (EFI_UGA_PIXEL *) LineBuffer, + EfiUgaBltBufferToVideo, + 0, + 0, + X, + Y, + GLYPH_WIDTH * BufferLen, + GLYPH_HEIGHT, + GLYPH_WIDTH * BufferLen * sizeof (EFI_UGA_PIXEL) + ); + } + +Error: + gBS->FreePool (LineBuffer); + gBS->FreePool (Buffer); + return Status; +} + + +UINTN +PrintXY ( + IN UINTN X, + IN UINTN Y, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL + IN CHAR_W *Fmt, + ... + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to the default console + +Arguments: + + X - X coordinate to start printing + + Y - Y coordinate to start printing + + ForeGround - Foreground color + + BackGround - Background color + + Fmt - Format string + + ... - Print arguments + +Returns: + + Length of string printed to the console + +--*/ +{ + EFI_HANDLE Handle; + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + EFI_UGA_DRAW_PROTOCOL *UgaDraw; + EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto; + EFI_STATUS Status; + VA_LIST Args; + + VA_START (Args, Fmt); + + Handle = gST->ConsoleOutHandle; + + Status = gBS->HandleProtocol ( + Handle, + &gEfiGraphicsOutputProtocolGuid, + &GraphicsOutput + ); + + UgaDraw = NULL; + if (EFI_ERROR (Status)) { + GraphicsOutput = NULL; + + Status = gBS->HandleProtocol ( + Handle, + &gEfiUgaDrawProtocolGuid, + &UgaDraw + ); + + if (EFI_ERROR (Status)) { + return Status; + } + } + + Status = gBS->HandleProtocol ( + Handle, + &gEfiSimpleTextOutProtocolGuid, + &Sto + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args); +} + + +UINTN +SPrint ( + OUT CHAR_W *Buffer, + IN UINTN BufferSize, + IN CONST CHAR_W *Format, + ... + ) +/*++ + +Routine Description: + + SPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + +UINTN +VSPrint ( + OUT CHAR_W *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR_W *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + +Arguments: + + StartOfBuffer - Unicode buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means + no limit. + + FormatString - Unicode format string see file header for more details. + + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + EFI_STATUS Status; + EFI_PRINT_PROTOCOL *PrintProtocol; + + Status = gBS->LocateProtocol ( + &gEfiPrintProtocolGuid, + NULL, + &PrintProtocol + ); + if (EFI_ERROR (Status)) { + return 0; + } else { + return PrintProtocol->VSPrint ( + StartOfBuffer, + BufferSize, + FormatString, + Marker + ); + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.h new file mode 100644 index 0000000000..7d4394e53a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.h + +Abstract: + + Private data for Print.c + +--*/ + +#ifndef _PRINT_H_ +#define _PRINT_H_ + +#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +#define PREFIX_ZERO 0x20 + +// +// Largest number of characters that can be printed out. +// +#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h new file mode 100644 index 0000000000..e8e8d6f353 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Unicode + STRING_W is L"" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR16 CHAR_W; +#define STRING_W(_s) L##_s + +#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +#include "EfiCommonLib.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c new file mode 100644 index 0000000000..6b70aa6544 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = AvSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +AvSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of ASPrint. + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + UnicodeFormat[Index] = (CHAR16) FormatString[Index]; + } + + UnicodeFormat[Index] = '\0'; + + Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR8) UnicodeResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/HobLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/HobLib.inf new file mode 100644 index 0000000000..6f34527a9c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/HobLib.inf @@ -0,0 +1,46 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# HobLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = HobLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + Hob.c + + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + +[libraries.common] + EdkGuidLib + EdkFrameworkGuidLib + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/hob.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/hob.c new file mode 100644 index 0000000000..ecfc7a22fb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/hob.c @@ -0,0 +1,521 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + hob.c + +Abstract: + + Support for hob operation + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "PeiHob.h" +#include EFI_GUID_DEFINITION (IoBaseHob) +#include EFI_GUID_DEFINITION (MemoryAllocationHob) + +VOID * +GetHob ( + IN UINT16 Type, + IN VOID *HobStart + ) +/*++ + +Routine Description: + + This function returns the first instance of a HOB type in a HOB list. + +Arguments: + + Type The HOB type to return. + HobStart The first HOB in the HOB list. + +Returns: + + HobStart There were no HOBs found with the requested type. + else Returns the first HOB with the matching type. + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = HobStart; + // + // Return input if not found + // + if (HobStart == NULL) { + return HobStart; + } + + // + // Parse the HOB list, stop if end of list or matching type found. + // + while (!END_OF_HOB_LIST (Hob)) { + + if (Hob.Header->HobType == Type) { + break; + } + + Hob.Raw = GET_NEXT_HOB (Hob); + } + + // + // Return input if not found + // + if (END_OF_HOB_LIST (Hob)) { + return HobStart; + } + + return (VOID *) (Hob.Raw); +} + +UINTN +GetHobListSize ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Get size of hob list. + +Arguments: + + HobStart - Start pointer of hob list + +Returns: + + Size of hob list. + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + UINTN Size; + + Hob.Raw = HobStart; + Size = 0; + + while (Hob.Header->HobType != EFI_HOB_TYPE_END_OF_HOB_LIST) { + Size += Hob.Header->HobLength; + Hob.Raw += Hob.Header->HobLength; + } + + Size += Hob.Header->HobLength; + + return Size; +} + +UINT32 +GetHobVersion ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Get hob version. + +Arguments: + + HobStart - Start pointer of hob list + +Returns: + + Hob version. + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = HobStart; + return Hob.HandoffInformationTable->Version; +} + +EFI_STATUS +GetHobBootMode ( + IN VOID *HobStart, + OUT EFI_BOOT_MODE *BootMode + ) +/*++ + +Routine Description: + + Get current boot mode. + +Arguments: + + HobStart - Start pointer of hob list + + BootMode - Current boot mode recorded in PHIT hob + +Returns: + + EFI_NOT_FOUND - Invalid hob header + + EFI_SUCCESS - Boot mode found + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = HobStart; + if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) { + return EFI_NOT_FOUND; + } + + *BootMode = Hob.HandoffInformationTable->BootMode; + return EFI_SUCCESS; +} + +EFI_STATUS +GetCpuHobInfo ( + IN VOID *HobStart, + OUT UINT8 *SizeOfMemorySpace, + OUT UINT8 *SizeOfIoSpace + ) +/*++ + +Routine Description: + + Get information recorded in CPU hob (Memory space size, Io space size) + +Arguments: + + HobStart - Start pointer of hob list + + SizeOfMemorySpace - Size of memory size + + SizeOfIoSpace - Size of IO size + +Returns: + + EFI_NOT_FOUND - CPU hob not found + + EFI_SUCCESS - CPU hob found and information got. + +--*/ +{ + EFI_PEI_HOB_POINTERS CpuHob; + + CpuHob.Raw = HobStart; + CpuHob.Raw = GetHob (EFI_HOB_TYPE_CPU, CpuHob.Raw); + if (CpuHob.Header->HobType != EFI_HOB_TYPE_CPU) { + return EFI_NOT_FOUND; + } + + *SizeOfMemorySpace = CpuHob.Cpu->SizeOfMemorySpace; + *SizeOfIoSpace = CpuHob.Cpu->SizeOfIoSpace; + return EFI_SUCCESS; +} + +EFI_STATUS +GetDxeCoreHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length, + OUT VOID **EntryPoint, + OUT EFI_GUID **FileName + ) +/*++ + +Routine Description: + + Get memory allocation hob created for DXE core and extract its information + +Arguments: + + HobStart - Start pointer of the hob list + BaseAddress - Start address of memory allocated for DXE core + Length - Length of memory allocated for DXE core + EntryPoint - DXE core file name + FileName - File Name + +Returns: + + EFI_NOT_FOUND - DxeCoreHob not found + EFI_SUCCESS - DxeCoreHob found and information got + +--*/ +{ + EFI_PEI_HOB_POINTERS DxeCoreHob; + + + DxeCoreHob.Raw = HobStart; + DxeCoreHob.Raw = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw); + while (DxeCoreHob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION && + !EfiCompareGuid (&DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.Name, + &gEfiHobMemeryAllocModuleGuid)) { + + DxeCoreHob.Raw = GET_NEXT_HOB (DxeCoreHob); + DxeCoreHob.Raw = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw); + + } + + if (DxeCoreHob.Header->HobType != EFI_HOB_TYPE_MEMORY_ALLOCATION) { + return EFI_NOT_FOUND; + } + + *BaseAddress = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress; + *Length = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength; + *EntryPoint = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint; + *FileName = &DxeCoreHob.MemoryAllocationModule->ModuleName; + + return EFI_SUCCESS; +} + +EFI_STATUS +GetNextFirmwareVolumeHob ( + IN OUT VOID **HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length + ) +/*++ + +Routine Description: + + Get next firmware volume hob from HobStart + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - Start address of next firmware volume + + Length - Length of next firmware volume + +Returns: + + EFI_NOT_FOUND - Next firmware volume not found + + EFI_SUCCESS - Next firmware volume found with address information + +--*/ +{ + EFI_PEI_HOB_POINTERS FirmwareVolumeHob; + + FirmwareVolumeHob.Raw = *HobStart; + if (END_OF_HOB_LIST (FirmwareVolumeHob)) { + return EFI_NOT_FOUND; + } + + FirmwareVolumeHob.Raw = GetHob (EFI_HOB_TYPE_FV, *HobStart); + if (FirmwareVolumeHob.Header->HobType != EFI_HOB_TYPE_FV) { + return EFI_NOT_FOUND; + } + + *BaseAddress = FirmwareVolumeHob.FirmwareVolume->BaseAddress; + *Length = FirmwareVolumeHob.FirmwareVolume->Length; + + *HobStart = GET_NEXT_HOB (FirmwareVolumeHob); + + return EFI_SUCCESS; +} + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) +EFI_STATUS +GetNextFirmwareVolume2Hob ( + IN OUT VOID **HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length, + OUT EFI_GUID *FileName + ) +/*++ + +Routine Description: + + Get next firmware volume2 hob from HobStart + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - Start address of next firmware volume + + Length - Length of next firmware volume + +Returns: + + EFI_NOT_FOUND - Next firmware volume not found + + EFI_SUCCESS - Next firmware volume found with address information + +--*/ +{ + EFI_PEI_HOB_POINTERS FirmwareVolumeHob; + + FirmwareVolumeHob.Raw = *HobStart; + if (END_OF_HOB_LIST (FirmwareVolumeHob)) { + return EFI_NOT_FOUND; + } + + FirmwareVolumeHob.Raw = GetHob (EFI_HOB_TYPE_FV2, *HobStart); + if (FirmwareVolumeHob.Header->HobType != EFI_HOB_TYPE_FV2) { + return EFI_NOT_FOUND; + } + + *BaseAddress = FirmwareVolumeHob.FirmwareVolume2->BaseAddress; + *Length = FirmwareVolumeHob.FirmwareVolume2->Length; + EfiCommonLibCopyMem(FileName,&FirmwareVolumeHob.FirmwareVolume2->FileName,sizeof(EFI_GUID)); + + *HobStart = GET_NEXT_HOB (FirmwareVolumeHob); + + return EFI_SUCCESS; +} +#endif + +EFI_STATUS +GetNextGuidHob ( + IN OUT VOID **HobStart, + IN EFI_GUID * Guid, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL + ) +/*++ + +Routine Description: + Get the next guid hob. + +Arguments: + HobStart A pointer to the start hob. + Guid A pointer to a guid. + Buffer A pointer to the buffer. + BufferSize Buffer size. + +Returns: + Status code. + + EFI_NOT_FOUND - Next Guid hob not found + + EFI_SUCCESS - Next Guid hob found and data for this Guid got + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_HOB_POINTERS GuidHob; + + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) { + + GuidHob.Raw = *HobStart; + if (END_OF_HOB_LIST (GuidHob)) { + return EFI_NOT_FOUND; + } + + GuidHob.Raw = GetHob (EFI_HOB_TYPE_GUID_EXTENSION, *HobStart); + if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) { + if (EfiCompareGuid (Guid, &GuidHob.Guid->Name)) { + Status = EFI_SUCCESS; + *Buffer = (VOID *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID)); + if (BufferSize != NULL) { + *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE); + } + } + } + + *HobStart = GET_NEXT_HOB (GuidHob); + } + + return Status; +} + + +#define PAL_ENTRY_HOB {0xe53cb8cc, 0xd62c, 0x4f74, 0xbd, 0xda, 0x31, 0xe5, 0x8d, 0xe5, 0x3e, 0x2} +EFI_GUID gPalEntryHob = PAL_ENTRY_HOB; + +EFI_STATUS +GetPalEntryHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *PalEntry + ) +/*++ + +Routine Description: + + Get PAL entry from PalEntryHob + +Arguments: + + HobStart - Start pointer of hob list + + PalEntry - Pointer to PAL entry + +Returns: + + Status code. + +--*/ +{ + VOID *Buffer; + UINTN BufferSize; + EFI_STATUS Status; + VOID *HobStart2; + + HobStart2 = HobStart; + Status = GetNextGuidHob ( + &HobStart2, + &gPalEntryHob, + &Buffer, + &BufferSize + ); + + *PalEntry = *((EFI_PHYSICAL_ADDRESS *) Buffer); + return Status; +} + + +EFI_STATUS +GetIoPortSpaceAddressHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress + ) +/*++ + +Routine Description: + + Get IO port space address from IoBaseHob. + +Arguments: + + HobStart - Start pointer of hob list + + IoPortSpaceAddress - IO port space address + +Returns: + + Status code + +--*/ +{ + + VOID *Buffer; + UINTN BufferSize; + EFI_STATUS Status; + VOID *HobStart2; + + HobStart2 = HobStart; + Status = GetNextGuidHob ( + &HobStart2, + &gEfiIoBaseHobGuid, + &Buffer, + &BufferSize + ); + + *IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) Buffer); + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ebc/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ebc/ProcDep.h new file mode 100644 index 0000000000..9509d25973 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ebc/ProcDep.h @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ProcDep.h + +Abstract: + + EBC- specific runtime lib. Only used to get a clean build of + EFI libraries. + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCombinationLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCombinationLib.h new file mode 100644 index 0000000000..a2e9f66284 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCombinationLib.h @@ -0,0 +1,294 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCombinationLib.h + +Abstract: + + Library functions that can be called in both PEI and DXE phase + +--*/ + +#ifndef _EFI_COMBINATION_LIB_H_ +#define _EFI_COMBINATION_LIB_H_ + +EFI_STATUS +EfiInitializeCommonDriverLib ( + IN EFI_HANDLE ImageHandle, + IN VOID *SystemTable + ) +/*++ + +Routine Description: + + Initialize lib function calling phase: PEI or DXE + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiCommonIoRead ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io read operation. + +Arguments: + + Width - Width of read operation + Address - Start IO address to read + Count - Read count + Buffer - Buffer to store result + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonIoWrite ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io write operation. + +Arguments: + + Width - Width of write operation + Address - Start IO address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciRead ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci read operation + +Arguments: + + Width - Width of PCI read + Address - PCI address to read + Count - Read count + Buffer - Output buffer for the read + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciWrite ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci write operation + +Arguments: + + Width - Width of PCI write + Address - PCI address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonStall ( + IN UINTN Microseconds + ) +/*++ + +Routine Description: + + Induces a fine-grained stall. + +Arguments: + + Microseconds - The number of microseconds to stall execution. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonAllocatePages ( + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ) +/*++ + +Routine Description: + + Allocates memory pages from the system. + +Arguments: + + Type - The type of allocation to perform. + MemoryType - The type of memory to allocate. + Pages - The number of contiguous pages to allocate. + Memory - Pointer to a physical address. + +Returns: + + EFI_OUT_OF_RESOURCES - The pages could not be allocated. + + EFI_INVALID_PARAMETER - Invalid parameter + + EFI_NOT_FOUND - The requested pages could not be found. + + EFI_SUCCESS - The requested pages were allocated. + +--*/ +; + +EFI_STATUS +EfiCommonLocateInterface ( + IN EFI_GUID *Guid, + OUT VOID **Interface + ) +/*++ + +Routine Description: + + Returns the first protocol instance that matches the given protocol. + +Arguments: + + Guid - Provides the protocol to search for. + Interface - On return, a pointer to the first interface that matches Protocol + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCommonLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCommonLib.h new file mode 100644 index 0000000000..4eaacc590f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiCommonLib.h @@ -0,0 +1,1359 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCommonLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_COMMON_LIB_H_ +#define _EFI_COMMON_LIB_H_ + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + TableGuid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +// +// ASPrint and AvSPrint definitions you must include the specific library +// to get the expected behavior from the two functions +// PEI: PeiLib +// Graphics: Dxe\Graphics\Unicode Dxe\Graphics\ASCII +// ASCII: Dxe\Print\ASCII +// Unicode: Dxe\Print\Unicode +// +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +AvSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN StrSize, + IN CONST CHAR8 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of ASPrint. + Process format and place the results in Buffer for narrow chars. + +Arguments: + + StartOfBuffer - Narrow char buffer to print the results of the parsing of Format into. + StrSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +// +// Lib functions which can be used in both PEI and DXE pahse +// +EFI_STATUS +EfiInitializeCommonDriverLib ( + IN EFI_HANDLE ImageHandle, + IN VOID *SystemTable + ) +/*++ + +Routine Description: + + Initialize lib function calling phase: PEI or DXE + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiCommonIoRead ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io read operation. + +Arguments: + + Width - Width of read operation + Address - Start IO address to read + Count - Read count + Buffer - Buffer to store result + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonIoWrite ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io write operation. + +Arguments: + + Width - Width of write operation + Address - Start IO address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciRead ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci read operation + +Arguments: + + Width - Width of PCI read + Address - PCI address to read + Count - Read count + Buffer - Output buffer for the read + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiCommonPciWrite ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci write operation + +Arguments: + + Width - Width of PCI write + Address - PCI address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +BOOLEAN +EfiCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +/*++ + +Routine Description: + + Compares two GUIDs + +Arguments: + + Guid1 - guid to compare + + Guid2 - guid to compare + +Returns: + TRUE if Guid1 == Guid2 + FALSE if Guid1 != Guid2 + +--*/ +; + +VOID +EfiCommonLibSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +/*++ + +Routine Description: + + Set Buffer to Value for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + + Value - Value of the set operation. + +Returns: + + None + +--*/ +; + +VOID +EfiCommonLibCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +; + +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Len + ) +/*++ + +Routine Description: + + Compares two memory buffers of a given length. + +Arguments: + + MemOne - First memory buffer + + MemTwo - Second memory buffer + + Len - Length of Mem1 and Mem2 memory regions to compare + +Returns: + + = 0 if MemOne == MemTwo + + > 0 if MemOne > MemTwo + + < 0 if MemOne < MemTwo + +--*/ +; + +VOID +EfiCommonLibZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + Set Buffer to 0 for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + +Returns: + + None + +--*/ +; + +// +// Min Max +// +#define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define EFI_MAX(a, b) (((a) > (b)) ? (a) : (b)) + +// +// Align a pointer. The pointer represented by ptr is aligned to the bound. +// The resulting pointer is always equal or greater (by no more than bound-1) +// than the ptr. I.e., if the ptr is already aligned, the result will be equal to ptr. +// Valid values for bound are powers of two: 2, 4, 8, 16, 32 etc. +// The returned pointer is VOID* this assignment-compatible with all pointer types. +// +#define EFI_ALIGN(ptr, bound) ((VOID *) (((UINTN) (ptr) + ((UINTN) (bound) - 1)) &~((UINTN) (bound) - 1))) + +// +// Alignment tests. +// +#define EFI_UINTN_ALIGN_MASK (sizeof (UINTN) - 1) +#define EFI_UINTN_ALIGNED(ptr) (((UINTN) (ptr)) & EFI_UINTN_ALIGN_MASK) + +// +// Integer division with rounding to the nearest rather than truncating. +// For example 8/3=2 but EFI_IDIV_ROUND(8,3)=3. 1/3=0 and EFI_IDIV_ROUND(1,3)=0. +// A half is rounded up e.g., EFI_IDIV_ROUND(1,2)=1 but 1/2=0. +// +#define EFI_IDIV_ROUND(r, s) ((r) / (s) + (((2 * ((r) % (s))) < (s)) ? 0 : 1)) + +// +// ReportStatusCode.c init +// +VOID * +EfiConstructStatusCodeData ( + IN UINT16 DataSize, + IN EFI_GUID *TypeGuid, + IN OUT EFI_STATUS_CODE_DATA *Data + ) +/*++ + +Routine Description: + + Construct stanader header for optional data passed into ReportStatusCode + +Arguments: + + DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header + TypeGuid - GUID to place in EFI_STATUS_CODE_DATA + Data - Buffer to use. + +Returns: + + Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA + +--*/ +; + +EFI_STATUS +EfiDebugVPrintWorker ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + Marker - VarArgs + + BufferSize - Size of Buffer. + + Buffer - Caller allocated buffer, contains ReportStatusCode extended data + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiDebugAssertWorker ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded DEADLOOP (). + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + FileName - File name of failing routine. + + LineNumber - Line number of failing ASSERT(). + + Description - Description, usually the assertion, + + BufferSize - Size of Buffer. + + Buffer - Caller allocated buffer, contains ReportStatusCode extendecd data + +Returns: + + Status code + +--*/ +; + +BOOLEAN +ReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +/*++ + +Routine Description: + + Extract assert information from status code data. + +Arguments: + + CodeType - Code type + Value - Code value + Data - Optional data associated with this status code. + Filename - Filename extracted from Data + Description - Description extracted from Data + LineNumber - Line number extracted from Data + +Returns: + + TRUE - Successfully extracted + + FALSE - Extraction failed + +--*/ +; + +BOOLEAN +ReportStatusCodeExtractDebugInfo ( + IN EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +/*++ + +Routine Description: + + Extract debug information from status code data. + +Arguments: + + Data - Optional data associated with status code. + ErrorLevel - Error level extracted from Data + Marker - VA_LIST extracted from Data + Format - Format string extracted from Data + +Returns: + + TRUE - Successfully extracted + + FALSE - Extraction failed + +--*/ +; + +BOOLEAN +CodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +/*++ + +Routine Description: + + Convert code value to an 8 bit post code + +Arguments: + + CodeType - Code type + Value - Code value + PostCode - Post code as output + +Returns: + + TRUE - Successfully converted + + FALSE - Convertion failed + +--*/ +; + +// +// math.c +// +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be multiplied with a 32 bit + value returns 64bit result. + No checking if the result is greater than 64bits + +Arguments: + + Multiplicand - multiplicand + Multiplier - multiplier + +Returns: + + Multiplicand * Multiplier + +--*/ +; + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be divided with a 32 bit value returns + 64bit result and the Remainder. + +Arguments: + + Dividend - dividend + Divisor - divisor + Remainder - buffer for remainder + +Returns: + + Dividend / Divisor + Remainder = Dividend mod Divisor + +--*/ +; + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be right shifted by 32 bits and returns the + shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift right. + +Returns: + + Value shifted right identified by the Count. + +--*/ +; + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be left shifted by 32 bits and + returns the shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift left. + +Returns: + + Value shifted left identified by the Count. + +--*/ +; + +UINT64 +Power10U64 ( + IN UINT64 Operand, + IN UINTN Power + ) +/*++ + +Routine Description: + + Raise 10 to the power of Power, and multiply the result with Operand + +Arguments: + + Operand - multiplicand + Power - power + +Returns: + + Operand * 10 ^ Power + +--*/ +; + +UINT8 +Log2 ( + IN UINT64 Operand + ) +/*++ + +Routine Description: + + Calculates and floors logarithms based on 2 + +Arguments: + + Operand - value to calculate logarithm + +Returns: + + The largest integer that is less than or equal + to the logarithm of Operand based on 2 + +--*/ +; + +UINT64 +GetPowerOfTwo ( + IN UINT64 Input + ) +/*++ + +Routine Description: + + Calculates the largest integer that is both + a power of two and less than Input + +Arguments: + + Input - value to calculate power of two + +Returns: + + the largest integer that is both a power of + two and less than Input + +--*/ +; + +// +// Unicode String primatives +// +VOID +EfiStrCpy ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +/*++ + +Routine Description: + Copy the Unicode string Source to Destination. + +Arguments: + Destination - Location to copy string + Source - String to copy + +Returns: + NONE + +--*/ +; + +VOID +EfiStrnCpy ( + OUT CHAR16 *Dst, + IN CHAR16 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Copy a string from source to destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +; + +UINTN +EfiStrLen ( + IN CHAR16 *String + ) +/*++ + +Routine Description: + Return the number of Unicode characters in String. This is not the same as + the length of the string in bytes. + +Arguments: + String - String to process + +Returns: + Number of Unicode characters in String + +--*/ +; + +UINTN +EfiStrSize ( + IN CHAR16 *String + ) +/*++ + +Routine Description: + Return the number bytes in the Unicode String. This is not the same as + the length of the string in characters. The string size includes the NULL + +Arguments: + String - String to process + +Returns: + Number of bytes in String + +--*/ +; + +INTN +EfiStrCmp ( + IN CHAR16 *String, + IN CHAR16 *String2 + ) +/*++ + +Routine Description: + Return the alphabetic relationship between two stirngs. + +Arguments: + String - Compare to String2 + + String2 - Compare to String + +Returns: + 0 - Identical + + > 0 - String is alphabeticly greater than String2 + + < 0 - String is alphabeticly less than String2 + +--*/ +; + +INTN +EfiStrnCmp ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN UINTN Length + ) +/*++ + +Routine Description: + This function compares the Unicode string String to the Unicode + string String2 for len characters. If the first len characters + of String is identical to the first len characters of String2, + then 0 is returned. If substring of String sorts lexicographically + after String2, the function returns a number greater than 0. If + substring of String sorts lexicographically before String2, the + function returns a number less than 0. + +Arguments: + String - Compare to String2 + String2 - Compare to String + Length - Number of Unicode characters to compare + +Returns: + 0 - The substring of String and String2 is identical. + > 0 - The substring of String sorts lexicographically after String2 + < 0 - The substring of String sorts lexicographically before String2 + +--*/ +; + +VOID +EfiStrCat ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +; + +VOID +EfiStrnCat ( + IN CHAR16 *Dest, + IN CHAR16 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +; + +UINTN +EfiAsciiStrLen ( + IN CHAR8 *String + ) +/*++ + +Routine Description: + Return the number of Ascii characters in String. This is not the same as + the length of the string in bytes. + +Arguments: + String - String to process + +Returns: + Number of Unicode characters in String + +--*/ +; + +CHAR8 * +EfiAsciiStrCpy ( + IN CHAR8 *Destination, + IN CHAR8 *Source + ) +/*++ + +Routine Description: + Copy the Ascii string Source to Destination. + +Arguments: + Destination - Location to copy string + Source - String to copy + +Returns: + Pointer just pass the end of Destination + +--*/ +; + +VOID +EfiAsciiStrnCpy ( + OUT CHAR8 *Dst, + IN CHAR8 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Copy the Ascii string from source to destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +; + +UINTN +EfiAsciiStrSize ( + IN CHAR8 *String + ) +/*++ + +Routine Description: + Return the number bytes in the Ascii String. This is not the same as + the length of the string in characters. The string size includes the NULL + +Arguments: + String - String to process + +Returns: + Number of bytes in String + +--*/ +; + + +INTN +EfiAsciiStrCmp ( + IN CHAR8 *String, + IN CHAR8 *String2 + ) +/*++ + +Routine Description: + Compare the Ascii string pointed by String to the string pointed by String2. + +Arguments: + String - String to process + + String2 - The other string to process + +Returns: + Return a positive integer if String is lexicall greater than String2; Zero if + the two strings are identical; and a negative interger if String is lexically + less than String2. +--*/ +; + +INTN +EfiAsciiStrnCmp ( + IN CHAR8 *String, + IN CHAR8 *String2, + IN UINTN Length + ) +/*++ + +Routine Description: + This function compares the ASCII string String to the ASCII + string String2 for len characters. If the first len characters + of String is identical to the first len characters of String2, + then 0 is returned. If substring of String sorts lexicographically + after String2, the function returns a number greater than 0. If + substring of String sorts lexicographically before String2, the + function returns a number less than 0. + +Arguments: + String - Compare to String2 + String2 - Compare to String + Length - Number of ASCII characters to compare + +Returns: + 0 - The substring of String and String2 is identical. + > 0 - The substring of String sorts lexicographically after String2 + < 0 - The substring of String sorts lexicographically before String2 + +--*/ +; + +VOID +EfiAsciiStrCat ( + IN CHAR8 *Destination, + IN CHAR8 *Source + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +; + +VOID +EfiAsciiStrnCat ( + IN CHAR8 *Destination, + IN CHAR8 *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +; + +// +// Print primitives +// +#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +#define PREFIX_ZERO 0x20 + +// +// Length of temp string buffer to store value string. +// +#define CHARACTER_NUMBER_FOR_VALUE 30 + +UINTN +EfiValueToHexStr ( + IN OUT CHAR16 *Buffer, + IN UINT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + VSPrint worker function that prints a Value as a hex number in Buffer + +Arguments: + + Buffer - Location to place ascii hex string of Value. + + Value - Hex value to convert to a string in Buffer. + + Flags - Flags to use in printing Hex string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +EfiValueToString ( + IN OUT CHAR16 *Buffer, + IN INT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + VSPrint worker function that prints a Value as a decimal number in Buffer + +Arguments: + + Buffer - Location to place ascii decimal number string of Value. + + Value - Decimal value to convert to a string in Buffer. + + Flags - Flags to use in printing decimal string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +; + +BOOLEAN +IsHexDigit ( + OUT UINT8 *Digit, + IN CHAR16 Char + ) +/*++ + + Routine Description: + Determines if a Unicode character is a hexadecimal digit. + The test is case insensitive. + + Arguments: + Digit - Pointer to byte that receives the value of the hex character. + Char - Unicode character to test. + + Returns: + TRUE - If the character is a hexadecimal digit. + FALSE - Otherwise. + +--*/ +; + +CHAR16 +NibbleToHexChar ( + UINT8 Nibble + ) +/*++ + + Routine Description: + Converts the low nibble of a byte to hex unicode character. + + Arguments: + Nibble - lower nibble of a byte. + + Returns: + Hex unicode character. + +--*/ +; + +EFI_STATUS +HexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ) +/*++ + + Routine Description: + Converts Unicode string to binary buffer. + The conversion may be partial. + The first character in the string that is not hex digit stops the conversion. + At a minimum, any blob of data could be represented as a hex string. + + Arguments: + Buf - Pointer to buffer that receives the data. + Len - Length in bytes of the buffer to hold converted data. + If routine return with EFI_SUCCESS, containing length of converted data. + If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired. + Str - String to be converted from. + ConvertedStrLen - Length of the Hex String consumed. + + Returns: + EFI_SUCCESS: Routine Success. + EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data. + EFI_ + +--*/ +; + +EFI_STATUS +BufToHexString ( + IN OUT CHAR16 *Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ) +/*++ + + Routine Description: + Converts binary buffer to Unicode string. + At a minimum, any blob of data could be represented as a hex string. + + Arguments: + Str - Pointer to the string. + HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character. + If routine return with EFI_SUCCESS, containing length of hex string buffer. + If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired. + Buf - Buffer to be converted from. + Len - Length in bytes of the buffer to be converted. + + Returns: + EFI_SUCCESS: Routine success. + EFI_BUFFER_TOO_SMALL: The hex string buffer is too small. + +--*/ +; + +VOID +EfiStrTrim ( + IN OUT CHAR16 *str, + IN CHAR16 CharC + ) +/*++ + +Routine Description: + + Removes (trims) specified leading and trailing characters from a string. + +Arguments: + + str - Pointer to the null-terminated string to be trimmed. On return, + str will hold the trimmed string. + CharC - Character will be trimmed from str. + +Returns: + + None + +--*/ +; +CHAR16* +EfiStrStr ( + IN CHAR16 *String, + IN CHAR16 *StrCharSet + ) +/*++ + +Routine Description: + + Find a substring. + +Arguments: + + String - Null-terminated string to search. + StrCharSet - Null-terminated string to search for. + +Returns: + The address of the first occurrence of the matching substring if successful, or NULL otherwise. +--*/ +; + +CHAR8* +EfiAsciiStrStr ( + IN CHAR8 *String, + IN CHAR8 *StrCharSet + ) +/*++ + +Routine Description: + + Find a Ascii substring. + +Arguments: + + String - Null-terminated Ascii string to search. + StrCharSet - Null-terminated Ascii string to search for. + +Returns: + The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise. +--*/ +; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h new file mode 100644 index 0000000000..03e660b247 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h @@ -0,0 +1,1203 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiDriverLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_DRIVER_LIB_H_ +#define _EFI_DRIVER_LIB_H_ + +#include "EfiStatusCode.h" +#include "EfiCommonLib.h" +#include "EfiPerf.h" +#include "LinkedList.h" +#include "GetImage.h" +#include "EfiImageFormat.h" + +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_GUID_DEFINITION (FrameworkDevicePath) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) +#include EFI_PROTOCOL_DEFINITION (DataHub) +#include EFI_PROTOCOL_DEFINITION (DriverBinding) +#include EFI_PROTOCOL_DEFINITION (ComponentName) +#include EFI_PROTOCOL_DEFINITION (ComponentName2) +#include EFI_PROTOCOL_DEFINITION (DriverConfiguration) +#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics) + +#include EFI_PROTOCOL_DEFINITION (DebugMask) + +typedef struct { + CHAR8 *Language; + CHAR16 *UnicodeString; +} EFI_UNICODE_STRING_TABLE; +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#define LANGUAGE_RFC_3066 +#define LANGUAGE_CODE_ENGLISH "en-US" +#else +#define LANGUAGE_ISO_639_2 +#define LANGUAGE_CODE_ENGLISH "eng" +#endif + +// +// Macros for EFI Driver Library Functions that are really EFI Boot Services +// +#define EfiCopyMem(_Destination, _Source, _Length) gBS->CopyMem ((_Destination), (_Source), (_Length)) +#define EfiSetMem(_Destination, _Length, _Value) gBS->SetMem ((_Destination), (_Length), (_Value)) +#define EfiZeroMem(_Destination, _Length) gBS->SetMem ((_Destination), (_Length), 0) + +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_DXE_SERVICES *gDS; +extern EFI_RUNTIME_SERVICES *gRT; +extern EFI_SYSTEM_TABLE *gST; +extern UINTN gErrorLevel; +extern EFI_GUID gEfiCallerIdGuid; +extern EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface; + +EFI_STATUS +EfiInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +DxeInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiLibInstallDriverBinding ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle + ) +/*++ + +Routine Description: + + Intialize a driver by installing the Driver Binding Protocol onto the + driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. This function also initializes the EFI Driver + Library that initializes the global variables gST, gBS, gRT. + +Arguments: + + ImageHandle - The image handle of the driver + + SystemTable - The EFI System Table that was passed to the driver's entry point + + DriverBinding - A Driver Binding Protocol instance that this driver is producing + + DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + +Returns: + + EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle + + Otherwise, then return status from gBS->InstallProtocolInterface() + +--*/ +; + +EFI_STATUS +EfiLibInstallAllDriverProtocols ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, + IN EFI_HANDLE DriverBindingHandle, +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + IN EFI_COMPONENT_NAME2_PROTOCOL *ComponentName, +#else + IN EFI_COMPONENT_NAME_PROTOCOL *ComponentName, +#endif + IN EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, + IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics + ) +/*++ + +Routine Description: + + Intialize a driver by installing the Driver Binding Protocol onto the + driver's DriverBindingHandle. This is typically the same as the driver's + ImageHandle, but it can be different if the driver produces multiple + DriverBinding Protocols. This function also initializes the EFI Driver + Library that initializes the global variables gST, gBS, gRT. + +Arguments: + + ImageHandle - The image handle of the driver + + SystemTable - The EFI System Table that was passed to the driver's entry point + + DriverBinding - A Driver Binding Protocol instance that this driver is producing + + DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this + parameter is NULL, then a new handle is created. + + ComponentName - A Component Name Protocol instance that this driver is producing + + DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing + + DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing + +Returns: + + EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle + + Otherwise, then return status from gBS->InstallProtocolInterface() + +--*/ +; + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + TableGuid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +BOOLEAN +EfiLibCompareLanguage ( + CHAR8 *Language1, + CHAR8 *Language2 + ) +/*++ + +Routine Description: + + Compare two languages to say whether they are identical. + +Arguments: + + Language1 - first language + Language2 - second language + +Returns: + + TRUE - identical + FALSE - not identical + +--*/ +; + +// +// DevicePath.c +// +BOOLEAN +EfiIsDevicePathMultiInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + Return TRUE is this is a multi instance device path. + +Arguments: + DevicePath - A pointer to a device path data structure. + + +Returns: + TRUE - If DevicePath is multi instance. + FALSE - If DevicePath is not multi instance. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Function retrieves the next device path instance from a device path data structure. + +Arguments: + DevicePath - A pointer to a device path data structure. + + Size - A pointer to the size of a device path instance in bytes. + +Returns: + + This function returns a pointer to the current device path instance. + In addition, it returns the size in bytes of the current device path instance in Size, + and a pointer to the next device path instance in DevicePath. + If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + +--*/ +; + +UINTN +EfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + + Calculate the size of a whole device path. + +Arguments: + + DevPath - The pointer to the device path data. + +Returns: + + Size of device path data structure.. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a Src1 and Src2 together. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + + A pointer to the new device path is returned. + NULL is returned if space for the new device path could not be allocated from pool. + It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +/*++ + +Routine Description: + + Locate device path protocol interface on a device handle. + +Arguments: + + Handle - The device handle + +Returns: + + Device path protocol interface located. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiDuplicateDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + Duplicate a new device path data structure from the old one. + +Arguments: + DevPath - A pointer to a device path data structure. + +Returns: + A pointer to the new allocated device path data. + Caller must free the memory used by DevicePath if it is no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a device path node to the end of another device path. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + This function returns a pointer to the new device path. + If there is not enough temporary pool memory available to complete this function, + then NULL is returned. + + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ) +/*++ + +Routine Description: + Create a device path that appends a MEDIA_DEVICE_PATH with + FileNameGuid to the device path of DeviceHandle. + +Arguments: + Device - Optional Device Handle to use as Root of the Device Path + + FileName - FileName + +Returns: + EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory + or NULL pointer. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *Src, + IN EFI_DEVICE_PATH_PROTOCOL *Instance + ) +/*++ + +Routine Description: + + Append a device path instance to another. + +Arguments: + + Src - The device path instance to be appended with. + Instance - The device path instance appending the other. + +Returns: + + The contaction of these two. + +--*/ +; + +// +// Lock.c +// +typedef struct { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + UINTN Lock; +} EFI_LOCK; + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + Note on a check build ASSERT()s are used to ensure proper + lock usage. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - The task priority level of the lock + + +Returns: + + An initialized Efi Lock structure. + +--*/ +; + +// +// Macro to initialize the state of a lock when a lock variable is declared +// +#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0} + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + None + +--*/ +; + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +; + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + +Arguments: + + Lock - The lock to release + +Returns: + + None + +--*/ +; + +VOID * +EfiLibAllocatePool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiBootServicesData pool of size AllocationSize + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateRuntimePool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiRuntimeServicesData pool of size AllocationSize + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateZeroPool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiBootServicesData pool of size AllocationSize and set memory to zero. + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate EfiRuntimeServicesData pool of size AllocationSize and set memory to zero. + +Arguments: + + AllocationSize - Pool size + +Returns: + + Pointer to the pool allocated + +--*/ +; + +VOID * +EfiLibAllocateCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool and use a buffer provided by + caller to fill it. + +Arguments: + + AllocationSize - The size to allocate + + Buffer - Buffer that will be filled into the buffer allocated + +Returns: + + Pointer of the buffer allocated. + +--*/ +; + +VOID * +EfiLibAllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Allocate RuntimeServicesData pool and use a buffer provided by + caller to fill it. + +Arguments: + + AllocationSize - The size to allocate + + Buffer - Buffer that will be filled into the buffer allocated + +Returns: + + Pointer of the buffer allocated. + +--*/ +; + +// +// Event.c +// +EFI_EVENT +EfiLibCreateProtocolNotifyEvent ( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT VOID **Registration + ) +/*++ + +Routine Description: + + Create a protocol notification event and return it. + +Arguments: + + ProtocolGuid - Protocol to register notification event on. + + NotifyTpl - Maximum TPL to single the NotifyFunction. + + NotifyFunction - EFI notification routine. + + NotifyContext - Context passed into Event when it is created. + + Registration - Registration key returned from RegisterProtocolNotify(). + +Returns: + + The EFI_EVENT that has been registered to be signaled when a ProtocolGuid + is added to the system. + +--*/ +; + +EFI_STATUS +EfiLibNamedEventSignal ( + IN EFI_GUID *Name + ) +/*++ + +Routine Description: + Signals a named event. All registered listeners will run. + The listeners should register using EfiLibNamedEventListen() function. + + NOTE: For now, the named listening/signalling is implemented + on a protocol interface being installed and uninstalled. + In the future, this maybe implemented based on a dedicated mechanism. + +Arguments: + Name - Name to perform the signaling on. The name is a GUID. + +Returns: + EFI_SUCCESS if successfull. + +--*/ +; + +EFI_STATUS +EfiLibNamedEventListen ( + IN EFI_GUID * Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext + ) +/*++ + +Routine Description: + Listenes to signals on the name. + EfiLibNamedEventSignal() signals the event. + + NOTE: For now, the named listening/signalling is implemented + on a protocol interface being installed and uninstalled. + In the future, this maybe implemented based on a dedicated mechanism. + +Arguments: + Name - Name to register the listener on. + NotifyTpl - Maximum TPL to singnal the NotifyFunction. + NotifyFunction - The listener routine. + NotifyContext - Context passed into the listener routine. + +Returns: + EFI_SUCCESS if successful. + +--*/ +; + +// +// Handle.c +// +EFI_STATUS +EfiLibLocateHandleProtocolByProtocols ( + IN OUT EFI_HANDLE * Handle, OPTIONAL + OUT VOID **Interface, OPTIONAL + ... + ) +/*++ +Routine Description: + + Function locates Protocol and/or Handle on which all Protocols specified + as a variable list are installed. + It supports continued search. The caller must assure that no handles are added + or removed while performing continued search, by e.g., rising the TPL and not + calling any handle routines. Otherwise the behavior is undefined. + +Arguments: + + Handle - The address of handle to receive the handle on which protocols + indicated by the variable list are installed. + If points to NULL, all handles are searched. If pointing to a + handle returned from previous call, searches starting from next handle. + If NULL, the parameter is ignored. + + Interface - The address of a pointer to a protocol interface that will receive + the interface indicated by first variable argument. + If NULL, the parameter is ignored. + + ... - A variable argument list containing protocol GUIDs. Must end with NULL. + +Returns: + + EFI_SUCCESS - All the protocols where found on same handle. + EFI_NOT_FOUND - A Handle with all the protocols installed was not found. + Other values as may be returned from LocateHandleBuffer() or HandleProtocol(). + +--*/ +; + +// +// Debug.c init +// +EFI_STATUS +EfiDebugAssertInit ( + VOID + ) +/*++ + +Routine Description: + + Locate Debug Assert Protocol and set as mDebugAssert + +Arguments: + + None + +Returns: + + Status code + +--*/ +; + +// +// Unicode String Support +// +EFI_STATUS +EfiLibLookupUnicodeString ( + CHAR8 *Language, + CHAR8 *SupportedLanguages, + EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + CHAR16 **UnicodeString + ) +/*++ + +Routine Description: + + Translate a unicode string to a specified language if supported. + +Arguments: + + Language - The name of language to translate to + SupportedLanguages - Supported languages set + UnicodeStringTable - Pointer of one item in translation dictionary + UnicodeString - The translated string + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + EFI_UNSUPPORTED - System not supported this language or this string translation + EFI_SUCCESS - String successfully translated + +--*/ +; + +EFI_STATUS +EfiLibAddUnicodeString ( + CHAR8 *Language, + CHAR8 *SupportedLanguages, + EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + CHAR16 *UnicodeString + ) +/*++ + +Routine Description: + + Add an translation to the dictionary if this language if supported. + +Arguments: + + Language - The name of language to translate to + SupportedLanguages - Supported languages set + UnicodeStringTable - Translation dictionary + UnicodeString - The corresponding string for the language to be translated to + +Returns: + + EFI_INVALID_PARAMETER - Invalid parameter + EFI_UNSUPPORTED - System not supported this language + EFI_ALREADY_STARTED - Already has a translation item of this language + EFI_OUT_OF_RESOURCES - No enough buffer to be allocated + EFI_SUCCESS - String successfully translated + +--*/ +; + +EFI_STATUS +EfiLibFreeUnicodeStringTable ( + EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ) +/*++ + +Routine Description: + + Free a string table. + +Arguments: + + UnicodeStringTable - The string table to be freed. + +Returns: + + EFI_SUCCESS - The table successfully freed. + +--*/ +; + +EFI_STATUS +EfiLibReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +/*++ + +Routine Description: + + Report status code. + +Arguments: + + Type - Code type + Value - Code value + Instance - Instance number + CallerId - Caller name + DevicePath - Device path that to be reported + +Returns: + + Status code. + + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + +--*/ +; + +EFI_STATUS +ReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId OPTIONAL, + IN EFI_DEVICE_PATH_PROTOCOL * DevicePath + ) +/*++ + +Routine Description: + + Report device path through status code. + +Arguments: + + Type - Code type + Value - Code value + Instance - Instance number + CallerId - Caller name + DevicePath - Device path that to be reported + +Returns: + + Status code. + + EFI_OUT_OF_RESOURCES - No enough buffer could be allocated + +--*/ +; + +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +; + +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +; + +VOID +EFIAPI +EfiInitializeFwVolDevicepathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN EFI_GUID *NameGuid + ) +/*++ +Routine Description: + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + +Arguments: + FvDevicePathNode - Pointer to a FV device path node to initialize + NameGuid - FV file name to use in FvDevicePathNode + +--*/ +; + +EFI_GUID * +EFIAPI +EfiGetNameGuidFromFwVolDevicePathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ) +/*++ +Routine Description: + Check to see if the Firmware Volume (FV) Media Device Path is valid. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. The return value to this + function points to a location in FvDevicePathNode and it does not allocate + new memory for the GUID pointer that is returned. + +Arguments: + FvDevicePathNode - Pointer to FV device path to check + +Return: + NULL - FvDevicePathNode is not valid. + Other - FvDevicePathNode is valid and pointer to NameGuid was returned. + +--*/ +; + +VOID +EfiLibSafeFreePool ( + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Free pool safely. + +Arguments: + + Buffer - The allocated pool entry to free + +Returns: + + Pointer of the buffer allocated. + +--*/ +; + +EFI_STATUS +EfiLibTestManagedDevice ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE DriverBindingHandle, + IN EFI_GUID *ManagedProtocolGuid + ) +/*++ + +Routine Description: + + Test to see if the controller is managed by a specific driver. + +Arguments: + + ControllerHandle - Handle for controller to test + + DriverBindingHandle - Driver binding handle for controller + + ManagedProtocolGuid - The protocol guid the driver opens on controller + +Returns: + + EFI_SUCCESS - The controller is managed by the driver + + EFI_UNSUPPORTED - The controller is not managed by the driver + +--*/ +; + +EFI_STATUS +EfiLibTestChildHandle ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle, + IN EFI_GUID *ConsumedGuid + ) +/*++ + +Routine Description: + + Test to see if the child handle is the child of the controller + +Arguments: + + ControllerHandle - Handle for controller (parent) + + ChildHandle - Child handle to test + + ConsumsedGuid - Protocol guid consumed by child from controller + +Returns: + + EFI_SUCCESS - The child handle is the child of the controller + + EFI_UNSUPPORTED - The child handle is not the child of the controller + +--*/ +; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiHobLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiHobLib.h new file mode 100644 index 0000000000..cbf1c8d250 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiHobLib.h @@ -0,0 +1,298 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiHobLib.h + +Abstract: + + +--*/ + +#ifndef _EFI_HOB_LIB_H_ +#define _EFI_HOB_LIB_H_ + +#include "PeiHob.h" + +VOID * +GetHob ( + IN UINT16 Type, + IN VOID *HobStart + ) +/*++ + +Routine Description: + + This function returns the first instance of a HOB type in a HOB list. + +Arguments: + + Type The HOB type to return. + HobStart The first HOB in the HOB list. + +Returns: + + HobStart There were no HOBs found with the requested type. + else Returns the first HOB with the matching type. + +--*/ +; + +UINTN +GetHobListSize ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Get size of hob list. + +Arguments: + + HobStart - Start pointer of hob list + +Returns: + + Size of hob list. + +--*/ +; + +UINT32 +GetHobVersion ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Get hob version. + +Arguments: + + HobStart - Start pointer of hob list + +Returns: + + Hob version. + +--*/ +; + +EFI_STATUS +GetHobBootMode ( + IN VOID *HobStart, + OUT EFI_BOOT_MODE *BootMode + ) +/*++ + +Routine Description: + + Get current boot mode. + +Arguments: + + HobStart - Start pointer of hob list + + BootMode - Current boot mode recorded in PHIT hob + +Returns: + + EFI_NOT_FOUND - Invalid hob header + + EFI_SUCCESS - Boot mode found + +--*/ +; + +EFI_STATUS +GetCpuHobInfo ( + IN VOID *HobStart, + OUT UINT8 *SizeOfMemorySpace, + OUT UINT8 *SizeOfIoSpace + ) +/*++ + +Routine Description: + + Get information recorded in CPU hob (Memory space size, Io space size) + +Arguments: + + HobStart - Start pointer of hob list + + SizeOfMemorySpace - Size of memory size + + SizeOfIoSpace - Size of IO size + +Returns: + + EFI_NOT_FOUND - CPU hob not found + + EFI_SUCCESS - CPU hob found and information got. + +--*/ +; + +EFI_STATUS +GetDxeCoreHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length, + OUT VOID **EntryPoint, + OUT EFI_GUID **FileName + ) +/*++ + +Routine Description: + + Get memory allocation hob created for DXE core and extract its information + +Arguments: + + HobStart - Start pointer of the hob list + + BaseAddress - Start address of memory allocated for DXE core + + Length - Length of memory allocated for DXE core + + EntryPoint - DXE core file name + + FileName - FileName + +Returns: + + EFI_NOT_FOUND - DxeCoreHob not found + + EFI_SUCCESS - DxeCoreHob found and information got + +--*/ +; + +EFI_STATUS +GetNextFirmwareVolumeHob ( + IN OUT VOID **HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length + ) +/*++ + +Routine Description: + + Get next firmware volume hob from HobStart + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - Start address of next firmware volume + + Length - Length of next firmware volume + +Returns: + + EFI_NOT_FOUND - Next firmware volume not found + + EFI_SUCCESS - Next firmware volume found with address information + +--*/ +; + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) +EFI_STATUS +GetNextFirmwareVolume2Hob ( + IN OUT VOID **HobStart, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress, + OUT UINT64 *Length, + OUT EFI_GUID *FileName + ) +; +#endif + +EFI_STATUS +GetNextGuidHob ( + IN OUT VOID **HobStart, + IN EFI_GUID * Guid, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL + ) +/*++ + +Routine Description: + Get the next guid hob. + +Arguments: + HobStart A pointer to the start hob. + Guid A pointer to a guid. + Buffer A pointer to the buffer. + BufferSize Buffer size. + +Returns: + Status code. + + EFI_NOT_FOUND - Next Guid hob not found + + EFI_SUCCESS - Next Guid hob found and data for this Guid got + +--*/ +; + +EFI_STATUS +GetPalEntryHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *PalEntry + ) +/*++ + +Routine Description: + + Get PAL entry from PalEntryHob + +Arguments: + + HobStart - Start pointer of hob list + + PalEntry - Pointer to PAL entry + +Returns: + + Status code. + +--*/ +; + +EFI_STATUS +GetIoPortSpaceAddressHobInfo ( + IN VOID *HobStart, + OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress + ) +/*++ + +Routine Description: + + Get IO port space address from IoBaseHob. + +Arguments: + + HobStart - Start pointer of hob list + + IoPortSpaceAddress - IO port space address + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h new file mode 100644 index 0000000000..a5191f8f8a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h @@ -0,0 +1,429 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiMgmtModeRuntimeLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_RT_SUPPORT_LIB_H_ +#define _EFI_RT_SUPPORT_LIB_H_ + +#ifndef EFI_LOAD_IMAGE_SMM +#define EFI_LOAD_DRIVER_SMM FALSE +#else +#define EFI_LOAD_DRIVER_SMM TRUE +#endif + +#ifndef EFI_NO_LOAD_IMAGE_RT +#define EFI_NO_LOAD_DRIVER_RT FALSE +#else +#define EFI_NO_LOAD_DRIVER_RT TRUE +#endif + +#include "EfiCommonLib.h" +#include "LinkedList.h" +#include "ProcDep.h" + +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) + +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_SYSTEM_TABLE *gST; +extern UINTN gRtErrorLevel; +extern BOOLEAN mEfiLoadDriverSmm; +extern BOOLEAN mEfiNoLoadDriverRt; +extern EFI_DEVICE_PATH_PROTOCOL *mFilePath; + +// +// Runtime Memory Allocation/De-Allocation tools (Should be used in Boot Phase only) +// +EFI_STATUS +EfiAllocateRuntimeMemoryPool ( + IN UINTN Size, + OUT VOID **Buffer + ) +/*++ + +Routine Description: + + Allocate EfiRuntimeServicesData pool of specified size. + +Arguments: + + Size - Pool size + Buffer - Memory pointer for output + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiFreeRuntimeMemoryPool ( + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Free allocated pool + +Arguments: + + Buffer - Pool to be freed + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiLocateProtocolHandleBuffers ( + IN EFI_GUID *Protocol, + IN OUT UINTN *NumberHandles, + OUT EFI_HANDLE **Buffer + ) +/*++ + +Routine Description: + + Returns an array of handles that support the requested protocol in a buffer allocated from pool. + +Arguments: + + Protocol - Provides the protocol to search by. + NumberHandles - The number of handles returned in Buffer. + Buffer - A pointer to the buffer to return the requested array of handles that + support Protocol. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiHandleProtocol ( + IN EFI_HANDLE Handle, + IN EFI_GUID *Protocol, + OUT VOID **Interface + ) +/*++ + +Routine Description: + + Queries a handle to determine if it supports a specified protocol. + +Arguments: + + Handle - The handle being queried. + Protocol - The published unique identifier of the protocol. + Interface - Supplies the address where a pointer to the corresponding Protocol + Interface is returned. NULL will be returned in *Interface if a + structure is not associated with Protocol. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiInstallProtocolInterface ( + IN OUT EFI_HANDLE *Handle, + IN EFI_GUID *Protocol, + IN EFI_INTERFACE_TYPE InterfaceType, + IN VOID *Interface + ) +/*++ + +Routine Description: + + Installs a protocol interface on a device handle. If the handle does not exist, it is created and added +to the list of handles in the system. + +Arguments: + + Handle - A pointer to the EFI_HANDLE on which the interface is to be installed. + Protocol - The numeric ID of the protocol interface. + InterfaceType - Indicates whether Interface is supplied in native form. + Interface - A pointer to the protocol interface. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiReinstallProtocolInterface ( + IN EFI_HANDLE SmmProtocolHandle, + IN EFI_GUID *Protocol, + IN VOID *OldInterface, + IN VOID *NewInterface + ) +/*++ + +Routine Description: + + Reinstalls a protocol interface on a device handle. + +Arguments: + + SmmProtocolHandle - Handle on which the interface is to be reinstalled. + Protocol - The numeric ID of the interface. + OldInterface - A pointer to the old interface. + NewInterface - A pointer to the new interface. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiLocateProtocolInterface ( + EFI_GUID *Protocol, + VOID *Registration, OPTIONAL + VOID **Interface + ) +/*++ + +Routine Description: + + Returns the first protocol instance that matches the given protocol. + +Arguments: + + Protocol - Provides the protocol to search for. + Registration - Optional registration key returned from + RegisterProtocolNotify(). If Registration is NULL, then + it is ignored. + Interface - On return, a pointer to the first interface that matches Protocol and + Registration. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +UninstallProtocolInterface ( + IN EFI_HANDLE SmmProtocolHandle, + IN EFI_GUID *Protocol, + IN VOID *Interface + ) +/*++ + +Routine Description: + + Removes a protocol interface from a device handle. + +Arguments: + + SmmProtocolHandle - The handle on which the interface was installed. + Protocol - The numeric ID of the interface. + Interface - A pointer to the interface. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiRegisterProtocolCallback ( + IN EFI_EVENT_NOTIFY CallbackFunction, + IN VOID *Context, + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + OUT VOID **Registeration, + OUT EFI_EVENT *Event + ) +/*++ + +Routine Description: + + Register a callback function to be signaled whenever an interface is installed for + a specified protocol. + +Arguments: + + CallbackFunction - Call back function + Context - Context of call back function + ProtocolGuid - The numeric ID of the protocol for which the callback function + is to be registered. + NotifyTpl - Notify tpl of callback function + Registeration - A pointer to a memory location to receive the registration value. + Event - Event that is to be signaled whenever a protocol interface is registered + for Protocol. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSignalProtocolEvent ( + EFI_EVENT Event + ) +/*++ + +Routine Description: + + Signals an event. + +Arguments: + + Event - The event to signal. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiInstallVendorConfigurationTable ( + IN EFI_GUID *Guid, + IN VOID *Table + ) +/*++ + +Routine Description: + + Adds, updates, or removes a configuration table entry from the EFI System Table. + +Arguments: + + Guid - A pointer to the GUID for the entry to add, update, or remove. + Table - A pointer to the configuration table for the entry to add, update, or + remove. May be NULL. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetVendorConfigurationTable ( + IN EFI_GUID *Guid, + OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + Guid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +EFI_STATUS +EfiInitializeUtilsRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY GoVirtualChildEvent + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + GoVirtualChildEvent - Caller can register a virtual notification event. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +BOOLEAN +EfiInManagementInterrupt ( + VOID + ) +/*++ + +Routine Description: + + Indicate whether the caller is already in SMM or not. + +Arguments: + + None + +Returns: + + TRUE - In SMM + FALSE - Not in SMM + +--*/ +; + +// +// This MACRO initializes the RUNTIME invironment and optionally loads Image to SMM or Non-SMM space +// based upon the presence of build flags EFI_LOAD_DRIVER_SMM and EFI_NO_LOAD_DRIVER_RT. +// +#define EFI_INITIALIZE_RUNTIME_DRIVER_LIB(ImageHandle, SystemTable, GoVirtualChildEvent, FilePath) \ + mEfiLoadDriverSmm = EFI_LOAD_DRIVER_SMM; \ + mEfiNoLoadDriverRt = EFI_NO_LOAD_DRIVER_RT; \ + mFilePath = (EFI_DEVICE_PATH_PROTOCOL*) FilePath; \ + EfiInitializeUtilsRuntimeDriverLib ((EFI_HANDLE) ImageHandle, (EFI_SYSTEM_TABLE*) SystemTable, (EFI_EVENT_NOTIFY) GoVirtualChildEvent); \ + if (!EfiInManagementInterrupt()) { \ + if (mEfiNoLoadDriverRt) { \ + return EFI_SUCCESS; \ + } \ + } + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiPrintLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiPrintLib.h new file mode 100644 index 0000000000..42a6ec8c8a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiPrintLib.h @@ -0,0 +1,326 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiPrintLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_PRINT_LIB_H_ +#define _EFI_PRINT_LIB_H_ + +#include EFI_PROTOCOL_DEFINITION(GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION(UgaDraw) +#include EFI_PROTOCOL_DEFINITION(Print) + +UINTN +ErrorPrint ( + IN CONST CHAR16 *ErrorString, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + ErrorString - Error message printed first + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +VOID +ErrorDumpHex ( + IN UINTN Indent, + IN UINTN Offset, + IN UINTN DataSize, + IN VOID *UserData + ) +/*++ + +Routine Description: + + Dump error info by hex. + +Arguments: + + Indent - Indent number + Offset - Offset number + DataSize - Size of user data + UserData - User data to dump + +Returns: + + None + +--*/ +; + +UINTN +Print ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to the default console + +Arguments: + + fmt - Format string + +Returns: + + Length of string printed to the console + +--*/ +; + +UINTN +PrintXY ( + IN UINTN X, + IN UINTN Y, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground, OPTIONAL + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background, OPTIONAL + IN CHAR16 *Fmt, + ... + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to the default console + +Arguments: + + X - X coordinate to start printing + + Y - Y coordinate to start printing + + ForeGround - Foreground color + + BackGround - Background color + + Fmt - Format string + + ... - Print arguments + +Returns: + + Length of string printed to the console + +--*/ +; + +UINTN +Aprint ( + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +UPrint ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +VSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN StrLen, + IN CONST CHAR16 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Prints a formatted unicode string to a buffer + +Arguments: + + StartOfBuffer - Output buffer to print the formatted string into + StrLen - Size of Str. String is truncated to this size. + A size of 0 means there is no limit + Format - The format string + Marker - Vararg list consumed by processing Format. + +Returns: + + String length returned in buffer + +--*/ +; + +UINTN +SPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + SPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +// +// BoxDraw support +// +BOOLEAN +IsValidEfiCntlChar ( + IN CHAR16 CharC + ) +/*++ + +Routine Description: + + Test whether a wide char is a valid control char. + +Arguments: + + CharC - A char + +Returns: + + TRUE - A control char + + FALSE - Not a control char + +--*/ +; + +BOOLEAN +IsValidAscii ( + IN CHAR16 Ascii + ) +/*++ + +Routine Description: + + Test whether a wide char is a normal printable char + +Arguments: + + Ascii - A char + +Returns: + + True - A normal, printable char + FALSE - Not a normal, printable char + +--*/ +; + +BOOLEAN +LibIsValidTextGraphics ( + IN CHAR16 Graphic, + OUT CHAR8 *PcAnsi, OPTIONAL + OUT CHAR8 *Ascii OPTIONAL + ) +/*++ + +Routine Description: + + Detects if a Unicode char is for Box Drawing text graphics. + +Arguments: + + Graphic - Unicode char to test. + + PcAnsi - Optional pointer to return PCANSI equivalent of Graphic. + + Ascii - Optional pointer to return Ascii equivalent of Graphic. + +Returns: + + TRUE if Gpaphic is a supported Unicode Box Drawing character. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRegTableLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRegTableLib.h new file mode 100644 index 0000000000..dece93717e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRegTableLib.h @@ -0,0 +1,205 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiRegTableLib.h + +Abstract: + + Definitions and macros for building register tables for chipset + initialization.. + + Components linking this lib must include CpuIo, PciRootBridgeIo, and + BootScriptSave protocols in their DPX. + +Revision History: + +--*/ + +#ifndef EFI_REG_TABLE_H +#define EFI_REG_TABLE_H + +#include "Tiano.h" +#include "EfiScriptLib.h" +#include EFI_PROTOCOL_CONSUMER (CpuIo) +#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo) + +// +// RegTable OpCodes are encoded as follows: +// +// |31----------------------------16|15---------8|7-------0| +// \ \ \ +// \ \ \ +// 31:16 defined by Base OpCode---+ \ \ +// Opcode Flags---+ \ +// Base OpCode---+ +// +#define OPCODE_BASE(OpCode) ((UINT8)((OpCode) & 0xFF)) +#define OPCODE_FLAGS(OpCode) ((UINT8)(((OpCode) >> 8) & 0xFF)) +#define OPCODE_EXTRA_DATA(OpCode) ((UINT16)((OpCode) >> 16)) + +// +// RegTable Base OpCodes +// +#define OP_TERMINATE_TABLE 0 +#define OP_MEM_WRITE 1 +#define OP_MEM_READ_MODIFY_WRITE 2 +#define OP_IO_WRITE 3 +#define OP_IO_READ_MODIFY_WRITE 4 +#define OP_PCI_WRITE 5 +#define OP_PCI_READ_MODIFY_WRITE 6 +#define OP_STALL 7 + +// +// RegTable OpCode Flags +// +#define OPCODE_FLAG_S3SAVE 1 + + +#define TERMINATE_TABLE { (UINT32) OP_TERMINATE_TABLE, (UINT32) 0, (UINT32) 0 } + + +// +// REG_TABLE_ENTRY_PCI_WRITE encodes the width in the upper bits of the OpCode +// as one of the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH values +// +typedef struct { + UINT32 OpCode; + UINT32 PciAddress; + UINT32 Data; +} EFI_REG_TABLE_PCI_WRITE; + +#define PCI_WRITE(Bus, Dev, Fnc, Reg, Width, Data, S3Flag) \ + { \ + (UINT32) (OP_PCI_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \ + (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \ + (UINT32) (Data), \ + (UINT32) (0) \ + } + +typedef struct { + UINT32 OpCode; + UINT32 PciAddress; + UINT32 OrMask; + UINT32 AndMask; +} EFI_REG_TABLE_PCI_READ_MODIFY_WRITE; + +#define PCI_READ_MODIFY_WRITE(Bus, Dev, Fnc, Reg, Width, OrMask, AndMask, S3Flag) \ + { \ + (UINT32) (OP_PCI_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \ + (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \ + (UINT32) (OrMask), \ + (UINT32) (AndMask) \ + } + +typedef struct { + UINT32 OpCode; + UINT32 MemAddress; + UINT32 OrMask; + UINT32 AndMask; +} EFI_REG_TABLE_MEM_READ_MODIFY_WRITE; + +#define MEM_READ_MODIFY_WRITE(Address, Width, OrMask, AndMask, S3Flag) \ + { \ + (UINT32) (OP_MEM_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \ + (UINT32) (Address), \ + (UINT32) (OrMask), \ + (UINT32) (AndMask) \ + } + +typedef struct { + UINT32 OpCode; + UINT32 Field2; + UINT32 Field3; + UINT32 Field4; +} EFI_REG_TABLE_GENERIC; + +typedef union { + EFI_REG_TABLE_GENERIC Generic; + EFI_REG_TABLE_PCI_WRITE PciWrite; + EFI_REG_TABLE_PCI_READ_MODIFY_WRITE PciReadModifyWrite; + EFI_REG_TABLE_MEM_READ_MODIFY_WRITE MemReadModifyWrite; +} EFI_REG_TABLE; + +VOID +ProcessRegTablePci ( + EFI_REG_TABLE * RegTableEntry, + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * PciRootBridgeIo, + EFI_CPU_IO_PROTOCOL * CpuIo + ) +/*++ + +Routine Description: + Processes register table assuming which may contain PCI, IO, MEM, and STALL + entries. + + No parameter checking is done so the caller must be careful about omitting + values for PciRootBridgeIo or CpuIo parameters. If the regtable does + not contain any PCI accesses, it is safe to omit the PciRootBridgeIo (supply + NULL). If the regtable does not contain any IO or Mem entries, it is safe to + omit the CpuIo (supply NULL). + + The RegTableEntry parameter is not checked, but is required. + + gBS is assumed to have been defined and is used when processing stalls. + + The function processes each entry sequentially until an OP_TERMINATE_TABLE + entry is encountered. + +Arguments: + RegTableEntry - A pointer to the register table to process + + PciRootBridgeIo - A pointer to the instance of PciRootBridgeIo that is used + when processing PCI table entries + + CpuIo - A pointer to the instance of CpuIo that is used when processing IO and + MEM table entries + +Returns: + Nothing. + +--*/ +; + +VOID +ProcessRegTableCpu ( + EFI_REG_TABLE * RegTableEntry, + EFI_CPU_IO_PROTOCOL * CpuIo + ) +/*++ + +Routine Description: + Processes register table assuming which may contain IO, MEM, and STALL + entries, but must NOT contain any PCI entries. Any PCI entries cause an + ASSERT in a DEBUG build and are skipped in a free build. + + No parameter checking is done. Both RegTableEntry and CpuIo parameters are + required. + + gBS is assumed to have been defined and is used when processing stalls. + + The function processes each entry sequentially until an OP_TERMINATE_TABLE + entry is encountered. + +Arguments: + RegTableEntry - A pointer to the register table to process + + CpuIo - A pointer to the instance of CpuIo that is used when processing IO and + MEM table entries + +Returns: + Nothing. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h new file mode 100644 index 0000000000..25b0d6e6c9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiRuntimeLib.h @@ -0,0 +1,1693 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiRuntimeLib.h + +Abstract: + + Light weight lib to support EFI drivers. + +--*/ + +#ifndef _EFI_RUNTIME_LIB_H_ +#define _EFI_RUNTIME_LIB_H_ +#define MAX_FVB_COUNT 16 +#include "EfiStatusCode.h" +#include "EfiCommonLib.h" + +#include "LinkedList.h" +#include "GetImage.h" +#include "RtDevicePath.h" + +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_PROTOCOL_DEFINITION (FvbExtension) +#include "ProcDep.h" + +typedef struct { + EFI_HANDLE Handle; + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; + EFI_FVB_EXTENSION_PROTOCOL *FvbExtension; +} FVB_ENTRY; + +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_SYSTEM_TABLE *gST; +extern EFI_DXE_SERVICES *gDS; +extern UINTN gRtErrorLevel; +extern FVB_ENTRY *mFvbEntry; + +VOID +EFIAPI +EfiRuntimeLibFvbVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Notify function to convert pointers to Fvb functions after ExitBootServices + +Arguments: + + Event - Event whose notification function is being invoked. + Context - Pointer to the notification function¡¯s context, which is + implementation-dependent. + +Returns: + + None + +--*/ +; + +EFI_STATUS +EfiInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY RuntimeNotifyEventHandler + ) +/*++ + +Routine Description: + + Intialize Runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + RuntimeNotifyEventHandler - Virtual address change notification event + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiShutdownRuntimeDriverLib ( + VOID + ) +/*++ + +Routine Description: + + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully + EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all + +--*/ +; + +EFI_STATUS +EfiInitializeSmmDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Smm Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + TableGuid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +; + +BOOLEAN +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + + Am I at runtime? + +Arguments: + + None + +Returns: + + TRUE - At runtime + FALSE - Not at runtime + +--*/ +; + +BOOLEAN +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + FALSE - If SetVirtualAddressMap () has not been called + +--*/ +; + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +/*++ + + + +Routine Description: + + + + Get table from configuration table by name + + + +Arguments: + + + + TableGuid - Table name to search + + + + Table - Pointer to the table caller wants + + + +Returns: + + + + EFI_NOT_FOUND - Not found the table + + + + EFI_SUCCESS - Found the table + + + +--*/ + +; + +EFI_EVENT +RtEfiLibCreateProtocolNotifyEvent ( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT VOID **Registration + ) +/*++ + +Routine Description: + + Create a protocol notification event and return it. + +Arguments: + + ProtocolGuid - Protocol to register notification event on. + + NotifyTpl - Maximum TPL to single the NotifyFunction. + + NotifyFunction - EFI notification routine. + + NotifyContext - Context passed into Event when it is created. + + Registration - Registration key returned from RegisterProtocolNotify(). + +Returns: + + The EFI_EVENT that has been registered to be signaled when a ProtocolGuid + is added to the system. + +--*/ +; + +// +// Lock.c +// +typedef struct { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + UINTN Lock; +} EFI_LOCK; + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + Note on a check build ASSERT()s are used to ensure proper + lock usage. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - The task priority level of the lock + + +Returns: + + An initialized Efi Lock structure. + +--*/ +; + +// +// Macro to initialize the state of a lock when a lock variable is declared +// +#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0} + + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + Lock owned + +--*/ +; + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +; + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + +Arguments: + + Lock - The lock to release + +Returns: + + None + +--*/ +; + +#define EfiCopyMem EfiCommonLibCopyMem +#define EfiSetMem EfiCommonLibSetMem +#define EfiZeroMem EfiCommonLibZeroMem + +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Len + ) +/*++ + +Routine Description: + + Compares two memory buffers of a given length. + +Arguments: + + MemOne - First memory buffer + + MemTwo - Second memory buffer + + Len - Length of Mem1 and Mem2 memory regions to compare + +Returns: + + = 0 if MemOne == MemTwo + + > 0 if MemOne > MemTwo + + < 0 if MemOne < MemTwo + +--*/ +; + +// +// Debug.c init +// +EFI_STATUS +EfiDebugAssertInit ( + VOID + ) +/*++ + +Routine Description: + + Locate Debug Assert Protocol and set as mDebugAssert + +Arguments: + + None + +Returns: + + Status code + +--*/ +; + +// +// Wrapper for EFI runtime functions +// +VOID +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Resets the entire platform. + +Arguments: + + ResetType - The type of reset to perform. + ResetStatus - The status code for the reset. + DataSize - The size, in bytes, of ResetData. + ResetData - A data buffer that includes a Null-terminated Unicode string, optionally + followed by additional binary data. + +Returns: + + None + +--*/ +; + +EFI_STATUS +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Returns the next high 32 bits of the platform¡¯s monotonic counter. + +Arguments: + + HighCount - Pointer to returned value. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSetTime ( + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +/*++ + +Routine Description: + + Returns the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - If not NULL, a pointer to the memory location to return the + attributes bitmask for the variable. + DataSize - On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + Data - The buffer to return the contents of the variable. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +/*++ + +Routine Description: + + Enumerates the current variable names. + +Arguments: + + VariableNameSize - The size of the VariableName buffer. + VariableName - On input, supplies the last VariableName that was returned + by GetNextVariableName(). + On output, returns the Nullterminated Unicode string of the + current variable. + VendorGuid - On input, supplies the last VendorGuid that was returned by + GetNextVariableName(). + On output, returns the VendorGuid of the current variable. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ) +/*++ + +Routine Description: + + Sets the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - Attributes bitmask to set for the variable. + DataSize - The size in bytes of the Data buffer. + Data - The contents for the variable. + +Returns: + + Status code + +--*/ +; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +EFI_STATUS +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) +/*++ + +Routine Description: + + This code returns information about the EFI variables. + +Arguments: + + Attributes Attributes bitmask to specify the type of variables + on which to return information. + MaximumVariableStorageSize Pointer to the maximum size of the storage space available + for the EFI variables associated with the attributes specified. + RemainingVariableStorageSize Pointer to the remaining size of the storage space available + for the EFI variables associated with the attributes specified. + MaximumVariableSize Pointer to the maximum size of the individual EFI variables + associated with the attributes specified. + +Returns: + + Status code + +--*/ +; +#endif + + +EFI_STATUS +EfiReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT EFI_LIST_ENTRY *ListHead + ) +/*++ + +Routine Description: + + Conver the standard Lib double linked list to a virtual mapping. + +Arguments: + + DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API) + + ListHead - Head of linked list to convert + +Returns: + + EFI_SUCCESS + +--*/ +; + +// +// Base IO Class Functions +// +EFI_STATUS +EfiIoRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO read into Buffer. + +Arguments: + Width - Width of read transaction, and repeat operation to use + Address - IO address to read + Count - Number of times to read the IO address. + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +; + +UINT8 +IoRead8 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a one byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +; + +UINT16 +IoRead16 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a two byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +; + +UINT32 +IoRead32 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a four byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +; + +EFI_STATUS +EfiIoWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +; + +VOID +IoWrite8 ( + IN UINT64 Address, + IN UINT8 Data + ) +/*++ + +Routine Description: + Do a one byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +IoWrite16 ( + IN UINT64 Address, + IN UINT16 Data + ) +/*++ + +Routine Description: + Do a two byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +IoWrite32 ( + IN UINT64 Address, + IN UINT32 Data + ) +/*++ + +Routine Description: + Do a four byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +EFI_STATUS +EfiMemRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a Memory mapped IO read into Buffer. + +Arguments: + Width - Width of each read transaction. + Address - Memory mapped IO address to read + Count - Number of Width quanta to read + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +; + +UINT8 +MemRead8 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a one byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +UINT16 +MemRead16 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a two byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +UINT32 +MemRead32 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a four byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +UINT64 +MemRead64 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a eight byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +; + +EFI_STATUS +EfiMemWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a memory mapped IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +; + +VOID +MemWrite8 ( + IN UINT64 Address, + IN UINT8 Data + ) +/*++ + +Routine Description: + Do a one byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +MemWrite16 ( + IN UINT64 Address, + IN UINT16 Data + ) +/*++ + +Routine Description: + Do a two byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +MemWrite32 ( + IN UINT64 Address, + IN UINT32 Data + ) +/*++ + +Routine Description: + Do a four byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +VOID +MemWrite64 ( + IN UINT64 Address, + IN UINT64 Data + ) +/*++ + +Routine Description: + Do a eight byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +; + +// +// Platform specific functions +// +UINT8 +PciRead8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +; + +UINT16 +PciRead16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +; + +UINT32 +PciRead32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +; + +VOID +PciWrite8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT8 Data + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +; + +VOID +PciWrite16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT16 Data + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +; + +VOID +PciWrite32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT32 Data + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +; + +VOID +EfiStall ( + IN UINTN Microseconds + ) +/*++ + +Routine Description: + Delay for at least the request number of microseconds + +Arguments: + Microseconds - Number of microseconds to delay. + +Returns: + NONE + +--*/ +; + +// +// FVB Services. +// +EFI_STATUS +EfiFvbInitialize ( + VOID + ) +/*++ + +Routine Description: + Initialize globals and register Fvb Protocol notification function. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiFvbShutdown ( + VOID + ) +/*++ + +Routine Description: + Release resources allocated in EfiFvbInitialize. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EfiFvbReadBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Reads specified number of bytes into a buffer from the specified block + +Arguments: + Instance - The FV instance to be read from + Lba - The logical block address to be read from + Offset - Offset into the block at which to begin reading + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes read + Buffer - Pointer to a caller allocated buffer that will be + used to hold the data read + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbWriteBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Writes specified number of bytes from the input buffer to the block + +Arguments: + Instance - The FV instance to be written to + Lba - The starting logical block index to write to + Offset - Offset into the block at which to begin writing + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes actually written + Buffer - Pointer to a caller allocated buffer that contains + the source for the write + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbEraseBlock ( + IN UINTN Instance, + IN EFI_LBA Lba + ) +/*++ + +Routine Description: + Erases and initializes a firmware volume block + +Arguments: + Instance - The FV instance to be erased + Lba - The logical block index to be erased + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbGetVolumeAttributes ( + IN UINTN Instance, + OUT EFI_FVB_ATTRIBUTES *Attributes + ) +/*++ + +Routine Description: + Retrieves attributes, insures positive polarity of attribute bits, returns + resulting attributes in output parameter + +Arguments: + Instance - The FV instance whose attributes is going to be + returned + Attributes - Output buffer which contains attributes + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbSetVolumeAttributes ( + IN UINTN Instance, + IN EFI_FVB_ATTRIBUTES Attributes + ) +/*++ + +Routine Description: + Modifies the current settings of the firmware volume according to the + input parameter, and returns the new setting of the volume + +Arguments: + Instance - The FV instance whose attributes is going to be + modified + Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES + containing the desired firmware volume settings. + On successful return, it contains the new settings + of the firmware volume + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbGetPhysicalAddress ( + IN UINTN Instance, + OUT EFI_PHYSICAL_ADDRESS *Address + ) +/*++ + +Routine Description: + Retrieves the physical address of a memory mapped FV + +Arguments: + Instance - The FV instance whose base address is going to be + returned + Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS + that on successful return, contains the base address + of the firmware volume. + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiFvbGetBlockSize ( + IN UINTN Instance, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks + ) +/*++ + +Routine Description: + Retrieve the size of a logical block + +Arguments: + Instance - The FV instance whose block size is going to be + returned + Lba - Indicates which block to return the size for. + BlockSize - A pointer to a caller allocated UINTN in which + the size of the block is returned + NumOfBlocks - a pointer to a caller allocated UINTN in which the + number of consecutive blocks starting with Lba is + returned. All blocks in this range have a size of + BlockSize + +Returns: + EFI_SUCCESS - The firmware volume was read successfully and + contents are in Buffer + +--*/ +; +EFI_STATUS +EfiFvbEraseCustomBlockRange ( + IN UINTN Instance, + IN EFI_LBA StartLba, + IN UINTN OffsetStartLba, + IN EFI_LBA LastLba, + IN UINTN OffsetLastLba + ) +/*++ + +Routine Description: + Erases and initializes a specified range of a firmware volume + +Arguments: + Instance - The FV instance to be erased + StartLba - The starting logical block index to be erased + OffsetStartLba - Offset into the starting block at which to + begin erasing + LastLba - The last logical block index to be erased + OffsetLastLba - Offset into the last block at which to end erasing + +Returns: + Status code + +--*/ +; + +EFI_STATUS +EfiCpuFlushCache ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Flush cache with specified range. + +Arguments: + + Start - Start address + Length - Length in bytes + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +EFIAPI +RtEfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +; + +EFI_STATUS +EFIAPI +RtEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiScriptLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiScriptLib.h new file mode 100644 index 0000000000..fbf9699a31 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiScriptLib.h @@ -0,0 +1,517 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiScriptLib.h + +Abstract: + + +--*/ + +#ifndef _EFI_SCRIPT_LIB_H_ +#define _EFI_SCRIPT_LIB_H_ + +#include "Tiano.h" +#include "EfiCommonLib.h" +#include "EfiBootScript.h" +#include EFI_PROTOCOL_DEFINITION (BootScriptSave) + + +EFI_STATUS +BootScriptSaveInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize Boot Script Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSaveIoWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save I/O write to boot script with opcode EFI_BOOT_SCRIPT_IO_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the I/O operations. + + Address - The base address of the I/O operations. + + Count - The number of I/O operations to perform. + + Buffer - The source buffer from which to write data. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSaveIoReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save I/O modify to boot script with opcode EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the I/O operations. + + Address - The base address of the I/O operations. + + Data - A pointer to the data to be OR-ed. + + DataMask - A pointer to the data mask to be AND-ed with the data read from the register. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSaveMemWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save memory write to boot script with opcode EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the memory operations. + + Address - The base address of the memory operations. + + Count - The number of memory operations to perform. + + Buffer - The source buffer from which to write the data. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSaveMemReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save memory modify to boot script with opcode EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the memory operations. + + Address - The base address of the memory operations. + + Data - A pointer to the data to be OR-ed. + + DataMask - A pointer to the data mask to be AND-ed with the data read from the register. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSavePciCfgWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save PCI configuration space write operation to boot script with opcode + EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the PCI operations + + Address - The address within the PCI configuration space. + + Count - The number of PCI operations to perform. + + Buffer - The source buffer from which to write the data. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSavePciCfgReadWrite ( + IN UINT16 TableName, + IN EFI_BOOT_SCRIPT_WIDTH Width, + IN UINT64 Address, + IN VOID *Data, + IN VOID *DataMask + ) +/*++ + +Routine Description: + + Save PCI configuration space modify operation to boot script with opcode + EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE + +Arguments: + + TableName - Desired boot script table + + Width - The width of the PCI operations + + Address - The address within the PCI configuration space. + + Data - A pointer to the data to be OR-ed. + + DataMask - A pointer to the data mask to be AND-ed with the data read from the register. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; +; + +EFI_STATUS +BootScriptSaveSmbusExecute ( + IN UINT16 TableName, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN UINTN *Length, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Save SMBus command execution to boot script with opcode + EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE + +Arguments: + + TableName - Desired boot script table + SlaveAddress - The SMBus address for the slave device that the operation is targeting. + Command - The command that is transmitted by the SMBus host controller to the + SMBus slave device. + Operation - Indicates which particular SMBus protocol it will use to execute the + SMBus transactions. + PecCheck - Defines if Packet Error Code (PEC) checking is required for this operation. + Length - A pointer to signify the number of bytes that this operation will do. + Buffer - Contains the value of data to execute to the SMBUS slave device. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSaveStall ( + IN UINT16 TableName, + IN UINTN Duration + ) +/*++ + +Routine Description: + + Save execution stall on the processor to boot script with opcode + EFI_BOOT_SCRIPT_STALL_OPCODE + +Arguments: + + TableName - Desired boot script table + + Duration - Duration in microseconds of the stall. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BootScriptSaveDispatch ( + IN UINT16 TableName, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +/*++ + +Routine Description: + + Save dispatching specified arbitrary code to boot script with opcode + EFI_BOOT_SCRIPT_DISPATCH_OPCODE + +Arguments: + + TableName - Desired boot script table + + EntryPoint - Entry point of the code to be dispatched. + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveInformation ( + IN UINT16 TableName, + IN UINT32 Length, + IN EFI_PHYSICAL_ADDRESS Buffer + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName + +Arguments: + + TableName - Desired boot script table + Length - Length of information in bytes + Buffer - Content of information that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveInformationUnicodeString ( + IN UINT16 TableName, + IN CHAR16 *String + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName, the information + is a unicode string. + +Arguments: + + TableName - Desired boot script table + String - The string that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +EFI_STATUS +EFIAPI +BootScriptSaveInformationAsciiString ( + IN UINT16 TableName, + IN CHAR8 *String + ) +/*++ + +Routine Description: + + Save a Information Opcode record in table specified with TableName, the information + is a ascii string. + +Arguments: + + TableName - Desired boot script table + String - The string that will be saved in script table + +Returns: + + EFI_NOT_FOUND - BootScriptSave Protocol not exist. + + EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS + +--*/ +; + +#ifdef EFI_S3_RESUME + +#define INITIALIZE_SCRIPT(ImageHandle, SystemTable) \ + BootScriptSaveInitialize(ImageHandle, SystemTable) + +#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) \ + BootScriptSaveIoWrite(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) \ + BootScriptSaveIoReadWrite(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) \ + BootScriptSaveMemWrite(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count) \ + BootScriptSaveMemWrite(TableName, Width, Address, Count, (VOID*)(UINTN)Address) + +#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) \ + BootScriptSaveMemReadWrite(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) \ + BootScriptSavePciCfgWrite(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) \ + BootScriptSavePciCfgReadWrite(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) \ + BootScriptSaveSmbusExecute(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) + +#define SCRIPT_STALL(TableName, Duration) \ + BootScriptSaveStall(TableName, Duration) + +#define SCRIPT_DISPATCH(TableName, EntryPoint) \ + BootScriptSaveDispatch(TableName, EntryPoint) + +#define SCRIPT_INOFRMATION(TableName, Length, Buffer) \ + BootScriptSaveInformation(TableName, Length, Buffer) + +#define SCRIPT_INOFRMATION_UNICODE_STRING(TableName, String) \ + BootScriptSaveInformationUnicodeString(TableName, String) + +#define SCRIPT_INOFRMATION_ASCII_STRING(TableName, String) \ + BootScriptSaveInformationAsciiString(TableName, String) + +#else + +#define INITIALIZE_SCRIPT(ImageHandle, SystemTable) + +#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count) + +#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) + +#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) + +#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) + +#define SCRIPT_STALL(TableName, Duration) + +#define SCRIPT_DISPATCH(TableName, EntryPoint) + +#define SCRIPT_INOFRMATION(TableName, Length, Buffer) + +#define SCRIPT_INOFRMATION_UNICODE_STRING(TableName, String) + +#define SCRIPT_INOFRMATION_ASCII_STRING(TableName, String) + +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h new file mode 100644 index 0000000000..239fb38f00 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h @@ -0,0 +1,220 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiSmmDriverLib.h + +Abstract: + + Light weight lib to support EFI Smm drivers. + +--*/ + +#ifndef _EFI_SMM_DRIVER_LIB_H_ +#define _EFI_SMM_DRIVER_LIB_H_ + +#include "Tiano.h" +#include "GetImage.h" +#include "EfiCommonLib.h" +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) +#include EFI_PROTOCOL_DEFINITION (SmmBase) +#include EFI_PROTOCOL_DEFINITION (SmmStatusCode) +// +// Driver Lib Globals. +// +extern EFI_BOOT_SERVICES *gBS; +extern EFI_SYSTEM_TABLE *gST; +extern EFI_RUNTIME_SERVICES *gRT; +extern EFI_SMM_BASE_PROTOCOL *gSMM; +extern EFI_SMM_STATUS_CODE_PROTOCOL *mSmmDebug; +extern UINTN gErrorLevel; + +#define EfiCopyMem EfiCommonLibCopyMem +#define EfiSetMem EfiCommonLibSetMem +#define EfiZeroMem EfiCommonLibZeroMem + +EFI_STATUS +EfiInitializeSmmDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN OUT BOOLEAN *InSmm + ) +/*++ + +Routine Description: + + Intialize Smm Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + InSmm - If InSmm is NULL, it will not register Image to SMM. + If InSmm is not NULL, it will register Image to SMM and + return information on currently in SMM mode or not. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +; + +VOID +EfiDebugAssert ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ) +/*++ + +Routine Description: + + Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded DEADLOOP (). + +Arguments: + + FileName - File name of failing routine. + + LineNumber - Line number of failing ASSERT(). + + Description - Description, usually the assertion, + +Returns: + + None + +--*/ +; + +VOID +EfiDebugVPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + Marker - VarArgs + +Returns: + + None + +--*/ +; + +VOID +EfiDebugPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + ... - VAR args for Format + +Returns: + + None + +--*/ +; + +EFI_STATUS +EFIAPI +SmmEfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +; + +EFI_STATUS +EFIAPI +SmmEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h new file mode 100644 index 0000000000..1403bbbcc0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h @@ -0,0 +1,205 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + EfiUiLib.h + +Abstract: + Collection of usefull UI functions. + +Revision History: + +--*/ + +#ifndef _EFI_UI_LIB_H_ +#define _EFI_UI_LIB_H_ + +#include "Tiano.h" +#include "TianoTypes.h" +#include "EfiDriverLib.h" + +CHAR16 * +StrHzToString ( + OUT CHAR16 *String, + IN UINT64 Val + ) +/*++ + +Routine Description: + Converts frequency in Hz to Unicode string. + Three significant digits are delivered. Used for processor info display. + +Arguments: + String - string that will contain the frequency. + Val - value to convert, minimum is 100000 i.e., 0.1 MHz. + +Returns: + String that contains the frequency. + +--*/ +; + +CHAR16 * +StrBytesToString ( + OUT CHAR16 *String, + IN UINT64 Val + ) +/*++ + +Routine Description: + Converts size in bytes to Unicode string. + Used for memory/cache size display. + +Arguments: + String - string that will contain the value + Val - value to convert in bytes + +Returns: + String that contains the value. + +--*/ +; + +CHAR16 * +StrVersionToString ( + OUT CHAR16 *String, + IN UINT8 Version + ) +/*++ + +Routine Description: + Converts 8 bit version value to Unicode string. + The upper nibble contains the upper part, the lower nibble contains the minor part. + The output format is .. + +Arguments: + String - string that will contain the version value + Version - Version value to convert + +Returns: + String that contains the version value. + +--*/ +; + +CHAR16 * +StrMacToString ( + OUT CHAR16 *String, + IN EFI_MAC_ADDRESS *MacAddr, + IN UINT32 AddrSize + ) +/*++ + +Routine Description: + Converts MAC address to Unicode string. + The value is 64-bit and the resulting string will be 12 + digit hex number in pairs of digits separated by dashes. + +Arguments: + String - string that will contain the value + MacAddr - MAC address to convert + AddrSize - Size of address + +Returns: + String that contains the value. + +--*/ +; + +CHAR16 * +StrIp4AdrToString ( + OUT CHAR16 *String, + IN EFI_IPv4_ADDRESS *Ip4Addr + ) +/*++ + +Routine Description: + Converts IP v4 address to Unicode string. + The value is 64-bit and the resulting string will + be four decimal values 0-255 separated by dots. + +Arguments: + String - string that will contain the value + Ip4Addr - IP v4 address to convert from + +Returns: + + String that contain the value + +--*/ +; + +EFI_STATUS +StrStringToIp4Adr ( + OUT EFI_IPv4_ADDRESS *Ip4Addr, + IN CHAR16 *String + ) +/*++ + +Routine Description: + Parses and converts Unicode string to IP v4 address. + The value will 64-bit. + The string must be four decimal values 0-255 separated by dots. + The string is parsed and format verified. + +Arguments: + Ip4Addr - pointer to the variable to store the value to + String - string that contains the value to parse and convert + +Returns: + EFI_SUCCESS - if successful + EFI_INVALID_PARAMETER - if String contains invalid IP v4 format + +--*/ +; + +CHAR16 * +Ascii2Unicode ( + OUT CHAR16 *UnicodeStr, + IN CHAR8 *AsciiStr + ) +/*++ + +Routine Description: + Converts ASCII characters to Unicode. + +Arguments: + UnicodeStr - the Unicode string to be written to. The buffer must be large enough. + AsciiStr - The ASCII string to be converted. + +Returns: + The address to the Unicode string - same as UnicodeStr. + +--*/ +; + +CHAR8 * +Unicode2Ascii ( + OUT CHAR8 *AsciiStr, + IN CHAR16 *UnicodeStr + ) +/*++ + +Routine Description: + Converts ASCII characters to Unicode. + Assumes that the Unicode characters are only these defined in the ASCII set. + +Arguments: + AsciiStr - The ASCII string to be written to. The buffer must be large enough. + UnicodeStr - the Unicode string to be converted. + +Returns: + The address to the ASCII string - same as AsciiStr. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiWinNtLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiWinNtLib.h new file mode 100644 index 0000000000..b118c8e7c6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiWinNtLib.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiWinNtLib.h + +Abstract: + + Set up gWinNt pointer so we can call WinNT APIs. + +--*/ + +#ifndef _EFI_WIN_NT_LIB_H_ +#define _EFI_WIN_NT_LIB_H_ + +extern EFI_WIN_NT_THUNK_PROTOCOL *gWinNt; + +EFI_STATUS +EfiInitializeWinNtDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize gWinNt and initialize debug console. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + Status code + +--*/ +; + +// +// NTDebugConsole Prototypes +// +VOID +NtDebugConsoleInit ( + VOID + ) +/*++ + +Routine Description: + + Nt debug console initialize. + +Arguments: + + None + +Returns: + + None + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GetImage.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GetImage.h new file mode 100644 index 0000000000..b8f70d0f37 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GetImage.h @@ -0,0 +1,104 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GetImage.h + +Abstract: + + Image data retrieval support for common use. + +--*/ + +#ifndef _GET_IMAGE_H_ +#define _GET_IMAGE_H_ +#include "EfiImageFormat.h" + +EFI_STATUS +GetImage ( + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Enumerate all the FVs, and fill Buffer with the SectionType section content in NameGuid file. + + Note: + 1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on + reading EFI_SECTION_PE32 section. + 2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on + reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file. + 3. Callee allocates memory, which caller is responsible to free. + +Arguments: + + NameGuid - Pointer to EFI_GUID, which is file name. + SectionType - Required section type. + Buffer - Pointer to a pointer in which the read content is returned. + Caller is responsible to free Buffer. + Size - Pointer to a UINTN, which indicates the size of returned *Buffer. + +Returns: + EFI_NOT_FOUND - Required content can not be found. + EFI_SUCCESS - Required content can be found, but whether the Buffer is filled + with section content or not depends on the Buffer and Size. +--*/ +; + +EFI_STATUS +GetImageEx ( + IN EFI_HANDLE ImageHandle, + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size, + BOOLEAN WithinImageFv + ) +/*++ + +Routine Description: + Search FVs, and fill Buffer with the SectionType section content in NameGuid file. + If ImageHandle is not NULL, the FV from which the ImageHandle is loaded is searched + first. If WithinImageFv is TRUE, only the FV from which the ImageHandle is loaded + is searched. If ImageHandle is NULL or WithinImageFv is FALSE, all FVs in the system + is searched. + + Note: + 1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on + reading EFI_SECTION_PE32 section. + 2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on + reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file. + 3. Callee allocates memory, which caller is responsible to free. + +Arguments: + + ImageHandle - The caller's driver image handle. + NameGuid - Pointer to EFI_GUID, which is file name. + SectionType - Required section type. + Buffer - Pointer to a pointer in which the read content is returned. + Caller is responsible to free Buffer. + Size - Pointer to a UINTN, which indicates the size of returned *Buffer. + WithinImageFv - Whether the search only performs on the FV from which the caller's + driver image is loaded. + +Returns: + EFI_INVALID_PARAMETER - ImageHandle is NULL and WithinImageFv is TRUE. + EFI_NOT_FOUND - Required content can not be found. + EFI_SUCCESS - Required content can be found, but whether the Buffer is filled + with section content or not depends on the Buffer and Size. +--*/ +; + +#endif //_GET_IMAGE_H_ diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GraphicsLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GraphicsLib.h new file mode 100644 index 0000000000..74dbf8799b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/GraphicsLib.h @@ -0,0 +1,250 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GraphicsLib.h + +Abstract: + + +--*/ + +#ifndef _EFI_GRAPHICS_LIB_H_ +#define _EFI_GRAPHICS_LIB_H_ + +#include EFI_PROTOCOL_DEFINITION (ConsoleControl) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) +#include EFI_PROTOCOL_DEFINITION (GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION (UgaDraw) +#include EFI_PROTOCOL_DEFINITION (EfiOEMBadging) + +#include EFI_GUID_DEFINITION (Bmp) + +EFI_STATUS +GetGraphicsBitMapFromFV ( + IN EFI_GUID *FileNameGuid, + OUT VOID **Image, + OUT UINTN *ImageSize + ) +/*++ + +Routine Description: + + Return the graphics image file named FileNameGuid into Image and return it's + size in ImageSize. All Firmware Volumes (FV) in the system are searched for the + file name. + +Arguments: + + FileNameGuid - File Name of graphics file in the FV(s). + + Image - Pointer to pointer to return graphics image. If NULL, a + buffer will be allocated. + + ImageSize - Size of the graphics Image in bytes. Zero if no image found. + + +Returns: + + EFI_SUCCESS - Image and ImageSize are valid. + EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size + EFI_NOT_FOUND - FileNameGuid not found + +--*/ +; + +EFI_STATUS +GetGraphicsBitMapFromFVEx ( + IN EFI_HANDLE ImageHandle, + IN EFI_GUID *FileNameGuid, + OUT VOID **Image, + OUT UINTN *ImageSize + ) +/*++ + +Routine Description: + + Return the graphics image file named FileNameGuid into Image and return it's + size in ImageSize. All Firmware Volumes (FV) in the system are searched for the + file name. + +Arguments: + + ImageHandle - The driver image handle of the caller. The parameter is used to + optimize the loading of the image file so that the FV from which + the driver image is loaded will be tried first. + + FileNameGuid - File Name of graphics file in the FV(s). + + Image - Pointer to pointer to return graphics image. If NULL, a + buffer will be allocated. + + ImageSize - Size of the graphics Image in bytes. Zero if no image found. + + +Returns: + + EFI_SUCCESS - Image and ImageSize are valid. + EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size + EFI_NOT_FOUND - FileNameGuid not found + +--*/ +; + + +EFI_STATUS +ConvertBmpToGopBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT VOID **GopBlt, + IN OUT UINTN *GopBltSize, + OUT UINTN *PixelHeight, + OUT UINTN *PixelWidth + ) +/*++ + +Routine Description: + + Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer + is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt + buffer is passed in it will be used if it is big enough. + +Arguments: + + BmpImage - Pointer to BMP file + + BmpImageSize - Number of bytes in BmpImage + + GopBlt - Buffer containing GOP version of BmpImage. + + GopBltSize - Size of GopBlt in bytes. + + PixelHeight - Height of GopBlt/BmpImage in pixels + + PixelWidth - Width of GopBlt/BmpImage in pixels + + +Returns: + + EFI_SUCCESS - GopBlt and GopBltSize are returned. + EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image + EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough. + GopBltSize will contain the required size. + EFI_OUT_OF_RESOURCES - No enough buffer to allocate + +--*/ +; + +EFI_STATUS +EnableQuietBoot ( + IN EFI_GUID *LogoFile + ) +/*++ + +Routine Description: + + Use Console Control to turn off UGA based Simple Text Out consoles from going + to the UGA device. Put up LogoFile on every UGA device that is a console + +Arguments: + + LogoFile - File name of logo to display on the center of the screen. + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +; + +EFI_STATUS +EnableQuietBootEx ( + IN EFI_GUID *LogoFile, + IN EFI_HANDLE ImageHandle + ) +/*++ + +Routine Description: + + Use Console Control to turn off UGA based Simple Text Out consoles from going + to the UGA device. Put up LogoFile on every UGA device that is a console + +Arguments: + + LogoFile - File name of logo to display on the center of the screen. + ImageHandle - The driver image handle of the caller. The parameter is used to + optimize the loading of the logo file so that the FV from which + the driver image is loaded will be tried first. + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +; + +EFI_STATUS +DisableQuietBoot ( + VOID + ) +/*++ + +Routine Description: + + Use Console Control to turn on UGA based Simple Text Out consoles. The UGA + Simple Text Out screens will now be synced up with all non UGA output devices + +Arguments: + + NONE + +Returns: + + EFI_SUCCESS - UGA devices are back in text mode and synced up. + EFI_UNSUPPORTED - Logo not found + +--*/ +; + +EFI_STATUS +LockKeyboards ( + IN CHAR16 *Password + ) +/*++ + +Routine Description: + Use Console Control Protocol to lock the Console In Spliter virtual handle. + This is the ConInHandle and ConIn handle in the EFI system table. All key + presses will be ignored until the Password is typed in. The only way to + disable the password is to type it in to a ConIn device. + +Arguments: + Password - Password used to lock ConIn device + + +Returns: + + EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo + displayed. + EFI_UNSUPPORTED - Logo not found + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h new file mode 100644 index 0000000000..8ddc018f7d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h @@ -0,0 +1,260 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuFuncs.h + +Abstract: + +--*/ + +#ifndef _CPU_FUNCS_H_ +#define _CPU_FUNCS_H_ + +#define EFI_CPUID_SIGNATURE 0x0 +#define EFI_CPUID_VERSION_INFO 0x1 +#define EFI_CPUID_CACHE_INFO 0x2 +#define EFI_CPUID_SERIAL_NUMBER 0x3 +#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000 +#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001 +#define EFI_CPUID_BRAND_STRING1 0x80000002 +#define EFI_CPUID_BRAND_STRING2 0x80000003 +#define EFI_CPUID_BRAND_STRING3 0x80000004 + +// +// CPUID version information masks +// Note: leaving masks here is for the compatibility +// use EfiCpuVersion (...) instead +// +#define EFI_CPUID_FAMILY 0x0F00 +#define EFI_CPUID_MODEL 0x00F0 +#define EFI_CPUID_STEPPING 0x000F + +#define EFI_CPUID_PENTIUM_M 0x0600 +#define EFI_CPUID_BANIAS 0x0090 +#define EFI_CPUID_DOTHAN 0x00D0 +#define EFI_CPUID_NETBURST 0x0F00 + +#define EFI_MSR_IA32_PLATFORM_ID 0x17 +#define EFI_MSR_IA32_APIC_BASE 0x1B +#define EFI_MSR_EBC_HARD_POWERON 0x2A +#define EFI_MSR_EBC_SOFT_POWERON 0x2B +#define BINIT_DRIVER_DISABLE 0x40 +#define INTERNAL_MCERR_DISABLE 0x20 +#define INITIATOR_MCERR_DISABLE 0x10 +#define EFI_MSR_EBC_FREQUENCY_ID 0x2C +#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79 +#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B +#define EFI_MSR_PSB_CLOCK_STATUS 0xCD +#define EFI_APIC_GLOBAL_ENABLE 0x800 +#define EFI_MSR_IA32_MISC_ENABLE 0x1A0 +#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000 +#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008 +#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004 +#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002 +#define FAST_STRING_ENABLE_BIT 0x00000001 + +#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200 +#define EFI_CACHE_VARIABLE_MTRR_END 0x20F +#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF +#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000 +#define EFI_CACHE_MTRR_VALID 0x800 +#define EFI_CACHE_FIXED_MTRR_VALID 0x400 +#define EFI_MSR_VALID_MASK 0xFFFFFFFFF + +#define EFI_IA32_MTRR_FIX64K_00000 0x250 +#define EFI_IA32_MTRR_FIX16K_80000 0x258 +#define EFI_IA32_MTRR_FIX16K_A0000 0x259 +#define EFI_IA32_MTRR_FIX4K_C0000 0x268 +#define EFI_IA32_MTRR_FIX4K_C8000 0x269 +#define EFI_IA32_MTRR_FIX4K_D0000 0x26A +#define EFI_IA32_MTRR_FIX4K_D8000 0x26B +#define EFI_IA32_MTRR_FIX4K_E0000 0x26C +#define EFI_IA32_MTRR_FIX4K_E8000 0x26D +#define EFI_IA32_MTRR_FIX4K_F0000 0x26E +#define EFI_IA32_MTRR_FIX4K_F8000 0x26F + +#define EFI_IA32_MCG_CAP 0x179 +#define EFI_IA32_MCG_CTL 0x17B +#define EFI_IA32_MC0_CTL 0x400 +#define EFI_IA32_MC0_STATUS 0x401 + +#define EFI_CACHE_UNCACHEABLE 0 +#define EFI_CACHE_WRITECOMBINING 1 +#define EFI_CACHE_WRITETHROUGH 4 +#define EFI_CACHE_WRITEPROTECTED 5 +#define EFI_CACHE_WRITEBACK 6 + +// +// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number +// +#define EfiMakeCpuVersion(f, m, s) \ + (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s))) + +typedef struct { + UINT32 HeaderVersion; + UINT32 UpdateRevision; + UINT32 Date; + UINT32 ProcessorId; + UINT32 Checksum; + UINT32 LoaderRevision; + UINT32 ProcessorFlags; + UINT32 DataSize; + UINT32 TotalSize; + UINT8 Reserved[12]; +} EFI_CPU_MICROCODE_HEADER; + +typedef struct { + UINT32 ExtSigCount; + UINT32 ExtChecksum; + UINT8 Reserved[12]; + UINT32 ProcessorId; + UINT32 ProcessorFlags; + UINT32 Checksum; +} EFI_CPU_MICROCODE_EXT_HEADER; + +typedef struct { + UINT32 RegEax; + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; +} EFI_CPUID_REGISTER; + +VOID +EfiWriteMsr ( + IN UINT32 Input, + IN UINT64 Value + ) +/*++ + +Routine Description: + + Write Cpu MSR + +Arguments: + + Input -The index value to select the register + Value -The value to write to the selected register + +Returns: + + None + +--*/ +; + +UINT64 +EfiReadMsr ( + IN UINT32 Input + ) +/*++ + +Routine Description: + + Read Cpu MSR. + +Arguments: + + Input: -The index value to select the register + +Returns: + + Return the read data + +--*/ +; + +VOID +EfiCpuid ( + IN UINT32 RegEax, + OUT EFI_CPUID_REGISTER *Reg + ) +/*++ + +Routine Description: + + Get the Cpu info by excute the CPUID instruction. + +Arguments: + + RegEax -The input value to put into register EAX + Reg -The Output value + +Returns: + + None + +--*/ +; + +VOID +EfiCpuVersion ( + IN UINT16 *FamilyId, OPTIONAL + IN UINT8 *Model, OPTIONAL + IN UINT8 *SteppingId, OPTIONAL + IN UINT8 *Processor OPTIONAL + ) +/*++ + +Routine Description: + Extract CPU detail version infomation + +Arguments: + FamilyId - FamilyId, including ExtendedFamilyId + Model - Model, including ExtendedModel + SteppingId - SteppingId + Processor - Processor + +--*/ +; + +UINT64 +EfiReadTsc ( + VOID + ) +/*++ + +Routine Description: + + Read Time stamp. + +Arguments: + + None + +Returns: + + Return the read data + +--*/ +; +VOID +EfiCpuidExt ( + IN UINT32 RegisterInEax, + IN UINT32 CacheLevel, + OUT EFI_CPUID_REGISTER *Regs + ) +/*++ +Routine Description: + When RegisterInEax != 4, the functionality is the same as EfiCpuid. + When RegisterInEax == 4, the function return the deterministic cache + parameters by excuting the CPUID instruction +Arguments: + RegisterInEax: - The input value to put into register EAX + CacheLevel: - The deterministic cache level + Regs: - The Output value +Returns: + None +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/ProcDep.h new file mode 100644 index 0000000000..950b9661aa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32/ProcDep.h @@ -0,0 +1,26 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ProcDep.h + +Abstract: + + IA-32 specific Runtime Lib code. At this time there is non. + IPF has different code due to extra API requirements. + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h new file mode 100644 index 0000000000..976d3dcf59 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Ia32EfiRuntimeDriverLib.h + +Abstract: + + Light weight lib to support IA32 EFI Libraries. + +--*/ + +#ifndef _IA32_EFI_RUNTIME_LIB_H_ +#define _IA32_EFI_RUNTIME_LIB_H_ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) + +typedef +EFI_STATUS +(EFIAPI *COMMON_PROC_ENTRY) ( + IN UINTN FunctionId, + IN UINTN Arg2, + IN UINTN Arg3, + IN UINTN Arg4, + IN UINTN Arg5, + IN UINTN Arg6, + IN UINTN Arg7, + IN UINTN Arg8 + ); + +typedef struct { + COMMON_PROC_ENTRY CommonProcEntry; +} COMMON_PROC_ENTRY_STRUCT; + +EFI_STATUS +InstallPlatformRuntimeLib ( + IN EFI_GUID *Guid, + IN COMMON_PROC_ENTRY_STRUCT *CommonEntry + ) +/*++ + +Routine Description: + + Install platform runtime lib. + +Arguments: + + Guid - Guid for runtime lib + CommonEntry - Common entry + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +GetPlatformRuntimeLib ( + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Get platform runtime lib. + +Arguments: + + SystemTable - Pointer to system table + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +ConvertPlatformRuntimeLibPtr ( + IN EFI_RUNTIME_SERVICES *mRT + ) +/*++ + +Routine Description: + + Convert platform runtime lib pointer. + +Arguments: + + mRT - Pointer to runtime service table. + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h new file mode 100644 index 0000000000..a2a9ec12c3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h @@ -0,0 +1,93 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuFuncs.h + +Abstract: + +--*/ + +#ifndef _CPU_FUNCS_H +#define _CPU_FUNCS_H + +#define EFI_CPUID_SIGNATURE 0x0 +#define EFI_CPUID_VERSION_INFO 0x1 +#define EFI_CPUID_CACHE_INFO 0x2 +#define EFI_CPUID_SERIAL_NUMBER 0x3 +#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000 +#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001 +#define EFI_CPUID_BRAND_STRING1 0x80000002 +#define EFI_CPUID_BRAND_STRING2 0x80000003 +#define EFI_CPUID_BRAND_STRING3 0x80000004 + +#define EFI_MSR_IA32_APIC_BASE 0x1B +#define EFI_MSR_EBC_HARD_POWERON 0x2A +#define EFI_MSR_EBC_SOFT_POWERON 0x2B +#define EFI_MSR_EBC_FREQUENCY_ID 0x2C +#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79 +#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B +#define EFI_APIC_GLOBAL_ENABLE 0x800 + +#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200 +#define EFI_CACHE_VARIABLE_MTRR_END 0x20F +#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF +#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000 +#define EFI_CACHE_MTRR_VALID 0x800 +#define EFI_CACHE_FIXED_MTRR_VALID 0x400 +#define EFI_MSR_VALID_MASK 0xFFFFFFFFF + +#define EFI_IA32_MTRR_FIX64K_00000 0x250 +#define EFI_IA32_MTRR_FIX16K_80000 0x258 +#define EFI_IA32_MTRR_FIX16K_A0000 0x259 +#define EFI_IA32_MTRR_FIX4K_C0000 0x268 +#define EFI_IA32_MTRR_FIX4K_C8000 0x269 +#define EFI_IA32_MTRR_FIX4K_D0000 0x26A +#define EFI_IA32_MTRR_FIX4K_D8000 0x26B +#define EFI_IA32_MTRR_FIX4K_E0000 0x26C +#define EFI_IA32_MTRR_FIX4K_E8000 0x26D +#define EFI_IA32_MTRR_FIX4K_F0000 0x26E +#define EFI_IA32_MTRR_FIX4K_F8000 0x26F + +#define EFI_IA32_MCG_CAP 0x179 +#define EFI_IA32_MCG_CTL 0x17B +#define EFI_IA32_MC0_CTL 0x400 +#define EFI_IA32_MC0_STATUS 0x401 + +#define EFI_CACHE_UNCACHEABLE 0 +#define EFI_CACHE_WRITECOMBINING 1 +#define EFI_CACHE_WRITETHROUGH 4 +#define EFI_CACHE_WRITEPROTECTED 5 +#define EFI_CACHE_WRITEBACK 6 + +UINT64 +EfiReadTsc ( + VOID + ) +/*++ + +Routine Description: + + Read Time stamp. + +Arguments: + + None + +Returns: + + Return the read data + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h new file mode 100644 index 0000000000..c46ffbca7e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h @@ -0,0 +1,1305 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EsalRuntimeLib.h + +Abstract: + + SAL Driver Lib + +Revision History + +--*/ + +#ifndef _ESAL_RUNTIME_LIB_H_ +#define _ESAL_RUNTIME_LIB_H_ + +#include "SalApi.h" +#include "EfiFirmwareVolumeHeader.h" + +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) + +VOID +EsalRuntimeLibVirtualNotify ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ImageHandle - Image Handle + SystemTable - the System Table + +Returns: + + TODO: add return values + +--*/ +; +SAL_RETURN_REGS +CallEsalService ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ClassGuid - TODO: add argument description + FunctionId - TODO: add argument description + Arg2 - TODO: add argument description + Arg3 - TODO: add argument description + Arg4 - TODO: add argument description + Arg5 - TODO: add argument description + Arg6 - TODO: add argument description + Arg7 - TODO: add argument description + Arg8 - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// Assembly Functions +// + +SAL_RETURN_REGS +EsalGetEntryPoint ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetPhysicalEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + EntryPoint - TODO: add argument description + Gp - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetVirtualEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + EntryPoint - TODO: add argument description + Gp - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetPhysicalModuleGlobal ( + IN VOID *Global + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Global - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalSetVirtualModuleGlobal ( + IN VOID *Global + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Global - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalGetModuleGlobal ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +GetIrrData ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +GetPsrData ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +GetProcIdData ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +VOID +SwitchCpuStack ( + IN UINT64 NewBsp, + IN UINT64 OldBsp + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + NewBsp - TODO: add argument description + OldBsp - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// PAL PROC Class +// + +SAL_RETURN_REGS +SalPalProc ( + IN UINT64 Arg1, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4 + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Arg1 - TODO: add argument description + Arg2 - TODO: add argument description + Arg3 - TODO: add argument description + Arg4 - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalRegisterNewPalEntry ( + IN BOOLEAN PhysicalPalAddress, + IN EFI_PHYSICAL_ADDRESS NewPalAddress + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + PhysicalPalAddress - TODO: add argument description + NewPalAddress - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalGetPalEntryPointer ( + IN BOOLEAN PhysicalPalAddress + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + PhysicalPalAddress - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// SAL BASE Class +// + +SAL_RETURN_REGS +SalProcSetVectors ( + IN UINT64 SalVectorType, + IN UINT64 PhyAddr1, + IN UINT64 Gp1, + IN UINT64 LengthCs1, + IN UINT64 PhyAddr2, + IN UINT64 Gp2, + IN UINT64 LengthCs2 + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + SalVectorType - TODO: add argument description + PhyAddr1 - TODO: add argument description + Gp1 - TODO: add argument description + LengthCs1 - TODO: add argument description + PhyAddr2 - TODO: add argument description + Gp2 - TODO: add argument description + LengthCs2 - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalProcMcRendez ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalProcMcSetParams ( + IN UINT64 ParamType, + IN UINT64 IntOrMem, + IN UINT64 IntOrMemVal, + IN UINT64 Timeout, + IN UINT64 McaOpt + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ParamType - TODO: add argument description + IntOrMem - TODO: add argument description + IntOrMemVal - TODO: add argument description + Timeout - TODO: add argument description + McaOpt - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetVectors ( + IN UINT64 VectorType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + VectorType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetParams ( + IN UINT64 ParamInfoType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ParamInfoType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetMcParams ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetMcCheckinFlags ( + IN UINT64 ProcessorUnit + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ProcessorUnit - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// Sal Base Class enums +// + +typedef enum { + McaVector, + BspInitVector, + BootRendezVector, + ApInitVector +} ESAL_GET_VECTOR_TYPE; + +SAL_RETURN_REGS +SalInitializeThreshold ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ThresholdStruct - TODO: add argument description + Count - TODO: add argument description + Duration - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalBumpThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ThresholdStruct - TODO: add argument description + Count - TODO: add argument description + Duration - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +SalGetThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ThresholdStruct - TODO: add argument description + Count - TODO: add argument description + Duration - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// Common Lib Function +// + +EFI_STATUS +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + FunctionId - TODO: add argument description + ClassGuid - TODO: add argument description + Function - TODO: add argument description + ModuleGlobal - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +RegisterEsalClass ( + IN EFI_GUID *ClassGuid, + IN VOID *ModuleGlobal, + ... + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ClassGuid - TODO: add argument description + ModuleGlobal - TODO: add argument description + ... - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// MP Class Functions +// +SAL_RETURN_REGS +LibMpAddCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + Enabled - TODO: add argument description + PalCompatability - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpRemoveCpuData ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpModifyCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + Enabled - TODO: add argument description + PalCompatability - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpGetCpuDataByID ( + IN UINT64 CpuGlobalId, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + IndexByEnabledCpu - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpGetCpuDataByIndex ( + IN UINT64 Index, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Index - TODO: add argument description + IndexByEnabledCpu - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpSendIpi ( + IN UINT64 ProcessorNumber, + IN UINT64 VectorNumber, + IN EFI_DELIVERY_MODE DeliveryMode, + IN BOOLEAN IRFlag + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + ProcessorNumber - TODO: add argument description + VectorNumber - TODO: add argument description + DeliveryMode - TODO: add argument description + IRFlag - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpCurrentProcessor ( + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + IndexByEnabledCpu - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibGetNumProcessors ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpSaveMinStatePointer ( + IN UINT64 CpuGlobalId, + IN EFI_PHYSICAL_ADDRESS MinStatePointer + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + MinStatePointer - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +SAL_RETURN_REGS +LibMpRestoreMinStatePointer ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuGlobalId - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// MCA Class Functions +// + +EFI_STATUS +LibMcaGetStateInfo ( + IN UINT64 CpuId, + OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer, + OUT UINT64 *RequiredStateBufferSize + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuId - TODO: add argument description + StateBufferPointer - TODO: add argument description + RequiredStateBufferSize - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibMcaRegisterCpu ( + IN UINT64 CpuId, + IN EFI_PHYSICAL_ADDRESS StateBufferAddress + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + CpuId - TODO: add argument description + StateBufferAddress - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// FVB Variables Class +// +EFI_STATUS +EsalReadBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + Offset - TODO: add argument description + NumBytes - TODO: add argument description + Buffer - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalWriteBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + Offset - TODO: add argument description + NumBytes - TODO: add argument description + Buffer - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalEraseBlock ( + IN UINTN Instance, + IN UINTN Lba + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalGetVolumeAttributes ( + IN UINTN Instance, + OUT EFI_FVB_ATTRIBUTES *Attributes + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Attributes - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalSetVolumeAttributes ( + IN UINTN Instance, + IN EFI_FVB_ATTRIBUTES Attributes + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Attributes - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalGetPhysicalAddress ( + IN UINTN Instance, + OUT EFI_PHYSICAL_ADDRESS *Address + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Address - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +EsalGetBlockSize ( + IN UINTN Instance, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + Instance - TODO: add argument description + Lba - TODO: add argument description + BlockSize - TODO: add argument description + NumOfBlocks - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +// +// SAL ELOG Functions +// +EFI_STATUS +LibSalGetStateInfo ( + IN UINT64 McaType, + IN UINT8 *McaBuffer, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + McaBuffer - TODO: add argument description + Size - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibSalGetStateInfoSize ( + IN UINT64 McaType, + OUT UINTN *Size + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + Size - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibSalClearStateInfo ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibEsalGetStateBuffer ( + IN UINT64 McaType, + OUT UINT8 **McaBuffer, + OUT UINTN *Index + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + McaBuffer - TODO: add argument description + Index - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +EFI_STATUS +LibEsalSaveStateBuffer ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + McaType - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/ProcDep.h new file mode 100644 index 0000000000..a882044649 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/ProcDep.h @@ -0,0 +1,119 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ProcDep.h + +Abstract: + + IPF specific Runtime Lib code. IPF has a SAL API that does not + exit on IA-32. Thus + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#include "SalApi.h" + +EFI_STATUS +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + Register ESAL Class Function and it's asociated global. + This function is boot service only! + +Arguments: + FunctionId - ID of function to register + ClassGuid - GUID of function class + Function - Function to register under ClassGuid/FunctionId pair + ModuleGlobal - Module global for Function. + +Returns: + EFI_SUCCESS - If ClassGuid/FunctionId Function was registered. + +--*/ +; + +EFI_STATUS +RegisterEsalClass ( + IN EFI_GUID *ClassGuid, + IN VOID *ModuleGlobal, + ... + ) +/*++ + +Routine Description: + + Register ESAL Class and it's asociated global. + This function is boot service only! + +Arguments: + ClassGuid - GUID of function class + ModuleGlobal - Module global for Function. + .. - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL + indicates the end of the list. + +Returns: + EFI_SUCCESS - All members of ClassGuid registered + +--*/ +; + +SAL_RETURN_REGS +EfiCallEsalService ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ) +/*++ + +Routine Description: + + Call module that is not linked direclty to this module. This code is IP + relative and hides the binding issues of virtual or physical calling. The + function that gets dispatched has extra arguments that include the registered + module global and a boolean flag to indicate if the system is in virutal mode. + +Arguments: + ClassGuid - GUID of function + FunctionId - Function in ClassGuid to call + Arg2 - Argument 2 ClassGuid/FunctionId defined + Arg3 - Argument 3 ClassGuid/FunctionId defined + Arg4 - Argument 4 ClassGuid/FunctionId defined + Arg5 - Argument 5 ClassGuid/FunctionId defined + Arg6 - Argument 6 ClassGuid/FunctionId defined + Arg7 - Argument 7 ClassGuid/FunctionId defined + Arg8 - Argument 8 ClassGuid/FunctionId defined + +Returns: + Status of ClassGuid/FuncitonId + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h new file mode 100644 index 0000000000..473cbfbda6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h @@ -0,0 +1,1454 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SalDriverLib.h + +Abstract: + + SAL Driver Lib + +Revision History + +--*/ + +#ifndef _SAL_DRIVER_LIB_H_ +#define _SAL_DRIVER_LIB_H_ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "SalApi.h" + +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) + +// +// Assembly Functions +// +SAL_RETURN_REGS +LibGetEsalPhyData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in physical mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetEsalVirtData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in virtual mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetEsalPhyData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in physical mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetEsalVirtData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in virtual mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetGlobalPhyData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in physical mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetGlobalVirtData ( + VOID + ) +/*++ + +Routine Description: + + Get Esal global data in virtual mode. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetGlobalPhyData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in physical mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibSetGlobalVirtData ( + IN VOID *Ptr, + IN UINT64 GP + ) +/*++ + +Routine Description: + + Set Esal global data in virtual mode. + +Arguments: + + Ptr - Pointer to the data + GP - Global pointer + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +GetIrrData ( + VOID + ) +/*++ + +Routine Description: + + Get interrupt request register. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +VOID +PrepareApsForHandOverToOS ( + VOID + ) +/*++ + +Routine Description: + + Prepare AP info for hand over to OS. + +Arguments: + + None + +Returns: + + None + +--*/ +; + +VOID +HandOverApsToOS ( + IN UINT64 a1, + IN UINT64 a2, + IN UINT64 a3 + ) +/*++ + +Routine Description: + + Hand over AP info to OS. + +Arguments: + + a1 - Address to call into + + a2 - GP + + a3 - Undefined + +Returns: + + None + +--*/ +; + +SAL_RETURN_REGS +GetPsrData ( + VOID + ) +/*++ + +Routine Description: + + Get PSR register. + +Arguments: + + None + +Returns: + + Output regs. + +--*/ +; + +SAL_RETURN_REGS +GetProcIdData ( + VOID + ) +/*++ + +Routine Description: + + Get LID + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +VOID +SwitchCpuStack ( + IN UINT64 NewBsp, + IN UINT64 OldBsp + ) +/*++ + +Routine Description: + + Switch BSP + +Arguments: + + NewBsp - New BSP index + OldBsp - Old BSP index + +Returns: + + None + +--*/ +; + +// +// SAL Reset Class +// +VOID +SalResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Reset system + +Arguments: + + ResetType - Reset type + ResetStatus - Reset status + DataSize - Size of ResetData + ResetData - Description string + +Returns: + + None + +--*/ +; + +// +// PAL PROC Class +// +SAL_RETURN_REGS +SalPalProc ( + IN UINT64 Arg1, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4 + ) +/*++ + +Routine Description: + + Call pal proc. + +Arguments: + + Arg1 - Pal call index + Arg2 - First arg + Arg3 - Second arg + Arg4 - Third arg + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalRegisterNewPalEntry ( + IN BOOLEAN PhysicalPalAddress, + IN EFI_PHYSICAL_ADDRESS NewPalAddress + ) +/*++ + +Routine Description: + + Register Pal entry. + +Arguments: + + PhysicalPalAddress - The address is physical or virtual + NewPalAddress - New Pal entry address + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalGetPalEntryPointer ( + IN BOOLEAN PhysicalPalAddress + ) +/*++ + +Routine Description: + + Get Pal entry. + +Arguments: + + PhysicalPalAddress - The address is physical or virtual + +Returns: + + Output regs + +--*/ +; + +// +// SAL MTC Class +// +EFI_STATUS +SalGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Get next high 32 bits of monotonic count. + +Arguments: + + HighCount - High 32 bits of monotonic count. + +Returns: + + Status code + +--*/ +; + +// +// SAL BASE Class +// +SAL_RETURN_REGS +SalProcSetVectors ( + IN UINT64 SalVectorType, + IN UINT64 PhyAddr1, + IN UINT64 Gp1, + IN UINT64 LengthCs1, + IN UINT64 PhyAddr2, + IN UINT64 Gp2, + IN UINT64 LengthCs2 + ) +/*++ + +Routine Description: + + Set vectors. + +Arguments: + + SalVectorType - Vector type + PhyAddr1 - OS MCA entry point + Gp1 - GP for OS MCA entry + LengthCs1 - Length of OS MCA + PhyAddr2 - OS INIT entry point + Gp2 - GP for OS Init entry + LengthCs2 - Length of OS INIT + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalProcMcRendez ( + VOID + ) +/*++ + +Routine Description: + + Mc rendezvous function. + +Arguments: + + None + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalProcMcSetParams ( + IN UINT64 ParamType, + IN UINT64 IntOrMem, + IN UINT64 IntOrMemVal, + IN UINT64 Timeout, + IN UINT64 McaOpt + ) +/*++ + +Routine Description: + + Set MCA parameters. + +Arguments: + + ParamType - Parameter type + IntOrMem - Interrupt or memory address + IntOrMemVal - Interrupt number or memory address value + Timeout - Time out value + McaOpt - Option for MCA + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetVectors ( + IN UINT64 VectorType + ) +/*++ + +Routine Description: + + Get OS MCA vector. + +Arguments: + + VectorType - Vector type + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetParams ( + IN UINT64 ParamInfoType + ) +/*++ + +Routine Description: + + Get MCA parameter. + +Arguments: + + ParamInfoType - Parameter info type + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcMcGetMcParams ( + VOID + ) +/*++ + +Routine Description: + + Get MCA parameter. + +Arguments: + + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +EsalProcGetMcCheckinFlags ( + IN UINT64 ProcessorUnit + ) +/*++ + +Routine Description: + + Get process status. + +Arguments: + + ProcessorUnit - Processor Index + +Returns: + + Output regs + +--*/ +; + +// +// Sal Base Class enums +// +typedef enum { + McaVector, + BspInitVector, + BootRendezVector, + ApInitVector +} ESAL_GET_VECTOR_TYPE; + +// +// Sal RTC Class +// +EFI_STATUS +SalGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +SalSetTime ( + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +SalGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +SalSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +; + +SAL_RETURN_REGS +SalInitializeThreshold ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + Init threshold structure. + +Arguments: + + ThresholdStruct - Threshold structure + Count - Threshold count + Duration - Duration + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalBumpThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + Bump threshold count. + +Arguments: + + ThresholdStruct - Threshold structure + Count - Threshold count + Duration - Duration + +Returns: + + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalGetThresholdCount ( + IN VOID *ThresholdStruct, + IN UINT64 Count, + IN UINT64 Duration + ) +/*++ + +Routine Description: + + Get threshold structure. + +Arguments: + + ThresholdStruct - Threshold structure + Count - Threshold count + Duration - Duration + +Returns: + + Output regs + +--*/ +; + +// +// Common Lib Function +// +EFI_STATUS +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + Register ESAL Class Function and it's asociated global. + This function is boot service only! + +Arguments: + FunctionId - ID of function to register + ClassGuid - GUID of function class + Function - Function to register under ClassGuid/FunctionId pair + ModuleGlobal - Module global for Function. + +Returns: + EFI_SUCCESS - If ClassGuid/FunctionId Function was registered. + +--*/ +; + +EFI_STATUS +EfiInitializeSalDriverLib ( + IN BOOLEAN Runtime + ) +/*++ + +Routine Description: + + Initialize Sal driver lib. + +Arguments: + Runtime - At runtime or not? + +Returns: + Status code + +--*/ +; + +// +// MCA PMI INIT Registeration Functions. +// +EFI_STATUS +LibRegisterMcaFunction ( + IN EFI_SAL_MCA_HANDLER McaHandler, + IN VOID *ModuleGlobal, + IN BOOLEAN MakeFirst, + IN BOOLEAN MakeLast + ) +/*++ + +Routine Description: + + Register MCA handler. + +Arguments: + McaHandler - MCA handler + ModuleGlobal - Module global for function + MakeFirst - Make it as first? + MakeLast - Make it as last? + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibRegisterPmiFunction ( + IN EFI_SAL_PMI_HANDLER PmiHandler, + IN VOID *ModuleGlobal, + IN BOOLEAN MakeFirst, + IN BOOLEAN MakeLast + ) +/*++ + +Routine Description: + + Register PMI handler. + +Arguments: + PmiHandler - PMI handler + ModuleGlobal - Module global for function + MakeFirst - Make it as first? + MakeLast - Make it as last? + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibRegisterInitFunction ( + IN EFI_SAL_INIT_HANDLER InitHandler, + IN VOID *ModuleGlobal, + IN BOOLEAN MakeFirst, + IN BOOLEAN MakeLast + ) +/*++ + +Routine Description: + + Register INIT handler. + +Arguments: + InitHandler - INIT handler + ModuleGlobal - Module global for function + MakeFirst - Make it as first? + MakeLast - Make it as last? + +Returns: + Status code + +--*/ +; + +// +// Base IO Class Functions +// +EFI_STATUS +ESalIoRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io read operation. + +Arguments: + + Width - Width of read operation + Address - Start IO address to read + Count - Read count + Buffer - Buffer to store result + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +ESalIoWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io write operation. + +Arguments: + + Width - Width of write operation + Address - Start IO address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +; + +EFI_STATUS +ESalMemRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a Memory mapped IO read into Buffer. + +Arguments: + Width - Width of each read transaction. + Address - Memory mapped IO address to read + Count - Number of Width quanta to read + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +; + +EFI_STATUS +ESalMemWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a memory mapped IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +; + +// +// PCI Class Functions +// +SAL_RETURN_REGS +SalPCIConfigRead ( + IN UINT64 Address, + IN UINT64 Size + ) +/*++ + +Routine Description: + Pci config space read. + +Arguments: + Address - PCI address to read + Size - Size to read + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +SalPCIConfigWrite ( + IN UINT64 Address, + IN UINT64 Size, + IN UINT64 Value + ) +/*++ + +Routine Description: + Pci config space write. + +Arguments: + Address - PCI address to write + Size - Size to write + Value - Value to write + +Returns: + Output regs + +--*/ +; + +// +// MP Class Functions +// +SAL_RETURN_REGS +LibMPAddCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + Add CPU data. + +Arguments: + CpuGlobalId - CPU ID + Enabled - Enabled or not + PalCompatability - Pal compatability + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPRemoveCpuData ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + Remove CPU data. + +Arguments: + CpuGlobalId - CPU ID + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPModifyCpuData ( + IN UINT64 CpuGlobalId, + IN BOOLEAN Enabled, + IN UINT64 PalCompatability + ) +/*++ + +Routine Description: + Modify CPU data. + +Arguments: + CpuGlobalId - CPU ID + Enabled - Enabled or not + PalCompatability - Pal compatability + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPGetCpuDataByID ( + IN UINT64 CpuGlobalId, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + Get CPU data. + +Arguments: + CpuGlobalId - CPU ID + IndexByEnabledCpu - Whether indexed by enabled CPU + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPGetCpuDataByIndex ( + IN UINT64 Index, + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + Get CPU data. + +Arguments: + Index - CPU index + IndexByEnabledCpu - Whether indexed by enabled CPU + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMPSendIpi ( + IN UINT64 ProcessorNumber, + IN UINT64 VectorNumber, + IN EFI_DELIVERY_MODE DeliveryMode, + IN BOOLEAN IRFlag + ) +/*++ + +Routine Description: + Send IPI. + +Arguments: + ProcessorNumber - Processor number + VectorNumber - Vector number + DeliveryMode - Delivery mode + IRFlag - Interrupt Redirection flag + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMpCurrentProcessor ( + IN BOOLEAN IndexByEnabledCpu + ) +/*++ + +Routine Description: + Get current processor index. + +Arguments: + IndexByEnabledCpu - Whether indexed by enabled CPU + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibGetNumProcessors ( + VOID + ) +/*++ + +Routine Description: + Get number of processors. + +Arguments: + None + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMpSaveMinStatePointer ( + IN UINT64 CpuGlobalId, + IN EFI_PHYSICAL_ADDRESS MinStatePointer + ) +/*++ + +Routine Description: + Register pointer to save min state. + +Arguments: + CpuGlobalId - CPU global ID + MinStatePointer - Pointer to save min state + +Returns: + Output regs + +--*/ +; + +SAL_RETURN_REGS +LibMpRestoreMinStatePointer ( + IN UINT64 CpuGlobalId + ) +/*++ + +Routine Description: + Restore pointer to save min state. + +Arguments: + CpuGlobalId - CPU global ID + +Returns: + Output regs + +--*/ +; + +// +// MCA Class Functions +// +EFI_STATUS +LibMcaGetStateInfo ( + IN UINT64 CpuId, + OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer, + OUT UINT64 *RequiredStateBufferSize + ) +/*++ + +Routine Description: + MCA get state info. + +Arguments: + CpuId - CPU ID + StateBufferPointer - Pointer of state buffer + RequiredStateBufferSize - Size of required state buffer + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibMcaRegisterCpu ( + IN UINT64 CpuId, + IN EFI_PHYSICAL_ADDRESS StateBufferAddress + ) +/*++ + +Routine Description: + MCA register CPU state info. + +Arguments: + CpuId - CPU ID + StateBufferAddress - Pointer of state buffer + +Returns: + Status code + +--*/ +; + +// +// SAL ELOG Functions +// +EFI_STATUS +LibSalGetStateInfo ( + IN UINT64 McaType, + IN UINT8 *McaBuffer, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Get state info. + +Arguments: + McaType - MCA type + McaBuffer - Info buffer provided by caller + Size - Size of info + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibSalGetStateInfoSize ( + IN UINT64 McaType, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Get state info size. + +Arguments: + McaType - MCA type + Size - Size required + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibSalClearStateInfo ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + Clear state info. + +Arguments: + McaType - MCA type + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibEsalGetStateBuffer ( + IN UINT64 McaType, + OUT UINT8 **McaBuffer, + OUT UINTN *Index + ) +/*++ + +Routine Description: + Get state buffer. + +Arguments: + McaType - MCA type + McaBuffer - MCA buffer + Index - CPU index + +Returns: + Status code + +--*/ +; + +EFI_STATUS +LibEsalSaveStateBuffer ( + IN UINT64 McaType + ) +/*++ + +Routine Description: + Save state buffer. + +Arguments: + McaType - MCA type + +Returns: + Status code + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h new file mode 100644 index 0000000000..4293820dff --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h @@ -0,0 +1,310 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LinkedList.h + +Abstract: + + This implementation of a linked list provides data structures for the + list itself and for list nodes. It provides operations for initializing + the list, modifying the list, and walking the list. + +--*/ + +// +// Prevent multiple includes in the same source file +// +#ifndef _LINKED_LIST_H_ +#define _LINKED_LIST_H_ + + +typedef struct _EFI_LIST_ENTRY { + struct _EFI_LIST_ENTRY *ForwardLink; + struct _EFI_LIST_ENTRY *BackLink; +} EFI_LIST_ENTRY; + +typedef EFI_LIST_ENTRY EFI_LIST; +typedef EFI_LIST_ENTRY EFI_LIST_NODE; + +#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead} + +// +// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure +// + +#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field))) + +// +// A lock structure +// + +typedef struct { + EFI_TPL Tpl; + EFI_TPL OwnerTpl; + UINTN Lock; +} FLOCK; + +VOID +InitializeListHead ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Initialize the head of the List. The caller must allocate the memory + for the EFI_LIST. This function must be called before the other linked + list macros can be used. + +Arguments: + + List - Pointer to list head to initialize + +Returns: + + None. + +--*/ +; + +BOOLEAN +IsListEmpty ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Return TRUE is the list contains zero nodes. Otherzise return FALSE. + The list must have been initialized with InitializeListHead () before using + this function. + +Arguments: + + List - Pointer to list head to test + + +Returns: + + Return TRUE is the list contains zero nodes. Otherzise return FALSE. + +--*/ +; + +VOID +RemoveEntryList ( + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Remove Node from the doubly linked list. It is the caller's responsibility + to free any memory used by the entry if needed. The list must have been + initialized with InitializeListHead () before using this function. + +Arguments: + + Entry - Element to remove from the list. + +Returns: + + None + +--*/ +; + +VOID +InsertTailList ( + EFI_LIST_ENTRY *ListHead, + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Insert a Node into the end of a doubly linked list. The list must have + been initialized with InitializeListHead () before using this function. + +Arguments: + + ListHead - Head of doubly linked list + + Entry - Element to insert at the end of the list. + +Returns: + + None + +--*/ +; + +VOID +InsertHeadList ( + EFI_LIST_ENTRY *ListHead, + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Insert a Node into the start of a doubly linked list. The list must have + been initialized with InitializeListHead () before using this function. + +Arguments: + + ListHead - Head of doubly linked list + + Entry - Element to insert to beginning of list + +Returns: + + None + +--*/ +; + +VOID +SwapListEntries ( + EFI_LIST_ENTRY *Entry1, + EFI_LIST_ENTRY *Entry2 + ) +/*++ + +Routine Description: + + Swap the location of the two elements of a doubly linked list. Node2 + is placed in front of Node1. The list must have been initialized with + InitializeListHead () before using this function. + +Arguments: + + Entry1 - Element in the doubly linked list in front of Node2. + + Entry2 - Element in the doubly linked list behind Node1. + +Returns: + + None + +--*/ +; + +EFI_LIST_ENTRY * +GetFirstNode ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Return the first node pointed to by the list head. The list must + have been initialized with InitializeListHead () before using this + function and must contain data. + +Arguments: + + List - The head of the doubly linked list. + +Returns: + + Pointer to the first node, if the list contains nodes. The list will + return a null value--that is, the value of List--when the list is empty. + See the description of IsNull for more information. + + +--*/ +; + +EFI_LIST_ENTRY * +GetNextNode ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Returns the node following Node in the list. The list must + have been initialized with InitializeListHead () before using this + function and must contain data. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node in the list. This value MUST NOT be the literal value NULL. + See the description of IsNull for more information. + +Returns: + + Pointer to the next node, if one exists. Otherwise, returns a null value, + which is actually a pointer to List. + See the description of IsNull for more information. + +--*/ +; + +BOOLEAN +IsNull ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Determines whether the given node is null. Note that Node is null + when its value is equal to the value of List. It is an error for + Node to be the literal value NULL [(VOID*)0x0]. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node to test. MUST NOT be the literal value NULL. See + the description above. + +Returns: + + Returns true if the node is null. + +--*/ +; + +BOOLEAN +IsNodeAtEnd ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Determines whether the given node is at the end of the list. Used + to walk the list. The list must have been initialized with + InitializeListHead () before using this function and must contain + data. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node to test. MUST NOT be the literal value NULL. + See the description of IsNull for more information. + +Returns: + + Returns true if the list is the tail. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/RtDevicePath.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/RtDevicePath.h new file mode 100644 index 0000000000..7c00bd5dd1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/RtDevicePath.h @@ -0,0 +1,231 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RtDevicePath.h + +Abstract: + + Device Path services. The thing to remember is device paths are built out of + nodes. The device path is terminated by an end node that is length + sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL) + all over this file. + + The only place where multi-instance device paths are supported is in + environment varibles. Multi-instance device paths should never be placed + on a Handle. + +--*/ +#ifndef _RT_DEVICE_PATH_H_ +#define _RT_DEVICE_PATH_H_ + +BOOLEAN +RtEfiIsDevicePathMultiInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + Return TRUE is this is a multi instance device path. + +Arguments: + DevicePath - A pointer to a device path data structure. + + +Returns: + TRUE - If DevicePath is multi instance. + FALSE - If DevicePath is not multi instance. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Function retrieves the next device path instance from a device path data structure. + +Arguments: + DevicePath - A pointer to a device path data structure. + + Size - A pointer to the size of a device path instance in bytes. + +Returns: + + This function returns a pointer to the current device path instance. + In addition, it returns the size in bytes of the current device path instance in Size, + and a pointer to the next device path instance in DevicePath. + If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + +--*/ +; + +UINTN +RtEfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + + Calculate the size of a whole device path. + +Arguments: + + DevPath - The pointer to the device path data. + +Returns: + + Size of device path data structure.. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a Src1 and Src2 together. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + + A pointer to the new device path is returned. + NULL is returned if space for the new device path could not be allocated from pool. + It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +/*++ + +Routine Description: + + Locate device path protocol interface on a device handle. + +Arguments: + + Handle - The device handle + +Returns: + + Device path protocol interface located. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDuplicateDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ) +/*++ + +Routine Description: + Duplicate a new device path data structure from the old one. + +Arguments: + DevPath - A pointer to a device path data structure. + +Returns: + A pointer to the new allocated device path data. + Caller must free the memory used by DevicePath if it is no longer needed. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a device path node to the end of another device path. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + This function returns a pointer to the new device path. + If there is not enough temporary pool memory available to complete this function, + then NULL is returned. + + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ) +/*++ + +Routine Description: + Create a device path that appends a MEDIA_DEVICE_PATH with + FileNameGuid to the device path of DeviceHandle. + +Arguments: + Device - Optional Device Handle to use as Root of the Device Path + + FileName - FileName + +Returns: + EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory + or NULL pointer. + +--*/ +; + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePathInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *Src, + IN EFI_DEVICE_PATH_PROTOCOL *Instance + ) +/*++ + +Routine Description: + + Append a device path instance to another. + +Arguments: + + Src - The device path instance to be appended with. + Instance - The device path instance appending the other. + +Returns: + + The contaction of these two. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/SmmRuntimeLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/SmmRuntimeLib.h new file mode 100644 index 0000000000..6412a6b01d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/SmmRuntimeLib.h @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SmmRuntimeLib.h + +Abstract: + + SMM Related prototypes that can be referenced for Preboot Configuration only. + +--*/ + +#ifndef _SMM_RUNTIME_LIB_H_ +#define _SMM_RUNTIME_LIB_H_ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" + +BOOLEAN +EfiInSmm ( + VOID + ) +/*++ + +Routine Description: + + Test whether in Smm mode currently. + +Arguments: + + None + +Returns: + + TRUE - In Smm mode + FALSE - Not in Smm mode + +--*/ +; + +EFI_STATUS +RegisterSmmRuntimeDriver ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + OUT EFI_HANDLE *SmmImageHandle + ) +/*++ + +Routine Description: + + Registers a Driver with the SMM. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + SystemTable - A pointer to the EFI System Table. + SmmImageHandle - Image handle returned by the SMM driver. + +Returns: + + Status code + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/CpuFuncs.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/CpuFuncs.h new file mode 100644 index 0000000000..f3b9e41335 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/CpuFuncs.h @@ -0,0 +1,262 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuFuncs.h + +Abstract: + +--*/ + +#ifndef _CPU_FUNCS_H_ +#define _CPU_FUNCS_H_ + +#define EFI_CPUID_SIGNATURE 0x0 +#define EFI_CPUID_VERSION_INFO 0x1 +#define EFI_CPUID_CACHE_INFO 0x2 +#define EFI_CPUID_SERIAL_NUMBER 0x3 +#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000 +#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001 +#define EFI_CPUID_BRAND_STRING1 0x80000002 +#define EFI_CPUID_BRAND_STRING2 0x80000003 +#define EFI_CPUID_BRAND_STRING3 0x80000004 + +// +// CPUID version information masks +// Note: leaving masks here is for the compatibility +// use EfiCpuVersion (...) instead +// + +#define EFI_CPUID_FAMILY 0x0F00 +#define EFI_CPUID_MODEL 0x00F0 +#define EFI_CPUID_STEPPING 0x000F + +#define EFI_CPUID_PENTIUM_M 0x0600 +#define EFI_CPUID_BANIAS 0x0090 +#define EFI_CPUID_DOTHAN 0x00D0 +#define EFI_CPUID_NETBURST 0x0F00 + +#define EFI_MSR_IA32_PLATFORM_ID 0x17 +#define EFI_MSR_IA32_APIC_BASE 0x1B +#define EFI_MSR_EBC_HARD_POWERON 0x2A +#define EFI_MSR_EBC_SOFT_POWERON 0x2B +#define BINIT_DRIVER_DISABLE 0x40 +#define INTERNAL_MCERR_DISABLE 0x20 +#define INITIATOR_MCERR_DISABLE 0x10 +#define EFI_MSR_EBC_FREQUENCY_ID 0x2C +#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79 +#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B +#define EFI_MSR_PSB_CLOCK_STATUS 0xCD +#define EFI_APIC_GLOBAL_ENABLE 0x800 +#define EFI_MSR_IA32_MISC_ENABLE 0x1A0 +#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000 +#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008 +#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004 +#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002 +#define FAST_STRING_ENABLE_BIT 0x00000001 + +#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200 +#define EFI_CACHE_VARIABLE_MTRR_END 0x20F +#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF +#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000 +#define EFI_CACHE_MTRR_VALID 0x800 +#define EFI_CACHE_FIXED_MTRR_VALID 0x400 +#define EFI_MSR_VALID_MASK 0xFFFFFFFFF + +#define EFI_IA32_MTRR_FIX64K_00000 0x250 +#define EFI_IA32_MTRR_FIX16K_80000 0x258 +#define EFI_IA32_MTRR_FIX16K_A0000 0x259 +#define EFI_IA32_MTRR_FIX4K_C0000 0x268 +#define EFI_IA32_MTRR_FIX4K_C8000 0x269 +#define EFI_IA32_MTRR_FIX4K_D0000 0x26A +#define EFI_IA32_MTRR_FIX4K_D8000 0x26B +#define EFI_IA32_MTRR_FIX4K_E0000 0x26C +#define EFI_IA32_MTRR_FIX4K_E8000 0x26D +#define EFI_IA32_MTRR_FIX4K_F0000 0x26E +#define EFI_IA32_MTRR_FIX4K_F8000 0x26F + +#define EFI_IA32_MCG_CAP 0x179 +#define EFI_IA32_MCG_CTL 0x17B +#define EFI_IA32_MC0_CTL 0x400 +#define EFI_IA32_MC0_STATUS 0x401 + +#define EFI_CACHE_UNCACHEABLE 0 +#define EFI_CACHE_WRITECOMBINING 1 +#define EFI_CACHE_WRITETHROUGH 4 +#define EFI_CACHE_WRITEPROTECTED 5 +#define EFI_CACHE_WRITEBACK 6 + +// +// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number +// +#define EfiMakeCpuVersion(f, m, s) \ + (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s))) + + +typedef struct { + UINT32 HeaderVersion; + UINT32 UpdateRevision; + UINT32 Date; + UINT32 ProcessorId; + UINT32 Checksum; + UINT32 LoaderRevision; + UINT32 ProcessorFlags; + UINT32 DataSize; + UINT32 TotalSize; + UINT8 Reserved[12]; +} EFI_CPU_MICROCODE_HEADER; + +typedef struct { + UINT32 ExtSigCount; + UINT32 ExtChecksum; + UINT8 Reserved[12]; + UINT32 ProcessorId; + UINT32 ProcessorFlags; + UINT32 Checksum; +} EFI_CPU_MICROCODE_EXT_HEADER; + +typedef struct { + UINT32 RegEax; + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; +} EFI_CPUID_REGISTER; + +VOID +EfiWriteMsr ( + IN UINT32 Input, + IN UINT64 Value + ) +/*++ + +Routine Description: + + Write Cpu MSR + +Arguments: + + Input -The index value to select the register + Value -The value to write to the selected register + +Returns: + + None + +--*/ +; + +UINT64 +EfiReadMsr ( + IN UINT32 Input + ) +/*++ + +Routine Description: + + Read Cpu MSR. + +Arguments: + + Input: -The index value to select the register + +Returns: + + Return the read data + +--*/ +; + +VOID +EfiCpuid ( + IN UINT32 RegEax, + OUT EFI_CPUID_REGISTER *Reg + ) +/*++ + +Routine Description: + + Get the Cpu info by excute the CPUID instruction. + +Arguments: + + RegEax -The input value to put into register EAX + Reg -The Output value + +Returns: + + None + +--*/ +; + +VOID +EfiCpuVersion ( + IN UINT16 *FamilyId, OPTIONAL + IN UINT8 *Model, OPTIONAL + IN UINT8 *SteppingId, OPTIONAL + IN UINT8 *Processor OPTIONAL + ) +/*++ + +Routine Description: + Extract CPU detail version infomation + +Arguments: + FamilyId - FamilyId, including ExtendedFamilyId + Model - Model, including ExtendedModel + SteppingId - SteppingId + Processor - Processor + +--*/ +; + +UINT64 +EfiReadTsc ( + VOID + ) +/*++ + +Routine Description: + + Read Time stamp. + +Arguments: + + None + +Returns: + + Return the read data + +--*/ +; +VOID +EfiCpuidExt ( + IN UINT32 RegisterInEax, + IN UINT32 CacheLevel, + OUT EFI_CPUID_REGISTER *Regs + ) +/*++ +Routine Description: + When RegisterInEax != 4, the functionality is the same as EfiCpuid. + When RegisterInEax == 4, the function return the deterministic cache + parameters by excuting the CPUID instruction +Arguments: + RegisterInEax: - The input value to put into register EAX + CacheLevel: - The deterministic cache level + Regs: - The Output value +Returns: + None +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/ProcDep.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/ProcDep.h new file mode 100644 index 0000000000..969ac02143 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/x64/ProcDep.h @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ProcDep.h + +Abstract: + + x64 specific Runtime Lib code. At this time there is non. + IPF has different code due to extra API requirements. + +--*/ + +#ifndef _PROC_DEP_H_ +#define _PROC_DEP_H_ + + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h new file mode 100644 index 0000000000..65087c1ed1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Ascii + STRING_W is "" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR8 CHAR_W; +#define STRING_W(_s) _s + +#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +UINTN +UvSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN StrLen, + IN CONST CHAR16 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + StartOfBuffer - Wide char buffer to print the results of the parsing of Format into. + StrLen - Maximum number of characters to put into buffer. + Format - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/Sprint.c new file mode 100644 index 0000000000..7c44ad57ce --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Ascii/Sprint.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +UvSPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + AsciiFormat[Index] = (CHAR8) FormatString[Index]; + } + + AsciiFormat[Index] = '\0'; + + Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR16) AsciiResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/BoxDraw.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/BoxDraw.c new file mode 100644 index 0000000000..bad563993d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/BoxDraw.c @@ -0,0 +1,212 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BoxDraw.c + +Abstract: + Lib functions to support Box Draw Unicode code pages. + + + +Revision History + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + + + +typedef struct { + CHAR16 Unicode; + CHAR8 PcAnsi; + CHAR8 Ascii; +} UNICODE_TO_CHAR; + + +// +// This list is used to define the valid extend chars. +// It also provides a mapping from Unicode to PCANSI or +// ASCII. The ASCII mapping we just made up. +// +// + +static UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = { + BOXDRAW_HORIZONTAL, 0xc4, L'-', + BOXDRAW_VERTICAL, 0xb3, L'|', + BOXDRAW_DOWN_RIGHT, 0xda, L'/', + BOXDRAW_DOWN_LEFT, 0xbf, L'\\', + BOXDRAW_UP_RIGHT, 0xc0, L'\\', + BOXDRAW_UP_LEFT, 0xd9, L'/', + BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|', + BOXDRAW_VERTICAL_LEFT, 0xb4, L'|', + BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+', + BOXDRAW_UP_HORIZONTAL, 0xc1, L'+', + BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+', + BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-', + BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|', + BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/', + BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/', + BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/', + BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\', + BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\', + BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\', + BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\', + BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\', + BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\', + BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/', + BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/', + BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/', + BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|', + BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|', + BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|', + BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|', + BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|', + BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|', + BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+', + BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+', + BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+', + BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+', + BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+', + BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+', + BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+', + BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+', + BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+', + + BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*', + BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+', + + GEOMETRICSHAPE_UP_TRIANGLE, 0x1e, L'^', + GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x10, L'>', + GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, L'v', + GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, L'<', + + ARROW_LEFT, 0x3c, L'<', + + ARROW_UP, 0x18, L'^', + + ARROW_RIGHT, 0x3e, L'>', + + ARROW_DOWN, 0x19, L'v', + + 0x0000, 0x00 +}; + + +BOOLEAN +LibIsValidTextGraphics ( + IN CHAR16 Graphic, + OUT CHAR8 *PcAnsi, OPTIONAL + OUT CHAR8 *Ascii OPTIONAL + ) +/*++ + +Routine Description: + + Detects if a Unicode char is for Box Drawing text graphics. + +Arguments: + + Grphic - Unicode char to test. + + PcAnsi - Optional pointer to return PCANSI equivalent of Graphic. + + Asci - Optional pointer to return Ascii equivalent of Graphic. + +Returns: + + TRUE if Gpaphic is a supported Unicode Box Drawing character. + +--*/ +{ + UNICODE_TO_CHAR *Table; + + if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) { + + // + // Unicode drawing code charts are all in the 0x25xx range, + // arrows are 0x21xx + // + return FALSE; + } + + for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) { + if (Graphic == Table->Unicode) { + if (PcAnsi != NULL) { + *PcAnsi = Table->PcAnsi; + } + if (Ascii != NULL) { + *Ascii = Table->Ascii; + } + return TRUE; + } + } + return FALSE; +} + + +BOOLEAN +IsValidAscii ( + IN CHAR16 Ascii + ) +/*++ + +Routine Description: + + Is it valid ascii char? + +Arguments: + + Ascii - The char to check + +Returns: + + TRUE - Is a ascii char + FALSE - Not a ascii char + +--*/ +{ + if ((Ascii >= 0x20) && (Ascii <= 0x7f)) { + return TRUE; + } + return FALSE; +} + + +BOOLEAN +IsValidEfiCntlChar ( + IN CHAR16 CharC + ) +/*++ + +Routine Description: + + Is it valid EFI control char? + +Arguments: + + Ascii - The char to check + +Returns: + + TRUE - Is a valid EFI control char + FALSE - Not a valid EFI control char + +--*/ +{ + if (CharC == CHAR_NULL || CharC == CHAR_BACKSPACE || CharC == CHAR_LINEFEED || CharC == CHAR_CARRIAGE_RETURN) { + return TRUE; + } + return FALSE; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c new file mode 100644 index 0000000000..d2bea32769 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c @@ -0,0 +1,585 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "EfiCommonLib.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +STATIC +CHAR_W * +GetFlagsAndWidth ( + IN CHAR_W *Format, + OUT UINTN *Flags, + OUT UINTN *Width, + IN OUT VA_LIST *Marker + ); + +STATIC +UINTN +GuidToString ( + IN EFI_GUID *Guid, + IN OUT CHAR_W *Buffer, + IN UINTN BufferSize + ); + +STATIC +UINTN +TimeToString ( + IN EFI_TIME *Time, + IN OUT CHAR_W *Buffer, + IN UINTN BufferSize + ); + +STATIC +UINTN +EfiStatusToString ( + IN EFI_STATUS Status, + OUT CHAR_W *Buffer, + IN UINTN BufferSize + ); + +UINTN +SPrint ( + OUT CHAR_W *Buffer, + IN UINTN BufferSize, + IN CONST CHAR_W *Format, + ... + ) +/*++ + +Routine Description: + + SPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +VSPrint ( + OUT CHAR_W *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR_W *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + +Arguments: + + StartOfBuffer - Unicode buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means + no limit. + + FormatString - Unicode format string see file header for more details. + + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE]; + CHAR_W *Buffer; + CHAR8 *AsciiStr; + CHAR16 *UnicodeStr; + CHAR_W *Format; + UINTN Index; + UINTN Flags; + UINTN Width; + UINTN Count; + UINTN NumberOfCharacters; + UINTN BufferLeft; + UINT64 Value; + EFI_GUID *TmpGUID; + + // + // Process the format string. Stop if Buffer is over run. + // + + Buffer = StartOfBuffer; + Format = (CHAR_W *)FormatString; + NumberOfCharacters = BufferSize/sizeof(CHAR_W); + BufferLeft = BufferSize; + for (Index = 0; (*Format != '\0') && (Index < NumberOfCharacters - 1); Format++) { + if (*Format != '%') { + if ((*Format == '\n') && (Index < NumberOfCharacters - 2)) { + // + // If carage return add line feed + // + Buffer[Index++] = '\r'; + BufferLeft -= sizeof(CHAR_W); + } + Buffer[Index++] = *Format; + BufferLeft -= sizeof(CHAR_W); + } else { + + // + // Now it's time to parse what follows after % + // + Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker); + switch (*Format) { + case 'X': + Flags |= PREFIX_ZERO; + Width = sizeof (UINT64) * 2; + // + // break skiped on purpose + // + case 'x': + if ((Flags & LONG_TYPE) == LONG_TYPE) { + Value = VA_ARG (Marker, UINT64); + } else { + Value = VA_ARG (Marker, UINTN); + } + + EfiValueToHexStr (TempBuffer, Value, Flags, Width); + UnicodeStr = TempBuffer; + + for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) { + Buffer[Index++] = *UnicodeStr; + } + break; + + case 'd': + if ((Flags & LONG_TYPE) == LONG_TYPE) { + Value = VA_ARG (Marker, UINT64); + } else { + Value = (UINTN)VA_ARG (Marker, UINTN); + } + + EfiValueToString (TempBuffer, Value, Flags, Width); + UnicodeStr = TempBuffer; + + for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) { + Buffer[Index++] = *UnicodeStr; + } + break; + + case 's': + case 'S': + UnicodeStr = (CHAR16 *)VA_ARG (Marker, CHAR_W *); + if (UnicodeStr == NULL) { + UnicodeStr = L""; + } + for (Count = 0 ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++, Count++) { + Buffer[Index++] = *UnicodeStr; + } + // + // Add padding if needed + // + for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) { + Buffer[Index++] = ' '; + } + + break; + + case 'a': + AsciiStr = (CHAR8 *)VA_ARG (Marker, CHAR8 *); + if (AsciiStr == NULL) { + AsciiStr = ""; + } + for (Count = 0 ;(*AsciiStr != '\0') && (Index < NumberOfCharacters - 1); AsciiStr++, Count++) { + Buffer[Index++] = (CHAR_W)*AsciiStr; + } + // + // Add padding if needed + // + for (;(Count < Width) && (Index < NumberOfCharacters - 1); Count++) { + Buffer[Index++] = ' '; + } + break; + + case 'c': + Buffer[Index++] = (CHAR_W)VA_ARG (Marker, UINTN); + break; + + case 'g': + TmpGUID = VA_ARG (Marker, EFI_GUID *); + if (TmpGUID != NULL) { + Index += GuidToString ( + TmpGUID, + &Buffer[Index], + BufferLeft + ); + } + break; + + case 't': + Index += TimeToString ( + VA_ARG (Marker, EFI_TIME *), + &Buffer[Index], + BufferLeft + ); + break; + + case 'r': + Index += EfiStatusToString ( + VA_ARG (Marker, EFI_STATUS), + &Buffer[Index], + BufferLeft + ); + break; + + case '%': + Buffer[Index++] = *Format; + break; + + default: + // + // if the type is unknown print it to the screen + // + Buffer[Index++] = *Format; + } + BufferLeft = BufferSize - Index * sizeof(CHAR_W) ; + } + } + Buffer[Index++] = '\0'; + + return &Buffer[Index] - StartOfBuffer; +} + + + +STATIC +CHAR_W * +GetFlagsAndWidth ( + IN CHAR_W *Format, + OUT UINTN *Flags, + OUT UINTN *Width, + IN OUT VA_LIST *Marker + ) +/*++ + +Routine Description: + + VSPrint worker function that parses flag and width information from the + Format string and returns the next index into the Format string that needs + to be parsed. See file headed for details of Flag and Width. + +Arguments: + + Format - Current location in the VSPrint format string. + + Flags - Returns flags + + Width - Returns width of element + + Marker - Vararg list that may be paritally consumed and returned. + +Returns: + + Pointer indexed into the Format string for all the information parsed + by this routine. + +--*/ +{ + UINTN Count; + BOOLEAN Done; + + *Flags = 0; + *Width = 0; + for (Done = FALSE; !Done; ) { + Format++; + + switch (*Format) { + + case '-': *Flags |= LEFT_JUSTIFY; break; + case '+': *Flags |= PREFIX_SIGN; break; + case ' ': *Flags |= PREFIX_BLANK; break; + case ',': *Flags |= COMMA_TYPE; break; + case 'L': + case 'l': *Flags |= LONG_TYPE; break; + + case '*': + *Width = VA_ARG (*Marker, UINTN); + break; + + case '0': + *Flags |= PREFIX_ZERO; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + Count = 0; + do { + Count = (Count * 10) + *Format - '0'; + Format++; + } while ((*Format >= '0') && (*Format <= '9')); + Format--; + *Width = Count; + break; + + default: + Done = TRUE; + } + } + return Format; +} + +STATIC +UINTN +GuidToString ( + IN EFI_GUID *Guid, + IN CHAR_W *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + VSPrint worker function that prints an EFI_GUID. + +Arguments: + + Guid - Pointer to GUID to print. + + Buffer - Buffe to print Guid into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + + Size = SPrint ( + Buffer, + BufferSize, + STRING_W ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"), + (UINTN)Guid->Data1, + (UINTN)Guid->Data2, + (UINTN)Guid->Data3, + (UINTN)Guid->Data4[0], + (UINTN)Guid->Data4[1], + (UINTN)Guid->Data4[2], + (UINTN)Guid->Data4[3], + (UINTN)Guid->Data4[4], + (UINTN)Guid->Data4[5], + (UINTN)Guid->Data4[6], + (UINTN)Guid->Data4[7] + ); + + // + // SPrint will null terminate the string. The -1 skips the null + // + return Size - 1; +} + + +STATIC +UINTN +TimeToString ( + IN EFI_TIME *Time, + OUT CHAR_W *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + VSPrint worker function that prints EFI_TIME. + +Arguments: + + Time - Pointer to EFI_TIME sturcture to print. + + Buffer - Buffer to print Time into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + + Size = SPrint ( + Buffer, + BufferSize, + STRING_W ("%02d/%02d/%04d %02d:%02d"), + (UINTN)Time->Month, + (UINTN)Time->Day, + (UINTN)Time->Year, + (UINTN)Time->Hour, + (UINTN)Time->Minute + ); + + // + // SPrint will null terminate the string. The -1 skips the null + // + return Size - 1; +} + +STATIC +UINTN +EfiStatusToString ( + IN EFI_STATUS Status, + OUT CHAR_W *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + VSPrint worker function that prints EFI_STATUS as a string. If string is + not known a hex value will be printed. + +Arguments: + + Status - EFI_STATUS sturcture to print. + + Buffer - Buffer to print EFI_STATUS message string into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + CHAR8 *Desc; + + Desc = NULL; + + // + // Can't use global Status String Array as UINTN is not constant for EBC + // + if (Status == EFI_SUCCESS) { Desc = "Success"; } else + if (Status == EFI_LOAD_ERROR) { Desc = "Load Error"; } else + if (Status == EFI_INVALID_PARAMETER) { Desc = "Invalid Parameter"; } else + if (Status == EFI_UNSUPPORTED) { Desc = "Unsupported"; } else + if (Status == EFI_BAD_BUFFER_SIZE) { Desc = "Bad Buffer Size"; } else + if (Status == EFI_BUFFER_TOO_SMALL) { Desc = "Buffer Too Small"; } else + if (Status == EFI_NOT_READY) { Desc = "Not Ready"; } else + if (Status == EFI_DEVICE_ERROR) { Desc = "Device Error"; } else + if (Status == EFI_WRITE_PROTECTED) { Desc = "Write Protected"; } else + if (Status == EFI_OUT_OF_RESOURCES) { Desc = "Out of Resources"; } else + if (Status == EFI_VOLUME_CORRUPTED) { Desc = "Volume Corrupt"; } else + if (Status == EFI_VOLUME_FULL) { Desc = "Volume Full"; } else + if (Status == EFI_NO_MEDIA) { Desc = "No Media"; } else + if (Status == EFI_MEDIA_CHANGED) { Desc = "Media changed"; } else + if (Status == EFI_NOT_FOUND) { Desc = "Not Found"; } else + if (Status == EFI_ACCESS_DENIED) { Desc = "Access Denied"; } else + if (Status == EFI_NO_RESPONSE) { Desc = "No Response"; } else + if (Status == EFI_NO_MAPPING) { Desc = "No mapping"; } else + if (Status == EFI_TIMEOUT) { Desc = "Time out"; } else + if (Status == EFI_NOT_STARTED) { Desc = "Not started"; } else + if (Status == EFI_ALREADY_STARTED) { Desc = "Already started"; } else + if (Status == EFI_ABORTED) { Desc = "Aborted"; } else + if (Status == EFI_ICMP_ERROR) { Desc = "ICMP Error"; } else + if (Status == EFI_TFTP_ERROR) { Desc = "TFTP Error"; } else + if (Status == EFI_PROTOCOL_ERROR) { Desc = "Protocol Error"; } else + if (Status == EFI_WARN_UNKNOWN_GLYPH) { Desc = "Warning Unknown Glyph"; } else + if (Status == EFI_WARN_DELETE_FAILURE) { Desc = "Warning Delete Failure"; } else + if (Status == EFI_WARN_WRITE_FAILURE) { Desc = "Warning Write Failure"; } else + if (Status == EFI_WARN_BUFFER_TOO_SMALL) { Desc = "Warning Buffer Too Small"; } + + // + // If we found a match, copy the message to the user's buffer. Otherwise + // sprint the hex status code to their buffer. + // + if (Desc != NULL) { + Size = SPrint (Buffer, BufferSize, STRING_W ("%a"), Desc); + } else { + Size = SPrint (Buffer, BufferSize, STRING_W ("%X"), Status); + } + return Size - 1; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.h new file mode 100644 index 0000000000..7d4394e53a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.h + +Abstract: + + Private data for Print.c + +--*/ + +#ifndef _PRINT_H_ +#define _PRINT_H_ + +#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +#define PREFIX_ZERO 0x20 + +// +// Largest number of characters that can be printed out. +// +#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf new file mode 100644 index 0000000000..e5c6f373f6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/PrintLib.inf @@ -0,0 +1,49 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PrintLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = PrintLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + BoxDraw.c + Print.c + Print.h + StdErr.c + Unicode\PrintWidth.h + Unicode\SPrint.c + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Print\Unicode + $(EDK_SOURCE)\Foundation\Core\Dxe + +[libraries.common] + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/StdErr.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/StdErr.c new file mode 100644 index 0000000000..e4a649d8f6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/StdErr.c @@ -0,0 +1,284 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StdErr.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "EfiCommonLib.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +ErrorPrint ( + IN CONST CHAR16 *ErrorString, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + ErrorString - String of error infomation. + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + UINTN Index; + UINTN MaxIndex; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format); + if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) { + // + // Format string was too long for use to process. + // + return 0; + } + + if (ErrorString != '\0') { + if (gST->StdErr != NULL) { + // + // To be extra safe make sure StdErr has been initialized + // + gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK)); + gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString); + gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK)); + } + } + + for (Index = 0; Index < MaxIndex; Index++) { + UnicodeFormat[Index] = (CHAR16) Format[Index]; + } + + UnicodeFormat[Index] = 0; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker); + VA_END (Marker); + + // + // Need to convert to Unicode to do an OutputString + // + + if (gST->StdErr != NULL) { + // + // To be extra safe make sure StdErr has been initialized + // + gST->StdErr->OutputString (gST->StdErr, Buffer); + } + + return Return; +} + + +UINTN +Aprint ( + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + UINTN Index; + UINTN MaxIndex; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format); + if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) { + // + // Format string was too long for use to process. + // + return 0; + } + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) { + UnicodeFormat[Index] = (CHAR16) Format[Index]; + } + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker); + VA_END (Marker); + + // + // Need to convert to Unicode to do an OutputString + // + + if (gST->ConOut != NULL) { + // + // To be extra safe make sure ConOut has been initialized + // + gST->ConOut->OutputString (gST->ConOut, Buffer); + } + + return Return; +} + + +UINTN +Print ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker); + VA_END (Marker); + + if (gST->ConOut != NULL) { + // + // To be extra safe make sure ConOut has been initialized + // + gST->ConOut->OutputString (gST->ConOut, Buffer); + } + + return Return; +} + +UINTN +UPrint ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker); + VA_END (Marker); + + if (gST->ConOut != NULL) { + // + // To be extra safe make sure ConOut has been initialized + // + gST->ConOut->OutputString (gST->ConOut, Buffer); + } + + return Return; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h new file mode 100644 index 0000000000..e8e8d6f353 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Unicode + STRING_W is L"" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR16 CHAR_W; +#define STRING_W(_s) L##_s + +#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +#include "EfiCommonLib.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/Sprint.c new file mode 100644 index 0000000000..6b70aa6544 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/Sprint.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = AvSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +AvSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of ASPrint. + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + UnicodeFormat[Index] = (CHAR16) FormatString[Index]; + } + + UnicodeFormat[Index] = '\0'; + + Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR8) UnicodeResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h new file mode 100644 index 0000000000..65087c1ed1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Ascii + STRING_W is "" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR8 CHAR_W; +#define STRING_W(_s) _s + +#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +UINTN +UvSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN StrLen, + IN CONST CHAR16 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + StartOfBuffer - Wide char buffer to print the results of the parsing of Format into. + StrLen - Maximum number of characters to put into buffer. + Format - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c new file mode 100644 index 0000000000..fc74c7cae3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c @@ -0,0 +1,142 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + +UINTN +USPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + +UINTN +UvSPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of USPrint. + Process format and place the results in Buffer for wide chars. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + AsciiFormat[Index] = (CHAR8) FormatString[Index]; + } + + AsciiFormat[Index] = '\0'; + + Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR16) AsciiResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/BoxDraw.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/BoxDraw.c new file mode 100644 index 0000000000..0fb537829b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/BoxDraw.c @@ -0,0 +1,212 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BoxDraw.c + +Abstract: + Lib functions to support Box Draw Unicode code pages. + + + +Revision History + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + + + +typedef struct { + CHAR16 Unicode; + CHAR8 PcAnsi; + CHAR8 Ascii; +} UNICODE_TO_CHAR; + + +// +// This list is used to define the valid extend chars. +// It also provides a mapping from Unicode to PCANSI or +// ASCII. The ASCII mapping we just made up. +// +// + +static UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = { + BOXDRAW_HORIZONTAL, 0xc4, L'-', + BOXDRAW_VERTICAL, 0xb3, L'|', + BOXDRAW_DOWN_RIGHT, 0xda, L'/', + BOXDRAW_DOWN_LEFT, 0xbf, L'\\', + BOXDRAW_UP_RIGHT, 0xc0, L'\\', + BOXDRAW_UP_LEFT, 0xd9, L'/', + BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|', + BOXDRAW_VERTICAL_LEFT, 0xb4, L'|', + BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+', + BOXDRAW_UP_HORIZONTAL, 0xc1, L'+', + BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+', + BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-', + BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|', + BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/', + BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/', + BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/', + BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\', + BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\', + BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\', + BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\', + BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\', + BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\', + BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/', + BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/', + BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/', + BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|', + BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|', + BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|', + BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|', + BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|', + BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|', + BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+', + BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+', + BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+', + BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+', + BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+', + BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+', + BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+', + BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+', + BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+', + + BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*', + BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+', + + GEOMETRICSHAPE_UP_TRIANGLE, 0x1e, L'^', + GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x10, L'>', + GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, L'v', + GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, L'<', + + ARROW_LEFT, 0x3c, L'<', + + ARROW_UP, 0x18, L'^', + + ARROW_RIGHT, 0x3e, L'>', + + ARROW_DOWN, 0x19, L'v', + + 0x0000, 0x00 +}; + + +BOOLEAN +LibIsValidTextGraphics ( + IN CHAR16 Graphic, + OUT CHAR8 *PcAnsi, OPTIONAL + OUT CHAR8 *Ascii OPTIONAL + ) +/*++ + +Routine Description: + + Detects if a Unicode char is for Box Drawing text graphics. + +Arguments: + + Graphic - Unicode char to test. + + PcAnsi - Optional pointer to return PCANSI equivalent of Graphic. + + Asci - Optional pointer to return Ascii equivalent of Graphic. + +Returns: + + TRUE if Gpaphic is a supported Unicode Box Drawing character. + +--*/ +{ + UNICODE_TO_CHAR *Table; + + if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) { + + // + // Unicode drawing code charts are all in the 0x25xx range, + // arrows are 0x21xx + // + return FALSE; + } + + for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) { + if (Graphic == Table->Unicode) { + if (PcAnsi != NULL) { + *PcAnsi = Table->PcAnsi; + } + if (Ascii != NULL) { + *Ascii = Table->Ascii; + } + return TRUE; + } + } + return FALSE; +} + + +BOOLEAN +IsValidAscii ( + IN CHAR16 Ascii + ) +/*++ + +Routine Description: + + Is it valid ascii char? + +Arguments: + + Ascii - The char to check + +Returns: + + TRUE - Is a ascii char + FALSE - Not a ascii char + +--*/ +{ + if ((Ascii >= 0x20) && (Ascii <= 0x7f)) { + return TRUE; + } + return FALSE; +} + + +BOOLEAN +IsValidEfiCntlChar ( + IN CHAR16 CharC + ) +/*++ + +Routine Description: + + Is it valid EFI control char? + +Arguments: + + CharC - The char to check + +Returns: + + TRUE - Is a valid EFI control char + FALSE - Not a valid EFI control char + +--*/ +{ + if (CharC == CHAR_NULL || CharC == CHAR_BACKSPACE || CharC == CHAR_LINEFEED || CharC == CHAR_CARRIAGE_RETURN) { + return TRUE; + } + return FALSE; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c new file mode 100644 index 0000000000..c648e25642 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c @@ -0,0 +1,153 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "TianoCommon.h" +#include "EfiCommonLib.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + +UINTN +SPrint ( + OUT CHAR_W *Buffer, + IN UINTN BufferSize, + IN CONST CHAR_W *Format, + ... + ) +/*++ + +Routine Description: + + SPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Wide char buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + +UINTN +VSPrint ( + OUT CHAR_W *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR_W *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + +Arguments: + + StartOfBuffer - Unicode buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means + no limit. + + FormatString - Unicode format string see file header for more details. + + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + EFI_STATUS Status; + EFI_PRINT_PROTOCOL *PrintProtocol; + + Status = gBS->LocateProtocol ( + &gEfiPrintProtocolGuid, + NULL, + (VOID*)&PrintProtocol + ); + if (EFI_ERROR (Status)) { + return 0; + } else { + return PrintProtocol->VSPrint ( + StartOfBuffer, + BufferSize, + FormatString, + Marker + ); + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.h new file mode 100644 index 0000000000..7d4394e53a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.h + +Abstract: + + Private data for Print.c + +--*/ + +#ifndef _PRINT_H_ +#define _PRINT_H_ + +#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +#define PREFIX_ZERO 0x20 + +// +// Largest number of characters that can be printed out. +// +#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf new file mode 100644 index 0000000000..6f791230b4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/PrintLib.inf @@ -0,0 +1,50 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PrintLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = PrintLibLite +COMPONENT_TYPE = LIBRARY + +[sources.common] + BoxDraw.c + Print.c + Print.h + StdErr.c + Unicode\PrintWidth.h + Unicode\SPrint.c + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Print\Unicode + $(EDK_SOURCE)\Foundation\Core\Dxe + +[libraries.common] + EdkProtocolLib + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/StdErr.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/StdErr.c new file mode 100644 index 0000000000..e4a649d8f6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/StdErr.c @@ -0,0 +1,284 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StdErr.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "EfiCommonLib.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +ErrorPrint ( + IN CONST CHAR16 *ErrorString, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + ErrorString - String of error infomation. + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + UINTN Index; + UINTN MaxIndex; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format); + if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) { + // + // Format string was too long for use to process. + // + return 0; + } + + if (ErrorString != '\0') { + if (gST->StdErr != NULL) { + // + // To be extra safe make sure StdErr has been initialized + // + gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK)); + gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString); + gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK)); + } + } + + for (Index = 0; Index < MaxIndex; Index++) { + UnicodeFormat[Index] = (CHAR16) Format[Index]; + } + + UnicodeFormat[Index] = 0; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker); + VA_END (Marker); + + // + // Need to convert to Unicode to do an OutputString + // + + if (gST->StdErr != NULL) { + // + // To be extra safe make sure StdErr has been initialized + // + gST->StdErr->OutputString (gST->StdErr, Buffer); + } + + return Return; +} + + +UINTN +Aprint ( + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + UINTN Index; + UINTN MaxIndex; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format); + if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) { + // + // Format string was too long for use to process. + // + return 0; + } + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) { + UnicodeFormat[Index] = (CHAR16) Format[Index]; + } + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker); + VA_END (Marker); + + // + // Need to convert to Unicode to do an OutputString + // + + if (gST->ConOut != NULL) { + // + // To be extra safe make sure ConOut has been initialized + // + gST->ConOut->OutputString (gST->ConOut, Buffer); + } + + return Return; +} + + +UINTN +Print ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker); + VA_END (Marker); + + if (gST->ConOut != NULL) { + // + // To be extra safe make sure ConOut has been initialized + // + gST->ConOut->OutputString (gST->ConOut, Buffer); + } + + return Return; +} + +UINTN +UPrint ( + IN CONST CHAR16 *Format, + ... + ) +/*++ + +Routine Description: + + Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii + characters. + +Arguments: + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + VA_START (Marker, Format); + Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker); + VA_END (Marker); + + if (gST->ConOut != NULL) { + // + // To be extra safe make sure ConOut has been initialized + // + gST->ConOut->OutputString (gST->ConOut, Buffer); + } + + return Return; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h new file mode 100644 index 0000000000..e8e8d6f353 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PrintWidth.h + +Abstract: + + Unicde option for generic width. + CHAR_W is Unicode + STRING_W is L"" + +--*/ + +#ifndef _PRINT_WIDTH_H_ +#define _PRINT_WIDTH_H_ + +typedef CHAR16 CHAR_W; +#define STRING_W(_s) L##_s + +#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format) +#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker) + +#include "EfiCommonLib.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c new file mode 100644 index 0000000000..6b70aa6544 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Sprint.c + +Abstract: + + Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very + simple implemenation of SPrint() and Print() to support debug. + + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "TianoCommon.h" +#include "PrintWidth.h" +#include "EfiPrintLib.h" +#include "Print.h" + + +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + Format - Format string + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = AvSPrint (Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +AvSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Internal implementation of ASPrint. + Process format and place the results in Buffer for narrow chars. + +Arguments: + + Buffer - Narrow char buffer to print the results of the parsing of Format into. + BufferSize - Maximum number of characters to put into buffer. + FormatString - Format string + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Index; + CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; + + for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { + UnicodeFormat[Index] = (CHAR16) FormatString[Index]; + } + + UnicodeFormat[Index] = '\0'; + + Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker); + + for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) { + Buffer[Index] = (CHAR8) UnicodeResult[Index]; + } + + Buffer[Index] = '\0'; + + return Index++; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c new file mode 100644 index 0000000000..d3e30df00f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c @@ -0,0 +1,556 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDxeDriverEntryPoint.c + +Abstract: + + DXE Driver entry point template file + +--*/ + +#include "EdkIIGlueDxe.h" +#include "Common/EdkIIGlueDependencies.h" + +STATIC EFI_EVENT _mDriverExitBootServicesNotifyEvent; + +// +// Driver Model related definitions. +// LIMITATION: only support one instance of Driver Model protocols per driver. +// In case where multiple Driver Model protocols need to be installed in a single driver, +// manually edit this file and compile/link the modified file with the driver. +// + +#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__ +extern EFI_DRIVER_BINDING_PROTOCOL __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__; +#endif + +#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +extern EFI_COMPONENT_NAME2_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__; +#else +extern EFI_COMPONENT_NAME_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__; +#endif +#endif + +#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__ +extern EFI_DRIVER_CONFIGURATION_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__; +#endif + +#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__ +extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__; +#endif + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = { + { +#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__ + &__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__ + &__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__ + &__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + +#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__ + &__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__, +#else + NULL, +#endif + } +}; + +// +// NOTE: Limitation: +// Only one handler for SetVirtualAddressMap Event and ExitBootServices Event each +// +#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ +VOID +__EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ ( + IN EFI_EVENT Event, + IN VOID *Context + ); +#endif + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = { +#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ + __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__, +#endif + NULL +}; + +#ifdef __EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__ +VOID +__EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__ ( + IN EFI_EVENT Event, + IN VOID *Context + ); +#endif + +/** + Set AtRuntime flag as TRUE after ExitBootServices + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +VOID +EFIAPI +RuntimeDriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ); + +GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = { +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + // + // only Runtime drivers need to link EdkDxeRuntimeDriverLib + // + RuntimeDriverExitBootServices, +#endif +#ifdef __EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__ + __EDKII_GLUE_EXIT_BOOT_SERVICES_EVENT_HANDLER__, +#endif + NULL +}; + + +// +// Module Unload Handler +// + +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ ( + EFI_HANDLE ImageHandle + ); +#endif + +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + EFI_HANDLE ImageHandle + ) +{ +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ + return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle)); +#else + return EFI_SUCCESS; +#endif +} + +#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__ + GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__; +#endif + +// +// Library constructors +// +VOID +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +// +// Declare "Status" if any of the following libraries are used +// +#if defined(__EDKII_GLUE_DXE_HOB_LIB__) \ + || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \ + || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) \ + || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_DXE_SMBUS_LIB__) \ + || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_EDK_DXE_SAL_LIB__) \ + || defined(__EDKII_GLUE_DXE_IO_LIB_CPU_IO__) + EFI_STATUS Status; +#endif + +// +// EdkII Glue Library Constructors: +// NOTE: the constructors must be called according to dependency order +// +// UefiBootServicesTableLib UefiBootServicesTableLibConstructor() +// DxeIoLibCpuIo IoLibConstructor() +// DxeSalLib DxeSalLibConstructor(), IPF only +// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct() +// DxeHobLib HobLibConstructor() +// UefiDriverModelLib UefiDriverModelLibConstructor() +// DxeSmbusLib SmbusLibConstructor() +// DxeServicesTableLib DxeServicesTableLibConstructor() +// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor() +// + +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + Status = IoLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_SAL_LIB__ + Status = DxeSalLibConstructor(ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + Status = RuntimeDriverLibConstruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + Status = UefiDriverModelLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ + Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ + Status = HobLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ + Status = SmbusLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +} + +// +// Library Destructors +// +VOID +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +#if defined (__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) || defined (__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) + EFI_STATUS Status; +#endif + +// +// NOTE: the destructors must be called according to dependency order +// +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + Status = UefiDriverModelLibDestructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + Status = RuntimeDriverLibDeconstruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif +} + + +/** + Unload function that is registered in the LoadImage protocol. It un-installs + protocols produced and deallocates pool used by the driver. Called by the core + when unloading the driver. + + @param ImageHandle + + @retval EFI_SUCCESS + +**/ +EFI_STATUS +EFIAPI +_DriverUnloadHandler ( + EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + // + // If an UnloadImage() handler is specified, then call it + // + Status = ProcessModuleUnloadList (ImageHandle); + + // + // If the driver specific unload handler does not return an error, then call all of the + // library destructors. If the unload handler returned an error, then the driver can not be + // unloaded, and the library destructors should not be called + // + if (!EFI_ERROR (Status)) { + // + // Close our ExitBootServices () notify function + // + if (_gDriverExitBootServicesEvent[0] != NULL) { + ASSERT (gBS != NULL); + Status = gBS->CloseEvent (_mDriverExitBootServicesNotifyEvent); + ASSERT_EFI_ERROR (Status); + } + + // + // NOTE: To allow passing in gST here, any library instance having a destructor + // must depend on EfiDriverLib + // + ProcessLibraryDestructorList (ImageHandle, gST); + } + + // + // Return the status from the driver specific unload handler + // + return Status; +} + +VOID +EFIAPI +_DriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Set AtRuntime flag as TRUE after ExitBootServices + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + EFI_EVENT_NOTIFY ChildNotifyEventHandler; + UINTN Index; + + for (Index = 0; _gDriverExitBootServicesEvent[Index] != NULL; Index++) { + ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index]; + ChildNotifyEventHandler (Event, NULL); + } +} + +EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint); + +// +// Module Entry Point +// +#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_ENTRY_POINT__ ( + EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +/** + Enrty point to DXE Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + +// if (_gUefiDriverRevision != 0) { +// // +// // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver +// // +// if (SystemTable->Hdr.Revision < _gUefiDriverRevision) { +// return EFI_INCOMPATIBLE_VERSION; +// } +// } + +// DEBUG ((EFI_D_ERROR, "EdkII Glue Driver Entry - 0\n")); + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (ImageHandle, SystemTable); + + // + // Register our ExitBootServices () notify function + // + if (_gDriverExitBootServicesEvent[0] != NULL) { + Status = SystemTable->BootServices->CreateEvent ( + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + EFI_TPL_NOTIFY, + _DriverExitBootServices, + NULL, + &_mDriverExitBootServicesNotifyEvent + ); + + ASSERT_EFI_ERROR (Status); + } + + // + // Install unload handler... + // + Status = SystemTable->BootServices->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **)&LoadedImage + ); + ASSERT_EFI_ERROR (Status); + LoadedImage->Unload = _DriverUnloadHandler; + + // + // Call the driver entry point + // + #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ + Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable)); + #else + Status = EFI_SUCCESS; + #endif + + // + // If all of the drivers returned errors, then invoke all of the library destructors + // + if (EFI_ERROR (Status)) { + // + // Close our ExitBootServices () notify function + // + if (_gDriverExitBootServicesEvent[0] != NULL) { + EFI_STATUS CloseEventStatus; + CloseEventStatus = SystemTable->BootServices->CloseEvent (_mDriverExitBootServicesNotifyEvent); + ASSERT_EFI_ERROR (CloseEventStatus); + } + + ProcessLibraryDestructorList (ImageHandle, SystemTable); + } + + // + // Return the cummalative return status code from all of the driver entry points + // + return Status; +} + + +/** + Enrty point wrapper of DXE Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + + EBC build envrionment has /D $(IMAGE_ENTRY_POINT)=EfiMain which overrides what GlueLib + defines: /D IMAGE_ENTRY_POINT=_ModuleEntryPoint, so _ModuleEntryPoint will be replaced with + EfiMain thus the function below isn't needed in EBC envrionment. + +**/ +#ifndef MDE_CPU_EBC +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return _ModuleEntryPoint (ImageHandle, SystemTable); +} +#endif + +// +// Guids not present in R8.6 code base +// + +// +// Protocol/Arch Protocol GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } }; +#if (EFI_SPECIFICATION_VERSION < 0x00020000) +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } }; +#endif + +// +// PPI GUID globals +// + +// +// GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } }; diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c new file mode 100644 index 0000000000..b84c883978 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c @@ -0,0 +1,183 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePeimEntryPoint.c + +Abstract: + + PEIM entry point template file + +--*/ + +#include "EdkIIGluePeim.h" +#include "Common/EdkIIGlueDependencies.h" + + +#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__ + GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__; +#endif + +// +// Library constructors +// +VOID +ProcessLibraryConstructorList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ +// +// Declare "Status" if any of the following libraries are used +// +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) \ + || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__) \ + || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) + EFI_STATUS Status; +#endif + +// +// EdkII Glue Library Constructors: +// PeiServicesTablePointerLib PeiServicesTablePointerLibConstructor() +// PeiServicesTablePointerLibMm7 PeiServicesTablePointerLibConstructor() +// PeiServicesTablePointerLibKr1 PeiServicesTablePointerLibConstructor() +// + +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) \ + || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__) \ + || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) + Status = PeiServicesTablePointerLibConstructor (FfsHeader, PeiServices); + ASSERT_EFI_ERROR (Status); +#endif +} + +EFI_PEIM_ENTRY_POINT (_ModuleEntryPoint); + +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_ENTRY_POINT__ ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + +/** + Image entry point of Peim. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +--*/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ +// if (_gPeimRevision != 0) { +// // +// // Make sure that the PEI spec revision of the platform is >= PEI spec revision of the driver +// // +// ASSERT ((*PeiServices)->Hdr.Revision >= _gPeimRevision); +// } + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (FfsHeader, PeiServices); + + // + // Call the driver entry point + // + return __EDKII_GLUE_MODULE_ENTRY_POINT__ (FfsHeader, PeiServices); +} + + +/** + Wrapper of Peim image entry point. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ + return _ModuleEntryPoint (FfsHeader, PeiServices); +} + +// +// Guids not present in R8.6 code base +// + +// +// Protocol/Arch Protocol GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } }; + +// +// PPI GUID globals +// + +// +// GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } }; diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c new file mode 100644 index 0000000000..f8c8f9c4ec --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c @@ -0,0 +1,480 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueSmmDriverEntryPoint.c + +Abstract: + + Smm Driver entry point template file + +--*/ + +#include "EdkIIGlueDxe.h" +#include "Common/EdkIIGlueDependencies.h" + + +// +// Module Unload Handler +// +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ ( + EFI_HANDLE ImageHandle + ); +#endif + +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + EFI_HANDLE ImageHandle + ) +{ +#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__ + return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle)); +#else + return EFI_SUCCESS; +#endif +} + +#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__ + GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__; +#endif + +// +// Library constructors +// +VOID +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +// +// Declare "Status" if any of the following libraries are used +// +#if defined(__EDKII_GLUE_DXE_HOB_LIB__) \ + || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \ + || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) \ + || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_DXE_SMBUS_LIB__) \ + || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \ + || defined(__EDKII_GLUE_DXE_IO_LIB_CPU_IO__) + EFI_STATUS Status; +#endif + +// +// EdkII Glue Library Constructors: +// NOTE: the constructors must be called according to dependency order +// +// UefiBootServicesTableLib UefiBootServicesTableLibConstructor() +// DxeIoLibCpuIo IoLibConstructor +// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct() +// DxeHobLib HobLibConstructor() +// UefiDriverModelLib UefiDriverModelLibConstructor() +// DxeSmbusLib SmbusLibConstructor() +// DxeServicesTableLib DxeServicesTableLibConstructor() +// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor() +// check here: check lib usage +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + Status = IoLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + Status = RuntimeDriverLibConstruct (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + Status = UefiDriverModelLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ + Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ + Status = HobLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif + +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ + Status = SmbusLibConstructor (ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); +#endif +} + +// +// Library destructors +// +VOID +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ +} + +EFI_BOOT_SERVICES *mBS; + +/** + This function returns the size, in bytes, + of the device path data structure specified by DevicePath. + If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @return The size of a device path in bytes. + +**/ +STATIC +UINTN +EFIAPI +SmmGetDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + if (DevicePath == NULL) { + return 0; + } + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Compute the size and add back in the size of the end device path structure + // + return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); +} + +/** + This function appends the device path SecondDevicePath + to every device path instance in FirstDevicePath. + + @param FirstDevicePath A pointer to a device path data structure. + + @param SecondDevicePath A pointer to a device path data structure. + + @return A pointer to the new device path is returned. + NULL is returned if space for the new device path could not be allocated from pool. + It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath + if they are no longer needed. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +SmmAppendDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath + ) +{ + EFI_STATUS Status; + UINTN Size; + UINTN Size1; + UINTN Size2; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePath2; + + ASSERT (FirstDevicePath != NULL && SecondDevicePath != NULL); + + // + // Allocate space for the combined device path. It only has one end node of + // length EFI_DEVICE_PATH_PROTOCOL + // + Size1 = SmmGetDevicePathSize (FirstDevicePath); + Size2 = SmmGetDevicePathSize (SecondDevicePath); + Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); + + Status = (mBS->AllocatePool) (EfiBootServicesData, Size, (VOID **) &NewDevicePath); + + if (EFI_SUCCESS == Status) { + (mBS->CopyMem) ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1); + // + // Over write Src1 EndNode and do the copy + // + DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + (mBS->CopyMem) ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2); + } + + return NewDevicePath; +} + +/** + Unload function that is registered in the LoadImage protocol. It un-installs + protocols produced and deallocates pool used by the driver. Called by the core + when unloading the driver. + + @param ImageHandle ImageHandle of the unloaded driver + + @return Status of the ProcessModuleUnloadList. + +**/ +EFI_STATUS +EFIAPI +_DriverUnloadHandler ( + EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + // + // Call the unload handlers for all the modules + // + Status = ProcessModuleUnloadList (ImageHandle); + + // + // If the driver specific unload handler does not return an error, then call all of the + // library destructors. If the unload handler returned an error, then the driver can not be + // unloaded, and the library destructors should not be called + // + if (!EFI_ERROR (Status)) { + // + // NOTE: To allow passing in gST here, any library instance having a destructor + // must depend on EfiDriverLib + // + } + + // + // Return the status from the driver specific unload handler + // + return Status; +} + +EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint); + +// +// Module Entry Point +// +#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ +EFI_STATUS +EFIAPI +__EDKII_GLUE_MODULE_ENTRY_POINT__ ( + EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +/** + Enrty point to DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + EFI_SMM_BASE_PROTOCOL *SmmBase; + BOOLEAN InSmm; + EFI_DEVICE_PATH_PROTOCOL *CompleteFilePath; + EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath; + EFI_HANDLE Handle; + + // + // Cache a pointer to the Boot Services Table + // + mBS = SystemTable->BootServices; + + // + // Retrieve the Loaded Image Protocol + // + Status = mBS->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID*)&LoadedImage + ); + ASSERT_EFI_ERROR (Status); + + // + // Retrieve SMM Base Protocol + // + Status = mBS->LocateProtocol ( + &gEfiSmmBaseProtocolGuid, + NULL, + (VOID **) &SmmBase + ); + ASSERT_EFI_ERROR (Status); + + // + // Check to see if we are already in SMM + // + SmmBase->InSmm (SmmBase, &InSmm); + + // + // + // + if (!InSmm) { + // + // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from + // + Status = mBS->HandleProtocol ( + LoadedImage->DeviceHandle, + &gEfiDevicePathProtocolGuid, + (VOID*)&ImageDevicePath + ); + ASSERT_EFI_ERROR (Status); + + // + // Build the full device path to the currently execuing image + // + CompleteFilePath = SmmAppendDevicePath (ImageDevicePath, LoadedImage->FilePath); + + // + // Load the image in memory to SMRAM; it will automatically generate the + // SMI. + // + Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE); + ASSERT_EFI_ERROR (Status); + return Status; + } + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (ImageHandle, SystemTable); + + // + // Install the unload handler + // + Status = mBS->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **)&LoadedImage + ); + ASSERT_EFI_ERROR (Status); + LoadedImage->Unload = _DriverUnloadHandler; + + // + // Call the list of driver entry points + // + #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__ + Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable)); + #else + Status = EFI_SUCCESS; + #endif + + if (EFI_ERROR (Status)) { + ProcessLibraryDestructorList (ImageHandle, SystemTable); + } + + return Status; +} + +/** + Enrty point wrapper of DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return _ModuleEntryPoint (ImageHandle, SystemTable); +} + +// +// Guids not present in R8.6 code base +// + +// +// Protocol/Arch Protocol GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } }; + +// +// PPI GUID globals +// + +// +// GUID globals +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } }; diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h new file mode 100644 index 0000000000..f0b5e16d6d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + AutoGen.h + +Abstract: + + This file is supposed to be used by a .dxe file. To write common .dxs file for R8.x + and R9, a header file named AutoGen.h musted be present. In R8.x-GlueLib code base, + this AutoGen.h plays the role as the AutoGen.h in R9. Here the AutoGen.h isn't auto-generated + by any tool. + +--*/ + +#ifndef __EDKII_GLUELIB_AUTOGEN_H__ +#define __EDKII_GLUELIB_AUTOGEN_H__ + + +// +// Explanation: +// BUILD_WITH_GLUELIB was used at the very beginning of EdkIIGlueLib development and +// BUILD_WITH_EDKII_GLUE_LIB was introduced later with newer EDK. The old one, BUILD_WITH_GLUELIB, +// is remained here only to keep source level compatibility with modules which already use it. +// +// Both macros are of same effect: to indicate a module it's using EdkIIGlueLib. For newly created +// modules, BUILD_WITH_EDKII_GLUE_LIB is recommended to use. +// +// The macros can be used in .dxs files and source files. +// + +#ifndef BUILD_WITH_EDKII_GLUE_LIB + #define BUILD_WITH_EDKII_GLUE_LIB +#endif + +#ifndef BUILD_WITH_GLUELIB + #define BUILD_WITH_GLUELIB +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h new file mode 100644 index 0000000000..957c9d69d9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h @@ -0,0 +1,90 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueBaseTypes.h + +Abstract: + + Defines additional data types for use by Base modules + +--*/ + +#ifndef __EDKII_GLUE_BASE_TYPES_H__ +#define __EDKII_GLUE_BASE_TYPES_H__ + +#include "..\EdkIIGlueConfig.h" + +#define BREAKPOINT EFI_BREAKPOINT +#define DEADLOOP EFI_DEADLOOP + +#define MAX_BIT EFI_MAX_BIT +#define MAX_ADDRESS EFI_MAX_ADDRESS + +#ifndef UINT8_MAX + #define UINT8_MAX 0xff +#endif + +// +// EFI Error Codes common to all execution phases +// + +typedef INTN RETURN_STATUS; + +/// +/// Set the upper bit to indicate EFI Error. +/// +#define ENCODE_ERROR(a) (MAX_BIT | (a)) + +#define ENCODE_WARNING(a) (a) +#define RETURN_ERROR(a) ((a) < 0) + +#define RETURN_SUCCESS 0 +#define RETURN_LOAD_ERROR ENCODE_ERROR (1) +#define RETURN_INVALID_PARAMETER ENCODE_ERROR (2) +#define RETURN_UNSUPPORTED ENCODE_ERROR (3) +#define RETURN_BAD_BUFFER_SIZE ENCODE_ERROR (4) +#define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5) +#define RETURN_NOT_READY ENCODE_ERROR (6) +#define RETURN_DEVICE_ERROR ENCODE_ERROR (7) +#define RETURN_WRITE_PROTECTED ENCODE_ERROR (8) +#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9) +#define RETURN_VOLUME_CORRUPTED ENCODE_ERROR (10) +#define RETURN_VOLUME_FULL ENCODE_ERROR (11) +#define RETURN_NO_MEDIA ENCODE_ERROR (12) +#define RETURN_MEDIA_CHANGED ENCODE_ERROR (13) +#define RETURN_NOT_FOUND ENCODE_ERROR (14) +#define RETURN_ACCESS_DENIED ENCODE_ERROR (15) +#define RETURN_NO_RESPONSE ENCODE_ERROR (16) +#define RETURN_NO_MAPPING ENCODE_ERROR (17) +#define RETURN_TIMEOUT ENCODE_ERROR (18) +#define RETURN_NOT_STARTED ENCODE_ERROR (19) +#define RETURN_ALREADY_STARTED ENCODE_ERROR (20) +#define RETURN_ABORTED ENCODE_ERROR (21) +#define RETURN_ICMP_ERROR ENCODE_ERROR (22) +#define RETURN_TFTP_ERROR ENCODE_ERROR (23) +#define RETURN_PROTOCOL_ERROR ENCODE_ERROR (24) +#define RETURN_INCOMPATIBLE_VERSION ENCODE_ERROR (25) +#define RETURN_SECURITY_VIOLATION ENCODE_ERROR (26) +#define RETURN_CRC_ERROR ENCODE_ERROR (27) +#define RETURN_END_OF_MEDIA ENCODE_ERROR (28) +#define RETURN_END_OF_FILE ENCODE_ERROR (31) + +#define RETURN_WARN_UNKNOWN_GLYPH ENCODE_WARNING (1) +#define RETURN_WARN_DELETE_FAILURE ENCODE_WARNING (2) +#define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3) +#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4) + +typedef UINT64 PHYSICAL_ADDRESS; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h new file mode 100644 index 0000000000..3c3076954d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h @@ -0,0 +1,113 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDefinitionChangesBase.h + +Abstract: + + Data structure definition changes from EDK to EDKII + +--*/ + +#ifndef __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__ +#define __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__ + +#include "EfiInternalFormRepresentation.h" +#include "EfiPxe.h" + + +// ---------------------------------------------------------------------------------- +// Data Hub Record GUID Name changes +// ---------------------------------------------------------------------------------- +#define gEfiProcessorSubClassGuid gProcessorSubClassName +#define gEfiCacheSubClassGuid gCacheSubClassName +#define gEfiMiscSubClassGuid gMiscSubClassName +#define gEfiProcessorProducerGuid gProcessorProducerGuid +#define gEfiMemoryProducerGuid gMemoryProducerGuid +#define gEfiMiscProducerGuid gMiscProducerGuid + + +// ---------------------------------------------------------------------------------- +// Hob.h: Get the data and data size field of GUID +// ---------------------------------------------------------------------------------- +#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID))) +#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE)) + +// ---------------------------------------------------------------------------------- +// InternalFormRepresentation.h: +// ---------------------------------------------------------------------------------- + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name + UINT8 Width; // The Size of the Data being saved + STRING_REF Prompt; // The String Token for the Prompt + STRING_REF Help; // The string Token for the context-help + UINT8 Flags; // For now, if non-zero, means that it is the default option, - further definition likely + UINT16 Key; // Value to be passed to caller to identify this particular op-code +} EFI_IFR_CHECKBOX; + +typedef struct { + EFI_IFR_OP_HEADER Header; + UINT8 Flags; +} EFI_IFR_GRAY_OUT; + +typedef struct { + EFI_IFR_OP_HEADER Header; +} EFI_IFR_END_EXPR; + +// ------------------------ +// define GUID as EFI_GUID +// ------------------------ +typedef EFI_GUID GUID; + + +// ------------------- +// EdkII Names - Edk Names +// ------------------- +#define EFI_GLOBAL_VARIABLE EFI_GLOBAL_VARIABLE_GUID +#define MPS_TABLE_GUID EFI_MPS_TABLE_GUID +#define SAL_SYSTEM_TABLE_GUID EFI_SAL_SYSTEM_TABLE_GUID +#define SMBIOS_TABLE_GUID EFI_SMBIOS_TABLE_GUID +#define EFI_OPTIONAL_PTR EFI_OPTIONAL_POINTER +#define PXE_FRAME_TYPE_FILTERED_MULTICAST PXE_FRAME_TYPE_MULTICAST +#define IMAGE_FILE_MACHINE_I386 EFI_IMAGE_MACHINE_IA32 +#define IMAGE_FILE_MACHINE_IA64 EFI_IMAGE_MACHINE_IA64 +#define IMAGE_FILE_MACHINE_EBC EFI_IMAGE_MACHINE_EBC +#define IMAGE_FILE_MACHINE_X64 EFI_IMAGE_MACHINE_X64 +#define EVENT_TIMER EFI_EVENT_TIMER +#define EVENT_RUNTIME EFI_EVENT_RUNTIME +#define EVENT_RUNTIME_CONTEXT EFI_EVENT_RUNTIME_CONTEXT +#define EVENT_NOTIFY_WAIT EFI_EVENT_NOTIFY_WAIT +#define EVENT_NOTIFY_SIGNAL EFI_EVENT_NOTIFY_SIGNAL +#define EVENT_SIGNAL_EXIT_BOOT_SERVICES EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES +#define EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE +#define TPL_APPLICATION EFI_TPL_APPLICATION +#define TPL_CALLBACK EFI_TPL_CALLBACK +#define TPL_NOTIFY EFI_TPL_NOTIFY +#define TPL_HIGH_LEVEL EFI_TPL_HIGH_LEVEL + +// +// Typos in R8.x +// +#define gEfiHobMemoryAllocModuleGuid gEfiHobMemeryAllocModuleGuid +#define gEfiHobMemoryAllocStackGuid gEfiHobMemeryAllocStackGuid +#define gEfiHobMemoryAllocBspStoreGuid gEfiHobMemeryAllocBspStoreGuid + +// +// typedef Edk types - EdkII types +// +typedef PXE_CPB_START PXE_CPB_START_30; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h new file mode 100644 index 0000000000..0f2cadd3fc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h @@ -0,0 +1,87 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDefinitionChangesDxe.h + +Abstract: + + Data structure definition changes from EDK to EDKII + +--*/ + +#ifndef __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__ +#define __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__ + +#include "EfiInternalFormRepresentation.h" + +#include "EdkIIGlueDefinitionChangesBase.h" + +#if (TIANO_RELEASE_VERSION <= 0x00080005) + #define gEfiStatusCodeRuntimeProtocolGuid gEfiStatusCodeArchProtocolGuid +#endif + +// +// typedef Edk types - EdkII types +// +typedef EFI_MEMORY_ARRAY_START_ADDRESS EFI_MEMORY_ARRAY_START_ADDRESS_DATA; +typedef EFI_MEMORY_DEVICE_START_ADDRESS EFI_MEMORY_DEVICE_START_ADDRESS_DATA; +typedef EFI_MISC_LAST_PCI_BUS EFI_MISC_LAST_PCI_BUS_DATA; +typedef EFI_MISC_BIOS_VENDOR EFI_MISC_BIOS_VENDOR_DATA; +typedef EFI_MISC_SYSTEM_MANUFACTURER EFI_MISC_SYSTEM_MANUFACTURER_DATA; +typedef EFI_MISC_BASE_BOARD_MANUFACTURER EFI_MISC_BASE_BOARD_MANUFACTURER_DATA; +typedef EFI_MISC_CHASSIS_MANUFACTURER EFI_MISC_CHASSIS_MANUFACTURER_DATA; +typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA; +typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA; +typedef EFI_MISC_ONBOARD_DEVICE EFI_MISC_ONBOARD_DEVICE_DATA; +typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA EFI_MISC_PORTING_DEVICE_TYPE_DATA; +typedef EFI_MISC_OEM_STRING EFI_MISC_OEM_STRING_DATA; +typedef EFI_MISC_SYSTEM_OPTION_STRING EFI_MISC_SYSTEM_OPTION_STRING_DATA; +typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA; +typedef EFI_MISC_SYSTEM_LANGUAGE_STRING EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA; +typedef EFI_MISC_BIS_ENTRY_POINT EFI_MISC_BIS_ENTRY_POINT_DATA; +typedef EFI_MISC_BOOT_INFORMATION_STATUS EFI_MISC_BOOT_INFORMATION_STATUS_DATA; +typedef EFI_MISC_SYSTEM_POWER_SUPPLY EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ; +typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA; + +// ------------------- +// EdkII Names - Edk Names +// ------------------- +#define gEfiAcpiSupportProtocolGuid gEfiAcpiSupportGuid +#define gEfiLoadPeImageProtocolGuid gEfiLoadPeImageGuid +#define EFI_GLYPH_NON_SPACING GLYPH_NON_SPACING +#define EFI_GLYPH_WIDE GLYPH_NON_BREAKING +#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUID BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE +#define EFI_EBC_PROTOCOL_GUID EFI_EBC_INTERPRETER_PROTOCOL_GUID +#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID +#define EFI_LOADED_IMAGE_PROTOCOL_REVISION EFI_LOADED_IMAGE_INFORMATION_REVISION +#define EFI_LOAD_FILE_PROTOCOL_GUID LOAD_FILE_PROTOCOL_GUID +#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION EFI_PXE_BASE_CODE_INTERFACE_REVISION +#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION +#define EFI_SERIAL_IO_PROTOCOL_REVISION SERIAL_IO_INTERFACE_REVISION +#define EFI_FILE_PROTOCOL_REVISION EFI_FILE_HANDLE_REVISION +#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID + + +// +// typedef Edk types - EdkII types +// +typedef EFI_VOLUME_OPEN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME; +typedef EFI_TEXT_OUTPUT_STRING EFI_TEXT_STRING; +typedef SCREEN_DESCRIPTOR EFI_SCREEN_DESCRIPTOR; +typedef EFI_SIMPLE_TEXT_IN_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL; +typedef EFI_SIMPLE_TEXT_OUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL; +//typedef EFI_TO_LEGACY16_INIT_TABLE EFI_TO_COMPATIBILITY16_INIT_TABLE; +//typedef DISPATCH_OPROM_TABLE EFI_DISPATCH_OPROM_TABLE; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h new file mode 100644 index 0000000000..353fe36709 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h @@ -0,0 +1,158 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDefinitionChangesPeim.h + +Abstract: + + Data structure definition changes from EDK to EDKII + +--*/ + +#ifndef __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__ +#define __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__ + +#include "EfiInternalFormRepresentation.h" + +#include "EdkIIGlueDefinitionChangesBase.h" +#include "EfiPciCfg.h" + +// +// typedef Edk types - EdkII types +// +typedef EFI_MEMORY_ARRAY_START_ADDRESS EFI_MEMORY_ARRAY_START_ADDRESS_DATA; +typedef EFI_MEMORY_DEVICE_START_ADDRESS EFI_MEMORY_DEVICE_START_ADDRESS_DATA; +typedef EFI_MISC_LAST_PCI_BUS EFI_MISC_LAST_PCI_BUS_DATA; +typedef EFI_MISC_BIOS_VENDOR EFI_MISC_BIOS_VENDOR_DATA; +typedef EFI_MISC_SYSTEM_MANUFACTURER EFI_MISC_SYSTEM_MANUFACTURER_DATA; +typedef EFI_MISC_BASE_BOARD_MANUFACTURER EFI_MISC_BASE_BOARD_MANUFACTURER_DATA; +typedef EFI_MISC_CHASSIS_MANUFACTURER EFI_MISC_CHASSIS_MANUFACTURER_DATA; +typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA; +typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA; +typedef EFI_MISC_ONBOARD_DEVICE EFI_MISC_ONBOARD_DEVICE_DATA; +typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA EFI_MISC_PORTING_DEVICE_TYPE_DATA; +typedef EFI_MISC_OEM_STRING EFI_MISC_OEM_STRING_DATA; +typedef EFI_MISC_SYSTEM_OPTION_STRING EFI_MISC_SYSTEM_OPTION_STRING_DATA; +typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA; +typedef EFI_MISC_SYSTEM_LANGUAGE_STRING EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA; +typedef EFI_MISC_BIS_ENTRY_POINT EFI_MISC_BIS_ENTRY_POINT_DATA; +typedef EFI_MISC_BOOT_INFORMATION_STATUS EFI_MISC_BOOT_INFORMATION_STATUS_DATA; +typedef EFI_MISC_SYSTEM_POWER_SUPPLY EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ; +typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA; + +// ------------------- +// EdkII Names - Edk Names +// ------------------- +#define gEfiPeiCpuIoPpiInServiceTableGuid gPeiCpuIoPpiInServiceTableGuid +#define gEfiEndOfPeiSignalPpiGuid gEndOfPeiSignalPpiGuid +#define gEfiPeiFvFileLoaderPpiGuid gPeiFvFileLoaderPpiGuid +#define gEfiPeiMasterBootModePpiGuid gPeiMasterBootModePpiGuid +#define gEfiPeiMemoryDiscoveredPpiGuid gPeiMemoryDiscoveredPpiGuid +#define gEfiPciCfgPpiInServiceTableGuid gPeiPciCfgPpiInServiceTableGuid +#define gEfiPeiReadOnlyVariablePpiGuid gPeiReadOnlyVariablePpiGuid +#define gEfiPeiRecoveryModulePpiGuid gPeiRecoveryModulePpiGuid +#define gEfiPeiResetPpiGuid gPeiResetPpiGuid +#define gEfiPeiS3ResumePpiGuid gPeiS3ResumePpiGuid +#define gEfiPeiSectionExtractionPpiGuid gPeiSectionExtractionPpiGuid +#define gEfiPeiSecurityPpiGuid gPeiSecurityPpiGuid +#define gEfiPeiStatusCodePpiGuid gPeiStatusCodePpiGuid +#define gEfiPeiBootScriptExecuterPpiGuid gPeiBootScriptExecuterPpiGuid +#define gEfiPeiSmbusPpiGuid gPeiSmbusPpiGuid +#define gEfiPeiBlockIoPpiGuid gPeiBlockIoPpiGuid +#define gEfiPeiDeviceRecoveryModulePpiGuid gPeiDeviceRecoveryModulePpiGuid +#define gEfiPeiStallPpiGuid gPeiStallPpiGuid +#define gEfiPeiPciCfgPpiInServiceTableGuid gPeiPciCfgPpiInServiceTableGuid +#define gEfiPeiAtaControllerPpiGuid gPeiAtaControllerPpiGuid +#define EFI_PEI_CPU_IO_PPI_INSTALLED_GUID PEI_CPU_IO_PPI_GUID +#define EFI_PEI_RESET_PPI_GUID PEI_RESET_PPI_GUID +#define EFI_PEI_PCI_CFG_PPI_INSTALLED_GUID PEI_PCI_CFG_PPI_GUID +#define EFI_PEI_REPORT_PROGRESS_CODE_PPI_GUID PEI_STATUS_CODE_PPI_GUID +#define EFI_PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI +#define EFI_PEI_END_OF_PEI_PHASE_PPI_GUID PEI_END_OF_PEI_PHASE_PPI_GUID +#define EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI PEI_MASTER_BOOT_MODE_PEIM_PPI +#define EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID +#define EFI_PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID +#define EFI_PEI_RECOVERY_MODULE_PPI_GUID PEI_RECOVERY_MODULE_INTERFACE_PPI +#define EFI_PEI_S3_RESUME_PPI_GUID PEI_S3_RESUME_PPI_GUID +#define EFI_PEI_SECURITY_PPI_GUID PEI_SECURITY_PPI_GUID +#define EFI_PEI_STALL_PPI_GUID PEI_STALL_PPI_GUID +#define EFI_PEI_SMBUS_PPI_GUID PEI_SMBUS_PPI_GUID +#define EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID +#define EFI_PEI_FIND_FV_PPI_GUID EFI_FIND_FV_PPI_GUID +#define EFI_PEI_VIRTUAL_BLOCK_IO_PPI PEI_BLOCK_IO_PPI_GUID +#define EFI_PEI_DEVICE_RECOVERY_MODULE_PPI_GUID PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI + + +// +// typedef Edk types - EdkII types +// +typedef PEI_RECOVERY_MODULE_INTERFACE EFI_PEI_RECOVERY_MODULE_PPI; +typedef PEI_CPU_IO_PPI EFI_PEI_CPU_IO_PPI; +typedef PEI_STALL_PPI EFI_PEI_STALL_PPI; +typedef PEI_SMBUS_PPI EFI_PEI_SMBUS_PPI; +typedef PEI_READ_ONLY_VARIABLE_PPI EFI_PEI_READ_ONLY_VARIABLE_PPI; +typedef PEI_PCI_CFG_PPI EFI_PEI_PCI_CFG_PPI; +typedef PEI_STATUS_CODE_PPI EFI_PEI_PROGRESS_CODE_PPI; +typedef PEI_CPU_IO_PPI_WIDTH EFI_PEI_CPU_IO_PPI_WIDTH; +typedef PEI_CPU_IO_PPI_IO_MEM EFI_PEI_CPU_IO_PPI_IO_MEM; +typedef PEI_CPU_IO_PPI_ACCESS EFI_PEI_CPU_IO_PPI_ACCESS; +typedef PEI_CPU_IO_PPI_IO_READ8 EFI_PEI_CPU_IO_PPI_IO_READ8; +typedef PEI_CPU_IO_PPI_IO_READ16 EFI_PEI_CPU_IO_PPI_IO_READ16; +typedef PEI_CPU_IO_PPI_IO_READ32 EFI_PEI_CPU_IO_PPI_IO_READ32; +typedef PEI_CPU_IO_PPI_IO_READ64 EFI_PEI_CPU_IO_PPI_IO_READ64; +typedef PEI_CPU_IO_PPI_IO_WRITE8 EFI_PEI_CPU_IO_PPI_IO_WRITE8; +typedef PEI_CPU_IO_PPI_IO_WRITE16 EFI_PEI_CPU_IO_PPI_IO_WRITE16; +typedef PEI_CPU_IO_PPI_IO_WRITE32 EFI_PEI_CPU_IO_PPI_IO_WRITE32; +typedef PEI_CPU_IO_PPI_IO_WRITE64 EFI_PEI_CPU_IO_PPI_IO_WRITE64; +typedef PEI_CPU_IO_PPI_MEM_READ8 EFI_PEI_CPU_IO_PPI_MEM_READ8; +typedef PEI_CPU_IO_PPI_MEM_READ16 EFI_PEI_CPU_IO_PPI_MEM_READ16; +typedef PEI_CPU_IO_PPI_MEM_READ32 EFI_PEI_CPU_IO_PPI_MEM_READ32; +typedef PEI_CPU_IO_PPI_MEM_READ64 EFI_PEI_CPU_IO_PPI_MEM_READ64; +typedef PEI_CPU_IO_PPI_MEM_WRITE8 EFI_PEI_CPU_IO_PPI_MEM_WRITE8; +typedef PEI_CPU_IO_PPI_MEM_WRITE16 EFI_PEI_CPU_IO_PPI_MEM_WRITE16; +typedef PEI_CPU_IO_PPI_MEM_WRITE32 EFI_PEI_CPU_IO_PPI_MEM_WRITE32; +typedef PEI_CPU_IO_PPI_MEM_WRITE64 EFI_PEI_CPU_IO_PPI_MEM_WRITE64; +typedef PEI_GET_VARIABLE EFI_PEI_GET_VARIABLE; +typedef PEI_GET_NEXT_VARIABLE_NAME EFI_PEI_GET_NEXT_VARIABLE_NAME; +typedef PEI_LOAD_RECOVERY_CAPSULE EFI_PEI_LOAD_RECOVERY_CAPSULE; +typedef PEI_RESET_PPI EFI_PEI_RESET_PPI; +typedef PEI_S3_RESUME_PPI EFI_PEI_S3_RESUME_PPI; +typedef PEI_S3_RESUME_PPI_RESTORE_CONFIG EFI_PEI_S3_RESUME_PPI_RESTORE_CONFIG; +typedef SEC_PLATFORM_INFORMATION EFI_SEC_PLATFORM_INFORMATION; +typedef PEI_SECURITY_PPI EFI_PEI_SECURITY_PPI; +typedef PEI_SECURITY_AUTHENTICATION_STATE EFI_PEI_SECURITY_AUTHENTICATION_STATE; +typedef PEI_STALL EFI_PEI_STALL; +typedef PEI_SMBUS_PPI_EXECUTE_OPERATION EFI_PEI_SMBUS_PPI_EXECUTE_OPERATION; +typedef PEI_SMBUS_NOTIFY_FUNCTION EFI_PEI_SMBUS_NOTIFY_FUNCTION; +typedef PEI_SMBUS_PPI_ARP_DEVICE EFI_PEI_SMBUS_PPI_ARP_DEVICE; +typedef PEI_SMBUS_PPI_GET_ARP_MAP EFI_PEI_SMBUS_PPI_GET_ARP_MAP; +typedef PEI_SMBUS_PPI_NOTIFY EFI_PEI_SMBUS_PPI_NOTIFY; +typedef PEI_BOOT_SCRIPT_EXECUTE EFI_PEI_BOOT_SCRIPT_EXECUTE; +typedef PEI_BOOT_SCRIPT_EXECUTER_PPI EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI; +typedef EFI_FIND_FV_FINDFV EFI_PEI_FIND_FV_FINDFV; +typedef EFI_FIND_FV_PPI EFI_PEI_FIND_FV_PPI; +typedef PEI_RECOVERY_BLOCK_IO_INTERFACE EFI_PEI_RECOVERY_BLOCK_IO_PPI; +typedef PEI_LBA EFI_PEI_LBA; +typedef PEI_BLOCK_IO_MEDIA EFI_PEI_BLOCK_IO_MEDIA; +typedef PEI_BLOCK_DEVICE_TYPE EFI_PEI_BLOCK_DEVICE_TYPE; +typedef PEI_GET_NUMBER_BLOCK_DEVICES EFI_PEI_GET_NUMBER_BLOCK_DEVICES; +typedef PEI_GET_DEVICE_MEDIA_INFORMATION EFI_PEI_GET_DEVICE_MEDIA_INFORMATION; +typedef PEI_READ_BLOCKS EFI_PEI_READ_BLOCKS; +typedef PEI_DEVICE_RECOVERY_MODULE_INTERFACE EFI_PEI_DEVICE_RECOVERY_MODULE_PPI; +typedef PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE EFI_PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE; +typedef PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO EFI_PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO; +typedef PEI_DEVICE_LOAD_RECOVERY_CAPSULE EFI_PEI_DEVICE_LOAD_RECOVERY_CAPSULE; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h new file mode 100644 index 0000000000..1f59b3552b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h @@ -0,0 +1,777 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDepedencies.h + +Abstract: + + Header file that lists dependency relations among library instances + +--*/ + +#ifndef __EDKII_GLUE_DEPENDENCIES_H__ +#define __EDKII_GLUE_DEPENDENCIES_H__ + +#include "EdkIIGlueProcessorBind.h" + +// +// Declarations of dependencies among EdkII Glue Library instances and R8 Libraries +// Pay attention to the order of following #define structures +// + + +// +// PeiDxeDebugLibReportStatusCode +// Actually almost every module and GlueLib instance needs this library, but GlueLib +// instances don't have to list this library in their own inf files. Module inf +// does this. +// +#ifdef __EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#endif + +// +// BaseDebugLibNull +// +#ifdef __EDKII_GLUE_BASE_DEBUG_LIB_NULL__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_PRINT_LIB__ + #define __EDKII_GLUE_BASE_PRINT_LIB__ + #endif +#endif + +// +// EdkDxeRuntimeDriverLib +// +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ + #ifndef __EDKII_GLUE_UEFI_LIB__ + #define __EDKII_GLUE_UEFI_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#ifdef MDE_CPU_IPF // IPF + #ifndef __EDKII_GLUE_EDK_DXE_SAL_LIB__ + #define __EDKII_GLUE_EDK_DXE_SAL_LIB__ + #endif +#endif // IPF +#endif + +// +// EdkDxeSalLib +// +#ifdef __EDKII_GLUE_EDK_DXE_SAL_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// BasePciLibCf8 +// +#ifdef __EDKII_GLUE_BASE_PCI_LIB_CF8__ + #ifndef __EDKII_GLUE_BASE_PCI_CF8_LIB__ + #define __EDKII_GLUE_BASE_PCI_CF8_LIB__ + #endif +#endif + +// +// BasePciLibPciExpress +// +#ifdef __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ + #ifndef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__ + #define __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__ + #endif +#endif + +// +// BasePciCf8Lib +// +#ifdef __EDKII_GLUE_BASE_PCI_CF8_LIB__ +#ifndef MDE_CPU_EBC + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#else + #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #endif +#endif +#endif + +// +// BasePciExpressLib +// +#ifdef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__ +#ifndef MDE_CPU_EBC + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#else + #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #endif +#endif +#endif + +// +// BaseTimerLibLocalApic +// +#ifdef __EDKII_GLUE_BASE_TIMER_LIB_LOCAL_APIC__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#ifndef MDE_CPU_EBC + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#else + #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #endif +#endif +#endif + +// +// DxeReportStatusCodeLib +// +#ifdef __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#ifndef MDE_CPU_EBC + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#else + #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #endif +#endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// PeiReportStatusCodeLib +// +#ifdef __EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#ifndef MDE_CPU_EBC + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#else + #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #endif +#endif +#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif +#elif defined(MDE_CPU_IPF) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #endif +#endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or + // __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// BasePeCoffLib +// +#ifdef __EDKII_GLUE_BASE_PE_COFF_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#endif + +// +// BaseUefiDecompressLib +// +#ifdef __EDKII_GLUE_BASE_UEFI_DECOMPRESS_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#endif + +// +// DxeHobLib +// +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_LIB__ + #define __EDKII_GLUE_UEFI_LIB__ + #endif +#endif + +// +// HiiLib +// +#ifdef __EDKII_GLUE_HII_LIB__ + #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #endif +#endif + +// +// UefiDevicePathLib +// +#ifdef __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif + #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #endif +#endif + +// +// UefiLib +// +#ifdef __EDKII_GLUE_UEFI_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif + #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #endif +#endif + +// +// DxeMemoryAllocationLib +// +#ifdef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// DxeSmbusLib +// +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// PeiHobLib +// +#ifdef __EDKII_GLUE_PEI_HOB_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif + #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__ + #define __EDKII_GLUE_PEI_SERVICES_LIB__ + #endif +#endif + +// +// PeiMemoryAllocationLib +// +#ifdef __EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif +#elif defined(MDE_CPU_IPF) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #endif +#endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or + // __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// PeiResourcePublicationLib +// +#ifdef __EDKII_GLUE_PEI_RESOURCE_PUBLICATION_LIB__ + #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__ + #define __EDKII_GLUE_PEI_SERVICES_LIB__ + #endif +#endif + +// +// PeiServicesLib +// +#ifdef __EDKII_GLUE_PEI_SERVICES_LIB__ +#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif +#elif defined(MDE_CPU_IPF) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #endif +#endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or + // __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// PeiSmbusLib +// +#ifdef __EDKII_GLUE_PEI_SMBUS_LIB__ + #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__ + #define __EDKII_GLUE_BASE_MEMORY_LIB__ + #endif +#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #endif +#elif defined(MDE_CPU_IPF) + #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #endif +#endif + // + // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ or + // __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ can be + // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ + // +#endif + +// +// PeiServicesTablePointerLibMm7 +// +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// PeiServicesTablePointerLibKr1 +// +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + + +// +// UefiDriverModelLib +// +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// DxeServicesTableLib +// +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ + #ifndef __EDKII_GLUE_UEFI_LIB__ + #define __EDKII_GLUE_UEFI_LIB__ + #endif +#endif + +// +// BasePrintLib +// +#ifdef __EDKII_GLUE_BASE_PRINT_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// BaseMemoryLib +// +#ifdef __EDKII_GLUE_BASE_MEMORY_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// BasePostCodeLibPort80 +// +#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__ +#ifndef MDE_CPU_EBC + #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #endif +#else + #ifndef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #define __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #endif +#endif +#endif + +// +// BaseIoLibIntrinsic +// +#ifdef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// DxeIoLibCpuIo +// +#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif + #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ + #endif +#endif + +// +// UefiBootServicesTableLib +// +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ +#endif + +// +// BaseCacheMaintenanceLib +// +#ifdef __EDKII_GLUE_BASE_CACHE_MAINTENANCE_LIB__ + #ifndef __EDKII_GLUE_BASE_LIB__ + #define __EDKII_GLUE_BASE_LIB__ + #endif +#endif + +// +// BaseLib +// +#ifdef __EDKII_GLUE_BASE_LIB__ +#endif + +// +// UefiRuntimeServicesTableLib +// +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ +#endif + +// +// BasePeCoffGetEntryPointLib +// +#ifdef __EDKII_GLUE_BASE_PE_COFF_GET_ENTRY_POINT_LIB__ +#endif + +// +// PeiServicesTablePointerLib +// +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ +#endif + +// +// BasePostCodeLibDebug +// +#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__ + // + // A DebugLib instance + // Usually EdkIIGluePeiDxeDebugLibReportStatusCodeLib is listed in module inf + // +#endif + +// +// PeiDxePostCodeLibReportStatusCode +// +#ifdef __EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__ + // + // PEI or DXE ReportStatusCodeLib instance + // Usually EdkIIGluePei/DxeReportStatusCodeLib is listed in module inf + // +#endif + + +// +// Check against multiple instances of same library class being used +// +#if defined(__EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__) + #error EdkIIGluePeiDxeDebugLibReportStatusCode and EdkIIGlueBaseDebugLibNull: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__) && defined(__EDKII_GLUE_BASE_PCI_LIB_CF8__) + #error EdkIIGluePciLibPciExpress and EdkIIGluePciLibCf8: can only be mutual exclusively used. +#endif + +#if defined (__EDKII_GLUE_DXE_HOB_LIB__) && (__EDKII_GLUE_PEI_HOB_LIB__) + #error EdkIIGlueDxeHobLib and EdkIIGluePeiHobLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__) + #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGlueBasePostCodeLibDebug: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__) + #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__) + #error EdkIIGlueBasePostCodeLibDebug and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) + #error EdkIIGluePeiServicesTablePointerLib and EdkIIGluePeiServicesTablePointerLibMm7: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__) + #error EdkIIGluePeiServicesTablePointerLib and EdkIIGluePeiServicesTablePointerLibKr1: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__) + #error EdkIIGluePeiServicesTablePointerLibMm7 and EdkIIGluePeiServicesTablePointerLibKr1: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__) + #error EdkIIGlueDxeReportStatusCodeLib and EdkIIGluePeiReportStatusCodeLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__) && defined(__EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__) + #error EdkIIGlueDxeMemoryAllocationLib and EdkIIGluePeiMemoryAllocationLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_DXE_SMBUS_LIB__) && defined(__EDKII_GLUE_PEI_SMBUS_LIB__) + #error EdkIIGlueDxeSmbusLib and EdkIIGluePeiSmbusLib: can only be mutual exclusively used. +#endif + +#if defined(__EDKII_GLUE_BASE_IO_LIB_INTRINSIC__) && defined(__EDKII_GLUE_DXE_IO_LIB_CPU_IO__) + #error EdkIIGlueBaseIoLibIntrinsic and EdkIIGlueDxeIoLibCpuIo: can only be mutual exclusively used. +#endif + +// +// Some instances must be supplied +// +#ifdef __EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ + #if !defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && !defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__) + #error You use EdkIIGluePeiDxeDebugLibReportStatusCode, so either EdkIIGlueDxeReportStatusCodeLib or EdkIIGluePeiReportStatusCodeLib must be supplied + #endif +#endif + +#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__ + #if !defined(__EDKII_GLUE_PEI_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) && !defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__) + #error You use EdkIIGlueBasePostCodeLibDebug, so either EdkIIGluePeiDxeDebugLibReportStatusCode or EdkIIGlueBaseDebugLibNull must be supplied + #endif +#endif + +// +// EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined +// +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ + #ifndef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__ + #error "EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined. Please define __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__." + #endif +#endif + +// +// EdkII Glue Library Constructors: +// NOTE: the constructors must be called according to dependency order +// +// UefiBootServicesTableLib UefiBootServicesTableLibConstructor() +// DxeIoLibCpuIo IoLibConstructor() +// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor() +// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct() +// DxeHobLib HobLibConstructor() +// UefiDriverModelLib UefiDriverModelLibConstructor() +// PeiServicesTablePointerLib PeiServicesTablePointerLibConstructor() +// PeiServicesTablePointerLibMm7 PeiServicesTablePointerLibConstructor() +// PeiServicesTablePointerLibKr1 PeiServicesTablePointerLibConstructor() +// DxeSmbusLib SmbusLibConstructor() +// DxeServicesTableLib DxeServicesTableLibConstructor() +// DxeSalLib DxeSalLibConstructor() +// + +#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ +EFI_STATUS +UefiBootServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__ +EFI_STATUS +EFIAPI +IoLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ +EFI_STATUS +UefiRuntimeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ +EFI_STATUS +RuntimeDriverLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_DXE_HOB_LIB__ +EFI_STATUS +HobLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ +EFI_STATUS +UefiDriverModelLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__ +EFI_STATUS +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); +#endif + +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ +EFI_STATUS +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); +#endif + +#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_KR1__ +EFI_STATUS +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); +#endif + +#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__ +EFI_STATUS +EFIAPI +SmbusLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ +EFI_STATUS +DxeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_SAL_LIB__ +EFI_STATUS +EFIAPI +DxeSalLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +// +// EdkII Glue Library Destructors: +// NOTE: the destructors must be called according to dependency order +// +// UefiDriverModelLibDestructor UefiDriverModelLibDestructor() +// EdkDxeRuntimeDriverLib RuntimeDriverLibDeconstruct() +// +#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__ +EFI_STATUS +UefiDriverModelLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__ +EFI_STATUS +RuntimeDriverLibDeconstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h new file mode 100644 index 0000000000..0a6310696a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DxeDepex.h + +Abstract: + + This file is used by .dxs file. To write common .dxs for R8.x and R9, a + header file named DxeDepex.h musted be present. + +--*/ + + +#ifndef __EDKII_GLUELIB_DXEDEPEX_H__ +#define __EDKII_GLUELIB_DXEDEPEX_H__ + + +// +// this file is used by .dxs file, just a place holder +// + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ebc/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ebc/EdkIIGlueProcessorBind.h new file mode 100644 index 0000000000..a96b57f68e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ebc/EdkIIGlueProcessorBind.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueProcessorBind.h + +Abstract: + + Processor specific definitions + +--*/ + +#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__ +#define __EDKII_GLUE_PROCESSOR_BIND_H__ + +// +// The Microsoft* C compiler can removed references to unreferenced data items +// if the /OPT:REF linker option is used. We defined a macro as this is a +// a non standard extension +// +#if _MSC_EXTENSIONS + #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) +#else + #define GLOBAL_REMOVE_IF_UNREFERENCED +#endif + +#ifndef MDE_CPU_EBC + #define MDE_CPU_EBC +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h new file mode 100644 index 0000000000..605c84547e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h @@ -0,0 +1,93 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueBase.h + +Abstract: + + Root include file for Base modules + +--*/ + +#ifndef __EDKII_GLUE_BASE_H__ +#define __EDKII_GLUE_BASE_H__ + +// +// Using this header means building with EdkIIGlueLib +// +#ifndef BUILD_WITH_EDKII_GLUE_LIB + #define BUILD_WITH_EDKII_GLUE_LIB +#endif + +// +// General Type & API definitions +// + +#include "EfiBind.h" +#include "EfiTypes.h" +#include "EfiError.h" +#include "Common\EdkIIGlueBaseTypes.h" +#include "EfiImage.h" +#include "EfiPeOptionalHeader.h" +#include "EfiStdArg.h" +#include "EfiDebug.h" +#include "EdkIIGlueProcessorBind.h" + +// +// Some Status Code data type definitions are in TianoSpecTypes.h in R8.5 +// +#if (TIANO_RELEASE_VERSION <= 0x00080005) +#include "TianoSpecTypes.h" +#endif +#include "EfiStatusCode.h" + +// +// R8.x Library headers used by EdkII Glue Libraries +// +#include "LinkedList.h" +#include "EfiCommonLib.h" + +#include "Common\EdkIIGlueDefinitionChangesBase.h" + +// +// EdkII Glue Library Class headers +// + +#include "Library\EdkIIGlueBaseLib.h" +#include "Library\EdkIIGlueBaseMemoryLib.h" +#include "Library\EdkIIGlueCacheMaintenanceLib.h" +#include "Library\EdkIIGlueIoLib.h" +#include "Library\EdkIIGluePciCf8Lib.h" +#include "Library\EdkIIGluePciExpressLib.h" +#include "Library\EdkIIGluePciLib.h" +#include "Library\EdkIIGluePeCoffGetEntryPointLib.h" +#include "Library\EdkIIGluePeCoffLib.h" +#include "Library\EdkIIGluePostCodeLib.h" +#include "Library\EdkIIGluePrintLib.h" +#include "Library\EdkIIGlueTimerLib.h" +#include "Library\EdkIIGlueUefiDecompressLib.h" +#include "Library\EdkIIGlueDebugLib.h" + +// +// Publish MDE Library PCDs +// +#include "Pcd\EdkIIGluePcdBaseLib.h" +#include "Pcd\EdkIIGluePcdDebugLib.h" +#include "Pcd\EdkIIGluePcdIoLib.h" +#include "Pcd\EdkIIGluePcdPciExpressLib.h" +#include "Pcd\EdkIIGluePcdPostCodeLib.h" +#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h" +#include "Pcd\EdkIIGluePcdTimerLib.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h new file mode 100644 index 0000000000..6bbcfee1bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueConfig.h + +Abstract: + + Configurable items provided by GlueLib + +--*/ + +#ifndef __EDKII_GLUE_CONFIG_H__ +#define __EDKII_GLUE_CONFIG_H__ + +#include "EdkIIGlueProcessorBind.h" + +// +// Glue Library version +// +// 0x3000 - the 3rd release +// 0x5000 - support IPF. Jan, 2007 +// 0x6000 - support EBC. Feb, 2007 +// +// For reference only, don't change the value +// +#define EDKII_GLUE_LIBRARY_VERSION 0x6000 + + +// +// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined. +// +#if !defined(EFI_SPECIFICATION_VERSION) + #error EFI_SPECIFICATION_VERSION not defined +#elif !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif (TIANO_RELEASE_VERSION == 0) + #error TIANO_RELEASE_VERSION can not be zero +#endif + + +// +// Glue Library debug flag +// +// Controls debug ON/OFF of GlueLib itself, no +// effect on any other libraries or modules +// +// Values: +// FALSE : debug off +// any TRUE value : debug on +// +#define EDKII_GLUE_LIBRARY_DEBUG_ENABLE 0 + + +// +// max unicode string length +// +#define EDKII_GLUE_MaximumUnicodeStringLength 1000000 + +// +// max ascii string length +// +#define EDKII_GLUE_MaximumAsciiStringLength 1000000 + +// +// spin lock timeout +// +#define EDKII_GLUE_SpinLockTimeout 10000000 + +// +// max linked list length +// +#define EDKII_GLUE_MaximumLinkedListLength 1000000 + +// +// debug print level +// only when EFI_DEBUG is defined, the mask is effective +// +#define EDKII_GLUE_DebugPrintErrorLevel EFI_D_ERROR + +// +// debug propery mask +// only when EFI_DEBUG is defined, the mask is effective +// +#define EDKII_GLUE_DebugPropertyMask ( DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED \ + | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED \ + | DEBUG_PROPERTY_DEBUG_CODE_ENABLED \ + | DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED \ + | DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED \ + | DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED \ + ) + +// +// clear memory value +// +#define EDKII_GLUE_DebugClearMemoryValue 0xAF + +// +// pci express base address +// +#define EDKII_GLUE_PciExpressBaseAddress 0xE0000000 + +// +// +// This value is FSB Clock frequency. Its unit is Hz and its +// default value is 200000000, that means FSB frequency is 200Mhz. +// +#define EDKII_GLUE_FSBClock 200000000 + +// +// post code property mask +// +#define EDKII_GLUE_PostCodePropertyMask ( POST_CODE_PROPERTY_POST_CODE_ENABLED \ + | POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED \ + ) + +// +// status code property mask +// +#define EDKII_GLUE_ReportStatusCodePropertyMask ( REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \ + | REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \ + | REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \ + ) + + +// +// for IPF only +// The base address of IPF IO Block +// +#ifdef MDE_CPU_IPF +#define EDKII_GLUE_IoBlockBaseAddressForIpf 0x0ffffc000000 +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h new file mode 100644 index 0000000000..8aa355e127 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h @@ -0,0 +1,251 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDxe.h + +Abstract: + + Root include file for DXE modules + +--*/ + +#ifndef __EDKII_GLUE_DXE_H__ +#define __EDKII_GLUE_DXE_H__ + + +// +// General Type & API definitions +// + +#include "Tiano.h" +#include "BootMode.h" +#include "EfiBootScript.h" +#include "EfiCapsule.h" +#include "EfiDependency.h" +#include "EfiImageFormat.h" +#include "EfiImage.h" +#include "EfiPeOptionalHeader.h" +#include "EfiFirmwareVolumeHeader.h" +#include "EfiFirmwareFileSystem.h" +#include "PeiHob.h" +#include "EfiInternalFormRepresentation.h" +#include "EfiStatusCode.h" + +// +// IPF only +// +#ifdef MDE_CPU_IPF +#include "SalApi.h" +#endif + +// +// GUID definitions +// + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#include EFI_GUID_DEFINITION (EventGroup) +#include EFI_GUID_DEFINITION (EventLegacybios) +#include EFI_GUID_DEFINITION (FrameworkDevicePath) + +#include EFI_PROTOCOL_DEFINITION (EdidActive) +#include EFI_PROTOCOL_DEFINITION (EdidDiscovered) +#include EFI_PROTOCOL_DEFINITION (EdidOverride) +#include EFI_PROTOCOL_DEFINITION (GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION (Hash) +#include EFI_PROTOCOL_DEFINITION (ScsiPassThruExt) +#include EFI_PROTOCOL_DEFINITION (TapeIo) +#endif + +#include EFI_GUID_DEFINITION (Acpi) +#include EFI_GUID_DEFINITION (AcpiTableStorage) +#include EFI_GUID_DEFINITION (Apriori) +#include EFI_GUID_DEFINITION (Capsule) +#include EFI_GUID_DEFINITION (DataHubRecords) +#include EFI_GUID_DEFINITION (DebugImageInfoTable) +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (FirmwareFileSystem) +#include EFI_GUID_DEFINITION (GlobalVariable) +#include EFI_GUID_DEFINITION (Gpt) +#include EFI_GUID_DEFINITION (Hob) +#include EFI_GUID_DEFINITION (MemoryAllocationHob) +#include EFI_GUID_DEFINITION (Mps) +#include EFI_GUID_DEFINITION (PcAnsi) +#include EFI_GUID_DEFINITION (SalSystemTable) +#include EFI_GUID_DEFINITION (Smbios) +//#include EFI_GUID_DEFINITION (SmmCommunicate) +#include EFI_GUID_DEFINITION (SmramMemoryReserve) +// +// *** NOTE ***: StatusCodeDataTypeId definition differences need to be +// resolved when porting a module to real EDK II +// +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +// +// Protocol definitions +// + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#include EFI_PROTOCOL_DEFINITION (DevicePathFromText) +#include EFI_PROTOCOL_DEFINITION (DevicePathToText) +#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities) +#include EFI_PROTOCOL_DEFINITION (Dhcp4) +#include EFI_PROTOCOL_DEFINITION (Ip4) +#include EFI_PROTOCOL_DEFINITION (Ip4Config) +#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName) +#include EFI_PROTOCOL_DEFINITION (UsbHostController) +#include EFI_PROTOCOL_DEFINITION (ManagedNetwork) +#include EFI_PROTOCOL_DEFINITION (Mtftp4) +#include EFI_PROTOCOL_DEFINITION (ServiceBinding) +#include EFI_PROTOCOL_DEFINITION (Tcp4) +#include EFI_PROTOCOL_DEFINITION (Udp4) +#include EFI_PROTOCOL_DEFINITION (Arp) +// check here: currently not implementated +//#include EFI_PROTOCOL_DEFINITION (AuthenticationInfo) +#endif + +#include EFI_PROTOCOL_DEFINITION (AcpiSupport) +#include EFI_PROTOCOL_DEFINITION (Bis) +#include EFI_PROTOCOL_DEFINITION (BlockIo) +#include EFI_PROTOCOL_DEFINITION (BootScriptSave) +#include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride) +#include EFI_PROTOCOL_DEFINITION (ComponentName) +#include EFI_PROTOCOL_DEFINITION (ComponentName2) +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (DataHub) +#include EFI_PROTOCOL_DEFINITION (DebugPort) +#include EFI_PROTOCOL_DEFINITION (DebugSupport) +#include EFI_PROTOCOL_DEFINITION (Decompress) +#include EFI_PROTOCOL_DEFINITION (DeviceIo) +#include EFI_PROTOCOL_DEFINITION (DevicePath) +#include EFI_PROTOCOL_DEFINITION (DiskIo) +#include EFI_PROTOCOL_DEFINITION (DriverBinding) +#include EFI_PROTOCOL_DEFINITION (DriverConfiguration) +#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics) +#include EFI_PROTOCOL_DEFINITION (Ebc) +#include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier) +#include EFI_PROTOCOL_DEFINITION (FileInfo) +#include EFI_PROTOCOL_DEFINITION (FileSystemInfo) +#include EFI_PROTOCOL_DEFINITION (FileSystemVolumeLabelInfo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch) +#include EFI_PROTOCOL_DEFINITION (FormBrowser) +#include EFI_PROTOCOL_DEFINITION (FormCallback) +#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction) +#include EFI_PROTOCOL_DEFINITION (Hii) +#include EFI_PROTOCOL_DEFINITION (IdeControllerInit) +#include EFI_PROTOCOL_DEFINITION (IncompatiblePciDeviceSupport) +#include EFI_PROTOCOL_DEFINITION (Legacy8259) +#include EFI_PROTOCOL_DEFINITION (LegacyBios) +#include EFI_PROTOCOL_DEFINITION (LegacyBiosPlatform) +#include EFI_PROTOCOL_DEFINITION (LegacyInterrupt) +#include EFI_PROTOCOL_DEFINITION (LegacyRegion) +#include EFI_PROTOCOL_DEFINITION (LoadedImage) +#include EFI_PROTOCOL_DEFINITION (LoadFile) +#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation) +#include EFI_PROTOCOL_DEFINITION (PciHotplugInit) +#include EFI_PROTOCOL_DEFINITION (PciIo) +#include EFI_PROTOCOL_DEFINITION (PciPlatform) +#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo) +#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride) +#include EFI_PROTOCOL_DEFINITION (PxeBaseCode) +#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack) +#include EFI_PROTOCOL_DEFINITION (ScsiIo) +#include EFI_PROTOCOL_DEFINITION (ScsiPassThru) +#include EFI_PROTOCOL_DEFINITION (SectionExtraction) +#include EFI_PROTOCOL_DEFINITION (SerialIo) +#include EFI_PROTOCOL_DEFINITION (SimpleFilesystem) +#include EFI_PROTOCOL_DEFINITION (SimpleNetwork) +#include EFI_PROTOCOL_DEFINITION (SimplePointer) +#include EFI_PROTOCOL_DEFINITION (SimpleTextIn) +#include EFI_PROTOCOL_DEFINITION (SimpleTextOut) +#include EFI_PROTOCOL_DEFINITION (Smbus) +#include EFI_PROTOCOL_DEFINITION (SmmAccess) +#include EFI_PROTOCOL_DEFINITION (SmmBase) +#include EFI_PROTOCOL_DEFINITION (SmmControl) +#include EFI_PROTOCOL_DEFINITION (SmmGpiDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmIchnDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmPeriodicTimerDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmPowerButtonDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmStandbyButtonDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmStatusCode) +#include EFI_PROTOCOL_DEFINITION (SmmSwDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmSxDispatch) +#include EFI_PROTOCOL_DEFINITION (SmmUsbDispatch) +#include EFI_PROTOCOL_DEFINITION (UgaDraw) +#include EFI_PROTOCOL_DEFINITION (UnicodeCollation) +#include EFI_PROTOCOL_DEFINITION (UsbHostController) +#include EFI_PROTOCOL_DEFINITION (UsbIo) +#include EFI_PROTOCOL_DEFINITION (SecurityPolicy) +#include EFI_PROTOCOL_DEFINITION (LoadPe32Image) + +// +// Arch Protocol definitions +// + +#include EFI_ARCH_PROTOCOL_DEFINITION (Bds) +#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu) +#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome) +#include EFI_ARCH_PROTOCOL_DEFINITION (Monotoniccounter) +#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock) +#include EFI_ARCH_PROTOCOL_DEFINITION (Reset) +#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime) +#include EFI_ARCH_PROTOCOL_DEFINITION (Security) +#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) +#include EFI_ARCH_PROTOCOL_DEFINITION (Timer) +#include EFI_ARCH_PROTOCOL_DEFINITION (Variable) +#include EFI_ARCH_PROTOCOL_DEFINITION (Variablewrite) +#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer) + +// +// IPF only +// +#ifdef MDE_CPU_IPF +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#endif + +// +// R8.x Library headers used by EdkII Glue Libraries +// +#include "EfiDriverLib.h" +#include "EfiCapsule.h" + +#include "Common\EdkIIGlueDefinitionChangesDxe.h" + + +// +// EdkII Glue Library Class headers +// + +#include "EdkIIGlueBase.h" +#include "Library\EdkIIGlueDebugLib.h" +#include "Library\EdkIIGluePostCodeLib.h" +#include "Library\EdkIIGlueReportStatusCodeLib.h" +#include "Library\EdkIIGlueHiiLib.h" +#include "Library\EdkIIGlueHobLib.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" +#include "Library\EdkIIGlueSmbusLib.h" +#include "Library\EdkIIGlueDxeRuntimeDriverLib.h" +#include "Library\EdkIIGlueDxeServicesTableLib.h" +#include "Library\EdkIIGlueDxeSmmDriverEntryPoint.h" +#include "Library\EdkIIGlueDevicePathLib.h" +#include "Library\EdkIIGlueUefiLib.h" +#include "Library\EdkIIGlueUefiDecompressLib.h" +#include "Library\EdkIIGlueUefiDriverModelLib.h" +#include "Library\EdkIIGlueUefiBootServicesTableLib.h" +#include "Library\EdkIIGlueUefiDriverEntryPoint.h" +#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h new file mode 100644 index 0000000000..617364ffba --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h @@ -0,0 +1,113 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePeim.h + +Abstract: + + Root include file for PEI Modules + +**/ + + +#ifndef __EDKII_GLUE_PEIM_H__ +#define __EDKII_GLUE_PEIM_H__ + + +// +// Check to make sure TIANO_RELEASE_VERSION is defined +// +#if !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif (TIANO_RELEASE_VERSION == 0) + #error TIANO_RELEASE_VERSION can not be zero +#endif + +// +// General Type & API definitions +// + +#include "Pei.h" +#include "EfiBootScript.h" +#include "EfiImage.h" +#include "EfiPeOptionalHeader.h" +#include "EfiCapsule.h" +#include EFI_PROTOCOL_DEFINITION (DevicePath) +#include "TianoDevicePath.h" + +// +// GUID definitions +// + +#include EFI_GUID_DEFINITION (Apriori) +#include EFI_GUID_DEFINITION (Capsule) +#include EFI_GUID_DEFINITION (DxeServices) +#include EFI_GUID_DEFINITION (Hob) +#include EFI_GUID_DEFINITION (MemoryAllocationHob) +#include EFI_GUID_DEFINITION (FirmwareFileSystem) +#include EFI_GUID_DEFINITION (SmramMemoryReserve) +#include EFI_GUID_DEFINITION (DataHubRecords) +// +// *** NOTE ***: StatusCodeDataTypeId definition differences need to be +// resolved when porting a module to real EDK II +// +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +// +// Ppi definitions +// + +#include EFI_PPI_DEFINITION (BlockIo) +#include EFI_PPI_DEFINITION (BootInRecoveryMode) +#include EFI_PPI_DEFINITION (BootScriptExecuter) +#include EFI_PPI_DEFINITION (CpuIo) +#include EFI_PPI_DEFINITION (DeviceRecoveryModule) +#include EFI_PPI_DEFINITION (DxeIpl) +#include EFI_PPI_DEFINITION (EndOfPeiSignal) +#include EFI_PPI_DEFINITION (FindFv) +#include EFI_PPI_DEFINITION (LoadFile) +#include EFI_PPI_DEFINITION (BootMode) +#include EFI_PPI_DEFINITION (MemoryDiscovered) +#include EFI_PPI_DEFINITION (PciCfg) +#include EFI_PPI_DEFINITION (Variable) +#include EFI_PPI_DEFINITION (RecoveryModule) +#include EFI_PPI_DEFINITION (Reset) +#include EFI_PPI_DEFINITION (S3Resume) +#include EFI_PPI_DEFINITION (SecPlatforminformation) +#include EFI_PPI_DEFINITION (SectionExtraction) +#include EFI_PPI_DEFINITION (Security) +#include EFI_PPI_DEFINITION (Smbus) +#include EFI_PPI_DEFINITION (Stall) +#include EFI_PPI_DEFINITION (StatusCode) + + +#include "Common\EdkIIGlueDefinitionChangesPeim.h" + +// +// EdkII Glue Library Class headers +// + +#include "EdkIIGlueBase.h" +#include "Library\EdkIIGlueDebugLib.h" +#include "Library\EdkIIGluePostCodeLib.h" +#include "Library\EdkIIGlueReportStatusCodeLib.h" +#include "Library\EdkIIGlueHobLib.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" +#include "Library\EdkIIGlueSmbusLib.h" +#include "Library\EdkIIGluePeiServicesLib.h" +#include "Library\EdkIIGluePeiServicesTablePointerLib.h" +#include "Library\EdkIIGlueResourcePublicationLib.h" +#include "Library\EdkIIGluePeimEntryPoint.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h new file mode 100644 index 0000000000..e71020e296 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h @@ -0,0 +1,174 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueUefi.h + +Abstract: + + Root include file for UEFI modules. + +**/ + + +#ifndef __EDKII_GLUE_UEFI_H__ +#define __EDKII_GLUE_UEFI_H__ + + +// +// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined. +// also check for legal combinations +// +#if !defined(EFI_SPECIFICATION_VERSION) + #error EFI_SPECIFICATION_VERSION not defined +#elif !defined(TIANO_RELEASE_VERSION) + #error TIANO_RELEASE_VERSION not defined +#elif TIANO_RELEASE_VERSION == 0x00000000 + +// +// UEFI mode with no Tiano extensions is legal +// +#elif (TIANO_RELEASE_VERSION <= 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000) + #error Illegal combination of EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION versions +#endif + +// +// General Type & API definitions +// + +#include "EfiSpec.h" +#include "EfiPxe.h" + + +// +// Protocols from EFI 1.10 that got thier names fixed in UEFI 2.0 +// +#include EFI_PROTOCOL_DEFINITION(LoadedImage) +#include EFI_PROTOCOL_DEFINITION(SimpleTextIn) +#include EFI_PROTOCOL_DEFINITION(SimpleTextOut) +#include EFI_PROTOCOL_DEFINITION(SerialIo) +#include EFI_PROTOCOL_DEFINITION(LoadFile) +#include EFI_PROTOCOL_DEFINITION(SimpleFileSystem) +#include EFI_PROTOCOL_DEFINITION(DiskIo) +#include EFI_PROTOCOL_DEFINITION(BlockIo) +#include EFI_PROTOCOL_DEFINITION(UnicodeCollation) +#include EFI_PROTOCOL_DEFINITION(SimpleNetwork) +#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier) +#include EFI_PROTOCOL_DEFINITION(PxeBaseCode) +#include EFI_PROTOCOL_DEFINITION(PxeBaseCodeCallBack) + +// +// EFI 1.10 Protocols +// +#include EFI_PROTOCOL_DEFINITION(Bis) +#include EFI_PROTOCOL_DEFINITION(BusSpecificDriverOverride) +#include EFI_PROTOCOL_DEFINITION(ComponentName) +#include EFI_PROTOCOL_DEFINITION(ComponentName2) +#include EFI_PROTOCOL_DEFINITION(DebugPort) +#include EFI_PROTOCOL_DEFINITION(DebugSupport) +#include EFI_PROTOCOL_DEFINITION(Decompress) +#include EFI_PROTOCOL_DEFINITION(DriverBinding) +#include EFI_PROTOCOL_DEFINITION(DriverConfiguration) +#include EFI_PROTOCOL_DEFINITION(DriverDiagnostics) +#include EFI_PROTOCOL_DEFINITION(Ebc) +#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier) +#include EFI_PROTOCOL_DEFINITION(FileInfo) +#include EFI_PROTOCOL_DEFINITION(FileSystemInfo) +#include EFI_PROTOCOL_DEFINITION(FileSystemVolumeLabelInfo) +#include EFI_PROTOCOL_DEFINITION(PciIo) +#include EFI_PROTOCOL_DEFINITION(PciRootBridgeIo) +#include EFI_PROTOCOL_DEFINITION(PlatformDriverOverride) +#include EFI_PROTOCOL_DEFINITION(SimplePointer) +#include EFI_PROTOCOL_DEFINITION(ScsiPassThru) +#include EFI_PROTOCOL_DEFINITION(UsbIo) +#include EFI_PROTOCOL_DEFINITION(UsbHostController) +#include EFI_PROTOCOL_DEFINITION(UgaDraw) + +// +// EFI 1.10 GUIDs +// +#include EFI_GUID_DEFINITION(Acpi) +#include EFI_GUID_DEFINITION(DebugImageInfoTable) +#include EFI_GUID_DEFINITION(GlobalVariable) +#include EFI_GUID_DEFINITION(Gpt) +#include EFI_GUID_DEFINITION(PcAnsi) +#include EFI_GUID_DEFINITION(SmBios) +#include EFI_GUID_DEFINITION(SalSystemTable) + + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +// +// UEFI 2.0 Protocols and GUIDs +// +// check here: currently not implementated +//#include EFI_PROTOCOL_DEFINITION(AuthenticationInfo) +#include EFI_PROTOCOL_DEFINITION(DevicePathUtilities) +#include EFI_PROTOCOL_DEFINITION(DevicePathToText) +#include EFI_PROTOCOL_DEFINITION(DevicePathFromText) +#include EFI_PROTOCOL_DEFINITION(GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION(EdidDiscovered) +#include EFI_PROTOCOL_DEFINITION(EdidActive) +#include EFI_PROTOCOL_DEFINITION(EdidOverride) +#include EFI_PROTOCOL_DEFINITION(ScsiIo) +#include EFI_PROTOCOL_DEFINITION(ScsiPassThruExt) +#include EFI_PROTOCOL_DEFINITION(IScsiInitiatorName) +#include EFI_PROTOCOL_DEFINITION(UsbHostController) +#include EFI_PROTOCOL_DEFINITION(TapeIo) +#include EFI_PROTOCOL_DEFINITION(ManagedNetwork) +#include EFI_PROTOCOL_DEFINITION(Arp) +#include EFI_PROTOCOL_DEFINITION(Dhcp4) +#include EFI_PROTOCOL_DEFINITION(IP4) +#include EFI_PROTOCOL_DEFINITION(IP4Config) +#include EFI_PROTOCOL_DEFINITION(Tcp4) +#include EFI_PROTOCOL_DEFINITION(Udp4) +#include EFI_PROTOCOL_DEFINITION(Mtftp4) +#include EFI_PROTOCOL_DEFINITION(ServiceBinding) +#include EFI_PROTOCOL_DEFINITION(Hash) +#include EFI_GUID_DEFINITION(EventGroup) +//#include +#endif + +#if (TIANO_RELEASE_VERSION > 0x00080005) +// +// Need due to R8.5 Tiano contamination of UEFI enumes. +// There is a UEFI library that does things the new way and the old way +// This is why these definitions are need in Uefi.h +// +#include EFI_GUID_DEFINITION (EventLegacyBios) +#include EFI_GUID_DEFINITION (FrameworkDevicePath) +#endif + +// +// R8.x Library headers used by EdkII Glue Libraries +// +#include "TianoSpecTypes.h" +#include "TianoSpecApi.h" +#include "TianoSpecDevicePath.h" +#include "EfiDriverLib.h" + +#include "Common\EdkIIGlueDefinitionChangesBase.h" + +// +// EdkII Glue Library Class headers +// + +#include "EdkIIGlueBase.h" +#include "Library\EdkIIGlueUefiDecompressLib.h" +#include "Library\EdkIIGlueDevicePathLib.h" +#include "Library\EdkIIGlueUefiBootServicesTableLib.h" +#include "Library\EdkIIGlueUefiDriverEntryPoint.h" +#include "Library\EdkIIGlueUefiDriverModelLib.h" +#include "Library\EdkIIGlueUefiLib.h" +#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h new file mode 100644 index 0000000000..b6f55b70bf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueProcessorBind.h + +Abstract: + + Processor specific definitions + +--*/ + +#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__ +#define __EDKII_GLUE_PROCESSOR_BIND_H__ + +// +// The Microsoft* C compiler can removed references to unreferenced data items +// if the /OPT:REF linker option is used. We defined a macro as this is a +// a non standard extension +// +#if _MSC_EXTENSIONS + #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) +#else + #define GLOBAL_REMOVE_IF_UNREFERENCED +#endif + +#ifndef MDE_CPU_IA32 + #define MDE_CPU_IA32 +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ipf/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ipf/EdkIIGlueProcessorBind.h new file mode 100644 index 0000000000..8c6ef88b4f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Ipf/EdkIIGlueProcessorBind.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueProcessorBind.h + +Abstract: + + Processor specific definitions + +--*/ + +#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__ +#define __EDKII_GLUE_PROCESSOR_BIND_H__ + +// +// The Microsoft* C compiler can removed references to unreferenced data items +// if the /OPT:REF linker option is used. We defined a macro as this is a +// a non standard extension +// +#if _MSC_EXTENSIONS + #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) +#else + #define GLOBAL_REMOVE_IF_UNREFERENCED +#endif + +#ifndef MDE_CPU_IPF + #define MDE_CPU_IPF +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h new file mode 100644 index 0000000000..4c95c85ce1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h @@ -0,0 +1,5842 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueBaseLib.h + +Abstract: + + Memory-only library functions with no library constructor/destructor + +--*/ + +#ifndef __EDKII_GLUE_BASE_LIB_H__ +#define __EDKII_GLUE_BASE_LIB_H__ + + +// +// String Functions +// +#define StrCpy(_Dest, _Source) GlueStrCpy(_Dest, _Source) +#define StrnCpy(_Dest, _Source, _Length) GlueStrnCpy(_Dest, _Source, _Length) +#define StrLen(_String) GlueStrLen(_String) +#define StrSize(_String) GlueStrSize(_String) +#define StrCmp(_FristString, _SecondString) GlueStrCmp(_FristString, _SecondString) +#define StrnCmp(_FirstString, _SecondString, _Length) GlueStrnCmp(_FirstString, _SecondString, _Length) +#define StrCat(_Dest, _Source) GlueStrCat(_Dest, _Source) +#define StrnCat(_Dest, _Source, _Length) GlueStrnCat(_Dest, _Source, _Length) + +// +// Linked List +// +#define InitializeListHead(_ListHead) GlueInitializeListHead(_ListHead) +#define InsertHeadList(_ListHead, _Entry ) GlueInsertHeadList(_ListHead, _Entry) +#define InsertTailList(_ListHead, _Entry) GlueInsertTailList(_ListHead, _Entry) +#define GetFirstNode(_List) GlueGetFirstNode(_List) +#define GetNextNode(_List, _Node) GlueGetNextNode(_List, _Node) +#define IsListEmpty(_ListHead) GlueIsListEmpty(_ListHead) +#define IsNull(_List, _Node) GlueIsNull(_List, _Node) +#define IsNodeAtEnd(_List, _Node) GlueIsNodeAtEnd(_List, _Node) +#define SwapListEntries(_FirstEntry, _SecondEntry) GlueSwapListEntries(_FirstEntry, _SecondEntry) +#define RemoveEntryList(_Entry) GlueRemoveEntryList(_Entry) + +// +// Math Functions +// +#define LShiftU64(_Op, _Count) GlueLShiftU64(_Op, _Count) +#define RShiftU64(_Op, _Count) GlueRShiftU64(_Op, _Count) +#define MultU64x32(_Multiplicand, _Multiplier) GlueMultU64x32(_Multiplicand, _Multiplier) +#define DivU64x32(_Dividend, _Divisor) GlueDivU64x32(_Dividend, _Divisor) + +// +// Others +// +#define GetInterruptState() GlueGetInterruptState() + + +// +// Definitions for architecture specific types +// These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER +// + +// +// SPIN_LOCK +// +typedef UINTN SPIN_LOCK; + +#if defined (MDE_CPU_IA32) +// +// IA32 context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT32 Ebx; + UINT32 Esi; + UINT32 Edi; + UINT32 Ebp; + UINT32 Esp; + UINT32 Eip; +} BASE_LIBRARY_JUMP_BUFFER; + +#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 + +#elif defined (MDE_CPU_IPF) +// +// IPF context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT64 F2[2]; + UINT64 F3[2]; + UINT64 F4[2]; + UINT64 F5[2]; + UINT64 F16[2]; + UINT64 F17[2]; + UINT64 F18[2]; + UINT64 F19[2]; + UINT64 F20[2]; + UINT64 F21[2]; + UINT64 F22[2]; + UINT64 F23[2]; + UINT64 F24[2]; + UINT64 F25[2]; + UINT64 F26[2]; + UINT64 F27[2]; + UINT64 F28[2]; + UINT64 F29[2]; + UINT64 F30[2]; + UINT64 F31[2]; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 SP; + UINT64 BR0; + UINT64 BR1; + UINT64 BR2; + UINT64 BR3; + UINT64 BR4; + UINT64 BR5; + UINT64 InitialUNAT; + UINT64 AfterSpillUNAT; + UINT64 PFS; + UINT64 BSP; + UINT64 Predicates; + UINT64 LoopCount; + UINT64 FPSR; +} BASE_LIBRARY_JUMP_BUFFER; + +#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10 + +#elif defined (MDE_CPU_X64) +// +// X64 context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT64 Rbx; + UINT64 Rsp; + UINT64 Rbp; + UINT64 Rdi; + UINT64 Rsi; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 Rip; +} BASE_LIBRARY_JUMP_BUFFER; + +#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 + +#elif defined (MDE_CPU_EBC) +// +// EBC context buffer used by SetJump() and LongJump() +// +typedef struct { + UINT64 R0; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 IP; +} BASE_LIBRARY_JUMP_BUFFER; + +#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8 + +#else +#error Unknown Processor Type +#endif + +// +// String Services +// + +/** + Copies one Null-terminated Unicode string to another Null-terminated Unicode + string and returns the new Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destiantion + +**/ +CHAR16 * +EFIAPI +GlueStrCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ); +/** + Copies one Null-terminated Unicode string with a maximum length to another + Null-terminated Unicode string with a maximum length and returns the new + Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. At most, Length Unicode + characters are copied from Source to Destination. If Length is 0, then + Destination is returned unmodified. If Length is greater that the number of + Unicode characters in Source, then Destination is padded with Null Unicode + characters. If Source and Destination overlap, then the results are + undefined. + + If Length > 0 and Destination is NULL, then ASSERT(). + If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Length > 0 and Source is NULL, then ASSERT(). + If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to copy. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ); +/** + Returns the length of a Null-terminated Unicode string. + + This function returns the number of Unicode characters in the Null-terminated + Unicode string specified by String. + + If String is NULL, then ASSERT(). + If String is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The length of String. + +**/ +UINTN +EFIAPI +GlueStrLen ( + IN CONST CHAR16 *String + ); +/** + Returns the size of a Null-terminated Unicode string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated Unicode + string specified by String. + + If String is NULL, then ASSERT(). + If String is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The size of String. + +**/ +UINTN +EFIAPI +GlueStrSize ( + IN CONST CHAR16 *String + ); +/** + Compares two Null-terminated Unicode strings, and returns the difference + between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched Unicode character in SecondString subtracted from the first + mismatched Unicode character in FirstString. + + If FirstString is NULL, then ASSERT(). + If FirstString is not aligned on a 16-bit boundary, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If SecondString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString + ); +/** + Compares two Null-terminated Unicode strings with maximum lengths, and + returns the difference between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. At most, Length Unicode + characters will be compared. If Length is 0, then 0 is returned. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched Unicode character in SecondString + subtracted from the first mismatched Unicode character in FirstString. + + If Length > 0 and FirstString is NULL, then ASSERT(). + If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT(). + If Length > 0 and SecondString is NULL, then ASSERT(). + If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to compare. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrnCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString, + IN UINTN Length + ); +/** + Concatenates one Null-terminated Unicode string to another Null-terminated + Unicode string, and returns the concatenated Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination. The Null-terminated concatenated + Unicode String is returned. If Source and Destination overlap, then the + results are undefined. + + If Destination is NULL, then ASSERT(). + If Destination is not aligned on a 16-bit bounadary, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit bounadary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ); +/** + Concatenates one Null-terminated Unicode string with a maximum length to the + end of another Null-terminated Unicode string, and returns the concatenated + Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination, and Destination is returned. At + most, Length Unicode characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Destination is NULL, then ASSERT(). + If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Length > 0 and Source is NULL, then ASSERT(). + If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to concatenate from + Source. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ); + +/** + Returns the first occurance of a Null-terminated Unicode sub-string + in a Null-terminated Unicode string. + + This function scans the contents of the Null-terminated Unicode string + specified by String and returns the first occurrence of SearchString. + If SearchString is not found in String, then NULL is returned. If + the length of SearchString is zero, then String is + returned. + + If String is NULL, then ASSERT(). + If String is not aligned on a 16-bit boundary, then ASSERT(). + If SearchString is NULL, then ASSERT(). + If SearchString is not aligned on a 16-bit boundary, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and SearchString + or String contains more than PcdMaximumUnicodeStringLength Unicode + characters not including the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + @param SearchString Pointer to a Null-terminated Unicode string to search for. + + @retval NULL If the SearchString does not appear in String. + @retval !NULL If there is a match. + +**/ +CHAR16 * +EFIAPI +StrStr ( + IN CONST CHAR16 *String, + IN CONST CHAR16 *SearchString + ); + +/** + Convert a Null-terminated Unicode decimal string to a value of + type UINTN. + + This function returns a value of type UINTN by interpreting the contents + of the Unicode string specified by String as a decimal number. The format + of the input Unicode string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The + function will ignore the pad space, which includes spaces or + tab characters, before [decimal digits]. The running zero in the + beginning of [decimal digits] will be ignored. Then, the function + stops at the first character that is a not a valid decimal character + or a Null-terminator, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, + then 0 is returned. + If the number represented by String overflows according + to the range defined by UINTN, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINTN + +**/ +UINTN +EFIAPI +StrDecimalToUintn ( + IN CONST CHAR16 *String + ); + +/** + Convert a Null-terminated Unicode decimal string to a value of + type UINT64. + + This function returns a value of type UINT64 by interpreting the contents + of the Unicode string specified by String as a decimal number. The format + of the input Unicode string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The + function will ignore the pad space, which includes spaces or + tab characters, before [decimal digits]. The running zero in the + beginning of [decimal digits] will be ignored. Then, the function + stops at the first character that is a not a valid decimal character + or a Null-terminator, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, + then 0 is returned. + If the number represented by String overflows according + to the range defined by UINT64, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +StrDecimalToUint64 ( + IN CONST CHAR16 *String + ); + +/** + Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN. + + This function returns a value of type UINTN by interpreting the contents + of the Unicode string specified by String as a hexadecimal number. + The format of the input Unicode string String is: + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. + If "x" appears in the input string, it must be prefixed with at least one 0. + The function will ignore the pad space, which includes spaces or tab characters, + before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or + [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the + first valid hexadecimal digit. Then, the function stops at the first character that is + a not a valid hexadecimal character or NULL, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then zero is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, + then zero is returned. + If the number represented by String overflows according to the range defined by + UINTN, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINTN + +**/ +UINTN +EFIAPI +StrHexToUintn ( + IN CONST CHAR16 *String + ); + +/** + Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64. + + This function returns a value of type UINT64 by interpreting the contents + of the Unicode string specified by String as a hexadecimal number. + The format of the input Unicode string String is + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. + If "x" appears in the input string, it must be prefixed with at least one 0. + The function will ignore the pad space, which includes spaces or tab characters, + before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or + [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the + first valid hexadecimal digit. Then, the function stops at the first character that is + a not a valid hexadecimal character or NULL, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then zero is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, + then zero is returned. + If the number represented by String overflows according to the range defined by + UINT64, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +StrHexToUint64 ( + IN CONST CHAR16 *String + ); + +/** + Convert one Null-terminated Unicode string to a Null-terminated + ASCII string and returns the ASCII string. + + This function converts the content of the Unicode string Source + to the ASCII string Destination by copying the lower 8 bits of + each Unicode character. It returns Destination. + + If any Unicode characters in Source contain non-zero value in + the upper 8 bits, then ASSERT(). + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and Source contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and Source contains more + than PcdMaximumAsciiStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Source Pointer to a Null-terminated Unicode string. + @param Destination Pointer to a Null-terminated ASCII string. + + @reture Destination + +**/ +CHAR8 * +EFIAPI +UnicodeStrToAsciiStr ( + IN CONST CHAR16 *Source, + OUT CHAR8 *Destination + ); + +/** + Copies one Null-terminated ASCII string to another Null-terminated ASCII + string and returns the new ASCII string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ); +/** + Copies one Null-terminated ASCII string with a maximum length to another + Null-terminated ASCII string with a maximum length and returns the new ASCII + string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. At most, Length ASCII characters + are copied from Source to Destination. If Length is 0, then Destination is + returned unmodified. If Length is greater that the number of ASCII characters + in Source, then Destination is padded with Null ASCII characters. If Source + and Destination overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to copy. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ); +/** + Returns the length of a Null-terminated ASCII string. + + This function returns the number of ASCII characters in the Null-terminated + ASCII string specified by String. + + If Length > 0 and Destination is NULL, then ASSERT(). + If Length > 0 and Source is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The length of String. + +**/ +UINTN +EFIAPI +AsciiStrLen ( + IN CONST CHAR8 *String + ); +/** + Returns the size of a Null-terminated ASCII string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated ASCII string + specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The size of String. + +**/ +UINTN +EFIAPI +AsciiStrSize ( + IN CONST CHAR8 *String + ); +/** + Compares two Null-terminated ASCII strings, and returns the difference + between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched ASCII character in SecondString subtracted from the first + mismatched ASCII character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ); +/** + Performs a case insensitive comparison of two Null-terminated ASCII strings, + and returns the difference between the first mismatched ASCII characters. + + This function performs a case insensitive comparison of the Null-terminated + ASCII string FirstString to the Null-terminated ASCII string SecondString. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched lower case ASCII character in + SecondString subtracted from the first mismatched lower case ASCII character + in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString using case insensitive + comparisons. + @retval !=0 FirstString is not identical to SecondString using case + insensitive comparisons. + +**/ +INTN +EFIAPI +AsciiStriCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ); +/** + Compares two Null-terminated ASCII strings with maximum lengths, and returns + the difference between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. At most, Length ASCII characters + will be compared. If Length is 0, then 0 is returned. If FirstString is + identical to SecondString, then 0 is returned. Otherwise, the value returned + is the first mismatched ASCII character in SecondString subtracted from the + first mismatched ASCII character in FirstString. + + If Length > 0 and FirstString is NULL, then ASSERT(). + If Length > 0 and SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrnCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString, + IN UINTN Length + ); +/** + Concatenates one Null-terminated ASCII string to another Null-terminated + ASCII string, and returns the concatenated ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents of + Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination. The Null-terminated concatenated ASCII + String is returned. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ); +/** + Concatenates one Null-terminated ASCII string with a maximum length to the + end of another Null-terminated ASCII string, and returns the concatenated + ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents + of Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination, and Destination is returned. At most, + Length ASCII characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Length > 0 and Destination is NULL, then ASSERT(). + If Length > 0 and Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters not including the Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to concatenate from + Source. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ); + +/** + Returns the first occurance of a Null-terminated ASCII sub-string + in a Null-terminated ASCII string. + + This function scans the contents of the ASCII string specified by String + and returns the first occurrence of SearchString. If SearchString is not + found in String, then NULL is returned. If the length of SearchString is zero, + then String is returned. + + If String is NULL, then ASSERT(). + If SearchString is NULL, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and SearchString or + String contains more than PcdMaximumAsciiStringLength Unicode characters + not including the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + @param SearchString Pointer to a Null-terminated ASCII string to search for. + + @retval NULL If the SearchString does not appear in String. + @retval !NULL If there is a match. + +**/ +CHAR8 * +EFIAPI +AsciiStrStr ( + IN CONST CHAR8 *String, + IN CONST CHAR8 *SearchString + ); + +/** + Convert a Null-terminated ASCII decimal string to a value of type + UINTN. + + This function returns a value of type UINTN by interpreting the contents + of the ASCII string String as a decimal number. The format of the input + ASCII string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The function will + ignore the pad space, which includes spaces or tab characters, before the digits. + The running zero in the beginning of [decimal digits] will be ignored. Then, the + function stops at the first character that is a not a valid decimal character or + Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, then 0 is returned. + If the number represented by String overflows according to the range defined by + UINTN, then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINTN + +**/ +UINTN +EFIAPI +AsciiStrDecimalToUintn ( + IN CONST CHAR8 *String + ); + +/** + Convert a Null-terminated ASCII decimal string to a value of type + UINT64. + + This function returns a value of type UINT64 by interpreting the contents + of the ASCII string String as a decimal number. The format of the input + ASCII string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The function will + ignore the pad space, which includes spaces or tab characters, before the digits. + The running zero in the beginning of [decimal digits] will be ignored. Then, the + function stops at the first character that is a not a valid decimal character or + Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, then 0 is returned. + If the number represented by String overflows according to the range defined by + UINT64, then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +AsciiStrDecimalToUint64 ( + IN CONST CHAR8 *String + ); + +/** + Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN. + + This function returns a value of type UINTN by interpreting the contents of + the ASCII string String as a hexadecimal number. The format of the input ASCII + string String is: + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" + appears in the input string, it must be prefixed with at least one 0. The function + will ignore the pad space, which includes spaces or tab characters, before [zeros], + [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] + will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal + digit. Then, the function stops at the first character that is a not a valid + hexadecimal character or Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then + 0 is returned. + + If the number represented by String overflows according to the range defined by UINTN, + then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, + and String contains more than PcdMaximumAsciiStringLength ASCII characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINTN + +**/ +UINTN +EFIAPI +AsciiStrHexToUintn ( + IN CONST CHAR8 *String + ); + +/** + Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64. + + This function returns a value of type UINT64 by interpreting the contents of + the ASCII string String as a hexadecimal number. The format of the input ASCII + string String is: + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" + appears in the input string, it must be prefixed with at least one 0. The function + will ignore the pad space, which includes spaces or tab characters, before [zeros], + [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] + will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal + digit. Then, the function stops at the first character that is a not a valid + hexadecimal character or Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then + 0 is returned. + + If the number represented by String overflows according to the range defined by UINT64, + then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, + and String contains more than PcdMaximumAsciiStringLength ASCII characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +AsciiStrHexToUint64 ( + IN CONST CHAR8 *String + ); + +/** + Convert one Null-terminated ASCII string to a Null-terminated + Unicode string and returns the Unicode string. + + This function converts the contents of the ASCII string Source to the Unicode + string Destination, and returns Destination. The function terminates the + Unicode string Destination by appending a Null-terminator character at the end. + The caller is responsible to make sure Destination points to a buffer with size + equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes. + + If Destination is NULL, then ASSERT(). + If Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param Source Pointer to a Null-terminated ASCII string. + @param Destination Pointer to a Null-terminated Unicode string. + + @reture Destination + +**/ +CHAR16 * +EFIAPI +AsciiStrToUnicodeStr ( + IN CONST CHAR8 *Source, + OUT CHAR16 *Destination + ); + +/** + Converts an 8-bit value to an 8-bit BCD value. + + Converts the 8-bit value specified by Value to BCD. The BCD value is + returned. + + If Value >= 100, then ASSERT(). + + @param Value The 8-bit value to convert to BCD. Range 0..99. + + @return The BCD value + +**/ +UINT8 +EFIAPI +DecimalToBcd8 ( + IN UINT8 Value + ); + +/** + Converts an 8-bit BCD value to an 8-bit value. + + Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit + value is returned. + + If Value >= 0xA0, then ASSERT(). + If (Value & 0x0F) >= 0x0A, then ASSERT(). + + @param Value The 8-bit BCD value to convert to an 8-bit value. + + @return The 8-bit value is returned. + +**/ +UINT8 +EFIAPI +BcdToDecimal8 ( + IN UINT8 Value + ); + +// +// LIST_ENTRY definition +// +typedef struct _LIST_ENTRY LIST_ENTRY; + +struct _LIST_ENTRY { + LIST_ENTRY *ForwardLink; + LIST_ENTRY *BackLink; +}; + +// +// Linked List Functions and Macros +// + +/** + Initializes the head node of a doubly linked list that is declared as a + global variable in a module. + + Initializes the forward and backward links of a new linked list. After + initializing a linked list with this macro, the other linked list functions + may be used to add and remove nodes from the linked list. This macro results + in smaller executables by initializing the linked list in the data section, + instead if calling the InitializeListHead() function to perform the + equivalent operation. + + @param ListHead The head note of a list to initiailize. + +**/ +#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead} + +/** + Initializes the head node of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Initializes the forward and backward links of a new linked list. After + initializing a linked list with this function, the other linked list + functions may be used to add and remove nodes from the linked list. It is up + to the caller of this function to allocate the memory for ListHead. + + If ListHead is NULL, then ASSERT(). + + @param ListHead A pointer to the head node of a new doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInitializeListHead ( + IN LIST_ENTRY *ListHead + ); + +/** + Adds a node to the beginning of a doubly linked list, and returns the pointer + to the head node of the doubly linked list. + + Adds the node Entry at the beginning of the doubly linked list denoted by + ListHead, and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be inserted at the beginning + of a doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertHeadList ( + IN LIST_ENTRY *ListHead, + IN LIST_ENTRY *Entry + ); + +/** + Adds a node to the end of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Adds the node Entry to the end of the doubly linked list denoted by ListHead, + and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be added at the end of the + doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertTailList ( + IN LIST_ENTRY *ListHead, + IN LIST_ENTRY *Entry + ); + +/** + Retrieves the first node of a doubly linked list. + + Returns the first node of a doubly linked list. List must have been + initialized with InitializeListHead(). If List is empty, then NULL is + returned. + + If List is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + + @return The first node of a doubly linked list. + @retval NULL The list is empty. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetFirstNode ( + IN CONST LIST_ENTRY *List + ); + +/** + Retrieves the next node of a doubly linked list. + + Returns the node of a doubly linked list that follows Node. List must have + been initialized with InitializeListHead(). If List is empty, then List is + returned. + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and List contains more than + PcdMaximumLinkedListLenth nodes, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @return Pointer to the next node if one exists. Otherwise a null value which + is actually List is returned. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetNextNode ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ); + +/** + Checks to see if a doubly linked list is empty or not. + + Checks to see if the doubly linked list is empty. If the linked list contains + zero nodes, this function returns TRUE. Otherwise, it returns FALSE. + + If ListHead is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + + @retval TRUE The linked list is empty. + @retval FALSE The linked list is not empty. + +**/ +BOOLEAN +EFIAPI +GlueIsListEmpty ( + IN CONST LIST_ENTRY *ListHead + ); + +/** + Determines if a node in a doubly linked list is null. + + Returns FALSE if Node is one of the nodes in the doubly linked list specified + by List. Otherwise, TRUE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List and Node is not equal to List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is one of the nodes in the doubly linked list. + @retval FALSE Node is not one of the nodes in the doubly linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNull ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ); + +/** + Determines if a node the last node in a doubly linked list. + + Returns TRUE if Node is the last node in the doubly linked list specified by + List. Otherwise, FALSE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is the last node in the linked list. + @retval FALSE Node is not the last node in the linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNodeAtEnd ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ); + +/** + Swaps the location of two nodes in a doubly linked list, and returns the + first node after the swap. + + If FirstEntry is identical to SecondEntry, then SecondEntry is returned. + Otherwise, the location of the FirstEntry node is swapped with the location + of the SecondEntry node in a doubly linked list. SecondEntry must be in the + same double linked list as FirstEntry and that double linked list must have + been initialized with InitializeListHead(). SecondEntry is returned after the + nodes are swapped. + + If FirstEntry is NULL, then ASSERT(). + If SecondEntry is NULL, then ASSERT(). + If SecondEntry and FirstEntry are not in the same linked list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing the FirstEntry and SecondEntry nodes, including + the FirstEntry and SecondEntry nodes, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param FirstEntry A pointer to a node in a linked list. + @param SecondEntry A pointer to another node in the same linked list. + +**/ +LIST_ENTRY * +EFIAPI +GlueSwapListEntries ( + IN LIST_ENTRY *FirstEntry, + IN LIST_ENTRY *SecondEntry + ); + +/** + Removes a node from a doubly linked list, and returns the node that follows + the removed node. + + Removes the node Entry from a doubly linked list. It is up to the caller of + this function to release the memory used by this node if that is required. On + exit, the node following Entry in the doubly linked list is returned. If + Entry is the only node in the linked list, then the head node of the linked + list is returned. + + If Entry is NULL, then ASSERT(). + If Entry is the head node of an empty list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing Entry, including the Entry node, is greater than + or equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param Entry A pointer to a node in a linked list + + @return Entry + +**/ +LIST_ENTRY * +EFIAPI +GlueRemoveEntryList ( + IN CONST LIST_ENTRY *Entry + ); + +// +// Math Services +// + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled + with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +GlueLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits are + filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +GlueRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled + with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +ARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 32-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT32 +EFIAPI +LRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ); + +/** + Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits + with the low bits that were rotated. + + This function rotates the 32-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT32 +EFIAPI +RRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +LRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits + with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +RRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Returns the bit position of the lowest bit set in a 32-bit value. + + This function computes the bit position of the lowest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet32 ( + IN UINT32 Operand + ); + +/** + Returns the bit position of the lowest bit set in a 64-bit value. + + This function computes the bit position of the lowest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet64 ( + IN UINT64 Operand + ); + +/** + Returns the bit position of the highest bit set in a 32-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet32 ( + IN UINT32 Operand + ); + +/** + Returns the bit position of the highest bit set in a 64-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet64 ( + IN UINT64 Operand + ); + +/** + Returns the value of the highest bit set in a 32-bit value. Equivalent to + 1 << HighBitSet32(x). + + This function computes the value of the highest bit set in the 32-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 32-bit operand to evaluate. + + @return 1 << HighBitSet32(Operand) + @retval 0 Operand is zero. + +**/ +UINT32 +EFIAPI +GetPowerOfTwo32 ( + IN UINT32 Operand + ); + +/** + Returns the value of the highest bit set in a 64-bit value. Equivalent to + 1 << HighBitSet64(x). + + This function computes the value of the highest bit set in the 64-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 64-bit operand to evaluate. + + @return 1 << HighBitSet64(Operand) + @retval 0 Operand is zero. + +**/ +UINT64 +EFIAPI +GetPowerOfTwo64 ( + IN UINT64 Operand + ); + +/** + Switches the endianess of a 16-bit integer. + + This function swaps the bytes in a 16-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 16-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT16 +EFIAPI +SwapBytes16 ( + IN UINT16 Value + ); + +/** + Switches the endianess of a 32-bit integer. + + This function swaps the bytes in a 32-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 32-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT32 +EFIAPI +SwapBytes32 ( + IN UINT32 Value + ); + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +SwapBytes64 ( + IN UINT64 Value + ); + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +GlueMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ); + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +MultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ); + +/** + Multiples a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result. + + This function multiples the 64-bit signed value Multiplicand by the 64-bit + signed value Multiplier and generates a 64-bit signed result. This 64-bit + signed result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit signed value. + @param Multiplier A 64-bit signed value. + + @return Multiplicand * Multiplier + +**/ +INT64 +EFIAPI +MultS64x64 ( + IN INT64 Multiplicand, + IN INT64 Multiplier + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +GlueDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +ModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x32Remainder ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder OPTIONAL + ); + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates + a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x64Remainder ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder OPTIONAL + ); + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit signed value Dividend by the 64-bit signed + value Divisor and generates a 64-bit signed quotient. If Remainder is not + NULL, then the 64-bit signed remainder is returned in Remainder. This + function returns the 64-bit signed quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +EFIAPI +DivS64x64Remainder ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ); + +/** + Reads a 16-bit value from memory that may be unaligned. + + This function returns the 16-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + + @return *Uint16 + +**/ +UINT16 +EFIAPI +ReadUnaligned16 ( + IN CONST UINT16 *Uint16 + ); + +/** + Writes a 16-bit value to memory that may be unaligned. + + This function writes the 16-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + @param Value 16-bit value to write to Buffer. + + @return Value + +**/ +UINT16 +EFIAPI +WriteUnaligned16 ( + OUT UINT16 *Uint16, + IN UINT16 Value + ); + +/** + Reads a 24-bit value from memory that may be unaligned. + + This function returns the 24-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + + @return The value read. + +**/ +UINT32 +EFIAPI +ReadUnaligned24 ( + IN CONST UINT32 *Buffer + ); + +/** + Writes a 24-bit value to memory that may be unaligned. + + This function writes the 24-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + @param Value 24-bit value to write to Buffer. + + @return The value written. + +**/ +UINT32 +EFIAPI +WriteUnaligned24 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ); + +/** + Reads a 32-bit value from memory that may be unaligned. + + This function returns the 32-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + + @return *Uint32 + +**/ +UINT32 +EFIAPI +ReadUnaligned32 ( + IN CONST UINT32 *Uint32 + ); + +/** + Writes a 32-bit value to memory that may be unaligned. + + This function writes the 32-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + @param Value 32-bit value to write to Buffer. + + @return Value + +**/ +UINT32 +EFIAPI +WriteUnaligned32 ( + OUT UINT32 *Uint32, + IN UINT32 Value + ); + +/** + Reads a 64-bit value from memory that may be unaligned. + + This function returns the 64-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + + @return *Uint64 + +**/ +UINT64 +EFIAPI +ReadUnaligned64 ( + IN CONST UINT64 *Uint64 + ); + +/** + Writes a 64-bit value to memory that may be unaligned. + + This function writes the 64-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + @param Value 64-bit value to write to Buffer. + + @return Value + +**/ +UINT64 +EFIAPI +WriteUnaligned64 ( + OUT UINT64 *Uint64, + IN UINT64 Value + ); + +// +// Bit Field Functions +// + +/** + Returns a bit field from an 8-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The bit field read. + +**/ +UINT8 +EFIAPI +BitFieldRead8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an 8-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 8-bit value is + returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldWrite8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the value + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAnd8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAndThenOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Returns a bit field from a 16-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The bit field read. + +**/ +UINT16 +EFIAPI +BitFieldRead16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a 16-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 16-bit value is + returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldWrite16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAnd16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAndThenOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Returns a bit field from a 32-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read. + +**/ +UINT32 +EFIAPI +BitFieldRead32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a 32-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 32-bit value is + returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldWrite32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAnd32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAndThenOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Returns a bit field from a 64-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The bit field read. + +**/ +UINT64 +EFIAPI +BitFieldRead64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a 64-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 64-bit value is + returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldWrite64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAnd64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAndThenOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +// +// Base Library Synchronization Functions +// + +/** + Retrieves the architecture specific spin lock alignment requirements for + optimal spin lock performance. + + This function retrieves the spin lock alignment requirements for optimal + performance on a given CPU architecture. The spin lock alignment must be a + power of two and is returned by this function. If there are no alignment + requirements, then 1 must be returned. The spin lock synchronization + functions must function correctly if the spin lock size and alignment values + returned by this function are not used at all. These values are hints to the + consumers of the spin lock synchronization functions to obtain optimal spin + lock performance. + + @return The architecture specific spin lock alignment. + +**/ +UINTN +EFIAPI +GetSpinLockProperties ( + VOID + ); + +/** + Initializes a spin lock to the released state and returns the spin lock. + + This function initializes the spin lock specified by SpinLock to the released + state, and returns SpinLock. Optimal performance can be achieved by calling + GetSpinLockProperties() to determine the size and alignment requirements for + SpinLock. + + If SpinLock is NULL, then ASSERT(). + + @param SpinLock A pointer to the spin lock to initialize to the released + state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +InitializeSpinLock ( + IN SPIN_LOCK *SpinLock + ); + +/** + Waits until a spin lock can be placed in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns SpinLock. Otherwise, this function waits + indefinitely for the spin lock to be released, and then places it in the + acquired state and returns SpinLock. All state transitions of SpinLock must + be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in + PcdSpinLockTimeout microseconds, then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +AcquireSpinLock ( + IN SPIN_LOCK *SpinLock + ); + +/** + Attempts to place a spin lock in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns TRUE. Otherwise, FALSE is returned. All state + transitions of SpinLock must be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @retval TRUE SpinLock was placed in the acquired state. + @retval FALSE SpinLock could not be acquired. + +**/ +BOOLEAN +EFIAPI +AcquireSpinLockOrFail ( + IN SPIN_LOCK *SpinLock + ); + +/** + Releases a spin lock. + + This function places the spin lock specified by SpinLock in the release state + and returns SpinLock. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to release. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +ReleaseSpinLock ( + IN SPIN_LOCK *SpinLock + ); + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InterlockedIncrement ( + IN UINT32 *Value + ); + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decremented value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to decrement. + + @return The decremented value. + +**/ +UINT32 +EFIAPI +InterlockedDecrement ( + IN UINT32 *Value + ); + +/** + Performs an atomic compare exchange operation on a 32-bit unsigned integer. + + Performs an atomic compare exchange operation on the 32-bit unsigned integer + specified by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, + then Value is returned. The compare exchange operation must be performed using + MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value for the compare exchange + operation. + @param CompareValue 32-bit value used in compare operation. + @param ExchangeValue 32-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT32 +EFIAPI +InterlockedCompareExchange32 ( + IN OUT UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ); + +/** + Performs an atomic compare exchange operation on a 64-bit unsigned integer. + + Performs an atomic compare exchange operation on the 64-bit unsigned integer specified + by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and + CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. + The compare exchange operation must be performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 64-bit value for the compare exchange + operation. + @param CompareValue 64-bit value used in compare operation. + @param ExchangeValue 64-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT64 +EFIAPI +InterlockedCompareExchange64 ( + IN OUT UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ); + +/** + Performs an atomic compare exchange operation on a pointer value. + + Performs an atomic compare exchange operation on the pointer value specified + by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to + CompareValue, then Value is returned. The compare exchange operation must be + performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the pointer value for the compare exchange + operation. + @param CompareValue Pointer value used in compare operation. + @param ExchangeValue Pointer value used in exchange operation. + +**/ +VOID * +EFIAPI +InterlockedCompareExchangePointer ( + IN OUT VOID **Value, + IN VOID *CompareValue, + IN VOID *ExchangeValue + ); + +// +// Base Library Checksum Functions +// + +/** + Calculate the sum of all elements in a buffer in unit of UINT8. + During calculation, the carry bits are dropped. + + This function calculates the sum of all elements in a buffer + in unit of UINT8. The carry bits in result of addition are dropped. + The result is returned as UINT8. If Length is Zero, then Zero is + returned. + + If Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the buffer to carry out the sum operation. + @param Length The size, in bytes, of Buffer . + + @return Sum The sum of Buffer with carry bits dropped during additions. + +**/ +UINT8 +EFIAPI +CalculateSum8 ( + IN CONST UINT8 *Buffer, + IN UINTN Length + ); + + +/** + Returns the two's complement checksum of all elements in a buffer + of 8-bit values. + + This function first calculates the sum of the 8-bit values in the + buffer specified by Buffer and Length. The carry bits in the result + of addition are dropped. Then, the two's complement of the sum is + returned. If Length is 0, then 0 is returned. + + If Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + + @param Buffer Pointer to the buffer to carry out the checksum operation. + @param Length The size, in bytes, of Buffer. + + @return Checksum The 2's complement checksum of Buffer. + +**/ +UINT8 +EFIAPI +CalculateCheckSum8 ( + IN CONST UINT8 *Buffer, + IN UINTN Length + ); + +/** + Returns the sum of all elements in a buffer of 16-bit values. During + calculation, the carry bits are dropped. + + This function calculates the sum of the 16-bit values in the buffer + specified by Buffer and Length. The carry bits in result of addition are dropped. + The 16-bit result is returned. If Length is 0, then 0 is returned. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the buffer to carry out the sum operation. + @param Length The size, in bytes, of Buffer. + + @return Sum The sum of Buffer with carry bits dropped during additions. + +**/ +UINT16 +EFIAPI +CalculateSum16 ( + IN CONST UINT16 *Buffer, + IN UINTN Length + ); + +/** + Returns the two's complement checksum of all elements in a buffer of + 16-bit values. + + This function first calculates the sum of the 16-bit values in the buffer + specified by Buffer and Length. The carry bits in the result of addition + are dropped. Then, the two's complement of the sum is returned. If Length + is 0, then 0 is returned. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the buffer to carry out the checksum operation. + @param Length The size, in bytes, of Buffer. + + @return Checksum The 2's complement checksum of Buffer. + +**/ +UINT16 +EFIAPI +CalculateCheckSum16 ( + IN CONST UINT16 *Buffer, + IN UINTN Length + ); + +/** + Returns the sum of all elements in a buffer of 32-bit values. During + calculation, the carry bits are dropped. + + This function calculates the sum of the 32-bit values in the buffer + specified by Buffer and Length. The carry bits in result of addition are dropped. + The 32-bit result is returned. If Length is 0, then 0 is returned. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the buffer to carry out the sum operation. + @param Length The size, in bytes, of Buffer. + + @return Sum The sum of Buffer with carry bits dropped during additions. + +**/ +UINT32 +EFIAPI +CalculateSum32 ( + IN CONST UINT32 *Buffer, + IN UINTN Length + ); + +/** + Returns the two's complement checksum of all elements in a buffer of + 32-bit values. + + This function first calculates the sum of the 32-bit values in the buffer + specified by Buffer and Length. The carry bits in the result of addition + are dropped. Then, the two's complement of the sum is returned. If Length + is 0, then 0 is returned. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the buffer to carry out the checksum operation. + @param Length The size, in bytes, of Buffer. + + @return Checksum The 2's complement checksum of Buffer. + +**/ +UINT32 +EFIAPI +CalculateCheckSum32 ( + IN CONST UINT32 *Buffer, + IN UINTN Length + ); + +/** + Returns the sum of all elements in a buffer of 64-bit values. During + calculation, the carry bits are dropped. + + This function calculates the sum of the 64-bit values in the buffer + specified by Buffer and Length. The carry bits in result of addition are dropped. + The 64-bit result is returned. If Length is 0, then 0 is returned. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the buffer to carry out the sum operation. + @param Length The size, in bytes, of Buffer. + + @return Sum The sum of Buffer with carry bits dropped during additions. + +**/ +UINT64 +EFIAPI +CalculateSum64 ( + IN CONST UINT64 *Buffer, + IN UINTN Length + ); + +/** + Returns the two's complement checksum of all elements in a buffer of + 64-bit values. + + This function first calculates the sum of the 64-bit values in the buffer + specified by Buffer and Length. The carry bits in the result of addition + are dropped. Then, the two's complement of the sum is returned. If Length + is 0, then 0 is returned. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the buffer to carry out the checksum operation. + @param Length The size, in bytes, of Buffer. + + @return Checksum The 2's complement checksum of Buffer. + +**/ +UINT64 +EFIAPI +CalculateCheckSum64 ( + IN CONST UINT64 *Buffer, + IN UINTN Length + ); + +// +// Base Library CPU Functions +// +typedef +VOID +(EFIAPI *SWITCH_STACK_ENTRY_POINT) ( + IN VOID *Context1, OPTIONAL + IN VOID *Context2 OPTIONAL + ); + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ); + +/** + Saves the current CPU context that can be restored with a call to LongJump() + and returns 0. + + Saves the current CPU context in the buffer specified by JumpBuffer and + returns 0. The initial call to SetJump() must always return 0. Subsequent + calls to LongJump() cause a non-zero value to be returned by SetJump(). + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + + @retval 0 Indicates a return from SetJump(). + +**/ +UINTN +EFIAPI +SetJump ( + OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ); + +/** + Restores the CPU context that was saved with SetJump(). + + Restores the CPU context from the buffer specified by JumpBuffer. This + function never returns to the caller. Instead is resumes execution based on + the state of JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + If Value is 0, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + @param Value The value to return when the SetJump() context is + restored and must be non-zero. + +**/ +VOID +EFIAPI +LongJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, + IN UINTN Value + ); + +/** + Enables CPU interrupts. + + Enables CPU interrupts. + +**/ +VOID +EFIAPI +EnableInterrupts ( + VOID + ); + +/** + Disables CPU interrupts. + + Disables CPU interrupts. + +**/ +VOID +EFIAPI +DisableInterrupts ( + VOID + ); + +/** + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + @retval TRUE CPU interrupts were enabled on entry to this call. + @retval FALSE CPU interrupts were disabled on entry to this call. + +**/ +BOOLEAN +EFIAPI +SaveAndDisableInterrupts ( + VOID + ); + +/** + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + +**/ +VOID +EFIAPI +EnableDisableInterrupts ( + VOID + ); + +/** + Retrieves the current CPU interrupt state. + + Retrieves the current CPU interrupt state. Returns TRUE is interrupts are + currently enabled. Otherwise returns FALSE. + + @retval TRUE CPU interrupts are enabled. + @retval FALSE CPU interrupts are disabled. + +**/ +BOOLEAN +EFIAPI +GlueGetInterruptState ( + VOID + ); + +/** + Set the current CPU interrupt state. + + Sets the current CPU interrupt state to the state specified by + InterruptState. If InterruptState is TRUE, then interrupts are enabled. If + InterruptState is FALSE, then interrupts are disabled. InterruptState is + returned. + + @param InterruptState TRUE if interrupts should enabled. FALSE if + interrupts should be disabled. + + @return InterruptState + +**/ +BOOLEAN +EFIAPI +SetInterruptState ( + IN BOOLEAN InterruptState + ); + +/** + Places the CPU in a sleep state until an interrupt is received. + + Places the CPU in a sleep state until an interrupt is received. If interrupts + are disabled prior to calling this function, then the CPU will be placed in a + sleep state indefinitely. + +**/ +VOID +EFIAPI +CpuSleep ( + VOID + ); + +/** + Requests CPU to pause for a short period of time. + + Requests CPU to pause for a short period of time. Typically used in MP + systems to prevent memory starvation while waiting for a spin lock. + +**/ +VOID +EFIAPI +CpuPause ( + VOID + ); + +/** + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + +**/ +VOID +EFIAPI +CpuFlushTlb ( + VOID + ); + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +SwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Generates a breakpoint on the CPU. + + Generates a breakpoint on the CPU. The breakpoint must be implemented such + that code can resume normal execution after the breakpoint. + +**/ +VOID +EFIAPI +CpuBreakpoint ( + VOID + ); + +/** + Executes an infinite loop. + + Forces the CPU to execute an infinite loop. A debugger may be used to skip + past the loop and the code that follows the loop must execute properly. This + implies that the infinite loop must not cause the code that follow it to be + optimized away. + +**/ +VOID +EFIAPI +CpuDeadLoop ( + VOID + ); + +// +// IA32 and X64 Specific Functions +// +// +// Byte packed structure for 16-bit Real Mode EFLAGS +// +typedef union { + struct { + UINT32 CF:1; // Carry Flag + UINT32 Reserved_0:1; // Reserved + UINT32 PF:1; // Parity Flag + UINT32 Reserved_1:1; // Reserved + UINT32 AF:1; // Auxiliary Carry Flag + UINT32 Reserved_2:1; // Reserved + UINT32 ZF:1; // Zero Flag + UINT32 SF:1; // Sign Flag + UINT32 TF:1; // Trap Flag + UINT32 IF:1; // Interrupt Enable Flag + UINT32 DF:1; // Direction Flag + UINT32 OF:1; // Overflow Flag + UINT32 IOPL:2; // I/O Privilege Level + UINT32 NT:1; // Nested Task + UINT32 Reserved_3:1; // Reserved + } Bits; + UINT16 Uint16; +} IA32_FLAGS16; + +// +// Byte packed structure for EFLAGS/RFLAGS +// 32-bits on IA-32 +// 64-bits on X64. The upper 32-bits on X64 are reserved +// +typedef union { + struct { + UINT32 CF:1; // Carry Flag + UINT32 Reserved_0:1; // Reserved + UINT32 PF:1; // Parity Flag + UINT32 Reserved_1:1; // Reserved + UINT32 AF:1; // Auxiliary Carry Flag + UINT32 Reserved_2:1; // Reserved + UINT32 ZF:1; // Zero Flag + UINT32 SF:1; // Sign Flag + UINT32 TF:1; // Trap Flag + UINT32 IF:1; // Interrupt Enable Flag + UINT32 DF:1; // Direction Flag + UINT32 OF:1; // Overflow Flag + UINT32 IOPL:2; // I/O Privilege Level + UINT32 NT:1; // Nested Task + UINT32 Reserved_3:1; // Reserved + UINT32 RF:1; // Resume Flag + UINT32 VM:1; // Virtual 8086 Mode + UINT32 AC:1; // Alignment Check + UINT32 VIF:1; // Virtual Interrupt Flag + UINT32 VIP:1; // Virtual Interrupt Pending + UINT32 ID:1; // ID Flag + UINT32 Reserved_4:10; // Reserved + } Bits; + UINTN UintN; +} IA32_EFLAGS32; + +// +// Byte packed structure for Control Register 0 (CR0) +// 32-bits on IA-32 +// 64-bits on X64. The upper 32-bits on X64 are reserved +// +typedef union { + struct { + UINT32 PE:1; // Protection Enable + UINT32 MP:1; // Monitor Coprocessor + UINT32 EM:1; // Emulation + UINT32 TS:1; // Task Switched + UINT32 ET:1; // Extension Type + UINT32 NE:1; // Numeric Error + UINT32 Reserved_0:10; // Reserved + UINT32 WP:1; // Write Protect + UINT32 Reserved_1:1; // Reserved + UINT32 AM:1; // Alignment Mask + UINT32 Reserved_2:10; // Reserved + UINT32 NW:1; // Mot Write-through + UINT32 CD:1; // Cache Disable + UINT32 PG:1; // Paging + } Bits; + UINTN UintN; +} IA32_CR0; + +// +// Byte packed structure for Control Register 4 (CR4) +// 32-bits on IA-32 +// 64-bits on X64. The upper 32-bits on X64 are reserved +// +typedef union { + struct { + UINT32 VME:1; // Virtual-8086 Mode Extensions + UINT32 PVI:1; // Protected-Mode Virtual Interrupts + UINT32 TSD:1; // Time Stamp Disable + UINT32 DE:1; // Debugging Extensions + UINT32 PSE:1; // Page Size Extensions + UINT32 PAE:1; // Physical Address Extension + UINT32 MCE:1; // Machine Check Enable + UINT32 PGE:1; // Page Global Enable + UINT32 PCE:1; // Performance Monitoring Counter + // Enable + UINT32 OSFXSR:1; // Operating System Support for + // FXSAVE and FXRSTOR instructions + UINT32 OSXMMEXCPT:1; // Operating System Support for + // Unmasked SIMD Floating Point + // Exceptions + UINT32 Reserved_0:2; // Reserved + UINT32 VMXE:1; // VMX Enable + UINT32 Reserved_1:18; // Reseved + } Bits; + UINTN UintN; +} IA32_CR4; + +// +// Byte packed structure for an IDTR, GDTR, LDTR descriptor +/// @bug How to make this structure byte-packed in a compiler independent way? +// +#pragma pack (1) +typedef struct { + UINT16 Limit; + UINTN Base; +} IA32_DESCRIPTOR; +#pragma pack () + +#define IA32_IDT_GATE_TYPE_TASK 0x85 +#define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86 +#define IA32_IDT_GATE_TYPE_TRAP_16 0x87 +#define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E +#define IA32_IDT_GATE_TYPE_TRAP_32 0x8F + +// +// Byte packed structure for an Interrupt Gate Descriptor +// +typedef union { + struct { + UINT32 OffsetLow:16; // Offset bits 15..0 + UINT32 Selector:16; // Selector + UINT32 Reserved_0:8; // Reserved + UINT32 GateType:8; // Gate Type. See #defines above + UINT32 OffsetHigh:16; // Offset bits 31..16 + } Bits; + UINT64 Uint64; +} IA32_IDT_GATE_DESCRIPTOR; + +// +// Byte packed structure for an FP/SSE/SSE2 context +// +typedef struct { + UINT8 Buffer[512]; +} IA32_FX_BUFFER; + +// +// Structures for the 16-bit real mode thunks +// +typedef struct { + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 Reserved3; + UINT32 Reserved4; + UINT8 BL; + UINT8 BH; + UINT16 Reserved5; + UINT8 DL; + UINT8 DH; + UINT16 Reserved6; + UINT8 CL; + UINT8 CH; + UINT16 Reserved7; + UINT8 AL; + UINT8 AH; + UINT16 Reserved8; +} IA32_BYTE_REGS; + +typedef struct { + UINT16 DI; + UINT16 Reserved1; + UINT16 SI; + UINT16 Reserved2; + UINT16 BP; + UINT16 Reserved3; + UINT16 SP; + UINT16 Reserved4; + UINT16 BX; + UINT16 Reserved5; + UINT16 DX; + UINT16 Reserved6; + UINT16 CX; + UINT16 Reserved7; + UINT16 AX; + UINT16 Reserved8; +} IA32_WORD_REGS; + +typedef struct { + UINT32 EDI; + UINT32 ESI; + UINT32 EBP; + UINT32 ESP; + UINT32 EBX; + UINT32 EDX; + UINT32 ECX; + UINT32 EAX; + UINT16 DS; + UINT16 ES; + UINT16 FS; + UINT16 GS; + IA32_EFLAGS32 EFLAGS; + UINT32 Eip; + UINT16 CS; + UINT16 SS; +} IA32_DWORD_REGS; + +typedef union { + IA32_DWORD_REGS E; + IA32_WORD_REGS X; + IA32_BYTE_REGS H; +} IA32_REGISTER_SET; + +// +// Byte packed structure for an 16-bit real mode thunks +// +typedef struct { + IA32_REGISTER_SET *RealModeState; + VOID *RealModeBuffer; + UINT32 RealModeBufferSize; + UINT32 ThunkAttributes; +} THUNK_CONTEXT; + +#define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001 +#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002 +#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004 + +/** + Retrieves CPUID information. + + Executes the CPUID instruction with EAX set to the value specified by Index. + This function always returns Index. + If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. + If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. + If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. + If Edx is not NULL, then the value of EDX after CPUID is returned in Edx. + This function is only available on IA-32 and X64. + + @param Index The 32-bit value to load into EAX prior to invoking the CPUID + instruction. + @param Eax Pointer to the 32-bit EAX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + @param Ebx Pointer to the 32-bit EBX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + @param Ecx Pointer to the 32-bit ECX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + @param Edx Pointer to the 32-bit EDX value returned by the CPUID + instruction. This is an optional parameter that may be NULL. + + @return Index + +**/ +UINT32 +EFIAPI +AsmCpuid ( + IN UINT32 Index, + OUT UINT32 *Eax, OPTIONAL + OUT UINT32 *Ebx, OPTIONAL + OUT UINT32 *Ecx, OPTIONAL + OUT UINT32 *Edx OPTIONAL + ); + +/** + Retrieves CPUID information using an extended leaf identifier. + + Executes the CPUID instruction with EAX set to the value specified by Index + and ECX set to the value specified by SubIndex. This function always returns + Index. This function is only available on IA-32 and x64. + + If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. + If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. + If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. + If Edx is not NULL, then the value of EDX after CPUID is returned in Edx. + + @param Index The 32-bit value to load into EAX prior to invoking the + CPUID instruction. + @param SubIndex The 32-bit value to load into ECX prior to invoking the + CPUID instruction. + @param Eax Pointer to the 32-bit EAX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + @param Ebx Pointer to the 32-bit EBX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + @param Ecx Pointer to the 32-bit ECX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + @param Edx Pointer to the 32-bit EDX value returned by the CPUID + instruction. This is an optional parameter that may be + NULL. + + @return Index + +**/ +UINT32 +EFIAPI +AsmCpuidEx ( + IN UINT32 Index, + IN UINT32 SubIndex, + OUT UINT32 *Eax, OPTIONAL + OUT UINT32 *Ebx, OPTIONAL + OUT UINT32 *Ecx, OPTIONAL + OUT UINT32 *Edx OPTIONAL + ); + +/** + Returns the lower 32-bits of a Machine Specific Register(MSR). + + Reads and returns the lower 32-bits of the MSR specified by Index. + No parameter checking is performed on Index, and some Index values may cause + CPU exceptions. The caller must either guarantee that Index is valid, or the + caller must set up exception handlers to catch the exceptions. This function + is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to read. + + @return The lower 32 bits of the MSR identified by Index. + +**/ +UINT32 +EFIAPI +AsmReadMsr32 ( + IN UINT32 Index + ); + +/** + Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR). + + Writes the 32-bit value specified by Value to the MSR specified by Index. The + upper 32-bits of the MSR write are set to zero. The 32-bit value written to + the MSR is returned. No parameter checking is performed on Index or Value, + and some of these may cause CPU exceptions. The caller must either guarantee + that Index and Value are valid, or the caller must establish proper exception + handlers. This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param Value The 32-bit value to write to the MSR. + + @return Value + +**/ +UINT32 +EFIAPI +AsmWriteMsr32 ( + IN UINT32 Index, + IN UINT32 Value + ); + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and + writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the lower 32-bits of the read result and the value specified by + OrData, and writes the result to the 64-bit MSR specified by Index. The lower + 32-bits of the value written to the MSR is returned. No parameter checking is + performed on Index or OrData, and some of these may cause CPU exceptions. The + caller must either guarantee that Index and OrData are valid, or the caller + must establish proper exception handlers. This function is only available on + IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrOr32 ( + IN UINT32 Index, + IN UINT32 OrData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes + the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData, and + writes the result to the 64-bit MSR specified by Index. The lower 32-bits of + the value written to the MSR is returned. No parameter checking is performed + on Index or AndData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index and AndData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAnd32 ( + IN UINT32 Index, + IN UINT32 AndData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR + on the lower 32-bits, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData + preserving the upper 32-bits, performs a bitwise inclusive OR between the + result of the AND operation and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Address. The lower 32-bits of the value + written to the MSR is returned. No parameter checking is performed on Index, + AndData, or OrData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index, AndData, and OrData are valid, or the + caller must establish proper exception handlers. This function is only + available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAndThenOr32 ( + IN UINT32 Index, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of an MSR. + + Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. The caller must either guarantee that Index is valid, or the caller + must set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read from the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldRead32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination MSR are preserved. The lower 32-bits of the MSR written is + returned. Extra left bits in Value are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldWrite32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The lower 32-bits of the value + written to the MSR are returned. Extra left bits in OrData are stripped. The + caller must either guarantee that Index and the data written is valid, or + the caller must set up exception handlers to catch the exceptions. This + function is only available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The lower 32-bits of the value written to the + MSR are returned. Extra left bits in AndData are stripped. The caller must + either guarantee that Index and the data written is valid, or the caller must + set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAnd32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a + bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + lower 32-bits of the value written to the MSR are returned. Extra left bits + in both AndData and OrData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAndThenOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Returns a 64-bit Machine Specific Register(MSR). + + Reads and returns the 64-bit MSR specified by Index. No parameter checking is + performed on Index, and some Index values may cause CPU exceptions. The + caller must either guarantee that Index is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + @param Index The 32-bit MSR index to read. + + @return The value of the MSR identified by Index. + +**/ +UINT64 +EFIAPI +AsmReadMsr64 ( + IN UINT32 Index + ); + +/** + Writes a 64-bit value to a Machine Specific Register(MSR), and returns the + value. + + Writes the 64-bit value specified by Value to the MSR specified by Index. The + 64-bit value written to the MSR is returned. No parameter checking is + performed on Index or Value, and some of these may cause CPU exceptions. The + caller must either guarantee that Index and Value are valid, or the caller + must establish proper exception handlers. This function is only available on + IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param Value The 64-bit value to write to the MSR. + + @return Value + +**/ +UINT64 +EFIAPI +AsmWriteMsr64 ( + IN UINT32 Index, + IN UINT64 Value + ); + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result + back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. No parameter checking is performed on Index or OrData, and some of + these may cause CPU exceptions. The caller must either guarantee that Index + and OrData are valid, or the caller must establish proper exception handlers. + This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrOr64 ( + IN UINT32 Index, + IN UINT64 OrData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by OrData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. No + parameter checking is performed on Index or OrData, and some of these may + cause CPU exceptions. The caller must either guarantee that Index and OrData + are valid, or the caller must establish proper exception handlers. This + function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAnd64 ( + IN UINT32 Index, + IN UINT64 AndData + ); + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive + OR, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between read + result and the value specified by AndData, performs a bitwise inclusive OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit MSR specified by Index. The value written + to the MSR is returned. No parameter checking is performed on Index, AndData, + or OrData, and some of these may cause CPU exceptions. The caller must either + guarantee that Index, AndData, and OrData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAndThenOr64 ( + IN UINT32 Index, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads a bit field of an MSR. + + Reads the bit field in the 64-bit MSR. The bit field is specified by the + StartBit and the EndBit. The value of the bit field is returned. The caller + must either guarantee that Index is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read from the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldRead64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in a 64-bit MSR. The bit field is specified by + the StartBit and the EndBit. All other bits in the destination MSR are + preserved. The MSR written is returned. Extra left bits in Value are + stripped. The caller must either guarantee that Index and the data written is + valid, or the caller must set up exception handlers to catch the exceptions. + This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldWrite64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and + writes the result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. Extra left bits in OrData are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. + Extra left bits in AndData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAnd64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by + a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + value written to the MSR is returned. Extra left bits in both AndData and + OrData are stripped. The caller must either guarantee that Index and the data + written is valid, or the caller must set up exception handlers to catch the + exceptions. This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAndThenOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads the current value of the EFLAGS register. + + Reads and returns the current value of the EFLAGS register. This function is + only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a + 64-bit value on X64. + + @return EFLAGS on IA-32 or RFLAGS on X64. + +**/ +UINTN +EFIAPI +AsmReadEflags ( + VOID + ); + +/** + Reads the current value of the Control Register 0 (CR0). + + Reads and returns the current value of CR0. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 0 (CR0). + +**/ +UINTN +EFIAPI +AsmReadCr0 ( + VOID + ); + +/** + Reads the current value of the Control Register 2 (CR2). + + Reads and returns the current value of CR2. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 2 (CR2). + +**/ +UINTN +EFIAPI +AsmReadCr2 ( + VOID + ); + +/** + Reads the current value of the Control Register 3 (CR3). + + Reads and returns the current value of CR3. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 3 (CR3). + +**/ +UINTN +EFIAPI +AsmReadCr3 ( + VOID + ); + +/** + Reads the current value of the Control Register 4 (CR4). + + Reads and returns the current value of CR4. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of the Control Register 4 (CR4). + +**/ +UINTN +EFIAPI +AsmReadCr4 ( + VOID + ); + +/** + Writes a value to Control Register 0 (CR0). + + Writes and returns a new value to CR0. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr0 The value to write to CR0. + + @return The value written to CR0. + +**/ +UINTN +EFIAPI +AsmWriteCr0 ( + UINTN Cr0 + ); + +/** + Writes a value to Control Register 2 (CR2). + + Writes and returns a new value to CR2. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr2 The value to write to CR2. + + @return The value written to CR2. + +**/ +UINTN +EFIAPI +AsmWriteCr2 ( + UINTN Cr2 + ); + +/** + Writes a value to Control Register 3 (CR3). + + Writes and returns a new value to CR3. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr3 The value to write to CR3. + + @return The value written to CR3. + +**/ +UINTN +EFIAPI +AsmWriteCr3 ( + UINTN Cr3 + ); + +/** + Writes a value to Control Register 4 (CR4). + + Writes and returns a new value to CR4. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Cr4 The value to write to CR4. + + @return The value written to CR4. + +**/ +UINTN +EFIAPI +AsmWriteCr4 ( + UINTN Cr4 + ); + +/** + Reads the current value of Debug Register 0 (DR0). + + Reads and returns the current value of DR0. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 0 (DR0). + +**/ +UINTN +EFIAPI +AsmReadDr0 ( + VOID + ); + +/** + Reads the current value of Debug Register 1 (DR1). + + Reads and returns the current value of DR1. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 1 (DR1). + +**/ +UINTN +EFIAPI +AsmReadDr1 ( + VOID + ); + +/** + Reads the current value of Debug Register 2 (DR2). + + Reads and returns the current value of DR2. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 2 (DR2). + +**/ +UINTN +EFIAPI +AsmReadDr2 ( + VOID + ); + +/** + Reads the current value of Debug Register 3 (DR3). + + Reads and returns the current value of DR3. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 3 (DR3). + +**/ +UINTN +EFIAPI +AsmReadDr3 ( + VOID + ); + +/** + Reads the current value of Debug Register 4 (DR4). + + Reads and returns the current value of DR4. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 4 (DR4). + +**/ +UINTN +EFIAPI +AsmReadDr4 ( + VOID + ); + +/** + Reads the current value of Debug Register 5 (DR5). + + Reads and returns the current value of DR5. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 5 (DR5). + +**/ +UINTN +EFIAPI +AsmReadDr5 ( + VOID + ); + +/** + Reads the current value of Debug Register 6 (DR6). + + Reads and returns the current value of DR6. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 6 (DR6). + +**/ +UINTN +EFIAPI +AsmReadDr6 ( + VOID + ); + +/** + Reads the current value of Debug Register 7 (DR7). + + Reads and returns the current value of DR7. This function is only available + on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on + X64. + + @return The value of Debug Register 7 (DR7). + +**/ +UINTN +EFIAPI +AsmReadDr7 ( + VOID + ); + +/** + Writes a value to Debug Register 0 (DR0). + + Writes and returns a new value to DR0. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr0 The value to write to Dr0. + + @return The value written to Debug Register 0 (DR0). + +**/ +UINTN +EFIAPI +AsmWriteDr0 ( + UINTN Dr0 + ); + +/** + Writes a value to Debug Register 1 (DR1). + + Writes and returns a new value to DR1. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr1 The value to write to Dr1. + + @return The value written to Debug Register 1 (DR1). + +**/ +UINTN +EFIAPI +AsmWriteDr1 ( + UINTN Dr1 + ); + +/** + Writes a value to Debug Register 2 (DR2). + + Writes and returns a new value to DR2. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr2 The value to write to Dr2. + + @return The value written to Debug Register 2 (DR2). + +**/ +UINTN +EFIAPI +AsmWriteDr2 ( + UINTN Dr2 + ); + +/** + Writes a value to Debug Register 3 (DR3). + + Writes and returns a new value to DR3. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr3 The value to write to Dr3. + + @return The value written to Debug Register 3 (DR3). + +**/ +UINTN +EFIAPI +AsmWriteDr3 ( + UINTN Dr3 + ); + +/** + Writes a value to Debug Register 4 (DR4). + + Writes and returns a new value to DR4. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr4 The value to write to Dr4. + + @return The value written to Debug Register 4 (DR4). + +**/ +UINTN +EFIAPI +AsmWriteDr4 ( + UINTN Dr4 + ); + +/** + Writes a value to Debug Register 5 (DR5). + + Writes and returns a new value to DR5. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr5 The value to write to Dr5. + + @return The value written to Debug Register 5 (DR5). + +**/ +UINTN +EFIAPI +AsmWriteDr5 ( + UINTN Dr5 + ); + +/** + Writes a value to Debug Register 6 (DR6). + + Writes and returns a new value to DR6. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr6 The value to write to Dr6. + + @return The value written to Debug Register 6 (DR6). + +**/ +UINTN +EFIAPI +AsmWriteDr6 ( + UINTN Dr6 + ); + +/** + Writes a value to Debug Register 7 (DR7). + + Writes and returns a new value to DR7. This function is only available on + IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. + + @param Dr7 The value to write to Dr7. + + @return The value written to Debug Register 7 (DR7). + +**/ +UINTN +EFIAPI +AsmWriteDr7 ( + UINTN Dr7 + ); + +/** + Reads the current value of Code Segment Register (CS). + + Reads and returns the current value of CS. This function is only available on + IA-32 and X64. + + @return The current value of CS. + +**/ +UINT16 +EFIAPI +AsmReadCs ( + VOID + ); + +/** + Reads the current value of Data Segment Register (DS). + + Reads and returns the current value of DS. This function is only available on + IA-32 and X64. + + @return The current value of DS. + +**/ +UINT16 +EFIAPI +AsmReadDs ( + VOID + ); + +/** + Reads the current value of Extra Segment Register (ES). + + Reads and returns the current value of ES. This function is only available on + IA-32 and X64. + + @return The current value of ES. + +**/ +UINT16 +EFIAPI +AsmReadEs ( + VOID + ); + +/** + Reads the current value of FS Data Segment Register (FS). + + Reads and returns the current value of FS. This function is only available on + IA-32 and X64. + + @return The current value of FS. + +**/ +UINT16 +EFIAPI +AsmReadFs ( + VOID + ); + +/** + Reads the current value of GS Data Segment Register (GS). + + Reads and returns the current value of GS. This function is only available on + IA-32 and X64. + + @return The current value of GS. + +**/ +UINT16 +EFIAPI +AsmReadGs ( + VOID + ); + +/** + Reads the current value of Stack Segment Register (SS). + + Reads and returns the current value of SS. This function is only available on + IA-32 and X64. + + @return The current value of SS. + +**/ +UINT16 +EFIAPI +AsmReadSs ( + VOID + ); + +/** + Reads the current value of Task Register (TR). + + Reads and returns the current value of TR. This function is only available on + IA-32 and X64. + + @return The current value of TR. + +**/ +UINT16 +EFIAPI +AsmReadTr ( + VOID + ); + +/** + Reads the current Global Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current GDTR descriptor and returns it in Gdtr. This + function is only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadGdtr ( + OUT IA32_DESCRIPTOR *Gdtr + ); + +/** + Writes the current Global Descriptor Table Register (GDTR) descriptor. + + Writes and the current GDTR descriptor specified by Gdtr. This function is + only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteGdtr ( + IN CONST IA32_DESCRIPTOR *Gdtr + ); + +/** + Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current IDTR descriptor and returns it in Idtr. This + function is only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadIdtr ( + OUT IA32_DESCRIPTOR *Idtr + ); + +/** + Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Writes the current IDTR descriptor and returns it in Idtr. This function is + only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteIdtr ( + IN CONST IA32_DESCRIPTOR *Idtr + ); + +/** + Reads the current Local Descriptor Table Register(LDTR) selector. + + Reads and returns the current 16-bit LDTR descriptor value. This function is + only available on IA-32 and X64. + + @return The current selector of LDT. + +**/ +UINT16 +EFIAPI +AsmReadLdtr ( + VOID + ); + +/** + Writes the current Local Descriptor Table Register (GDTR) selector. + + Writes and the current LDTR descriptor specified by Ldtr. This function is + only available on IA-32 and X64. + + @param Ldtr 16-bit LDTR selector value. + +**/ +VOID +EFIAPI +AsmWriteLdtr ( + IN UINT16 Ldtr + ); + +/** + Save the current floating point/SSE/SSE2 context to a buffer. + + Saves the current floating point/SSE/SSE2 state to the buffer specified by + Buffer. Buffer must be aligned on a 16-byte boundary. This function is only + available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxSave ( + OUT IA32_FX_BUFFER *Buffer + ); + +/** + Restores the current floating point/SSE/SSE2 context from a buffer. + + Restores the current floating point/SSE/SSE2 state from the buffer specified + by Buffer. Buffer must be aligned on a 16-byte boundary. This function is + only available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + If Buffer was not saved with AsmFxSave(), then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ); + +/** + Reads the current value of 64-bit MMX Register #0 (MM0). + + Reads and returns the current value of MM0. This function is only available + on IA-32 and X64. + + @return The current value of MM0. + +**/ +UINT64 +EFIAPI +AsmReadMm0 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #1 (MM1). + + Reads and returns the current value of MM1. This function is only available + on IA-32 and X64. + + @return The current value of MM1. + +**/ +UINT64 +EFIAPI +AsmReadMm1 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #2 (MM2). + + Reads and returns the current value of MM2. This function is only available + on IA-32 and X64. + + @return The current value of MM2. + +**/ +UINT64 +EFIAPI +AsmReadMm2 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #3 (MM3). + + Reads and returns the current value of MM3. This function is only available + on IA-32 and X64. + + @return The current value of MM3. + +**/ +UINT64 +EFIAPI +AsmReadMm3 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #4 (MM4). + + Reads and returns the current value of MM4. This function is only available + on IA-32 and X64. + + @return The current value of MM4. + +**/ +UINT64 +EFIAPI +AsmReadMm4 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #5 (MM5). + + Reads and returns the current value of MM5. This function is only available + on IA-32 and X64. + + @return The current value of MM5. + +**/ +UINT64 +EFIAPI +AsmReadMm5 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #6 (MM6). + + Reads and returns the current value of MM6. This function is only available + on IA-32 and X64. + + @return The current value of MM6. + +**/ +UINT64 +EFIAPI +AsmReadMm6 ( + VOID + ); + +/** + Reads the current value of 64-bit MMX Register #7 (MM7). + + Reads and returns the current value of MM7. This function is only available + on IA-32 and X64. + + @return The current value of MM7. + +**/ +UINT64 +EFIAPI +AsmReadMm7 ( + VOID + ); + +/** + Writes the current value of 64-bit MMX Register #0 (MM0). + + Writes the current value of MM0. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM0. + +**/ +VOID +EFIAPI +AsmWriteMm0 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #1 (MM1). + + Writes the current value of MM1. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM1. + +**/ +VOID +EFIAPI +AsmWriteMm1 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #2 (MM2). + + Writes the current value of MM2. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM2. + +**/ +VOID +EFIAPI +AsmWriteMm2 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #3 (MM3). + + Writes the current value of MM3. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM3. + +**/ +VOID +EFIAPI +AsmWriteMm3 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #4 (MM4). + + Writes the current value of MM4. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM4. + +**/ +VOID +EFIAPI +AsmWriteMm4 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #5 (MM5). + + Writes the current value of MM5. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM5. + +**/ +VOID +EFIAPI +AsmWriteMm5 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #6 (MM6). + + Writes the current value of MM6. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM6. + +**/ +VOID +EFIAPI +AsmWriteMm6 ( + IN UINT64 Value + ); + +/** + Writes the current value of 64-bit MMX Register #7 (MM7). + + Writes the current value of MM7. This function is only available on IA32 and + X64. + + @param Value The 64-bit value to write to MM7. + +**/ +VOID +EFIAPI +AsmWriteMm7 ( + IN UINT64 Value + ); + +/** + Reads the current value of Time Stamp Counter (TSC). + + Reads and returns the current value of TSC. This function is only available + on IA-32 and X64. + + @return The current value of TSC + +**/ +UINT64 +EFIAPI +AsmReadTsc ( + VOID + ); + +/** + Reads the current value of a Performance Counter (PMC). + + Reads and returns the current value of performance counter specified by + Index. This function is only available on IA-32 and X64. + + @param Index The 32-bit Performance Counter index to read. + + @return The value of the PMC specified by Index. + +**/ +UINT64 +EFIAPI +AsmReadPmc ( + IN UINT32 Index + ); + +/** + Sets up a monitor buffer that is used by AsmMwait(). + + Executes a MONITOR instruction with the register state specified by Eax, Ecx + and Edx. Returns Eax. This function is only available on IA-32 and X64. + + @param Eax The value to load into EAX or RAX before executing the MONITOR + instruction. + @param Ecx The value to load into ECX or RCX before executing the MONITOR + instruction. + @param Edx The value to load into EDX or RDX before executing the MONITOR + instruction. + + @return Eax + +**/ +UINTN +EFIAPI +AsmMonitor ( + IN UINTN Eax, + IN UINTN Ecx, + IN UINTN Edx + ); + +/** + Executes an MWAIT instruction. + + Executes an MWAIT instruction with the register state specified by Eax and + Ecx. Returns Eax. This function is only available on IA-32 and X64. + + @param Eax The value to load into EAX or RAX before executing the MONITOR + instruction. + @param Ecx The value to load into ECX or RCX before executing the MONITOR + instruction. + + @return Eax + +**/ +UINTN +EFIAPI +AsmMwait ( + IN UINTN Eax, + IN UINTN Ecx + ); + +/** + Executes a WBINVD instruction. + + Executes a WBINVD instruction. This function is only available on IA-32 and + X64. + +**/ +VOID +EFIAPI +AsmWbinvd ( + VOID + ); + +/** + Executes a INVD instruction. + + Executes a INVD instruction. This function is only available on IA-32 and + X64. + +**/ +VOID +EFIAPI +AsmInvd ( + VOID + ); + +/** + Flushes a cache line from all the instruction and data caches within the + coherency domain of the CPU. + + Flushed the cache line specified by LinearAddress, and returns LinearAddress. + This function is only available on IA-32 and X64. + + @param LinearAddress The address of the cache line to flush. If the CPU is + in a physical addressing mode, then LinearAddress is a + physical address. If the CPU is in a virtual + addressing mode, then LinearAddress is a virtual + address. + + @return LinearAddress +**/ +VOID * +EFIAPI +AsmFlushCacheLine ( + IN VOID *LinearAddress + ); + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + If the current execution mode is not 32-bit paged mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Enables the 64-bit paging mode on the CPU. + + Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode with flat + descriptors. This function is only available on IA-32. After the 64-bit + paging mode is enabled, control is transferred to the function specified by + EntryPoint using the new stack specified by NewStack and passing in the + parameters specified by Context1 and Context2. Context1 and Context2 are + optional and may be 0. The function EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode with flat + descriptors, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for long mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is enabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is enabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is enabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging64 ( + IN UINT16 CodeSelector, + IN UINT64 EntryPoint, + IN UINT64 Context1, OPTIONAL + IN UINT64 Context2, OPTIONAL + IN UINT64 NewStack + ); + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + If the current execution mode is not 64-bit paged mode, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging64 ( + IN UINT16 CodeSelector, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ); + +// +// 16-bit thunking services +// + +/** + Retrieves the properties for 16-bit thunk functions. + + Computes the size of the buffer and stack below 1MB required to use the + AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This + buffer size is returned in RealModeBufferSize, and the stack size is returned + in ExtraStackSize. If parameters are passed to the 16-bit real mode code, + then the actual minimum stack size is ExtraStackSize plus the maximum number + of bytes that need to be passed to the 16-bit real mode code. + + If RealModeBufferSize is NULL, then ASSERT(). + If ExtraStackSize is NULL, then ASSERT(). + + @param RealModeBufferSize A pointer to the size of the buffer below 1MB + required to use the 16-bit thunk functions. + @param ExtraStackSize A pointer to the extra size of stack below 1MB + that the 16-bit thunk functions require for + temporary storage in the transition to and from + 16-bit real mode. + +**/ +VOID +EFIAPI +AsmGetThunk16Properties ( + OUT UINT32 *RealModeBufferSize, + OUT UINT32 *ExtraStackSize + ); + +/** + Prepares all structures a code required to use AsmThunk16(). + + Prepares all structures and code required to use AsmThunk16(). + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareThunk16 ( + OUT THUNK_CONTEXT *ThunkContext + ); + +/** + Transfers control to a 16-bit real mode entry point and returns the results. + + Transfers control to a 16-bit real mode entry point and returns the results. + AsmPrepareThunk16() must be called with ThunkContext before this function is + used. + + If ThunkContext is NULL, then ASSERT(). + If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ); + +/** + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. + + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. If the + caller only need to perform a single 16-bit real mode thunk, then this + service should be used. If the caller intends to make more than one 16-bit + real mode thunk, then it is more efficient if AsmPrepareThunk16() is called + once and AsmThunk16() can be called for each 16-bit real mode thunk. + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareAndThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ); + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + @param NewBsp A pointer to the new memory location for RSE backing + store. + +**/ +VOID +EFIAPI +AsmSwitchStackAndBackingStore ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack, + IN VOID *NewBsp + ); + +typedef struct { + UINT64 Status; + UINT64 r9; + UINT64 r10; + UINT64 r11; +} PAL_PROC_RETURN; + +// +// IPF Specific functions +// + + +/** + Performs a PAL call using static calling convention. + + An internal function to perform a PAL call using static calling convention. + + @param PalEntryPoint The entry point address of PAL. The address in ar.kr5 + would be used if this parameter were NULL on input. + @param Arg1 The first argument of a PAL call. + @param Arg1 The second argument of a PAL call. + @param Arg1 The third argument of a PAL call. + @param Arg1 The fourth argument of a PAL call. + + @return The values returned in r8, r9, r10 and r11. + +**/ +PAL_PROC_RETURN +PalCallStatic ( + IN CONST VOID *PalEntryPoint, + IN UINT64 Arg1, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4 + ); + + +/** + Returns the current value of ar.itc. + + An internal function to return the current value of ar.itc, which is the + timer tick on IPF. + + @return The currect value of ar.itc + +**/ +INT64 +IpfReadItc ( + VOID + ); + + +/** + Flush a range of cache lines in the cache coherency domain of the calling + CPU. + + Invalidates the cache lines specified by Address and Length. If Address is + not aligned on a cache line boundary, then entire cache line containing + Address is invalidated. If Address + Length is not aligned on a cache line + boundary, then the entire instruction cache line containing Address + Length + -1 is invalidated. This function may choose to invalidate the entire + instruction cache if that is more efficient than invalidating the specified + range. If Length is 0, the no instruction cache lines are invalidated. + Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the instruction lines to invalidate. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing mode, + then Address is a virtual address. + + @param Length The number of bytes to invalidate from the instruction cache. + + @return Address + +**/ +VOID * +EFIAPI +IpfFlushCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h new file mode 100644 index 0000000000..5c8c14464c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h @@ -0,0 +1,391 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueBaseMemoryLib.h + +Abstract: + + Memory-only library functions with no library constructor/destructor + +--*/ + +#ifndef __EDKII_GLUE_BASE_MEMORY_LIB_H__ +#define __EDKII_GLUE_BASE_MEMORY_LIB_H__ + + +#define CopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) GlueCopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) +#define ZeroMem(_BUFFER, _LENGTH) GlueZeroMem(_BUFFER, _LENGTH) +#define SetMem(_BUFFER, _LENGTH, _VALUE) GlueSetMem(_BUFFER, _LENGTH, _VALUE) +#define CompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) GlueCompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) +#define CompareGuid(_GUID1, _GUID2) GlueCompareGuid(_GUID1, _GUID2) + + +/** + Copies a source buffer to a destination buffer, and returns the destination buffer. + + This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns + DestinationBuffer. The implementation must be reentrant, and it must handle the case + where SourceBuffer overlaps DestinationBuffer. + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer Pointer to the destination buffer of the memory copy. + @param SourceBuffer Pointer to the source buffer of the memory copy. + @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer. + + @return DestinationBuffer. + +**/ +VOID * +EFIAPI +GlueCopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Fills a target buffer with a byte value, and returns the target buffer. + + This function fills Length bytes of Buffer with Value, and returns Buffer. + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Memory to set. + @param Length Number of bytes to set. + @param Value Value of the set operation. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueSetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 16-bit value specified by + Value, and returns Buffer. Value is repeated every 16-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 32-bit value specified by + Value, and returns Buffer. Value is repeated every 32-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 64-bit value specified by + Value, and returns Buffer. Value is repeated every 64-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +/** + Fills a target buffer with zeros, and returns the target buffer. + + This function fills Length bytes of Buffer with zeros, and returns Buffer. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with zeros. + @param Length Number of bytes in Buffer to fill with zeros. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ); + +/** + Compares the contents of two buffers. + + This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer. + If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the + value returned is the first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT(). + If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT(). + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer Pointer to the destination buffer to compare. + @param SourceBuffer Pointer to the source buffer to compare. + @param Length Number of bytes to compare. + + @return 0 All Length bytes of the two buffers are identical. + @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + +**/ +INTN +EFIAPI +GlueCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for an 8-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 16-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 32-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 64-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +/** + Copies a source GUID to a destination GUID. + + This function copies the contents of the 128-bit GUID specified by SourceGuid to + DestinationGuid, and returns DestinationGuid. + If DestinationGuid is NULL, then ASSERT(). + If SourceGuid is NULL, then ASSERT(). + + @param DestinationGuid Pointer to the destination GUID. + @param SourceGuid Pointer to the source GUID. + + @return DestinationGuid. + +**/ +GUID * +EFIAPI +CopyGuid ( + OUT GUID *DestinationGuid, + IN CONST GUID *SourceGuid + ); + +/** + Compares two GUIDs. + + This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned. + If there are any bit differences in the two GUIDs, then FALSE is returned. + If Guid1 is NULL, then ASSERT(). + If Guid2 is NULL, then ASSERT(). + + @param Guid1 A pointer to a 128 bit GUID. + @param Guid2 A pointer to a 128 bit GUID. + + @retval TRUE Guid1 and Guid2 are identical. + @retval FALSE Guid1 and Guid2 are not identical. + +**/ +BOOLEAN +EFIAPI +GlueCompareGuid ( + IN CONST GUID *Guid1, + IN CONST GUID *Guid2 + ); + +/** + Scans a target buffer for a GUID, and returns a pointer to the matching GUID + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from + the lowest address to the highest address at 128-bit increments for the 128-bit + GUID value that matches Guid. If a match is found, then a pointer to the matching + GUID in the target buffer is returned. If no match is found, then NULL is returned. + If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Guid Value to search for in the target buffer. + + @return A pointer to the matching Guid in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanGuid ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN CONST GUID *Guid + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h new file mode 100644 index 0000000000..db1702f658 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h @@ -0,0 +1,224 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueCacheMaintenanceLib.h + +Abstract: + + Cache Maintenance Functions + +--*/ + +#ifndef __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__ +#define __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__ + + +#define InvalidateInstructionCache() GlueInvalidateInstructionCache() + + +/** + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + +**/ +VOID +EFIAPI +GlueInvalidateInstructionCache ( + VOID + ); + +/** + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + @param Length The number of bytes to invalidate from the instruction cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +/** + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. + + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. This function guarantees that all dirty cache lines are + written back to system memory, and also invalidates all the data cache lines + in the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackInvalidateDataCache ( + VOID + ); + +/** + Writes Back and Invalidates a range of data cache lines in the cache + coherency domain of the calling CPU. + + Writes Back and Invalidate the data cache lines specified by Address and + Length. If Address is not aligned on a cache line boundary, then entire data + cache line containing Address is written back and invalidated. If Address + + Length is not aligned on a cache line boundary, then the entire data cache + line containing Address + Length -1 is written back and invalidated. This + function may choose to write back and invalidate the entire data cache if + that is more efficient than writing back and invalidating the specified + range. If Length is 0, the no data cache lines are written back and + invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back and + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + @param Length The number of bytes to write back and invalidate from the + data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackInvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +/** + Writes Back the entire data cache in cache coherency domain of the calling + CPU. + + Writes Back the entire data cache in cache coherency domain of the calling + CPU. This function guarantees that all dirty cache lines are written back to + system memory. This function may also invalidate all the data cache lines in + the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackDataCache ( + VOID + ); + +/** + Writes Back a range of data cache lines in the cache coherency domain of the + calling CPU. + + Writes Back the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is written back. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is written back. This function may choose to write back the entire + data cache if that is more efficient than writing back the specified range. + If Length is 0, the no data cache lines are written back. This function may + also invalidate all the data cache lines in the specified range of the cache + coherency domain of the calling CPU. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing + mode, then Address is a virtual address. + @param Length The number of bytes to write back from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +/** + Invalidates the entire data cache in cache coherency domain of the calling + CPU. + + Invalidates the entire data cache in cache coherency domain of the calling + CPU. This function must be used with care because dirty cache lines are not + written back to system memory. It is typically used for cache diagnostics. If + the CPU does not support invalidation of the entire data cache, then a write + back and invalidate operation should be performed on the entire data cache. + +**/ +VOID +EFIAPI +InvalidateDataCache ( + VOID + ); + +/** + Invalidates a range of data cache lines in the cache coherency domain of the + calling CPU. + + Invalidates the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is invalidated. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is invalidated. This function must never invalidate any cache lines + outside the specified range. If Length is 0, the no data cache lines are + invalidated. Address is returned. This function must be used with care + because dirty cache lines are not written back to system memory. It is + typically used for cache diagnostics. If the CPU does not support + invalidation of a data cache range, then a write back and invalidate + operation should be performed on the data cache range. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to invalidate. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing mode, + then Address is a virtual address. + @param Length The number of bytes to invalidate from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h new file mode 100644 index 0000000000..577b28d272 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h @@ -0,0 +1,571 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDebugLib.h + +Abstract: + + Public include file for the Debug Library + +--*/ + +#ifndef __EDKII_GLUE_DEBUG_LIB_H__ +#define __EDKII_GLUE_DEBUG_LIB_H__ + +// +// To use EdkII code, these R8.x macros are undefined +// +#undef ASSERT +#undef DEBUG +#undef ASSERT_EFI_ERROR +#undef ASSERT_PROTOCOL_ALREADY_INSTALLED +#undef DEBUG_CODE +#undef CR + +#undef EFI_D_INIT +#undef EFI_D_WARN +#undef EFI_D_LOAD +#undef EFI_D_FS +#undef EFI_D_POOL +#undef EFI_D_PAGE +#undef EFI_D_INFO +#undef EFI_D_VARIABLE +#undef EFI_D_BM +#undef EFI_D_BLKIO +#undef EFI_D_NET +#undef EFI_D_UNDI +#undef EFI_D_LOADFILE +#undef EFI_D_EVENT +#undef EFI_D_ERROR + +// +// Declare bits for PcdDebugPropertyMask +// +#define DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED 0x01 +#define DEBUG_PROPERTY_DEBUG_PRINT_ENABLED 0x02 +#define DEBUG_PROPERTY_DEBUG_CODE_ENABLED 0x04 +#define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED 0x08 +#define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED 0x10 +#define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED 0x20 + +// +// Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint() +// +#define DEBUG_INIT 0x00000001 // Initialization +#define DEBUG_WARN 0x00000002 // Warnings +#define DEBUG_LOAD 0x00000004 // Load events +#define DEBUG_FS 0x00000008 // EFI File system +#define DEBUG_POOL 0x00000010 // Alloc & Free's +#define DEBUG_PAGE 0x00000020 // Alloc & Free's +#define DEBUG_INFO 0x00000040 // Verbose +#define DEBUG_VARIABLE 0x00000100 // Variable +#define DEBUG_BM 0x00000400 // Boot Manager +#define DEBUG_BLKIO 0x00001000 // BlkIo Driver +#define DEBUG_NET 0x00004000 // SNI Driver +#define DEBUG_UNDI 0x00010000 // UNDI Driver +#define DEBUG_LOADFILE 0x00020000 // UNDI Driver +#define DEBUG_EVENT 0x00080000 // Event messages +#define DEBUG_ERROR 0x80000000 // Error + +// +// Aliases of debug message mask bits +// +#define EFI_D_INIT DEBUG_INIT +#define EFI_D_WARN DEBUG_WARN +#define EFI_D_LOAD DEBUG_LOAD +#define EFI_D_FS DEBUG_FS +#define EFI_D_POOL DEBUG_POOL +#define EFI_D_PAGE DEBUG_PAGE +#define EFI_D_INFO DEBUG_INFO +#define EFI_D_VARIABLE DEBUG_VARIABLE +#define EFI_D_BM DEBUG_BM +#define EFI_D_BLKIO DEBUG_BLKIO +#define EFI_D_NET DEBUG_NET +#define EFI_D_UNDI DEBUG_UNDI +#define EFI_D_LOADFILE DEBUG_LOADFILE +#define EFI_D_EVENT DEBUG_EVENT +#define EFI_D_ERROR DEBUG_ERROR + +/** + + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ); + + +/** + + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. + + Print a message of the form "ASSERT (): \n" + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. + + If FileName is NULL, then a string of ?NULL) Filename?is printed. + + If Description is NULL, then a string of ?NULL) Description?is printed. + + @param FileName Pointer to the name of the source file that generated the assert condition. + @param LineNumber The line number in the source file that generated the assert condition + @param Description Pointer to the description of the assert condition. + +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ); + + +/** + + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. + + This function fills Length bytes of Buffer with the value specified by + PcdDebugClearMemoryValue, and returns Buffer. + + If Buffer is NULL, then ASSERT(). + + If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + + @return Buffer + +**/ +VOID * +EFIAPI +DebugClearMemory ( + OUT VOID *Buffer, + IN UINTN Length + ); + + +/** + + Returns TRUE if ASSERT() macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugAssertEnabled ( + VOID + ); + + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugPrintEnabled ( + VOID + ); + + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugCodeEnabled ( + VOID + ); + + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugClearMemoryEnabled ( + VOID + ); + + +/** + + Internal worker macro that calls DebugAssert(). + + This macro calls DebugAssert() passing in the filename, line number, and + expression that evailated to FALSE. + + @param Expression Boolean expression that evailated to FALSE + +**/ +#define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression) + + +/** + + Internal worker macro that calls DebugPrint(). + + This macro calls DebugPrint() passing in the debug error level, a format + string, and a variable argument list. + + @param Expression Expression containing an error level, a format string, + and a variable argument list based on the format string. + +**/ +#define _DEBUG(Expression) DebugPrint Expression + + +/** + + Macro that calls DebugAssert() if a expression evaluates to FALSE. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro evaluates the Boolean expression specified by Expression. If + Expression evaluates to FALSE, then DebugAssert() is called passing in the + source filename, source line number, and Expression. + + @param Expression Boolean expression + +**/ +#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION + // Glue Library internal + + #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE + #ifdef EFI_DEBUG + #define ASSERT(Expression) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (!(Expression)) { \ + _ASSERT (Expression); \ + } \ + } \ + } while (FALSE) + #endif + #else + #define ASSERT(Expression) do{} while(0) + #endif + +#else + // External usage + + #ifdef EFI_DEBUG + #define ASSERT(Expression) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (!(Expression)) { \ + _ASSERT (Expression); \ + } \ + } \ + } while (FALSE) + #else + #define ASSERT(Expression) do{} while(0) + #endif + +#endif + +/** + + Macro that calls DebugPrint(). + + If the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set, + then this macro passes Expression to DebugPrint(). + + @param Expression Expression containing an error level, a format string, + and a variable argument list based on the format string. + + +**/ +#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION + // Glue Library internal + + #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE + #ifdef EFI_DEBUG + #define DEBUG(Expression) \ + do { \ + if (DebugPrintEnabled ()) { \ + _DEBUG (Expression); \ + } \ + } while (FALSE) + #endif + #else + #define DEBUG(Expression) do{} while(0) + #endif + +#else + // External usage + + #ifdef EFI_DEBUG + #define DEBUG(Expression) \ + do { \ + if (DebugPrintEnabled ()) { \ + _DEBUG (Expression); \ + } \ + } while (FALSE) + #else + #define DEBUG(Expression) do{} while(0) + #endif + +#endif + + +/** + + Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro evaluates the EFI_STATUS value specified by StatusParameter. + If StatusParameter is an error code, then DebugAssert() is called passing in + the source filename, source line number, and StatusParameter. + + @param StatusParameter EFI_STATUS value to evaluate. + +**/ +#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION + // Glue Library internal + + #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE + #ifdef EFI_DEBUG + #define ASSERT_EFI_ERROR(StatusParameter) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (EFI_ERROR (StatusParameter)) { \ + DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter)); \ + _ASSERT (!EFI_ERROR (StatusParameter)); \ + } \ + } \ + } while (FALSE) + #endif + #else + #define ASSERT_EFI_ERROR(Expression) do{} while(0) + #endif + +#else + // External usage + + #ifdef EFI_DEBUG + #define ASSERT_EFI_ERROR(StatusParameter) \ + do { \ + if (DebugAssertEnabled ()) { \ + if (EFI_ERROR (StatusParameter)) { \ + DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter)); \ + _ASSERT (!EFI_ERROR (StatusParameter)); \ + } \ + } \ + } while (FALSE) + #else + #define ASSERT_EFI_ERROR(Expression) do{} while(0) + #endif + +#endif + + +/** + + Macro that calls DebugAssert() if a protocol is already installed in the + handle database. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, + then return. + + If Handle is NULL, then a check is made to see if the protocol specified by Guid + is present on any handle in the handle database. If Handle is not NULL, then + a check is made to see if the protocol specified by Guid is present on the + handle specified by Handle. If the check finds the protocol, then DebugAssert() + is called passing in the source filename, source line number, and Guid. + + If Guid is NULL, then ASSERT(). + + @param Handle The handle to check for the protocol. This is an optional + parameter that may be NULL. If it is NULL, then the entire + handle database is searched. + + @param Guid Pointer to a protocol GUID. + +**/ +#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \ + do { \ + if (DebugAssertEnabled ()) { \ + VOID *Instance; \ + ASSERT (Guid != NULL); \ + if (Handle == NULL) { \ + if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) { \ + _ASSERT (Guid already installed in database); \ + } \ + } else { \ + if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \ + _ASSERT (Guid already installed on Handle); \ + } \ + } \ + } \ + } while (FALSE) + + +/** + Macro that marks the beginning of debug source code. + + If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, + then this macro marks the beginning of source code that is included in a module. + Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() + are not included in a module. + +**/ +#define DEBUG_CODE_BEGIN() do { if (DebugCodeEnabled ()) { UINT8 __DebugCodeLocal + + +/** + + Macro that marks the end of debug source code. + + If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, + then this macro marks the end of source code that is included in a module. + Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() + are not included in a module. + +**/ +#define DEBUG_CODE_END() __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE) + + +/** + + Macro that declares a section of debug source code. + + If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, + then the source code specified by Expression is included in a module. + Otherwise, the source specified by Expression is not included in a module. + +**/ +#define DEBUG_CODE(Expression) \ + DEBUG_CODE_BEGIN (); \ + Expression \ + DEBUG_CODE_END () + + +/** + + Macro that calls DebugClearMemory() to clear a buffer to a default value. + + If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set, + then this macro calls DebugClearMemory() passing in Address and Length. + + @param Address Pointer to a buffer. + @param Length The number of bytes in the buffer to set. + +**/ +#define DEBUG_CLEAR_MEMORY(Address, Length) \ + do { \ + if (DebugClearMemoryEnabled ()) { \ + DebugClearMemory (Address, Length); \ + } \ + } while (FALSE) + + +/** + + Macro that calls DebugAssert() if the containing record does not have a + matching signature. If the signatures matches, then a pointer to the data + structure that contains a specified field of that data structure is returned. + This is a light weight method hide information by placing a public data + structure inside a larger private data structure and using a pointer to the + public data structure to retrieve a pointer to the private data structure. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, + then this macro computes the offset, in bytes, of field specified by Field + from the beginning of the data structure specified by TYPE. This offset is + subtracted from Record, and is used to return a pointer to a data structure + of the type specified by TYPE. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro computes the offset, in bytes, of field specified by Field from + the beginning of the data structure specified by TYPE. This offset is + subtracted from Record, and is used to compute a pointer to a data structure of + the type specified by TYPE. The Signature field of the data structure specified + by TYPE is compared to TestSignature. If the signatures match, then a pointer + to the pointer to a data structure of the type specified by TYPE is returned. + If the signatures do not match, then DebugAssert() is called with a description + of "CR has a bad signature" and Record is returned. + + If the data type specified by TYPE does not contain the field specified by Field, + then the module will not compile. + + If TYPE does not contain a field called Signature, then the module will not + compile. + + @param Record Pointer to the field specified by Field within a data + structure of type TYPE. + + @param TYPE The name of the data structure type to return This + data structure must contain the field specified by Field. + + @param Field The name of the field in the data structure specified + by TYPE to which Record points. + + @param TestSignature The 32-bit signature value to match. + +**/ +#define CR(Record, TYPE, Field, TestSignature) \ + (DebugAssertEnabled () && (_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \ + (TYPE *) (_ASSERT (CR has Bad Signature), Record) : \ + _CR (Record, TYPE, Field) + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h new file mode 100644 index 0000000000..42adebe042 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h @@ -0,0 +1,269 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDevicePathLib.h + +Abstract: + + Public header file for Device Path Lib + +--*/ + +#ifndef __EDKII_GLUE_DEVICE_PATH_LIB_H__ +#define __EDKII_GLUE_DEVICE_PATH_LIB_H__ + + +#define GetDevicePathSize(_DEVICEPATH) GlueGetDevicePathSize(_DEVICEPATH) +#define DuplicateDevicePath(_DEVICEPATH) GlueDuplicateDevicePath(_DEVICEPATH) +#define AppendDevicePath(_FIRSTPATH, _SECONDPATH) GlueAppendDevicePath(_FIRSTPATH, _SECONDPATH) +#define AppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE) GlueAppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE) +#define AppendDevicePathInstance(_SOURCE, _INSTANCE) GlueAppendDevicePathInstance(_SOURCE,_INSTANCE) +#define GetNextDevicePathInstance(_DEVICEPATH, _SIZE) GlueGetNextDevicePathInstance(_DEVICEPATH, _SIZE) +#define IsDevicePathMultiInstance(_DEVICEPATH) GlueIsDevicePathMultiInstance(_DEVICEPATH) +#define DevicePathFromHandle(_HANDLE) GlueDevicePathFromHandle(_HANDLE) +#define FileDevicePath(_DEVICE, _FILENAME) GlueFileDevicePath(_DEVICE, _FILENAME) + + +/** + Returns the size of a device path in bytes. + + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @return The size of a device path in bytes. + +**/ +UINTN +EFIAPI +GlueGetDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +/** + Creates a new device path by appending a second device path to a first device path. + + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. + + @param DevicePath A pointer to a device path data structure. + + @return A pointer to the duplicated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDuplicateDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +/** + Creates a new device path by appending a second device path to a first device path. + + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. + + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL + ); + +/** + Creates a new path by appending the device node to the device path. + + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePath is NULL, then NULL is returned. + If DevicePathNode is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathNode ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL + ); + +/** + Creates a new device path by appending the specified device path instance to the specified device + path. + + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL + ); + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueGetNextDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ); + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ); + +/** + Determines if a device path is single or multi-instance. + + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. + + @param DevicePath A pointer to a device path data structure. + + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. + +**/ +BOOLEAN +EFIAPI +GlueIsDevicePathMultiInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +/** + Retrieves the device path protocol from a handle. + + This function returns the device path protocol from the handle specified by Handle. If Handle is + NULL or Handle does not contain a device path protocol, then NULL is returned. + + @param Handle The handle from which to retrieve the device path protocol. + + @return The device path protocol from the handle specified by Handle. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDevicePathFromHandle ( + IN EFI_HANDLE Handle + ); + +/** + Allocates a device path for a file and appends it to an existing device path. + + If Device is a valid device handle that contains a device path protocol, then a device path for + the file specified by FileName is allocated and appended to the device path associated with the + handle Device. The allocated device path is returned. If Device is NULL or Device is a handle + that does not support the device path protocol, then a device path containing a single device + path node for the file specified by FileName is allocated and returned. + If FileName is NULL, then ASSERT(). + + @param Device A pointer to a device handle. This parameter is optional and + may be NULL. + @param FileName A pointer to a Null-terminated Unicode string. + + @return The allocated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueFileDevicePath ( + IN EFI_HANDLE Device, OPTIONAL + IN CONST CHAR16 *FileName + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h new file mode 100644 index 0000000000..f5ee0bc5ed --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h @@ -0,0 +1,454 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDxeRuntimeDriverLib.h + +Abstract: + + Library that abstracts runtime services + +--*/ + +#ifndef __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__ +#define __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__ + +#ifdef MDE_CPU_IPF +#include "EdkIIGlueEdkDxeSalLib.h" +#endif + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + +typedef struct { + EFI_GUID CapsuleGuid; + UINT32 HeaderSize; + UINT32 Flags; + UINT32 CapsuleImageSize; +} UEFI_CAPSULE_HEADER; + +#else + +typedef EFI_CAPSULE_HEADER UEFI_CAPSULE_HEADER; + +#endif + +extern const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[]; + +extern const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[]; + +/** + Check to see if the execute context is in Runtime phase or not. + + @param None. + + @retval TRUE The driver is in SMM. + @retval FALSE The driver is not in SMM. + +**/ +BOOLEAN +EFIAPI +EfiAtRuntime ( + VOID + ); + +/** + Check to see if the SetVirtualAddressMsp() is invoked or not. + + @retval TRUE SetVirtualAddressMsp() has been called. + @retval FALSE SetVirtualAddressMsp() has not been called. + +**/ +BOOLEAN +EFIAPI +EfiGoneVirtual ( + VOID + ); + +/** + Return current time and date information, and time-keeping + capabilities of hardware platform. + + @param Time A pointer to storage to receive a snapshot of the current time. + @param Capabilities An optional pointer to a buffer to receive the real time clock device's + capabilities. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ); + +/** + Set current time and date information. + + @param Time A pointer to cache of time setting. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to execute the function. + +**/ +EFI_STATUS +EFIAPI +EfiSetTime ( + IN EFI_TIME *Time + ); + +/** + Return current wakeup alarm clock setting. + + @param Enabled Indicate if the alarm clock is enabled or disabled. + @param Pending Indicate if the alarm signal is pending and requires acknowledgement. + @param Time Current alarm clock setting. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ); + +/** + Set current wakeup alarm clock. + + @param Enable Enable or disable current alarm clock.. + @param Time Point to alarm clock setting. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ); + +/** + Return value of variable. + + @param VariableName the name of the vendor's variable, it's a + Null-Terminated Unicode String + @param VendorGuid Unify identifier for vendor. + @param Attributes Point to memory location to return the attributes of variable. If the point + is NULL, the parameter would be ignored. + @param DataSize As input, point to the maxinum size of return Data-Buffer. + As output, point to the actual size of the returned Data-Buffer. + @param Data Point to return Data-Buffer. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + OUT UINT32 *Attributes, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +; + +/** + Enumerates variable's name. + + @param VariableNameSize As input, point to maxinum size of variable name. + As output, point to actual size of varaible name. + @param VariableName As input, supplies the last VariableName that was returned by + GetNextVariableName(). + As output, returns the name of variable. The name + string is Null-Terminated Unicode string. + @param VendorGuid As input, supplies the last VendorGuid that was returned by + GetNextVriableName(). + As output, returns the VendorGuid of the current variable. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ); + +/** + Sets value of variable. + + @param VariableName the name of the vendor's variable, it's a + Null-Terminated Unicode String + @param VendorGuid Unify identifier for vendor. + @param Attributes Point to memory location to return the attributes of variable. If the point + is NULL, the parameter would be ignored. + @param DataSize The size in bytes of Data-Buffer. + @param Data Point to the content of the variable. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ); + +/** + Returns the next high 32 bits of platform's monotonic counter. + + @param HighCount Pointer to returned value. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ); + +/** + Resets the entire platform. + + @param ResetType The type of reset to perform. + @param ResetStatus The status code for reset. + @param DataSize The size in bytes of reset data. + @param ResetData Pointer to data buffer that includes + Null-Terminated Unicode string. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +VOID +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ); + +/** + Determines the new virtual address that is to be used on subsequent memory accesses. + + @param DebugDisposition Supplies type information for the pointer being converted. + @param Address The pointer to a pointer that is to be fixed to be the + value needed for the new virtual address mapping being + applied. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID **Address + ); + + +/** + Change the runtime addressing mode of EFI firmware from physical to virtual. + + @param MemoryMapSize The size in bytes of VirtualMap. + @param DescriptorSize The size in bytes of an entry in the VirtualMap. + @param DescriptorVersion The version of the structure entries in VirtualMap. + @param VirtualMap An array of memory descriptors which contain new virtual + address mapping information for all runtime ranges. Type + EFI_MEMORY_DESCRIPTOR is defined in the + GetMemoryMap() function description. + + @retval EFI_SUCCESS The virtual address map has been applied. + @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in + virtual address mapped mode. + @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is + invalid. + @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory + map that requires a mapping. + @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found + in the memory map. +**/ +EFI_STATUS +EFIAPI +EfiSetVirtualAddressMap ( + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize, + IN UINT32 DescriptorVersion, + IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap + ); + + +/** + Conver the standard Lib double linked list to a virtual mapping. + + @param DebugDisposition Supplies type information for the pointer being converted. + @param ListHead Head of linked list to convert. + + @retval EFI_SUCCESS Success to execute the function. + @retval !EFI_SUCCESS Failed to e3xecute the function. + +**/ +EFI_STATUS +EFIAPI +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT LIST_ENTRY *ListHead + ); + +/** + + Passes capsules to the firmware with both virtual and physical mapping. + Depending on the intended consumption, the firmware may + process the capsule immediately. If the payload should persist across a + system reset, the reset value returned from EFI_QueryCapsuleCapabilities must + be passed into ResetSystem() and will cause the capsule to be processed by + the firmware as part of the reset process. + + @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules + being passed into update capsule. Each capsules is assumed to + stored in contiguous virtual memory. The capsules in the + CapsuleHeaderArray must be the same capsules as the + ScatterGatherList. The CapsuleHeaderArray must + have the capsules in the same order as the ScatterGatherList. + @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in + CaspuleHeaderArray. + @param ScatterGatherList Physical pointer to a set of + EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the + location in physical memory of a set of capsules. See Related + Definitions for an explanation of how more than one capsule is + passed via this interface. The capsules in the + ScatterGatherList must be in the same order as the + CapsuleHeaderArray. This parameter is only referenced if + the capsules are defined to persist across system reset. + + @retval EFI_SUCCESS Valid capsule was passed. I Valid capsule was passed. If + CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the + capsule has been successfully processed by the firmware. + @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL. + @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error. + +**/ +EFI_STATUS +EFIAPI +EfiUpdateCapsule ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + IN EFI_PHYSICAL_ADDRESS ScatterGatherList + ); + + +/** + + The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or + capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and + size of the entire capsule is checked. + If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be + constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof + (EFI_CAPSULE_HEADER). To determine reset requirements, + CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the + EFI_CAPSULE_HEADER. + The firmware must support any capsule that has the + CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The + firmware sets the policy for what capsules are supported that do not have the + CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set. + + @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules + being passed into update capsule. The capsules are assumed to + stored in contiguous virtual memory. + @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in + CaspuleHeaderArray. + @param MaxiumCapsuleSize On output the maximum size that UpdateCapsule() can + support as an argument to UpdateCapsule() via + CapsuleHeaderArray and ScatterGatherList. + Undefined on input. + @param ResetType Returns the type of reset required for the capsule update. + + @retval EFI_SUCCESS Valid answer returned.. + @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL. + @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and + MaximumCapsuleSize and ResetType are undefined. + +**/ +EFI_STATUS +EFIAPI +EfiQueryCapsuleCapabilities ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + OUT UINT64 *MaximumCapsuleSize, + OUT EFI_RESET_TYPE *ResetType + ); + + +/** + + The QueryVariableInfo() function allows a caller to obtain the information about the + maximum size of the storage space available for the EFI variables, the remaining size of the storage + space available for the EFI variables and the maximum size of each individual EFI variable, + associated with the attributes specified. + The returned MaximumVariableStorageSize, RemainingVariableStorageSize, + MaximumVariableSize information may change immediately after the call based on other + runtime activities including asynchronous error events. Also, these values associated with different + attributes are not additive in nature. + + @param Attributes Attributes bitmask to specify the type of variables on + which to return information. Refer to the + GetVariable() function description. + @param MaximumVariableStorageSize + On output the maximum size of the storage space + available for the EFI variables associated with the + attributes specified. + @param RemainingVariableStorageSize + Returns the remaining size of the storage space + available for the EFI variables associated with the + attributes specified.. + @param MaximumVariableSize Returns the maximum size of the individual EFI + variables associated with the attributes specified. + + @retval EFI_SUCCESS Valid answer returned. + @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied. + @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the + MaximumVariableStorageSize, + RemainingVariableStorageSize, MaximumVariableSize + are undefined. +**/ +EFI_STATUS +EFIAPI +EfiQueryVariableInfo ( + IN UINT32 Attrubutes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ); + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h new file mode 100644 index 0000000000..fd4412fe42 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDxeServicesTableLib.h + +Abstract: + + Library that provides a global pointer to the DXE Services Table + +--*/ + +#ifndef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__ +#define __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__ + +// +// Cache copy of the DXE Services Table +// +extern EFI_DXE_SERVICES *gDS; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h new file mode 100644 index 0000000000..fb72b97958 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h @@ -0,0 +1,147 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EdkIIGlueDxeSmmDriverEntryPoint.h + +Abstract: + + Public header file for DXE SMM Driver Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_MODULE_ENTRY_POINT_H__ +#define __EDKII_GLUE_MODULE_ENTRY_POINT_H__ + +// +// Declare the EFI/UEFI Specification Revision to which this driver is implemented +// +extern const UINT32 _gUefiDriverRevision; + +// +// Declare the number of entry points in the image. +// +extern const UINT8 _gDriverEntryPointCount; + +// +// Declare the number of unload handler in the image. +// +extern const UINT8 _gDriverUnloadImageCount; + +/** + Enrty point to DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Enrty point wrapper of DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Computes the cummulative return status for the driver entry point and perform + a long jump back into DriverEntryPoint(). + + @param Status Status returned by the driver that is exiting. + +**/ +VOID +EFIAPI +ExitDriver ( + IN EFI_STATUS Status + ); + +/** + Call constructs for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Call destructors for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call the list of driver entry points. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @return Status returned by entry points of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleEntryPointList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call the unload handlers for all the modules. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + + @return Status returned by unload handlers of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + IN EFI_HANDLE ImageHandle + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueEdkDxeSalLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueEdkDxeSalLib.h new file mode 100644 index 0000000000..b88c919bbb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueEdkDxeSalLib.h @@ -0,0 +1,144 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueEdkDxeSalLib.h + +Abstract: + +--*/ + + +#ifndef __EDKII_GLUE_ESAL_SERVICE_LIB_H__ +#define __EDKII_GLUE_ESAL_SERVICE_LIB_H__ + +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) + +EFI_STATUS +EFIAPI +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + Register ESAL Class Function and it's asociated global. + This function is boot service only! + +Arguments: + FunctionId - ID of function to register + ClassGuid - GUID of function class + Function - Function to register under ClassGuid/FunctionId pair + ModuleGlobal - Module global for Function. + +Returns: + EFI_SUCCESS - If ClassGuid/FunctionId Function was registered. + +--*/ +; + +EFI_STATUS +EFIAPI +RegisterEsalClass ( + IN EFI_GUID *ClassGuid, + IN VOID *ModuleGlobal, + ... + ) +/*++ + +Routine Description: + + Register ESAL Class and it's asociated global. + This function is boot service only! + +Arguments: + ClassGuid - GUID of function class + ModuleGlobal - Module global for Function. + .. - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL + indicates the end of the list. + +Returns: + EFI_SUCCESS - All members of ClassGuid registered + +--*/ +; + +SAL_RETURN_REGS +EFIAPI +EfiCallEsalService ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ) +/*++ + +Routine Description: + + Call module that is not linked direclty to this module. This code is IP + relative and hides the binding issues of virtual or physical calling. The + function that gets dispatched has extra arguments that include the registered + module global and a boolean flag to indicate if the system is in virutal mode. + +Arguments: + ClassGuid - GUID of function + FunctionId - Function in ClassGuid to call + Arg2 - Argument 2 ClassGuid/FunctionId defined + Arg3 - Argument 3 ClassGuid/FunctionId defined + Arg4 - Argument 4 ClassGuid/FunctionId defined + Arg5 - Argument 5 ClassGuid/FunctionId defined + Arg6 - Argument 6 ClassGuid/FunctionId defined + Arg7 - Argument 7 ClassGuid/FunctionId defined + Arg8 - Argument 8 ClassGuid/FunctionId defined + +Returns: + Status of ClassGuid/FuncitonId + +--*/ +; + +SAL_RETURN_REGS +EFIAPI +SetEsalVirtualEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ) +; + +SAL_RETURN_REGS +EFIAPI +SetEsalPhysicalEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ) +; + +SAL_RETURN_REGS +EFIAPI +GetEsalEntryPoint ( + VOID + ) +; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h new file mode 100644 index 0000000000..601656923b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueHiiLib.h + +Abstract: + + Public header file for Hii Lib + +--*/ + +#ifndef __EDKII_GLUE_HII_LIB_H__ +#define __EDKII_GLUE_HII_LIB_H__ + + +#define PreparePackages GluePreparePackages + + +/** + This function allocates pool for an EFI_HII_PACKAGES structure + with enough space for the variable argument list of package pointers. + The allocated structure is initialized using NumberOfPackages, Guid, + and the variable length argument list of package pointers. + + @param NumberOfPackages The number of HII packages to prepare. + @param Guid Package GUID. + + @return + The allocated and initialized packages. + +**/ +EFI_HII_PACKAGES * +EFIAPI +GluePreparePackages ( + IN UINTN NumberOfPackages, + IN CONST EFI_GUID *Guid OPTIONAL, + ... + ) +; + + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h new file mode 100644 index 0000000000..694eb5f44c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h @@ -0,0 +1,384 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueHobLib.h + +Abstract: + + Public header file for Hob Lib + +--*/ + +#ifndef __EDKII_GLUE_HOB_LIB_H__ +#define __EDKII_GLUE_HOB_LIB_H__ + + +#define GetFirstGuidHob(_GUID) GlueGetFirstGuidHob(_GUID) +#define GetNextGuidHob(_GUID, _HobStart) GlueGetNextGuidHob(_GUID, _HobStart) +#define BuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT) GlueBuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT) +#define BuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE) GlueBuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE) + + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +; + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +; + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16 Type + ) +; + +/** + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart A pointer to a Guid. + + @return The next instance of the matched GUID HOB from the starting HOB. + +**/ +VOID * +EFIAPI +GlueGetNextGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +; + +/** + This function searches the first instance of a HOB among the whole HOB list. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + If Guid is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + + @return The first instance of the matched GUID HOB among the whole HOB list. + +**/ +VOID * +EFIAPI +GlueGetFirstGuidHob ( + IN CONST EFI_GUID *Guid + ) +; + +/** + Get the Boot Mode from the HOB list. + + This function returns the system boot mode information from the + PHIT HOB in HOB list. + + @param VOID + + @return The Boot Mode. + +**/ +EFI_BOOT_MODE +EFIAPI +GetBootModeHob ( + VOID + ) +; + +/** + Builds a HOB for a loaded PE32 module. + + This function builds a HOB for a loaded PE32 module. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If ModuleName is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param ModuleName The GUID File Name of the module. + @param MemoryAllocationModule The 64 bit physical address of the module. + @param ModuleLength The length of the module in bytes. + @param EntryPoint The 64 bit physical address of the module entry point. + +**/ +VOID +EFIAPI +GlueBuildModuleHob ( + IN CONST EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +; + +/** + Builds a HOB that describes a chunk of system memory. + + This function builds a HOB that describes a chunk of system memory. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + +**/ +VOID +EFIAPI +BuildResourceDescriptorHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +; + +/** + Builds a GUID HOB with a certain data length. + + This function builds a customized HOB tagged with a GUID for identification + and returns the start address of GUID HOB data so that caller can fill the customized data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidHob ( + IN CONST EFI_GUID *Guid, + IN UINTN DataLength + ) +; + +/** + Copies a data buffer to a newly-built HOB. + + This function builds a customized HOB tagged with a GUID for identification, + copies the input data to the HOB data field and returns the start address of the GUID HOB data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If Data is NULL and DataLength > 0, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param Data The data to be copied into the data field of the GUID HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidDataHob ( + IN CONST EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +; + +/** + Builds a Firmware Volume HOB. + + This function builds a Firmware Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + +**/ +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +; + +/** + Builds a Capsule Volume HOB. + + This function builds a Capsule Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Capsule Volume. + @param Length The size of the Capsule Volume in bytes. + +**/ +VOID +EFIAPI +BuildCvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +; + +/** + Builds a HOB for the CPU. + + This function builds a HOB for the CPU. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param SizeOfMemorySpace The maximum physical memory addressability of the processor. + @param SizeOfIoSpace The maximum physical I/O addressability of the processor. + +**/ +VOID +EFIAPI +BuildCpuHob ( + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +; + +/** + Builds a HOB for the Stack. + + This function builds a HOB for the stack. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the Stack. + @param Length The length of the stack in bytes. + +**/ +VOID +EFIAPI +BuildStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +; + +/** + Builds a HOB for the BSP store. + + This function builds a HOB for BSP store. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the BSP. + @param Length The length of the BSP store in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildBspStoreHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +; + +/** + Builds a HOB for the memory allocation. + + This function builds a HOB for the memory allocation. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the memory. + @param Length The length of the memory allocation in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +GlueBuildMemoryAllocationHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h new file mode 100644 index 0000000000..354efef9d4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h @@ -0,0 +1,2563 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueIoLib.h + +Abstract: + + Public header file for IO Lib + +--*/ + +#ifndef __EDKII_GLUE_IO_LIB_H__ +#define __EDKII_GLUE_IO_LIB_H__ + + +#define IoRead8(_PORT) GlueIoRead8(_PORT) +#define IoWrite8(_PORT,_VALUE) GlueIoWrite8(_PORT,_VALUE) +#define IoRead16(_PORT) GlueIoRead16(_PORT) +#define IoWrite16(_PORT,_VALUE) GlueIoWrite16(_PORT,_VALUE) +#define IoRead32(_PORT) GlueIoRead32(_PORT) +#define IoWrite32(_PORT,_VALUE) GlueIoWrite32(_PORT,_VALUE) + + +#define IO_LIB_ADDRESS(Segment,Port) \ + ( ((Port) & 0xffff) | (((Segment) & 0xffff) << 16) ) + +/** + Reads an 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +GlueIoRead8 ( + IN UINTN Port + ); + +/** + Writes an 8-bit I/O port. + + Writes the 8-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT8 +EFIAPI +GlueIoWrite8 ( + IN UINTN Port, + IN UINT8 Value + ); + +/** + Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoOr8 ( + IN UINTN Port, + IN UINT8 OrData + ); + +/** + Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back + to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAnd8 ( + IN UINTN Port, + IN UINT8 AndData + ); + +/** + Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 8-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAndThenOr8 ( + IN UINTN Port, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in an 8-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoBitFieldRead8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldWrite8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAnd8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 8-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAndThenOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +GlueIoRead16 ( + IN UINTN Port + ); + +/** + Writes a 16-bit I/O port. + + Writes the 16-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT16 +EFIAPI +GlueIoWrite16 ( + IN UINTN Port, + IN UINT16 Value + ); + +/** + Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoOr16 ( + IN UINTN Port, + IN UINT16 OrData + ); + +/** + Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back + to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAnd16 ( + IN UINTN Port, + IN UINT16 AndData + ); + +/** + Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 16-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAndThenOr16 ( + IN UINTN Port, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 16-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoBitFieldRead16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldWrite16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAnd16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 16-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAndThenOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +GlueIoRead32 ( + IN UINTN Port + ); + +/** + Writes a 32-bit I/O port. + + Writes the 32-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT32 +EFIAPI +GlueIoWrite32 ( + IN UINTN Port, + IN UINT32 Value + ); + +/** + Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoOr32 ( + IN UINTN Port, + IN UINT32 OrData + ); + +/** + Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back + to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAnd32 ( + IN UINTN Port, + IN UINT32 AndData + ); + +/** + Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 32-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAndThenOr32 ( + IN UINTN Port, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 32-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoBitFieldRead32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldWrite32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAnd32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 32-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAndThenOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoRead64 ( + IN UINTN Port + ); + +/** + Writes a 64-bit I/O port. + + Writes the 64-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT64 +EFIAPI +IoWrite64 ( + IN UINTN Port, + IN UINT64 Value + ); + +/** + Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoOr64 ( + IN UINTN Port, + IN UINT64 OrData + ); + +/** + Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back + to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAnd64 ( + IN UINTN Port, + IN UINT64 AndData + ); + +/** + Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAndThenOr64 ( + IN UINTN Port, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 64-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoBitFieldRead64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldWrite64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAnd64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAndThenOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads an 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioRead8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit MMIO register. + + Writes the 8-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioWrite8 ( + IN UINTN Address, + IN UINT8 Value + ); + +/** + Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioOr8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result + back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 8-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in an 8-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 8-bit register is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 8-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioRead16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit MMIO register. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWrite16 ( + IN UINTN Address, + IN UINT16 Value + ); + +/** + Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioOr16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result + back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 16-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 16-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 16-bit register is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 16-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioRead32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit MMIO register. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWrite32 ( + IN UINTN Address, + IN UINT32 Value + ); + +/** + Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioOr32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result + back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 32-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 32-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 32-bit register is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 32-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioRead64 ( + IN UINTN Address + ); + +/** + Writes a 64-bit MMIO register. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWrite64 ( + IN UINTN Address, + IN UINT64 Value + ); + +/** + Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioOr64 ( + IN UINTN Address, + IN UINT64 OrData + ); + +/** + Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result + back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAnd64 ( + IN UINTN Address, + IN UINT64 AndData + ); + +/** + Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 64-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAndThenOr64 ( + IN UINTN Address, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 64-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioBitFieldRead64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 64-bit register is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldWrite64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ); + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ); + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAnd64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ); + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 64-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAndThenOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ); + +/** + Copy data from MMIO region to system memory by using 8-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 8-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT8 * +EFIAPI +MmioReadBuffer8 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT8 *Buffer + ); + +/** + Copy data from MMIO region to system memory by using 16-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 16-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 16-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT16 * +EFIAPI +MmioReadBuffer16 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT16 *Buffer + ); + +/** + Copy data from MMIO region to system memory by using 32-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 32-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 32-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT32 * +EFIAPI +MmioReadBuffer32 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT32 *Buffer + ); + +/** + Copy data from MMIO region to system memory by using 64-bit access. + + Copy data from MMIO region specified by starting address StartAddress + to system memory specified by Buffer by using 64-bit access. The total + number of byte to be copied is specified by Length. Buffer is returned. + + If StartAddress is not aligned on a 64-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied from. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer receiving the data read. + + @return Buffer + +**/ +UINT64 * +EFIAPI +MmioReadBuffer64 ( + IN UINTN StartAddress, + IN UINTN Length, + OUT UINT64 *Buffer + ); + +/** + Copy data from system memory to MMIO region by using 8-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 8-bit access. The total number + of byte to be copied is specified by Length. Buffer is returned. + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Size in bytes of the copy. + +**/ +UINT8 * +EFIAPI +MmioWriteBuffer8 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT8 *Buffer + ); + +/** + Copy data from system memory to MMIO region by using 16-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 16-bit access. The total number + of byte to be copied is specified by Length. Length is returned. + + If StartAddress is not aligned on a 16-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Size in bytes of the copy. + +**/ +UINT16 * +EFIAPI +MmioWriteBuffer16 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT16 *Buffer + ); + +/** + Copy data from system memory to MMIO region by using 32-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 32-bit access. The total number + of byte to be copied is specified by Length. Length is returned. + + If StartAddress is not aligned on a 32-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + If Length is not aligned on a 32-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Size in bytes of the copy. + +**/ +UINT32 * +EFIAPI +MmioWriteBuffer32 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT32 *Buffer + ); + +/** + Copy data from system memory to MMIO region by using 64-bit access. + + Copy data from system memory specified by Buffer to MMIO region specified + by starting address StartAddress by using 64-bit access. The total number + of byte to be copied is specified by Length. Length is returned. + + If StartAddress is not aligned on a 64-bit boundary, then ASSERT(). + + If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). + + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + + @param StartAddress Starting address for the MMIO region to be copied to. + @param Length Size in bytes of the copy. + @param Buffer Pointer to a system memory buffer containing the data to write. + + @return Size in bytes of the copy. + +**/ +UINT64 * +EFIAPI +MmioWriteBuffer64 ( + IN UINTN StartAddress, + IN UINTN Length, + IN CONST UINT64 *Buffer + ); + + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h new file mode 100644 index 0000000000..51607be711 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h @@ -0,0 +1,637 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueMemoryAllocationLib.h + +Abstract: + + Public header file for Memory Allocation Lib + +--*/ + +#ifndef __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__ +#define __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__ + + +#define AllocatePages(_PAGES) GlueAllocatePages(_PAGES) +#define FreePages(_BUFFER, _PAGES) GlueFreePages(_BUFFER, _PAGES) +#define AllocatePool(_SIZE) GlueAllocatePool(_SIZE) +#define AllocateZeroPool(_ALLOCATIONSIZE) GlueAllocateZeroPool(_ALLOCATIONSIZE) +#define AllocateCopyPool(_ALLOCATIONSIZE, _BUFFER) GlueAllocateCopyPool(_ALLOCATIONSIZE, _BUFFER) +#define FreePool(_BUFFER) GlueFreePool(_BUFFER) + + +/** + Allocates one or more 4KB pages of type EfiBootServicesData. + + Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePages ( + IN UINTN Pages + ); + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePages ( + IN UINTN Pages + ); + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType. + + Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPages ( + IN UINTN Pages + ); + +/** + Frees one or more 4KB pages that were previously allocated with one of the page allocation + functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with a page allocation function in the Memory Allocation Library, + then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +GlueFreePages ( + IN VOID *Buffer, + IN UINTN Pages + ); + +/** + Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPages ( + IN UINTN Pages, + IN UINTN Alignment + ); + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePages ( + IN UINTN Pages, + IN UINTN Alignment + ); + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPages ( + IN UINTN Pages, + IN UINTN Alignment + ); + +/** + Frees one or more 4KB pages that were previously allocated with one of the aligned page + allocation functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the aligned page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with an aligned page allocation function in the Memory Allocation + Library, then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreeAlignedPages ( + IN VOID *Buffer, + IN UINTN Pages + ); + +/** + Allocates a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePool ( + IN UINTN AllocationSize + ); + +/** + Allocates a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePool ( + IN UINTN AllocationSize + ); + +/** + Allocates a buffer of type EfieservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPool ( + IN UINTN AllocationSize + ); + +/** + Allocates and zeros a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateZeroPool ( + IN UINTN AllocationSize + ); + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ); + +/** + Allocates and zeros a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedZeroPool ( + IN UINTN AllocationSize + ); + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ); + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ); + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ); + +/** + Frees a buffer that was previously allocated with one of the pool allocation functions in the + Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, + then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +GlueFreePool ( + IN VOID *Buffer + ); + +/** + Allocates a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ); + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ); + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ); + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ); + +/** + Frees a buffer that was previously allocated with one of the aligned pool allocation functions + in the Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + aligned pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation + Library, then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +FreeAlignedPool ( + IN VOID *Buffer + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h new file mode 100644 index 0000000000..8916a0f098 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h @@ -0,0 +1,1055 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePciCf8Lib.h + +Abstract: + + Public header file for Pci Cf8 Lib + +--*/ + +#ifndef __EDKII_GLUE_PCI_CF8_LIB_H__ +#define __EDKII_GLUE_PCI_CF8_LIB_H__ + + +/** + Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an + address that can be passed to the PCI Library functions. + + Computes an address that is compatible with the PCI Library functions. The + unused upper bits of Bus, Device, Function and Register are stripped prior to + the generation of the address. + + @param Bus PCI Bus number. Range 0..255. + @param Device PCI Device number. Range 0..31. + @param Function PCI Function number. Range 0..7. + @param Register PCI Register number. Range 0..255. + + @return The encode PCI address. + +**/ +#define PCI_CF8_LIB_ADDRESS(Bus,Device,Function,Offset) \ + (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Read8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Write8 ( + IN UINTN Address, + IN UINT8 Data + ); + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Or8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8And8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8AndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Read16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Write16 ( + IN UINTN Address, + IN UINT16 Data + ); + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Or16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8And16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8AndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Read32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Write32 ( + IN UINTN Address, + IN UINT32 Data + ); + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Or32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8And32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8AndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8ReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ); + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8WriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h new file mode 100644 index 0000000000..8396576dba --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h @@ -0,0 +1,1023 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePciExpressLib.h + +Abstract: + + Public header file for Pci Express Lib + +--*/ + +#ifndef __EDKII_GLUE_PCI_EXPRESS_LIB_H__ +#define __EDKII_GLUE_PCI_EXPRESS_LIB_H__ + + +/** + Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an + address that can be passed to the PCI Library functions. + + Computes an address that is compatible with the PCI Library functions. The + unused upper bits of Bus, Device, Function and Register are stripped prior to + the generation of the address. + + @param Bus PCI Bus number. Range 0..255. + @param Device PCI Device number. Range 0..31. + @param Function PCI Function number. Range 0..7. + @param Register PCI Register number. Range 0..4095. + + @return The encode PCI address. + +**/ +#define PCI_EXPRESS_LIB_ADDRESS(Bus,Device,Function,Offset) \ + (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressRead8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressWrite8 ( + IN UINTN Address, + IN UINT8 Data + ); + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressOr8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressRead16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressWrite16 ( + IN UINTN Address, + IN UINT16 Data + ); + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressOr16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressRead32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressWrite32 ( + IN UINTN Address, + IN UINT32 Data + ); + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressOr32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ); + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h new file mode 100644 index 0000000000..d51ceb7bfc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h @@ -0,0 +1,1019 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePciLib.h + +Abstract: + + Public header file for Pci Lib + +--*/ + +#ifndef __EDKII_GLUE_PCI_LIB_H__ +#define __EDKII_GLUE_PCI_LIB_H__ + +/** + Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an + address that can be passed to the PCI Library functions. + + @param Bus PCI Bus number. Range 0..255. + @param Device PCI Device number. Range 0..31. + @param Function PCI Function number. Range 0..7. + @param Register PCI Register number. Range 0..255 for PCI. Range 0..4095 + for PCI Express. + + @return The encoded PCI address. + +**/ +#define PCI_LIB_ADDRESS(Bus,Device,Function,Offset) \ + (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciRead8 ( + IN UINTN Address + ); + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciWrite8 ( + IN UINTN Address, + IN UINT8 Data + ); + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciOr8 ( + IN UINTN Address, + IN UINT8 OrData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ); + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ); + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ); + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ); + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ); + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciRead16 ( + IN UINTN Address + ); + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciWrite16 ( + IN UINTN Address, + IN UINT16 Data + ); + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciOr16 ( + IN UINTN Address, + IN UINT16 OrData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ); + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ); + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ); + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ); + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ); + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciRead32 ( + IN UINTN Address + ); + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciWrite32 ( + IN UINTN Address, + IN UINT32 Data + ); + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciOr32 ( + IN UINTN Address, + IN UINT32 OrData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ); + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ); + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ); + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ); + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ); + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ); + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h new file mode 100644 index 0000000000..d7861f37fc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h @@ -0,0 +1,93 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePeCoffGetEntryPointLib.h + +Abstract: + + Public header file for PeCoff Get Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__ +#define __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__ + +/** + Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded + into system memory with the PE/COFF Loader Library functions. + + Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry + point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then + return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS. + If Pe32Data is NULL, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system memory. + @param EntryPoint Pointer to entry point to the PE/COFF image to return. + + @retval RETURN_SUCCESS EntryPoint was returned. + @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image. + +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderGetEntryPoint ( + IN VOID *Pe32Data, + OUT VOID **EntryPoint + ); + +/** + Returns the machine type of a PE/COFF image. + + Returns the machine type from the PE/COFF image specified by Pe32Data. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return Machine type or zero if not a valid iamge. + +**/ +UINT16 +EFIAPI +PeCoffLoaderGetMachineType ( + IN VOID *Pe32Data + ); + +/** + Returns a pointer to the PDB file name for a PE/COFF image that has been + loaded into system memory with the PE/COFF Loader Library functions. + + Returns the PDB file name for the PE/COFF image specified by Pe32Data. If + the PE/COFF image specified by Pe32Data is not a valid, then NULL is + returned. If the PE/COFF image specified by Pe32Data does not contain a + debug directory entry, then NULL is returned. If the debug directory entry + in the PE/COFF image specified by Pe32Data does not contain a PDB file name, + then NULL is returned. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL + if it cannot be retrieved. + +**/ +VOID * +EFIAPI +PeCoffLoaderGetPdbPointer ( + IN VOID *Pe32Data + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h new file mode 100644 index 0000000000..4ac6659462 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h @@ -0,0 +1,226 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePeCoffLib.h + +Abstract: + + Public header file for PeCoff Lib + +--*/ + +#ifndef __EDKII_GLUE_BASE_PE_COFF_LIB_H__ +#define __EDKII_GLUE_BASE_PE_COFF_LIB_H__ + + +#define PeCoffLoaderGetImageInfo(_IMAGECONTEXT) GluePeCoffLoaderGetImageInfo(_IMAGECONTEXT) +#define PeCoffLoaderRelocateImage(_IMAGECONTEXT) GluePeCoffLoaderRelocateImage(_IMAGECONTEXT) +#define PeCoffLoaderLoadImage(_IMAGECONTEXT) GluePeCoffLoaderLoadImage(_IMAGECONTEXT) +#define PeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR) GluePeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR) +#define PeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR) GluePeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR) +#define PeCoffLoaderRelocateImage(_IMAGECONTEXT) GluePeCoffLoaderRelocateImage(_IMAGECONTEXT) +#define PeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \ + GluePeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) +#define PeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \ + GluePeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) + + +// +// Return status codes from the PE/COFF Loader services +// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes +// +#define IMAGE_ERROR_SUCCESS 0 +#define IMAGE_ERROR_IMAGE_READ 1 +#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2 +#define IMAGE_ERROR_INVALID_MACHINE_TYPE 3 +#define IMAGE_ERROR_INVALID_SUBSYSTEM 4 +#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5 +#define IMAGE_ERROR_INVALID_IMAGE_SIZE 6 +#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7 +#define IMAGE_ERROR_SECTION_NOT_LOADED 8 +#define IMAGE_ERROR_FAILED_RELOCATION 9 +#define IMAGE_ERROR_FAILED_ICACHE_FLUSH 10 + +// +// PE/COFF Loader Read Function passed in by caller +// +typedef +RETURN_STATUS +(EFIAPI *PE_COFF_LOADER_READ_FILE) ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ); + +// +// Context structure used while PE/COFF image is being loaded and relocated +// +typedef struct { + PHYSICAL_ADDRESS ImageAddress; + UINT64 ImageSize; + PHYSICAL_ADDRESS DestinationAddress; + PHYSICAL_ADDRESS EntryPoint; + PE_COFF_LOADER_READ_FILE ImageRead; + VOID *Handle; + VOID *FixupData; + UINT32 SectionAlignment; + UINT32 PeCoffHeaderOffset; + UINT32 DebugDirectoryEntryRva; + VOID *CodeView; + CHAR8 *PdbPointer; + UINTN SizeOfHeaders; + UINT32 ImageCodeMemoryType; + UINT32 ImageDataMemoryType; + UINT32 ImageError; + UINTN FixupDataSize; + UINT16 Machine; + UINT16 ImageType; + BOOLEAN RelocationsStripped; + BOOLEAN IsTeImage; +} PE_COFF_LOADER_IMAGE_CONTEXT; + +/** + Retrieves information about a PE/COFF image. + + Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView, + PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva + fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER. + If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not + a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while + computing the fields of ImageContext, then the error status is returned in the ImageError field of + ImageContext. + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that needs to be examined by this function. + + @retval RETURN_SUCCESS The information on the PE/COFF image was collected. + @retval RETURN_INVALID_PARAMETER ImageContext is NULL. + @retval RETURN_UNSUPPORTED The PE/COFF image is not supported. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderGetImageInfo ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +; + +/** + Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage(). + + If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of + ImageContext as the relocation base address. Otherwise, use the DestinationAddress field + of ImageContext as the relocation base address. The caller must allocate the relocation + fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being relocated. + + @retval RETURN_SUCCESS The PE/COFF image was relocated. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_UNSUPPORTED A relocation record type is not supported. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderRelocateImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +; + +/** + Loads a PE/COFF image into memory. + + Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer + specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate + the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function. + The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being loaded. + + @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by + the ImageAddress and ImageSize fields of ImageContext. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_INVALID_PARAMETER The image address is invalid. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderLoadImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +; + + +/** + ImageRead function that operates on a memory buffer whos base is passed into + FileHandle. + + @param FileHandle Ponter to baes of the input stream + @param FileOffset Offset to the start of the buffer + @param ReadSize Number of bytes to copy into the buffer + @param Buffer Location to place results of read + + @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into + the buffer. +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderImageReadFromMemory ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ) +; + + +/** + Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI + runtime. + + PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply + the fixups with a virtual mapping. + + + @param ImageBase Base address of relocated image + @param VirtImageBase Virtual mapping for ImageBase + @param ImageSize Size of the image to relocate + @param RelocationData Location to place results of read + +**/ +VOID +EFIAPI +PeCoffLoaderRelocateImageForRuntime ( + IN PHYSICAL_ADDRESS ImageBase, + IN PHYSICAL_ADDRESS VirtImageBase, + IN UINTN ImageSize, + IN VOID *RelocationData + ) +; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h new file mode 100644 index 0000000000..373723376e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h @@ -0,0 +1,306 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePeiServicesLib.h + +Abstract: + + Public header file for PEI Services Lib + +--*/ + +#ifndef __EDKII_GLUE_PEI_SERVICES_LIB_H__ +#define __EDKII_GLUE_PEI_SERVICES_LIB_H__ + +/** + This service enables a given PEIM to register an interface into the PEI Foundation. + + @param PpiList A pointer to the list of interfaces that the caller shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *PpiList + ); + +/** + This service enables PEIMs to replace an entry in the PPI database with an alternate entry. + + @param OldPpi Pointer to the old PEI PPI Descriptors. + @param NewPpi Pointer to the new PEI PPI Descriptors. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been + installed. + +**/ +EFI_STATUS +EFIAPI +PeiServicesReInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, + IN EFI_PEI_PPI_DESCRIPTOR *NewPpi + ); + +/** + This service enables PEIMs to discover a given instance of an interface. + + @param Guid A pointer to the GUID whose corresponding interface needs to be + found. + @param Instance The N-th instance of the interface that is required. + @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. + @param Ppi A pointer to the instance of the interface. + + @retval EFI_SUCCESS The interface was successfully returned. + @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesLocatePpi ( + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ); + +/** + This service enables PEIMs to register a given service to be invoked when another service is + installed or reinstalled. + + @param NotifyList A pointer to the list of notification interfaces that the caller + shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesNotifyPpi ( + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList + ); + +/** + This service enables PEIMs to ascertain the present value of the boot mode. + + @param BootMode A pointer to contain the value of the boot mode. + + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetBootMode ( + IN OUT EFI_BOOT_MODE *BootMode + ); + +/** + This service enables PEIMs to update the boot mode variable. + + @param BootMode The value of the boot mode to set. + + @retval EFI_SUCCESS The value was successfully updated + +**/ +EFI_STATUS +EFIAPI +PeiServicesSetBootMode ( + IN EFI_BOOT_MODE BootMode + ); + +/** + This service enables a PEIM to ascertain the address of the list of HOBs in memory. + + @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. + + @retval EFI_SUCCESS The list was successfully returned. + @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetHobList ( + IN OUT VOID **HobList + ); + +/** + This service enables PEIMs to create various types of HOBs. + + @param Type The type of HOB to be installed. + @param Length The length of the HOB to be added. + @param Hob The address of a pointer that will contain the HOB header. + + @retval EFI_SUCCESS The HOB was successfully created. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesCreateHob ( + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob + ); + +#if (PI_SPECIFICATION_VERSION < 0x00010000) +/** + This service enables PEIMs to discover additional firmware volumes. + + @param Instance This instance of the firmware volume to find. The value 0 is the + Boot Firmware Volume (BFV). + @param FwVolHeader Pointer to the firmware volume header of the volume to return. + + @retval EFI_SUCCESS The volume was found. + @retval EFI_NOT_FOUND The volume was not found. + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextVolume ( + IN UINTN Instance, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ); + +/** + This service enables PEIMs to discover additional firmware files. + + @param SearchType A filter to find files only of this type. + @param FwVolHeader Pointer to the firmware volume header of the volume to search. + This parameter must point to a valid FFS volume. + @param FileHeader Pointer to the current file from which to begin searching. + + @retval EFI_SUCCESS The file was found. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_NOT_FOUND The header checksum was not zero. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextFile ( + IN EFI_FV_FILETYPE SearchType, + IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, + IN OUT EFI_FFS_FILE_HEADER **FileHeader + ); + +/** + This service enables PEIMs to discover sections of a given type within a valid FFS file. + + @param SearchType The value of the section type to find. + @param FfsFileHeader A pointer to the file header that contains the set of sections to + be searched. + @param SectionData A pointer to the discovered section, if successful. + + @retval EFI_SUCCESS The section was found. + @retval EFI_NOT_FOUND The section was not found. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindSectionData ( + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData + ); +#endif + +/** + This service enables PEIMs to register the permanent memory configuration + that has been initialized with the PEI Foundation. + + @param MemoryBegin The value of a region of installed memory. + @param MemoryLength The corresponding length of a region of installed memory. + + @retval EFI_SUCCESS The region was successfully installed in a HOB. + @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPeiMemory ( + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ); + +/** + This service enables PEIMs to allocate memory after the permanent memory has been installed by a + PEIM. + + @param MemoryType Type of memory to allocate. + @param Pages Number of pages to allocate. + @param Memory Pointer of memory allocated. + + @retval EFI_SUCCESS The memory range was successfully allocated. + @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. + @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ); + +/** + This service allocates memory from the Hand-Off Block (HOB) heap. + + @param Size The number of bytes to allocate from the pool. + @param Buffer If the call succeeds, a pointer to a pointer to the allocate + buffer; undefined otherwise. + + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePool ( + IN UINTN Size, + OUT VOID **Buffer + ); + +/** + This service resets the entire platform, including all processors and devices, and reboots the + system. + + @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. + +**/ +EFI_STATUS +EFIAPI +PeiServicesResetSystem ( + VOID + ); + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h new file mode 100644 index 0000000000..a839dade92 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePeiServicesTablePointerLib.h + +Abstract: + + Public header file for PEI Services Table Pointer Lib + +--*/ + +#ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__ +#define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__ + +/** + The function returns the pointer to PEI services. + + The function returns the pointer to PEI services. + It will ASSERT() if the pointer to PEI services is NULL. + + @retval The pointer to PeiServices. + +**/ +EFI_PEI_SERVICES ** +EFIAPI +GetPeiServicesTablePointer ( + VOID + ); + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h new file mode 100644 index 0000000000..2ed64c5803 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePeimEntryPoint.h + +Abstract: + + Public header file for PEIM Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_PEIM_ENTRY_POINT_H__ +#define __EDKII_GLUE_PEIM_ENTRY_POINT_H__ + +// +// Declare the EFI/UEFI Specification Revision to which this driver is implemented +// +extern const UINT32 _gPeimRevision; + +/** + Image entry point of Peim. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Wrapper of Peim image entry point. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of Peims. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Call constructs for all libraries. Automatics Generated by tool. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + +**/ +VOID +EFIAPI +ProcessLibraryConstructorList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Call destructors for all libraries. Automatics Generated by tool. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + +**/ +VOID +EFIAPI +ProcessLibraryDestructorList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + + +/** + Call the list of driver entry points. Automatics Generated by tool. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @return Status returned by entry points of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleEntryPointList ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h new file mode 100644 index 0000000000..34da75a85c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h @@ -0,0 +1,165 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePostCodeLib.h + +Abstract: + + Public header file for Post Code Lib + +--*/ + +#ifndef __EDKII_GLUE_POST_CODE_LIB_H__ +#define __EDKII_GLUE_POST_CODE_LIB_H__ + + +#define PostCode(_VALUE) GluePostCode(_VALUE) +#define PostCodeWithDescription(_VALUE, _DESC) GluePostCodeWithDescription(_VALUE, _DESC) +#define PostCodeEnabled() GluePostCodeEnabled() +#define PostCodeDescriptionEnabled() GluePostCodeDescriptionEnabled() + + +#define POST_CODE_PROPERTY_POST_CODE_ENABLED 0x00000008 +#define POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED 0x00000010 + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ); + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ); + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ); + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the + POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ); + + +/** + Sends an 32-bit value to a POST card. + + If POST codes are enabled in PcdPostCodeProperyMask, then call PostCode() + passing in Value. Value is returned. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +#define POST_CODE(Value) PostCodeEnabled() ? PostCode(Value) : Value + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + If POST codes and POST code descriptions are enabled in + PcdPostCodeProperyMask, then call PostCodeWithDescription() passing in + Value and Description. If only POST codes are enabled, then call PostCode() + passing in Value. Value is returned. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. + +**/ +#define POST_CODE_WITH_DESCRIPTION(Value,Description) \ + PostCodeEnabled() ? \ + (PostCodeDescriptionEnabled() ? \ + PostCodeWithDescription(Value,Description) : \ + PostCode(Value)) : \ + Value + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h new file mode 100644 index 0000000000..3409af9111 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h @@ -0,0 +1,481 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePrintLib.h + +Abstract: + + Public header file Print Lib + +--*/ + +#ifndef __EDKII_GLUE_PRINT_LIB_H__ +#define __EDKII_GLUE_PRINT_LIB_H__ + +/// +/// Define the maximum number of characters that are required to +/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL +/// terminator. +/// +/// Maximum Length Decimal String = 28 +/// "-9,223,372,036,854,775,808" +/// Maximum Length Hexidecimal String = 17 +/// "FFFFFFFFFFFFFFFF" +/// Maximum Length GUID = 37 +/// "00000000-0000-0000-0000-000000000000" +/// Maximum Length TIME = 18 +/// "12/12/2006 12:12" +/// +#define MAXIMUM_VALUE_CHARACTERS 38 + +/// +/// Flags bitmask values use in UnicodeValueToString() and +/// AsciiValueToString() +/// +#define LEFT_JUSTIFY 0x01 +#define COMMA_TYPE 0x08 +#define PREFIX_ZERO 0x20 +#define RADIX_HEX 0x80 + +/** + Produces a Null-terminated Unicode string in an output buffer based on + a Null-terminated Unicode format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + Unicode format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ); + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ); + +/** + Converts a decimal value to a Null-terminated Unicode string. + + Converts the decimal number specified by Value to a Null-terminated Unicode + string specified by Buffer containing at most Width characters. No padding of spaces + is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of Unicode characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be + formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + Unicode string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Unicode characters to place in Buffer, not including + the Null-terminator. + + @return The number of Unicode characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeValueToString ( + IN OUT CHAR16 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ); + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ); + +/** + Converts a decimal value to a Null-terminated ASCII string. + + Converts the decimal number specified by Value to a Null-terminated ASCII string + specified by Buffer containing at most Width characters. No padding of spaces + is ever performed. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of ASCII characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first Width + characters are returned, and the total number of characters required to perform + the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be + formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + ASCII string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of ASCII characters to place in Buffer, not including + the Null-terminator. + + @return The number of ASCII characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +AsciiValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h new file mode 100644 index 0000000000..d7bc47b5d9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h @@ -0,0 +1,659 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueReportStatusCodeLib.h + +Abstract: + + Public header file for Report Status Code Lib + +--*/ + +#ifndef __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__ +#define __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__ + + + +#define CodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE) GlueCodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE) +#define ReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER) \ + GlueReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER) +#define ReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT) \ + GlueReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT) +#define ReportStatusCode(_TYPE, _VALUE) GlueReportStatusCode(_TYPE, _VALUE) +#define ReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH) \ + GlueReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH) +#define ReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE) \ + GlueReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE) +#define ReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE) \ + GlueReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE) +#define ReportProgressCodeEnabled() GlueReportProgressCodeEnabled() +#define ReportErrorCodeEnabled() GlueReportErrorCodeEnabled() +#define ReportDebugCodeEnabled() GlueReportDebugCodeEnabled() + + +// +// Declare bits for PcdReportStatusCodePropertyMask +// +#define REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED 0x00000001 +#define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED 0x00000002 +#define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED 0x00000004 + +// +// Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed +// + +/// +/// Voltage Extended Error Data +/// +typedef struct { + EFI_EXP_BASE10_DATA Voltage; + EFI_EXP_BASE10_DATA Threshold; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_VOLTAGE_ERROR_DATA; + +/// +/// Microcode Update Extended Error Data +/// +typedef struct { + UINT32 Version; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_MICROCODE_UPDATE_ERROR_DATA; + +/// +/// Asynchronous Timer Extended Error Data +/// +typedef struct { + EFI_EXP_BASE10_DATA TimerLimit; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_TIMER_EXPIRED_ERROR_DATA; + +/// +/// Host Processor Mismatch Extended Error Data +/// +typedef struct { + UINT32 Instance; + UINT16 Attributes; +} REPORT_STATUS_CODE_LIBRARY_HOST_PROCESSOR_MISMATCH_ERROR_DATA; + +/// +/// Thermal Extended Error Data +/// +typedef struct { + EFI_EXP_BASE10_DATA Temperature; + EFI_EXP_BASE10_DATA Threshold; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_THERMAL_ERROR_DATA; + +/// +/// Processor Disabled Extended Error Data +/// +typedef struct { + UINT32 Cause; + BOOLEAN SoftwareDisabled; +} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_CPU_DISABLED_ERROR_DATA; + +/// +/// Embedded cache init extended data +/// +typedef struct { + UINT32 Level; + EFI_INIT_CACHE_TYPE Type; +} REPORT_STATUS_CODE_LIBRARY_CACHE_INIT_DATA; + +/// +/// Memory Extended Error Data +/// +typedef struct { + EFI_MEMORY_ERROR_GRANULARITY Granularity; + EFI_MEMORY_ERROR_OPERATION Operation; + UINTN Syndrome; + EFI_PHYSICAL_ADDRESS Address; + UINTN Resolution; +} REPORT_STATUS_CODE_LIBRARY_MEMORY_EXTENDED_ERROR_DATA; + +/// +/// DIMM number +/// +typedef struct { + UINT16 Array; + UINT16 Device; +} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_DIMM_NUMBER; + +/// +/// Memory Module Mismatch Extended Error Data +/// +typedef struct { + EFI_STATUS_CODE_DIMM_NUMBER Instance; +} REPORT_STATUS_CODE_LIBRARY_MEMORY_MODULE_MISMATCH_ERROR_DATA; + +/// +/// Memory Range Extended Data +/// +typedef struct { + EFI_PHYSICAL_ADDRESS Start; + EFI_PHYSICAL_ADDRESS Length; +} REPORT_STATUS_CODE_LIBRARY_MEMORY_RANGE_EXTENDED_DATA; + +/// +/// Device handle Extended Data. Used for many +/// errors and progress codes to point to the device. +/// +typedef struct { + EFI_HANDLE Handle; +} REPORT_STATUS_CODE_LIBRARY_DEVICE_HANDLE_EXTENDED_DATA; + +typedef struct { + UINT8 *DevicePath; +} REPORT_STATUS_CODE_LIBRARY_DEVICE_PATH_EXTENDED_DATA; + +typedef struct { + EFI_HANDLE ControllerHandle; + EFI_HANDLE DriverBindingHandle; + UINT16 DevicePathSize; + UINT8 *RemainingDevicePath; +} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_START_EXTENDED_DATA; + +/// +/// Resource Allocation Failure Extended Error Data +/// +typedef struct { + UINT32 Bar; + UINT16 DevicePathSize; + UINT16 ReqResSize; + UINT16 AllocResSize; + UINT8 *DevicePath; + UINT8 *ReqRes; + UINT8 *AllocRes; +} REPORT_STATUS_CODE_LIBRARY_RESOURCE_ALLOC_FAILURE_ERROR_DATA; + +/// +/// Extended Error Data for Assert +/// +typedef struct { + UINT32 LineNumber; + UINT32 FileNameSize; + EFI_STATUS_CODE_STRING_DATA *FileName; +} REPORT_STATUS_CODE_LIBRARY_DEBUG_ASSERT_DATA; + +/// +/// System Context Data EBC/IA32/IPF +/// +typedef struct { + EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT Context; +} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_EXCEP_EXTENDED_DATA; + +/// +/// Legacy Oprom extended data +/// +typedef struct { + EFI_HANDLE DeviceHandle; + EFI_PHYSICAL_ADDRESS RomImageBase; +} REPORT_STATUS_CODE_LIBRARY_LEGACY_OPROM_EXTENDED_DATA; + +// +// Extern for the modules Caller ID GUID +// +extern EFI_GUID gEfiCallerIdGuid; + +/** + Converts a status code to an 8-bit POST code value. + + Converts the status code specified by CodeType and Value to an 8-bit POST code + and returns the 8-bit POST code in PostCode. If CodeType is an + EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode + are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits + 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. + + If PostCode is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param PostCode A pointer to the 8-bit POST code value to return. + + @retval TRUE The status code specified by CodeType and Value was converted + to an 8-bit POST code and returned in PostCode. + @retval FALSE The status code specified by CodeType and Value could not be + converted to an 8-bit POST code value. + +**/ +BOOLEAN +EFIAPI +GlueCodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ); + + +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ); + + +/** + Extracts DEBUG() information from a status code structure. + + Converts the status code specified by Data to the DEBUG() arguments specified + by ErrorLevel, Marker, and Format. If type GUID in Data is + EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and + Format from the optional data area of the status code buffer specified by Data. + The optional data area of Data contains a 32-bit ErrorLevel followed by Marker + which is 12 UINTN parameters, followed by a Null-terminated ASCII string for + the Format. If the DEBUG() information could be extracted from Data, then + return TRUE. Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If ErrorLevel is NULL, then ASSERT(). + If Marker is NULL, then ASSERT(). + If Format is NULL, then ASSERT(). + + @param Data Pointer to status code data buffer. + @param ErrorLevel Pointer to error level mask for a debug message. + @param Marker Pointer to the variable argument list associated with Format. + @param Format Pointer to a Null-terminated ASCII format string of a + debug message. + + @retval TRUE The status code specified by Data was converted DEBUG() arguments + specified by ErrorLevel, Marker, and Format. + @retval FALSE The status code specified by Data could not be converted to + DEBUG() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractDebugInfo ( + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ); + + +/** + Reports a status code. + + Reports the status code specified by the parameters Type and Value. Status + code also require an instance, caller ID, and extended data. This function + passed in a zero instance, NULL extended data, and a caller ID of + gEfiCallerIdGuid, which is the GUID for the module. + + ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() + is called while processing another any other Report Status Code Library function, + then ReportStatusCode() must return immediately. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a + device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value + ); + + +/** + Reports a status code with a Device Path Protocol as the extended data. + + Allocates and fills in the extended data section of a status code with the + Device Path Protocol specified by DevicePath. This function is responsible + for allocating a buffer large enough for the standard header and the device + path. The standard header is filled in with a GUID of + gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero + instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithDevicePath()must actively prevent recursion. If + ReportStatusCodeWithDevicePath() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithDevicePath() + must return EFI_DEVICE_ERROR immediately. + + If DevicePath is NULL, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + + +/** + Reports a status code with an extended data buffer. + + Allocates and fills in the extended data section of a status code with the + extended data specified by ExtendedData and ExtendedDataSize. ExtendedData + is assumed to be one of the data structures specified in Related Definitions. + These data structure do not have the standard header, so this function is + responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled + in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported + with a zero instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithExtendedData()must actively prevent recursion. If + ReportStatusCodeWithExtendedData() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithExtendedData() + must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL, then ASSERT(). + If ExtendedDataSize is 0, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithExtendedData ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST VOID *ExtendedData, + IN UINTN ExtendedDataSize + ); + + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ); + + +/** + Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportProgressCodeEnabled ( + VOID + ); + + +/** + Returns TRUE if status codes of type EFI_ERROR_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportErrorCodeEnabled ( + VOID + ); + + +/** + Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportDebugCodeEnabled ( + VOID + ); + + +/** + Reports a status code with minimal parameters if the status code type is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type + and Value. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE(Type,Value) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCode(Type,Value) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCode(Type,Value) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCode(Type,Value) : \ + EFI_UNSUPPORTED + + +/** + Reports a status code with a Device Path Protocol as the extended data if the + status code type is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath() + passing in Type, Value, and DevicePath. + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \ + EFI_UNSUPPORTED + + +/** + Reports a status code with an extended data buffer if the status code type + is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData() + passing in Type, Value, ExtendedData, and ExtendedDataSize. + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \ + EFI_UNSUPPORTED + +/** + Reports a status code specifying all parameters if the status code type is enabled. + + If the status code type specified by Type is enabled in + PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type, + Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +#define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \ + (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \ + ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \ + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \ + ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \ + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \ + ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \ + EFI_UNSUPPORTED + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h new file mode 100644 index 0000000000..f2ea2fd9fe --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueResourcePublicationLib.h + +Abstract: + + Public header file for Resource Publication Lib + +--*/ + +#ifndef __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__ +#define __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__ + +/** + + Declares the presence of permanent system memory in the platform. + + Declares that the system memory buffer specified by MemoryBegin and MemoryLength + as permanent memory that may be used for general purpose use by software. + The amount of memory available to software may be less than MemoryLength + if published memory has alignment restrictions. + + @param MemoryBegin The start address of the memory being declared. + @param MemoryLength The number of bytes of memory being declared. + + @retval RETURN_SUCCESS The memory buffer was published. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to publish the memory buffer + +**/ +RETURN_STATUS +EFIAPI +PublishSystemMemory ( + IN PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ) +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h new file mode 100644 index 0000000000..3ae42e60a4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h @@ -0,0 +1,394 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueSmbusLib.h + +Abstract: + + Public header file for Smbus Lib + +--*/ + +#ifndef __EDKII_GLUE_SMBUS_LIB_H__ +#define __EDKII_GLUE_SMBUS_LIB_H__ + +// +// PEC BIT is bit 22 in SMBUS address +// +#define SMBUS_LIB_PEC_BIT (1 << 22) + +/** + Macro that converts SMBUS slave address, SMBUS command, SMBUS data length, + and PEC to a value that can be passed to the SMBUS Library functions. + + Computes an address that is compatible with the SMBUS Library functions. + The unused upper bits of SlaveAddress, Command, and Length are stripped + prior to the generation of the address. + + @param SlaveAddress SMBUS Slave Address. Range 0..127. + @param Command SMBUS Command. Range 0..255. + @param Length SMBUS Data Length. Range 0..32. + @param Pec TRUE if Packet Error Checking is enabled. Otherwise FALSE. + +**/ +#define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec) \ + ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0) | \ + (((SlaveAddress) & 0x7f) << 1) | \ + (((Command) & 0xff) << 8) | \ + (((Length) & 0x3f) << 16) \ + ) + +/** + Executes an SMBUS quick read command. + + Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickRead ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS quick write command. + + Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickWrite ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS receive byte command. + + Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + The byte received from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte received from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReceiveByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS send byte command. + + Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress. + The byte specified by Value is sent. + Only the SMBUS slave address field of SmBusAddress is required. Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to send. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusSendByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS read data byte command. + + Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 8-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReadDataByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS write data byte command. + + Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. + The 8-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusWriteDataByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS read data word command. + + Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT16 +EFIAPI +SmBusReadDataWord ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS write data word command. + + Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT16 +EFIAPI +SmBusWriteDataWord ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS process call command. + + Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value returned by the process call command is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The 16-bit value returned by the process call command. + +**/ +UINT16 +EFIAPI +SmBusProcessCall ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS read block command. + + Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Bytes are read from the SMBUS and stored in Buffer. + The number of bytes read is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is not zero, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes read. + +**/ +UINTN +EFIAPI +SmBusReadBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS write block command. + + Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from Buffer. + The number of bytes written is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusWriteBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + +/** + Executes an SMBUS block process call command. + + Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If WriteBuffer is NULL, then ASSERT(). + If ReadBuffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. + @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusBlockProcessCall ( + IN UINTN SmBusAddress, + IN VOID *WriteBuffer, + OUT VOID *ReadBuffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h new file mode 100644 index 0000000000..6e5e110778 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h @@ -0,0 +1,106 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueTimerLib.h + +Abstract: + + Public header file for Timer Lib + +--*/ + +#ifndef __EDKII_GLUE_TIMER_LIB_H__ +#define __EDKII_GLUE_TIMER_LIB_H__ + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return MicroSeconds + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ); + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return NanoSeconds + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ); + +/** + Retrieves the current value of a 64-bit free running performance counter. + + Retrieves the current value of a 64-bit free running performance counter. The + counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ); + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + OUT UINT64 *StartValue, OPTIONAL + OUT UINT64 *EndValue OPTIONAL + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h new file mode 100644 index 0000000000..fa044ea715 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueUefiBootServicesTableLib.h + +Abstract: + + Public header file for UEFI Boot Services Table Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__ +#define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__ + +// +// Cache the Image Handle +// +extern EFI_HANDLE gImageHandle; + +// +// Cache pointer to the EFI System Table +// +extern EFI_SYSTEM_TABLE *gST; + +// +// Cache pointer to the EFI Boot Services Table +// +extern EFI_BOOT_SERVICES *gBS; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h new file mode 100644 index 0000000000..865b2a8ccb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h @@ -0,0 +1,113 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueUefiDecompressLib.h + +Abstract: + + Public header file for UEFI Decompress Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__ +#define __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__ + +#define FillBuf(_SD, _NUMOFBITS) GlueFillBuf(_SD, _NUMOFBITS) +#define GetBits(_SD, _NUMOFBITS) GlueGetBits(_SD, _NUMOFBITS) +#define MakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE) GlueMakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE) +#define DecodeP(_SD) GlueDecodeP(_SD) +#define ReadPTLen( _SD, _NN, _NBIT, _SPECIAL) GlueReadPTLen( _SD, _NN, _NBIT, _SPECIAL) +#define ReadCLen(_SD) GlueReadCLen(_SD) +#define DecodeC(_SD) GlueDecodeC(_SD) +#define Decode(_SD) GlueDecode(_SD) + + + +/** + Retrieves the size of the uncompressed buffer and the size of the scratch buffer. + + Retrieves the size of the uncompressed buffer and the temporary scratch buffer + required to decompress the buffer specified by Source and SourceSize. + If the size of the uncompressed buffer or the size of the scratch buffer cannot + be determined from the compressed data specified by Source and SourceData, + then RETURN_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed + buffer is returned in DestinationSize, the size of the scratch buffer is returned + in ScratchSize, and RETURN_SUCCESS is returned. + This function does not have scratch buffer available to perform a thorough + checking of the validity of the source data. It just retrieves the "Original Size" + field from the beginning bytes of the source data and output it as DestinationSize. + And ScratchSize is specific to the decompression implementation. + + If Source is NULL, then ASSERT(). + If DestinationSize is NULL, then ASSERT(). + If ScratchSize is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param SourceSize The size, in bytes, of the source buffer. + @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer + that will be generated when the compressed buffer specified + by Source and SourceSize is decompressed.. + @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that + is required to decompress the compressed buffer specified + by Source and SourceSize. + + @retval RETURN_SUCCESS The size of destination buffer and the size of scratch + buffer are successull retrieved. + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompressGetInfo ( + IN CONST VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); + +/** + Decompresses a compressed source buffer. + + This function is designed so that the decompression algorithm can be implemented + without using any memory services. As a result, this function is not allowed to + call any memory allocation services in its implementation. It is the caller's r + esponsibility to allocate and free the Destination and Scratch buffers. + If the compressed source data specified by Source is sucessfully decompressed + into Destination, then RETURN_SUCCESS is returned. If the compressed source data + specified by Source is not in a valid compressed data format, + then RETURN_INVALID_PARAMETER is returned. + + If Source is NULL, then ASSERT(). + If Destination is NULL, then ASSERT(). + If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param Destination The destination buffer to store the decompressed data + @param Scratch A temporary scratch buffer that is used to perform the decompression. + This is an optional parameter that may be NULL if the + required scratch buffer size is 0. + + @retval RETURN_SUCCESS Decompression is successfull + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompress ( + IN CONST VOID *Source, + IN OUT VOID *Destination, + IN OUT VOID *Scratch + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h new file mode 100644 index 0000000000..967e45c7e8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h @@ -0,0 +1,162 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueUefiDriverEntryPoint.h + +Abstract: + + Public header file for UEFI Driver Entry Point Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__ +#define __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__ + +// +// Declare the EFI/UEFI Specification Revision to which this driver is implemented +// +extern const UINT32 _gUefiDriverRevision; + +// +// Declare the number of entry points in the image. +// +extern const UINT8 _gDriverEntryPointCount; + +// +// Declare the number of unload handler in the image. +// +extern const UINT8 _gDriverUnloadImageCount; + +// +// Declare the arrary of Boot Sevice Exit Event callbacks . +// +extern const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[]; + +// +// Declare the arrary of Virtual Address Change Event callbacks . +// +extern const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[]; + +/** + Enrty point to DXE SMM Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Enrty point wrapper of DXE Driver. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @retval EFI_SUCCESS One or more of the drivers returned a success code. + @retval !EFI_SUCESS The return status from the last driver entry point in the list. + +**/ +EFI_STATUS +EFIAPI +EfiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Computes the cummulative return status for the driver entry point and perform + a long jump back into DriverEntryPoint(). + + @param Status Status returned by the driver that is exiting. + +**/ +VOID +EFIAPI +ExitDriver ( + IN EFI_STATUS Status + ); + + +/** + Call constructs for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryConstructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call destructors for all libraries. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + +**/ +VOID +EFIAPI +ProcessLibraryDestructorList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Call the list of driver entry points. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + @param SystemTable Pointer to the EFI System Table. + + @return Status returned by entry points of drivers. + +**/ + +EFI_STATUS +EFIAPI +ProcessModuleEntryPointList ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + Call the unload handlers for all the modules. Automatics Generated by tool. + + @param ImageHandle ImageHandle of the loaded driver. + + @return Status returned by unload handlers of drivers. + +**/ +EFI_STATUS +EFIAPI +ProcessModuleUnloadList ( + IN EFI_HANDLE ImageHandle + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h new file mode 100644 index 0000000000..2038303a2c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueUefiDriverModelLib.h + +Abstract: + + Public header file for UEFI Driver Model Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__ +#define __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__ + +// +// Declare bitmask values for the protocols that are enabled +// +#define UEFI_DRIVER_MODEL_LIBRARY_COMPONENT_NAME_PROTOCOL_ENABLED 0x01 +#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_DIAGNOSTICS_PROTOCOL_ENABLED 0x02 +#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_CONFIGURATION_PROTOCOL_ENABLED 0x04 + +// +// Data structure that declares pointers to the Driver Model +// Protocols. +// +typedef struct { + const EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + const EFI_COMPONENT_NAME2_PROTOCOL *ComponentName; +#else + const EFI_COMPONENT_NAME_PROTOCOL *ComponentName; +#endif + const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration; + const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics; +} EFI_DRIVER_MODEL_PROTOCOL_LIST; + +// +// UEFI Driver Model Protocols arrary +// +extern const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[]; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h new file mode 100644 index 0000000000..eba1f1afd3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h @@ -0,0 +1,722 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueUefiLib.h + +Abstract: + + Public header file for UEFI Lib + +--*/ + +#ifndef __EDKII_GLUE_UEFI_LIB_H__ +#define __EDKII_GLUE_UEFI_LIB_H__ + + +#define EfiInitializeLock(_LOCK, _PRIORITY) GlueEfiInitializeLock(_LOCK, _PRIORITY) +#define EfiAcquireLock(_LOCK) GlueEfiAcquireLock(_LOCK) +#define EfiAcquireLockOrFail(_LOCK) GlueEfiAcquireLockOrFail(_LOCK) +#define EfiReleaseLock(_LOCK) GlueEfiReleaseLock(_LOCK) +#define GetGlyphWidth(_UNICODECHAR) GlueGetGlyphWidth(_UNICODECHAR) +#define EfiCreateEventLegacyBoot(_LEGACYBOOT) GlueEfiCreateEventLegacyBoot(_LEGACYBOOT) +#define EfiCreateEventReadyToBoot(_READYTOBOOTEVENT) GlueEfiCreateEventReadyToBoot(_READYTOBOOTEVENT) +#define EfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE) GlueEfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE) +#define EfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID) GlueEfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID) + + +// +// EFI Lock Status +// +typedef enum { + EfiLockUninitialized = 0, + EfiLockReleased = 1, + EfiLockAcquired = 2 +} EFI_LOCK_STATE; + + +/** + This function searches the list of configuration tables stored in the EFI System + Table for a table with a GUID that matches TableGuid. If a match is found, + then a pointer to the configuration table is returned in Table, and EFI_SUCCESS + is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. + + @param TableGuid Pointer to table's GUID type.. + @param Table Pointer to the table associated with TableGuid in the EFI System Table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. + +**/ +EFI_STATUS +EFIAPI +EfiGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ); + +/** + This function causes the notification function to be executed for every protocol + of type ProtocolGuid instance that exists in the system when this function is + invoked. In addition, every time a protocol of type ProtocolGuid instance is + installed or reinstalled, the notification function is also executed. + + @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @return The notification event that was created. + +**/ +EFI_EVENT +EFIAPI +EfiCreateProtocolNotifyEvent( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, OPTIONAL + OUT VOID **Registration + ); + +/** + This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. + This event is signaled with EfiNamedEventSignal(). This provide the ability for + one or more listeners on the same event named by the GUID specified by Name. + + @param Name Supplies GUID name of the event. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @retval EFI_SUCCESS A named event was created. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventListen ( + IN CONST EFI_GUID *Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN CONST VOID *NotifyContext, OPTIONAL + OUT VOID *Registration OPTIONAL + ); + +/** + This function signals the named event specified by Name. The named event must + have been created with EfiNamedEventListen(). + + @param Name Supplies GUID name of the event. + + @retval EFI_SUCCESS A named event was signaled. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventSignal ( + IN CONST EFI_GUID *Name + ); + +/** + Returns the current TPL. + + This function returns the current TPL. There is no EFI service to directly + retrieve the current TPL. Instead, the RaiseTPL() function is used to raise + the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level + can then immediately be restored back to the current TPL level with a call + to RestoreTPL(). + + @param VOID + + @retvale EFI_TPL The current TPL. + +**/ +EFI_TPL +EFIAPI +EfiGetCurrentTpl ( + VOID + ); + +/** + This function initializes a basic mutual exclusion lock to the released state + and returns the lock. Each lock provides mutual exclusion access at its task + priority level. Since there is no preemption or multiprocessor support in EFI, + acquiring the lock only consists of raising to the locks TPL. + + @param Lock A pointer to the lock data structure to initialize. + @param Priority EFI TPL associated with the lock. + + @return The lock. + +**/ +EFI_LOCK * +EFIAPI +GlueEfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ); + +/** + This macro initializes the contents of a basic mutual exclusion lock to the + released state. Each lock provides mutual exclusion access at its task + priority level. Since there is no preemption or multiprocessor support in EFI, + acquiring the lock only consists of raising to the locks TPL. + + @param Lock A pointer to the lock data structure to initialize. + @param Priority The task priority level of the lock. + + @return The lock. + +**/ +#ifdef EFI_INITIALIZE_LOCK_VARIABLE +#undef EFI_INITIALIZE_LOCK_VARIABLE +#endif + +#define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \ + {Priority, EFI_TPL_APPLICATION, EfiLockReleased } + + +/** + + Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state. + + If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, + then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock + is not in the locked state, then DebugAssert() is called passing in the source + filename, source line number, and Lock. + + If Lock is NULL, then ASSERT(). + + @param LockParameter A pointer to the lock to acquire. + +**/ +#ifdef ASSERT_LOCKED +#undef ASSERT_LOCKED +#endif + +#define ASSERT_LOCKED(LockParameter) \ + do { \ + if (DebugAssertEnabled ()) { \ + ASSERT (LockParameter != NULL); \ + if ((LockParameter)->Lock != EfiLockAcquired) { \ + _ASSERT (LockParameter not locked); \ + } \ + } \ + } while (FALSE) + + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it places the lock in the + acquired state. + + @param Priority The task priority level of the lock. + +**/ +VOID +EFIAPI +GlueEfiAcquireLock ( + IN EFI_LOCK *Lock + ); + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it attempts to place the + lock in the acquired state. + + @param Lock A pointer to the lock to acquire. + + @retval EFI_SUCCESS The lock was acquired. + @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned. + +**/ +EFI_STATUS +EFIAPI +GlueEfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ); + +/** + This function transitions a mutual exclusion lock from the acquired state to + the released state, and restores the system's task priority level to its + previous level. + + @param Lock A pointer to the lock to release. + +**/ +VOID +EFIAPI +GlueEfiReleaseLock ( + IN EFI_LOCK *Lock + ); + +/** + Tests whether a controller handle is being managed by a specific driver. + + This function tests whether the driver specified by DriverBindingHandle is + currently managing the controller specified by ControllerHandle. This test + is performed by evaluating if the the protocol specified by ProtocolGuid is + present on ControllerHandle and is was opened by DriverBindingHandle with an + attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a controller to test. + @param DriverBindingHandle Specifies the driver binding handle for the + driver. + @param ProtocolGuid Specifies the protocol that the driver specified + by DriverBindingHandle opens in its Start() + function. + + @retval EFI_SUCCESS ControllerHandle is managed by the driver + specifed by DriverBindingHandle. + @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver + specifed by DriverBindingHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestManagedDevice ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE DriverBindingHandle, + IN CONST EFI_GUID *ProtocolGuid + ); + +/** + Tests whether a child handle is a child device of the controller. + + This function tests whether ChildHandle is one of the children of + ControllerHandle. This test is performed by checking to see if the protocol + specified by ProtocolGuid is present on ControllerHandle and opened by + ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a (parent) controller to test. + @param ChildHandle A child handle to test. + @param ConsumsedGuid Supplies the protocol that the child controller + opens on its parent controller. + + @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. + @retval EFI_UNSUPPORTED ChildHandle is not a child of the + ControllerHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestChildHandle ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE ChildHandle, + IN CONST EFI_GUID *ProtocolGuid + ); + +/** + This function looks up a Unicode string in UnicodeStringTable. If Language is + a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable + that matches the language code specified by Language, then it is returned in + UnicodeString. + + @param Language A pointer to the ISO 639-2 language code for the + Unicode string to look up and return. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. Language + must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string from UnicodeStringTable + that matches the language specified by Language. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found + in the table of Unicoide strings UnicodeStringTable, + and it was returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + @retval EFI_UNSUPPORTED The language specified by Language is not + supported by UnicodeStringTable. + +**/ +EFI_STATUS +EFIAPI +LookupUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + OUT CHAR16 **UnicodeString + ); + +/** + This function adds a Unicode string to UnicodeStringTable. + If Language is a member of SupportedLanguages then UnicodeString is added to + UnicodeStringTable. New buffers are allocated for both Language and + UnicodeString. The contents of Language and UnicodeString are copied into + these new buffers. These buffers are automatically freed when + FreeUnicodeStringTable() is called. + + @param Language A pointer to the ISO 639-2 language code for the Unicode + string to add. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. + Language must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string to add. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found in the table of + Unicode strings UnicodeStringTable, and it was + returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_ALREADY_STARTED A Unicode string with language Language is + already present in UnicodeStringTable. + @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another + Unicode string to UnicodeStringTable. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + +**/ +EFI_STATUS +EFIAPI +AddUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + IN CONST CHAR16 *UnicodeString + ); + +/** + This function frees the table of Unicode strings in UnicodeStringTable. + If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. + Otherwise, each language code, and each Unicode string in the Unicode string + table are freed, and EFI_SUCCESS is returned. + + @param UnicodeStringTable A pointer to the table of Unicode strings. + + @retval EFI_SUCCESS The Unicode string table was freed. + +**/ +EFI_STATUS +EFIAPI +FreeUnicodeStringTable ( + IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ); + +/** + This function computes and returns the width of the Unicode character + specified by UnicodeChar. + + @param UnicodeChar A Unicode character. + + @retval 0 The width if UnicodeChar could not be determined. + @retval 1 UnicodeChar is a narrow glyph. + @retval 2 UnicodeChar is a wide glyph. + +**/ +UINTN +EFIAPI +GlueGetGlyphWidth ( + IN CHAR16 UnicodeChar + ); + +/** + This function computes and returns the display length of + the Null-terminated Unicode string specified by String. + If String is NULL, then 0 is returned. + If any of the widths of the Unicode characters in String + can not be determined, then 0 is returned. + + @param String A pointer to a Null-terminated Unicode string. + + @return The display length of the Null-terminated Unicode string specified by String. + +**/ +UINTN +EFIAPI +UnicodeStringDisplayLength ( + IN CONST CHAR16 *String + ); + +// +// Functions that abstract early Framework contamination of UEFI. +// +/** + Signal a Ready to Boot Event. + + Create a Ready to Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventReadyToBoot ( + VOID + ); + +/** + Signal a Legacy Boot Event. + + Create a legacy Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventLegacyBoot ( + VOID + ); + +/** + Create a Legacy Boot Event. + + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventLegacyBoot ( + OUT EFI_EVENT *LegacyBootEvent + ); + +/** + Create an EFI event in the Legacy Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Legacy Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If LegacyBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *LegacyBootEvent + ); + +/** + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the EDK/EFI 1.10 form and EDKII/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventReadyToBoot ( + OUT EFI_EVENT *ReadyToBootEvent + ); + +/** + Create an EFI event in the Ready To Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Ready to Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If ReadyToBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToBootEvent + ); + +/** + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for Tiano extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + + @param FvDevicePathNode Pointer to a FV device path node to initialize + @param NameGuid FV file name to use in FvDevicePathNode + +**/ +VOID +EFIAPI +GlueEfiInitializeFwVolDevicepathNode ( + IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN CONST EFI_GUID *NameGuid + ); + +/** + Check to see if the Firmware Volume (FV) Media Device Path is valid + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for Tiano extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. The return value to this + function points to a location in FvDevicePathNode and it does not allocate + new memory for the GUID pointer that is returned. + + @param FvDevicePathNode Pointer to FV device path to check. + + @retval NULL FvDevicePathNode is not valid. + @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned. + +**/ +EFI_GUID * +EFIAPI +GlueEfiGetNameGuidFromFwVolDevicePathNode ( + IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ); + +/** + Prints a formatted Unicode string to the console output device specified by + ConOut defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted Unicode string to the console output device + specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode + characters that printed to ConOut. If the length of the formatted Unicode + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. + + @param Format Null-terminated Unicode format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ +UINTN +EFIAPI +Print ( + IN CONST CHAR16 *Format, + ... + ); + +/** + Prints a formatted Unicode string to the console output device specified by + StdErr defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted Unicode string to the console output device + specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode + characters that printed to StdErr. If the length of the formatted Unicode + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. + + @param Format Null-terminated Unicode format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ +UINTN +EFIAPI +ErrorPrint ( + IN CONST CHAR16 *Format, + ... + ); + +/** + Prints a formatted ASCII string to the console output device specified by + ConOut defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted ASCII string to the console output device + specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII + characters that printed to ConOut. If the length of the formatted ASCII + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. + + @param Format Null-terminated ASCII format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ +UINTN +EFIAPI +AsciiPrint ( + IN CONST CHAR8 *Format, + ... + ); + +/** + Prints a formatted ASCII string to the console output device specified by + StdErr defined in the EFI_SYSTEM_TABLE. + + This function prints a formatted ASCII string to the console output device + specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII + characters that printed to StdErr. If the length of the formatted ASCII + string is greater than PcdUefiLibMaxPrintBufferSize, then only the first + PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. + + @param Format Null-terminated ASCII format string. + @param ... VARARG list consumed to process Format. + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + +**/ +UINTN +EFIAPI +AsciiErrorPrint ( + IN CONST CHAR8 *Format, + ... + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h new file mode 100644 index 0000000000..f4bace19f4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueUefiRuntimeServicesTableLib.h + +Abstract: + + Library that provides a global pointer to the UEFI Runtime Services Tables + +--*/ + +#ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__ +#define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__ + +// +// Cached copy of the EFI Runtime Services Table +// +extern EFI_RUNTIME_SERVICES *gRT; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h new file mode 100644 index 0000000000..e60daa5f42 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcd.h + +Abstract: + + Fixed-at-build PCD macro expansion definitions + +--*/ + +#ifndef __EDKII_GLUE_PCD_H__ +#define __EDKII_GLUE_PCD_H__ + +// +// Redefine Pcd functions into compile time hardcoded values +// +#define FixedPcdGet8(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGet16(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGet32(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGet64(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define FixedPcdGetBool(TokenName) __EDKII_GLUE_PCD_##TokenName##__ + +#define PcdGet8(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGet16(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGet32(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGet64(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGetPtr(TokenName) __EDKII_GLUE_PCD_##TokenName##__ +#define PcdGetBool(TokenName) __EDKII_GLUE_PCD_##TokenName##__ + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h new file mode 100644 index 0000000000..6e89978531 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcdBaseLib.h + +Abstract: + + PCD vadues for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_BASE_LIB_H__ +#define __EDKII_GLUE_PCD_BASE_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + +#ifndef __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__ +#define __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__ EDKII_GLUE_MaximumUnicodeStringLength +#endif + +#ifndef __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__ +#define __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__ EDKII_GLUE_MaximumAsciiStringLength +#endif + +// +// SpinLock Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdSpinLockTimeout__ +#define __EDKII_GLUE_PCD_PcdSpinLockTimeout__ EDKII_GLUE_SpinLockTimeout +#endif + +// Linked List +#ifndef __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__ +#define __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__ EDKII_GLUE_MaximumLinkedListLength +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h new file mode 100644 index 0000000000..01285757a5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcdDebugLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_DEBUG_LIB_H__ +#define __EDKII_GLUE_PCD_DEBUG_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// Debug Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__ +#define __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__ EDKII_GLUE_DebugPrintErrorLevel +#endif + + +#ifndef __EDKII_GLUE_PCD_PcdDebugPropertyMask__ +#define __EDKII_GLUE_PCD_PcdDebugPropertyMask__ EDKII_GLUE_DebugPropertyMask +#endif + + +#ifndef __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__ +#define __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__ EDKII_GLUE_DebugClearMemoryValue +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h new file mode 100644 index 0000000000..1de1434283 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcdIoLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_IO_LIB_H__ +#define __EDKII_GLUE_PCD_IO_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// IoBlockBaseAddressForIpf Pcd +// +#ifdef MDE_CPU_IPF +#ifndef __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__ +#define __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__ EDKII_GLUE_IoBlockBaseAddressForIpf +#endif +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h new file mode 100644 index 0000000000..7593cebb35 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcdPciExpressLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__ +#define __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// PciExpress Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__ +#define __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__ EDKII_GLUE_PciExpressBaseAddress +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h new file mode 100644 index 0000000000..401cc55d36 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcdPostCodeLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_POST_CODE_LIB_H__ +#define __EDKII_GLUE_PCD_POST_CODE_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + +// +// PostCode Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdPostCodePropertyMask__ +#define __EDKII_GLUE_PCD_PcdPostCodePropertyMask__ EDKII_GLUE_PostCodePropertyMask +#endif + +#include "Pcd/EdkIIGluePcd.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h new file mode 100644 index 0000000000..6d4306f042 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcdReportStatusCodeLib.h + +Abstract: + + Pcd values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__ +#define __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + +// +// ReportStatusCode Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__ +#define __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__ EDKII_GLUE_ReportStatusCodePropertyMask +#endif + +#include "Pcd/EdkIIGluePcd.h" + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h new file mode 100644 index 0000000000..47d8c1c391 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGluePcdTimerLib.h + +Abstract: + + PCD values for library customization + +--*/ + +#ifndef __EDKII_GLUE_PCD_TIMER_LIB_H__ +#define __EDKII_GLUE_PCD_TIMER_LIB_H__ + +// +// Following Pcd values are hard coded at compile time. +// Override these through compiler option "/D" in PlatformTools.env if needed +// + + +// +// Timer Lib Pcds +// +#ifndef __EDKII_GLUE_PCD_PcdFSBClock__ +#define __EDKII_GLUE_PCD_PcdFSBClock__ EDKII_GLUE_FSBClock +#endif + +#include "Pcd/EdkIIGluePcd.h" +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h new file mode 100644 index 0000000000..d9e0b2027a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeimDepex.h + +Abstract: + + This file is used by .dxs file. To write common .dxs for R8.x and R9, a + header file named PeimDepex.h musted be present. + +--*/ + + +#ifndef __EDKII_GLUELIB_PEIMDEPEX_H__ +#define __EDKII_GLUELIB_PEIMDEPEX_H__ + + +// +// this file is used by .dxs file, just a place holder +// + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h new file mode 100644 index 0000000000..7d58bd3e80 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h @@ -0,0 +1,41 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueProcessorBind.h + +Abstract: + + Processor specific definitions + +--*/ + +#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__ +#define __EDKII_GLUE_PROCESSOR_BIND_H__ + +// +// The Microsoft* C compiler can removed references to unreferenced data items +// if the /OPT:REF linker option is used. We defined a macro as this is a +// a non standard extension +// +#if _MSC_EXTENSIONS + #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany) +#else + #define GLOBAL_REMOVE_IF_UNREFERENCED +#endif + +#ifndef MDE_CPU_X64 + #define MDE_CPU_X64 +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf new file mode 100644 index 0000000000..c24ff0cf02 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BaseCacheMaintenanceLib.inf +# +# Abstract: +# +# Component description file for BaseCacheMaintenanceLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseCacheMaintenanceLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + x86Cache.c + +[sources.x64] + x86Cache.c + +[sources.ipf] + IpfCache.c + +[sources.ebc] + EbcCache.c + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC + \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EbcCache.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EbcCache.c new file mode 100644 index 0000000000..585c6b4dc7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EbcCache.c @@ -0,0 +1,241 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86Cache.c + +Abstract: + + Cache Maintenance Functions. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + +**/ +VOID +EFIAPI +GlueInvalidateInstructionCache ( + VOID + ) +{ +} + +/** + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + @param Length The number of bytes to invalidate from the instruction cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + return Address; +} + +/** + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. + + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. This function guarantees that all dirty cache lines are + written back to system memory, and also invalidates all the data cache lines + in the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackInvalidateDataCache ( + VOID + ) +{ +} + +/** + Writes Back and Invalidates a range of data cache lines in the cache + coherency domain of the calling CPU. + + Writes Back and Invalidate the data cache lines specified by Address and + Length. If Address is not aligned on a cache line boundary, then entire data + cache line containing Address is written back and invalidated. If Address + + Length is not aligned on a cache line boundary, then the entire data cache + line containing Address + Length -1 is written back and invalidated. This + function may choose to write back and invalidate the entire data cache if + that is more efficient than writing back and invalidating the specified + range. If Length is 0, the no data cache lines are written back and + invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back and + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + @param Length The number of bytes to write back and invalidate from the + data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackInvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + return Address; +} + +/** + Writes Back the entire data cache in cache coherency domain of the calling + CPU. + + Writes Back the entire data cache in cache coherency domain of the calling + CPU. This function guarantees that all dirty cache lines are written back to + system memory. This function may also invalidate all the data cache lines in + the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackDataCache ( + VOID + ) +{ +} + +/** + Writes Back a range of data cache lines in the cache coherency domain of the + calling CPU. + + Writes Back the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is written back. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is written back. This function may choose to write back the entire + data cache if that is more efficient than writing back the specified range. + If Length is 0, the no data cache lines are written back. This function may + also invalidate all the data cache lines in the specified range of the cache + coherency domain of the calling CPU. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing + mode, then Address is a virtual address. + @param Length The number of bytes to write back from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + return Address; +} + +/** + Invalidates the entire data cache in cache coherency domain of the calling + CPU. + + Invalidates the entire data cache in cache coherency domain of the calling + CPU. This function must be used with care because dirty cache lines are not + written back to system memory. It is typically used for cache diagnostics. If + the CPU does not support invalidation of the entire data cache, then a write + back and invalidate operation should be performed on the entire data cache. + +**/ +VOID +EFIAPI +InvalidateDataCache ( + VOID + ) +{ +} + +/** + Invalidates a range of data cache lines in the cache coherency domain of the + calling CPU. + + Invalidates the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is invalidated. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is invalidated. This function must never invalidate any cache lines + outside the specified range. If Length is 0, the no data cache lines are + invalidated. Address is returned. This function must be used with care + because dirty cache lines are not written back to system memory. It is + typically used for cache diagnostics. If the CPU does not support + invalidation of a data cache range, then a write back and invalidate + operation should be performed on the data cache range. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to invalidate. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing mode, + then Address is a virtual address. + @param Length The number of bytes to invalidate from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + return Address; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/IpfCache.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/IpfCache.c new file mode 100644 index 0000000000..ebfaebdcdf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/IpfCache.c @@ -0,0 +1,245 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86Cache.c + +Abstract: + + Cache Maintenance Functions. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + +**/ +VOID +EFIAPI +GlueInvalidateInstructionCache ( + VOID + ) +{ + PalCallStatic (NULL, 1, 1, 1, 0); +} + +/** + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + @param Length The number of bytes to invalidate from the instruction cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + return IpfFlushCacheRange (Address, Length); +} + +/** + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. + + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. This function guarantees that all dirty cache lines are + written back to system memory, and also invalidates all the data cache lines + in the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackInvalidateDataCache ( + VOID + ) +{ + PalCallStatic (NULL, 1, 2, 1, 0); +} + +/** + Writes Back and Invalidates a range of data cache lines in the cache + coherency domain of the calling CPU. + + Writes Back and Invalidate the data cache lines specified by Address and + Length. If Address is not aligned on a cache line boundary, then entire data + cache line containing Address is written back and invalidated. If Address + + Length is not aligned on a cache line boundary, then the entire data cache + line containing Address + Length -1 is written back and invalidated. This + function may choose to write back and invalidate the entire data cache if + that is more efficient than writing back and invalidating the specified + range. If Length is 0, the no data cache lines are written back and + invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back and + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + @param Length The number of bytes to write back and invalidate from the + data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackInvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + + return IpfFlushCacheRange (Address, Length); +} + +/** + Writes Back the entire data cache in cache coherency domain of the calling + CPU. + + Writes Back the entire data cache in cache coherency domain of the calling + CPU. This function guarantees that all dirty cache lines are written back to + system memory. This function may also invalidate all the data cache lines in + the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackDataCache ( + VOID + ) +{ + PalCallStatic (NULL, 1, 2, 0, 0); +} + +/** + Writes Back a range of data cache lines in the cache coherency domain of the + calling CPU. + + Writes Back the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is written back. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is written back. This function may choose to write back the entire + data cache if that is more efficient than writing back the specified range. + If Length is 0, the no data cache lines are written back. This function may + also invalidate all the data cache lines in the specified range of the cache + coherency domain of the calling CPU. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing + mode, then Address is a virtual address. + @param Length The number of bytes to write back from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + + return IpfFlushCacheRange (Address, Length); +} + +/** + Invalidates the entire data cache in cache coherency domain of the calling + CPU. + + Invalidates the entire data cache in cache coherency domain of the calling + CPU. This function must be used with care because dirty cache lines are not + written back to system memory. It is typically used for cache diagnostics. If + the CPU does not support invalidation of the entire data cache, then a write + back and invalidate operation should be performed on the entire data cache. + +**/ +VOID +EFIAPI +InvalidateDataCache ( + VOID + ) +{ + WriteBackInvalidateDataCache (); +} + +/** + Invalidates a range of data cache lines in the cache coherency domain of the + calling CPU. + + Invalidates the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is invalidated. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is invalidated. This function must never invalidate any cache lines + outside the specified range. If Length is 0, the no data cache lines are + invalidated. Address is returned. This function must be used with care + because dirty cache lines are not written back to system memory. It is + typically used for cache diagnostics. If the CPU does not support + invalidation of a data cache range, then a write back and invalidate + operation should be performed on the data cache range. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to invalidate. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing mode, + then Address is a virtual address. + @param Length The number of bytes to invalidate from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + return IpfFlushCacheRange (Address, Length); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c new file mode 100644 index 0000000000..2e2cb767c8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c @@ -0,0 +1,262 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86Cache.c + +Abstract: + + Cache Maintenance Functions. + +--*/ + +#include "EdkIIGlueBase.h" + +// +// This size must be at or below the smallest cache size possible among all +// supported processors +// +#define CACHE_LINE_SIZE 0x20 + +/** + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + + Invalidates the entire instruction cache in cache coherency domain of the + calling CPU. + +**/ +VOID +EFIAPI +GlueInvalidateInstructionCache ( + VOID + ) +{ +} + +/** + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + @param Length The number of bytes to invalidate from the instruction cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + return Address; +} + +/** + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. + + Writes Back and Invalidates the entire data cache in cache coherency domain + of the calling CPU. This function guarantees that all dirty cache lines are + written back to system memory, and also invalidates all the data cache lines + in the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackInvalidateDataCache ( + VOID + ) +{ + AsmWbinvd (); +} + +/** + Writes Back and Invalidates a range of data cache lines in the cache + coherency domain of the calling CPU. + + Writes Back and Invalidate the data cache lines specified by Address and + Length. If Address is not aligned on a cache line boundary, then entire data + cache line containing Address is written back and invalidated. If Address + + Length is not aligned on a cache line boundary, then the entire data cache + line containing Address + Length -1 is written back and invalidated. This + function may choose to write back and invalidate the entire data cache if + that is more efficient than writing back and invalidating the specified + range. If Length is 0, the no data cache lines are written back and + invalidated. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back and + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + @param Length The number of bytes to write back and invalidate from the + data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackInvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + UINTN Start, End; + + ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1); + + if (Length == 0) { + return Address; + } + + Start = (UINTN)Address; + End = (Start + Length + (CACHE_LINE_SIZE - 1)) & ~(CACHE_LINE_SIZE - 1); + Start &= ~(CACHE_LINE_SIZE - 1); + + do { + Start = (UINTN)AsmFlushCacheLine ((VOID*)Start) + CACHE_LINE_SIZE; + } while (Start != End); + return Address; +} + +/** + Writes Back the entire data cache in cache coherency domain of the calling + CPU. + + Writes Back the entire data cache in cache coherency domain of the calling + CPU. This function guarantees that all dirty cache lines are written back to + system memory. This function may also invalidate all the data cache lines in + the cache coherency domain of the calling CPU. + +**/ +VOID +EFIAPI +WriteBackDataCache ( + VOID + ) +{ + WriteBackInvalidateDataCache (); +} + +/** + Writes Back a range of data cache lines in the cache coherency domain of the + calling CPU. + + Writes Back the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is written back. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is written back. This function may choose to write back the entire + data cache if that is more efficient than writing back the specified range. + If Length is 0, the no data cache lines are written back. This function may + also invalidate all the data cache lines in the specified range of the cache + coherency domain of the calling CPU. Address is returned. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to write back. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing + mode, then Address is a virtual address. + @param Length The number of bytes to write back from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +WriteBackDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + return WriteBackInvalidateDataCacheRange (Address, Length); +} + +/** + Invalidates the entire data cache in cache coherency domain of the calling + CPU. + + Invalidates the entire data cache in cache coherency domain of the calling + CPU. This function must be used with care because dirty cache lines are not + written back to system memory. It is typically used for cache diagnostics. If + the CPU does not support invalidation of the entire data cache, then a write + back and invalidate operation should be performed on the entire data cache. + +**/ +VOID +EFIAPI +InvalidateDataCache ( + VOID + ) +{ + AsmInvd (); +} + +/** + Invalidates a range of data cache lines in the cache coherency domain of the + calling CPU. + + Invalidates the data cache lines specified by Address and Length. If Address + is not aligned on a cache line boundary, then entire data cache line + containing Address is invalidated. If Address + Length is not aligned on a + cache line boundary, then the entire data cache line containing Address + + Length -1 is invalidated. This function must never invalidate any cache lines + outside the specified range. If Length is 0, the no data cache lines are + invalidated. Address is returned. This function must be used with care + because dirty cache lines are not written back to system memory. It is + typically used for cache diagnostics. If the CPU does not support + invalidation of a data cache range, then a write back and invalidate + operation should be performed on the data cache range. + + If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). + + @param Address The base address of the data cache lines to invalidate. If + the CPU is in a physical addressing mode, then Address is a + physical address. If the CPU is in a virtual addressing mode, + then Address is a virtual address. + @param Length The number of bytes to invalidate from the data cache. + + @return Address + +**/ +VOID * +EFIAPI +InvalidateDataCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +{ + return WriteBackInvalidateDataCacheRange (Address, Length); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf new file mode 100644 index 0000000000..4b33115fc1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf @@ -0,0 +1,79 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BaseDebugLibNull.inf +# +# Abstract: +# +# Component description file for BaseDebugLibNull. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseDebugLibNull +COMPONENT_TYPE = LIBRARY + +[sources.common] + DebugLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueBasePrintLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c new file mode 100644 index 0000000000..6ce2f49f34 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c @@ -0,0 +1,193 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DebugLib.c + +Abstract: + + Base Debug Library that uses PrintLib to print messages to a memory buffer. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ) +{ +} + + +/** + + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. + + Print a message of the form "ASSERT (): \n" + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. + + If FileName is NULL, then a string of "(NULL) Filename" is printed. + + If Description is NULL, then a string of "(NULL) Description" is printed. + + @param FileName Pointer to the name of the source file that generated the assert condition. + @param LineNumber The line number in the source file that generated the assert condition + @param Description Pointer to the description of the assert condition. + +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) +{ +} + + +/** + + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. + + This function fills Length bytes of Buffer with the value specified by + PcdDebugClearMemoryValue, and returns Buffer. + + If Buffer is NULL, then ASSERT(). + + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + + @return Buffer + +**/ +VOID * +EFIAPI +DebugClearMemory ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + return Buffer; +} + + +/** + + Returns TRUE if ASSERT() macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugAssertEnabled ( + VOID + ) +{ + return FALSE; +} + + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugPrintEnabled ( + VOID + ) +{ + return FALSE; +} + + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugCodeEnabled ( + VOID + ) +{ + return FALSE; +} + + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugClearMemoryEnabled ( + VOID + ) +{ + return FALSE; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf new file mode 100644 index 0000000000..1feeb5c2d0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf @@ -0,0 +1,85 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BaseIoLibIntrinsic.inf +# +# Abstract: +# +# Component description file for BaseIoLibIntrinsic. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseIoLibIntrinsic +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + IoLib.c + IoLibMsc.c + IoHighLevel.c + +[sources.x64] + IoLib.c + IoLibMsc.c + IoHighLevel.c + +[sources.ipf] + IoLibIpf.c + IoHighLevel.c + +[sources.ebc] +# doesn't support EBC + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c new file mode 100644 index 0000000000..c843be5291 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c @@ -0,0 +1,2280 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IoHighLevel.c + +Abstract: + + High-level Io/Mmio functions. + + All assertions for bit field operations are handled bit field functions in the + Base Library. + + The following IoLib instances share the same version of this file: + + BaseIoLibIntrinsic + DxeIoLibCpuIo + PeiIoLibCpuIo + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoOr8 ( + IN UINTN Port, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData)); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back + to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAnd8 ( + IN UINTN Port, + IN UINT8 AndData + ) +{ + return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData)); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 8-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAndThenOr8 ( + IN UINTN Port, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData)); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in an 8-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoBitFieldRead8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldWrite8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return IoWrite8 ( + Port, + BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAnd8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return IoWrite8 ( + Port, + BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 8-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAndThenOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoOr16 ( + IN UINTN Port, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData)); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back + to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAnd16 ( + IN UINTN Port, + IN UINT16 AndData + ) +{ + return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData)); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 16-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAndThenOr16 ( + IN UINTN Port, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData)); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 16-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoBitFieldRead16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldWrite16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return IoWrite16 ( + Port, + BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAnd16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return IoWrite16 ( + Port, + BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 16-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAndThenOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoOr32 ( + IN UINTN Port, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) | OrData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back + to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAnd32 ( + IN UINTN Port, + IN UINT32 AndData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) & AndData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 32-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAndThenOr32 ( + IN UINTN Port, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 32-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoBitFieldRead32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldWrite32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return IoWrite32 ( + Port, + BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAnd32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return IoWrite32 ( + Port, + BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 32-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAndThenOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoOr64 ( + IN UINTN Port, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) | OrData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back + to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAnd64 ( + IN UINTN Port, + IN UINT64 AndData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) & AndData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAndThenOr64 ( + IN UINTN Port, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 64-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoBitFieldRead64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldWrite64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return IoWrite64 ( + Port, + BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAnd64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return IoWrite64 ( + Port, + BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAndThenOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData)); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result + back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData)); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 8-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in an 8-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 8-bit register is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return MmioWrite8 ( + Address, + BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 8-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData)); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result + back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData)); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 16-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 16-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 16-bit register is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return MmioWrite16 ( + Address, + BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 16-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) | OrData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result + back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) & AndData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 32-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 32-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 32-bit register is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return MmioWrite32 ( + Address, + BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 32-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioOr64 ( + IN UINTN Address, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) | OrData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result + back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAnd64 ( + IN UINTN Address, + IN UINT64 AndData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) & AndData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 64-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAndThenOr64 ( + IN UINTN Address, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 64-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioBitFieldRead64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 64-bit register is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldWrite64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return MmioWrite64 ( + Address, + BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAnd64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 64-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAndThenOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData) + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c new file mode 100644 index 0000000000..c24d0bc370 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IoLib.c + +Abstract: + + Common I/O Library routines. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads a 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoRead64 ( + IN UINTN Port + ) +{ + ASSERT (FALSE); + return 0; +} + +/** + Writes a 64-bit I/O port. + + Writes the 64-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT64 +EFIAPI +IoWrite64 ( + IN UINTN Port, + IN UINT64 Value + ) +{ + ASSERT (FALSE); + return 0; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIpf.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIpf.c new file mode 100644 index 0000000000..dc999c3e87 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibIpf.c @@ -0,0 +1,490 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IoLibIpf.c + +Abstract: + + +--*/ + +#include "EdkIIGlueBase.h" + +#define BIT63 0x8000000000000000UL + +#define MAP_PORT_BASE_TO_MEM(_Port) \ + ((((_Port) & 0xfffc) << 10) | ((_Port) & 0x0fff)) + +/** + Reads a 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoRead8 ( + IN UINT64 Port + ) +{ + UINT64 Address; + + // + // Add the 64MB aligned IO Port space to the IO address + // + Address = MAP_PORT_BASE_TO_MEM (Port); + Address += PcdGet64(PcdIoBlockBaseAddressForIpf); + + return MmioRead8 (Address); +} + +/** + Reads a 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoRead16 ( + IN UINT64 Port + ) +{ + UINT64 Address; + + // + // Add the 64MB aligned IO Port space to the IO address + // + Address = MAP_PORT_BASE_TO_MEM (Port); + Address += PcdGet64(PcdIoBlockBaseAddressForIpf); + + return MmioRead16 (Address); +} + +/** + Reads a 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoRead32 ( + IN UINT64 Port + ) +{ + UINT64 Address; + + // + // Add the 64MB aligned IO Port space to the IO address + // + Address = MAP_PORT_BASE_TO_MEM (Port); + Address += PcdGet64(PcdIoBlockBaseAddressForIpf); + + return MmioRead32 (Address); +} + +/** + Reads a 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoRead64 ( + IN UINTN Port + ) +{ + ASSERT (FALSE); + return 0; +} + +/** + Writes a 8-bit I/O port. + + Writes the 8-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT8 +EFIAPI +IoWrite8 ( + IN UINT64 Port, + IN UINT8 Data + ) +{ + UINT64 Address; + + // + // Add the 64MB aligned IO Port space to the IO address + // + Address = MAP_PORT_BASE_TO_MEM (Port); + Address += PcdGet64(PcdIoBlockBaseAddressForIpf); + + return MmioWrite8 (Address, Data); +} + +/** + Writes a 16-bit I/O port. + + Writes the 16-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT16 +EFIAPI +IoWrite16 ( + IN UINT64 Port, + IN UINT16 Data + ) +{ + UINT64 Address; + + // + // Add the 64MB aligned IO Port space to the IO address + // + Address = MAP_PORT_BASE_TO_MEM (Port); + Address += PcdGet64(PcdIoBlockBaseAddressForIpf); + + return MmioWrite16 (Address, Data); +} + +/** + Writes a 32-bit I/O port. + + Writes the 32-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT32 +EFIAPI +IoWrite32 ( + IN UINT64 Port, + IN UINT32 Data + ) +{ + UINT64 Address; + + // + // Add the 64MB aligned IO Port space to the IO address + // + Address = MAP_PORT_BASE_TO_MEM (Port); + Address += PcdGet64(PcdIoBlockBaseAddressForIpf); + + return MmioWrite32 (Address, Data); +} + +/** + Writes a 64-bit I/O port. + + Writes the 64-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT64 +EFIAPI +IoWrite64 ( + IN UINTN Port, + IN UINT64 Value + ) +{ + ASSERT (FALSE); + return 0; +} + +/** + Reads a 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioRead8 ( + IN UINT64 Address + ) +{ + UINT8 Data; + + Address |= BIT63; + + MemoryFence (); + Data = *((volatile UINT8 *) Address); + MemoryFence (); + + return Data; +} + +/** + Reads a 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioRead16 ( + IN UINT64 Address + ) +{ + UINT16 Data; + + Address |= BIT63; + + MemoryFence (); + Data = *((volatile UINT16 *) Address); + MemoryFence (); + + return Data; +} + +/** + Reads a 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioRead32 ( + IN UINT64 Address + ) +{ + UINT32 Data; + + Address |= BIT63; + + MemoryFence (); + Data = *((volatile UINT32 *) Address); + MemoryFence (); + + return Data; +} + +/** + Reads a 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioRead64 ( + IN UINT64 Address + ) +{ + UINT64 Data; + + Address |= BIT63; + + MemoryFence (); + Data = *((volatile UINT64 *) Address); + MemoryFence (); + + return Data; + +} + +/** + Writes a 8-bit MMIO register. + + Writes the 8-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + @param Address The MMIO register to write. + @param Data The value to write to the MMIO register. + + @return The value written the memory address. + +**/ +UINT8 +EFIAPI +MmioWrite8 ( + IN UINT64 Address, + IN UINT8 Data + ) +{ + Address |= BIT63; + + MemoryFence (); + *((volatile UINT8 *) Address) = Data; + MemoryFence (); + + return Data; +} + +/** + Writes a 16-bit MMIO register. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + @param Address The MMIO register to write. + @param Data The value to write to the MMIO register. + + @return The value written the memory address. + +**/ +UINT16 +EFIAPI +MmioWrite16 ( + IN UINT64 Address, + IN UINT16 Data + ) +{ + Address |= BIT63; + + MemoryFence (); + *((volatile UINT16 *) Address) = Data; + MemoryFence (); + + return Data; +} + +/** + Writes a 32-bit MMIO register. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + @param Address The MMIO register to write. + @param Data The value to write to the MMIO register. + + @return The value written the memory address. + +**/ +UINT32 +EFIAPI +MmioWrite32 ( + IN UINT64 Address, + IN UINT32 Data + ) +{ + Address |= BIT63; + + MemoryFence (); + *((volatile UINT32 *) Address) = Data; + MemoryFence (); + + return Data; +} + +/** + Writes a 64-bit MMIO register. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + @param Address The MMIO register to write. + @param Data The value to write to the MMIO register. + + @return The value written the memory address. + +**/ +UINT64 +EFIAPI +MmioWrite64 ( + IN UINT64 Address, + IN UINT64 Data + ) +{ + Address |= BIT63; + + MemoryFence (); + *((volatile UINT64 *) Address) = Data; + MemoryFence (); + + return Data; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c new file mode 100644 index 0000000000..7b78e273cc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c @@ -0,0 +1,436 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IoLibMsc.c + +Abstract: + + I/O Library. This file has compiler specifics for Microsft C as there is no + ANSI C standard for doing IO. + + MSC - uses intrinsic functions and the optimize will remove the function call + overhead. + + We don't advocate putting compiler specifics in libraries or drivers but there + is no other way to make this work. + +--*/ + +#include "EdkIIGlueBase.h" + +#if _MSC_EXTENSIONS + +// +// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics +// +int _inp (unsigned short port); +unsigned short _inpw (unsigned short port); +unsigned long _inpd (unsigned short port); +int _outp (unsigned short port, int databyte ); +unsigned short _outpw (unsigned short port, unsigned short dataword ); +unsigned long _outpd (unsigned short port, unsigned long dataword ); +void _ReadWriteBarrier (void); + +#pragma intrinsic(_inp) +#pragma intrinsic(_inpw) +#pragma intrinsic(_inpd) +#pragma intrinsic(_outp) +#pragma intrinsic(_outpw) +#pragma intrinsic(_outpd) +#pragma intrinsic(_ReadWriteBarrier) + +// +// _ReadWriteBarrier() forces memory reads and writes to complete at the point +// in the call. This is only a hint to the compiler and does emit code. +// In past versions of the compiler, _ReadWriteBarrier was enforced only +// locally and did not affect functions up the call tree. In Visual C++ +// 2005, _ReadWriteBarrier is enforced all the way up the call tree. +// + +/** + Reads an 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +GlueIoRead8 ( + IN UINTN Port + ) +{ + UINT8 Value; + + _ReadWriteBarrier (); + Value = (UINT8)_inp ((UINT16)Port); + _ReadWriteBarrier (); + return Value; +} + +/** + Writes an 8-bit I/O port. + + Writes the 8-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT8 +EFIAPI +GlueIoWrite8 ( + IN UINTN Port, + IN UINT8 Value + ) +{ + _ReadWriteBarrier (); + (UINT8)_outp ((UINT16)Port, Value); + _ReadWriteBarrier (); + return Value; +} + +/** + Reads a 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +GlueIoRead16 ( + IN UINTN Port + ) +{ + UINT16 Value; + + ASSERT ((Port & 1) == 0); + _ReadWriteBarrier (); + Value = _inpw ((UINT16)Port); + _ReadWriteBarrier (); + return Value; +} + +/** + Writes a 16-bit I/O port. + + Writes the 16-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT16 +EFIAPI +GlueIoWrite16 ( + IN UINTN Port, + IN UINT16 Value + ) +{ + ASSERT ((Port & 1) == 0); + _ReadWriteBarrier (); + _outpw ((UINT16)Port, Value); + _ReadWriteBarrier (); + return Value; +} + +/** + Reads a 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +GlueIoRead32 ( + IN UINTN Port + ) +{ + UINT32 Value; + + ASSERT ((Port & 3) == 0); + _ReadWriteBarrier (); + Value = _inpd ((UINT16)Port); + _ReadWriteBarrier (); + return Value; +} + +/** + Writes a 32-bit I/O port. + + Writes the 32-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT32 +EFIAPI +GlueIoWrite32 ( + IN UINTN Port, + IN UINT32 Value + ) +{ + ASSERT ((Port & 3) == 0); + _ReadWriteBarrier (); + _outpd ((UINT16)Port, Value); + _ReadWriteBarrier (); + return Value; +} + + +/** + Reads an 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioRead8 ( + IN UINTN Address + ) +{ + UINT8 Value; + + Value = *(volatile UINT8*)Address; + return Value; +} + +/** + Writes an 8-bit MMIO register. + + Writes the 8-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioWrite8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + return *(volatile UINT8*)Address = Value; +} + +/** + Reads a 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioRead16 ( + IN UINTN Address + ) +{ + UINT16 Value; + + ASSERT ((Address & 1) == 0); + Value = *(volatile UINT16*)Address; + return Value; +} + +/** + Writes a 16-bit MMIO register. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWrite16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + ASSERT ((Address & 1) == 0); + return *(volatile UINT16*)Address = Value; +} + +/** + Reads a 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioRead32 ( + IN UINTN Address + ) +{ + UINT32 Value; + + ASSERT ((Address & 3) == 0); + Value = *(volatile UINT32*)Address; + return Value; +} + +/** + Writes a 32-bit MMIO register. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWrite32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + ASSERT ((Address & 3) == 0); + return *(volatile UINT32*)Address = Value; +} + +/** + Reads a 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioRead64 ( + IN UINTN Address + ) +{ + UINT64 Value; + + ASSERT ((Address & 7) == 0); + Value = *(volatile UINT64*)Address; + return Value; +} + +/** + Writes a 64-bit MMIO register. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWrite64 ( + IN UINTN Address, + IN UINT64 Value + ) +{ + ASSERT ((Address & 7) == 0); + return *(volatile UINT64*)Address = Value; +} + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c new file mode 100644 index 0000000000..2dbf61d1da --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ARShiftU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled + with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand arithmetically shifted right by Count + +**/ +UINT64 +EFIAPI +ARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathARShiftU64 (Operand, Count); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf new file mode 100644 index 0000000000..40b2824350 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf @@ -0,0 +1,361 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BaseLib.inf +# +# Abstract: +# +# Component description file for BaseLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + String.c + LinkedList.c + Synchronization.c + Cpu.c + CpuDeadLoop.c + BitField.c + ARShiftU64.c + DivS64x64Remainder.c + DivU64x32.c + DivU64x32Remainder.c + DivU64x64Remainder.c + GetPowerOfTwo32.c + GetPowerOfTwo64.c + HighBitSet32.c + HighBitSet64.c + LowBitSet32.c + LowBitSet64.c + LRotU32.c + LRotU64.c + LShiftU64.c + ModU64x32.c + MultS64x64.c + MultU64x32.c + MultU64x64.c + RRotU32.c + RRotU64.c + RShiftU64.c + SetJump.c + LongJump.c + SwapBytes16.c + SwapBytes32.c + SwapBytes64.c + SwitchStack.c + +[sources.ia32] + x86DisablePaging32.c + x86DisablePaging64.c + x86EnablePaging32.c + x86EnablePaging64.c + x86FxRestore.c + x86FxSave.c + x86GetInterruptState.c + x86MemoryFence.c + x86Msr.c + x86ReadGdtr.c + x86ReadIdtr.c + x86Thunk.c + x86WriteGdtr.c + x86WriteIdtr.c + Unaligned.c + Ia32\Non-existing.c + Ia32\InternalSwitchStack.c + Ia32\DivS64x64Remainder.c + Ia32\ARShiftU64.asm + Ia32\CpuBreakpoint.asm + Ia32\CpuFlushTlb.asm + Ia32\CpuSleep.asm + Ia32\CpuId.asm + Ia32\CpuIdEx.asm + Ia32\CpuPause.asm + Ia32\DisableInterrupts.asm + Ia32\DisablePaging32.asm + Ia32\DivU64x32.asm + Ia32\DivU64x32Remainder.asm + Ia32\DivU64x64Remainder.asm + Ia32\EnableDisableInterrupts.asm + Ia32\EnableInterrupts.asm + Ia32\EnablePaging32.asm + Ia32\EnablePaging64.asm + Ia32\FlushCacheLine.asm + Ia32\FxSave.asm + Ia32\FxRestore.asm + Ia32\InterlockedIncrement.asm + Ia32\InterlockedDecrement.asm + Ia32\InterlockedCompareExchange32.asm + Ia32\InterlockedCompareExchange64.asm + Ia32\Invd.asm + Ia32\LongJump.asm + Ia32\LRotU64.asm + Ia32\LShiftU64.asm + Ia32\MultU64x32.asm + Ia32\MultU64x64.asm + Ia32\ModU64x32.asm + Ia32\Monitor.asm + Ia32\Mwait.asm + Ia32\ReadCr0.asm + Ia32\ReadCr2.asm + Ia32\ReadCr3.asm + Ia32\ReadCr4.asm + Ia32\ReadDr0.asm + Ia32\ReadDr1.asm + Ia32\ReadDr2.asm + Ia32\ReadDr3.asm + Ia32\ReadDr4.asm + Ia32\ReadDr5.asm + Ia32\ReadDr6.asm + Ia32\ReadDr7.asm + Ia32\ReadEflags.asm + Ia32\ReadMm0.asm + Ia32\ReadMm1.asm + Ia32\ReadMm2.asm + Ia32\ReadMm3.asm + Ia32\ReadMm4.asm + Ia32\ReadMm5.asm + Ia32\ReadMm6.asm + Ia32\ReadMm7.asm + Ia32\ReadMsr64.asm + Ia32\ReadCs.asm + Ia32\ReadDs.asm + Ia32\ReadEs.asm + Ia32\ReadFs.asm + Ia32\ReadGs.asm + Ia32\ReadSs.asm + Ia32\ReadTr.asm + Ia32\ReadGdtr.asm + Ia32\ReadIdtr.asm + Ia32\ReadLdtr.asm + Ia32\ReadTsc.asm + Ia32\ReadPmc.asm + Ia32\RShiftU64.asm + Ia32\RRotU64.asm + Ia32\SetJump.asm + Ia32\SwapBytes64.asm + Ia32\Thunk16.asm + Ia32\WriteMsr64.asm + Ia32\WriteCr0.asm + Ia32\WriteCr2.asm + Ia32\WriteCr3.asm + Ia32\WriteCr4.asm + Ia32\WriteDr0.asm + Ia32\WriteDr1.asm + Ia32\WriteDr2.asm + Ia32\WriteDr3.asm + Ia32\WriteDr4.asm + Ia32\WriteDr5.asm + Ia32\WriteDr6.asm + Ia32\WriteDr7.asm + Ia32\WriteGdtr.asm + Ia32\WriteIdtr.asm + Ia32\WriteLdtr.asm + Ia32\WriteMm0.asm + Ia32\WriteMm1.asm + Ia32\WriteMm2.asm + Ia32\WriteMm3.asm + Ia32\WriteMm4.asm + Ia32\WriteMm5.asm + Ia32\WriteMm6.asm + Ia32\WriteMm7.asm + Ia32\Wbinvd.asm + +[sources.x64] + x86DisablePaging32.c + x86DisablePaging64.c + x86EnablePaging32.c + x86EnablePaging64.c + x86FxRestore.c + x86FxSave.c + x86GetInterruptState.c + x86MemoryFence.c + x86Msr.c + x86ReadGdtr.c + x86ReadIdtr.c + x86Thunk.c + x86WriteGdtr.c + x86WriteIdtr.c + Unaligned.c + Math64.c + X64\Non-existing.c + X64\SwitchStack.asm + X64\SetJump.asm + X64\LongJump.asm + X64\CpuId.asm + X64\CpuIdEx.asm + X64\ReadEflags.asm + X64\ReadMsr64.asm + X64\WriteMsr64.asm + X64\ReadCr0.asm + X64\ReadCr2.asm + X64\ReadCr3.asm + X64\ReadCr4.asm + X64\WriteCr0.asm + X64\WriteCr2.asm + X64\WriteCr3.asm + X64\WriteCr4.asm + X64\ReadDr0.asm + X64\ReadDr1.asm + X64\ReadDr2.asm + X64\ReadDr3.asm + X64\ReadDr4.asm + X64\ReadDr5.asm + X64\ReadDr6.asm + X64\ReadDr7.asm + X64\WriteDr0.asm + X64\WriteDr1.asm + X64\WriteDr2.asm + X64\WriteDr3.asm + X64\WriteDr4.asm + X64\WriteDr5.asm + X64\WriteDr6.asm + X64\WriteDr7.asm + X64\ReadCs.asm + X64\ReadDs.asm + X64\ReadEs.asm + X64\ReadFs.asm + X64\ReadGs.asm + X64\ReadSs.asm + X64\ReadTr.asm + X64\ReadGdtr.asm + X64\WriteGdtr.asm + X64\ReadIdtr.asm + X64\WriteIdtr.asm + X64\ReadLdtr.asm + X64\WriteLdtr.asm + X64\FxSave.asm + X64\FxRestore.asm + X64\ReadMm0.asm + X64\ReadMm1.asm + X64\ReadMm2.asm + X64\ReadMm3.asm + X64\ReadMm4.asm + X64\ReadMm5.asm + X64\ReadMm6.asm + X64\ReadMm7.asm + X64\WriteMm0.asm + X64\WriteMm1.asm + X64\WriteMm2.asm + X64\WriteMm3.asm + X64\WriteMm4.asm + X64\WriteMm5.asm + X64\WriteMm6.asm + X64\WriteMm7.asm + X64\ReadTsc.asm + X64\ReadPmc.asm + X64\Monitor.asm + X64\Mwait.asm + X64\EnablePaging64.asm + X64\DisablePaging64.asm + X64\Wbinvd.asm + X64\Invd.asm + X64\FlushCacheLine.asm + X64\InterlockedIncrement.asm + X64\InterlockedDecrement.asm + X64\InterlockedCompareExchange32.asm + X64\InterlockedCompareExchange64.asm + X64\EnableInterrupts.asm + X64\DisableInterrupts.asm + X64\EnableDisableInterrupts.asm + X64\CpuSleep.asm + X64\CpuPause.asm + X64\CpuBreakpoint.asm + X64\CpuFlushTlb.asm + X64\Thunk16.asm + +[sources.ipf] + Math64.c + Ipf\asm.h + Ipf\ia_64gen.h + Ipf\PalCallStatic.s + Ipf\setjmp.s + Ipf\longjmp.s + Ipf\SwitchStack.s + Ipf\Unaligned.c + Ipf\CpuBreakpoint.c + Ipf\InterlockedCompareExchange32.s + Ipf\InterlockedCompareExchange64.s + Ipf\Synchronization.c + Ipf\CpuPause.s + Ipf\CpuFlushTlb.s + Ipf\GetInterruptState.s + Ipf\Non-existing.c + Ipf\FlushCacheRange.s + Ipf\ReadItc.s + +[sources.ebc] + Math64.c + Unaligned.c + Ebc\SwitchStack.c + Ebc\SetJumpLongJump.c + Ebc\CpuBreakpoint.c + Ebc\Synchronization.c + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[includes.IA32] + ..\..\Include\Ia32 + +[includes.X64] + ..\..\Include\x64 + + +[libraries.common] +# +# Actually, BaesLib may refer +# BaseTimerLibLocalApic::GetPerformanceCounter()in AcquireSpinLock() +# BaseMemoryLib::ZeroMem() in StrnCpy() +# + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC + \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h new file mode 100644 index 0000000000..1ed70853c4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h @@ -0,0 +1,813 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + BaseLibInternal.h + +Abstract: + + Declaration of internal functions in BaseLib. + +--*/ + +#ifndef __BASE_LIB_INTERNAL_H__ +#define __BASE_LIB_INTERNAL_H__ + +#include "EdkIIGlueBase.h" + +#define QUIENT_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 / 10) +#define REMINDER_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 % 10) + +#define QUIENT_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 / 16) +#define REMINDER_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 % 16) + +#define QUIENT_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 / 10) +#define REMINDER_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 % 10) + +#define QUIENT_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 / 16) +#define REMINDER_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 % 16) + +// +// Math functions +// + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +InternalMathLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +InternalMathRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits + are filled with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand arithmetically shifted right by Count + +**/ +UINT64 +EFIAPI +InternalMathARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling + the low bits with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +InternalMathLRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling + the high bits with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +InternalMathRRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +InternalMathSwapBytes64 ( + IN UINT64 Operand + ); + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ); + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +InternalMathModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ); + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder + ); + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x64 ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder + ); + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and + generates a 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +InternalMathDivRemS64x64 ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ); + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +InternalSwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, + IN VOID *Context2, + IN VOID *NewStack + ); + +// +// Ia32 and x64 specific functions +// + +/** + Reads the current Global Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current GDTR descriptor and returns it in Gdtr. This + function is only available on IA-32 and X64. + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86ReadGdtr ( + OUT IA32_DESCRIPTOR *Gdtr + ); + +/** + Writes the current Global Descriptor Table Register (GDTR) descriptor. + + Writes and the current GDTR descriptor specified by Gdtr. This function is + only available on IA-32 and X64. + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86WriteGdtr ( + IN CONST IA32_DESCRIPTOR *Gdtr + ); + +/** + Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current IDTR descriptor and returns it in Idtr. This + function is only available on IA-32 and X64. + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86ReadIdtr ( + OUT IA32_DESCRIPTOR *Idtr + ); + +/** + Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Writes the current IDTR descriptor and returns it in Idtr. This function is + only available on IA-32 and X64. + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +InternalX86WriteIdtr ( + IN CONST IA32_DESCRIPTOR *Idtr + ); + +/** + Save the current floating point/SSE/SSE2 context to a buffer. + + Saves the current floating point/SSE/SSE2 state to the buffer specified by + Buffer. Buffer must be aligned on a 16-byte boundary. This function is only + available on IA-32 and X64. + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +InternalX86FxSave ( + OUT IA32_FX_BUFFER *Buffer + ); + +/** + Restores the current floating point/SSE/SSE2 context from a buffer. + + Restores the current floating point/SSE/SSE2 state from the buffer specified + by Buffer. Buffer must be aligned on a 16-byte boundary. This function is + only available on IA-32 and X64. + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +InternalX86FxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ); + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +InternalX86EnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ); + +/** + Enables the 64-bit paging mode on the CPU. + + Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode with flat + descriptors. This function is only available on IA-32. After the 64-bit + paging mode is enabled, control is transferred to the function specified by + EntryPoint using the new stack specified by NewStack and passing in the + parameters specified by Context1 and Context2. Context1 and Context2 are + optional and may be 0. The function EntryPoint must never return. + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for long mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is enabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is enabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is enabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is enabled. + +**/ +VOID +EFIAPI +InternalX86EnablePaging64 ( + IN UINT16 Cs, + IN UINT64 EntryPoint, + IN UINT64 Context1, OPTIONAL + IN UINT64 Context2, OPTIONAL + IN UINT64 NewStack + ); + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging64 ( + IN UINT16 Cs, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ); + +/** + Worker function that locates the Node in the List + + By searching the List, finds the location of the Node in List. At the same time, + verifies the validity of this list. + + If List is NULL, then ASSERT(). + If List->ForwardLink is NULL, then ASSERT(). + If List->backLink is NULL, then ASSERT(). + If Node is NULL, then ASSERT(); + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param List A pointer to a node in a linked list. + @param Node A pointer to one nod. + + @retval TRUE Node is in List + @retval FALSE Node isn't in List, or List is invalid + +**/ +BOOLEAN +IsNodeInList ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ); + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InternalSyncIncrement ( + IN volatile UINT32 *Value + ); + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decrement value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to decrement. + + @return The decrement value. + +**/ +UINT32 +EFIAPI +InternalSyncDecrement ( + IN volatile UINT32 *Value + ); + +/** + Performs an atomic compare exchange operation on a 32-bit unsigned integer. + + Performs an atomic compare exchange operation on the 32-bit unsigned integer + specified by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, + then Value is returned. The compare exchange operation must be performed using + MP safe mechanisms. + + @param Value A pointer to the 32-bit value for the compare exchange + operation. + @param CompareValue 32-bit value used in compare operation. + @param ExchangeValue 32-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT32 +EFIAPI +InternalSyncCompareExchange32 ( + IN volatile UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ); + +/** + Performs an atomic compare exchange operation on a 64-bit unsigned integer. + + Performs an atomic compare exchange operation on the 64-bit unsigned integer specified + by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and + CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. + The compare exchange operation must be performed using MP safe mechanisms. + + @param Value A pointer to the 64-bit value for the compare exchange + operation. + @param CompareValue 64-bit value used in compare operation. + @param ExchangeValue 64-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT64 +EFIAPI +InternalSyncCompareExchange64 ( + IN volatile UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ); + +/** + Worker function that returns a bit field from Operand + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + + @return The bit field read. + +**/ +unsigned int +BitFieldReadUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit + ); + +/** + Worker function that reads a bit field from Operand, performs a bitwise OR, + and returns the result. + + Performs a bitwise OR between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new value is returned. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + @param OrData The value to OR with the read value from the value + + @return The new value. + +**/ +unsigned int +BitFieldOrUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN unsigned int OrData + ); + +/** + Worker function that reads a bit field from Operand, performs a bitwise AND, + and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new value is returned. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + @param AndData The value to And with the read value from the value + + @return The new value. + +**/ +unsigned int +BitFieldAndUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN unsigned int AndData + ); + +/** + Worker function that checks ASSERT condition for JumpBuffer + + Checks ASSERT condition for JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + +**/ +VOID +InternalAssertJumpBuffer ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ); + +/** + Restores the CPU context that was saved with SetJump(). + + Restores the CPU context from the buffer specified by JumpBuffer. + This function never returns to the caller. + Instead is resumes execution based on the state of JumpBuffer. + + @param JumpBuffer A pointer to CPU context buffer. + @param Value The value to return when the SetJump() context is restored. + +**/ +VOID +EFIAPI +InternalLongJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, + IN UINTN Value + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c new file mode 100644 index 0000000000..6b332e5f82 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c @@ -0,0 +1,873 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + BitField.c + +Abstract: + + Bit field functions of BaseLib. + +--*/ + +#include "BaseLibInternal.h" + +/** + Worker function that returns a bit field from Operand + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + + @return The bit field read. + +**/ +unsigned int +BitFieldReadUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + // + // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit] + // are 1's while bit[EndBit + 1] thru the most significant bit are 0's. + // + return (Operand & ~((unsigned int)-2 << EndBit)) >> StartBit; +} + +/** + Worker function that reads a bit field from Operand, performs a bitwise OR, + and returns the result. + + Performs a bitwise OR between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new value is returned. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + @param OrData The value to OR with the read value from the value + + @return The new value. + +**/ +unsigned int +BitFieldOrUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN unsigned int OrData + ) +{ + // + // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit] + // are 1's while bit[EndBit + 1] thru the most significant bit are 0's. + // + return Operand | ((OrData << StartBit) & ~((unsigned int) -2 << EndBit)); +} + +/** + Worker function that reads a bit field from Operand, performs a bitwise AND, + and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new value is returned. + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + @param EndBit The ordinal of the most significant bit in the bit field. + @param AndData The value to And with the read value from the value + + @return The new value. + +**/ +unsigned int +BitFieldAndUint ( + IN unsigned int Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN unsigned int AndData + ) +{ + // + // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit] + // are 1's while bit[EndBit + 1] thru the most significant bit are 0's. + // + return Operand & ~((~AndData << StartBit) & ~((unsigned int) -2 << EndBit)); +} + +/** + Returns a bit field from an 8-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The bit field read. + +**/ +UINT8 +EFIAPI +BitFieldRead8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT8)BitFieldReadUint (Operand, StartBit, EndBit); +} + +/** + Writes a bit field to an 8-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 8-bit value is + returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldWrite8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr8 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the value + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT8)BitFieldOrUint (Operand, StartBit, EndBit, OrData); +} + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAnd8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT8)BitFieldAndUint (Operand, StartBit, EndBit, AndData); +} + +/** + Reads a bit field from an 8-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 8-bit value is returned. + + If 8-bit operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 8-bit value. + +**/ +UINT8 +EFIAPI +BitFieldAndThenOr8 ( + IN UINT8 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldOr8 ( + BitFieldAnd8 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} + +/** + Returns a bit field from a 16-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The bit field read. + +**/ +UINT16 +EFIAPI +BitFieldRead16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT16)BitFieldReadUint (Operand, StartBit, EndBit); +} + +/** + Writes a bit field to a 16-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 16-bit value is + returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldWrite16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr16 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT16)BitFieldOrUint (Operand, StartBit, EndBit, OrData); +} + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAnd16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT16)BitFieldAndUint (Operand, StartBit, EndBit, AndData); +} + +/** + Reads a bit field from a 16-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 16-bit value is returned. + + If 16-bit operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 16-bit value. + +**/ +UINT16 +EFIAPI +BitFieldAndThenOr16 ( + IN UINT16 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldOr16 ( + BitFieldAnd16 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} + +/** + Returns a bit field from a 32-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read. + +**/ +UINT32 +EFIAPI +BitFieldRead32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)BitFieldReadUint (Operand, StartBit, EndBit); +} + +/** + Writes a bit field to a 32-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 32-bit value is + returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldWrite32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr32 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)BitFieldOrUint (Operand, StartBit, EndBit, OrData); +} + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAnd32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)BitFieldAndUint (Operand, StartBit, EndBit, AndData); +} + +/** + Reads a bit field from a 32-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 32-bit value is returned. + + If 32-bit operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 32-bit value. + +**/ +UINT32 +EFIAPI +BitFieldAndThenOr32 ( + IN UINT32 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldOr32 ( + BitFieldAnd32 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} + +/** + Returns a bit field from a 64-bit value. + + Returns the bitfield specified by the StartBit and the EndBit from Operand. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The bit field read. + +**/ +UINT64 +EFIAPI +BitFieldRead64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return RShiftU64 (Operand & ~LShiftU64 ((UINT64)-2, EndBit), StartBit); +} + +/** + Writes a bit field to a 64-bit value, and returns the result. + + Writes Value to the bit field specified by the StartBit and the EndBit in + Operand. All other bits in Operand are preserved. The new 64-bit value is + returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldWrite64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldAndThenOr64 (Operand, StartBit, EndBit, 0, Value); +} + +/** + Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the + result. + + Performs a bitwise inclusive OR between the bit field specified by StartBit + and EndBit in Operand and the value specified by OrData. All other bits in + Operand are preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + UINT64 Value1; + UINT64 Value2; + + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + + Value1 = LShiftU64 (OrData, StartBit); + Value2 = LShiftU64 ((UINT64) - 2, EndBit); + + return Operand | (Value1 & ~Value2); +} + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND, and returns + the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAnd64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + UINT64 Value1; + UINT64 Value2; + + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + + Value1 = LShiftU64 (~AndData, StartBit); + Value2 = LShiftU64 ((UINT64)-2, EndBit); + + return Operand & ~(Value1 & ~Value2); +} + +/** + Reads a bit field from a 64-bit value, performs a bitwise AND followed by a + bitwise OR, and returns the result. + + Performs a bitwise AND between the bit field specified by StartBit and EndBit + in Operand and the value specified by AndData, followed by a bitwise + inclusive OR with value specified by OrData. All other bits in Operand are + preserved. The new 64-bit value is returned. + + If 64-bit operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Operand Operand on which to perform the bitfield operation. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the value. + @param OrData The value to OR with the result of the AND operation. + + @return The new 64-bit value. + +**/ +UINT64 +EFIAPI +BitFieldAndThenOr64 ( + IN UINT64 Operand, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + ASSERT (EndBit < sizeof (Operand) * 8); + ASSERT (StartBit <= EndBit); + return BitFieldOr64 ( + BitFieldAnd64 (Operand, StartBit, EndBit, AndData), + StartBit, + EndBit, + OrData + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c new file mode 100644 index 0000000000..adabe6165c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Cpu.c + +Abstract: + + Base Library CPU Functions for all architectures. + +--*/ + +#include "BaseLibInternal.h" + +/** + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + Disables CPU interrupts and returns the interrupt state prior to the disable + operation. + + @retval TRUE CPU interrupts were enabled on entry to this call. + @retval FALSE CPU interrupts were disabled on entry to this call. + +**/ +BOOLEAN +EFIAPI +SaveAndDisableInterrupts ( + VOID + ) +{ + BOOLEAN InterruptState; + + InterruptState = GetInterruptState (); + DisableInterrupts (); + return InterruptState; +} + +/** + Set the current CPU interrupt state. + + Sets the current CPU interrupt state to the state specified by + InterruptState. If InterruptState is TRUE, then interrupts are enabled. If + InterruptState is FALSE, then interrupts are disabled. InterruptState is + returned. + + @param InterruptState TRUE if interrupts should enabled. FALSE if + interrupts should be disabled. + + @return InterruptState + +**/ +BOOLEAN +EFIAPI +SetInterruptState ( + IN BOOLEAN InterruptState + ) +{ + if (InterruptState) { + EnableInterrupts (); + } else { + DisableInterrupts (); + } + return InterruptState; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c new file mode 100644 index 0000000000..6eef0357d7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CpuDeadLoop.c + +Abstract: + + Base Library CPU Functions for all architectures. + +--*/ + +#include "BaseLibInternal.h" + +/** + Executes an infinite loop. + + Forces the CPU to execute an infinite loop. A debugger may be used to skip + past the loop and the code that follows the loop must execute properly. This + implies that the infinite loop must not cause the code that follow it to be + optimized away. + +**/ +VOID +EFIAPI +CpuDeadLoop ( + VOID + ) +{ + volatile UINTN Index; + + for (Index = 0; Index == 0;); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c new file mode 100644 index 0000000000..58d99de18a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DivS64x64Remainder.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit signed value Dividend by the 64-bit signed + value Divisor and generates a 64-bit signed quotient. If Remainder is not + NULL, then the 64-bit signed remainder is returned in Remainder. This + function returns the 64-bit signed quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +EFIAPI +DivS64x64Remainder ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivRemS64x64 (Dividend, Divisor, Remainder); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c new file mode 100644 index 0000000000..d45c4d465f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DivU64x32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +GlueDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivU64x32 (Dividend, Divisor); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c new file mode 100644 index 0000000000..fe065cdd57 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DivU64x32Remainder.c + +Abstract: + + Math worker functions + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x32Remainder ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder OPTIONAL + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivRemU64x32 (Dividend, Divisor, Remainder); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c new file mode 100644 index 0000000000..6ea2f0a430 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DivU64x64Remainder.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates + a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +DivU64x64Remainder ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder OPTIONAL + ) +{ + ASSERT (Divisor != 0); + return InternalMathDivRemU64x64 (Dividend, Divisor, Remainder); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/CpuBreakpoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/CpuBreakpoint.c new file mode 100644 index 0000000000..438df67aec --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/CpuBreakpoint.c @@ -0,0 +1,173 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + CpuBreakpoint.c + +Abstract: + + +--*/ + +#include "..\BaseLibInternal.h" + +extern +UINT64 +_break ( + CHAR8 BreakCode + ); + +/** + Generates a breakpoint on the CPU. + + Generates a breakpoint on the CPU. The breakpoint must be implemented such + that code can resume normal execution after the breakpoint. + +**/ +VOID +EFIAPI +CpuBreakpoint ( + VOID + ) +{ + _break (3); +} + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ) +{ +} + +/** + Disables CPU interrupts. + + Disables CPU interrupts. + +**/ +VOID +EFIAPI +DisableInterrupts ( + VOID + ) +{ + ASSERT (FALSE); +} + +/** + Enables CPU interrupts. + + Enables CPU interrupts. + +**/ +VOID +EFIAPI +EnableInterrupts ( + VOID + ) +{ + ASSERT (FALSE); +} + +/** + Retrieves the current CPU interrupt state. + + Retrieves the current CPU interrupt state. Returns TRUE is interrupts are + currently enabled. Otherwise returns FALSE. + + @retval TRUE CPU interrupts are enabled. + @retval FALSE CPU interrupts are disabled. + +**/ +BOOLEAN +EFIAPI +GlueGetInterruptState ( + VOID + ) +{ + ASSERT (FALSE); + return FALSE; +} + +/** + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + +**/ +VOID +EFIAPI +EnableDisableInterrupts ( + VOID + ) +{ + EnableInterrupts (); + DisableInterrupts (); +} + +/** + Requests CPU to pause for a short period of time. + + Requests CPU to pause for a short period of time. Typically used in MP + systems to prevent memory starvation while waiting for a spin lock. + +**/ +VOID +EFIAPI +CpuPause ( + VOID + ) +{ +} + +/** + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + +**/ +VOID +EFIAPI +CpuFlushTlb ( + VOID + ) +{ + ASSERT (FALSE); +} + +/** + Places the CPU in a sleep state until an interrupt is received. + + Places the CPU in a sleep state until an interrupt is received. If interrupts + are disabled prior to calling this function, then the CPU will be placed in a + sleep state indefinitely. + +**/ +VOID +EFIAPI +CpuSleep ( + VOID + ) +{ +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SetJumpLongJump.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SetJumpLongJump.c new file mode 100644 index 0000000000..c42fa5ca2a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SetJumpLongJump.c @@ -0,0 +1,85 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SetJumpLongJump.c + +Abstract: + + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Worker function that checks ASSERT condition for JumpBuffer + + Checks ASSERT condition for JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + +**/ +VOID +InternalAssertJumpBuffer ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ); + +/** + Saves the current CPU context that can be restored with a call to LongJump() and returns 0. + + Saves the current CPU context in the buffer specified by JumpBuffer and returns 0. The initial + call to SetJump() must always return 0. Subsequent calls to LongJump() cause a non-zero + value to be returned by SetJump(). + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + +**/ +UINTN +EFIAPI +SetJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ) +{ + InternalAssertJumpBuffer (JumpBuffer); + return 0; +} + +/** + Restores the CPU context that was saved with SetJump(). + + Restores the CPU context from the buffer specified by JumpBuffer. + This function never returns to the caller. + Instead is resumes execution based on the state of JumpBuffer. + + @param JumpBuffer A pointer to CPU context buffer. + @param Value The value to return when the SetJump() context is restored. + +**/ +VOID +EFIAPI +InternalLongJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, + IN UINTN Value + ) +{ + // + // This function cannot work on EBC + // + ASSERT (FALSE); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SwitchStack.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SwitchStack.c new file mode 100644 index 0000000000..c94a0863c2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/SwitchStack.c @@ -0,0 +1,59 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SwitchStack.c + +Abstract: + + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +InternalSwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + // + // This version of this function does not actually change the stack pointer + // This is to support compilation of CPU types that do not support assemblers + // such as EBC + // + EntryPoint (Context1, Context2); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/Synchronization.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/Synchronization.c new file mode 100644 index 0000000000..2c08ffac65 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/Synchronization.c @@ -0,0 +1,106 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Synchronization.c + +Abstract: + + +--*/ + +#include "..\BaseLibInternal.h" + +UINT32 +EFIAPI +InternalSyncCompareExchange32 ( + IN volatile UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ) +{ + return *Value != CompareValue ? *Value : + ((*Value = ExchangeValue), CompareValue); +} + +/** + Performs an atomic compare exchange operation on a 64-bit unsigned integer. + + Performs an atomic compare exchange operation on the 64-bit unsigned integer specified + by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and + CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. + The compare exchange operation must be performed using MP safe mechanisms. + + @param Value A pointer to the 64-bit value for the compare exchange + operation. + @param CompareValue 64-bit value used in compare operation. + @param ExchangeValue 64-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT64 +EFIAPI +InternalSyncCompareExchange64 ( + IN volatile UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ) +{ + return *Value != CompareValue ? *Value : + ((*Value = ExchangeValue), CompareValue); +} + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InternalSyncIncrement ( + IN volatile UINT32 *Value + ) +{ + return ++*Value; +} + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decrement value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to decrement. + + @return The decrement value. + +**/ +UINT32 +EFIAPI +InternalSyncDecrement ( + IN volatile UINT32 *Value + ) +{ + return --*Value; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c new file mode 100644 index 0000000000..1199bfd3f5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c @@ -0,0 +1,48 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GetPowerOfTwo32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the value of the highest bit set in a 32-bit value. Equivalent to + 1 << HighBitSet32(x). + + This function computes the value of the highest bit set in the 32-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 32-bit operand to evaluate. + + @return 1 << HighBitSet32(Operand) + @retval 0 Operand is zero. + +**/ +UINT32 +EFIAPI +GetPowerOfTwo32 ( + IN UINT32 Operand + ) +{ + if (Operand == 0) { + return 0; + } + + return 1ul << HighBitSet32 (Operand); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c new file mode 100644 index 0000000000..bd702a27b9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + GetPowerOfTwo64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the value of the highest bit set in a 64-bit value. Equivalent to + 1 << HighBitSet64(x). + + This function computes the value of the highest bit set in the 64-bit value + specified by Operand. If Operand is zero, then zero is returned. + + @param Operand The 64-bit operand to evaluate. + + @return 1 << HighBitSet64(Operand) + @retval 0 Operand is zero. + +**/ +UINT64 +EFIAPI +GetPowerOfTwo64 ( + IN UINT64 Operand + ) +{ + if (Operand == 0) { + return 0; + } + + return LShiftU64 (1, HighBitSet64 (Operand)); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c new file mode 100644 index 0000000000..a7a1f56923 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + HighBitSet32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the highest bit set in a 32-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet32 ( + IN UINT32 Operand + ) +{ + INTN BitIndex; + + if (Operand == 0) { + return - 1; + } + for (BitIndex = 31; (INT32)Operand > 0; BitIndex--, Operand <<= 1); + return BitIndex; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c new file mode 100644 index 0000000000..e19928f651 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c @@ -0,0 +1,60 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + HighBitSet64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the highest bit set in a 64-bit value. Equivalent + to log2(x). + + This function computes the bit position of the highest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the highest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +HighBitSet64 ( + IN UINT64 Operand + ) +{ + if (Operand == (UINT32)Operand) { + // + // Operand is just a 32-bit integer + // + return HighBitSet32 ((UINT32)Operand); + } + + // + // Operand is really a 64-bit integer + // + if (sizeof (UINTN) == sizeof (UINT32)) { + return HighBitSet32 (((UINT32*)&Operand)[1]) + 32; + } else { + return HighBitSet32 ((UINT32)RShiftU64 (Operand, 32)) + 32; + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm new file mode 100644 index 0000000000..1e14e9e9ea --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm @@ -0,0 +1,44 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ARShiftU64.asm +; +; Abstract: +; +; 64-bit arithmetic right shift function for IA-32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathARShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathARShiftU64 PROC + mov cl, [esp + 12] + mov eax, [esp + 8] + cdq + test cl, 32 + cmovz edx, eax + cmovz eax, [esp + 4] + shrd eax, edx, cl + sar edx, cl + ret +InternalMathARShiftU64 ENDP + + END \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm new file mode 100644 index 0000000000..e1050afff8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuBreakpoint.Asm +; +; Abstract: +; +; CpuBreakpoint function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuBreakpoint ( +; VOID +; ); +;------------------------------------------------------------------------------ +_CpuBreakpoint PROC + int 3 + ret +_CpuBreakpoint ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm new file mode 100644 index 0000000000..ba4849f0af --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuFlushTlb.Asm +; +; Abstract: +; +; CpuFlushTlb function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuFlushTlb ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuFlushTlb PROC + mov eax, cr3 + mov cr3, eax ; moving to CR3 flushes TLB + ret +CpuFlushTlb ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm new file mode 100644 index 0000000000..4b97570daa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm @@ -0,0 +1,64 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuId.Asm +; +; Abstract: +; +; AsmCpuid function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586P + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmCpuid ( +; IN UINT32 RegisterInEax, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ); +;------------------------------------------------------------------------------ +AsmCpuid PROC USES ebx + push ebp + mov ebp, esp + mov eax, [ebp + 12] + cpuid + push ecx + mov ecx, [ebp + 16] + jecxz @F + mov [ecx], eax +@@: + mov ecx, [ebp + 20] + jecxz @F + mov [ecx], ebx +@@: + mov ecx, [ebp + 24] + jecxz @F + pop [ecx] +@@: + mov ecx, [ebp + 28] + jecxz @F + mov [ecx], edx +@@: + mov eax, [ebp + 12] + leave + ret +AsmCpuid ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm new file mode 100644 index 0000000000..ea57e60e97 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm @@ -0,0 +1,66 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuIdEx.Asm +; +; Abstract: +; +; AsmCpuidEx function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; AsmCpuidEx ( +; IN UINT32 RegisterInEax, +; IN UINT32 RegisterInEcx, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ) +;------------------------------------------------------------------------------ +AsmCpuidEx PROC USES ebx + push ebp + mov ebp, esp + mov eax, [ebp + 12] + mov ecx, [ebp + 16] + cpuid + push ecx + mov ecx, [ebp + 20] + jecxz @F + mov [ecx], eax +@@: + mov ecx, [ebp + 24] + jecxz @F + mov [ecx], ebx +@@: + mov ecx, [ebp + 28] + jecxz @F + pop [ecx] +@@: + mov edx, [ebp + 32] + jecxz @F + mov [ecx], edx +@@: + mov eax, [ebp + 12] + leave + ret +AsmCpuidEx ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm new file mode 100644 index 0000000000..95e1307f8d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuPause.Asm +; +; Abstract: +; +; CpuPause function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuPause ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuPause PROC + pause + ret +CpuPause ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm new file mode 100644 index 0000000000..4220834104 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuSleep.Asm +; +; Abstract: +; +; CpuSleep function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuSleep ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuSleep PROC + hlt + ret +CpuSleep ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm new file mode 100644 index 0000000000..fabb3b8323 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DisableInterrupts.Asm +; +; Abstract: +; +; DisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; DisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +DisableInterrupts PROC + cli + ret +DisableInterrupts ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm new file mode 100644 index 0000000000..77eee7c094 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm @@ -0,0 +1,55 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DisablePaging32.Asm +; +; Abstract: +; +; AsmDisablePaging32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86DisablePaging32 ( +; IN SWITCH_STACK_ENTRY_POINT EntryPoint, +; IN VOID *Context1, OPTIONAL +; IN VOID *Context2, OPTIONAL +; IN VOID *NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86DisablePaging32 PROC + mov ebx, [esp + 4] + mov ecx, [esp + 8] + mov edx, [esp + 12] + pushfd + pop edi ; save EFLAGS to edi + cli + mov eax, cr0 + btr eax, 31 + mov esp, [esp + 16] + mov cr0, eax + push edi + popfd ; restore EFLAGS from edi + push edx + push ecx + call ebx + jmp $ ; EntryPoint() should not return +InternalX86DisablePaging32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c new file mode 100644 index 0000000000..c53b8a0e9c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c @@ -0,0 +1,60 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DivS64x64Remainder.c + +Abstract: + + Integer division worker functions for Ia32. + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Worker function that Divides a 64-bit signed integer by a 64-bit signed integer and + generates a 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +InternalMathDivRemS64x64 ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ) +{ + INT64 Quot; + + Quot = InternalMathDivRemU64x64 ( + Dividend >= 0 ? Dividend : -Dividend, + Divisor >= 0 ? Divisor : -Divisor, + (UINT64 *) Remainder + ); + if (Remainder != NULL && Dividend < 0) { + *Remainder = -*Remainder; + } + return (Dividend ^ Divisor) >= 0 ? Quot : -Quot; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm new file mode 100644 index 0000000000..28ae1f88d8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm @@ -0,0 +1,44 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DivU64x32.asm +; +; Abstract: +; +; Calculate the quotient of a 64-bit integer by a 32-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor +; ); +;------------------------------------------------------------------------------ +InternalMathDivU64x32 PROC + mov eax, [esp + 8] + mov ecx, [esp + 12] + xor edx, edx + div ecx + push eax ; save quotient on stack + mov eax, [esp + 8] + div ecx + pop edx ; restore high-order dword of the quotient + ret +InternalMathDivU64x32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm new file mode 100644 index 0000000000..6a1b0eb608 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm @@ -0,0 +1,49 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DivError.asm +; +; Abstract: +; +; Set error flag for all division functions +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivRemU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor, +; OUT UINT32 *Remainder +; ); +;------------------------------------------------------------------------------ +InternalMathDivRemU64x32 PROC + mov ecx, [esp + 12] ; ecx <- divisor + mov eax, [esp + 8] ; eax <- dividend[32..63] + xor edx, edx + div ecx ; eax <- quotient[32..63], edx <- remainder + push eax + mov eax, [esp + 8] ; eax <- dividend[0..31] + div ecx ; eax <- quotient[0..31] + mov ecx, [esp + 20] ; ecx <- Remainder + jecxz @F ; abandon remainder if Remainder == NULL + mov [ecx], edx +@@: + pop edx ; edx <- quotient[32..63] + ret +InternalMathDivRemU64x32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm new file mode 100644 index 0000000000..f0261c67a6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm @@ -0,0 +1,90 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DivU64x64Remainder.asm +; +; Abstract: +; +; Calculate the quotient of a 64-bit integer by a 64-bit integer and returns +; both the quotient and the remainder +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +EXTERN InternalMathDivRemU64x32:PROC + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathDivRemU64x64 ( +; IN UINT64 Dividend, +; IN UINT64 Divisor, +; OUT UINT64 *Remainder OPTIONAL +; ); +;------------------------------------------------------------------------------ +InternalMathDivRemU64x64 PROC + mov ecx, [esp + 16] ; ecx <- divisor[32..63] + test ecx, ecx + jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32 + mov ecx, [esp + 20] + jecxz @F + and dword ptr [ecx + 4], 0 ; zero high dword of remainder + mov [esp + 16], ecx ; set up stack frame to match DivRemU64x32 +@@: + jmp InternalMathDivRemU64x32 +InternalMathDivRemU64x64 ENDP + +_@DivRemU64x64 PROC USES ebx esi edi + mov edx, dword ptr [esp + 20] + mov eax, dword ptr [esp + 16] ; edx:eax <- dividend + mov edi, edx + mov esi, eax ; edi:esi <- dividend + mov ebx, dword ptr [esp + 24] ; ecx:ebx <- divisor +@@: + shr edx, 1 + rcr eax, 1 + shrd ebx, ecx, 1 + shr ecx, 1 + jnz @B + div ebx + mov ebx, eax ; ebx <- quotient + mov ecx, [esp + 28] ; ecx <- high dword of divisor + mul dword ptr [esp + 24] ; edx:eax <- quotient * divisor[0..31] + imul ecx, ebx ; ecx <- quotient * divisor[32..63] + add edx, ecx ; edx <- (quotient * divisor)[32..63] + mov ecx, dword ptr [esp + 32] ; ecx <- addr for Remainder + jc @TooLarge ; product > 2^64 + cmp edi, edx ; compare high 32 bits + ja @Correct + jb @TooLarge ; product > dividend + cmp esi, eax + jae @Correct ; product <= dividend +@TooLarge: + dec ebx ; adjust quotient by -1 + jecxz @Return ; return if Remainder == NULL + sub eax, dword ptr [esp + 24] + sbb edx, dword ptr [esp + 28] ; edx:eax <- (quotient - 1) * divisor +@Correct: + jecxz @Return + sub esi, eax + sbb edi, edx ; edi:esi <- remainder + mov [ecx], esi + mov [ecx + 4], edi +@Return: + mov eax, ebx ; eax <- quotient + xor edx, edx ; quotient is 32 bits long + ret +_@DivRemU64x64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm new file mode 100644 index 0000000000..7218d3027b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; EnableDisableInterrupts.Asm +; +; Abstract: +; +; EnableDisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableDisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +_EnableDisableInterrupts PROC + sti + cli + ret +_EnableDisableInterrupts ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm new file mode 100644 index 0000000000..26cc379308 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; EnableInterrupts.Asm +; +; Abstract: +; +; EnableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +_EnableInterrupts PROC + sti + ret +_EnableInterrupts ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm new file mode 100644 index 0000000000..06188d7352 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm @@ -0,0 +1,55 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; EnablePaging32.Asm +; +; Abstract: +; +; AsmEnablePaging32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86EnablePaging32 ( +; IN SWITCH_STACK_ENTRY_POINT EntryPoint, +; IN VOID *Context1, OPTIONAL +; IN VOID *Context2, OPTIONAL +; IN VOID *NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86EnablePaging32 PROC + mov ebx, [esp + 4] + mov ecx, [esp + 8] + mov edx, [esp + 12] + pushfd + pop edi ; save flags in edi + cli + mov eax, cr0 + bts eax, 31 + mov esp, [esp + 16] + mov cr0, eax + push edi + popfd ; restore flags + push edx + push ecx + call ebx + jmp $ +InternalX86EnablePaging32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm new file mode 100644 index 0000000000..bed4753595 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm @@ -0,0 +1,66 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; EnablePaging64.Asm +; +; Abstract: +; +; AsmEnablePaging64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86EnablePaging64 ( +; IN UINT16 Cs, +; IN UINT64 EntryPoint, +; IN UINT64 Context1, OPTIONAL +; IN UINT64 Context2, OPTIONAL +; IN UINT64 NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86EnablePaging64 PROC + cli + mov [esp], @F ; offset for far retf, seg is the 1st arg + mov eax, cr4 + or al, (1 SHL 5) + mov cr4, eax ; enable PAE + mov ecx, 0c0000080h + rdmsr + or ah, 1 ; set LME + wrmsr + mov eax, cr0 + bts eax, 31 ; set PG + mov cr0, eax ; enable paging + retf ; topmost 2 dwords hold the address +@@: ; long mode starts here + DB 67h, 48h ; 32-bit address size, 64-bit operand size + mov ebx, [esp] ; mov rbx, [esp] + DB 67h, 48h + mov ecx, [esp + 8] ; mov rcx, [esp + 8] + DB 67h, 48h + mov edx, [esp + 10h] ; mov rdx, [esp + 10h] + DB 67h, 48h + mov esp, [esp + 18h] ; mov rsp, [esp + 18h] + DB 48h + add esp, -20h ; add rsp, -20h + call ebx ; call rbx + hlt ; no one should get here +InternalX86EnablePaging64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm new file mode 100644 index 0000000000..e4d188034c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm @@ -0,0 +1,40 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; FlushCacheLine.Asm +; +; Abstract: +; +; AsmFlushCacheLine function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586P + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; AsmFlushCacheLine ( +; IN VOID *LinearAddress +; ); +;------------------------------------------------------------------------------ +AsmFlushCacheLine PROC + mov eax, [esp + 4] + clflush [eax] + ret +AsmFlushCacheLine ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm new file mode 100644 index 0000000000..520efe8cef --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm @@ -0,0 +1,40 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; FxRestore.Asm +; +; Abstract: +; +; AsmFxRestore function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxRestore ( +; IN CONST IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxRestore PROC + mov eax, [esp + 4] ; Buffer must be 16-byte aligned + fxrstor [eax] + ret +InternalX86FxRestore ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm new file mode 100644 index 0000000000..cd8a8017f0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm @@ -0,0 +1,40 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; FxSave.Asm +; +; Abstract: +; +; AsmFxSave function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxSave ( +; OUT IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxSave PROC + mov eax, [esp + 4] ; Buffer must be 16-byte aligned + fxsave [eax] + ret +InternalX86FxSave ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm new file mode 100644 index 0000000000..1937c86a80 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedCompareExchange32.Asm +; +; Abstract: +; +; InterlockedCompareExchange32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .486 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalSyncCompareExchange32 ( +; IN UINT32 *Value, +; IN UINT32 CompareValue, +; IN UINT32 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange32 PROC + mov ecx, [esp + 4] + mov eax, [esp + 8] + mov edx, [esp + 12] + lock cmpxchg [ecx], edx + ret +InternalSyncCompareExchange32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm new file mode 100644 index 0000000000..8cea7dcd1f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm @@ -0,0 +1,45 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedCompareExchange64.Asm +; +; Abstract: +; +; InterlockedCompareExchange64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586P + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalSyncCompareExchange64 ( +; IN UINT64 *Value, +; IN UINT64 CompareValue, +; IN UINT64 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange64 PROC USES esi ebx + mov esi, [esp + 12] + mov eax, [esp + 16] + mov edx, [esp + 20] + mov ebx, [esp + 24] + mov ecx, [esp + 28] + lock cmpxchg8b qword ptr [esi] + ret +InternalSyncCompareExchange64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm new file mode 100644 index 0000000000..269c5f2f15 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm @@ -0,0 +1,40 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedDecrement.Asm +; +; Abstract: +; +; InterlockedDecrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalSyncDecrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncDecrement PROC + mov eax, [esp + 4] + lock dec dword ptr [eax] + mov eax, [eax] + ret +InternalSyncDecrement ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm new file mode 100644 index 0000000000..4d989b564e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm @@ -0,0 +1,40 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedIncrement.Asm +; +; Abstract: +; +; InterlockedIncrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalSyncIncrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncIncrement PROC + mov eax, [esp + 4] + lock inc dword ptr [eax] + mov eax, [eax] + ret +InternalSyncIncrement ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c new file mode 100644 index 0000000000..9d6443ab03 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c @@ -0,0 +1,60 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + InternalSwitchStack.c + +Abstract: + + SwitchStack() function for IA-32. + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +InternalSwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, + IN VOID *Context2, + IN VOID *NewStack + ) +{ + BASE_LIBRARY_JUMP_BUFFER JumpBuffer; + + JumpBuffer.Eip = (UINTN)EntryPoint; + JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*); + JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2); + ((VOID**)JumpBuffer.Esp)[1] = Context1; + ((VOID**)JumpBuffer.Esp)[2] = Context2; + + LongJump (&JumpBuffer, (UINTN)-1); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm new file mode 100644 index 0000000000..24a3869ed2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Invd.Asm +; +; Abstract: +; +; AsmInvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .486p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmInvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +_AsmInvd PROC + invd + ret +_AsmInvd ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm new file mode 100644 index 0000000000..f1bbd5886e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm @@ -0,0 +1,47 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; LRotU64.asm +; +; Abstract: +; +; 64-bit left rotation for Ia32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathLRotU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathLRotU64 PROC USES ebx + mov cl, [esp + 16] + mov edx, [esp + 12] + mov eax, [esp + 8] + shld ebx, edx, cl + shld edx, eax, cl + ror ebx, cl + shld eax, ebx, cl + test cl, 32 ; Count >= 32? + cmovnz ecx, eax + cmovnz eax, edx + cmovnz edx, ecx + ret +InternalMathLRotU64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm new file mode 100644 index 0000000000..06a521dde6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm @@ -0,0 +1,44 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; LShiftU64.asm +; +; Abstract: +; +; 64-bit left shift function for IA-32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathLShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathLShiftU64 PROC + mov cl, [esp + 12] + xor eax, eax + mov edx, [esp + 4] + test cl, 32 ; Count >= 32? + cmovz eax, edx + cmovz edx, [esp + 8] + shld edx, eax, cl + shl eax, cl + ret +InternalMathLShiftU64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm new file mode 100644 index 0000000000..68e5b6b737 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm @@ -0,0 +1,44 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; LongJump.Asm +; +; Abstract: +; +; Implementation of _LongJump() on IA-32. +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalLongJump ( +; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +InternalLongJump PROC + pop eax ; skip return address + pop edx ; edx <- JumpBuffer + pop eax ; eax <- Value + mov ebx, [edx] + mov esi, [edx + 4] + mov edi, [edx + 8] + mov ebp, [edx + 12] + mov esp, [edx + 16] + jmp dword ptr [edx + 20] ; restore "eip" +InternalLongJump ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm new file mode 100644 index 0000000000..62e310a415 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DivU64x32.asm +; +; Abstract: +; +; Calculate the remainder of a 64-bit integer by a 32-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InternalMathModU64x32 ( +; IN UINT64 Dividend, +; IN UINT32 Divisor +; ); +;------------------------------------------------------------------------------ +InternalMathModU64x32 PROC + mov eax, [esp + 8] + mov ecx, [esp + 12] + xor edx, edx + div ecx + mov eax, [esp + 4] + div ecx + mov eax, edx + ret +InternalMathModU64x32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm new file mode 100644 index 0000000000..cf298a9edf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Monitor.Asm +; +; Abstract: +; +; AsmMonitor function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmMonitor ( +; IN UINTN Eax, +; IN UINTN Ecx, +; IN UINTN Edx +; ); +;------------------------------------------------------------------------------ +AsmMonitor PROC + mov eax, [esp + 4] + mov ecx, [esp + 8] + mov edx, [esp + 12] + DB 0fh, 1, 0c8h ; monitor + ret +AsmMonitor ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm new file mode 100644 index 0000000000..f10c4a74bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm @@ -0,0 +1,41 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MultU64x32.asm +; +; Abstract: +; +; Calculate the product of a 64-bit integer and a 32-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathMultU64x32 ( +; IN UINT64 Multiplicand, +; IN UINT32 Multiplier +; ); +;------------------------------------------------------------------------------ +InternalMathMultU64x32 PROC + mov ecx, [esp + 12] + mov eax, ecx + imul ecx, [esp + 8] ; overflow not detectable + mul dword ptr [esp + 4] + add edx, ecx + ret +InternalMathMultU64x32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm new file mode 100644 index 0000000000..39a66ebfdd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm @@ -0,0 +1,45 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; MultU64x64.asm +; +; Abstract: +; +; Calculate the product of a 64-bit integer and another 64-bit integer +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathMultU64x64 ( +; IN UINT64 Multiplicand, +; IN UINT64 Multiplier +; ); +;------------------------------------------------------------------------------ +InternalMathMultU64x64 PROC USES ebx + mov ebx, [esp + 8] ; ebx <- M1[0..31] + mov edx, [esp + 16] ; edx <- M2[0..31] + mov ecx, ebx + mov eax, edx + imul ebx, [esp + 20] ; ebx <- M1[0..31] * M2[32..63] + imul edx, [esp + 12] ; edx <- M1[32..63] * M2[0..31] + add ebx, edx ; carries are abandoned + mul ecx ; edx:eax <- M1[0..31] * M2[0..31] + add edx, ebx ; carries are abandoned + ret +InternalMathMultU64x64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm new file mode 100644 index 0000000000..bb2a07cc18 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm @@ -0,0 +1,41 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Mwait.Asm +; +; Abstract: +; +; AsmMwait function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmMwait ( +; IN UINTN Eax, +; IN UINTN Ecx +; ); +;------------------------------------------------------------------------------ +AsmMwait PROC + mov eax, [esp + 4] + mov ecx, [esp + 8] + DB 0fh, 1, 0c9h ; mwait + ret +AsmMwait ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c new file mode 100644 index 0000000000..6ac40c718c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c @@ -0,0 +1,66 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Non-existing.c + +Abstract: + + Non-existing BaseLib functions on Ia32 + +--*/ + +#include "..\BaseLibInternal.h" + + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging64 ( + IN UINT16 CodeSelector, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ) +{ + // + // This function cannot work on IA32 platform + // + ASSERT (FALSE); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm new file mode 100644 index 0000000000..413ae0c8e8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm @@ -0,0 +1,47 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; RRotU64.asm +; +; Abstract: +; +; 64-bit right rotation for Ia32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathRRotU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathRRotU64 PROC USES ebx + mov cl, [esp + 16] + mov eax, [esp + 8] + mov edx, [esp + 12] + shrd ebx, eax, cl + shrd eax, edx, cl + rol ebx, cl + shrd edx, ebx, cl + test cl, 32 ; Count >= 32? + cmovnz ecx, eax ; switch eax & edx if Count >= 32 + cmovnz eax, edx + cmovnz edx, ecx + ret +InternalMathRRotU64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm new file mode 100644 index 0000000000..78b039f479 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm @@ -0,0 +1,44 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; RShiftU64.asm +; +; Abstract: +; +; 64-bit logical right shift function for IA-32 +; +;------------------------------------------------------------------------------ + + .686 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathRShiftU64 ( +; IN UINT64 Operand, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +InternalMathRShiftU64 PROC + mov cl, [esp + 12] ; cl <- Count + xor edx, edx + mov eax, [esp + 8] + test cl, 32 ; Count >= 32? + cmovz edx, eax + cmovz eax, [esp + 4] + shrd eax, edx, cl + shr edx, cl + ret +InternalMathRShiftU64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm new file mode 100644 index 0000000000..6d15ad5d43 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr0.Asm +; +; Abstract: +; +; AsmReadCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr0 PROC + mov eax, cr0 + ret +AsmReadCr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm new file mode 100644 index 0000000000..b7f75e4566 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr2.Asm +; +; Abstract: +; +; AsmReadCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr2 PROC + mov eax, cr2 + ret +AsmReadCr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm new file mode 100644 index 0000000000..2f3b54bfd0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr3.Asm +; +; Abstract: +; +; AsmReadCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr3 PROC + mov eax, cr3 + ret +AsmReadCr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm new file mode 100644 index 0000000000..bf2aaee384 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr4.Asm +; +; Abstract: +; +; AsmReadCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr4 PROC + mov eax, cr4 + ret +AsmReadCr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm new file mode 100644 index 0000000000..69e2d11954 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCs.Asm +; +; Abstract: +; +; AsmReadCs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadCs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCs PROC + mov eax, cs + ret +AsmReadCs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm new file mode 100644 index 0000000000..bf5d5467c2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr0.Asm +; +; Abstract: +; +; AsmReadDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr0 PROC + mov eax, dr0 + ret +AsmReadDr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm new file mode 100644 index 0000000000..9b143cd0c7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr1.Asm +; +; Abstract: +; +; AsmReadDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr1 PROC + mov eax, dr1 + ret +AsmReadDr1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm new file mode 100644 index 0000000000..ba24037528 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr2.Asm +; +; Abstract: +; +; AsmReadDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr2 PROC + mov eax, dr2 + ret +AsmReadDr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm new file mode 100644 index 0000000000..67a0f1c32d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr3.Asm +; +; Abstract: +; +; AsmReadDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr3 PROC + mov eax, dr3 + ret +AsmReadDr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm new file mode 100644 index 0000000000..cfae3e8927 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm @@ -0,0 +1,45 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr4.Asm +; +; Abstract: +; +; AsmReadDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr4 PROC + ; + ; DR4 is alias to DR6 only if DE (in CR4) is cleared. Otherwise, reading + ; this register will cause a #UD exception. + ; + ; MS assembler doesn't support this instruction since no one would use it + ; under normal circustances. Here opcode is used. + ; + DB 0fh, 21h, 0e0h + ret +AsmReadDr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm new file mode 100644 index 0000000000..9f3fec11e8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm @@ -0,0 +1,45 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr5.Asm +; +; Abstract: +; +; AsmReadDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr5 PROC + ; + ; DR5 is alias to DR7 only if DE (in CR4) is cleared. Otherwise, reading + ; this register will cause a #UD exception. + ; + ; MS assembler doesn't support this instruction since no one would use it + ; under normal circustances. Here opcode is used. + ; + DB 0fh, 21h, 0e8h + ret +AsmReadDr5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm new file mode 100644 index 0000000000..a773f1236e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr6.Asm +; +; Abstract: +; +; AsmReadDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr6 PROC + mov eax, dr6 + ret +AsmReadDr6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm new file mode 100644 index 0000000000..74b2927110 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr7.Asm +; +; Abstract: +; +; AsmReadDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr7 PROC + mov eax, dr7 + ret +AsmReadDr7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm new file mode 100644 index 0000000000..b724a469d3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDs.Asm +; +; Abstract: +; +; AsmReadDs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadDs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDs PROC + mov eax, ds + ret +AsmReadDs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm new file mode 100644 index 0000000000..5cb241f5bb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadEflags.Asm +; +; Abstract: +; +; AsmReadEflags function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadEflags ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEflags PROC + pushfd + pop eax + ret +AsmReadEflags ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm new file mode 100644 index 0000000000..6706071b73 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadEs.Asm +; +; Abstract: +; +; AsmReadEs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadEs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEs PROC + mov eax, es + ret +AsmReadEs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm new file mode 100644 index 0000000000..773da70044 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadFs.Asm +; +; Abstract: +; +; AsmReadFs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadFs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadFs PROC + mov eax, fs + ret +AsmReadFs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm new file mode 100644 index 0000000000..19db886f35 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadGdtr.Asm +; +; Abstract: +; +; AsmReadGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadGdtr ( +; OUT IA32_DESCRIPTOR *Gdtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadGdtr PROC + mov eax, [esp + 4] + sgdt fword ptr [eax] + ret +InternalX86ReadGdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm new file mode 100644 index 0000000000..55ccca402d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadGs.Asm +; +; Abstract: +; +; AsmReadGs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadGs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadGs PROC + mov eax, gs + ret +AsmReadGs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm new file mode 100644 index 0000000000..6c10fcac29 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadIdtr.Asm +; +; Abstract: +; +; AsmReadIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadIdtr ( +; OUT IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadIdtr PROC + mov eax, [esp + 4] + sidt fword ptr [eax] + ret +InternalX86ReadIdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm new file mode 100644 index 0000000000..7b9696f216 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadLdtr.Asm +; +; Abstract: +; +; AsmReadLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadLdtr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadLdtr PROC + sldt ax + ret +AsmReadLdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm new file mode 100644 index 0000000000..1ea5b21747 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm0.Asm +; +; Abstract: +; +; AsmReadMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm0 PROC + push eax + push eax + movq [esp], mm0 + pop eax + pop edx + ret +AsmReadMm0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm new file mode 100644 index 0000000000..36d14b0b47 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm1.Asm +; +; Abstract: +; +; AsmReadMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm1 PROC + push eax + push eax + movq [esp], mm1 + pop eax + pop edx + ret +AsmReadMm1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm new file mode 100644 index 0000000000..652ae5e221 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm2.Asm +; +; Abstract: +; +; AsmReadMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm2 PROC + push eax + push eax + movq [esp], mm2 + pop eax + pop edx + ret +AsmReadMm2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm new file mode 100644 index 0000000000..2cf4c67050 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm3.Asm +; +; Abstract: +; +; AsmReadMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm3 PROC + push eax + push eax + movq [esp], mm3 + pop eax + pop edx + ret +AsmReadMm3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm new file mode 100644 index 0000000000..37599aeb6e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm4.Asm +; +; Abstract: +; +; AsmReadMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm4 PROC + push eax + push eax + movq [esp], mm4 + pop eax + pop edx + ret +AsmReadMm4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm new file mode 100644 index 0000000000..3722f9dae4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm5.Asm +; +; Abstract: +; +; AsmReadMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm5 PROC + push eax + push eax + movq [esp], mm5 + pop eax + pop edx + ret +AsmReadMm5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm new file mode 100644 index 0000000000..031889e6f2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm6.Asm +; +; Abstract: +; +; AsmReadMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm6 PROC + push eax + push eax + movq [esp], mm6 + pop eax + pop edx + ret +AsmReadMm6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm new file mode 100644 index 0000000000..c83195082a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm @@ -0,0 +1,43 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm7.Asm +; +; Abstract: +; +; AsmReadMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm7 PROC + push eax + push eax + movq [esp], mm7 + pop eax + pop edx + ret +AsmReadMm7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm new file mode 100644 index 0000000000..f0cf6a8308 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMsr64.Asm +; +; Abstract: +; +; AsmReadMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMsr64 ( +; IN UINT64 Index +; ); +;------------------------------------------------------------------------------ +AsmReadMsr64 PROC + mov ecx, [esp + 4] + rdmsr + ret +AsmReadMsr64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm new file mode 100644 index 0000000000..3b0d0e3f1b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadPmc.Asm +; +; Abstract: +; +; AsmReadPmc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadPmc ( +; IN UINT32 PmcIndex +; ); +;------------------------------------------------------------------------------ +AsmReadPmc PROC + mov ecx, [esp + 4] + rdpmc + ret +AsmReadPmc ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm new file mode 100644 index 0000000000..7788fc98bd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadSs.Asm +; +; Abstract: +; +; AsmReadSs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadSs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadSs PROC + mov eax, ss + ret +AsmReadSs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm new file mode 100644 index 0000000000..8990e3120e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadTr.Asm +; +; Abstract: +; +; AsmReadTr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadTr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTr PROC + str ax + ret +AsmReadTr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm new file mode 100644 index 0000000000..8ff0ea40f4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadTsc.Asm +; +; Abstract: +; +; AsmReadTsc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadTsc ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTsc PROC + rdtsc + ret +AsmReadTsc ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm new file mode 100644 index 0000000000..e3d33e1028 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm @@ -0,0 +1,49 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetJump.Asm +; +; Abstract: +; +; Implementation of SetJump() on IA-32. +; +;------------------------------------------------------------------------------ + + .386 + .model flat,C + .code + +InternalAssertJumpBuffer PROTO C + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; SetJump ( +; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer +; ); +;------------------------------------------------------------------------------ +SetJump PROC + push [esp + 4] + call InternalAssertJumpBuffer ; To validate JumpBuffer + pop ecx + pop ecx ; ecx <- return address + mov edx, [esp] + mov [edx], ebx + mov [edx + 4], esi + mov [edx + 8], edi + mov [edx + 12], ebp + mov [edx + 16], esp + mov [edx + 20], ecx ; eip value to restore in LongJump + xor eax, eax + jmp ecx +SetJump ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm new file mode 100644 index 0000000000..9554c1985e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm @@ -0,0 +1,41 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuId.Asm +; +; Abstract: +; +; AsmCpuid function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InternalMathSwapBytes64 ( +; IN UINT64 Operand +; ); +;------------------------------------------------------------------------------ +InternalMathSwapBytes64 PROC + mov eax, [esp + 8] ; eax <- upper 32 bits + mov edx, [esp + 4] ; edx <- lower 32 bits + bswap eax + bswap edx + ret +InternalMathSwapBytes64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm new file mode 100644 index 0000000000..154008f99a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm @@ -0,0 +1,250 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Thunk.asm +; +; Abstract: +; +; Real mode thunk +; +;------------------------------------------------------------------------------ + + .686p + .model flat,C + +EXTERNDEF C m16Start:BYTE +EXTERNDEF C m16Size:WORD +EXTERNDEF C mThunk16Attr:WORD +EXTERNDEF C m16Gdt:WORD +EXTERNDEF C m16GdtrBase:WORD +EXTERNDEF C mTransition:WORD + +THUNK_ATTRIBUTE_BIG_REAL_MODE EQU 1 +THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 EQU 2 +THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL EQU 4 + +; +; Here is the layout of the real mode stack. _ToUserCode() is responsible for +; loading all these registers from real mode stack. +; +IA32_REGS STRUC 4t +_EDI DD ? +_ESI DD ? +_EBP DD ? +_ESP DD ? +_EBX DD ? +_EDX DD ? +_ECX DD ? +_EAX DD ? +_DS DW ? +_ES DW ? +_FS DW ? +_GS DW ? +_EFLAGS DD ? +_EIP DD ? +_CS DW ? +_SS DW ? +IA32_REGS ENDS + + .const + +; +; These are global constant to convey information to C code. +; +m16Size DW InternalAsmThunk16 - m16Start +mThunk16Attr DW _ThunkAttr - m16Start +m16Gdt DW _NullSegDesc - m16Start +m16GdtrBase DW _16GdtrBase - m16Start +mTransition DW _EntryPoint - m16Start + + .code + +m16Start LABEL BYTE + +SavedGdt LABEL FWORD + DW ? + DD ? +;------------------------------------------------------------------------------ +; _BackFromUserCode() takes control in real mode after 'retf' has been executed +; by user code. It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_BackFromUserCode PROC + ; + ; The order of saved registers on the stack matches the order they appears + ; in IA32_REGS structure. This facilitates wrapper function to extract them + ; into that structure. + ; + push ss + push cs + DB 66h + call @Base ; push eip +@Base: + pushf ; pushfd actually + cli ; disable interrupts + push gs + push fs + push es + push ds + pushaw ; pushad actually + DB 66h, 0bah ; mov edx, imm32 +_ThunkAttr DD ? + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 + jz @1 + mov eax, 15cd2401h ; mov ax, 2401h & int 15h + cli ; disable interrupts + jnc @2 +@1: + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL + jz @2 + in al, 92h + or al, 2 + out 92h, al ; deactivate A20M# +@2: + mov eax, ss + DB 67h + lea bp, [esp + sizeof (IA32_REGS)] + ; + ; esi's in the following 2 instructions are indeed bp in 16-bit code. Fact + ; is "esi" in 32-bit addressing mode has the same encoding of "bp" in 16- + ; bit addressing mode. + ; + mov word ptr (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._ESP, bp + mov ebx, (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._EIP + shl ax, 4 ; shl eax, 4 + add bp, ax ; add ebp, eax + DB 66h, 0b8h ; mov eax, imm32 +SavedCr4 DD ? + mov cr4, eax + DB 66h + lgdt fword ptr cs:[edi + (SavedGdt - @Base)] + DB 66h, 0b8h ; mov eax, imm32 +SavedCr0 DD ? + mov cr0, eax + DB 0b8h ; mov ax, imm16 +SavedSs DW ? + mov ss, eax + DB 66h, 0bch ; mov esp, imm32 +SavedEsp DD ? + DB 66h + retf ; return to protected mode +_BackFromUserCode ENDP + +_EntryPoint DD _ToUserCode - m16Start + DW 8h +_16Idtr FWORD (1 SHL 10) - 1 +_16Gdtr LABEL FWORD + DW GdtEnd - _NullSegDesc - 1 +_16GdtrBase DD _NullSegDesc + +;------------------------------------------------------------------------------ +; _ToUserCode() takes control in real mode before passing control to user code. +; It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_ToUserCode PROC + mov edx, ss + mov ss, ecx ; set new segment selectors + mov ds, ecx + mov es, ecx + mov fs, ecx + mov gs, ecx + mov cr0, eax + mov cr4, ebp ; real mode starts at next instruction + mov ss, esi ; set up 16-bit stack segment + xchg sp, bx ; set up 16-bit stack pointer + DB 66h + call @Base ; push eip +@Base: + pop bp ; ebp <- address of @Base + DB 67h ; address size override + push [esp + sizeof (IA32_REGS) + 2] + lea eax, [esi + (@RealMode - @Base)] + push eax + retf +@RealMode: + mov cs:[esi + (SavedSs - @Base)], edx + mov cs:[esi + (SavedEsp - @Base)], bx + DB 66h + lidt fword ptr cs:[esi + (_16Idtr - @Base)] + popaw ; popad actually + pop ds + pop es + pop fs + pop gs + popf ; popfd + DB 66h ; Use 32-bit addressing for "retf" below + retf ; transfer control to user code +_ToUserCode ENDP + +_NullSegDesc DQ 0 +_16CsDesc LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +_16DsDesc LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +GdtEnd LABEL QWORD + +;------------------------------------------------------------------------------ +; IA32_REGISTER_SET * +; EFIAPI +; InternalAsmThunk16 ( +; IN IA32_REGISTER_SET *RegisterSet, +; IN OUT VOID *Transition +; ); +;------------------------------------------------------------------------------ +InternalAsmThunk16 PROC USES ebp ebx esi edi ds es fs gs + mov esi, [esp + 36] ; esi <- RegSet, the 1st parameter + movzx edx, (IA32_REGS ptr [esi])._SS + mov edi, (IA32_REGS ptr [esi])._ESP + add edi, - (sizeof (IA32_REGS) + 4) ; reserve stack space + mov ebx, edi ; ebx <- stack offset + imul eax, edx, 16 ; eax <- edx * 16 + push sizeof (IA32_REGS) / 4 + add edi, eax ; edi <- linear address of 16-bit stack + pop ecx + rep movsd ; copy RegSet + mov eax, [esp + 40] ; eax <- address of transition code + mov esi, edx ; esi <- 16-bit stack segment + lea edx, [eax + (SavedCr0 - m16Start)] + mov ecx, eax + and ecx, 0fh + shl eax, 12 + lea ecx, [ecx + (_BackFromUserCode - m16Start)] + mov ax, cx + stosd ; [edi] <- return address of user code + sgdt fword ptr [edx + (SavedGdt - SavedCr0)] + sidt fword ptr [esp + 36] ; save IDT stack in argument space + mov eax, cr0 + mov [edx], eax ; save CR0 in SavedCr0 + and eax, 7ffffffeh ; clear PE, PG bits + mov ebp, cr4 + mov [edx + (SavedCr4 - SavedCr0)], ebp + and ebp, 300h ; clear all but PCE and OSFXSR bits + push 10h + pop ecx ; ecx <- selector for data segments + lgdt fword ptr [edx + (_16Gdtr - SavedCr0)] + pushfd ; Save df/if indeed + call fword ptr [edx + (_EntryPoint - SavedCr0)] + popfd + lidt fword ptr [esp + 36] ; restore protected mode IDTR + lea eax, [ebp - sizeof (IA32_REGS)] ; eax <- the address of IA32_REGS + ret +InternalAsmThunk16 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm new file mode 100644 index 0000000000..9ffdec9474 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Wbinvd.Asm +; +; Abstract: +; +; AsmWbinvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .486p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWbinvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmWbinvd PROC + wbinvd + ret +AsmWbinvd ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm new file mode 100644 index 0000000000..d87c7e323d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr0.Asm +; +; Abstract: +; +; AsmWriteCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr0 ( +; UINTN Cr0 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr0 PROC + mov eax, [esp + 4] + mov cr0, eax + ret +AsmWriteCr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm new file mode 100644 index 0000000000..412cb26108 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr2.Asm +; +; Abstract: +; +; AsmWriteCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr2 ( +; UINTN Cr2 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr2 PROC + mov eax, [esp + 4] + mov cr2, eax + ret +AsmWriteCr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm new file mode 100644 index 0000000000..47514ea798 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr3.Asm +; +; Abstract: +; +; AsmWriteCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr3 ( +; UINTN Cr3 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr3 PROC + mov eax, [esp + 4] + mov cr3, eax + ret +AsmWriteCr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm new file mode 100644 index 0000000000..dd8d37e594 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr4.Asm +; +; Abstract: +; +; AsmWriteCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr4 ( +; UINTN Cr4 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr4 PROC + mov eax, [esp + 4] + mov cr4, eax + ret +AsmWriteCr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm new file mode 100644 index 0000000000..0154d0ff40 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr0.Asm +; +; Abstract: +; +; AsmWriteDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr0 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr0 PROC + mov eax, [esp + 4] + mov dr0, eax + ret +AsmWriteDr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm new file mode 100644 index 0000000000..4c7a2b3809 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr1.Asm +; +; Abstract: +; +; AsmWriteDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr1 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr1 PROC + mov eax, [esp + 4] + mov dr1, eax + ret +AsmWriteDr1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm new file mode 100644 index 0000000000..f621f6dfa4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr2.Asm +; +; Abstract: +; +; AsmWriteDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr2 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr2 PROC + mov eax, [esp + 4] + mov dr2, eax + ret +AsmWriteDr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm new file mode 100644 index 0000000000..99a5d564be --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr3.Asm +; +; Abstract: +; +; AsmWriteDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr3 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr3 PROC + mov eax, [esp + 4] + mov dr3, eax + ret +AsmWriteDr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm new file mode 100644 index 0000000000..9ed8bb3f26 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm @@ -0,0 +1,46 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr4.Asm +; +; Abstract: +; +; AsmWriteDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr4 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr4 PROC + mov eax, [esp + 4] + ; + ; DR4 is alias to DR6 only if DE (in CR4) is cleared. Otherwise, writing to + ; this register will cause a #UD exception. + ; + ; MS assembler doesn't support this instruction since no one would use it + ; under normal circustances. Here opcode is used. + ; + DB 0fh, 23h, 0e0h + ret +AsmWriteDr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm new file mode 100644 index 0000000000..ba74eaa075 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm @@ -0,0 +1,46 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr5.Asm +; +; Abstract: +; +; AsmWriteDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr5 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr5 PROC + mov eax, [esp + 4] + ; + ; DR5 is alias to DR7 only if DE (in CR4) is cleared. Otherwise, writing to + ; this register will cause a #UD exception. + ; + ; MS assembler doesn't support this instruction since no one would use it + ; under normal circustances. Here opcode is used. + ; + DB 0fh, 23h, 0e8h + ret +AsmWriteDr5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm new file mode 100644 index 0000000000..f36e95e09b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr6.Asm +; +; Abstract: +; +; AsmWriteDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr6 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr6 PROC + mov eax, [esp + 4] + mov dr6, eax + ret +AsmWriteDr6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm new file mode 100644 index 0000000000..cba6459231 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr7.Asm +; +; Abstract: +; +; AsmWriteDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr7 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr7 PROC + mov eax, [esp + 4] + mov dr7, eax + ret +AsmWriteDr7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm new file mode 100644 index 0000000000..0d5b5337ab --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteGdtr.Asm +; +; Abstract: +; +; AsmWriteGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteGdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteGdtr PROC + mov eax, [esp + 4] + lgdt fword ptr [eax] + ret +InternalX86WriteGdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm new file mode 100644 index 0000000000..427637a13d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteIdtr.Asm +; +; Abstract: +; +; AsmWriteIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteIdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteIdtr PROC + mov eax, [esp + 4] + lidt fword ptr [eax] + ret +InternalX86WriteIdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm new file mode 100644 index 0000000000..fb24d05042 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteLdtr.Asm +; +; Abstract: +; +; AsmWriteLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .386p + .model flat + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteLdtr ( +; IN UINT16 Ldtr +; ); +;------------------------------------------------------------------------------ +_AsmWriteLdtr PROC + mov eax, [esp + 4] + lldt ax + ret +_AsmWriteLdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm new file mode 100644 index 0000000000..64090cecf7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm0.Asm +; +; Abstract: +; +; AsmWriteMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm0 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm0 PROC + movq mm0, [esp + 4] + ret +AsmWriteMm0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm new file mode 100644 index 0000000000..9f81608ed6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm1.Asm +; +; Abstract: +; +; AsmWriteMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm1 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm1 PROC + movq mm1, [esp + 4] + ret +AsmWriteMm1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm new file mode 100644 index 0000000000..e882045163 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm2.Asm +; +; Abstract: +; +; AsmWriteMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm2 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm2 PROC + movq mm2, [esp + 4] + ret +AsmWriteMm2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm new file mode 100644 index 0000000000..c00c328940 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm3.Asm +; +; Abstract: +; +; AsmWriteMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm3 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm3 PROC + movq mm3, [esp + 4] + ret +AsmWriteMm3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm new file mode 100644 index 0000000000..f12f1e33f5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm4.Asm +; +; Abstract: +; +; AsmWriteMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm4 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm4 PROC + movq mm4, [esp + 4] + ret +AsmWriteMm4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm new file mode 100644 index 0000000000..a6fe8fd7f7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm5.Asm +; +; Abstract: +; +; AsmWriteMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm5 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm5 PROC + movq mm5, [esp + 4] + ret +AsmWriteMm5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm new file mode 100644 index 0000000000..b8be7e5cdf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm6.Asm +; +; Abstract: +; +; AsmWriteMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm6 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm6 PROC + movq mm6, [esp + 4] + ret +AsmWriteMm6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm new file mode 100644 index 0000000000..dfce9eb6b2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm7.Asm +; +; Abstract: +; +; AsmWriteMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm7 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm7 PROC + movq mm7, [esp + 4] + ret +AsmWriteMm7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm new file mode 100644 index 0000000000..69eaae0937 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm @@ -0,0 +1,42 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMsr64.Asm +; +; Abstract: +; +; AsmWriteMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmWriteMsr64 ( +; IN UINT32 Index, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMsr64 PROC + mov edx, [esp + 12] + mov eax, [esp + 8] + mov ecx, [esp + 4] + wrmsr + ret +AsmWriteMsr64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuBreakpoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuBreakpoint.c new file mode 100644 index 0000000000..237ca21992 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuBreakpoint.c @@ -0,0 +1,126 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + CpuBreakpint.c + +Abstract: + +--*/ + +#include "..\BaseLibInternal.h" + +//void __mfa (void); + +#pragma intrinsic (_enable) +#pragma intrinsic (_disable) +#pragma intrinsic (__break) +#pragma intrinsic (__mfa) + + +/** + Generates a breakpoint on the CPU. + + Generates a breakpoint on the CPU. The breakpoint must be implemented such + that code can resume normal execution after the breakpoint. + +**/ +VOID +EFIAPI +CpuBreakpoint ( + VOID + ) +{ + __break (0); +} + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ) +{ + __mfa (); +} + +/** + Disables CPU interrupts. + + Disables CPU interrupts. + +**/ +VOID +EFIAPI +DisableInterrupts ( + VOID + ) +{ + _disable (); +} + +/** + Enables CPU interrupts. + + Enables CPU interrupts. + +**/ +VOID +EFIAPI +EnableInterrupts ( + VOID + ) +{ + _enable (); +} + +/** + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + + Enables CPU interrupts for the smallest window required to capture any + pending interrupts. + +**/ +VOID +EFIAPI +EnableDisableInterrupts ( + VOID + ) +{ + EnableInterrupts (); + DisableInterrupts (); +} + +/** + Places the CPU in a sleep state until an interrupt is received. + + Places the CPU in a sleep state until an interrupt is received. If interrupts + are disabled prior to calling this function, then the CPU will be placed in a + sleep state indefinitely. + +**/ +VOID +EFIAPI +CpuSleep ( + VOID + ) +{ + PalCallStatic (NULL, 29, 0, 0, 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuFlushTlb.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuFlushTlb.s new file mode 100644 index 0000000000..02b67fd0af --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuFlushTlb.s @@ -0,0 +1,59 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// CpuFlushTlb.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.globl PalCallStatic +.type PalCallStatic, @function + +.proc CpuFlushTlb +.type CpuFlushTlb, @function +CpuFlushTlb:: + alloc loc0 = ar.pfs, 0, 3, 5, 0 + mov out0 = 0 + mov out1 = 6 + mov out2 = 0 + mov out3 = 0 + mov loc1 = b0 + mov out4 = 0 + brl.call.sptk b0 = PalCallStatic + mov loc2 = psr // save PSR + mov ar.pfs = loc0 + extr.u r14 = r10, 32, 32 // r14 <- count1 + rsm 1 << 14 // Disable interrupts + extr.u r15 = r11, 32, 32 // r15 <- stride1 + extr.u r10 = r10, 0, 32 // r10 <- count2 + add r10 = -1, r10 + extr.u r11 = r11, 0, 32 // r11 <- stride2 + br.cond.sptk LoopPredicate +LoopOuter: + mov ar.lc = r10 // LC <- count2 + mov ar.ec = r0 // EC <- 0 +Loop: + ptc.e r9 + add r9 = r11, r9 // r9 += stride2 + br.ctop.sptk Loop + add r9 = r15, r9 // r9 += stride1 +LoopPredicate: + cmp.ne p6 = r0, r14 // count1 == 0? + add r14 = -1, r14 +(p6) br.cond.sptk LoopOuter + mov psr.l = loc2 + mov b0 = loc1 + br.ret.sptk.many b0 +.endp diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuPause.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuPause.s new file mode 100644 index 0000000000..8b336421a2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/CpuPause.s @@ -0,0 +1,26 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// CpuPause.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc CpuPause +.type CpuPause, @function +CpuPause:: + hint 0 //@pause + br.ret.sptk.many b0 +.endp diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/FlushCacheRange.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/FlushCacheRange.s new file mode 100644 index 0000000000..8c88f90a51 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/FlushCacheRange.s @@ -0,0 +1,94 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// FlushCacheRange.s +/// +/// Abstract: +/// +/// + +.file "IpfCpuCache.s" + +#include "IpfMacro.i" +#include "IpfDefines.h" + +// +// Invalidates a range of instruction cache lines in the cache coherency domain +// of the calling CPU. +// +// Invalidates the instruction cache lines specified by Address and Length. If +// Address is not aligned on a cache line boundary, then entire instruction +// cache line containing Address is invalidated. If Address + Length is not +// aligned on a cache line boundary, then the entire instruction cache line +// containing Address + Length -1 is invalidated. This function may choose to +// invalidate the entire instruction cache if that is more efficient than +// invalidating the specified range. If Length is 0, the no instruction cache +// lines are invalidated. Address is returned. +// +// If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). +// +// @param Address The base address of the instruction cache lines to +// invalidate. If the CPU is in a physical addressing mode, then +// Address is a physical address. If the CPU is in a virtual +// addressing mode, then Address is a virtual address. +// +// @param Length The number of bytes to invalidate from the instruction cache. +// +// @return Address +// +// VOID * +// EFIAPI +// IpfFlushCacheRange ( +// IN VOID *Address, +// IN UINTN Length +// ); +// +PROCEDURE_ENTRY (IpfFlushCacheRange) + + NESTED_SETUP (5,8,0,0) + + mov loc2 = ar.lc + + mov loc3 = in0 // Start address. + mov loc4 = in1;; // Length in bytes. + + cmp.eq p6,p7 = loc4, r0;; // If Length is zero then don't flush any cache + (p6) br.spnt.many DoneFlushingC;; + + add loc4 = loc4,loc3 + mov loc5 = 1;; + sub loc4 = loc4, loc5 ;; // the End address to flush + + dep loc3 = r0,loc3,0,5 + dep loc4 = r0,loc4,0,5;; + shr loc3 = loc3,5 + shr loc4 = loc4,5;; // 32 byte cache line + + sub loc4 = loc4,loc3;; // total flush count, It should be add 1 but + // the br.cloop will first execute one time + mov loc3 = in0 + mov loc5 = 32 + mov ar.lc = loc4;; + +StillFlushingC: + fc loc3;; + sync.i;; + srlz.i;; + add loc3 = loc5,loc3;; + br.cloop.sptk.few StillFlushingC;; + +DoneFlushingC: + mov ar.lc = loc2 + mov r8 = in0 // return *Address + NESTED_RETURN + +PROCEDURE_EXIT (IpfFlushCacheRange) + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/GetInterruptState.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/GetInterruptState.s new file mode 100644 index 0000000000..873676f534 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/GetInterruptState.s @@ -0,0 +1,27 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// GetInterruptState.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc GlueGetInterruptState +.type GlueGetInterruptState, @function +GlueGetInterruptState:: + mov r8 = psr + extr.u r8 = r8, 14, 1 + br.ret.sptk.many b0 +.endp GlueGetInterruptState diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange32.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange32.s new file mode 100644 index 0000000000..4b5d7cb24f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange32.s @@ -0,0 +1,29 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// InterlockedCompareExchange32.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc InternalSyncCompareExchange32 +.type InternalSyncCompareExchange32, @function +InternalSyncCompareExchange32:: + zxt4 r33 = r33 + mov ar.ccv = r33 + cmpxchg4.rel r8 = [r32], r34 + mf + br.ret.sptk.many b0 +.endp InternalSyncCompareExchange32 \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange64.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange64.s new file mode 100644 index 0000000000..b3d7b84126 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/InterlockedCompareExchange64.s @@ -0,0 +1,28 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// InterlockedCompareExchange64.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc InternalSyncCompareExchange64 +.type InternalSyncCompareExchange64, @function +InternalSyncCompareExchange64:: + mov ar.ccv = r33 + cmpxchg8.rel r8 = [r32], r34 + mf + br.ret.sptk.many b0 +.endp InternalSyncCompareExchange64 \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Non-existing.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Non-existing.c new file mode 100644 index 0000000000..47f2f5ab3e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Non-existing.c @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Non-existing.c + +Abstract: + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +InternalSwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + // + // This version of this function does not actually change the stack pointer + // This is to support compilation of CPU types that do not support assemblers + // such as EBC + // + ASSERT (FALSE); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/PalCallStatic.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/PalCallStatic.s new file mode 100644 index 0000000000..d6b883ec62 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/PalCallStatic.s @@ -0,0 +1,48 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// PalCallStatic.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc PalCallStatic +.type PalCallStatic, @function +.regstk 5, 0, 0, 0 +PalCallStatic:: + cmp.eq p15 = in0, r0 + mov r31 = in4 + mov r8 = ip + +(p15) mov in0 = ar.k5 + add r8 = (_PalProcReturn - PalCallStatic), r8 + mov r30 = in3 + + mov in4 = psr + mov in3 = b0 + mov b7 = in0 + + rsm 1 << 14 // Disable interrupts + mov r29 = in2 + mov r28 = in1 + + mov b0 = r8 + br.cond.sptk.many b7 + +_PalProcReturn: + mov psr.l = in4 + mov b0 = in3 + br.ret.sptk.many b0 +.endp PalCallStatic diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ReadItc.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ReadItc.s new file mode 100644 index 0000000000..473c82ec34 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ReadItc.s @@ -0,0 +1,26 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// ReadItc.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc IpfReadItc +.type IpfReadItc, @function +IpfReadItc:: + mov r8 = ar.itc + br.ret.sptk.many b0 +.endp IpfReadItc diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/SwitchStack.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/SwitchStack.s new file mode 100644 index 0000000000..5ec5abae9c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/SwitchStack.s @@ -0,0 +1,51 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// SwitchStack.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc AsmSwitchStackAndBackingStore +.type AsmSwitchStackAndBackingStore, @function +.regstk 5, 0, 0, 0 +AsmSwitchStackAndBackingStore:: + mov r14 = ar.rsc + movl r2 = ~((((1 << 14) - 1) << 16) | 3) + + mov r17 = in1 + mov r18 = in2 + and r2 = r14, r2 + + mov ar.rsc = r2 + mov sp = in3 + mov r19 = in4 + + ld8.nt1 r16 = [in0], 8 + ld8.nta gp = [in0] + mov r3 = -1 + + loadrs + mov ar.bspstore = r19 + mov b7 = r16 + + alloc r2 = ar.pfs, 0, 0, 2, 0 + mov out0 = r17 + mov out1 = r18 + + mov ar.rnat = r3 + mov ar.rsc = r14 + br.call.sptk.many b0 = b7 +.endp AsmSwitchStackAndBackingStore diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Synchronization.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Synchronization.c new file mode 100644 index 0000000000..e1bc578ad1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Synchronization.c @@ -0,0 +1,83 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Synchronization.c + +Abstract: + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InternalSyncIncrement ( + IN volatile UINT32 *Value + ) +{ + UINT32 OriginalValue; + + do { + OriginalValue = *Value; + } while (OriginalValue != InternalSyncCompareExchange32 ( + Value, + OriginalValue, + OriginalValue + 1 + )); + return OriginalValue + 1; +} + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decrement value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + @param Value A pointer to the 32-bit value to decrement. + + @return The decrement value. + +**/ +UINT32 +EFIAPI +InternalSyncDecrement ( + IN volatile UINT32 *Value + ) +{ + UINT32 OriginalValue; + + do { + OriginalValue = *Value; + } while (OriginalValue != InternalSyncCompareExchange32 ( + Value, + OriginalValue, + OriginalValue - 1 + )); + return OriginalValue - 1; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Unaligned.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Unaligned.c new file mode 100644 index 0000000000..bcb3bb806b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/Unaligned.c @@ -0,0 +1,249 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Unaligned.c + +Abstract: + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Reads a 16-bit value from memory that may be unaligned. + + This function returns the 16-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + + @return *Uint16 + +**/ +UINT16 +EFIAPI +ReadUnaligned16 ( + IN CONST UINT16 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return (UINT16)(((UINT8*)Buffer)[0] | (((UINT8*)Buffer)[1] << 8)); +} + +/** + Writes a 16-bit value to memory that may be unaligned. + + This function writes the 16-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + @param Value 16-bit value to write to Buffer. + + @return Value + +**/ +UINT16 +EFIAPI +WriteUnaligned16 ( + OUT UINT16 *Buffer, + IN UINT16 Value + ) +{ + ASSERT (Buffer != NULL); + + ((UINT8*)Buffer)[0] = (UINT8)Value; + ((UINT8*)Buffer)[1] = (UINT8)(Value >> 8); + + return Value; +} + +/** + Reads a 24-bit value from memory that may be unaligned. + + This function returns the 24-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + + @return The value read. + +**/ +UINT32 +EFIAPI +ReadUnaligned24 ( + IN CONST UINT32 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return (UINT32)( + ReadUnaligned16 ((UINT16*)Buffer) | + (((UINT8*)Buffer)[2] << 16) + ); +} + +/** + Writes a 24-bit value to memory that may be unaligned. + + This function writes the 24-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + @param Value 24-bit value to write to Buffer. + + @return The value written. + +**/ +UINT32 +EFIAPI +WriteUnaligned24 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ) +{ + ASSERT (Buffer != NULL); + + WriteUnaligned16 ((UINT16*)Buffer, (UINT16)Value); + *(UINT8*)((UINT16*)Buffer + 1) = (UINT8)(Value >> 16); + return Value; +} + +/** + Reads a 32-bit value from memory that may be unaligned. + + This function returns the 32-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + + @return *Uint32 + +**/ +UINT32 +EFIAPI +ReadUnaligned32 ( + IN CONST UINT32 *Buffer + ) +{ + UINT16 LowerBytes; + UINT16 HigherBytes; + + ASSERT (Buffer != NULL); + + LowerBytes = ReadUnaligned16 ((UINT16*) Buffer); + HigherBytes = ReadUnaligned16 ((UINT16*) Buffer + 1); + + return (UINT32) (LowerBytes | (HigherBytes << 16)); +} + +/** + Writes a 32-bit value to memory that may be unaligned. + + This function writes the 32-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + @param Value 32-bit value to write to Buffer. + + @return Value + +**/ +UINT32 +EFIAPI +WriteUnaligned32 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ) +{ + ASSERT (Buffer != NULL); + + WriteUnaligned16 ((UINT16*)Buffer, (UINT16)Value); + WriteUnaligned16 ((UINT16*)Buffer + 1, (UINT16)(Value >> 16)); + return Value; +} + +/** + Reads a 64-bit value from memory that may be unaligned. + + This function returns the 64-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + + @return *Uint64 + +**/ +UINT64 +EFIAPI +ReadUnaligned64 ( + IN CONST UINT64 *Buffer + ) +{ + UINT32 LowerBytes; + UINT32 HigherBytes; + + ASSERT (Buffer != NULL); + + LowerBytes = ReadUnaligned32 ((UINT32*) Buffer); + HigherBytes = ReadUnaligned32 ((UINT32*) Buffer + 1); + + return (UINT64) (LowerBytes | LShiftU64 (HigherBytes, 32)); +} + +/** + Writes a 64-bit value to memory that may be unaligned. + + This function writes the 64-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + @param Value 64-bit value to write to Buffer. + + @return Value + +**/ +UINT64 +EFIAPI +WriteUnaligned64 ( + OUT UINT64 *Buffer, + IN UINT64 Value + ) +{ + ASSERT (Buffer != NULL); + + WriteUnaligned32 ((UINT32*)Buffer, (UINT32)Value); + WriteUnaligned32 ((UINT32*)Buffer + 1, (UINT32)RShiftU64 (Value, 32)); + return Value; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/asm.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/asm.h new file mode 100644 index 0000000000..1b3c84eff1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/asm.h @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + asm.h + +Abstract: + +--*/ + +#ifndef _ASM_H +#define _ASM_H + +#define TRUE 1 +#define FALSE 0 +#define PROCEDURE_ENTRY(name) .##text; \ + .##type name, @function; \ + .##proc name; \ + name:: + +#define PROCEDURE_EXIT(name) .##endp name + +#endif // _ASM_H diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ia_64gen.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ia_64gen.h new file mode 100644 index 0000000000..a2a284ee18 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/ia_64gen.h @@ -0,0 +1,211 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + asm.h + +Abstract: + +--*/ + +#ifndef _IA64GEN_H +#define _IA64GEN_H + +#define TT_UNAT 0 +#define C_PSR 0 +#define J_UNAT 0 +#define T_TYPE 0 +#define T_IPSR 0x8 +#define T_ISR 0x10 +#define T_IIP 0x18 +#define T_IFA 0x20 +#define T_IIPA 0x28 +#define T_IFS 0x30 +#define T_IIM 0x38 +#define T_RSC 0x40 +#define T_BSP 0x48 +#define T_BSPSTORE 0x50 +#define T_RNAT 0x58 +#define T_PFS 0x60 +#define T_KBSPSTORE 0x68 +#define T_UNAT 0x70 +#define T_CCV 0x78 +#define T_DCR 0x80 +#define T_PREDS 0x88 +#define T_NATS 0x90 +#define T_R1 0x98 +#define T_GP 0x98 +#define T_R2 0xa0 +#define T_R3 0xa8 +#define T_R4 0xb0 +#define T_R5 0xb8 +#define T_R6 0xc0 +#define T_R7 0xc8 +#define T_R8 0xd0 +#define T_R9 0xd8 +#define T_R10 0xe0 +#define T_R11 0xe8 +#define T_R12 0xf0 +#define T_SP 0xf0 +#define T_R13 0xf8 +#define T_R14 0x100 +#define T_R15 0x108 +#define T_R16 0x110 +#define T_R17 0x118 +#define T_R18 0x120 +#define T_R19 0x128 +#define T_R20 0x130 +#define T_R21 0x138 +#define T_R22 0x140 +#define T_R23 0x148 +#define T_R24 0x150 +#define T_R25 0x158 +#define T_R26 0x160 +#define T_R27 0x168 +#define T_R28 0x170 +#define T_R29 0x178 +#define T_R30 0x180 +#define T_R31 0x188 +#define T_F2 0x1f0 +#define T_F3 0x200 +#define T_F4 0x210 +#define T_F5 0x220 +#define T_F6 0x230 +#define T_F7 0x240 +#define T_F8 0x250 +#define T_F9 0x260 +#define T_F10 0x270 +#define T_F11 0x280 +#define T_F12 0x290 +#define T_F13 0x2a0 +#define T_F14 0x2b0 +#define T_F15 0x2c0 +#define T_F16 0x2d0 +#define T_F17 0x2e0 +#define T_F18 0x2f0 +#define T_F19 0x300 +#define T_F20 0x310 +#define T_F21 0x320 +#define T_F22 0x330 +#define T_F23 0x340 +#define T_F24 0x350 +#define T_F25 0x360 +#define T_F26 0x370 +#define T_F27 0x380 +#define T_F28 0x390 +#define T_F29 0x3a0 +#define T_F30 0x3b0 +#define T_F31 0x3c0 +#define T_FPSR 0x1e0 +#define T_B0 0x190 +#define T_B1 0x198 +#define T_B2 0x1a0 +#define T_B3 0x1a8 +#define T_B4 0x1b0 +#define T_B5 0x1b8 +#define T_B6 0x1c0 +#define T_B7 0x1c8 +#define T_EC 0x1d0 +#define T_LC 0x1d8 +#define J_NATS 0x8 +#define J_PFS 0x10 +#define J_BSP 0x18 +#define J_RNAT 0x20 +#define J_PREDS 0x28 +#define J_LC 0x30 +#define J_R4 0x38 +#define J_R5 0x40 +#define J_R6 0x48 +#define J_R7 0x50 +#define J_SP 0x58 +#define J_F2 0x60 +#define J_F3 0x70 +#define J_F4 0x80 +#define J_F5 0x90 +#define J_F16 0xa0 +#define J_F17 0xb0 +#define J_F18 0xc0 +#define J_F19 0xd0 +#define J_F20 0xe0 +#define J_F21 0xf0 +#define J_F22 0x100 +#define J_F23 0x110 +#define J_F24 0x120 +#define J_F25 0x130 +#define J_F26 0x140 +#define J_F27 0x150 +#define J_F28 0x160 +#define J_F29 0x170 +#define J_F30 0x180 +#define J_F31 0x190 +#define J_FPSR 0x1a0 +#define J_B0 0x1a8 +#define J_B1 0x1b0 +#define J_B2 0x1b8 +#define J_B3 0x1c0 +#define J_B4 0x1c8 +#define J_B5 0x1d0 +#define TRAP_FRAME_LENGTH 0x3d0 +#define C_UNAT 0x28 +#define C_NATS 0x30 +#define C_PFS 0x8 +#define C_BSPSTORE 0x10 +#define C_RNAT 0x18 +#define C_RSC 0x20 +#define C_PREDS 0x38 +#define C_LC 0x40 +#define C_DCR 0x48 +#define C_R1 0x50 +#define C_GP 0x50 +#define C_R4 0x58 +#define C_R5 0x60 +#define C_R6 0x68 +#define C_R7 0x70 +#define C_SP 0x78 +#define C_R13 0x80 +#define C_F2 0x90 +#define C_F3 0xa0 +#define C_F4 0xb0 +#define C_F5 0xc0 +#define C_F16 0xd0 +#define C_F17 0xe0 +#define C_F18 0xf0 +#define C_F19 0x100 +#define C_F20 0x110 +#define C_F21 0x120 +#define C_F22 0x130 +#define C_F23 0x140 +#define C_F24 0x150 +#define C_F25 0x160 +#define C_F26 0x170 +#define C_F27 0x180 +#define C_F28 0x190 +#define C_F29 0x1a0 +#define C_F30 0x1b0 +#define C_F31 0x1c0 +#define C_FPSR 0x1d0 +#define C_B0 0x1d8 +#define C_B1 0x1e0 +#define C_B2 0x1e8 +#define C_B3 0x1f0 +#define C_B4 0x1f8 +#define C_B5 0x200 +#define TT_R2 0x8 +#define TT_R3 0x10 +#define TT_R8 0x18 +#define TT_R9 0x20 +#define TT_R10 0x28 +#define TT_R11 0x30 +#define TT_R14 0x38 + +#endif _IA64GEN_H diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/longjmp.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/longjmp.s new file mode 100644 index 0000000000..c0cea0bc62 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/longjmp.s @@ -0,0 +1,122 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// longjmp.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.proc InternalLongJump +.type InternalLongJump, @function +.regstk 2, 0, 0, 0 +InternalLongJump:: + add r10 = 0x10*20 + 8*14, in0 + movl r2 = ~((((1 << 14) - 1) << 16) | 3) + + ld8.nt1 r14 = [r10], -8*2 // BSP, skip PFS + mov r15 = ar.bspstore // BSPSTORE + + ld8.nt1 r17 = [r10], -8 // UNAT after spill + mov r16 = ar.rsc // RSC + cmp.leu p6 = r14, r15 + + ld8.nt1 r18 = [r10], -8 // UNAT + ld8.nt1 r25 = [r10], -8 // b5 + and r2 = r16, r2 + + ldf.fill.nt1 f2 = [in0], 0x10 + ld8.nt1 r24 = [r10], -8 // b4 + mov b5 = r25 + + mov ar.rsc = r2 + ld8.nt1 r23 = [r10], -8 // b3 + mov b4 = r24 + + ldf.fill.nt1 f3 = [in0], 0x10 + mov ar.unat = r17 +(p6) br.spnt.many _skip_flushrs + + flushrs + mov r15 = ar.bsp // New BSPSTORE + +_skip_flushrs: + mov r31 = ar.rnat // RNAT + loadrs + + ldf.fill.nt1 f4 = [in0], 0x10 + ld8.nt1 r22 = [r10], -8 + dep r2 = -1, r14, 3, 6 + + ldf.fill.nt1 f5 = [in0], 0x10 + ld8.nt1 r21 = [r10], -8 + cmp.ltu p6 = r2, r15 + + ld8.nt1 r20 = [r10], -0x10 // skip sp +(p6) ld8.nta r31 = [r2] + mov b3 = r23 + + ldf.fill.nt1 f16 = [in0], 0x10 + ld8.fill.nt1 r7 = [r10], -8 + mov b2 = r22 + + ldf.fill.nt1 f17 = [in0], 0x10 + ld8.fill.nt1 r6 = [r10], -8 + mov b1 = r21 + + ldf.fill.nt1 f18 = [in0], 0x10 + ld8.fill.nt1 r5 = [r10], -8 + mov b0 = r20 + + ldf.fill.nt1 f19 = [in0], 0x10 + ld8.fill.nt1 r4 = [r10], 8*13 + + ldf.fill.nt1 f20 = [in0], 0x10 + ld8.nt1 r19 = [r10], 0x10 // PFS + + ldf.fill.nt1 f21 = [in0], 0x10 + ld8.nt1 r26 = [r10], 8 // Predicate + mov ar.pfs = r19 + + ldf.fill.nt1 f22 = [in0], 0x10 + ld8.nt1 r27 = [r10], 8 // LC + mov pr = r26, -1 + + ldf.fill.nt1 f23 = [in0], 0x10 + ld8.nt1 r28 = [r10], -17*8 - 0x10 + mov ar.lc = r27 + + ldf.fill.nt1 f24 = [in0], 0x10 + ldf.fill.nt1 f25 = [in0], 0x10 + mov r8 = in1 + + ldf.fill.nt1 f26 = [in0], 0x10 + ldf.fill.nt1 f31 = [r10], -0x10 + + ldf.fill.nt1 f27 = [in0], 0x10 + ldf.fill.nt1 f30 = [r10], -0x10 + + ldf.fill.nt1 f28 = [in0] + ldf.fill.nt1 f29 = [r10], 0x10*3 + 8*4 + + ld8.fill.nt1 sp = [r10] + mov ar.unat = r18 + + mov ar.bspstore = r14 + mov ar.rnat = r31 + + invala + mov ar.rsc = r16 + br.ret.sptk b0 +.endp diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s new file mode 100644 index 0000000000..9032bcecb9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/setjmp.s @@ -0,0 +1,109 @@ +/// Copyright (c) 2004, Intel Corporation +/// All rights reserved. This program and the accompanying materials +/// are licensed and made available under the terms and conditions of the BSD License +/// which accompanies this distribution. The full text of the license may be found at +/// http://opensource.org/licenses/bsd-license.php +/// +/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +/// +/// Module Name: +/// +/// setjmp.s +/// +/// Abstract: +/// +/// + +.auto +.text + +.globl InternalAssertJumpBuffer +.type InternalAssertJumpBuffer, @function + +.proc SetJump +.type SetJump, @function +SetJump:: + alloc loc0 = ar.pfs, 1, 2, 1, 0 + mov loc1 = b0 + mov out0 = in0 + + brl.call.sptk.many b0 = InternalAssertJumpBuffer + + mov r14 = ar.unat + mov r15 = ar.bsp + add r10 = 0x10*20, in0 + + stf.spill.nta [in0] = f2, 0x10 + st8.spill.nta [r10] = r4, 8 + mov r21 = b1 + + stf.spill.nta [in0] = f3, 0x10 + st8.spill.nta [r10] = r5, 8 + mov r22 = b2 + + stf.spill.nta [in0] = f4, 0x10 + st8.spill.nta [r10] = r6, 8 + mov r23 = b3 + + stf.spill.nta [in0] = f5, 0x10 + st8.spill.nta [r10] = r7, 8 + mov r24 = b4 + + stf.spill.nta [in0] = f16, 0x10 + st8.spill.nta [r10] = sp, 8 + mov r25 = b5 + + stf.spill.nta [in0] = f17, 0x10 + st8.nta [r10] = loc1, 8 + mov r16 = pr + + stf.spill.nta [in0] = f18, 0x10 + st8.nta [r10] = r21, 8 + mov r17 = ar.lc + + stf.spill.nta [in0] = f19, 0x10 + st8.nta [r10] = r22, 8 + + stf.spill.nta [in0] = f20, 0x10 + st8.nta [r10] = r23, 8 + + stf.spill.nta [in0] = f21, 0x10 + st8.nta [r10] = r24, 8 + + stf.spill.nta [in0] = f22, 0x10 + st8.nta [r10] = r25, 8 + + stf.spill.nta [in0] = f23, 0x10 + mov r18 = ar.unat + + stf.spill.nta [in0] = f24, 0x10 + st8.nta [r10] = r14, 8 // UNAT + + stf.spill.nta [in0] = f25, 0x10 + st8.nta [r10] = r18, 8 // UNAT after spill + + stf.spill.nta [in0] = f26, 0x10 + st8.nta [r10] = loc0, 8 // PFS + + stf.spill.nta [in0] = f27, 0x10 + st8.nta [r10] = r15, 8 // BSP + mov r8 = 0 + + stf.spill.nta [in0] = f28, 0x10 + mov r19 = ar.fpsr + + stf.spill.nta [in0] = f29, 0x10 + st8.nta [r10] = r16, 8 // PR + mov ar.pfs = loc0 + + stf.spill.nta [in0] = f30, 0x10 + st8.nta [r10] = r17, 8 // LC + mov b0 = loc1 + + stf.spill.nta [in0] = f31, 0x10 + st8.nta [r10] = r19 // FPSR + + mov ar.unat = r14 + br.ret.sptk b0 +.endp SetJump diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c new file mode 100644 index 0000000000..81ba6e0917 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LRotU32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 32-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT32 +EFIAPI +LRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return (Operand << Count) | (Operand >> (32 - Count)); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c new file mode 100644 index 0000000000..ba919b2f55 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LRotU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits + with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +LRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathLRotU64 (Operand, Count); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c new file mode 100644 index 0000000000..163fb30895 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LShiftU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled + with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +GlueLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathLShiftU64 (Operand, Count); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c new file mode 100644 index 0000000000..6c680d6863 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c @@ -0,0 +1,471 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LinkedList.c + +Abstract: + + Linked List Library Functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Worker function that locates the Node in the List + + By searching the List, finds the location of the Node in List. At the same time, + verifies the validity of this list. + + If List is NULL, then ASSERT(). + If List->ForwardLink is NULL, then ASSERT(). + If List->backLink is NULL, then ASSERT(). + If Node is NULL, then ASSERT(); + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param List A pointer to a node in a linked list. + @param Node A pointer to one nod. + + @retval TRUE Node is in List + @retval FALSE Node isn't in List, or List is invalid + +**/ +BOOLEAN +IsNodeInList ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + UINTN Count; + CONST LIST_ENTRY *Ptr; + BOOLEAN Found; + + // + // Test the validity of List and Node + // + ASSERT (List != NULL); + ASSERT (List->ForwardLink != NULL); + ASSERT (List->BackLink != NULL); + ASSERT (Node != NULL); + + Count = PcdGet32 (PcdMaximumLinkedListLength); + + Ptr = List; + do { + Ptr = Ptr->ForwardLink; + Count--; + } while ((Ptr != List) && (Ptr != Node) && (Count > 0)); + Found = (BOOLEAN)(Ptr == Node); + + if (PcdGet32 (PcdMaximumLinkedListLength) > 0) { + while ((Count > 0) && (Ptr != List)) { + Ptr = Ptr->ForwardLink; + Count--; + } + ASSERT (Count > 0); + } + + return Found; +} + +/** + Initializes the head node of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Initializes the forward and backward links of a new linked list. After + initializing a linked list with this function, the other linked list + functions may be used to add and remove nodes from the linked list. It is up + to the caller of this function to allocate the memory for ListHead. + + If ListHead is NULL, then ASSERT(). + + @param ListHead A pointer to the head node of a new doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInitializeListHead ( + IN OUT LIST_ENTRY *List + ) + +{ + ASSERT (List != NULL); + + List->ForwardLink = List; + List->BackLink = List; + return List; +} + +/** + Adds a node to the beginning of a doubly linked list, and returns the pointer + to the head node of the doubly linked list. + + Adds the node Entry at the beginning of the doubly linked list denoted by + ListHead, and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be inserted at the beginning + of a doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertHeadList ( + IN OUT LIST_ENTRY *List, + IN OUT LIST_ENTRY *Entry + ) +{ + // + // ASSERT List not too long and Entry is not one of the nodes of List + // + ASSERT (!IsNodeInList (List, Entry)); + + Entry->ForwardLink = List->ForwardLink; + Entry->BackLink = List; + Entry->ForwardLink->BackLink = Entry; + List->ForwardLink = Entry; + return List; +} + +/** + Adds a node to the end of a doubly linked list, and returns the pointer to + the head node of the doubly linked list. + + Adds the node Entry to the end of the doubly linked list denoted by ListHead, + and returns ListHead. + + If ListHead is NULL, then ASSERT(). + If Entry is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number + of nodes in ListHead, including the ListHead node, is greater than or + equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + @param Entry A pointer to a node that is to be added at the end of the + doubly linked list. + + @return ListHead + +**/ +LIST_ENTRY * +EFIAPI +GlueInsertTailList ( + IN OUT LIST_ENTRY *List, + IN OUT LIST_ENTRY *Entry + ) +{ + // + // ASSERT List not too long and Entry is not one of the nodes of List + // + ASSERT (!IsNodeInList (List, Entry)); + + Entry->ForwardLink = List; + Entry->BackLink = List->BackLink; + Entry->BackLink->ForwardLink = Entry; + List->BackLink = Entry; + return List; +} + +/** + Retrieves the first node of a doubly linked list. + + Returns the first node of a doubly linked list. List must have been + initialized with InitializeListHead(). If List is empty, then NULL is + returned. + + If List is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + + @return The first node of a doubly linked list. + @retval NULL The list is empty. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetFirstNode ( + IN CONST LIST_ENTRY *List + ) +{ + // + // ASSERT List not too long + // + ASSERT (IsNodeInList (List, List)); + + return List->ForwardLink; +} + +/** + Retrieves the next node of a doubly linked list. + + Returns the node of a doubly linked list that follows Node. List must have + been initialized with InitializeListHead(). If List is empty, then List is + returned. + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and List contains more than + PcdMaximumLinkedListLenth nodes, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @return Pointer to the next node if one exists. Otherwise a null value which + is actually List is returned. + +**/ +LIST_ENTRY * +EFIAPI +GlueGetNextNode ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + // + // ASSERT List not too long and Node is one of the nodes of List + // + ASSERT (IsNodeInList (List, Node)); + + return Node->ForwardLink; +} + +/** + Checks to see if a doubly linked list is empty or not. + + Checks to see if the doubly linked list is empty. If the linked list contains + zero nodes, this function returns TRUE. Otherwise, it returns FALSE. + + If ListHead is NULL, then ASSERT(). + If ListHead was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param ListHead A pointer to the head node of a doubly linked list. + + @retval TRUE The linked list is empty. + @retval FALSE The linked list is not empty. + +**/ +BOOLEAN +EFIAPI +GlueIsListEmpty ( + IN CONST LIST_ENTRY *List + ) +{ + // + // ASSERT List not too long + // + ASSERT (IsNodeInList (List, List)); + + return (BOOLEAN)(List->ForwardLink == List); +} + +/** + Determines if a node in a doubly linked list is null. + + Returns FALSE if Node is one of the nodes in the doubly linked list specified + by List. Otherwise, TRUE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List and Node is not equal to List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is one of the nodes in the doubly linked list. + @retval FALSE Node is not one of the nodes in the doubly linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNull ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + // + // ASSERT List not too long and Node is one of the nodes of List + // + ASSERT (IsNodeInList (List, Node)); + + return (BOOLEAN)(Node == List); +} + +/** + Determines if a node the last node in a doubly linked list. + + Returns TRUE if Node is the last node in the doubly linked list specified by + List. Otherwise, FALSE is returned. List must have been initialized with + InitializeListHead(). + + If List is NULL, then ASSERT(). + If Node is NULL, then ASSERT(). + If List was not initialized with InitializeListHead(), then ASSERT(). + If PcdMaximumLinkedListLenth is not zero, and the number of nodes + in List, including the List node, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + If Node is not a node in List, then ASSERT(). + + @param List A pointer to the head node of a doubly linked list. + @param Node A pointer to a node in the doubly linked list. + + @retval TRUE Node is the last node in the linked list. + @retval FALSE Node is not the last node in the linked list. + +**/ +BOOLEAN +EFIAPI +GlueIsNodeAtEnd ( + IN CONST LIST_ENTRY *List, + IN CONST LIST_ENTRY *Node + ) +{ + // + // ASSERT List not too long and Node is one of the nodes of List + // + ASSERT (IsNodeInList (List, Node)); + + return (BOOLEAN)(!IsNull (List, Node) && List->BackLink == Node); +} + +/** + Swaps the location of two nodes in a doubly linked list, and returns the + first node after the swap. + + If FirstEntry is identical to SecondEntry, then SecondEntry is returned. + Otherwise, the location of the FirstEntry node is swapped with the location + of the SecondEntry node in a doubly linked list. SecondEntry must be in the + same double linked list as FirstEntry and that double linked list must have + been initialized with InitializeListHead(). SecondEntry is returned after the + nodes are swapped. + + If FirstEntry is NULL, then ASSERT(). + If SecondEntry is NULL, then ASSERT(). + If SecondEntry and FirstEntry are not in the same linked list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing the FirstEntry and SecondEntry nodes, including + the FirstEntry and SecondEntry nodes, is greater than or equal to + PcdMaximumLinkedListLength, then ASSERT(). + + @param FirstEntry A pointer to a node in a linked list. + @param SecondEntry A pointer to another node in the same linked list. + +**/ +LIST_ENTRY * +EFIAPI +GlueSwapListEntries ( + IN OUT LIST_ENTRY *FirstEntry, + IN OUT LIST_ENTRY *SecondEntry + ) +{ + LIST_ENTRY *Ptr; + + if (FirstEntry == SecondEntry) { + return SecondEntry; + } + + // + // ASSERT Entry1 and Entry2 are in the same linked list + // + ASSERT (IsNodeInList (FirstEntry, SecondEntry)); + + // + // Ptr is the node pointed to by FirstEntry->ForwardLink + // + Ptr = RemoveEntryList (FirstEntry); + + // + // If FirstEntry immediately follows SecondEntry, FirstEntry willl be placed + // immediately in front of SecondEntry + // + if (Ptr->BackLink == SecondEntry) { + return InsertTailList (SecondEntry, FirstEntry); + } + + // + // Ptr == SecondEntry means SecondEntry immediately follows FirstEntry, + // then there are no further steps necessary + // + if (Ptr == InsertHeadList (SecondEntry, FirstEntry)) { + return Ptr; + } + + // + // Move SecondEntry to the front of Ptr + // + RemoveEntryList (SecondEntry); + InsertTailList (Ptr, SecondEntry); + return SecondEntry; +} + +/** + Removes a node from a doubly linked list, and returns the node that follows + the removed node. + + Removes the node Entry from a doubly linked list. It is up to the caller of + this function to release the memory used by this node if that is required. On + exit, the node following Entry in the doubly linked list is returned. If + Entry is the only node in the linked list, then the head node of the linked + list is returned. + + If Entry is NULL, then ASSERT(). + If Entry is the head node of an empty list, then ASSERT(). + If PcdMaximumLinkedListLength is not zero, and the number of nodes in the + linked list containing Entry, including the Entry node, is greater than + or equal to PcdMaximumLinkedListLength, then ASSERT(). + + @param Entry A pointer to a node in a linked list + + @return Entry + +**/ +LIST_ENTRY * +EFIAPI +GlueRemoveEntryList ( + IN CONST LIST_ENTRY *Entry + ) +{ + ASSERT (!IsListEmpty (Entry)); + + Entry->ForwardLink->BackLink = Entry->BackLink; + Entry->BackLink->ForwardLink = Entry->ForwardLink; + return Entry->ForwardLink; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c new file mode 100644 index 0000000000..7ca6ab9b30 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LongJump.c + +Abstract: + + Long Jump functions + +--*/ + +#include "BaseLibInternal.h" + +/** + Restores the CPU context that was saved with SetJump(). + + Restores the CPU context from the buffer specified by JumpBuffer. + This function never returns to the caller. + Instead is resumes execution based on the state of JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). + If Value is 0, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + @param Value The value to return when the SetJump() context is restored. + +**/ +VOID +EFIAPI +LongJump ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, + IN UINTN Value + ) +{ + InternalAssertJumpBuffer (JumpBuffer); + ASSERT (Value != 0); + + InternalLongJump (JumpBuffer, Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c new file mode 100644 index 0000000000..eb032152ca --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LowBitSet32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the lowest bit set in a 32-bit value. + + This function computes the bit position of the lowest bit set in the 32-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 31 is returned. + + @param Operand The 32-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet32 ( + IN UINT32 Operand + ) +{ + INTN BitIndex; + + if (Operand == 0) { + return -1; + } + + for (BitIndex = 0; (Operand & 1) == 0; BitIndex++, Operand >>= 1); + return BitIndex; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c new file mode 100644 index 0000000000..1330c7301b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + LowBitSet64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the bit position of the lowest bit set in a 64-bit value. + + This function computes the bit position of the lowest bit set in the 64-bit + value specified by Operand. If Operand is zero, then -1 is returned. + Otherwise, a value between 0 and 63 is returned. + + @param Operand The 64-bit operand to evaluate. + + @return Position of the lowest bit set in Operand if found. + @retval -1 Operand is zero. + +**/ +INTN +EFIAPI +LowBitSet64 ( + IN UINT64 Operand + ) +{ + INTN BitIndex; + + if (Operand == 0) { + return -1; + } + + for (BitIndex = 0; + (Operand & 1) == 0; + BitIndex++, Operand = RShiftU64 (Operand, 1)); + return BitIndex; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c new file mode 100644 index 0000000000..9ca5e0f876 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c @@ -0,0 +1,377 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Match64.c + +Abstract: + + Leaf math worker functions that require 64-bit arithmetic support from the + compiler. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer left between 0 and 63 bits. The low bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the left by Count bits. The + low Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift left. + @param Count The number of bits to shift left. + + @return Operand << Count + +**/ +UINT64 +EFIAPI +InternalMathLShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return Operand << Count; +} + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits + are filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +InternalMathRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return Operand >> Count; +} + +/** + Shifts a 64-bit integer right between 0 and 63 bits. The high bits + are filled with original integer's bit 63. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to bit 63 of Operand. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand arithmetically shifted right by Count + +**/ +UINT64 +EFIAPI +InternalMathARShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + INTN TestValue; + + // + // Test if this compiler supports arithmetic shift + // + TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)); + if (TestValue == -1) { + // + // Arithmetic shift is supported + // + return (UINT64)((INT64)Operand >> Count); + } + + // + // Arithmetic is not supported + // + return (Operand >> Count) | + ((INTN)Operand < 0 ? ~((UINTN)-1 >> Count) : 0); +} + + +/** + Rotates a 64-bit integer left between 0 and 63 bits, filling + the low bits with the high bits that were rotated. + + This function rotates the 64-bit value Operand to the left by Count bits. The + low Count bits are fill with the high Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate left. + @param Count The number of bits to rotate left. + + @return Operand <<< Count + +**/ +UINT64 +EFIAPI +InternalMathLRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return (Operand << Count) | (Operand >> (64 - Count)); +} + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling + the high bits with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +InternalMathRRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + return (Operand >> Count) | (Operand << (64 - Count)); +} + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +InternalMathSwapBytes64 ( + IN UINT64 Operand + ) +{ + UINT64 LowerBytes; + UINT64 HigherBytes; + + LowerBytes = (UINT64) SwapBytes32 ((UINT32) Operand); + HigherBytes = (UINT64) SwapBytes32 ((UINT32) (Operand >> 32)); + + return (LowerBytes << 32 | HigherBytes); +} + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ) +{ + return Multiplicand * Multiplier; +} + + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer + and generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +InternalMathMultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ) +{ + return Multiplicand * Multiplier; +} + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. This + function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + return Dividend / Divisor; +} + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer + and generates a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +InternalMathModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + return (UINT32)(Dividend % Divisor); +} + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result and an optional 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 32-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + @param Remainder A pointer to a 32-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor, + OUT UINT32 *Remainder OPTIONAL + ) +{ + if (Remainder != NULL) { + *Remainder = (UINT32)(Dividend % Divisor); + } + return Dividend / Divisor; +} + +/** + Divides a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result and an optional 64-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit unsigned value. + @param Divisor A 64-bit unsigned value. + @param Remainder A pointer to a 64-bit unsigned value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +UINT64 +EFIAPI +InternalMathDivRemU64x64 ( + IN UINT64 Dividend, + IN UINT64 Divisor, + OUT UINT64 *Remainder OPTIONAL + ) +{ + if (Remainder != NULL) { + *Remainder = Dividend % Divisor; + } + return Dividend / Divisor; +} + +/** + Divides a 64-bit signed integer by a 64-bit signed integer and + generates a 64-bit signed result and a optional 64-bit signed remainder. + + This function divides the 64-bit unsigned value Dividend by the 64-bit + unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder + is not NULL, then the 64-bit unsigned remainder is returned in Remainder. + This function returns the 64-bit unsigned quotient. + + @param Dividend A 64-bit signed value. + @param Divisor A 64-bit signed value. + @param Remainder A pointer to a 64-bit signed value. This parameter is + optional and may be NULL. + + @return Dividend / Divisor + +**/ +INT64 +InternalMathDivRemS64x64 ( + IN INT64 Dividend, + IN INT64 Divisor, + OUT INT64 *Remainder OPTIONAL + ) +{ + if (Remainder != NULL) { + *Remainder = Dividend % Divisor; + } + return Dividend / Divisor; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c new file mode 100644 index 0000000000..22824f2269 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ModU64x32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates + a 32-bit unsigned remainder. + + This function divides the 64-bit unsigned value Dividend by the 32-bit + unsigned value Divisor and generates a 32-bit remainder. This function + returns the 32-bit unsigned remainder. + + If Divisor is 0, then ASSERT(). + + @param Dividend A 64-bit unsigned value. + @param Divisor A 32-bit unsigned value. + + @return Dividend % Divisor + +**/ +UINT32 +EFIAPI +ModU64x32 ( + IN UINT64 Dividend, + IN UINT32 Divisor + ) +{ + ASSERT (Divisor != 0); + return InternalMathModU64x32 (Dividend, Divisor); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c new file mode 100644 index 0000000000..780bfe53b2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + MultS64x64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Multiples a 64-bit signed integer by a 64-bit signed integer and generates a + 64-bit signed result. + + This function multiples the 64-bit signed value Multiplicand by the 64-bit + signed value Multiplier and generates a 64-bit signed result. This 64-bit + signed result is returned. + + If the result overflows, then ASSERT(). + + @param Multiplicand A 64-bit signed value. + @param Multiplier A 64-bit signed value. + + @return Multiplicand * Multiplier + +**/ +INT64 +EFIAPI +MultS64x64 ( + IN INT64 Multiplicand, + IN INT64 Multiplier + ) +{ + return (INT64)MultU64x64 (Multiplicand, Multiplier); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c new file mode 100644 index 0000000000..f9f3a28e95 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + MultU64x32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 32-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 32-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +GlueMultU64x32 ( + IN UINT64 Multiplicand, + IN UINT32 Multiplier + ) +{ + UINT64 Result; + + Result = InternalMathMultU64x32 (Multiplicand, Multiplier); + + return Result; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c new file mode 100644 index 0000000000..c8888bc1fd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + MultU64x64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and + generates a 64-bit unsigned result. + + This function multiples the 64-bit unsigned value Multiplicand by the 64-bit + unsigned value Multiplier and generates a 64-bit unsigned result. This 64- + bit unsigned result is returned. + + @param Multiplicand A 64-bit unsigned value. + @param Multiplier A 64-bit unsigned value. + + @return Multiplicand * Multiplier + +**/ +UINT64 +EFIAPI +MultU64x64 ( + IN UINT64 Multiplicand, + IN UINT64 Multiplier + ) +{ + UINT64 Result; + + Result = InternalMathMultU64x64 (Multiplicand, Multiplier); + + return Result; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c new file mode 100644 index 0000000000..a68df78900 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RRotU32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits + with the low bits that were rotated. + + This function rotates the 32-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 31, then ASSERT(). + + @param Operand The 32-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT32 +EFIAPI +RRotU32 ( + IN UINT32 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return (Operand >> Count) | (Operand << (32 - Count)); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c new file mode 100644 index 0000000000..18b2482e3c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RRotU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits + with the high low bits that were rotated. + + This function rotates the 64-bit value Operand to the right by Count bits. + The high Count bits are fill with the low Count bits of Operand. The rotated + value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to rotate right. + @param Count The number of bits to rotate right. + + @return Operand >>> Count + +**/ +UINT64 +EFIAPI +RRotU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathRRotU64 (Operand, Count); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c new file mode 100644 index 0000000000..ee29680c9b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c @@ -0,0 +1,49 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RShiftU64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Shifts a 64-bit integer right between 0 and 63 bits. This high bits are + filled with zeros. The shifted value is returned. + + This function shifts the 64-bit value Operand to the right by Count bits. The + high Count bits are set to zero. The shifted value is returned. + + If Count is greater than 63, then ASSERT(). + + @param Operand The 64-bit operand to shift right. + @param Count The number of bits to shift right. + + @return Operand >> Count + +**/ +UINT64 +EFIAPI +GlueRShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + ASSERT (Count < sizeof (Operand) * 8); + return InternalMathRShiftU64 (Operand, Count); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c new file mode 100644 index 0000000000..b1bf185816 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SetJump.c + +Abstract: + + Internal ASSERT () functions for SetJump. + +--*/ + +#include "BaseLibInternal.h" + +/** + Worker function that checks ASSERT condition for JumpBuffer + + Checks ASSERT condition for JumpBuffer. + + If JumpBuffer is NULL, then ASSERT(). + If JumpBuffer is not aligned on a BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT + boundary, then ASSERT(). + + @param JumpBuffer A pointer to CPU context buffer. + +**/ +VOID +EFIAPI +InternalAssertJumpBuffer ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ) +{ + ASSERT (JumpBuffer != NULL); + + ASSERT (((UINTN)JumpBuffer & ((BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT - 1) >> 8)) == 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c new file mode 100644 index 0000000000..033092323c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c @@ -0,0 +1,2077 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + String.c + +Abstract: + + Unicode string primatives. + +--*/ + +#include "BaseLibInternal.h" + +/** + Copies one Null-terminated Unicode string to another Null-terminated Unicode + string and returns the new Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destiantion + +**/ +CHAR16 * +EFIAPI +GlueStrCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ) +{ + CHAR16 *ReturnValue; + + // + // Destination cannot be NULL + // + ASSERT (Destination != NULL); + ASSERT (((UINTN) Destination & 0x01) == 0); + + // + // Destination and source cannot overlap + // + ASSERT ((UINTN)(Destination - Source) > StrLen (Source)); + ASSERT ((UINTN)(Source - Destination) > StrLen (Source)); + + ReturnValue = Destination; + while (*Source) { + *(Destination++) = *(Source++); + } + *Destination = 0; + return ReturnValue; +} + +/** + Copies one Null-terminated Unicode string with a maximum length to another + Null-terminated Unicode string with a maximum length and returns the new + Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. At most, Length Unicode + characters are copied from Source to Destination. If Length is 0, then + Destination is returned unmodified. If Length is greater that the number of + Unicode characters in Source, then Destination is padded with Null Unicode + characters. If Source and Destination overlap, then the results are + undefined. + + If Length > 0 and Destination is NULL, then ASSERT(). + If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Length > 0 and Source is NULL, then ASSERT(). + If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to copy. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ) +{ + CHAR16 *ReturnValue; + + if (Length == 0) { + return Destination; + } + + // + // Destination cannot be NULL if Length is not zero + // + ASSERT (Destination != NULL); + ASSERT (((UINTN) Destination & 0x01) == 0); + + // + // Destination and source cannot overlap + // Q: Does Source have to be NULL-terminated? + // + ASSERT ((UINTN)(Destination - Source) > StrLen (Source)); + ASSERT ((UINTN)(Source - Destination) >= Length); + + ReturnValue = Destination; + + while ((*Source != L'\0') && (Length > 0)) { + *(Destination++) = *(Source++); + Length--; + } + + ZeroMem (Destination, Length * sizeof (*Destination)); + return ReturnValue; +} + +/** + Returns the length of a Null-terminated Unicode string. + + This function returns the number of Unicode characters in the Null-terminated + Unicode string specified by String. + + If String is NULL, then ASSERT(). + If String is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The length of String. + +**/ +UINTN +EFIAPI +GlueStrLen ( + IN CONST CHAR16 *String + ) +{ + UINTN Length; + + ASSERT (String != NULL); + ASSERT (((UINTN) String & 0x01) == 0); + + for (Length = 0; *String != L'\0'; String++, Length++) { + // + // If PcdMaximumUnicodeStringLength is not zero, + // length should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) { + ASSERT (Length < PcdGet32 (PcdMaximumUnicodeStringLength)); + } + } + return Length; +} + +/** + Returns the size of a Null-terminated Unicode string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated Unicode + string specified by String. + + If String is NULL, then ASSERT(). + If String is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @return The size of String. + +**/ +UINTN +EFIAPI +GlueStrSize ( + IN CONST CHAR16 *String + ) +{ + return (StrLen (String) + 1) * sizeof (*String); +} + +/** + Compares two Null-terminated Unicode strings, and returns the difference + between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched Unicode character in SecondString subtracted from the first + mismatched Unicode character in FirstString. + + If FirstString is NULL, then ASSERT(). + If FirstString is not aligned on a 16-bit boundary, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If SecondString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString + ) +{ + // + // ASSERT both strings are less long than PcdMaximumUnicodeStringLength + // + ASSERT (StrSize (FirstString) != 0); + ASSERT (StrSize (SecondString) != 0); + + while ((*FirstString != L'\0') && (*FirstString == *SecondString)) { + FirstString++; + SecondString++; + } + return *FirstString - *SecondString; +} + +/** + Compares two Null-terminated Unicode strings with maximum lengths, and + returns the difference between the first mismatched Unicode characters. + + This function compares the Null-terminated Unicode string FirstString to the + Null-terminated Unicode string SecondString. At most, Length Unicode + characters will be compared. If Length is 0, then 0 is returned. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched Unicode character in SecondString + subtracted from the first mismatched Unicode character in FirstString. + + If Length > 0 and FirstString is NULL, then ASSERT(). + If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT(). + If Length > 0 and SecondString is NULL, then ASSERT(). + If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated Unicode string. + @param SecondString Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to compare. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +GlueStrnCmp ( + IN CONST CHAR16 *FirstString, + IN CONST CHAR16 *SecondString, + IN UINTN Length + ) +{ + if (Length == 0) { + return 0; + } + + // + // ASSERT both strings are less long than PcdMaximumUnicodeStringLength. + // Length tests are performed inside StrLen(). + // + ASSERT (StrSize (FirstString) != 0); + ASSERT (StrSize (SecondString) != 0); + + while ((*FirstString != L'\0') && + (*FirstString == *SecondString) && + (Length > 1)) { + FirstString++; + SecondString++; + Length--; + } + + return *FirstString - *SecondString; +} + +/** + Concatenates one Null-terminated Unicode string to another Null-terminated + Unicode string, and returns the concatenated Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination. The Null-terminated concatenated + Unicode String is returned. If Source and Destination overlap, then the + results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ) +{ + StrCpy (Destination + StrLen (Destination), Source); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (StrSize (Destination) != 0); + return Destination; +} + +/** + Concatenates one Null-terminated Unicode string with a maximum length to the + end of another Null-terminated Unicode string, and returns the concatenated + Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination, and Destination is returned. At + most, Length Unicode characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Destination is NULL, then ASSERT(). + If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Length > 0 and Source is NULL, then ASSERT(). + If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated Unicode string. + @param Source Pointer to a Null-terminated Unicode string. + @param Length Maximum number of Unicode characters to concatenate from + Source. + + @return Destination + +**/ +CHAR16 * +EFIAPI +GlueStrnCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ) +{ + StrnCpy (Destination + StrLen (Destination), Source, Length); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (StrSize (Destination) != 0); + return Destination; +} + +/** + Returns the first occurance of a Null-terminated Unicode sub-string + in a Null-terminated Unicode string. + + This function scans the contents of the Null-terminated Unicode string + specified by String and returns the first occurrence of SearchString. + If SearchString is not found in String, then NULL is returned. If + the length of SearchString is zero, then String is + returned. + + If String is NULL, then ASSERT(). + If String is not aligned on a 16-bit boundary, then ASSERT(). + If SearchString is NULL, then ASSERT(). + If SearchString is not aligned on a 16-bit boundary, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and SearchString + or String contains more than PcdMaximumUnicodeStringLength Unicode + characters not including the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + @param SearchString Pointer to a Null-terminated Unicode string to search for. + + @retval NULL If the SearchString does not appear in String. + @retval !NULL If there is a match. + +**/ +CHAR16 * +EFIAPI +StrStr ( + IN CONST CHAR16 *String, + IN CONST CHAR16 *SearchString + ) +{ + CONST CHAR16 *FirstMatch; + CONST CHAR16 *SearchStringTmp; + + ASSERT (String != NULL); + ASSERT (((UINTN) String & 0x01) == 0); + ASSERT (SearchString != NULL); + ASSERT (((UINTN) SearchString & 0x01) == 0); + + // + // If PcdMaximumUnicodeStringLength is not zero, + // length of String should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) { + ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength)); + } + + // + // If PcdMaximumUnicodeStringLength is not zero, + // length of SearchString should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) { + ASSERT (StrLen (SearchString) < PcdGet32 (PcdMaximumAsciiStringLength)); + } + + while (*String != '\0') { + SearchStringTmp = SearchString; + FirstMatch = String; + + while ((*String == *SearchStringTmp) + && (*SearchStringTmp != '\0') + && (*String != '\0')) { + String++; + SearchStringTmp++; + } + + if (*SearchStringTmp == '\0') { + return (CHAR16 *) FirstMatch; + } + + if (SearchStringTmp == SearchString) { + // + // If no character from SearchString match, + // move the pointer to the String under search + // by one character. + // + String++; + } + } + + return NULL; +} + +/** + Check if a Unicode character is a decimal character. + + This internal function checks if a Unicode character is a + decimal character. The valid decimal character is from + L'0' to L'9'. + + + @param Char The character to check against. + + @retval TRUE If the Char is a decmial character. + @retval FALSE Otherwise. + +**/ +STATIC +BOOLEAN +InternalIsDecimalDigitCharacter ( + IN CHAR16 Char + ) +{ + return (BOOLEAN) (Char >= L'0' && Char <= L'9'); +} + +/** + Convert a Unicode character to upper case only if + it maps to a valid small-case ASCII character. + + This internal function only deal with Unicode character + which maps to a valid small-case ASII character, i.e. + L'a' to L'z'. For other Unicode character, the input character + is returned directly. + + + @param Char The character to convert. + + @retval LowerCharacter If the Char is with range L'a' to L'z'. + @retval Unchanged Otherwise. + +**/ +STATIC +CHAR16 +InternalCharToUpper ( + IN CHAR16 Char + ) +{ + if (Char >= L'a' && Char <= L'z') { + return (CHAR16) (Char - (L'a' - L'A')); + } + + return Char; +} + +/** + Convert a Unicode character to numerical value. + + This internal function only deal with Unicode character + which maps to a valid hexadecimal ASII character, i.e. + L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other + Unicode character, the value returned does not make sense. + + @param Char The character to convert. + + @retval UINTN The numerical value converted. + +**/ +STATIC +UINTN +InternalHexCharToUintn ( + IN CHAR16 Char + ) +{ + if (InternalIsDecimalDigitCharacter (Char)) { + return Char - L'0'; + } + + return (UINTN) (10 + InternalCharToUpper (Char) - L'A'); +} + +/** + Check if a Unicode character is a hexadecimal character. + + This internal function checks if a Unicode character is a + decimal character. The valid hexadecimal character is + L'0' to L'9', L'a' to L'f', or L'A' to L'F'. + + + @param Char The character to check against. + + @retval TRUE If the Char is a hexadecmial character. + @retval FALSE Otherwise. + +**/ +STATIC +BOOLEAN +InternalIsHexaDecimalDigitCharacter ( + IN CHAR16 Char + ) +{ + + return (BOOLEAN) (InternalIsDecimalDigitCharacter (Char) || + (Char >= L'A' && Char <= L'F') || + (Char >= L'a' && Char <= L'f')); +} + +/** + Convert a Null-terminated Unicode decimal string to a value of + type UINTN. + + This function returns a value of type UINTN by interpreting the contents + of the Unicode string specified by String as a decimal number. The format + of the input Unicode string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The + function will ignore the pad space, which includes spaces or + tab characters, before [decimal digits]. The running zero in the + beginning of [decimal digits] will be ignored. Then, the function + stops at the first character that is a not a valid decimal character + or a Null-terminator, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, + then 0 is returned. + If the number represented by String overflows according + to the range defined by UINTN, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINTN + +**/ +UINTN +EFIAPI +StrDecimalToUintn ( + IN CONST CHAR16 *String + ) +{ + UINTN Result; + + ASSERT (String != NULL); + ASSERT (((UINTN) String & 0x01) == 0); + ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength)); + + // + // Ignore the pad spaces (space or tab) + // + while ((*String == L' ') || (*String == L'\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == L'0') { + String++; + } + + Result = 0; + + while (InternalIsDecimalDigitCharacter (*String)) { + // + // If the number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) || + ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_10) && + (*String - L'0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10) + ); + + Result = Result * 10 + (*String - L'0'); + String++; + } + + return Result; +} + + +/** + Convert a Null-terminated Unicode decimal string to a value of + type UINT64. + + This function returns a value of type UINT64 by interpreting the contents + of the Unicode string specified by String as a decimal number. The format + of the input Unicode string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The + function will ignore the pad space, which includes spaces or + tab characters, before [decimal digits]. The running zero in the + beginning of [decimal digits] will be ignored. Then, the function + stops at the first character that is a not a valid decimal character + or a Null-terminator, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, + then 0 is returned. + If the number represented by String overflows according + to the range defined by UINT64, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +StrDecimalToUint64 ( + IN CONST CHAR16 *String + ) +{ + UINT64 Result; + + ASSERT (String != NULL); + ASSERT (((UINTN) String & 0x01) == 0); + ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength)); + + // + // Ignore the pad spaces (space or tab) + // + while ((*String == L' ') || (*String == L'\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == L'0') { + String++; + } + + Result = 0; + + while (InternalIsDecimalDigitCharacter (*String)) { + // + // If the number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) || + ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_10) && + (*String - L'0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10) + ); + + Result = MultU64x32 (Result, 10) + (*String - L'0'); + String++; + } + + return Result; +} + +/** + Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN. + + This function returns a value of type UINTN by interpreting the contents + of the Unicode string specified by String as a hexadecimal number. + The format of the input Unicode string String is: + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. + If "x" appears in the input string, it must be prefixed with at least one 0. + The function will ignore the pad space, which includes spaces or tab characters, + before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or + [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the + first valid hexadecimal digit. Then, the function stops at the first character that is + a not a valid hexadecimal character or NULL, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then zero is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, + then zero is returned. + If the number represented by String overflows according to the range defined by + UINTN, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINTN + +**/ +UINTN +EFIAPI +StrHexToUintn ( + IN CONST CHAR16 *String + ) +{ + UINTN Result; + + ASSERT (String != NULL); + ASSERT (((UINTN) String & 0x01) == 0); + ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength)); + + // + // Ignore the pad spaces (space or tab) + // + while ((*String == L' ') || (*String == L'\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == L'0') { + String++; + } + + if (InternalCharToUpper (*String) == L'X') { + ASSERT (*(String - 1) == L'0'); + if (*(String - 1) != L'0') { + return 0; + } + // + // Skip the 'X' + // + String++; + } + + Result = 0; + + while (InternalIsHexaDecimalDigitCharacter (*String)) { + // + // If the Hex Number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) || + ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_16) && + (InternalHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16)) + ); + + Result = (Result << 4) + InternalHexCharToUintn (*String); + String++; + } + + return Result; +} + + +/** + Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64. + + This function returns a value of type UINT64 by interpreting the contents + of the Unicode string specified by String as a hexadecimal number. + The format of the input Unicode string String is + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. + If "x" appears in the input string, it must be prefixed with at least one 0. + The function will ignore the pad space, which includes spaces or tab characters, + before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or + [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the + first valid hexadecimal digit. Then, the function stops at the first character that is + a not a valid hexadecimal character or NULL, whichever one comes first. + + If String is NULL, then ASSERT(). + If String is not aligned in a 16-bit boundary, then ASSERT(). + If String has only pad spaces, then zero is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, + then zero is returned. + If the number represented by String overflows according to the range defined by + UINT64, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and String contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated Unicode string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +StrHexToUint64 ( + IN CONST CHAR16 *String + ) +{ + UINT64 Result; + + ASSERT (String != NULL); + ASSERT (((UINTN) String & 0x01) == 0); + ASSERT (StrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength)); + + // + // Ignore the pad spaces (space or tab) + // + while ((*String == L' ') || (*String == L'\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == L'0') { + String++; + } + + if (InternalCharToUpper (*String) == L'X') { + ASSERT (*(String - 1) == L'0'); + if (*(String - 1) != L'0') { + return 0; + } + // + // Skip the 'X' + // + String++; + } + + Result = 0; + + while (InternalIsHexaDecimalDigitCharacter (*String)) { + // + // If the Hex Number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16)|| + ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_16) && + (InternalHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16)) + ); + + Result = LShiftU64 (Result, 4); + Result = Result + InternalHexCharToUintn (*String); + String++; + } + + return Result; +} + +/** + Check if a ASCII character is a decimal character. + + This internal function checks if a Unicode character is a + decimal character. The valid decimal character is from + '0' to '9'. + + @param Char The character to check against. + + @retval TRUE If the Char is a decmial character. + @retval FALSE Otherwise. + +**/ +STATIC +BOOLEAN +InternalAsciiIsDecimalDigitCharacter ( + IN CHAR8 Char + ) +{ + return (BOOLEAN) (Char >= '0' && Char <= '9'); +} + +/** + Check if a ASCII character is a hexadecimal character. + + This internal function checks if a ASCII character is a + decimal character. The valid hexadecimal character is + L'0' to L'9', L'a' to L'f', or L'A' to L'F'. + + + @param Char The character to check against. + + @retval TRUE If the Char is a hexadecmial character. + @retval FALSE Otherwise. + +**/ +STATIC +BOOLEAN +InternalAsciiIsHexaDecimalDigitCharacter ( + IN CHAR8 Char + ) +{ + + return (BOOLEAN) (InternalAsciiIsDecimalDigitCharacter (Char) || + (Char >= 'A' && Char <= 'F') || + (Char >= 'a' && Char <= 'f')); +} + +/** + Convert a Null-terminated Unicode string to a Null-terminated + ASCII string and returns the ASCII string. + + This function converts the content of the Unicode string Source + to the ASCII string Destination by copying the lower 8 bits of + each Unicode character. It returns Destination. The function terminates + the ASCII string Destination by appending a Null-terminator character + at the end. The caller is responsible to make sure Destination points + to a buffer with size equal or greater than (StrLen (Source) + 1) in bytes. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + + If any Unicode characters in Source contain non-zero value in + the upper 8 bits, then ASSERT(). + + If PcdMaximumUnicodeStringLength is not zero, and Source contains + more than PcdMaximumUnicodeStringLength Unicode characters not including + the Null-terminator, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and Source contains more + than PcdMaximumAsciiStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param Source Pointer to a Null-terminated Unicode string. + @param Destination Pointer to a Null-terminated ASCII string. + + @reture Destination + +**/ +CHAR8 * +EFIAPI +UnicodeStrToAsciiStr ( + IN CONST CHAR16 *Source, + OUT CHAR8 *Destination + ) +{ + ASSERT (Destination != NULL); + ASSERT (Source != NULL); + ASSERT (((UINTN) Source & 0x01) == 0); + + // + // Source and Destination should not overlap + // + ASSERT ((UINTN) ((CHAR16 *) Destination - Source) > StrLen (Source)); + ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source)); + + // + // If PcdMaximumUnicodeStringLength is not zero, + // length of Source should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) { + ASSERT (StrLen (Source) < PcdGet32 (PcdMaximumUnicodeStringLength)); + } + + while (*Source != '\0') { + // + // If any Unicode characters in Source contain + // non-zero value in the upper 8 bits, then ASSERT(). + // + ASSERT (*Source < 0x100); + *(Destination++) = (CHAR8) *(Source++); + } + + *Destination = '\0'; + + return Destination; +} + + +/** + Copies one Null-terminated ASCII string to another Null-terminated ASCII + string and returns the new ASCII string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. If Source and Destination + overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ) +{ + CHAR8 *ReturnValue; + + // + // Destination cannot be NULL + // + ASSERT (Destination != NULL); + + // + // Destination and source cannot overlap + // + ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source)); + ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source)); + + ReturnValue = Destination; + while (*Source) { + *(Destination++) = *(Source++); + } + *Destination = 0; + return ReturnValue; +} + +/** + Copies one Null-terminated ASCII string with a maximum length to another + Null-terminated ASCII string with a maximum length and returns the new ASCII + string. + + This function copies the contents of the ASCII string Source to the ASCII + string Destination, and returns Destination. At most, Length ASCII characters + are copied from Source to Destination. If Length is 0, then Destination is + returned unmodified. If Length is greater that the number of ASCII characters + in Source, then Destination is padded with Null ASCII characters. If Source + and Destination overlap, then the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to copy. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCpy ( + OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ) +{ + CHAR8 *ReturnValue; + + if (Length == 0) { + return Destination; + } + + // + // Destination cannot be NULL + // + ASSERT (Destination != NULL); + + // + // Destination and source cannot overlap + // + ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source)); + ASSERT ((UINTN)(Source - Destination) >= Length); + + ReturnValue = Destination; + + while (*Source && Length > 0) { + *(Destination++) = *(Source++); + Length--; + } + + ZeroMem (Destination, Length * sizeof (*Destination)); + return ReturnValue; +} + +/** + Returns the length of a Null-terminated ASCII string. + + This function returns the number of ASCII characters in the Null-terminated + ASCII string specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The length of String. + +**/ +UINTN +EFIAPI +AsciiStrLen ( + IN CONST CHAR8 *String + ) +{ + UINTN Length; + + ASSERT (String != NULL); + + for (Length = 0; *String != '\0'; String++, Length++) { + // + // If PcdMaximumUnicodeStringLength is not zero, + // length should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) { + ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength)); + } + } + return Length; +} + +/** + Returns the size of a Null-terminated ASCII string in bytes, including the + Null terminator. + + This function returns the size, in bytes, of the Null-terminated ASCII string + specified by String. + + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @return The size of String. + +**/ +UINTN +EFIAPI +AsciiStrSize ( + IN CONST CHAR8 *String + ) +{ + return (AsciiStrLen (String) + 1) * sizeof (*String); +} + +/** + Compares two Null-terminated ASCII strings, and returns the difference + between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. If FirstString is identical to + SecondString, then 0 is returned. Otherwise, the value returned is the first + mismatched ASCII character in SecondString subtracted from the first + mismatched ASCII character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ) +{ + // + // ASSERT both strings are less long than PcdMaximumAsciiStringLength + // + ASSERT (AsciiStrSize (FirstString)); + ASSERT (AsciiStrSize (SecondString)); + + while ((*FirstString != '\0') && (*FirstString == *SecondString)) { + FirstString++; + SecondString++; + } + + return *FirstString - *SecondString; +} + +/** + Converts a lowercase Ascii character to upper one + + If Chr is lowercase Ascii character, then converts it to upper one. + + If Value >= 0xA0, then ASSERT(). + If (Value & 0x0F) >= 0x0A, then ASSERT(). + + @param chr one Ascii character + + @return The uppercase value of Ascii character + +**/ +STATIC +CHAR8 +AsciiToUpper ( + IN CHAR8 Chr + ) +{ + return (UINT8) ((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr); +} + +/** + Convert a ASCII character to numerical value. + + This internal function only deal with Unicode character + which maps to a valid hexadecimal ASII character, i.e. + '0' to '9', 'a' to 'f' or 'A' to 'F'. For other + ASCII character, the value returned does not make sense. + + @param Char The character to convert. + + @retval UINTN The numerical value converted. + +**/ +STATIC +UINTN +InternalAsciiHexCharToUintn ( + IN CHAR8 Char + ) +{ + if (InternalIsDecimalDigitCharacter (Char)) { + return Char - '0'; + } + + return (UINTN) (10 + AsciiToUpper (Char) - 'A'); +} + + +/** + Performs a case insensitive comparison of two Null-terminated ASCII strings, + and returns the difference between the first mismatched ASCII characters. + + This function performs a case insensitive comparison of the Null-terminated + ASCII string FirstString to the Null-terminated ASCII string SecondString. If + FirstString is identical to SecondString, then 0 is returned. Otherwise, the + value returned is the first mismatched lower case ASCII character in + SecondString subtracted from the first mismatched lower case ASCII character + in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more + than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString using case insensitive + comparisons. + @retval !=0 FirstString is not identical to SecondString using case + insensitive comparisons. + +**/ +INTN +EFIAPI +AsciiStriCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString + ) +{ + CHAR8 UpperFirstString; + CHAR8 UpperSecondString; + + // + // ASSERT both strings are less long than PcdMaximumAsciiStringLength + // + ASSERT (AsciiStrSize (FirstString)); + ASSERT (AsciiStrSize (SecondString)); + + UpperFirstString = AsciiToUpper (*FirstString); + UpperSecondString = AsciiToUpper (*SecondString); + while ((*FirstString != '\0') && (UpperFirstString == UpperSecondString)) { + FirstString++; + SecondString++; + UpperFirstString = AsciiToUpper (*FirstString); + UpperSecondString = AsciiToUpper (*SecondString); + } + + return UpperFirstString - UpperSecondString; +} + +/** + Compares two Null-terminated ASCII strings with maximum lengths, and returns + the difference between the first mismatched ASCII characters. + + This function compares the Null-terminated ASCII string FirstString to the + Null-terminated ASCII string SecondString. At most, Length ASCII characters + will be compared. If Length is 0, then 0 is returned. If FirstString is + identical to SecondString, then 0 is returned. Otherwise, the value returned + is the first mismatched ASCII character in SecondString subtracted from the + first mismatched ASCII character in FirstString. + + If FirstString is NULL, then ASSERT(). + If SecondString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and FirstString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and SecondString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param FirstString Pointer to a Null-terminated ASCII string. + @param SecondString Pointer to a Null-terminated ASCII string. + + @retval 0 FirstString is identical to SecondString. + @retval !=0 FirstString is not identical to SecondString. + +**/ +INTN +EFIAPI +AsciiStrnCmp ( + IN CONST CHAR8 *FirstString, + IN CONST CHAR8 *SecondString, + IN UINTN Length + ) +{ + if (Length == 0) { + return 0; + } + + // + // ASSERT both strings are less long than PcdMaximumAsciiStringLength + // + ASSERT (AsciiStrSize (FirstString)); + ASSERT (AsciiStrSize (SecondString)); + + while ((*FirstString != '\0') && + (*FirstString == *SecondString) && + (Length > 1)) { + FirstString++; + SecondString++; + Length--; + } + return *FirstString - *SecondString; +} + +/** + Concatenates one Null-terminated ASCII string to another Null-terminated + ASCII string, and returns the concatenated ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents of + Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination. The Null-terminated concatenated ASCII + String is returned. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source + ) +{ + AsciiStrCpy (Destination + AsciiStrLen (Destination), Source); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (AsciiStrSize (Destination) != 0); + return Destination; +} + +/** + Concatenates one Null-terminated ASCII string with a maximum length to the + end of another Null-terminated ASCII string, and returns the concatenated + ASCII string. + + This function concatenates two Null-terminated ASCII strings. The contents + of Null-terminated ASCII string Source are concatenated to the end of Null- + terminated ASCII string Destination, and Destination is returned. At most, + Length ASCII characters are concatenated from Source to the end of + Destination, and Destination is always Null-terminated. If Length is 0, then + Destination is returned unmodified. If Source and Destination overlap, then + the results are undefined. + + If Destination is NULL, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Destination contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and + Source results in a ASCII string with more than PcdMaximumAsciiStringLength + ASCII characters not including the Null-terminator, then ASSERT(). + + @param Destination Pointer to a Null-terminated ASCII string. + @param Source Pointer to a Null-terminated ASCII string. + @param Length Maximum number of ASCII characters to concatenate from + Source. + + @return Destination + +**/ +CHAR8 * +EFIAPI +AsciiStrnCat ( + IN OUT CHAR8 *Destination, + IN CONST CHAR8 *Source, + IN UINTN Length + ) +{ + AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length); + + // + // Size of the resulting string should never be zero. + // PcdMaximumUnicodeStringLength is tested inside StrLen(). + // + ASSERT (AsciiStrSize (Destination) != 0); + return Destination; +} + +/** + Returns the first occurance of a Null-terminated ASCII sub-string + in a Null-terminated ASCII string. + + This function scans the contents of the ASCII string specified by String + and returns the first occurrence of SearchString. If SearchString is not + found in String, then NULL is returned. If the length of SearchString is zero, + then String is returned. + + If String is NULL, then ASSERT(). + If SearchString is NULL, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and SearchString or + String contains more than PcdMaximumAsciiStringLength Unicode characters + not including the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + @param SearchString Pointer to a Null-terminated ASCII string to search for. + + @retval NULL If the SearchString does not appear in String. + @retval !NULL If there is a match. + +**/ +CHAR8 * +EFIAPI +AsciiStrStr ( + IN CONST CHAR8 *String, + IN CONST CHAR8 *SearchString + ) +{ + CONST CHAR8 *FirstMatch; + CONST CHAR8 *SearchStringTmp; + + ASSERT (String != NULL); + ASSERT (SearchString != NULL); + + // + // If PcdMaximumUnicodeStringLength is not zero, + // length of String should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) { + ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength)); + } + + // + // If PcdMaximumUnicodeStringLength is not zero, + // length of SearchString should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) { + ASSERT (AsciiStrLen (SearchString) < PcdGet32 (PcdMaximumAsciiStringLength)); + } + + while (*String != '\0') { + SearchStringTmp = SearchString; + FirstMatch = String; + + while ((*String == *SearchStringTmp) + && (*SearchStringTmp != '\0') + && (*String != '\0')) { + String++; + SearchStringTmp++; + } + + if (*SearchStringTmp == '\0') { + return (CHAR8 *) FirstMatch; + } + + if (SearchStringTmp == SearchString) { + // + // If no character from SearchString match, + // move the pointer to the String under search + // by one character. + // + String++; + } + + } + + return NULL; +} + +/** + Convert a Null-terminated ASCII decimal string to a value of type + UINTN. + + This function returns a value of type UINTN by interpreting the contents + of the ASCII string String as a decimal number. The format of the input + ASCII string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The function will + ignore the pad space, which includes spaces or tab characters, before the digits. + The running zero in the beginning of [decimal digits] will be ignored. Then, the + function stops at the first character that is a not a valid decimal character or + Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, then 0 is returned. + If the number represented by String overflows according to the range defined by + UINTN, then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINTN + +**/ +UINTN +EFIAPI +AsciiStrDecimalToUintn ( + IN CONST CHAR8 *String + ) +{ + UINTN Result; + + ASSERT (String != NULL); + ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength)); + + // + // Ignore the pad spaces (space or tab) + // + while ((*String == ' ') || (*String == '\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == '0') { + String++; + } + + Result = 0; + + while (InternalAsciiIsDecimalDigitCharacter (*String)) { + // + // If the number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_10) || + ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_10) && + (*String - '0') <= REMINDER_MAX_UINTN_DIVIDED_BY_10) + ); + + Result = Result * 10 + (*String - '0'); + String++; + } + + return Result; +} + + +/** + Convert a Null-terminated ASCII decimal string to a value of type + UINT64. + + This function returns a value of type UINT64 by interpreting the contents + of the ASCII string String as a decimal number. The format of the input + ASCII string String is: + + [spaces] [decimal digits]. + + The valid decimal digit character is in the range [0-9]. The function will + ignore the pad space, which includes spaces or tab characters, before the digits. + The running zero in the beginning of [decimal digits] will be ignored. Then, the + function stops at the first character that is a not a valid decimal character or + Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no pad spaces or valid decimal digits, then 0 is returned. + If the number represented by String overflows according to the range defined by + UINT64, then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and String contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +AsciiStrDecimalToUint64 ( + IN CONST CHAR8 *String + ) +{ + UINT64 Result; + + ASSERT (String != NULL); + ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength)); + + // + // Ignore the pad spaces (space or tab) + // + while ((*String == ' ') || (*String == '\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == '0') { + String++; + } + + Result = 0; + + while (InternalAsciiIsDecimalDigitCharacter (*String)) { + // + // If the number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_10) || + ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_10) && + (*String - '0') <= REMINDER_MAX_UINT64_DIVIDED_BY_10) + ); + + Result = MultU64x32 (Result, 10) + (*String - '0'); + String++; + } + + return Result; +} + +/** + Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN. + + This function returns a value of type UINTN by interpreting the contents of + the ASCII string String as a hexadecimal number. The format of the input ASCII + string String is: + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" + appears in the input string, it must be prefixed with at least one 0. The function + will ignore the pad space, which includes spaces or tab characters, before [zeros], + [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] + will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal + digit. Then, the function stops at the first character that is a not a valid + hexadecimal character or Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then + 0 is returned. + + If the number represented by String overflows according to the range defined by UINTN, + then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, + and String contains more than PcdMaximumAsciiStringLength ASCII characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINTN + +**/ +UINTN +EFIAPI +AsciiStrHexToUintn ( + IN CONST CHAR8 *String + ) +{ + UINTN Result; + + ASSERT (String != NULL); + ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumAsciiStringLength)); + + // + // Ignore the pad spaces (space or tab) + // + while ((*String == ' ') || (*String == '\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == '0') { + String++; + } + + if (AsciiToUpper (*String) == 'X') { + ASSERT (*(String - 1) == '0'); + if (*(String - 1) != '0') { + return 0; + } + // + // Skip the 'X' + // + String++; + } + + Result = 0; + + while (InternalAsciiIsHexaDecimalDigitCharacter (*String)) { + // + // If the Hex Number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINTN_DIVIDED_BY_16) || + ((Result == QUIENT_MAX_UINTN_DIVIDED_BY_16) && + (InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINTN_DIVIDED_BY_16)) + ); + + Result = (Result << 4) + InternalAsciiHexCharToUintn (*String); + String++; + } + + return Result; +} + + +/** + Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64. + + This function returns a value of type UINT64 by interpreting the contents of + the ASCII string String as a hexadecimal number. The format of the input ASCII + string String is: + + [spaces][zeros][x][hexadecimal digits]. + + The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F]. + The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x" + appears in the input string, it must be prefixed with at least one 0. The function + will ignore the pad space, which includes spaces or tab characters, before [zeros], + [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits] + will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal + digit. Then, the function stops at the first character that is a not a valid + hexadecimal character or Null-terminator, whichever on comes first. + + If String has only pad spaces, then 0 is returned. + If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then + 0 is returned. + + If the number represented by String overflows according to the range defined by UINT64, + then ASSERT(). + If String is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, + and String contains more than PcdMaximumAsciiStringLength ASCII characters not including + the Null-terminator, then ASSERT(). + + @param String Pointer to a Null-terminated ASCII string. + + @retval UINT64 + +**/ +UINT64 +EFIAPI +AsciiStrHexToUint64 ( + IN CONST CHAR8 *String + ) +{ + UINT64 Result; + + ASSERT (String != NULL); + ASSERT (AsciiStrLen (String) < PcdGet32 (PcdMaximumUnicodeStringLength)); + + // + // Ignore the pad spaces (space or tab) and leading Zeros + // + // + // Ignore the pad spaces (space or tab) + // + while ((*String == ' ') || (*String == '\t')) { + String++; + } + + // + // Ignore leading Zeros after the spaces + // + while (*String == '0') { + String++; + } + + if (AsciiToUpper (*String) == 'X') { + ASSERT (*(String - 1) == '0'); + if (*(String - 1) != '0') { + return 0; + } + // + // Skip the 'X' + // + String++; + } + + Result = 0; + + while (InternalAsciiIsHexaDecimalDigitCharacter (*String)) { + // + // If the Hex Number represented by String overflows according + // to the range defined by UINTN, then ASSERT(). + // + ASSERT ((Result < QUIENT_MAX_UINT64_DIVIDED_BY_16) || + ((Result == QUIENT_MAX_UINT64_DIVIDED_BY_16) && + (InternalAsciiHexCharToUintn (*String) <= REMINDER_MAX_UINT64_DIVIDED_BY_16)) + ); + + Result = LShiftU64 (Result, 4); + Result = Result + InternalAsciiHexCharToUintn (*String); + String++; + } + + return Result; +} + + +/** + Convert one Null-terminated ASCII string to a Null-terminated + Unicode string and returns the Unicode string. + + This function converts the contents of the ASCII string Source to the Unicode + string Destination, and returns Destination. The function terminates the + Unicode string Destination by appending a Null-terminator character at the end. + The caller is responsible to make sure Destination points to a buffer with size + equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes. + + If Destination is NULL, then ASSERT(). + If Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and Source contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, + then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param Source Pointer to a Null-terminated ASCII string. + @param Destination Pointer to a Null-terminated Unicode string. + + @reture Destination + +**/ +CHAR16 * +EFIAPI +AsciiStrToUnicodeStr ( + IN CONST CHAR8 *Source, + OUT CHAR16 *Destination + ) +{ + ASSERT (Destination != NULL); + ASSERT (Source != NULL); + + // + // Source and Destination should not overlap + // + ASSERT ((UINTN) ((CHAR8 *) Destination - Source) > AsciiStrLen (Source)); + ASSERT ((UINTN) (Source - (CHAR8 *) Destination) > (AsciiStrLen (Source) * sizeof (CHAR16))); + + // + // If PcdMaximumAsciiStringLength is not zero, + // length of Source should not more than PcdMaximumUnicodeStringLength + // + if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) { + ASSERT (AsciiStrLen (Source) < PcdGet32 (PcdMaximumAsciiStringLength)); + } + + while (*Source != '\0') { + *(Destination++) = (CHAR16) *(Source++); + } + // + // End the Destination with a NULL. + // + *Destination = '\0'; + + return Destination; +} + +/** + Converts an 8-bit value to an 8-bit BCD value. + + Converts the 8-bit value specified by Value to BCD. The BCD value is + returned. + + If Value >= 100, then ASSERT(). + + @param Value The 8-bit value to convert to BCD. Range 0..99. + + @return The BCD value + +**/ +UINT8 +EFIAPI +DecimalToBcd8 ( + IN UINT8 Value + ) +{ + ASSERT (Value < 100); + return (UINT8) (((Value / 10) << 4) | (Value % 10)); +} + +/** + Converts an 8-bit BCD value to an 8-bit value. + + Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit + value is returned. + + If Value >= 0xA0, then ASSERT(). + If (Value & 0x0F) >= 0x0A, then ASSERT(). + + @param Value The 8-bit BCD value to convert to an 8-bit value. + + @return The 8-bit value is returned. + +**/ +UINT8 +EFIAPI +BcdToDecimal8 ( + IN UINT8 Value + ) +{ + ASSERT (Value < 0xa0); + ASSERT ((Value & 0xf) < 0xa); + return (UINT8) ((Value >> 4) * 10 + (Value & 0xf)); +} + + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c new file mode 100644 index 0000000000..890369ed29 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SwapBytes16.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Switches the endianess of a 16-bit integer. + + This function swaps the bytes in a 16-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 16-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT16 +EFIAPI +SwapBytes16 ( + IN UINT16 Operand + ) +{ + return (UINT16) ((Operand << 8) | (Operand >> 8)); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c new file mode 100644 index 0000000000..59b4659663 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SwapBytes32.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Switches the endianess of a 32-bit integer. + + This function swaps the bytes in a 32-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 32-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT32 +EFIAPI +SwapBytes32 ( + IN UINT32 Operand + ) +{ + UINT32 LowerBytes; + UINT32 HigherBytes; + + LowerBytes = (UINT32) SwapBytes16 ((UINT16) Operand); + HigherBytes = (UINT32) SwapBytes16 ((UINT16) (Operand >> 16)); + + return (LowerBytes << 16 | HigherBytes); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c new file mode 100644 index 0000000000..bd402d39e8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SwapBytes64.c + +Abstract: + + Math worker functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Switches the endianess of a 64-bit integer. + + This function swaps the bytes in a 64-bit unsigned value to switch the value + from little endian to big endian or vice versa. The byte swapped value is + returned. + + @param Operand A 64-bit unsigned value. + + @return The byte swaped Operand. + +**/ +UINT64 +EFIAPI +SwapBytes64 ( + IN UINT64 Operand + ) +{ + return InternalMathSwapBytes64 (Operand); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c new file mode 100644 index 0000000000..82a19ebdee --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SwitchStack.c + +Abstract: + + Switch Stack functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Transfers control to a function starting with a new stack. + + Transfers control to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + For IPF CPUs, if NewStack is not aligned on a 16-byte boundary, then ASSERT(). + + @param EntryPoint A pointer to function to call with the new stack. + @param Context1 A pointer to the context to pass into the EntryPoint + function. + @param Context2 A pointer to the context to pass into the EntryPoint + function. + @param NewStack A pointer to the new stack to use for the EntryPoint + function. + +**/ +VOID +EFIAPI +SwitchStack ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, + IN VOID *Context2, + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL && NewStack != NULL); + +#ifdef MDE_CPU_IPF + ASSERT (((UINTN)NewStack & 0xf) == 0); +#endif + + InternalSwitchStack (EntryPoint, Context1, Context2, NewStack); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c new file mode 100644 index 0000000000..9165b867c5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c @@ -0,0 +1,364 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Synchronization.c + +Abstract: + + Implementation of synchronization functions. + +--*/ + +#include "BaseLibInternal.h" + +#define SPIN_LOCK_RELEASED ((SPIN_LOCK)1) +#define SPIN_LOCK_ACQUIRED ((SPIN_LOCK)2) + +/** + Retrieves the architecture specific spin lock alignment requirements for + optimal spin lock performance. + + This function retrieves the spin lock alignment requirements for optimal + performance on a given CPU architecture. The spin lock alignment must be a + power of two and is returned by this function. If there are no alignment + requirements, then 1 must be returned. The spin lock synchronization + functions must function correctly if the spin lock size and alignment values + returned by this function are not used at all. These values are hints to the + consumers of the spin lock synchronization functions to obtain optimal spin + lock performance. + + @return The architecture specific spin lock alignment. + +**/ +UINTN +EFIAPI +GetSpinLockProperties ( + VOID + ) +{ + // @bug May use a PCD entry to determine this alignment. + return 32; +} + +/** + Initializes a spin lock to the released state and returns the spin lock. + + This function initializes the spin lock specified by SpinLock to the released + state, and returns SpinLock. Optimal performance can be achieved by calling + GetSpinLockProperties() to determine the size and alignment requirements for + SpinLock. + + If SpinLock is NULL, then ASSERT(). + + @param SpinLock A pointer to the spin lock to initialize to the released + state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +InitializeSpinLock ( + OUT SPIN_LOCK *SpinLock + ) +{ + ASSERT (SpinLock != NULL); + *SpinLock = SPIN_LOCK_RELEASED; + return SpinLock; +} + +/** + Waits until a spin lock can be placed in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns SpinLock. Otherwise, this function waits + indefinitely for the spin lock to be released, and then places it in the + acquired state and returns SpinLock. All state transitions of SpinLock must + be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in + PcdSpinLockTimeout microseconds, then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +AcquireSpinLock ( + IN OUT SPIN_LOCK *SpinLock + ) +{ + UINT64 Tick; + UINT64 Start, End; + UINT64 Timeout; + + Tick = 0; + Start = 0; + End = 0; + if (PcdGet32 (PcdSpinLockTimeout) > 0) { + Tick = GetPerformanceCounter (); + Timeout = DivU64x32 ( + MultU64x32 ( + GetPerformanceCounterProperties (&Start, &End), + PcdGet32 (PcdSpinLockTimeout) + ), + 1000000 + ); + if (Start < End) { + Tick += Timeout; + } else { + Tick -= Timeout; + } + } + + while (!AcquireSpinLockOrFail (SpinLock)) { + CpuPause (); + ASSERT ((Start < End) ^ (Tick <= GetPerformanceCounter ())); + } + return SpinLock; +} + +/** + Attempts to place a spin lock in the acquired state. + + This function checks the state of the spin lock specified by SpinLock. If + SpinLock is in the released state, then this function places SpinLock in the + acquired state and returns TRUE. Otherwise, FALSE is returned. All state + transitions of SpinLock must be performed using MP safe mechanisms. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to place in the acquired state. + + @retval TRUE SpinLock was placed in the acquired state. + @retval FALSE SpinLock could not be acquired. + +**/ +BOOLEAN +EFIAPI +AcquireSpinLockOrFail ( + IN OUT SPIN_LOCK *SpinLock + ) +{ + volatile SPIN_LOCK LockValue; + + ASSERT (SpinLock != NULL); + + LockValue = *SpinLock; + ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED); + + return (BOOLEAN)( + InterlockedCompareExchangePointer ( + (VOID**)SpinLock, + (VOID*)SPIN_LOCK_RELEASED, + (VOID*)SPIN_LOCK_ACQUIRED + ) == (VOID*)SPIN_LOCK_RELEASED + ); +} + +/** + Releases a spin lock. + + This function places the spin lock specified by SpinLock in the release state + and returns SpinLock. + + If SpinLock is NULL, then ASSERT(). + If SpinLock was not initialized with InitializeSpinLock(), then ASSERT(). + + @param SpinLock A pointer to the spin lock to release. + + @return SpinLock + +**/ +SPIN_LOCK * +EFIAPI +ReleaseSpinLock ( + IN OUT SPIN_LOCK *SpinLock + ) +{ + volatile SPIN_LOCK LockValue; + + ASSERT (SpinLock != NULL); + + LockValue = *SpinLock; + ASSERT (LockValue == SPIN_LOCK_ACQUIRED || LockValue == SPIN_LOCK_RELEASED); + + *SpinLock = SPIN_LOCK_RELEASED; + return SpinLock; +} + +/** + Performs an atomic increment of an 32-bit unsigned integer. + + Performs an atomic increment of the 32-bit unsigned integer specified by + Value and returns the incremented value. The increment operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to increment. + + @return The incremented value. + +**/ +UINT32 +EFIAPI +InterlockedIncrement ( + IN UINT32 *Value + ) +{ + ASSERT (Value != NULL); + return InternalSyncIncrement (Value); +} + +/** + Performs an atomic decrement of an 32-bit unsigned integer. + + Performs an atomic decrement of the 32-bit unsigned integer specified by + Value and returns the decremented value. The decrement operation must be + performed using MP safe mechanisms. The state of the return value is not + guaranteed to be MP safe. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value to decrement. + + @return The decremented value. + +**/ +UINT32 +EFIAPI +InterlockedDecrement ( + IN UINT32 *Value + ) +{ + ASSERT (Value != NULL); + return InternalSyncDecrement (Value); +} + +/** + Performs an atomic compare exchange operation on a 32-bit unsigned integer. + + Performs an atomic compare exchange operation on the 32-bit unsigned integer + specified by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, + then Value is returned. The compare exchange operation must be performed using + MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 32-bit value for the compare exchange + operation. + @param CompareValue 32-bit value used in compare operation. + @param ExchangeValue 32-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT32 +EFIAPI +InterlockedCompareExchange32 ( + IN OUT UINT32 *Value, + IN UINT32 CompareValue, + IN UINT32 ExchangeValue + ) +{ + ASSERT (Value != NULL); + return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue); +} + +/** + Performs an atomic compare exchange operation on a 64-bit unsigned integer. + + Performs an atomic compare exchange operation on the 64-bit unsigned integer specified + by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and + CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. + The compare exchange operation must be performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the 64-bit value for the compare exchange + operation. + @param CompareValue 64-bit value used in compare operation. + @param ExchangeValue 64-bit value used in exchange operation. + + @return The original *Value before exchange. + +**/ +UINT64 +EFIAPI +InterlockedCompareExchange64 ( + IN OUT UINT64 *Value, + IN UINT64 CompareValue, + IN UINT64 ExchangeValue + ) +{ + ASSERT (Value != NULL); + return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue); +} + +/** + Performs an atomic compare exchange operation on a pointer value. + + Performs an atomic compare exchange operation on the pointer value specified + by Value. If Value is equal to CompareValue, then Value is set to + ExchangeValue and CompareValue is returned. If Value is not equal to + CompareValue, then Value is returned. The compare exchange operation must be + performed using MP safe mechanisms. + + If Value is NULL, then ASSERT(). + + @param Value A pointer to the pointer value for the compare exchange + operation. + @param CompareValue Pointer value used in compare operation. + @param ExchangeValue Pointer value used in exchange operation. + +**/ +VOID * +EFIAPI +InterlockedCompareExchangePointer ( + IN OUT VOID **Value, + IN VOID *CompareValue, + IN VOID *ExchangeValue + ) +{ + UINT8 SizeOfValue; + + SizeOfValue = sizeof (*Value); + + switch (SizeOfValue) { + case sizeof (UINT32): + return (VOID*)(UINTN)InterlockedCompareExchange32 ( + (UINT32*)Value, + (UINT32)(UINTN)CompareValue, + (UINT32)(UINTN)ExchangeValue + ); + case sizeof (UINT64): + return (VOID*)(UINTN)InterlockedCompareExchange64 ( + (UINT64*)Value, + (UINT64)(UINTN)CompareValue, + (UINT64)(UINTN)ExchangeValue + ); + default: + ASSERT (FALSE); + return NULL; + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c new file mode 100644 index 0000000000..37c9e71f76 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c @@ -0,0 +1,228 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Unaligned.c + +Abstract: + + Unaligned access functions of BaseLib. + +--*/ + +#include "BaseLibInternal.h" + +/** + Reads a 16-bit value from memory that may be unaligned. + + This function returns the 16-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + + @return *Uint16 + +**/ +UINT16 +EFIAPI +ReadUnaligned16 ( + IN CONST UINT16 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer; +} + +/** + Writes a 16-bit value to memory that may be unaligned. + + This function writes the 16-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 16-bit value that may be unaligned. + @param Value 16-bit value to write to Buffer. + + @return Value + +**/ +UINT16 +EFIAPI +WriteUnaligned16 ( + OUT UINT16 *Buffer, + IN UINT16 Value + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer = Value; +} + +/** + Reads a 24-bit value from memory that may be unaligned. + + This function returns the 24-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + + @return The value read. + +**/ +UINT32 +EFIAPI +ReadUnaligned24 ( + IN CONST UINT32 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer & 0xffffff; +} + +/** + Writes a 24-bit value to memory that may be unaligned. + + This function writes the 24-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 24-bit value that may be unaligned. + @param Value 24-bit value to write to Buffer. + + @return The value written. + +**/ +UINT32 +EFIAPI +WriteUnaligned24 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ) +{ + ASSERT (Buffer != NULL); + + *Buffer = BitFieldWrite32 (*Buffer, 0, 23, Value); + return Value; +} + +/** + Reads a 32-bit value from memory that may be unaligned. + + This function returns the 32-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + + @return *Uint32 + +**/ +UINT32 +EFIAPI +ReadUnaligned32 ( + IN CONST UINT32 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer; +} + +/** + Writes a 32-bit value to memory that may be unaligned. + + This function writes the 32-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 32-bit value that may be unaligned. + @param Value 32-bit value to write to Buffer. + + @return Value + +**/ +UINT32 +EFIAPI +WriteUnaligned32 ( + OUT UINT32 *Buffer, + IN UINT32 Value + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer = Value; +} + +/** + Reads a 64-bit value from memory that may be unaligned. + + This function returns the 64-bit value pointed to by Buffer. The function + guarantees that the read operation does not produce an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + + @return *Uint64 + +**/ +UINT64 +EFIAPI +ReadUnaligned64 ( + IN CONST UINT64 *Buffer + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer; +} + +/** + Writes a 64-bit value to memory that may be unaligned. + + This function writes the 64-bit value specified by Value to Buffer. Value is + returned. The function guarantees that the write operation does not produce + an alignment fault. + + If the Buffer is NULL, then ASSERT(). + + @param Buffer Pointer to a 64-bit value that may be unaligned. + @param Value 64-bit value to write to Buffer. + + @return Value + +**/ +UINT64 +EFIAPI +WriteUnaligned64 ( + OUT UINT64 *Buffer, + IN UINT64 Value + ) +{ + ASSERT (Buffer != NULL); + + return *Buffer = Value; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm new file mode 100644 index 0000000000..75d081ed23 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuBreakpoint.Asm +; +; Abstract: +; +; CpuBreakpoint function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuBreakpoint ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuBreakpoint PROC + int 3 + ret +CpuBreakpoint ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm new file mode 100644 index 0000000000..2da3b42a46 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuFlushTlb.Asm +; +; Abstract: +; +; CpuFlushTlb function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuFlushTlb ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuFlushTlb PROC + mov rax, cr3 + mov cr3, rax + ret +CpuFlushTlb ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm new file mode 100644 index 0000000000..5680014e16 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm @@ -0,0 +1,60 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuId.Asm +; +; Abstract: +; +; AsmCpuid function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmCpuid ( +; IN UINT32 RegisterInEax, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ) +;------------------------------------------------------------------------------ +AsmCpuid PROC USES rbx + mov eax, ecx + push rax ; save Index on stack + push rdx + cpuid + test r9, r9 + jz @F + mov [r9], ecx +@@: + pop rcx + jrcxz @F + mov [rcx], eax +@@: + mov rcx, r8 + jrcxz @F + mov [rcx], ebx +@@: + mov rcx, [rsp + 38h] + jrcxz @F + mov [rcx], edx +@@: + pop rax ; restore Index to rax as return value + ret +AsmCpuid ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm new file mode 100644 index 0000000000..2f531f72e9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm @@ -0,0 +1,62 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuIdEx.Asm +; +; Abstract: +; +; AsmCpuidEx function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; AsmCpuidEx ( +; IN UINT32 RegisterInEax, +; IN UINT32 RegisterInEcx, +; OUT UINT32 *RegisterOutEax OPTIONAL, +; OUT UINT32 *RegisterOutEbx OPTIONAL, +; OUT UINT32 *RegisterOutEcx OPTIONAL, +; OUT UINT32 *RegisterOutEdx OPTIONAL +; ) +;------------------------------------------------------------------------------ +AsmCpuidEx PROC USES rbx + mov eax, ecx + mov ecx, edx + push rax ; save Index on stack + cpuid + mov r10, [rsp + 38h] + test r10, r10 + jz @F + mov [r10], ecx +@@: + mov rcx, r8 + jrcxz @F + mov [rcx], eax +@@: + mov rcx, r9 + jrcxz @F + mov [rcx], ebx +@@: + mov rcx, [rsp + 40h] + jrcxz @F + mov [rcx], edx +@@: + pop rax ; restore Index to rax as return value + ret +AsmCpuidEx ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm new file mode 100644 index 0000000000..4e9697d220 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuPause.Asm +; +; Abstract: +; +; CpuPause function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuPause ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuPause PROC + pause + ret +CpuPause ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm new file mode 100644 index 0000000000..f0ba4172cf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CpuSleep.Asm +; +; Abstract: +; +; CpuSleep function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; CpuSleep ( +; VOID +; ); +;------------------------------------------------------------------------------ +CpuSleep PROC + hlt + ret +CpuSleep ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm new file mode 100644 index 0000000000..b332a2e524 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DisableInterrupts.Asm +; +; Abstract: +; +; DisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; DisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +DisableInterrupts PROC + cli + ret +DisableInterrupts ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm new file mode 100644 index 0000000000..0359baf5ca --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm @@ -0,0 +1,63 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; DisablePaging64.Asm +; +; Abstract: +; +; AsmDisablePaging64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86DisablePaging64 ( +; IN UINT16 Cs, +; IN UINT32 EntryPoint, +; IN UINT32 Context1, OPTIONAL +; IN UINT32 Context2, OPTIONAL +; IN UINT32 NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86DisablePaging64 PROC + cli + shl rcx, 32 ; rcx[32..47] <- Cs + lea eax, @F + mov esi, r8d + or rcx, rax ; rcx[0..47] <- Cs:@F + mov edi, r9d + mov eax, [rsp + 28h] ; eax <- New Stack + push rcx + retf ; switch to compatibility mode +@@: + mov esp, eax ; set up new stack + mov rax, cr0 + btr eax, 31 + mov cr0, rax ; disable paging + mov ecx, 0c0000080h + rdmsr + and ah, NOT 1 ; clear LME + wrmsr + mov rax, cr4 + and al, NOT (1 SHL 5) ; clear PAE + mov cr4, rax + push rdi ; push Context2 + push rsi ; push Context1 + call rdx ; transfer control to EntryPoint + hlt ; no one should get here +InternalX86DisablePaging64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm new file mode 100644 index 0000000000..bc0d74828b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; EnableDisableInterrupts.Asm +; +; Abstract: +; +; EnableDisableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableDisableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +EnableDisableInterrupts PROC + sti + cli + ret +EnableDisableInterrupts ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm new file mode 100644 index 0000000000..d94bb42408 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; EnableInterrupts.Asm +; +; Abstract: +; +; EnableInterrupts function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; EnableInterrupts ( +; VOID +; ); +;------------------------------------------------------------------------------ +EnableInterrupts PROC + sti + ret +EnableInterrupts ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm new file mode 100644 index 0000000000..b4f50b29bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm @@ -0,0 +1,62 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; EnablePaging64.Asm +; +; Abstract: +; +; AsmEnablePaging64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86EnablePaging64 ( +; IN UINT16 Cs, +; IN UINT64 EntryPoint, +; IN UINT64 Context1, OPTIONAL +; IN UINT64 Context2, OPTIONAL +; IN UINT64 NewStack +; ); +;------------------------------------------------------------------------------ +InternalX86EnablePaging64 PROC + cli + pop rax ; skip the return address + call @Base +@Base: + add dword ptr [rsp], @F - @Base ; offset for far retf, seg is the 1st arg + mov rax, cr4 ; mov eax, cr4 + or al, (1 SHL 5) + mov cr4, rax ; enable PAE + mov ecx, 0c0000080h + rdmsr + or ah, 1 ; set LME + wrmsr + mov rax, cr0 ; mov eax, cr0 + bts eax, 31 + mov cr0, rax ; enable paging + retf +@@: ; long mode starts here + mov rbx, [esp] + mov rcx, [esp + 8] + mov rdx, [esp + 10h] + mov rsp, [esp + 18h] + add rsp, -20h + call rbx + hlt ; halt processor if EntryPoint() returned +InternalX86EnablePaging64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm new file mode 100644 index 0000000000..f2c17c4d23 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; FlushCacheLine.Asm +; +; Abstract: +; +; AsmFlushCacheLine function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; AsmFlushCacheLine ( +; IN VOID *LinearAddress +; ); +;------------------------------------------------------------------------------ +AsmFlushCacheLine PROC + clflush [rcx] + mov rax, rcx + ret +AsmFlushCacheLine ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm new file mode 100644 index 0000000000..962827e1fb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; FxRestore.Asm +; +; Abstract: +; +; AsmFxRestore function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxRestore ( +; IN CONST IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxRestore PROC + fxrstor [rcx] + ret +InternalX86FxRestore ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm new file mode 100644 index 0000000000..072d275fc0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; FxSave.Asm +; +; Abstract: +; +; AsmFxSave function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86FxSave ( +; OUT IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +InternalX86FxSave PROC + fxsave [rcx] + ret +InternalX86FxSave ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm new file mode 100644 index 0000000000..947822a065 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedCompareExchange32.Asm +; +; Abstract: +; +; InterlockedCompareExchange32 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InterlockedCompareExchange32 ( +; IN UINT32 *Value, +; IN UINT32 CompareValue, +; IN UINT32 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange32 PROC + mov eax, edx + lock cmpxchg [rcx], r8d + ret +InternalSyncCompareExchange32 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm new file mode 100644 index 0000000000..769b31339d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedCompareExchange64.Asm +; +; Abstract: +; +; InterlockedCompareExchange64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; InterlockedCompareExchange64 ( +; IN UINT64 *Value, +; IN UINT64 CompareValue, +; IN UINT64 ExchangeValue +; ); +;------------------------------------------------------------------------------ +InternalSyncCompareExchange64 PROC + mov rax, rdx + lock cmpxchg [rcx], r8 + ret +InternalSyncCompareExchange64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm new file mode 100644 index 0000000000..be0807bf26 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedDecrement.Asm +; +; Abstract: +; +; InterlockedDecrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InterlockedDecrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncDecrement PROC + lock dec dword ptr [rcx] + mov eax, [rcx] + ret +InternalSyncDecrement ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm new file mode 100644 index 0000000000..3b24752bfa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; InterlockedIncrement.Asm +; +; Abstract: +; +; InterlockedIncrement function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT32 +; EFIAPI +; InterlockedIncrement ( +; IN UINT32 *Value +; ); +;------------------------------------------------------------------------------ +InternalSyncIncrement PROC + lock inc dword ptr [rcx] + mov eax, [rcx] + ret +InternalSyncIncrement ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm new file mode 100644 index 0000000000..b69fc7b8de --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Invd.Asm +; +; Abstract: +; +; AsmInvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmInvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmInvd PROC + invd + ret +AsmInvd ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm new file mode 100644 index 0000000000..3e0d540704 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm @@ -0,0 +1,44 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; LongJump.Asm +; +; Abstract: +; +; Implementation of _LongJump() on x64. +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalLongJump ( +; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +InternalLongJump PROC + mov rbx, [rcx] + mov rsp, [rcx + 8] + mov rbp, [rcx + 10h] + mov rdi, [rcx + 18h] + mov rsi, [rcx + 20h] + mov r12, [rcx + 28h] + mov r13, [rcx + 30h] + mov r14, [rcx + 38h] + mov r15, [rcx + 40h] + mov rax, rdx ; set return value + jmp qword ptr [rcx + 48h] +InternalLongJump ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm new file mode 100644 index 0000000000..d83077583f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm @@ -0,0 +1,41 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Monitor.Asm +; +; Abstract: +; +; AsmMonitor function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmMonitor ( +; IN UINTN Eax, +; IN UINTN Ecx, +; IN UINTN Edx +; ); +;------------------------------------------------------------------------------ +AsmMonitor PROC + mov eax, ecx + mov ecx, edx + mov edx, r8d + DB 0fh, 1, 0c8h ; monitor + ret +AsmMonitor ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm new file mode 100644 index 0000000000..4dcdb7ba8b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Mwait.Asm +; +; Abstract: +; +; AsmMwait function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmMwait ( +; IN UINTN Eax, +; IN UINTN Ecx +; ); +;------------------------------------------------------------------------------ +AsmMwait PROC + mov eax, ecx + mov ecx, edx + DB 0fh, 1, 0c9h ; mwait + ret +AsmMwait ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c new file mode 100644 index 0000000000..023af1c1e0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c @@ -0,0 +1,116 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Non-existing.c + +Abstract: + + Non-existing BaseLib functions on x64 + +--*/ + +#include "..\BaseLibInternal.h" + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +InternalX86EnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + // + // This function cannot work on X64 platform + // + ASSERT (FALSE); +} + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +InternalX86DisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + // + // This function cannot work on X64 platform + // + ASSERT (FALSE); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm new file mode 100644 index 0000000000..d9a1459b71 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr0.Asm +; +; Abstract: +; +; AsmReadCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr0 PROC + mov rax, cr0 + ret +AsmReadCr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm new file mode 100644 index 0000000000..8a62a36328 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr2.Asm +; +; Abstract: +; +; AsmReadCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr2 PROC + mov rax, cr2 + ret +AsmReadCr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm new file mode 100644 index 0000000000..c87fabf336 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr3.Asm +; +; Abstract: +; +; AsmReadCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr3 PROC + mov rax, cr3 + ret +AsmReadCr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm new file mode 100644 index 0000000000..b53d063eea --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCr4.Asm +; +; Abstract: +; +; AsmReadCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadCr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCr4 PROC + mov rax, cr4 + ret +AsmReadCr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm new file mode 100644 index 0000000000..c537764ec7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadCs.Asm +; +; Abstract: +; +; AsmReadCs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadCs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadCs PROC + mov eax, cs + ret +AsmReadCs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm new file mode 100644 index 0000000000..f501659b7f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr0.Asm +; +; Abstract: +; +; AsmReadDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr0 PROC + mov rax, dr0 + ret +AsmReadDr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm new file mode 100644 index 0000000000..fb3f1f902f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr1.Asm +; +; Abstract: +; +; AsmReadDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr1 PROC + mov rax, dr1 + ret +AsmReadDr1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm new file mode 100644 index 0000000000..1a95578e54 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr2.Asm +; +; Abstract: +; +; AsmReadDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr2 PROC + mov rax, dr2 + ret +AsmReadDr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm new file mode 100644 index 0000000000..1828fae3fa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr3.Asm +; +; Abstract: +; +; AsmReadDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr3 PROC + mov rax, dr3 + ret +AsmReadDr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm new file mode 100644 index 0000000000..0708718cdc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm @@ -0,0 +1,40 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr4.Asm +; +; Abstract: +; +; AsmReadDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr4 PROC + ; + ; There's no obvious reason to access this register, since it's aliased to + ; DR7 when DE=0 or an exception generated when DE=1 + ; + DB 0fh, 21h, 0e0h + ret +AsmReadDr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm new file mode 100644 index 0000000000..5c740809ad --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm @@ -0,0 +1,40 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr5.Asm +; +; Abstract: +; +; AsmReadDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr5 PROC + ; + ; There's no obvious reason to access this register, since it's aliased to + ; DR7 when DE=0 or an exception generated when DE=1 + ; + DB 0fh, 21h, 0e8h + ret +AsmReadDr5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm new file mode 100644 index 0000000000..cdf034da34 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr6.Asm +; +; Abstract: +; +; AsmReadDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr6 PROC + mov rax, dr6 + ret +AsmReadDr6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm new file mode 100644 index 0000000000..ee570dd595 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDr7.Asm +; +; Abstract: +; +; AsmReadDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadDr7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDr7 PROC + mov rax, dr7 + ret +AsmReadDr7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm new file mode 100644 index 0000000000..525b219be1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadDs.Asm +; +; Abstract: +; +; AsmReadDs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadDs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadDs PROC + mov eax, ds + ret +AsmReadDs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm new file mode 100644 index 0000000000..83dc8decae --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadEflags.Asm +; +; Abstract: +; +; AsmReadEflags function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmReadEflags ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEflags PROC + pushfq + pop rax + ret +AsmReadEflags ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm new file mode 100644 index 0000000000..8d94c8b582 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadEs.Asm +; +; Abstract: +; +; AsmReadEs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadEs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadEs PROC + mov eax, es + ret +AsmReadEs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm new file mode 100644 index 0000000000..ea49b687c4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadFs.Asm +; +; Abstract: +; +; AsmReadFs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadFs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadFs PROC + mov eax, fs + ret +AsmReadFs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm new file mode 100644 index 0000000000..4e4cb8bd4a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadGdtr.Asm +; +; Abstract: +; +; AsmReadGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadGdtr ( +; OUT IA32_DESCRIPTOR *Gdtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadGdtr PROC + sgdt fword ptr [rcx] + ret +InternalX86ReadGdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm new file mode 100644 index 0000000000..18beba0c39 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadGs.Asm +; +; Abstract: +; +; AsmReadGs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadGs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadGs PROC + mov eax, gs + ret +AsmReadGs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm new file mode 100644 index 0000000000..b4d21a0b35 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadIdtr.Asm +; +; Abstract: +; +; AsmReadIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86ReadIdtr ( +; OUT IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86ReadIdtr PROC + sidt fword ptr [rcx] + ret +InternalX86ReadIdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm new file mode 100644 index 0000000000..cc43bfdefe --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadLdtr.Asm +; +; Abstract: +; +; AsmReadLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadLdtr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadLdtr PROC + sldt eax + ret +AsmReadLdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm new file mode 100644 index 0000000000..c21458e1b9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm0.Asm +; +; Abstract: +; +; AsmReadMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm0 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm0 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0c0h + ret +AsmReadMm0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm new file mode 100644 index 0000000000..aff4795ca2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm1.Asm +; +; Abstract: +; +; AsmReadMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm1 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm1 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0c8h + ret +AsmReadMm1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm new file mode 100644 index 0000000000..872e72aa8f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm2.Asm +; +; Abstract: +; +; AsmReadMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm2 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm2 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0d0h + ret +AsmReadMm2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm new file mode 100644 index 0000000000..0178d5157f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm3.Asm +; +; Abstract: +; +; AsmReadMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm3 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm3 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0d8h + ret +AsmReadMm3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm new file mode 100644 index 0000000000..07d22911df --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm4.Asm +; +; Abstract: +; +; AsmReadMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm4 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm4 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0e0h + ret +AsmReadMm4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm new file mode 100644 index 0000000000..1feb517a99 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm5.Asm +; +; Abstract: +; +; AsmReadMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm5 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm5 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0e8h + ret +AsmReadMm5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm new file mode 100644 index 0000000000..09f420d3ed --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm6.Asm +; +; Abstract: +; +; AsmReadMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm6 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm6 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0f0h + ret +AsmReadMm6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm new file mode 100644 index 0000000000..b51de17d47 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMm7.Asm +; +; Abstract: +; +; AsmReadMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMm7 ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadMm7 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 7eh, 0f8h + ret +AsmReadMm7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm new file mode 100644 index 0000000000..5b376bd750 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadMsr64.Asm +; +; Abstract: +; +; AsmReadMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadMsr64 ( +; IN UINT32 Index +; ); +;------------------------------------------------------------------------------ +AsmReadMsr64 PROC + rdmsr ; edx & eax are zero extended + shl rdx, 20h + or rax, rdx + ret +AsmReadMsr64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm new file mode 100644 index 0000000000..9c3f69afbc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadPmc.Asm +; +; Abstract: +; +; AsmReadPmc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadPmc ( +; IN UINT32 PmcIndex +; ); +;------------------------------------------------------------------------------ +AsmReadPmc PROC + rdpmc + shl rdx, 20h + or rax, rdx + ret +AsmReadPmc ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm new file mode 100644 index 0000000000..7f809646c6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadSs.Asm +; +; Abstract: +; +; AsmReadSs function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadSs ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadSs PROC + mov eax, ss + ret +AsmReadSs ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm new file mode 100644 index 0000000000..3e29b4f125 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadTr.Asm +; +; Abstract: +; +; AsmReadTr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT16 +; EFIAPI +; AsmReadTr ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTr PROC + str eax + ret +AsmReadTr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm new file mode 100644 index 0000000000..ffbb5f44b6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm @@ -0,0 +1,38 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadTsc.Asm +; +; Abstract: +; +; AsmReadTsc function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmReadTsc ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmReadTsc PROC + rdtsc + shl rdx, 20h + or rax, rdx + ret +AsmReadTsc ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm new file mode 100644 index 0000000000..cd0293e05a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm @@ -0,0 +1,52 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetJump.Asm +; +; Abstract: +; +; Implementation of SetJump() on x64. +; +;------------------------------------------------------------------------------ + + .code + +EXTERNDEF InternalAssertJumpBuffer:PROC + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; SetJump ( +; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer +; ); +;------------------------------------------------------------------------------ +SetJump PROC + push rcx + add rsp, -20h + call InternalAssertJumpBuffer + add rsp, 20h + pop rcx + pop rdx + mov [rcx], rbx + mov [rcx + 8], rsp + mov [rcx + 10h], rbp + mov [rcx + 18h], rdi + mov [rcx + 20h], rsi + mov [rcx + 28h], r12 + mov [rcx + 30h], r13 + mov [rcx + 38h], r14 + mov [rcx + 40h], r15 + mov [rcx + 48h], rdx + xor rax, rax + jmp rdx +SetJump ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm new file mode 100644 index 0000000000..db93c13a3d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm @@ -0,0 +1,45 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SwitchStack.Asm +; +; Abstract: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; Routine Description: +; +; Routine for switching stacks with 1 parameter +; +; Arguments: +; +; (rcx) EntryPoint - Entry point with new stack. +; (rdx) Context - Parameter for entry point. +; (r8) Context2 - Parameter2 for entry point. +; (r9) NewStack - Pointer to new stack. +; +; Returns: +; +; None +; +;------------------------------------------------------------------------------ +InternalSwitchStack PROC + mov rax, rcx + mov rcx, rdx + mov rdx, r8 + lea rsp, [r9 - 20h] + call rax +InternalSwitchStack ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm new file mode 100644 index 0000000000..0c3bb7df26 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm @@ -0,0 +1,285 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Thunk.asm +; +; Abstract: +; +; Real mode thunk +; +;------------------------------------------------------------------------------ + +EXTERNDEF m16Start:BYTE +EXTERNDEF m16Size:WORD +EXTERNDEF mThunk16Attr:WORD +EXTERNDEF m16Gdt:WORD +EXTERNDEF m16GdtrBase:WORD +EXTERNDEF mTransition:WORD + +THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 EQU 2 +THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL EQU 4 + +IA32_REGS STRUC 4t +_EDI DD ? +_ESI DD ? +_EBP DD ? +_ESP DD ? +_EBX DD ? +_EDX DD ? +_ECX DD ? +_EAX DD ? +_DS DW ? +_ES DW ? +_FS DW ? +_GS DW ? +_EFLAGS DQ ? +_EIP DD ? +_CS DW ? +_SS DW ? +IA32_REGS ENDS + + .const + +m16Size DW InternalAsmThunk16 - m16Start +mThunk16Attr DW _ThunkAttr - m16Start +m16Gdt DW _NullSeg - m16Start +m16GdtrBase DW _16GdtrBase - m16Start +mTransition DW _EntryPoint - m16Start + + .code + +m16Start LABEL BYTE + +SavedGdt LABEL FWORD + DW ? + DQ ? + +;------------------------------------------------------------------------------ +; _BackFromUserCode() takes control in real mode after 'retf' has been executed +; by user code. It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_BackFromUserCode PROC + ; + ; The order of saved registers on the stack matches the order they appears + ; in IA32_REGS structure. This facilitates wrapper function to extract them + ; into that structure. + ; + ; Some instructions for manipulation of segment registers have to be written + ; in opcode since 64-bit MASM prevents accesses to those registers. + ; + DB 16h ; push ss + DB 0eh ; push cs + DB 66h + call @Base ; push eip +@Base: + DB 66h + push 0 ; reserved high order 32 bits of EFlags + pushf ; pushfd actually + cli ; disable interrupts + push gs + push fs + DB 6 ; push es + DB 1eh ; push ds + DB 66h, 60h ; pushad + DB 66h, 0bah ; mov edx, imm32 +_ThunkAttr DD ? + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 + jz @1 + mov eax, 15cd2401h ; mov ax, 2401h & int 15h + cli ; disable interrupts + jnc @2 +@1: + test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL + jz @2 + in al, 92h + or al, 2 + out 92h, al ; deactivate A20M# +@2: + mov eax, ss + lea bp, [esp + sizeof (IA32_REGS)] + ; + ; rsi in the following 2 instructions is indeed bp in 16-bit code + ; + mov word ptr (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._ESP, bp + DB 66h + mov ebx, (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._EIP + shl ax, 4 ; shl eax, 4 + add bp, ax ; add ebp, eax + mov ax, cs + shl ax, 4 + lea ax, [eax + ebx + (@64BitCode - @Base)] + DB 66h, 2eh, 89h, 87h ; mov cs:[bx + (@64Eip - @Base)], eax + DW @64Eip - @Base + DB 66h, 0b8h ; mov eax, imm32 +SavedCr4 DD ? + mov cr4, rax + ; + ; rdi in the instruction below is indeed bx in 16-bit code + ; + DB 66h, 2eh ; 2eh is "cs:" segment override + lgdt fword ptr [rdi + (SavedGdt - @Base)] + DB 66h + mov ecx, 0c0000080h + rdmsr + or ah, 1 + wrmsr + DB 66h, 0b8h ; mov eax, imm32 +SavedCr0 DD ? + mov cr0, rax + DB 66h, 0eah ; jmp far cs:@64Bit +@64Eip DD ? +SavedCs DW ? +@64BitCode: + mov rsp, r8 ; restore stack + ret +_BackFromUserCode ENDP + +_EntryPoint DD _ToUserCode - m16Start + DW CODE16 +_16Gdtr LABEL FWORD + DW GDT_SIZE - 1 +_16GdtrBase DQ _NullSeg +_16Idtr FWORD (1 SHL 10) - 1 + +;------------------------------------------------------------------------------ +; _ToUserCode() takes control in real mode before passing control to user code. +; It will be shadowed to somewhere in memory below 1MB. +;------------------------------------------------------------------------------ +_ToUserCode PROC + mov ss, edx ; set new segment selectors + mov ds, edx + mov es, edx + mov fs, edx + mov gs, edx + DB 66h + mov ecx, 0c0000080h + mov cr0, rax ; real mode starts at next instruction + rdmsr + and ah, NOT 1 + wrmsr + mov cr4, rbp + mov ss, esi ; set up 16-bit stack segment + mov sp, bx ; set up 16-bit stack pointer + DB 66h ; make the following call 32-bit + call @Base ; push eip +@Base: + pop bp ; ebp <- address of @Base + push [esp + sizeof (IA32_REGS) + 2] + lea eax, [rsi + (@RealMode - @Base)] ; rsi is "bp" in 16-bit code + push rax + retf ; execution begins at next instruction +@RealMode: + DB 66h, 2eh ; CS and operand size override + lidt fword ptr [rsi + (_16Idtr - @Base)] + DB 66h, 61h ; popad + DB 1fh ; pop ds + DB 07h ; pop es + pop fs + pop gs + popf ; popfd + lea sp, [esp + 4] ; skip high order 32 bits of EFlags + DB 66h ; make the following retf 32-bit + retf ; transfer control to user code +_ToUserCode ENDP + +CODE16 = _16Code - $ +DATA16 = _16Data - $ +DATA32 = _32Data - $ + +_NullSeg DQ 0 +_16Code LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +_16Data LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh ; 16-bit segment, 4GB limit + DB 0 +_32Data LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 0cfh ; 16-bit segment, 4GB limit + DB 0 + +GDT_SIZE = $ - _NullSeg + +;------------------------------------------------------------------------------ +; IA32_REGISTER_SET * +; EFIAPI +; InternalAsmThunk16 ( +; IN IA32_REGISTER_SET *RegisterSet, +; IN OUT VOID *Transition +; ); +;------------------------------------------------------------------------------ +InternalAsmThunk16 PROC USES rbp rbx rsi rdi + mov r10d, ds ; r9 ~ r11 are not accessible in 16-bit + mov r11d, es ; so use them for saving seg registers + mov r9d, ss + push fs + push gs + mov rsi, rcx + movzx r8d, (IA32_REGS ptr [rsi])._SS + mov edi, (IA32_REGS ptr [rsi])._ESP + lea rdi, [edi - (sizeof (IA32_REGS) + 4)] + imul eax, r8d, 16 ; eax <- r8d(stack segment) * 16 + mov ebx, edi ; ebx <- stack for 16-bit code + push sizeof (IA32_REGS) / 4 + add edi, eax ; edi <- linear address of 16-bit stack + pop rcx + rep movsd ; copy RegSet + lea ecx, [rdx + (SavedCr4 - m16Start)] + mov eax, edx ; eax <- transition code address + and edx, 0fh + shl eax, 12 ; segment address in high order 16 bits + lea ax, [rdx + (_BackFromUserCode - m16Start)] ; offset address + stosd ; [edi] <- return address of user code + sgdt fword ptr [rcx + (SavedGdt - SavedCr4)] + sidt fword ptr [rsp + 38h] ; save IDT stack in argument space + mov rax, cr0 + mov [rcx + (SavedCr0 - SavedCr4)], eax + and eax, 7ffffffeh ; clear PE, PG bits + mov rbp, cr4 + mov [rcx], ebp ; save CR4 in SavedCr4 + and ebp, 300h ; clear all but PCE and OSFXSR bits + mov esi, r8d ; esi <- 16-bit stack segment + DB 6ah, DATA32 ; push DATA32 + pop rdx ; rdx <- 32-bit data segment selector + lgdt fword ptr [rcx + (_16Gdtr - SavedCr4)] + mov ss, edx + pushfq + lea edx, [rdx + DATA16 - DATA32] + lea r8, @RetFromRealMode + push r8 + mov r8d, cs + mov [rcx + (SavedCs - SavedCr4)], r8w + mov r8, rsp + jmp fword ptr [rcx + (_EntryPoint - SavedCr4)] +@RetFromRealMode: + popfq + lidt fword ptr [rsp + 38h] ; restore protected mode IDTR + lea eax, [rbp - sizeof (IA32_REGS)] + pop gs + pop fs + mov ss, r9d + mov es, r11d + mov ds, r10d + ret +InternalAsmThunk16 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm new file mode 100644 index 0000000000..722e1f86d0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; Wbinvd.Asm +; +; Abstract: +; +; AsmWbinvd function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWbinvd ( +; VOID +; ); +;------------------------------------------------------------------------------ +AsmWbinvd PROC + wbinvd + ret +AsmWbinvd ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm new file mode 100644 index 0000000000..aab3525d03 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr0.Asm +; +; Abstract: +; +; AsmWriteCr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr0 ( +; UINTN Cr0 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr0 PROC + mov cr0, rcx + mov rax, rcx + ret +AsmWriteCr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm new file mode 100644 index 0000000000..30194c4136 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr2.Asm +; +; Abstract: +; +; AsmWriteCr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr2 ( +; UINTN Cr2 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr2 PROC + mov cr2, rcx + mov rax, rcx + ret +AsmWriteCr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm new file mode 100644 index 0000000000..a32b5df0e9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr3.Asm +; +; Abstract: +; +; AsmWriteCr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr3 ( +; UINTN Cr3 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr3 PROC + mov cr3, rcx + mov rax, rcx + ret +AsmWriteCr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm new file mode 100644 index 0000000000..c20d1ef5b9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteCr4.Asm +; +; Abstract: +; +; AsmWriteCr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteCr4 ( +; UINTN Cr4 +; ); +;------------------------------------------------------------------------------ +AsmWriteCr4 PROC + mov cr4, rcx + mov rax, rcx + ret +AsmWriteCr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm new file mode 100644 index 0000000000..ad4f36a1bd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr0.Asm +; +; Abstract: +; +; AsmWriteDr0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr0 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr0 PROC + mov dr0, rcx + mov rax, rcx + ret +AsmWriteDr0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm new file mode 100644 index 0000000000..a298285521 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr1.Asm +; +; Abstract: +; +; AsmWriteDr1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr1 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr1 PROC + mov dr1, rcx + mov rax, rcx + ret +AsmWriteDr1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm new file mode 100644 index 0000000000..2ee275c091 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr2.Asm +; +; Abstract: +; +; AsmWriteDr2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr2 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr2 PROC + mov dr2, rcx + mov rax, rcx + ret +AsmWriteDr2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm new file mode 100644 index 0000000000..42512c1c9b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr3.Asm +; +; Abstract: +; +; AsmWriteDr3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr3 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr3 PROC + mov dr3, rcx + mov rax, rcx + ret +AsmWriteDr3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm new file mode 100644 index 0000000000..487a8a602b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm @@ -0,0 +1,41 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr4.Asm +; +; Abstract: +; +; AsmWriteDr4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr4 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr4 PROC + ; + ; There's no obvious reason to access this register, since it's aliased to + ; DR6 when DE=0 or an exception generated when DE=1 + ; + DB 0fh, 23h, 0e1h + mov rax, rcx + ret +AsmWriteDr4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm new file mode 100644 index 0000000000..4417c5825a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm @@ -0,0 +1,41 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr5.Asm +; +; Abstract: +; +; AsmWriteDr5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr6 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr5 PROC + ; + ; There's no obvious reason to access this register, since it's aliased to + ; DR7 when DE=0 or an exception generated when DE=1 + ; + DB 0fh, 23h, 0e9h + mov rax, rcx + ret +AsmWriteDr5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm new file mode 100644 index 0000000000..28fd589ad7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr6.Asm +; +; Abstract: +; +; AsmWriteDr6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr6 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr6 PROC + mov dr6, rcx + mov rax, rcx + ret +AsmWriteDr6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm new file mode 100644 index 0000000000..07a25ee320 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm @@ -0,0 +1,37 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteDr7.Asm +; +; Abstract: +; +; AsmWriteDr7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINTN +; EFIAPI +; AsmWriteDr7 ( +; IN UINTN Value +; ); +;------------------------------------------------------------------------------ +AsmWriteDr7 PROC + mov dr7, rcx + mov rax, rcx + ret +AsmWriteDr7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm new file mode 100644 index 0000000000..e401a67660 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteGdtr.Asm +; +; Abstract: +; +; AsmWriteGdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteGdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteGdtr PROC + lgdt fword ptr [rcx] + ret +InternalX86WriteGdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm new file mode 100644 index 0000000000..aa8c70d07c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteIdtr.Asm +; +; Abstract: +; +; AsmWriteIdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; InternalX86WriteIdtr ( +; IN CONST IA32_DESCRIPTOR *Idtr +; ); +;------------------------------------------------------------------------------ +InternalX86WriteIdtr PROC + lidt fword ptr [rcx] + ret +InternalX86WriteIdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm new file mode 100644 index 0000000000..92ca864f1a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm @@ -0,0 +1,36 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteLdtr.Asm +; +; Abstract: +; +; AsmWriteLdtr function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteLdtr ( +; IN UINT16 Ldtr +; ); +;------------------------------------------------------------------------------ +AsmWriteLdtr PROC + lldt cx + ret +AsmWriteLdtr ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm new file mode 100644 index 0000000000..e9064403da --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm0.Asm +; +; Abstract: +; +; AsmWriteMm0 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm0 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm0 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0c1h + ret +AsmWriteMm0 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm new file mode 100644 index 0000000000..49b7b18c40 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm1.Asm +; +; Abstract: +; +; AsmWriteMm1 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm1 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm1 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0c9h + ret +AsmWriteMm1 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm new file mode 100644 index 0000000000..358194ea82 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm2.Asm +; +; Abstract: +; +; AsmWriteMm2 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm2 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm2 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0d1h + ret +AsmWriteMm2 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm new file mode 100644 index 0000000000..48e1c3217d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm3.Asm +; +; Abstract: +; +; AsmWriteMm3 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm3 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm3 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0d9h + ret +AsmWriteMm3 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm new file mode 100644 index 0000000000..f90f9d3c10 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm4.Asm +; +; Abstract: +; +; AsmWriteMm4 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm4 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm4 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0e1h + ret +AsmWriteMm4 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm new file mode 100644 index 0000000000..2d06be2b19 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm5.Asm +; +; Abstract: +; +; AsmWriteMm5 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm5 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm5 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0e9h + ret +AsmWriteMm5 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm new file mode 100644 index 0000000000..42e17f9050 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm6.Asm +; +; Abstract: +; +; AsmWriteMm6 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm6 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm6 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0f1h + ret +AsmWriteMm6 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm new file mode 100644 index 0000000000..17e8f98196 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMm7.Asm +; +; Abstract: +; +; AsmWriteMm7 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EFIAPI +; AsmWriteMm7 ( +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMm7 PROC + ; + ; 64-bit MASM doesn't support MMX instructions, so use opcode here + ; + DB 48h, 0fh, 6eh, 0f9h + ret +AsmWriteMm7 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm new file mode 100644 index 0000000000..95c48f46dc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm @@ -0,0 +1,39 @@ +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteMsr64.Asm +; +; Abstract: +; +; AsmWriteMsr64 function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; UINT64 +; EFIAPI +; AsmWriteMsr64 ( +; IN UINT32 Index, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ +AsmWriteMsr64 PROC + mov rax, rdx ; meanwhile, rax <- return value + shr rdx, 20h ; edx:eax contains the value to write + wrmsr + ret +AsmWriteMsr64 ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c new file mode 100644 index 0000000000..8af5534546 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c @@ -0,0 +1,71 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86DisablePaging32.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Disables the 32-bit paging mode on the CPU. + + Disables the 32-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 32-paged protected + mode. This function is only available on IA-32. After the 32-bit paging mode + is disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be NULL. The function EntryPoint must never return. + + If the current execution mode is not 32-bit paged mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit paged mode. + 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. + 4) CR3 must point to valid page tables that guarantee that the pages for + this function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is disabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is disabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is + disabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL); + ASSERT (NewStack != NULL); + InternalX86DisablePaging32 (EntryPoint, Context1, Context2, NewStack); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c new file mode 100644 index 0000000000..5c4737b326 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c @@ -0,0 +1,68 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86DisablePaging64.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Disables the 64-bit paging mode on the CPU. + + Disables the 64-bit paging mode on the CPU and returns to 32-bit protected + mode. This function assumes the current execution mode is 64-paging mode. + This function is only available on X64. After the 64-bit paging mode is + disabled, control is transferred to the function specified by EntryPoint + using the new stack specified by NewStack and passing in the parameters + specified by Context1 and Context2. Context1 and Context2 are optional and + may be 0. The function EntryPoint must never return. + + If the current execution mode is not 64-bit paged mode, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for 32-bit protected mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is disabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is disabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is disabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is disabled. + +**/ +VOID +EFIAPI +AsmDisablePaging64 ( + IN UINT16 Cs, + IN UINT32 EntryPoint, + IN UINT32 Context1, OPTIONAL + IN UINT32 Context2, OPTIONAL + IN UINT32 NewStack + ) +{ + ASSERT (EntryPoint != 0); + ASSERT (NewStack != 0); + InternalX86DisablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c new file mode 100644 index 0000000000..33622a5a44 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86EnablePaging32.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Enables the 32-bit paging mode on the CPU. + + Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode. This function is + only available on IA-32. After the 32-bit paging mode is enabled, control is + transferred to the function specified by EntryPoint using the new stack + specified by NewStack and passing in the parameters specified by Context1 and + Context2. Context1 and Context2 are optional and may be NULL. The function + EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + If NewStack is NULL, then ASSERT(). + + There are a number of constraints that must be followed before calling this + function: + 1) Interrupts must be disabled. + 2) The caller must be in 32-bit protected mode with flat descriptors. This + means all descriptors must have a base of 0 and a limit of 4GB. + 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat + descriptors. + 4) CR3 must point to valid page tables that will be used once the transition + is complete, and those page tables must guarantee that the pages for this + function and the stack are identity mapped. + + @param EntryPoint A pointer to function to call with the new stack after + paging is enabled. + @param Context1 A pointer to the context to pass into the EntryPoint + function as the first parameter after paging is enabled. + @param Context2 A pointer to the context to pass into the EntryPoint + function as the second parameter after paging is enabled. + @param NewStack A pointer to the new stack to use for the EntryPoint + function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging32 ( + IN SWITCH_STACK_ENTRY_POINT EntryPoint, + IN VOID *Context1, OPTIONAL + IN VOID *Context2, OPTIONAL + IN VOID *NewStack + ) +{ + ASSERT (EntryPoint != NULL); + ASSERT (NewStack != NULL); + InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c new file mode 100644 index 0000000000..790c80c399 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c @@ -0,0 +1,70 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86EnablePaging64.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Enables the 64-bit paging mode on the CPU. + + Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables + must be properly initialized prior to calling this service. This function + assumes the current execution mode is 32-bit protected mode with flat + descriptors. This function is only available on IA-32. After the 64-bit + paging mode is enabled, control is transferred to the function specified by + EntryPoint using the new stack specified by NewStack and passing in the + parameters specified by Context1 and Context2. Context1 and Context2 are + optional and may be 0. The function EntryPoint must never return. + + If the current execution mode is not 32-bit protected mode with flat + descriptors, then ASSERT(). + If EntryPoint is 0, then ASSERT(). + If NewStack is 0, then ASSERT(). + + @param Cs The 16-bit selector to load in the CS before EntryPoint + is called. The descriptor in the GDT that this selector + references must be setup for long mode. + @param EntryPoint The 64-bit virtual address of the function to call with + the new stack after paging is enabled. + @param Context1 The 64-bit virtual address of the context to pass into + the EntryPoint function as the first parameter after + paging is enabled. + @param Context2 The 64-bit virtual address of the context to pass into + the EntryPoint function as the second parameter after + paging is enabled. + @param NewStack The 64-bit virtual address of the new stack to use for + the EntryPoint function after paging is enabled. + +**/ +VOID +EFIAPI +AsmEnablePaging64 ( + IN UINT16 Cs, + IN UINT64 EntryPoint, + IN UINT64 Context1, OPTIONAL + IN UINT64 Context2, OPTIONAL + IN UINT64 NewStack + ) +{ + ASSERT (EntryPoint != 0); + ASSERT (NewStack != 0); + InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c new file mode 100644 index 0000000000..46a3eefe31 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c @@ -0,0 +1,54 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86FxRestore.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Restores the current floating point/SSE/SSE2 context from a buffer. + + Restores the current floating point/SSE/SSE2 state from the buffer specified + by Buffer. Buffer must be aligned on a 16-byte boundary. This function is + only available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + If Buffer was not saved with AsmFxSave(), then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ) +{ + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & 0xf) == 0); + + // + // Check the flag recorded by AsmFxSave() + // + ASSERT (*(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) == 0xAA5555AA); + + InternalX86FxRestore (Buffer); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c new file mode 100644 index 0000000000..de59619aa5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86FxSave.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Save the current floating point/SSE/SSE2 context to a buffer. + + Saves the current floating point/SSE/SSE2 state to the buffer specified by + Buffer. Buffer must be aligned on a 16-byte boundary. This function is only + available on IA-32 and X64. + + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-byte boundary, then ASSERT(). + + @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context. + +**/ +VOID +EFIAPI +AsmFxSave ( + OUT IA32_FX_BUFFER *Buffer + ) +{ + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & 0xf) == 0); + + InternalX86FxSave (Buffer); + + // + // Mark one flag at end of Buffer, it will be check by AsmFxRestor() + // + *(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c new file mode 100644 index 0000000000..d3fd368e94 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86GetInterruptState.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Retrieves the current CPU interrupt state. + + Retrieves the current CPU interrupt state. Returns TRUE is interrupts are + currently enabled. Otherwise returns FALSE. + + @retval TRUE CPU interrupts are enabled. + @retval FALSE CPU interrupts are disabled. + +**/ +BOOLEAN +EFIAPI +GlueGetInterruptState ( + VOID + ) +{ + IA32_EFLAGS32 EFlags; + + EFlags.UintN = AsmReadEflags (); + return (BOOLEAN)(EFlags.Bits.IF == 1); +} + + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c new file mode 100644 index 0000000000..4a9c2ade5c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c @@ -0,0 +1,39 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86MemoryFence.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ) +{ + return; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c new file mode 100644 index 0000000000..ce7d58d779 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c @@ -0,0 +1,657 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86Msr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Returns the lower 32-bits of a Machine Specific Register(MSR). + + Reads and returns the lower 32-bits of the MSR specified by Index. + No parameter checking is performed on Index, and some Index values may cause + CPU exceptions. The caller must either guarantee that Index is valid, or the + caller must set up exception handlers to catch the exceptions. This function + is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to read. + + @return The lower 32 bits of the MSR identified by Index. + +**/ +UINT32 +EFIAPI +AsmReadMsr32 ( + IN UINT32 Index + ) +{ + return (UINT32)AsmReadMsr64 (Index); +} + +/** + Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR). + + Writes the 32-bit value specified by Value to the MSR specified by Index. The + upper 32-bits of the MSR write are set to zero. The 32-bit value written to + the MSR is returned. No parameter checking is performed on Index or Value, + and some of these may cause CPU exceptions. The caller must either guarantee + that Index and Value are valid, or the caller must establish proper exception + handlers. This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param Value The 32-bit value to write to the MSR. + + @return Value + +**/ +UINT32 +EFIAPI +AsmWriteMsr32 ( + IN UINT32 Index, + IN UINT32 Value + ) +{ + return (UINT32)AsmWriteMsr64 (Index, Value); +} + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and + writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the lower 32-bits of the read result and the value specified by + OrData, and writes the result to the 64-bit MSR specified by Index. The lower + 32-bits of the value written to the MSR is returned. No parameter checking is + performed on Index or OrData, and some of these may cause CPU exceptions. The + caller must either guarantee that Index and OrData are valid, or the caller + must establish proper exception handlers. This function is only available on + IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrOr32 ( + IN UINT32 Index, + IN UINT32 OrData + ) +{ + return (UINT32)AsmMsrOr64 (Index, OrData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes + the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData, and + writes the result to the 64-bit MSR specified by Index. The lower 32-bits of + the value written to the MSR is returned. No parameter checking is performed + on Index or AndData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index and AndData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAnd32 ( + IN UINT32 Index, + IN UINT32 AndData + ) +{ + return (UINT32)AsmMsrAnd64 (Index, AndData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR + on the lower 32-bits, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + lower 32-bits of the read result and the value specified by AndData + preserving the upper 32-bits, performs a bitwise inclusive OR between the + result of the AND operation and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Address. The lower 32-bits of the value + written to the MSR is returned. No parameter checking is performed on Index, + AndData, or OrData, and some of these may cause CPU exceptions. The caller + must either guarantee that Index, AndData, and OrData are valid, or the + caller must establish proper exception handlers. This function is only + available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrAndThenOr32 ( + IN UINT32 Index, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData); +} + +/** + Reads a bit field of an MSR. + + Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. The caller must either guarantee that Index is valid, or the caller + must set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The bit field read from the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldRead32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit); +} + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination MSR are preserved. The lower 32-bits of the MSR written is + returned. Extra left bits in Value are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldWrite32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT (EndBit < sizeof (Value) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The lower 32-bits of the value + written to the MSR are returned. Extra left bits in OrData are stripped. The + caller must either guarantee that Index and the data written is valid, or + the caller must set up exception handlers to catch the exceptions. This + function is only available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (OrData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The lower 32-bits of the value written to the + MSR are returned. Extra left bits in AndData are stripped. The caller must + either guarantee that Index and the data written is valid, or the caller must + set up exception handlers to catch the exceptions. This function is only + available on IA-32 and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAnd32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT (EndBit < sizeof (AndData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a + bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + lower 32-bits of the value written to the MSR are returned. Extra left bits + in both AndData and OrData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The lower 32-bit of the value written to the MSR. + +**/ +UINT32 +EFIAPI +AsmMsrBitFieldAndThenOr32 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT (EndBit < sizeof (AndData) * 8); + ASSERT (StartBit <= EndBit); + return (UINT32)AsmMsrBitFieldAndThenOr64 ( + Index, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result + back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. No parameter checking is performed on Index or OrData, and some of + these may cause CPU exceptions. The caller must either guarantee that Index + and OrData are valid, or the caller must establish proper exception handlers. + This function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param OrData The value to OR with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrOr64 ( + IN UINT32 Index, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by OrData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. No + parameter checking is performed on Index or OrData, and some of these may + cause CPU exceptions. The caller must either guarantee that Index and OrData + are valid, or the caller must establish proper exception handlers. This + function is only available on IA-32 and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAnd64 ( + IN UINT32 Index, + IN UINT64 AndData + ) +{ + return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData); +} + +/** + Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive + OR, and writes the result back to the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between read + result and the value specified by AndData, performs a bitwise inclusive OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit MSR specified by Index. The value written + to the MSR is returned. No parameter checking is performed on Index, AndData, + or OrData, and some of these may cause CPU exceptions. The caller must either + guarantee that Index, AndData, and OrData are valid, or the caller must + establish proper exception handlers. This function is only available on IA-32 + and X64. + + @param Index The 32-bit MSR index to write. + @param AndData The value to AND with the read value from the MSR. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrAndThenOr64 ( + IN UINT32 Index, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData); +} + +/** + Reads a bit field of an MSR. + + Reads the bit field in the 64-bit MSR. The bit field is specified by the + StartBit and the EndBit. The value of the bit field is returned. The caller + must either guarantee that Index is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldRead64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit); +} + +/** + Writes a bit field to an MSR. + + Writes Value to a bit field in a 64-bit MSR. The bit field is specified by + the StartBit and the EndBit. All other bits in the destination MSR are + preserved. The MSR written is returned. Extra left bits in Value are + stripped. The caller must either guarantee that Index and the data written is + valid, or the caller must set up exception handlers to catch the exceptions. + This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldWrite64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and + writes the result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit MSR specified by Index. The value written to the MSR is + returned. Extra left bits in OrData are stripped. The caller must either + guarantee that Index and the data written is valid, or the caller must set up + exception handlers to catch the exceptions. This function is only available + on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND between the + read result and the value specified by AndData, and writes the result to the + 64-bit MSR specified by Index. The value written to the MSR is returned. + Extra left bits in AndData are stripped. The caller must either guarantee + that Index and the data written is valid, or the caller must set up exception + handlers to catch the exceptions. This function is only available on IA-32 + and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAnd64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MSR. + + Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by + a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit MSR specified by Index. The + value written to the MSR is returned. Extra left bits in both AndData and + OrData are stripped. The caller must either guarantee that Index and the data + written is valid, or the caller must set up exception handlers to catch the + exceptions. This function is only available on IA-32 and X64. + + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Index The 32-bit MSR index to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the bit field. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MSR. + +**/ +UINT64 +EFIAPI +AsmMsrBitFieldAndThenOr64 ( + IN UINT32 Index, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return AsmWriteMsr64 ( + Index, + BitFieldAndThenOr64 ( + AsmReadMsr64 (Index), + StartBit, + EndBit, + AndData, + OrData + ) + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c new file mode 100644 index 0000000000..b271f7ef24 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86ReadGdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Reads the current Global Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current GDTR descriptor and returns it in Gdtr. This + function is only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadGdtr ( + OUT IA32_DESCRIPTOR *Gdtr + ) +{ + ASSERT (Gdtr != NULL); + InternalX86ReadGdtr (Gdtr); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c new file mode 100644 index 0000000000..579b7382bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86ReadIdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Reads the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Reads and returns the current IDTR descriptor and returns it in Idtr. This + function is only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmReadIdtr ( + OUT IA32_DESCRIPTOR *Idtr + ) +{ + ASSERT (Idtr != NULL); + InternalX86ReadIdtr (Idtr); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c new file mode 100644 index 0000000000..aafc18d8d7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c @@ -0,0 +1,250 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86Thunk.c + +Abstract: + + Real Mode Thunk Functions for IA32 and X64. + +--*/ + +#include "BaseLibInternal.h" +// +// Byte packed structure for a segment descriptor in a GDT/LDT +// +typedef union { + struct { + UINT32 LimitLow:16; + UINT32 BaseLow:16; + UINT32 BaseMid:8; + UINT32 Type:4; + UINT32 S:1; + UINT32 DPL:2; + UINT32 P:1; + UINT32 LimitHigh:4; + UINT32 AVL:1; + UINT32 L:1; + UINT32 DB:1; + UINT32 G:1; + UINT32 BaseHigh:8; + } Bits; + UINT64 Uint64; +} IA32_SEGMENT_DESCRIPTOR; + +extern CONST UINT8 m16Start; +extern CONST UINT16 m16Size; +extern CONST UINT16 mThunk16Attr; +extern CONST UINT16 m16Gdt; +extern CONST UINT16 m16GdtrBase; +extern CONST UINT16 mTransition; + +/** + Invokes 16-bit code in big real mode and returns the updated register set. + + This function transfers control to the 16-bit code specified by CS:EIP using + the stack specified by SS:ESP in RegisterSet. The updated registers are saved + on the real mode stack and the starting address of the save area is returned. + + @param RegisterSet Values of registers before invocation of 16-bit code. + @param Transition Pointer to the transition code under 1MB. + + @return The pointer to a IA32_REGISTER_SET structure containing the updated + register values. + +**/ +IA32_REGISTER_SET * +EFIAPI +InternalAsmThunk16 ( + IN IA32_REGISTER_SET *RegisterSet, + IN OUT VOID *Transition + ); + +/** + Retrieves the properties for 16-bit thunk functions. + + Computes the size of the buffer and stack below 1MB required to use the + AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This + buffer size is returned in RealModeBufferSize, and the stack size is returned + in ExtraStackSize. If parameters are passed to the 16-bit real mode code, + then the actual minimum stack size is ExtraStackSize plus the maximum number + of bytes that need to be passed to the 16-bit real mode code. + + If RealModeBufferSize is NULL, then ASSERT(). + If ExtraStackSize is NULL, then ASSERT(). + + @param RealModeBufferSize A pointer to the size of the buffer below 1MB + required to use the 16-bit thunk functions. + @param ExtraStackSize A pointer to the extra size of stack below 1MB + that the 16-bit thunk functions require for + temporary storage in the transition to and from + 16-bit real mode. + +**/ +VOID +EFIAPI +AsmGetThunk16Properties ( + OUT UINT32 *RealModeBufferSize, + OUT UINT32 *ExtraStackSize + ) +{ + ASSERT (RealModeBufferSize != NULL); + ASSERT (ExtraStackSize != NULL); + + *RealModeBufferSize = m16Size; + + // + // Extra 4 bytes for return address, and another 4 bytes for mode transition + // + *ExtraStackSize = sizeof (IA32_DWORD_REGS) + 8; +} + +/** + Prepares all structures a code required to use AsmThunk16(). + + Prepares all structures and code required to use AsmThunk16(). + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareThunk16 ( + OUT THUNK_CONTEXT *ThunkContext + ) +{ + IA32_SEGMENT_DESCRIPTOR *RealModeGdt; + + ASSERT (ThunkContext != NULL); + ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000); + ASSERT (ThunkContext->RealModeBufferSize >= m16Size); + ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000); + + CopyMem (ThunkContext->RealModeBuffer, &m16Start, m16Size); + + // + // Point RealModeGdt to the GDT to be used in transition + // + // RealModeGdt[0]: Reserved as NULL descriptor + // RealModeGdt[1]: Code Segment + // RealModeGdt[2]: Data Segment + // RealModeGdt[3]: Call Gate + // + RealModeGdt = (IA32_SEGMENT_DESCRIPTOR*)( + (UINTN)ThunkContext->RealModeBuffer + m16Gdt); + + // + // Update Code & Data Segment Descriptor + // + RealModeGdt[1].Bits.BaseLow = + (UINT32)(UINTN)ThunkContext->RealModeBuffer & ~0xf; + RealModeGdt[1].Bits.BaseMid = + (UINT32)(UINTN)ThunkContext->RealModeBuffer >> 16; + + // + // Update transition code entry point offset + // + *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mTransition) += + (UINT32)(UINTN)ThunkContext->RealModeBuffer & 0xf; + + // + // Update Segment Limits for both Code and Data Segment Descriptors + // + if ((ThunkContext->ThunkAttributes & THUNK_ATTRIBUTE_BIG_REAL_MODE) == 0) { + // + // Set segment limits to 64KB + // + RealModeGdt[1].Bits.LimitHigh = 0; + RealModeGdt[1].Bits.G = 0; + RealModeGdt[2].Bits.LimitHigh = 0; + RealModeGdt[2].Bits.G = 0; + } + + // + // Update GDTBASE for this thunk context + // + *(VOID**)((UINTN)ThunkContext->RealModeBuffer + m16GdtrBase) = RealModeGdt; + + // + // Update Thunk Attributes + // + *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mThunk16Attr) = + ThunkContext->ThunkAttributes; +} + +/** + Transfers control to a 16-bit real mode entry point and returns the results. + + Transfers control to a 16-bit real mode entry point and returns the results. + AsmPrepareThunk16() must be called with ThunkContext before this function is + used. This function must be called with interrupts disabled. + + If ThunkContext is NULL, then ASSERT(). + If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ) +{ + IA32_REGISTER_SET *UpdatedRegs; + + ASSERT (ThunkContext != NULL); + ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000); + ASSERT (ThunkContext->RealModeBufferSize >= m16Size); + ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000); + + UpdatedRegs = InternalAsmThunk16 ( + ThunkContext->RealModeState, + ThunkContext->RealModeBuffer + ); + + CopyMem (ThunkContext->RealModeState, UpdatedRegs, sizeof (*UpdatedRegs)); +} + +/** + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. + + Prepares all structures and code for a 16-bit real mode thunk, transfers + control to a 16-bit real mode entry point, and returns the results. If the + caller only need to perform a single 16-bit real mode thunk, then this + service should be used. If the caller intends to make more than one 16-bit + real mode thunk, then it is more efficient if AsmPrepareThunk16() is called + once and AsmThunk16() can be called for each 16-bit real mode thunk. This + function must be called with interrupts disabled. + + If ThunkContext is NULL, then ASSERT(). + + @param ThunkContext A pointer to the context structure that describes the + 16-bit real mode code to call. + +**/ +VOID +EFIAPI +AsmPrepareAndThunk16 ( + IN OUT THUNK_CONTEXT *ThunkContext + ) +{ + AsmPrepareThunk16 (ThunkContext); + AsmThunk16 (ThunkContext); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c new file mode 100644 index 0000000000..9dfa789525 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86WriteGdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Writes the current Global Descriptor Table Register (GDTR) descriptor. + + Writes and the current GDTR descriptor specified by Gdtr. This function is + only available on IA-32 and X64. + + If Gdtr is NULL, then ASSERT(). + + @param Gdtr Pointer to a GDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteGdtr ( + IN CONST IA32_DESCRIPTOR *Gdtr + ) +{ + ASSERT (Gdtr != NULL); + InternalX86WriteGdtr (Gdtr); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c new file mode 100644 index 0000000000..fed0ef8ef6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c @@ -0,0 +1,44 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86WriteIdtr.c + +Abstract: + + IA-32/x64 specific functions. + +--*/ + +#include "BaseLibInternal.h" + +/** + Writes the current Interrupt Descriptor Table Register(GDTR) descriptor. + + Writes the current IDTR descriptor and returns it in Idtr. This function is + only available on IA-32 and X64. + + If Idtr is NULL, then ASSERT(). + + @param Idtr Pointer to a IDTR descriptor. + +**/ +VOID +EFIAPI +AsmWriteIdtr ( + IN CONST IA32_DESCRIPTOR *Idtr + ) +{ + ASSERT (Idtr != NULL); + InternalX86WriteIdtr (Idtr); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf new file mode 100644 index 0000000000..2ea4399444 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf @@ -0,0 +1,91 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BaseMemoryLib.inf +# +# Abstract: +# +# Component description file for BaseMemoryLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseMemoryLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + CopyMem.c + MemLibGuid.c + MemLibGeneric.c + CopyMemWrapper.c + SetMemWrapper.c + SetMem16Wrapper.c + SetMem32Wrapper.c + SetMem64Wrapper.c + CompareMemWrapper.c + ZeroMemWrapper.c + ScanMem8Wrapper.c + ScanMem16Wrapper.c + ScanMem32Wrapper.c + ScanMem64Wrapper.c + SetMem.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h new file mode 100644 index 0000000000..6a621041ea --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h @@ -0,0 +1,227 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BaseMemoryLibInternals.h + +Abstract: + + Header file for Base Memory Library. + +--*/ + +#ifndef __BASEMEMORY_LIB_INTERNALS_H__ +#define __BASEMEMORY_LIB_INTERNALS_H__ + +#include "EdkIIGlueBase.h" +/** + Copy Length bytes from Source to Destination. + + @param Destination Target of copy + @param Source Place to copy from + @param Length Number of bytes to copy + + @return Destination + +**/ +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ); + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c new file mode 100644 index 0000000000..fe0738268d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c @@ -0,0 +1,63 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CompareMemWrapper.c + +Abstract: + + CompareMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Compares the contents of two buffers. + + This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer. + If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the + value returned is the first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT(). + If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT(). + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + + @param DestinationBuffer Pointer to the destination buffer to compare. + @param SourceBuffer Pointer to the source buffer to compare. + @param Length Number of bytes to compare. + + @return 0 All Length bytes of the two buffers are identical. + @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + +**/ +INTN +EFIAPI +GlueCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + if (Length == 0) { + return 0; + } + ASSERT (DestinationBuffer != NULL); + ASSERT (SourceBuffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); + + return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c new file mode 100644 index 0000000000..bd39f1f6a7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c @@ -0,0 +1,65 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + CopyMem.c + +Abstract: + + Internal CopyMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copy Length bytes from Source to Destination. + + @param Destination Target of copy + @param Source Place to copy from + @param Length Number of bytes to copy + + @return Destination + +**/ +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *Destination, + IN CONST VOID *Source, + IN UINTN Length + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memcpy() + // + volatile UINT8 *Destination8; + CONST UINT8 *Source8; + + if (Source > Destination) { + Destination8 = (UINT8*)Destination; + Source8 = (CONST UINT8*)Source; + while (Length-- != 0) { + *(Destination8++) = *(Source8++); + } + } else if (Source < Destination) { + Destination8 = (UINT8*)Destination + Length; + Source8 = (CONST UINT8*)Source + Length; + while (Length-- != 0) { + *(--Destination8) = *(--Source8); + } + } + return Destination; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c new file mode 100644 index 0000000000..4a62962b80 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CopyMemWrapper.c + +Abstract: + + CopyMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copies a source buffer to a destination buffer, and returns the destination buffer. + + This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns + DestinationBuffer. The implementation must be reentrant, and it must handle the case + where SourceBuffer overlaps DestinationBuffer. + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer Pointer to the destination buffer of the memory copy. + @param SourceBuffer Pointer to the source buffer of the memory copy. + @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer. + + @return DestinationBuffer. + +**/ +VOID * +EFIAPI +GlueCopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + if (Length == 0) { + return DestinationBuffer; + } + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); + + if (DestinationBuffer == SourceBuffer) { + return DestinationBuffer; + } + return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c new file mode 100644 index 0000000000..a7fc82f03c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c @@ -0,0 +1,261 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + MemLibGeneric.c + +Abstract: + + Architecture Independent Base Memory Library Implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + do { + ((UINT16*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + do { + ((UINT32*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + do { + ((UINT64*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + return InternalMemSetMem (Buffer, Length, 0); +} + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + while ((--Length != 0) && + (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) { + DestinationBuffer = (INT8*)DestinationBuffer + 1; + SourceBuffer = (INT8*)SourceBuffer + 1; + } + return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer; +} + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + CONST UINT8 *Pointer; + + Pointer = (CONST UINT8*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + CONST UINT16 *Pointer; + + Pointer = (CONST UINT16*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + CONST UINT32 *Pointer; + + Pointer = (CONST UINT32*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + CONST UINT64 *Pointer; + + Pointer = (CONST UINT64*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c new file mode 100644 index 0000000000..6a3654c1b7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c @@ -0,0 +1,135 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MemLibGuid.c + +Abstract: + + Implementation of GUID functions. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Copies a source GUID to a destination GUID. + + This function copies the contents of the 128-bit GUID specified by SourceGuid to + DestinationGuid, and returns DestinationGuid. + If DestinationGuid is NULL, then ASSERT(). + If SourceGuid is NULL, then ASSERT(). + + @param DestinationGuid Pointer to the destination GUID. + @param SourceGuid Pointer to the source GUID. + + @return DestinationGuid. + +**/ +GUID * +EFIAPI +CopyGuid ( + OUT GUID *DestinationGuid, + IN CONST GUID *SourceGuid + ) +{ + WriteUnaligned64 ( + (UINT64*)DestinationGuid, + ReadUnaligned64 ((CONST UINT64*)SourceGuid) + ); + WriteUnaligned64 ( + (UINT64*)DestinationGuid + 1, + ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1) + ); + return DestinationGuid; +} + +/** + Compares two GUIDs. + + This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned. + If there are any bit differences in the two GUIDs, then FALSE is returned. + If Guid1 is NULL, then ASSERT(). + If Guid2 is NULL, then ASSERT(). + + @param Guid1 A pointer to a 128 bit GUID. + @param Guid2 A pointer to a 128 bit GUID. + + @retval TRUE Guid1 and Guid2 are identical. + @retval FALSE Guid1 and Guid2 are not identical. + +**/ +BOOLEAN +EFIAPI +GlueCompareGuid ( + IN CONST GUID *Guid1, + IN CONST GUID *Guid2 + ) +{ + UINT64 LowPartOfGuid1; + UINT64 LowPartOfGuid2; + UINT64 HighPartOfGuid1; + UINT64 HighPartOfGuid2; + + LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1); + LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2); + HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1); + HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1); + + return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2); +} + +/** + Scans a target buffer for a GUID, and returns a pointer to the matching GUID + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from + the lowest address to the highest address at 128-bit increments for the 128-bit + GUID value that matches Guid. If a match is found, then a pointer to the matching + GUID in the target buffer is returned. If no match is found, then NULL is returned. + If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Guid Value to search for in the target buffer. + + @return A pointer to the matching Guid in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanGuid ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN CONST GUID *Guid + ) +{ + CONST GUID *GuidPtr; + + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); + ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); + + GuidPtr = (GUID*)Buffer; + Buffer = GuidPtr + Length / sizeof (*GuidPtr); + while (GuidPtr < (CONST GUID*)Buffer) { + if (CompareGuid (GuidPtr, Guid)) { + return (VOID*)GuidPtr; + } + GuidPtr++; + } + return NULL; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c new file mode 100644 index 0000000000..e1fc8f19f1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c @@ -0,0 +1,63 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ScanMem16Wrapper.c + +Abstract: + + ScanMem16() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 16-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c new file mode 100644 index 0000000000..f9ae443982 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c @@ -0,0 +1,63 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ScanMem32Wrapper.c + +Abstract: + + ScanMem32() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 32-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c new file mode 100644 index 0000000000..fb2227082a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScanMem64Wrapper.c + +Abstract: + + ScanMem64() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 64-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c new file mode 100644 index 0000000000..90f7df87be --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c @@ -0,0 +1,57 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ScanMem8Wrapper.c + +Abstract: + + ScanMem8() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for an 8-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + if (Length == 0) { + return NULL; + } + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + + return (VOID*)InternalMemScanMem8 (Buffer, Length, Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c new file mode 100644 index 0000000000..364623364e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c @@ -0,0 +1,55 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SetMem.c + +Abstract: + + Internal SetMem + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +{ + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memset() + // + volatile UINT8 *Pointer; + + Pointer = (UINT8*)Buffer; + while (Size-- != 0) { + *(Pointer++) = Value; + } + return Buffer; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c new file mode 100644 index 0000000000..2fa5c6ee7c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c @@ -0,0 +1,61 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SetMem16Wrapper.c + +Abstract: + + SetMem16() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 16-bit value specified by + Value, and returns Buffer. Value is repeated every 16-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c new file mode 100644 index 0000000000..198f221cb4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c @@ -0,0 +1,61 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SetMem32Wrapper.c + +Abstract: + + SetMem32() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 32-bit value specified by + Value, and returns Buffer. Value is repeated every 32-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem32 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c new file mode 100644 index 0000000000..5643665c73 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + SetMem64Wrapper.c + +Abstract: + + SetMem64() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 64-bit value specified by + Value, and returns Buffer. Value is repeated every 64-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem64 (Buffer, Length / sizeof (Value), Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c new file mode 100644 index 0000000000..79481d884a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SetMemWrapper.c + +Abstract: + + SetMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with a byte value, and returns the target buffer. + + This function fills Length bytes of Buffer with Value, and returns Buffer. + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Memory to set. + @param Length Number of bytes to set. + @param Value Value of the set operation. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueSetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + + return InternalMemSetMem (Buffer, Length, Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c new file mode 100644 index 0000000000..6adda514ac --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c @@ -0,0 +1,47 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ZeroMemWrapper.c + +Abstract: + + ZeroMem() implementation. + +--*/ + +#include "BaseMemoryLibInternal.h" + +/** + Fills a target buffer with zeros, and returns the target buffer. + + This function fills Length bytes of Buffer with zeros, and returns Buffer. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with zeros. + @param Length Number of bytes in Buffer to fill with zeros. + + @return Buffer. + +**/ +VOID * +EFIAPI +GlueZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + ASSERT (!(Buffer == NULL && Length > 0)); + ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + return InternalMemZeroMem (Buffer, Length); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf new file mode 100644 index 0000000000..94af7735c8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf @@ -0,0 +1,84 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePciCf8Lib.inf +# +# Abstract: +# +# Component description file for BasePciCf8Lib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciCf8Lib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + + +[libraries.ia32] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.x64] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ebc] + EdkIIGlueDxeIoLibCpuIo + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c new file mode 100644 index 0000000000..0bd1471a1d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c @@ -0,0 +1,1468 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciLib.c + +Abstract: + + PCI Library. + +--*/ + +#include "EdkIIGlueBase.h" + +// +// Declare I/O Ports used to perform PCI Confguration Cycles +// +#define PCI_CONFIGURATION_ADDRESS_PORT 0xCF8 +#define PCI_CONFIGURATION_DATA_PORT 0xCFC + +// +// Declare macro to convert PCI Library formatted address to CF8 formatted address +// +// PCI Library formatted address CF8 Formatted Address +// ============================= ====================== +// Bits 00..11 Register Bits 00..07 Register +// Bits 12..14 Function Bits 08..10 Function +// Bits 15..19 Device Bits 11..15 Device +// Bits 20..27 Bus Bits 16..23 Bus +// Bits 28..31 Reserved(MBZ) Bits 24..30 Reserved(MBZ) +// Bits 31..31 Must be 1 +// + +/** + Assert the validity of a PCI address. A valid PCI address should contain 1's + only in the low 28 bits. + + @param A The address to validate. + @param M Additional bits to assert to be zero. + +**/ +#define ASSERT_INVALID_PCI_ADDRESS(A,M) \ + ASSERT (((A) & (~0xffff0ff | (M))) == 0) + +/** + Convert a PCI Express address to PCI CF8 address. + + @param A The address to convert. + + @retval The coverted address. + +**/ +#define PCI_TO_CF8_ADDRESS(A) \ + ((UINT32) ((((A) >> 4) & 0x00ffff00) | ((A) & 0xfc) | 0x80000000)) + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Read8 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoRead8 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3)); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Write8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoWrite8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + Value + ); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8Or8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + OrData + ); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8And8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAnd8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + AndData + ); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8AndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAndThenOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldRead8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldWrite8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAnd8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciCf8BitFieldAndThenOr8( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 0); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAndThenOr8 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Read16 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoRead16 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2)); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Write16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoWrite16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + Value + ); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8Or16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + OrData + ); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8And16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAnd16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + AndData + ); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8AndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAndThenOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldRead16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldWrite16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAnd16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciCf8BitFieldAndThenOr16( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 1); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAndThenOr16 ( + PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Read32 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoRead32 (PCI_CONFIGURATION_DATA_PORT); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Write32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoWrite32 ( + PCI_CONFIGURATION_DATA_PORT, + Value + ); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8Or32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoOr32 ( + PCI_CONFIGURATION_DATA_PORT, + OrData + ); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8And32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAnd32 ( + PCI_CONFIGURATION_DATA_PORT, + AndData + ); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8AndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoAndThenOr32 ( + PCI_CONFIGURATION_DATA_PORT, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldRead32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldWrite32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldOr32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAnd32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If the register specified by Address >= 0x100, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciCf8BitFieldAndThenOr32( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address, 3); + IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); + return IoBitFieldAndThenOr32 ( + PCI_CONFIGURATION_DATA_PORT, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8ReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); + + if (Size == 0) { + return Size; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Read a byte if StartAddress is byte aligned + // + *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Read a word if StartAddress is word aligned + // + *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Read as many double words as possible + // + *(volatile UINT32 *)Buffer = PciCf8Read32 (StartAddress); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Read the last remaining word if exist + // + *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Read the last remaining byte if exist + // + *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress); + } + + return ReturnValue; +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If the register specified by StartAddress >= 0x100, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciCf8WriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); + + if (Size == 0) { + return 0; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Write a byte if StartAddress is byte aligned + // + PciCf8Write8 (StartAddress, *(UINT8*)Buffer); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Write a word if StartAddress is word aligned + // + PciCf8Write16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Write as many double words as possible + // + PciCf8Write32 (StartAddress, *(UINT32*)Buffer); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Write the last remaining word if exist + // + PciCf8Write16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Write the last remaining byte if exist + // + PciCf8Write8 (StartAddress, *(UINT8*)Buffer); + } + + return ReturnValue; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf new file mode 100644 index 0000000000..b408dc3f4d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf @@ -0,0 +1,83 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePciExpressLib.inf +# +# Abstract: +# +# Component description file for BasePciExpressLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciExpressLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\Include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + +[libraries.ia32] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.x64] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ebc] + EdkIIGlueDxeIoLibCpuIo + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c new file mode 100644 index 0000000000..8404f71bdb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c @@ -0,0 +1,1373 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciLib.c + +Abstract: + + PCI Library. + + Functions in this library instance make use of MMIO functions in IoLib to + access memory mapped PCI configuration space. + + All assertions for I/O operations are handled in MMIO functions in the IoLib + Library. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Assert the validity of a PCI address. A valid PCI address should contain 1's + only in the low 28 bits. + + @param A The address to validate. + +**/ +#define ASSERT_INVALID_PCI_ADDRESS(A) \ + ASSERT (((A) & ~0xfffffff) == 0) + + +/** + Gets the base address of PCI Express. + + This internal functions retrieves PCI Express Base Address via a PCD entry + PcdPciExpressBaseAddress. + + @return The base address of PCI Express. + +**/ +STATIC +volatile VOID* +GetPciExpressBaseAddress ( + VOID + ) +{ + return (VOID*)(UINTN) PcdGet64 (PcdPciExpressBaseAddress); +} + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressRead8 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioRead8 ((UINTN) GetPciExpressBaseAddress () + Address); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressWrite8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioWrite8 ((UINTN) GetPciExpressBaseAddress () + Address, Value); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioOr8 ((UINTN) GetPciExpressBaseAddress () + Address, OrData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAnd8 ((UINTN) GetPciExpressBaseAddress () + Address, AndData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAndThenOr8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldRead8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldWrite8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldOr8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAnd8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciExpressBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAndThenOr8 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressRead16 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioRead16 ((UINTN) GetPciExpressBaseAddress () + Address); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressWrite16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioWrite16 ((UINTN) GetPciExpressBaseAddress () + Address, Value); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioOr16 ((UINTN) GetPciExpressBaseAddress () + Address, OrData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAnd16 ((UINTN) GetPciExpressBaseAddress () + Address, AndData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAndThenOr16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldRead16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldWrite16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldOr16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAnd16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciExpressBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAndThenOr16 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressRead32 ( + IN UINTN Address + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioRead32 ((UINTN) GetPciExpressBaseAddress () + Address); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressWrite32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioWrite32 ((UINTN) GetPciExpressBaseAddress () + Address, Value); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioOr32 ((UINTN) GetPciExpressBaseAddress () + Address, OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAnd32 ((UINTN) GetPciExpressBaseAddress () + Address, AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioAndThenOr32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + AndData, + OrData + ); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldRead32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit + ); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldWrite32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + Value + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldOr32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + OrData + ); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAnd32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciExpressBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + ASSERT_INVALID_PCI_ADDRESS (Address); + return MmioBitFieldAndThenOr32 ( + (UINTN) GetPciExpressBaseAddress () + Address, + StartBit, + EndBit, + AndData, + OrData + ); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); + + if (Size == 0) { + return Size; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Read a byte if StartAddress is byte aligned + // + *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Read a word if StartAddress is word aligned + // + *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Read as many double words as possible + // + *(volatile UINT32 *)Buffer = PciExpressRead32 (StartAddress); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Read the last remaining word if exist + // + *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Read the last remaining byte if exist + // + *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress); + } + + return ReturnValue; +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciExpressWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_ADDRESS (StartAddress); + ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); + + if (Size == 0) { + return 0; + } + + ASSERT (Buffer != NULL); + + // + // Save Size for return + // + ReturnValue = Size; + + if ((StartAddress & 1) != 0) { + // + // Write a byte if StartAddress is byte aligned + // + PciExpressWrite8 (StartAddress, *(UINT8*)Buffer); + StartAddress += sizeof (UINT8); + Size -= sizeof (UINT8); + Buffer = (UINT8*)Buffer + 1; + } + + if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) { + // + // Write a word if StartAddress is word aligned + // + PciExpressWrite16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + while (Size >= sizeof (UINT32)) { + // + // Write as many double words as possible + // + PciExpressWrite32 (StartAddress, *(UINT32*)Buffer); + StartAddress += sizeof (UINT32); + Size -= sizeof (UINT32); + Buffer = (UINT32*)Buffer + 1; + } + + if (Size >= sizeof (UINT16)) { + // + // Write the last remaining word if exist + // + PciExpressWrite16 (StartAddress, *(UINT16*)Buffer); + StartAddress += sizeof (UINT16); + Size -= sizeof (UINT16); + Buffer = (UINT16*)Buffer + 1; + } + + if (Size >= sizeof (UINT8)) { + // + // Write the last remaining byte if exist + // + PciExpressWrite8 (StartAddress, *(UINT8*)Buffer); + } + + return ReturnValue; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf new file mode 100644 index 0000000000..2196639d52 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePciLibCf8.inf +# +# Abstract: +# +# Component description file for BasePciLibCf8. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciLibCf8 +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBasePciCf8Lib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c new file mode 100644 index 0000000000..cc818a7d34 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c @@ -0,0 +1,1076 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PciLib.c + +Abstract: + + PCI Library using Port CF8/CFC access. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciRead8 ( + IN UINTN Address + ) +{ + return PciCf8Read8 (Address); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciWrite8 ( + IN UINTN Address, + IN UINT8 Data + ) +{ + return PciCf8Write8 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return PciCf8Or8 (Address, OrData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return PciCf8And8 (Address, AndData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciCf8AndThenOr8 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciCf8BitFieldRead8 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return PciCf8BitFieldWrite8 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return PciCf8BitFieldOr8 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return PciCf8BitFieldAnd8 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciCf8BitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciRead16 ( + IN UINTN Address + ) +{ + return PciCf8Read16 (Address); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciWrite16 ( + IN UINTN Address, + IN UINT16 Data + ) +{ + return PciCf8Write16 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return PciCf8Or16 (Address, OrData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return PciCf8And16 (Address, AndData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciCf8AndThenOr16 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciCf8BitFieldRead16 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return PciCf8BitFieldOr16 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciCf8BitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciRead32 ( + IN UINTN Address + ) +{ + return PciCf8Read32 (Address); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciWrite32 ( + IN UINTN Address, + IN UINT32 Data + ) +{ + return PciCf8Write32 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return PciCf8Or32 (Address, OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return PciCf8And32 (Address, AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciCf8AndThenOr32 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciCf8BitFieldRead32 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return PciCf8BitFieldAnd32 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciCf8BitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + return PciCf8ReadBuffer (StartAddress, Size, Buffer); +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + return PciCf8WriteBuffer (StartAddress, Size, Buffer); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf new file mode 100644 index 0000000000..84af9d6161 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePciLibPciExpress.inf +# +# Abstract: +# +# Component description file for BasePciLibPciExpress. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePciLibPciExpress +COMPONENT_TYPE = LIBRARY + +[sources.common] + PciLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBasePciExpressLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c new file mode 100644 index 0000000000..652bfd908a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c @@ -0,0 +1,1076 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PciLib.c + +Abstract: + + PCI Library using PC Express access. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciRead8 ( + IN UINTN Address + ) +{ + return PciExpressRead8 (Address); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciWrite8 ( + IN UINTN Address, + IN UINT8 Data + ) +{ + return PciExpressWrite8 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return PciExpressOr8 (Address, OrData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return PciExpressAnd8 (Address, AndData); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit + value, followed a bitwise inclusive OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciExpressAndThenOr8 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciExpressBitFieldRead8 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 8-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return PciExpressBitFieldWrite8 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return PciExpressBitFieldOr8 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return PciExpressBitFieldAnd8 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciExpressBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciRead16 ( + IN UINTN Address + ) +{ + return PciExpressRead16 (Address); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciWrite16 ( + IN UINTN Address, + IN UINT16 Data + ) +{ + return PciExpressWrite16 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return PciExpressOr16 (Address, OrData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return PciExpressAnd16 (Address, AndData); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit + value, followed a bitwise inclusive OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciExpressAndThenOr16 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciExpressBitFieldRead16 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 16-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return PciExpressBitFieldWrite16 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return PciExpressBitFieldOr16 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 16-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 16-bit register. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 16-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return PciExpressBitFieldAnd16 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciExpressBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Address. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + + @return The read value from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciRead32 ( + IN UINTN Address + ) +{ + return PciExpressRead32 (Address); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with the + value specified by Value. Value is returned. This function must guarantee + that all PCI read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciWrite32 ( + IN UINTN Address, + IN UINT32 Data + ) +{ + return PciExpressWrite32 (Address, Data); +} + +/** + Performs a bitwise inclusive OR of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return PciExpressOr32 (Address, OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return PciExpressAnd32 (Address, AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit + value, followed a bitwise inclusive OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, + performs a bitwise inclusive OR between the result of the AND operation and + the value specified by OrData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. + + If Address > 0x0FFFFFFF, then ASSERT(). + + @param Address Address that encodes the PCI Bus, Device, Function and + Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciExpressAndThenOr32 (Address, AndData, OrData); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit field is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value of the bit field read from the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return PciExpressBitFieldRead32 (Address, StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of the + 32-bit register is returned. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return PciExpressBitFieldWrite32 (Address, StartBit, EndBit, Value); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise inclusive OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration register is + returned. This function must guarantee that all PCI read and write operations + are serialized. Extra left bits in OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return PciExpressBitFieldOr32 (Address, StartBit, EndBit, OrData); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bitwise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND between the read result and the value specified by AndData, and + writes the result to the 32-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return PciExpressBitFieldAnd32 (Address, StartBit, EndBit, AndData); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, performs a + bitwise AND followed by a bitwise inclusive OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that all PCI + read and write operations are serialized. Extra left bits in both AndData and + OrData are stripped. + + If Address > 0x0FFFFFFF, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciExpressBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buffer. + + Reads the range of PCI configuration registers specified by StartAddress and + Size into the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to read + from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning and the + end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciReadBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + return PciExpressReadBuffer (StartAddress, Size, Buffer); +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddress and + Size from the buffer specified by Buffer. This function only allows the PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrictions, + 8-bit and 16-bit PCI configuration write cycles may be used at the beginning + and the end of the range. + + If StartAddress > 0x0FFFFFFF, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress Starting address that encodes the PCI Bus, Device, + Function and Register. + @param Size Size in bytes of the transfer. + @param Buffer Pointer to a buffer containing the data to write. + + @return Size + +**/ +UINTN +EFIAPI +PciWriteBuffer ( + IN UINTN StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + return PciExpressWriteBuffer (StartAddress, Size, Buffer); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf new file mode 100644 index 0000000000..7b272bf2e4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf @@ -0,0 +1,83 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePeCoffGetEntryPointLib.inf +# +# Abstract: +# +# Component description file for BasePeCoffGetEntryPointLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePeCoffGetEntryPointLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeCoffGetEntryPoint.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Efi\Include + + +[libraries.common] + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c new file mode 100644 index 0000000000..87818b7446 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c @@ -0,0 +1,222 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeCoffGetEntryPoint.c + +Abstract: + + Pe/Coff loader + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded + into system memory with the PE/COFF Loader Library functions. + + Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry + point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then + return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS. + If Pe32Data is NULL, then ASSERT(). + If EntryPoint is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system memory. + @param EntryPoint Pointer to entry point to the PE/COFF image to return. + + @retval RETURN_SUCCESS EntryPoint was returned. + @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image. + +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderGetEntryPoint ( + IN VOID *Pe32Data, + OUT VOID **EntryPoint + ) +{ + EFI_IMAGE_DOS_HEADER *DosHeader; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Header; + + ASSERT (Pe32Data != NULL); + ASSERT (EntryPoint != NULL); + + DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image header. + // + Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff)); + } else { + // + // DOS image header is not present, so PE header is at the image base. + // + Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; + } + + // + // Calculate the entry point relative to the start of the image. + // AddressOfEntryPoint is common for PE32 & PE32+ + // + *EntryPoint = (VOID *)((UINTN)Pe32Data + (UINTN)(Header.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff)); + return RETURN_SUCCESS; +} + + +/** + Returns the machine type of a PE/COFF image. + + Returns the machine type from the PE/COFF image specified by Pe32Data. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return Machine type or zero if not a valid iamge. + +**/ +UINT16 +EFIAPI +PeCoffLoaderGetMachineType ( + IN VOID *Pe32Data + ) +{ + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DOS_HEADER *DosHdr; + + DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + DosHdr->e_lfanew); + } else { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data); + } + + if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + return Hdr.Pe32->FileHeader.Machine; + } + + return 0x0000; +} + +/** + Returns a pointer to the PDB file name for a PE/COFF image that has been + loaded into system memory with the PE/COFF Loader Library functions. + + Returns the PDB file name for the PE/COFF image specified by Pe32Data. If + the PE/COFF image specified by Pe32Data is not a valid, then NULL is + returned. If the PE/COFF image specified by Pe32Data does not contain a + debug directory entry, then NULL is returned. If the debug directory entry + in the PE/COFF image specified by Pe32Data does not contain a PDB file name, + then NULL is returned. + If Pe32Data is NULL, then ASSERT(). + + @param Pe32Data Pointer to the PE/COFF image that is loaded in system + memory. + + @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL + if it cannot be retrieved. + +**/ +VOID * +EFIAPI +PeCoffLoaderGetPdbPointer ( + IN VOID *Pe32Data + ) +{ + EFI_IMAGE_DOS_HEADER *DosHeader; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; + UINTN DirCount; + VOID *CodeViewEntryPointer; + INTN TEImageAdjust; + UINT32 NumberOfRvaAndSizes; + + ASSERT (Pe32Data != NULL); + + TEImageAdjust = 0; + DirectoryEntry = NULL; + DebugEntry = NULL; + NumberOfRvaAndSizes = 0; + + DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image header. + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff)); + } else { + // + // DOS image header is not present, so PE header is at the image base. + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data; + } + + if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { + if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) { + DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG]; + TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te + + Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress + + TEImageAdjust); + } + } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset get Debug Directory Entry + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); + } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + // + // Use PE32+ offset get Debug Directory Entry + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress); + } + + if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { + DirectoryEntry = NULL; + DebugEntry = NULL; + } + } else { + return NULL; + } + + if (DebugEntry == NULL || DirectoryEntry == NULL) { + return NULL; + } + + for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) { + if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + if (DebugEntry->SizeOfData > 0) { + CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust); + switch (* (UINT32 *) CodeViewEntryPointer) { + case CODEVIEW_SIGNATURE_NB10: + return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)); + case CODEVIEW_SIGNATURE_RSDS: + return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY)); + default: + break; + } + } + } + } + + return NULL; +} + + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c new file mode 100644 index 0000000000..489667cba3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c @@ -0,0 +1,1336 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EdkIIGlueDxeDriverEntryPoint.c + +Abstract: + + Pe/Coff loader + +--*/ + +#include "BasePeCoffLibInternals.h" + +/** + Retrieves the magic value from the PE/COFF header. + + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 + @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ + +**/ +UINT16 +PeCoffLoaderGetPeHeaderMagicValue ( + IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ) +{ + // + // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value + // in the PE/COFF Header. If the MachineType is Itanium(IA64) and the + // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC + // then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC + // + if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } + // + // Return the magic value from the PC/COFF Optional Header + // + return Hdr.Pe32->OptionalHeader.Magic; +} + + +/** + Retrieves the PE or TE Header from a PE/COFF or TE image. + + @param ImageContext The context of the image being loaded. + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @retval RETURN_SUCCESS The PE or TE Header is read. + @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function. + +**/ +RETURN_STATUS +GluePeCoffLoaderGetPeHeader ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_DOS_HEADER DosHdr; + UINTN Size; + UINT16 Magic; + + // + // Read the DOS image header to check for it's existance + // + Size = sizeof (EFI_IMAGE_DOS_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &Size, + &DosHdr + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + ImageContext->PeCoffHeaderOffset = 0; + if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image + // header + // + ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew; + } + + // + // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much + // data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic + // determins if this is a PE32 or PE32+ image. The magic is in the same + // location in both images. + // + Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + ImageContext->PeCoffHeaderOffset, + &Size, + Hdr.Pe32 + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + // + // Use Signature to figure out if we understand the image format + // + if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { + ImageContext->IsTeImage = TRUE; + ImageContext->Machine = Hdr.Te->Machine; + ImageContext->ImageType = (UINT16)(Hdr.Te->Subsystem); + ImageContext->ImageSize = 0; + ImageContext->SectionAlignment = 4096; + ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize; + + } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + ImageContext->IsTeImage = FALSE; + ImageContext->Machine = Hdr.Pe32->FileHeader.Machine; + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + ImageContext->ImageType = Hdr.Pe32->OptionalHeader.Subsystem; + ImageContext->ImageSize = (UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage; + ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment; + ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; + + } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + // + // Use PE32+ offset + // + ImageContext->ImageType = Hdr.Pe32Plus->OptionalHeader.Subsystem; + ImageContext->ImageSize = (UINT64) Hdr.Pe32Plus->OptionalHeader.SizeOfImage; + ImageContext->SectionAlignment = Hdr.Pe32Plus->OptionalHeader.SectionAlignment; + ImageContext->SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders; + } else { + ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE; + return RETURN_UNSUPPORTED; + } + } else { + ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE; + return RETURN_UNSUPPORTED; + } + + if (!PeCoffLoaderImageFormatSupported (ImageContext->Machine)) { + // + // If the PE/COFF loader does not support the image type return + // unsupported. This library can suport lots of types of images + // this does not mean the user of this library can call the entry + // point of the image. + // + return RETURN_UNSUPPORTED; + } + + return RETURN_SUCCESS; +} + + +/** + Retrieves information about a PE/COFF image. + + Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView, + PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva + fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER. + If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not + a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while + computing the fields of ImageContext, then the error status is returned in the ImageError field of + ImageContext. + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that needs to be examined by this function. + + @retval RETURN_SUCCESS The information on the PE/COFF image was collected. + @retval RETURN_INVALID_PARAMETER ImageContext is NULL. + @retval RETURN_UNSUPPORTED The PE/COFF image is not supported. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderGetImageInfo ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *DebugDirectoryEntry; + UINTN Size; + UINTN Index; + UINTN DebugDirectoryEntryRva; + UINTN DebugDirectoryEntryFileOffset; + UINTN SectionHeaderOffset; + EFI_IMAGE_SECTION_HEADER SectionHeader; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + if (NULL == ImageContext) { + return RETURN_INVALID_PARAMETER; + } + // + // Assume success + // + ImageContext->ImageError = IMAGE_ERROR_SUCCESS; + + Hdr.Union = &HdrData; + Status = PeCoffLoaderGetPeHeader (ImageContext, Hdr); + if (RETURN_ERROR (Status)) { + return Status; + } + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + // + // Retrieve the base address of the image + // + if (!(ImageContext->IsTeImage)) { + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + ImageContext->ImageAddress = Hdr.Pe32->OptionalHeader.ImageBase; + } else { + // + // Use PE32+ offset + // + ImageContext->ImageAddress = Hdr.Pe32Plus->OptionalHeader.ImageBase; + } + } else { + ImageContext->ImageAddress = (PHYSICAL_ADDRESS)(Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER)); + } + + // + // Initialize the alternate destination address to 0 indicating that it + // should not be used. + // + ImageContext->DestinationAddress = 0; + + // + // Initialize the codeview pointer. + // + ImageContext->CodeView = NULL; + ImageContext->PdbPointer = NULL; + + // + // Three cases with regards to relocations: + // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable + // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable + // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but + // has no base relocs to apply + // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid. + // + // Look at the file header to determine if relocations have been stripped, and + // save this info in the image context for later use. + // + if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) { + ImageContext->RelocationsStripped = TRUE; + } else { + ImageContext->RelocationsStripped = FALSE; + } + + if (!(ImageContext->IsTeImage)) { + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { + + DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; + + // + // Determine the file offset of the debug directory... This means we walk + // the sections to find which section contains the RVA of the debug + // directory + // + DebugDirectoryEntryFileOffset = 0; + + SectionHeaderOffset = (UINTN)( + ImageContext->PeCoffHeaderOffset + + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER) + + Hdr.Pe32->FileHeader.SizeOfOptionalHeader + ); + + for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) { + // + // Read section header from file + // + Size = sizeof (EFI_IMAGE_SECTION_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + SectionHeaderOffset, + &Size, + &SectionHeader + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && + DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { + + DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData; + break; + } + + SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); + } + + if (DebugDirectoryEntryFileOffset != 0) { + for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) { + // + // Read next debug directory entry + // + Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugDirectoryEntryFileOffset, + &Size, + &DebugEntry + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index); + if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) { + ImageContext->ImageSize += DebugEntry.SizeOfData; + } + + return RETURN_SUCCESS; + } + } + } + } + } else { + + DebugDirectoryEntry = &Hdr.Te->DataDirectory[1]; + DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; + SectionHeaderOffset = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER)); + + DebugDirectoryEntryFileOffset = 0; + + for (Index = 0; Index < Hdr.Te->NumberOfSections;) { + // + // Read section header from file + // + Size = sizeof (EFI_IMAGE_SECTION_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + SectionHeaderOffset, + &Size, + &SectionHeader + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && + DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { + DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - + SectionHeader.VirtualAddress + + SectionHeader.PointerToRawData + + sizeof (EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize; + + // + // File offset of the debug directory was found, if this is not the last + // section, then skip to the last section for calculating the image size. + // + if (Index < (UINTN) Hdr.Te->NumberOfSections - 1) { + SectionHeaderOffset += (Hdr.Te->NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER); + Index = Hdr.Te->NumberOfSections - 1; + continue; + } + } + + // + // In Te image header there is not a field to describe the ImageSize. + // Actually, the ImageSize equals the RVA plus the VirtualSize of + // the last section mapped into memory (Must be rounded up to + // a mulitple of Section Alignment). Per the PE/COFF specification, the + // section headers in the Section Table must appear in order of the RVA + // values for the corresponding sections. So the ImageSize can be determined + // by the RVA and the VirtualSize of the last section header in the + // Section Table. + // + if ((++Index) == (UINTN)Hdr.Te->NumberOfSections) { + ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize + + ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1); + } + + SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); + } + + if (DebugDirectoryEntryFileOffset != 0) { + for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) { + // + // Read next debug directory entry + // + Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugDirectoryEntryFileOffset, + &Size, + &DebugEntry + ); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index); + return RETURN_SUCCESS; + } + } + } + } + + return RETURN_SUCCESS; +} + + +/** + Converts an image address to the loaded address. + + @param ImageContext The context of the image being loaded. + @param Address The address to be converted to the loaded address. + + @return The converted address or NULL if the address can not be converted. + +**/ +VOID * +GluePeCoffLoaderImageAddress ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + IN UINTN Address + ) +{ + // + // @bug Check to make sure ImageSize is correct for the relocated image. + // it may only work for the file we start with and not the relocated image + // + if (Address >= ImageContext->ImageSize) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return NULL; + } + + return (CHAR8 *)((UINTN) ImageContext->ImageAddress + Address); +} + +/** + Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage(). + + If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of + ImageContext as the relocation base address. Otherwise, use the DestinationAddress field + of ImageContext as the relocation base address. The caller must allocate the relocation + fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being relocated. + + @retval RETURN_SUCCESS The PE/COFF image was relocated. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_UNSUPPORTED A relocation record type is not supported. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderRelocateImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *RelocDir; + UINT64 Adjust; + EFI_IMAGE_BASE_RELOCATION *RelocBase; + EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd; + UINT16 *Reloc; + UINT16 *RelocEnd; + CHAR8 *Fixup; + CHAR8 *FixupBase; + UINT16 *F16; + UINT32 *F32; + UINT64 *F64; + CHAR8 *FixupData; + PHYSICAL_ADDRESS BaseAddress; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + ASSERT (ImageContext != NULL); + + // + // Assume success + // + ImageContext->ImageError = IMAGE_ERROR_SUCCESS; + + // + // If there are no relocation entries, then we are done + // + if (ImageContext->RelocationsStripped) { + return RETURN_SUCCESS; + } + + // + // If the destination address is not 0, use that rather than the + // image address as the relocation target. + // + if (ImageContext->DestinationAddress != 0) { + BaseAddress = ImageContext->DestinationAddress; + } else if (!(ImageContext->IsTeImage)) { + BaseAddress = ImageContext->ImageAddress; + } else { + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + BaseAddress = ImageContext->ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; + } + + if (!(ImageContext->IsTeImage)) { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase; + Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress; + + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } else { + // + // Use PE32+ offset + // + Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase; + Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress; + + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + RelocDir = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } + + // + // Find the relocation block + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { + RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress); + RelocBaseEnd = PeCoffLoaderImageAddress ( + ImageContext, + RelocDir->VirtualAddress + RelocDir->Size - 1 + ); + } else { + // + // Set base and end to bypass processing below. + // + RelocBase = RelocBaseEnd = 0; + } + } else { + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase); + Hdr.Te->ImageBase = (UINT64) (BaseAddress); + + // + // Find the relocation block + // + RelocDir = &Hdr.Te->DataDirectory[0]; + RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)( + ImageContext->ImageAddress + + RelocDir->VirtualAddress + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1); + } + + // + // Run the relocation information and apply the fixups + // + FixupData = ImageContext->FixupData; + while (RelocBase < RelocBaseEnd) { + + Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION)); + RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock); + if (!(ImageContext->IsTeImage)) { + FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress); + } else { + FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress + + RelocBase->VirtualAddress + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + } + + if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) || + (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + + (UINTN)ImageContext->ImageSize)) { + ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION; + return RETURN_LOAD_ERROR; + } + + // + // Run this relocation record + // + while (Reloc < RelocEnd) { + + Fixup = FixupBase + (*Reloc & 0xFFF); + switch ((*Reloc) >> 12) { + case EFI_IMAGE_REL_BASED_ABSOLUTE: + break; + + case EFI_IMAGE_REL_BASED_HIGH: + F16 = (UINT16 *) Fixup; + *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16))); + if (FixupData != NULL) { + *(UINT16 *) FixupData = *F16; + FixupData = FixupData + sizeof (UINT16); + } + break; + + case EFI_IMAGE_REL_BASED_LOW: + F16 = (UINT16 *) Fixup; + *F16 = (UINT16) (*F16 + (UINT16) Adjust); + if (FixupData != NULL) { + *(UINT16 *) FixupData = *F16; + FixupData = FixupData + sizeof (UINT16); + } + break; + + case EFI_IMAGE_REL_BASED_HIGHLOW: + F32 = (UINT32 *) Fixup; + *F32 = *F32 + (UINT32) Adjust; + if (FixupData != NULL) { + FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); + *(UINT32 *)FixupData = *F32; + FixupData = FixupData + sizeof (UINT32); + } + break; + + case EFI_IMAGE_REL_BASED_DIR64: + F64 = (UINT64 *) Fixup; + *F64 = *F64 + (UINT64) Adjust; + if (FixupData != NULL) { + FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64)); + *(UINT64 *)(FixupData) = *F64; + FixupData = FixupData + sizeof(UINT64); + } + break; + + default: + // + // The common code does not handle some of the stranger IPF relocations + // PeCoffLoaderRelocateImageEx () addes support for these complex fixups + // on IPF and is a No-Op on other archtiectures. + // + Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust); + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION; + return Status; + } + } + + // + // Next relocation record + // + Reloc += 1; + } + + // + // Next reloc block + // + RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; + } + + return RETURN_SUCCESS; +} + +/** + Loads a PE/COFF image into memory. + + Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer + specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate + the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function. + The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed. + If ImageContext is NULL, then ASSERT(). + + @param ImageContext Pointer to the image context structure that describes the PE/COFF + image that is being loaded. + + @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by + the ImageAddress and ImageSize fields of ImageContext. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations. + Extended status information is in the ImageError field of ImageContext. + @retval RETURN_INVALID_PARAMETER The image address is invalid. + Extended status information is in the ImageError field of ImageContext. + +**/ +RETURN_STATUS +EFIAPI +GluePeCoffLoaderLoadImage ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +{ + RETURN_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + PE_COFF_LOADER_IMAGE_CONTEXT CheckContext; + EFI_IMAGE_SECTION_HEADER *FirstSection; + EFI_IMAGE_SECTION_HEADER *Section; + UINTN NumberOfSections; + UINTN Index; + CHAR8 *Base; + CHAR8 *End; + CHAR8 *MaxEnd; + EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; + UINTN Size; + UINT32 TempDebugEntryRva; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + ASSERT (ImageContext != NULL); + + // + // Assume success + // + ImageContext->ImageError = IMAGE_ERROR_SUCCESS; + + // + // Copy the provided context info into our local version, get what we + // can from the original image, and then use that to make sure everything + // is legit. + // + CopyMem (&CheckContext, ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT)); + + Status = PeCoffLoaderGetImageInfo (&CheckContext); + if (RETURN_ERROR (Status)) { + return Status; + } + + // + // Make sure there is enough allocated space for the image being loaded + // + if (ImageContext->ImageSize < CheckContext.ImageSize) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE; + return RETURN_BUFFER_TOO_SMALL; + } + if (ImageContext->ImageAddress == 0) { + // + // Image cannot be loaded into 0 address. + // + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return RETURN_INVALID_PARAMETER; + } + // + // If there's no relocations, then make sure it's not a runtime driver, + // and that it's being loaded at the linked address. + // + if (CheckContext.RelocationsStripped) { + // + // If the image does not contain relocations and it is a runtime driver + // then return an error. + // + if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM; + return RETURN_LOAD_ERROR; + } + // + // If the image does not contain relocations, and the requested load address + // is not the linked address, then return an error. + // + if (CheckContext.ImageAddress != ImageContext->ImageAddress) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return RETURN_INVALID_PARAMETER; + } + } + // + // Make sure the allocated space has the proper section alignment + // + if (!(ImageContext->IsTeImage)) { + if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) { + ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT; + return RETURN_INVALID_PARAMETER; + } + } + // + // Read the entire PE/COFF or TE header into memory + // + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &ImageContext->SizeOfHeaders, + (VOID *) (UINTN) ImageContext->ImageAddress + ); + + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); + + FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( + (UINTN)ImageContext->ImageAddress + + ImageContext->PeCoffHeaderOffset + + sizeof(UINT32) + + sizeof(EFI_IMAGE_FILE_HEADER) + + Hdr.Pe32->FileHeader.SizeOfOptionalHeader + ); + NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &ImageContext->SizeOfHeaders, + (void *)(UINTN)ImageContext->ImageAddress + ); + + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + + FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( + (UINTN)ImageContext->ImageAddress + + sizeof(EFI_TE_IMAGE_HEADER) + ); + NumberOfSections = (UINTN) (Hdr.Te->NumberOfSections); + + } + + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return RETURN_LOAD_ERROR; + } + + // + // Load each section of the image + // + Section = FirstSection; + for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) { + + // + // Compute sections address + // + Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress); + End = PeCoffLoaderImageAddress ( + ImageContext, + Section->VirtualAddress + Section->Misc.VirtualSize - 1 + ); + if (ImageContext->IsTeImage) { + Base = (CHAR8 *)((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize); + End = (CHAR8 *)((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize); + } + + if (End > MaxEnd) { + MaxEnd = End; + } + // + // If the base start or end address resolved to 0, then fail. + // + if ((Base == NULL) || (End == NULL)) { + ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED; + return RETURN_LOAD_ERROR; + } + + // + // Read the section + // + Size = (UINTN) Section->Misc.VirtualSize; + if ((Size == 0) || (Size > Section->SizeOfRawData)) { + Size = (UINTN) Section->SizeOfRawData; + } + + if (Section->SizeOfRawData) { + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + Section->PointerToRawData, + &Size, + Base + ); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize, + &Size, + Base + ); + } + + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return Status; + } + } + + // + // If raw size is less then virt size, zero fill the remaining + // + + if (Size < Section->Misc.VirtualSize) { + ZeroMem (Base + Size, Section->Misc.VirtualSize - Size); + } + + // + // Next Section + // + Section += 1; + } + + // + // Get image's entry point + // + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + if (!(ImageContext->IsTeImage)) { + // + // Sizes of AddressOfEntryPoint are different so we need to do this safely + // + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress ( + ImageContext, + (UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint + ); + } else { + // + // Use PE32+ offset + // + ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress ( + ImageContext, + (UINTN)Hdr.Pe32Plus->OptionalHeader.AddressOfEntryPoint + ); + } + } else { + ImageContext->EntryPoint = (PHYSICAL_ADDRESS) ( + (UINTN)ImageContext->ImageAddress + + (UINTN)Hdr.Te->AddressOfEntryPoint + + (UINTN)sizeof(EFI_TE_IMAGE_HEADER) - + (UINTN)Hdr.Te->StrippedSize + ); + } + + // + // Determine the size of the fixup data + // + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + if (!(ImageContext->IsTeImage)) { + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { + ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); + } else { + ImageContext->FixupDataSize = 0; + } + } else { + DirectoryEntry = &Hdr.Te->DataDirectory[0]; + ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); + } + // + // Consumer must allocate a buffer for the relocation fixup log. + // Only used for runtime drivers. + // + ImageContext->FixupData = NULL; + + // + // Load the Codeview info if present + // + if (ImageContext->DebugDirectoryEntryRva != 0) { + if (!(ImageContext->IsTeImage)) { + DebugEntry = PeCoffLoaderImageAddress ( + ImageContext, + ImageContext->DebugDirectoryEntryRva + ); + } else { + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)( + ImageContext->ImageAddress + + ImageContext->DebugDirectoryEntryRva + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + } + + if (DebugEntry != NULL) { + TempDebugEntryRva = DebugEntry->RVA; + if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) { + Section--; + if ((UINTN)Section->SizeOfRawData < Section->Misc.VirtualSize) { + TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize; + } else { + TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData; + } + } + + if (TempDebugEntryRva != 0) { + if (!(ImageContext->IsTeImage)) { + ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva); + } else { + ImageContext->CodeView = (VOID *)( + (UINTN)ImageContext->ImageAddress + + (UINTN)TempDebugEntryRva + + (UINTN)sizeof (EFI_TE_IMAGE_HEADER) - + (UINTN) Hdr.Te->StrippedSize + ); + } + + if (ImageContext->CodeView == NULL) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return RETURN_LOAD_ERROR; + } + + if (DebugEntry->RVA == 0) { + Size = DebugEntry->SizeOfData; + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugEntry->FileOffset, + &Size, + ImageContext->CodeView + ); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize, + &Size, + ImageContext->CodeView + ); + // + // Should we apply fix up to this field according to the size difference between PE and TE? + // Because now we maintain TE header fields unfixed, this field will also remain as they are + // in original PE image. + // + } + + if (RETURN_ERROR (Status)) { + ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ; + return RETURN_LOAD_ERROR; + } + + DebugEntry->RVA = TempDebugEntryRva; + } + + switch (*(UINT32 *) ImageContext->CodeView) { + case CODEVIEW_SIGNATURE_NB10: + ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY); + break; + + case CODEVIEW_SIGNATURE_RSDS: + ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY); + break; + + default: + break; + } + } + } + } + + return Status; +} + + +/** + Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI + runtime. + + PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply + the fixups with a virtual mapping. + + + @param ImageBase Base address of relocated image + @param VirtImageBase Virtual mapping for ImageBase + @param ImageSize Size of the image to relocate + @param RelocationData Location to place results of read + +**/ +VOID +EFIAPI +PeCoffLoaderRelocateImageForRuntime ( + IN PHYSICAL_ADDRESS ImageBase, + IN PHYSICAL_ADDRESS VirtImageBase, + IN UINTN ImageSize, + IN VOID *RelocationData + ) +{ + CHAR8 *OldBase; + CHAR8 *NewBase; + EFI_IMAGE_DOS_HEADER *DosHdr; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + UINT32 NumberOfRvaAndSizes; + EFI_IMAGE_DATA_DIRECTORY *DataDirectory; + EFI_IMAGE_DATA_DIRECTORY *RelocDir; + EFI_IMAGE_BASE_RELOCATION *RelocBase; + EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd; + UINT16 *Reloc; + UINT16 *RelocEnd; + CHAR8 *Fixup; + CHAR8 *FixupBase; + UINT16 *F16; + UINT32 *F32; + UINT64 *F64; + CHAR8 *FixupData; + UINTN Adjust; + RETURN_STATUS Status; + UINT16 Magic; + + OldBase = (CHAR8 *)((UINTN)ImageBase); + NewBase = (CHAR8 *)((UINTN)VirtImageBase); + Adjust = (UINTN) NewBase - (UINTN) OldBase; + + // + // Find the image's relocate dir info + // + DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase; + if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // Valid DOS header so get address of PE header + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(((CHAR8 *)DosHdr) + DosHdr->e_lfanew); + } else { + // + // No Dos header so assume image starts with PE header. + // + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)OldBase; + } + + if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) { + // + // Not a valid PE image so Exit + // + return ; + } + + Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]); + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]); + } + + // + // Find the relocation block + // + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { + RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC; + RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress); + RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress + RelocDir->Size); + } else { + // + // Cannot find relocations, cannot continue + // + ASSERT (FALSE); + return ; + } + + ASSERT (RelocBase != NULL && RelocBaseEnd != NULL); + + // + // Run the whole relocation block. And re-fixup data that has not been + // modified. The FixupData is used to see if the image has been modified + // since it was relocated. This is so data sections that have been updated + // by code will not be fixed up, since that would set them back to + // defaults. + // + FixupData = RelocationData; + while (RelocBase < RelocBaseEnd) { + + Reloc = (UINT16 *) ((UINT8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION)); + RelocEnd = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock); + FixupBase = (CHAR8 *) ((UINTN)ImageBase) + RelocBase->VirtualAddress; + + // + // Run this relocation record + // + while (Reloc < RelocEnd) { + + Fixup = FixupBase + (*Reloc & 0xFFF); + switch ((*Reloc) >> 12) { + + case EFI_IMAGE_REL_BASED_ABSOLUTE: + break; + + case EFI_IMAGE_REL_BASED_HIGH: + F16 = (UINT16 *) Fixup; + if (*(UINT16 *) FixupData == *F16) { + *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16))); + } + + FixupData = FixupData + sizeof (UINT16); + break; + + case EFI_IMAGE_REL_BASED_LOW: + F16 = (UINT16 *) Fixup; + if (*(UINT16 *) FixupData == *F16) { + *F16 = (UINT16) (*F16 + ((UINT16) Adjust & 0xffff)); + } + + FixupData = FixupData + sizeof (UINT16); + break; + + case EFI_IMAGE_REL_BASED_HIGHLOW: + F32 = (UINT32 *) Fixup; + FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); + if (*(UINT32 *) FixupData == *F32) { + *F32 = *F32 + (UINT32) Adjust; + } + + FixupData = FixupData + sizeof (UINT32); + break; + + case EFI_IMAGE_REL_BASED_DIR64: + F64 = (UINT64 *)Fixup; + FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64)); + if (*(UINT64 *) FixupData == *F64) { + *F64 = *F64 + (UINT64)Adjust; + } + + FixupData = FixupData + sizeof (UINT64); + break; + + case EFI_IMAGE_REL_BASED_HIGHADJ: + // + // Not implemented, but not used in EFI 1.0 + // + ASSERT (FALSE); + break; + + default: + // + // Only Itanium requires ConvertPeImage_Ex + // + Status = PeHotRelocateImageEx (Reloc, Fixup, &FixupData, Adjust); + if (RETURN_ERROR (Status)) { + return ; + } + } + // + // Next relocation record + // + Reloc += 1; + } + // + // next reloc block + // + RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; + } +} + + +/** + ImageRead function that operates on a memory buffer whos base is passed into + FileHandle. + + @param FileHandle Ponter to baes of the input stream + @param FileOffset Offset to the start of the buffer + @param ReadSize Number of bytes to copy into the buffer + @param Buffer Location to place results of read + + @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into + the buffer. +**/ +RETURN_STATUS +EFIAPI +PeCoffLoaderImageReadFromMemory ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ) +{ + CopyMem (Buffer, ((UINT8 *)FileHandle) + FileOffset, *ReadSize); + return RETURN_SUCCESS; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf new file mode 100644 index 0000000000..8c9f6bc31b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf @@ -0,0 +1,83 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePeCoffLib.inf +# +# Abstract: +# +# Component description file for BasePeCoffLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePeCoffLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + BasePeCoff.c + +[sources.ia32] + Ia32\PeCoffLoaderEx.c + +[sources.x64] + X64\PeCoffLoaderEx.c + +[sources.ipf] + Ipf\PeCoffLoaderEx.c + +[sources.ebc] + Ebc\PeCoffLoaderEx.c + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] + EdkIIGlueBaseMemoryLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h new file mode 100644 index 0000000000..c72f1821f8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h @@ -0,0 +1,131 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BasePeCoffLibInternals.h + +Abstract: + + Header file for Base PeCoff Library + +--*/ + +#ifndef __BASE_PECOFF_LIB_INTERNALS__ +#define __BASE_PECOFF_LIB_INTERNALS__ + +#include "EdkIIGlueBase.h" + +/** + Performs an Itanium-based specific relocation fixup and is a no-op on other + instruction sets. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ); + + +/** + Performs an Itanium-based specific re-relocation fixup and is a no-op on other + instruction sets. This is used to re-relocated the image into the EFI virtual + space for runtime calls. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ); + + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ); + +/** + Retrieves the magic value from the PE/COFF header. + + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 + @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ + +**/ +UINT16 +PeCoffLoaderGetPeHeaderMagicValue ( + IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ); + +/** + Retrieves the PE or TE Header from a PE/COFF or TE image. + + @param ImageContext The context of the image being loaded. + @param Hdr The buffer in which to return the PE32, PE32+, or TE header. + + @retval RETURN_SUCCESS The PE or TE Header is read. + @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function. + +**/ +RETURN_STATUS +PeCoffLoaderGetPeHeader ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ); + +/** + Converts an image address to the loaded address. + + @param ImageContext The context of the image being loaded. + @param Address The address to be converted to the loaded address. + + @return The converted address or NULL if the address can not be converted. + +**/ +VOID * +PeCoffLoaderImageAddress ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + IN UINTN Address + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ebc/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ebc/PeCoffLoaderEx.c new file mode 100644 index 0000000000..b6df433092 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ebc/PeCoffLoaderEx.c @@ -0,0 +1,98 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeCoffLoaderEx.c + +Abstract: + + EBC Specific relocation fixups. + +--*/ + +#include "BasePeCoffLibInternals.h" + +/** + Performs an EBC specific relocation fixup. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @retval EFI_UNSUPPORTED Unsupported now. + +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +{ + if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || + (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} + + +/** + Performs an Itanium-based specific re-relocation fixup and is a no-op on other + instruction sets. This is used to re-relocated the image into the EFI virtual + space for runtime calls. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c new file mode 100644 index 0000000000..713ad7b66c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c @@ -0,0 +1,98 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeCoffLoaderEx.c + +Abstract: + + IA-32 Specific relocation fixups. + +--*/ + +#include "BasePeCoffLibInternals.h" + +/** + Performs an IA-32 specific relocation fixup. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @retval EFI_UNSUPPORTED Unsupported now. + +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +{ + if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || + (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} + +/** + Performs an Itanium-based specific re-relocation fixup and is a no-op on other + instruction sets. This is used to re-relocated the image into the EFI virtual + space for runtime calls. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c new file mode 100644 index 0000000000..d722175cf0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c @@ -0,0 +1,430 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeCoffLoaderEx.c + +Abstract: + + IA-32 Specific relocation fixups. + +--*/ + +#include "BasePeCoffLibInternals.h" + +#define EFI_IMAGE_MACHINE_IPF EFI_IMAGE_MACHINE_IA64 + +#define EXT_IMM64(Value, Address, Size, InstPos, ValPos) \ + Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos) + +#define INS_IMM64(Value, Address, Size, InstPos, ValPos) \ + *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \ + ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos) + +#define IMM64_IMM7B_INST_WORD_X 3 +#define IMM64_IMM7B_SIZE_X 7 +#define IMM64_IMM7B_INST_WORD_POS_X 4 +#define IMM64_IMM7B_VAL_POS_X 0 + +#define IMM64_IMM9D_INST_WORD_X 3 +#define IMM64_IMM9D_SIZE_X 9 +#define IMM64_IMM9D_INST_WORD_POS_X 18 +#define IMM64_IMM9D_VAL_POS_X 7 + +#define IMM64_IMM5C_INST_WORD_X 3 +#define IMM64_IMM5C_SIZE_X 5 +#define IMM64_IMM5C_INST_WORD_POS_X 13 +#define IMM64_IMM5C_VAL_POS_X 16 + +#define IMM64_IC_INST_WORD_X 3 +#define IMM64_IC_SIZE_X 1 +#define IMM64_IC_INST_WORD_POS_X 12 +#define IMM64_IC_VAL_POS_X 21 + +#define IMM64_IMM41a_INST_WORD_X 1 +#define IMM64_IMM41a_SIZE_X 10 +#define IMM64_IMM41a_INST_WORD_POS_X 14 +#define IMM64_IMM41a_VAL_POS_X 22 + +#define IMM64_IMM41b_INST_WORD_X 1 +#define IMM64_IMM41b_SIZE_X 8 +#define IMM64_IMM41b_INST_WORD_POS_X 24 +#define IMM64_IMM41b_VAL_POS_X 32 + +#define IMM64_IMM41c_INST_WORD_X 2 +#define IMM64_IMM41c_SIZE_X 23 +#define IMM64_IMM41c_INST_WORD_POS_X 0 +#define IMM64_IMM41c_VAL_POS_X 40 + +#define IMM64_SIGN_INST_WORD_X 3 +#define IMM64_SIGN_SIZE_X 1 +#define IMM64_SIGN_INST_WORD_POS_X 27 +#define IMM64_SIGN_VAL_POS_X 63 + +/** + Performs an Itanium-based specific relocation fixup. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + UINT64 *F64; + UINT64 FixupVal; + + switch ((*Reloc) >> 12) { + case EFI_IMAGE_REL_BASED_IA64_IMM64: + + // + // Align it to bundle address before fixing up the + // 64-bit immediate value of the movl instruction. + // + + Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15)); + FixupVal = (UINT64)0; + + // + // Extract the lower 32 bits of IMM64 from bundle + // + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X, + IMM64_IMM7B_SIZE_X, + IMM64_IMM7B_INST_WORD_POS_X, + IMM64_IMM7B_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X, + IMM64_IMM9D_SIZE_X, + IMM64_IMM9D_INST_WORD_POS_X, + IMM64_IMM9D_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X, + IMM64_IMM5C_SIZE_X, + IMM64_IMM5C_INST_WORD_POS_X, + IMM64_IMM5C_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IC_INST_WORD_X, + IMM64_IC_SIZE_X, + IMM64_IC_INST_WORD_POS_X, + IMM64_IC_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X, + IMM64_IMM41a_SIZE_X, + IMM64_IMM41a_INST_WORD_POS_X, + IMM64_IMM41a_VAL_POS_X + ); + + // + // Update 64-bit address + // + FixupVal += Adjust; + + // + // Insert IMM64 into bundle + // + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X), + IMM64_IMM7B_SIZE_X, + IMM64_IMM7B_INST_WORD_POS_X, + IMM64_IMM7B_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X), + IMM64_IMM9D_SIZE_X, + IMM64_IMM9D_INST_WORD_POS_X, + IMM64_IMM9D_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X), + IMM64_IMM5C_SIZE_X, + IMM64_IMM5C_INST_WORD_POS_X, + IMM64_IMM5C_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X), + IMM64_IC_SIZE_X, + IMM64_IC_INST_WORD_POS_X, + IMM64_IC_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X), + IMM64_IMM41a_SIZE_X, + IMM64_IMM41a_INST_WORD_POS_X, + IMM64_IMM41a_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X), + IMM64_IMM41b_SIZE_X, + IMM64_IMM41b_INST_WORD_POS_X, + IMM64_IMM41b_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X), + IMM64_IMM41c_SIZE_X, + IMM64_IMM41c_INST_WORD_POS_X, + IMM64_IMM41c_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X), + IMM64_SIGN_SIZE_X, + IMM64_SIGN_INST_WORD_POS_X, + IMM64_SIGN_VAL_POS_X + ); + + F64 = (UINT64 *) Fixup; + if (*FixupData != NULL) { + *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64)); + *(UINT64 *)(*FixupData) = *F64; + *FixupData = *FixupData + sizeof(UINT64); + } + break; + + default: + return RETURN_UNSUPPORTED; + } + + return RETURN_SUCCESS; +} + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. This version also supports the special relocations + for Itanium. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +{ + if ((Machine == EFI_IMAGE_MACHINE_IPF) || (Machine == EFI_IMAGE_MACHINE_IA32) || + (Machine == EFI_IMAGE_MACHINE_EBC) || (Machine == EFI_IMAGE_MACHINE_X64)) { + return TRUE; + } + + return FALSE; +} + + +/** + ImageRead function that operates on a memory buffer whos base is passed into + FileHandle. + + @param Reloc Ponter to baes of the input stream + @param Fixup Offset to the start of the buffer + @param FixupData Number of bytes to copy into the buffer + @param Adjust Location to place results of read + + @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into + the buffer. +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + UINT64 *F64; + UINT64 FixupVal; + + switch ((*Reloc) >> 12) { + case EFI_IMAGE_REL_BASED_DIR64: + F64 = (UINT64 *) Fixup; + *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64)); + if (*(UINT64 *) (*FixupData) == *F64) { + *F64 = *F64 + (UINT64) Adjust; + } + + *FixupData = *FixupData + sizeof (UINT64); + break; + + case EFI_IMAGE_REL_BASED_IA64_IMM64: + F64 = (UINT64 *) Fixup; + *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64)); + if (*(UINT64 *) (*FixupData) == *F64) { + // + // Align it to bundle address before fixing up the + // 64-bit immediate value of the movl instruction. + // + // + Fixup = (CHAR8 *) ((UINT64) Fixup & (UINT64)~(15)); + FixupVal = (UINT64) 0; + + // + // Extract the lower 32 bits of IMM64 from bundle + // + EXT_IMM64 ( + FixupVal, + (UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X, + IMM64_IMM7B_SIZE_X, + IMM64_IMM7B_INST_WORD_POS_X, + IMM64_IMM7B_VAL_POS_X + ); + + EXT_IMM64 ( + FixupVal, + (UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X, + IMM64_IMM9D_SIZE_X, + IMM64_IMM9D_INST_WORD_POS_X, + IMM64_IMM9D_VAL_POS_X + ); + + EXT_IMM64 ( + FixupVal, + (UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X, + IMM64_IMM5C_SIZE_X, + IMM64_IMM5C_INST_WORD_POS_X, + IMM64_IMM5C_VAL_POS_X + ); + + EXT_IMM64 ( + FixupVal, + (UINT32 *) Fixup + IMM64_IC_INST_WORD_X, + IMM64_IC_SIZE_X, + IMM64_IC_INST_WORD_POS_X, + IMM64_IC_VAL_POS_X + ); + + EXT_IMM64 ( + FixupVal, + (UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X, + IMM64_IMM41a_SIZE_X, + IMM64_IMM41a_INST_WORD_POS_X, + IMM64_IMM41a_VAL_POS_X + ); + + // + // Update 64-bit address + // + FixupVal += Adjust; + + // + // Insert IMM64 into bundle + // + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X), + IMM64_IMM7B_SIZE_X, + IMM64_IMM7B_INST_WORD_POS_X, + IMM64_IMM7B_VAL_POS_X + ); + + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X), + IMM64_IMM9D_SIZE_X, + IMM64_IMM9D_INST_WORD_POS_X, + IMM64_IMM9D_VAL_POS_X + ); + + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X), + IMM64_IMM5C_SIZE_X, + IMM64_IMM5C_INST_WORD_POS_X, + IMM64_IMM5C_VAL_POS_X + ); + + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_IC_INST_WORD_X), + IMM64_IC_SIZE_X, + IMM64_IC_INST_WORD_POS_X, + IMM64_IC_VAL_POS_X + ); + + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X), + IMM64_IMM41a_SIZE_X, + IMM64_IMM41a_INST_WORD_POS_X, + IMM64_IMM41a_VAL_POS_X + ); + + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_IMM41b_INST_WORD_X), + IMM64_IMM41b_SIZE_X, + IMM64_IMM41b_INST_WORD_POS_X, + IMM64_IMM41b_VAL_POS_X + ); + + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_IMM41c_INST_WORD_X), + IMM64_IMM41c_SIZE_X, + IMM64_IMM41c_INST_WORD_POS_X, + IMM64_IMM41c_VAL_POS_X + ); + + INS_IMM64 ( + FixupVal, + ((UINT32 *) Fixup + IMM64_SIGN_INST_WORD_X), + IMM64_SIGN_SIZE_X, + IMM64_SIGN_INST_WORD_POS_X, + IMM64_SIGN_VAL_POS_X + ); + + *(UINT64 *) (*FixupData) = *F64; + } + + *FixupData = *FixupData + sizeof (UINT64); + break; + + default: + DEBUG ((EFI_D_ERROR, "PeHotRelocateEx:unknown fixed type\n")); + return RETURN_UNSUPPORTED; + } + + return RETURN_SUCCESS; +} + + + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/x64/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/x64/PeCoffLoaderEx.c new file mode 100644 index 0000000000..6d1fb39013 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/x64/PeCoffLoaderEx.c @@ -0,0 +1,99 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeCoffLoaderEx.c + +Abstract: + + x64 Specific relocation fixups. + +--*/ + +#include "BasePeCoffLibInternals.h" + + +/** + Performs an x64 specific relocation fixup. + + @param Reloc Pointer to the relocation record + @param Fixup Pointer to the address to fix up + @param FixupData Pointer to a buffer to log the fixups + @param Adjust The offset to adjust the fixup + + @retval RETURN_SUCCESS Success to perform relocation + @retval RETURN_UNSUPPORTED Unsupported. +**/ +RETURN_STATUS +GluePeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + + @param Machine Machine type from the PE Header. + + @return TRUE if this PE/COFF loader can load the image + +**/ +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +{ + if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || + (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} + + +/** + Performs an X64 specific re-relocation fixup and is a no-op on other + instruction sets. This is used to re-relocated the image into the EFI virtual + space for runtime calls. + + @param Reloc Pointer to the relocation record. + @param Fixup Pointer to the address to fix up. + @param FixupData Pointer to a buffer to log the fixups. + @param Adjust The offset to adjust the fixup. + + @return Status code. + +**/ +RETURN_STATUS +GluePeHotRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +{ + return RETURN_UNSUPPORTED; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf new file mode 100644 index 0000000000..4911096127 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePostCodeLibDebug.inf +# +# Abstract: +# +# Component description file for BasePostCodeLibDebug +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePostCodeLibDebug +COMPONENT_TYPE = LIBRARY + +[sources.common] + PostCode.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] +# A DebugLib instance + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c new file mode 100644 index 0000000000..d16b592cfa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c @@ -0,0 +1,131 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PostCode.c + +Abstract: + + Post Code functions + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ) +{ + DEBUG((EFI_D_INFO, "POST %08x\n", Value)); + return Value; +} + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ) +{ + DEBUG((EFI_D_INFO, "POST %08x - %s\n", Value, Description)); + return Value; +} + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf new file mode 100644 index 0000000000..f7376ca098 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf @@ -0,0 +1,84 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePostCodeLibPort80.inf +# +# Abstract: +# +# Component description file for BasePostCodeLibPort80 +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePostCodeLibPort80 +COMPONENT_TYPE = LIBRARY + +[sources.common] + PostCode.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] + +[libraries.ia32] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.x64] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ebc] + EdkIIGlueDxeIoLibCpuIo + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c new file mode 100644 index 0000000000..ff140115d4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c @@ -0,0 +1,131 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PostCode.c + +Abstract: + + Post Code functions + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ) +{ + IoWrite8 (0x80, (UINT8)(Value)); + return Value; +} + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ) +{ + IoWrite8 (0x80, (UINT8)(Value)); + return Value; +} + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the + POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf new file mode 100644 index 0000000000..4e1030920d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf @@ -0,0 +1,82 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BasePrintLib.inf +# +# Abstract: +# +# Component description file for BasePrintLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBasePrintLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PrintLib.c + PrintLibInternal.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader + + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c new file mode 100644 index 0000000000..e90b73f235 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c @@ -0,0 +1,1086 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PrintLib.c + +Abstract: + + Print Library. + +--*/ + +#include "PrintLibInternal.h" + +#define WARNING_STATUS_NUMBER 4 +#define ERROR_STATUS_NUMBER 24 +#define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0) + +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *StatusString [] = { + "Success", // RETURN_SUCCESS = 0 + "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1 + "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2 + "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3 + "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4 + "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT + "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT + "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT + "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT + "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT + "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT + "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT + "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT + "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT + "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT + "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT + "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT + "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT + "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT + "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT + "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT + "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT + "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT + "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT + "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT + "Aborted", // RETURN_ABORTED = 21 | MAX_BIT + "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT + "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT + "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT +}; + +/** + Worker function that produces a Null-terminated string in an output buffer + based on a Null-terminated format string and a VA_LIST argument list. + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine. + + @param Buffer Character buffer to print the results of the parsing + of Format into. + @param BufferSize Maximum number of characters to put into buffer. + @param Flags Intial flags value. + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set. + @param Format Null-terminated format string. + @param Marker Vararg list consumed by processing Format. + + @return Number of characters printed not including the Null-terminator. + +**/ +UINTN +BasePrintLibVSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN CONST CHAR8 *Format, + IN VA_LIST Marker + ) +{ + CHAR8 *OriginalBuffer; + CHAR8 *EndBuffer; + CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS]; + UINTN BytesPerOutputCharacter; + UINTN BytesPerFormatCharacter; + UINTN FormatMask; + UINTN FormatCharacter; + UINTN Width; + UINTN Precision; + INT64 Value; + CONST CHAR8 *ArgumentString; + UINTN Character; + GUID *TmpGuid; + TIME *TmpTime; + UINTN Count; + UINTN ArgumentMask; + INTN BytesPerArgumentCharacter; + UINTN ArgumentCharacter; + BOOLEAN Done; + UINTN Index; + CHAR8 Prefix; + BOOLEAN ZeroPad; + BOOLEAN Comma; + UINTN Digits; + UINTN Radix; + RETURN_STATUS Status; + + if (BufferSize == 0) { + return 0; + } + ASSERT (Buffer != NULL); + + if ((Flags & OUTPUT_UNICODE) != 0) { + BytesPerOutputCharacter = 2; + } else { + BytesPerOutputCharacter = 1; + } + + // + // Reserve space for the Null terminator. + // + BufferSize--; + OriginalBuffer = Buffer; + // + // Set the tag for the end of the input Buffer. + // + EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter; + + if ((Flags & FORMAT_UNICODE) != 0) { + // + // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength + // Unicode characters if PcdMaximumUnicodeStringLength is not zero. + // + ASSERT (StrSize ((CHAR16 *) Format) != 0); + BytesPerFormatCharacter = 2; + FormatMask = 0xffff; + } else { + // + // Make sure format string cannot contain more than PcdMaximumAsciiStringLength + // Ascii characters if PcdMaximumAsciiStringLength is not zero. + // + ASSERT (AsciiStrSize (Format) != 0); + BytesPerFormatCharacter = 1; + FormatMask = 0xff; + } + + + + // + // Get the first character from the format string + // + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + + // + // Loop until the end of the format string is reached or the output buffer is full + // + while (FormatCharacter != 0 && Buffer < EndBuffer) { + // + // Clear all the flag bits except those that may have been passed in + // + Flags &= (OUTPUT_UNICODE | FORMAT_UNICODE); + + // + // Set the default width to zero, and the default precision to 1 + // + Width = 0; + Precision = 1; + Prefix = 0; + Comma = FALSE; + ZeroPad = FALSE; + Count = 0; + Digits = 0; + + switch (FormatCharacter) { + case '%': + // + // Parse Flags and Width + // + for (Done = FALSE; !Done; ) { + Format += BytesPerFormatCharacter; + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + switch (FormatCharacter) { + case '.': + Flags |= PRECISION; + break; + case '-': + Flags |= LEFT_JUSTIFY; + break; + case '+': + Flags |= PREFIX_SIGN; + break; + case ' ': + Flags |= PREFIX_BLANK; + break; + case ',': + Flags |= COMMA_TYPE; + break; + case 'L': + case 'l': + Flags |= LONG_TYPE; + break; + case '*': + if ((Flags & PRECISION) == 0) { + Flags |= PAD_TO_WIDTH; + Width = VA_ARG (Marker, UINTN); + } else { + Precision = VA_ARG (Marker, UINTN); + } + break; + case '0': + if ((Flags & PRECISION) == 0) { + Flags |= PREFIX_ZERO; + } + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + for (Count = 0; ((FormatCharacter >= '0') && (FormatCharacter <= '9')); ){ + Count = (Count * 10) + FormatCharacter - '0'; + Format += BytesPerFormatCharacter; + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + } + Format -= BytesPerFormatCharacter; + if ((Flags & PRECISION) == 0) { + Flags |= PAD_TO_WIDTH; + Width = Count; + } else { + Precision = Count; + } + break; + + case '\0': + // + // Make no output if Format string terminates unexpectedly when + // looking up for flag, width, precision and type. + // + Format -= BytesPerFormatCharacter; + Precision = 0; + // + // break skipped on purpose. + // + default: + Done = TRUE; + break; + } + } + + // + // Handle each argument type + // + switch (FormatCharacter) { + case 'p': + // + // Flag space, +, 0, L & l are invalid for type p. + // + Flags &= ~(PREFIX_BLANK | PREFIX_SIGN | PREFIX_ZERO | LONG_TYPE); + if (sizeof (VOID *) > 4) { + Flags |= LONG_TYPE; + } + case 'X': + Flags |= PREFIX_ZERO; + // + // break skipped on purpose + // + case 'x': + Flags |= RADIX_HEX; + // + // break skipped on purpose + // + case 'd': + if ((Flags & LONG_TYPE) == 0) { + Value = (VA_ARG (Marker, int)); + } else { + Value = VA_ARG (Marker, INT64); + } + if ((Flags & PREFIX_BLANK) != 0) { + Prefix = ' '; + } + if ((Flags & PREFIX_SIGN) != 0) { + Prefix = '+'; + } + if ((Flags & COMMA_TYPE) != 0) { + Comma = TRUE; + } + if ((Flags & RADIX_HEX) == 0) { + Radix = 10; + if (Comma) { + Flags &= (~PREFIX_ZERO); + Precision = 1; + } + if (Value < 0) { + Flags |= PREFIX_SIGN; + Prefix = '-'; + Value = -Value; + } + } else { + Radix = 16; + Comma = FALSE; + if ((Flags & LONG_TYPE) == 0 && Value < 0) { + Value = (unsigned int)Value; + } + } + // + // Convert Value to a reversed string + // + Count = BasePrintLibValueToString (ValueBuffer, Value, Radix); + if (Value == 0 && Precision == 0) { + Count = 0; + } + ArgumentString = (CHAR8 *)ValueBuffer + Count; + + Digits = Count % 3; + if (Digits != 0) { + Digits = 3 - Digits; + } + if (Comma && Count != 0) { + Count += ((Count - 1) / 3); + } + if (Prefix != 0) { + Count++; + Precision++; + } + Flags |= ARGUMENT_REVERSED; + ZeroPad = TRUE; + if ((Flags & PREFIX_ZERO) != 0) { + if ((Flags & LEFT_JUSTIFY) == 0) { + if ((Flags & PAD_TO_WIDTH) != 0) { + if ((Flags & PRECISION) == 0) { + Precision = Width; + } + } + } + } + break; + + case 's': + case 'S': + Flags |= ARGUMENT_UNICODE; + // + // break skipped on purpose + // + case 'a': + ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *); + if (ArgumentString == NULL) { + Flags &= (~ARGUMENT_UNICODE); + ArgumentString = ""; + } + break; + + case 'c': + Character = VA_ARG (Marker, UINTN) & 0xffff; + ArgumentString = (CHAR8 *)&Character; + Flags |= ARGUMENT_UNICODE; + break; + + case 'g': + TmpGuid = VA_ARG (Marker, GUID *); + if (TmpGuid == NULL) { + ArgumentString = ""; + } else { + BasePrintLibSPrint ( + ValueBuffer, + MAXIMUM_VALUE_CHARACTERS, + 0, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + TmpGuid->Data1, + TmpGuid->Data2, + TmpGuid->Data3, + TmpGuid->Data4[0], + TmpGuid->Data4[1], + TmpGuid->Data4[2], + TmpGuid->Data4[3], + TmpGuid->Data4[4], + TmpGuid->Data4[5], + TmpGuid->Data4[6], + TmpGuid->Data4[7] + ); + ArgumentString = ValueBuffer; + } + break; + + case 't': + TmpTime = VA_ARG (Marker, TIME *); + if (TmpTime == NULL) { + ArgumentString = ""; + } else { + BasePrintLibSPrint ( + ValueBuffer, + MAXIMUM_VALUE_CHARACTERS, + 0, + "%02d/%02d/%04d %02d:%02d", + TmpTime->Month, + TmpTime->Day, + TmpTime->Year, + TmpTime->Hour, + TmpTime->Minute + ); + ArgumentString = ValueBuffer; + } + break; + + case 'r': + Status = VA_ARG (Marker, RETURN_STATUS); + ArgumentString = ValueBuffer; + if (RETURN_ERROR (Status)) { + // + // Clear error bit + // + Index = Status & ~MAX_BIT; + if (Index > 0 && Index <= ERROR_STATUS_NUMBER) { + ArgumentString = StatusString [Index + WARNING_STATUS_NUMBER]; + } + } else { + Index = Status; + if (Index <= WARNING_STATUS_NUMBER) { + ArgumentString = StatusString [Index]; + } + } + if (ArgumentString == ValueBuffer) { + BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status); + } + break; + + case '\n': + ArgumentString = "\n\r"; + break; + + case '%': + default: + // + // if the type is '%' or unknown, then print it to the screen + // + ArgumentString = (CHAR8 *)&FormatCharacter; + Flags |= ARGUMENT_UNICODE; + break; + } + break; + + case '\n': + ArgumentString = "\n\r"; + break; + + default: + ArgumentString = (CHAR8 *)&FormatCharacter; + Flags |= ARGUMENT_UNICODE; + break; + } + + // + // Retrieve the ArgumentString attriubutes + // + if ((Flags & ARGUMENT_UNICODE) != 0) { + ArgumentMask = 0xffff; + BytesPerArgumentCharacter = 2; + } else { + ArgumentMask = 0xff; + BytesPerArgumentCharacter = 1; + } + if ((Flags & ARGUMENT_REVERSED) != 0) { + BytesPerArgumentCharacter = -BytesPerArgumentCharacter; + } else { + // + // Compute the number of characters in ArgumentString and store it in Count + // ArgumentString is either null-terminated, or it contains Precision characters + // + for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) { + ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask; + if (ArgumentCharacter == 0) { + break; + } + } + } + + if (Precision < Count) { + Precision = Count; + } + + // + // Pad before the string + // + if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter); + } + + if (ZeroPad) { + if (Prefix != 0) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter); + } + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter); + } else { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter); + if (Prefix != 0) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter); + } + } + + // + // Output the Prefix character if it is present + // + Index = 0; + if (Prefix != 0) { + Index++; + } + + // + // Copy the string into the output buffer performing the required type conversions + // + while (Index < Count) { + ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask; + + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter); + ArgumentString += BytesPerArgumentCharacter; + Index++; + if (Comma) { + Digits++; + if (Digits == 3) { + Digits = 0; + Index++; + if (Index < Count) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter); + } + } + } + } + + // + // Pad after the string + // + if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter); + } + + // + // Get the next character from the format string + // + Format += BytesPerFormatCharacter; + + // + // Get the next character from the format string + // + FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask; + } + + // + // Null terminate the Unicode or ASCII string + // + BasePrintLibFillBuffer (Buffer, EndBuffer + BytesPerOutputCharacter, 1, 0, BytesPerOutputCharacter); + // + // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength + // Unicode characters if PcdMaximumUnicodeStringLength is not zero. + // + ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0)); + // + // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength + // ASCII characters if PcdMaximumAsciiStringLength is not zero. + // + ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0)); + + return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter); +} + +/** + Worker function that produces a Null-terminated string in an output buffer + based on a Null-terminated format string and variable argument list. + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine. + + @param Buffer Character buffer to print the results of the parsing + of Format into. + @param BufferSize Maximum number of characters to put into buffer. + Zero means no limit. + @param Flags Intial flags value. + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set + @param FormatString Null-terminated format string. + + @return Number of characters printed not including the Null-terminator. + +**/ +UINTN +BasePrintLibSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN CONST CHAR8 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on + a Null-terminated Unicode format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +{ + ASSERT_UNICODE_BUFFER(StartOfBuffer); + ASSERT_UNICODE_BUFFER(FormatString); + return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + Unicode format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on the + contents of the format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeVSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +{ + ASSERT_UNICODE_BUFFER(StartOfBuffer); + return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker); +} + +/** + Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer + and BufferSize. + The Unicode string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeSPrintAsciiFormat ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker); +} + +/** + Converts a decimal value to a Null-terminated Unicode string. + + Converts the decimal number specified by Value to a Null-terminated Unicode + string specified by Buffer containing at most Width characters. No padding of spaces + is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of Unicode characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be + formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + Unicode string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Unicode characters to place in Buffer, not including + the Null-terminator. + + @return The number of Unicode characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +UnicodeValueToString ( + IN OUT CHAR16 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ) +{ + ASSERT_UNICODE_BUFFER(Buffer); + return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +{ + return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and a VA_LIST argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list specified by Marker based on + the contents of the format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + @param Marker VA_LIST marker for the variable argument list. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiVSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +{ + ASSERT_UNICODE_BUFFER (FormatString); + return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker); +} + +/** + Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated + ASCII format string and variable argument list. + + Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer + and BufferSize. + The ASCII string is produced by parsing the format string specified by FormatString. + Arguments are pulled from the variable argument list based on the contents of the + format string. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0, then no output buffer is produced and 0 is returned. + + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). + + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated + ASCII string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param FormatString Null-terminated Unicode format string. + + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. + +**/ +UINTN +EFIAPI +AsciiSPrintUnicodeFormat ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, FormatString); + return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker); +} + + +/** + Converts a decimal value to a Null-terminated ASCII string. + + Converts the decimal number specified by Value to a Null-terminated ASCII string + specified by Buffer containing at most Width characters. No padding of spaces + is ever performed. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of ASCII characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first Width + characters are returned, and the total number of characters required to perform + the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be + formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + ASCII string. + @param Flags The bitmask of flags that specify left justification, zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of ASCII characters to place in Buffer, not including + the Null-terminator. + + @return The number of ASCII characters in Buffer not including the Null-terminator. + +**/ +UINTN +EFIAPI +AsciiValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ) +{ + return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1); +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c new file mode 100644 index 0000000000..2319469f15 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c @@ -0,0 +1,215 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PrintLibInternal.c + +Abstract: + + Print Library worker functions. + +--*/ + +#include "PrintLibInternal.h" + +GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + + +/** + Internal function that places the character into the Buffer. + + Internal function that places ASCII or Unicode character into the Buffer. + + @param Buffer Buffer to place the Unicode or ASCII string. + @param EndBuffer The end of the input Buffer. No characters will be + placed after that. + @param Length Count of character to be placed into Buffer. + @param Character Character to be placed into Buffer. + @param Increment Character increment in Buffer. + + @return Number of characters printed. + +**/ +CHAR8 * +BasePrintLibFillBuffer ( + CHAR8 *Buffer, + CHAR8 *EndBuffer, + INTN Length, + UINTN Character, + INTN Increment + ) +{ + INTN Index; + + for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { + *Buffer = (CHAR8) Character; + *(Buffer + 1) = (CHAR8) (Character >> 8); + Buffer += Increment; + } + return Buffer; +} + +/** + Internal function that convert a decimal number to a string in Buffer. + + Print worker function that convert a decimal number to a string in Buffer. + + @param Buffer Location to place the Unicode or ASCII string of Value. + @param Value Value to convert to a Decimal or Hexidecimal string in Buffer. + @param Radix Radix of the value + + @return Number of characters printed. + +**/ +UINTN +EFIAPI +BasePrintLibValueToString ( + IN OUT CHAR8 *Buffer, + IN INT64 Value, + IN UINTN Radix + ) +{ + UINTN Digits; + UINT32 Remainder; + + // + // Loop to convert one digit at a time in reverse order + // + *(Buffer++) = 0; + Digits = 0; + do { + Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder); + *(Buffer++) = mHexStr[Remainder]; + Digits++; + } while (Value != 0); + return Digits; +} + +/** + Internal function that converts a decimal value to a Null-terminated string. + + Converts the decimal number specified by Value to a Null-terminated + string specified by Buffer containing at most Width characters. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The number of characters in Buffer is returned not including the Null-terminator. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If HEX_RADIX is set in Flags, then the output buffer will be formatted in hexadecimal format. + If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + string. + @param Flags The bitmask of flags that specify left justification, zero pad, + and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of characters to place in Buffer, not including + the Null-terminator. + @param Increment Character increment in Buffer. + + @return The number of characters in Buffer not including the Null-terminator. + +**/ +UINTN +BasePrintLibConvertValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width, + IN UINTN Increment + ) +{ + CHAR8 *OriginalBuffer; + CHAR8 *EndBuffer; + CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS]; + UINTN Count; + UINTN Digits; + UINTN Index; + UINTN Radix; + + ASSERT (Buffer != NULL); + ASSERT (Width < MAXIMUM_VALUE_CHARACTERS); + // + // Make sure Flags can only contain supported bits. + // + ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO | RADIX_HEX)) == 0); + + // + // If both COMMA_TYPE and HEX_RADIX are set, then ASSERT () + // + ASSERT (((Flags & COMMA_TYPE) != 0 && (Flags & RADIX_HEX) != 0) == FALSE); + + OriginalBuffer = Buffer; + + if (Width == 0 || (Flags & COMMA_TYPE) != 0) { + Flags &= (~PREFIX_ZERO); + } + + if (Width == 0) { + Width = MAXIMUM_VALUE_CHARACTERS - 1; + } + // + // Set the tag for the end of the input Buffer. + // + EndBuffer = Buffer + Width * Increment; + + if ((Value < 0) && ((Flags & RADIX_HEX) == 0)) { + Value = -Value; + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, '-', Increment); + Width--; + } + + Radix = ((Flags & RADIX_HEX) == 0)? 10 : 16; + Count = BasePrintLibValueToString (ValueBuffer, Value, Radix); + + if ((Flags & PREFIX_ZERO) != 0) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Count, '0', Increment); + } + + Digits = Count % 3; + if (Digits != 0) { + Digits = 3 - Digits; + } + for (Index = 0; Index < Count; Index++) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ValueBuffer[Count - Index], Increment); + if ((Flags & COMMA_TYPE) != 0) { + Digits++; + if (Digits == 3) { + Digits = 0; + if ((Index + 1) < Count) { + Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', Increment); + } + } + } + } + + BasePrintLibFillBuffer (Buffer, EndBuffer + Increment, 1, 0, Increment); + + return ((Buffer - OriginalBuffer) / Increment); +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h new file mode 100644 index 0000000000..84424161be --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h @@ -0,0 +1,209 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PrintLibInternal.h + +Abstract: + + Print Library. + +--*/ + +#ifndef __PRINT_LIB_INTERNAL_H__ +#define __PRINT_LIB_INTERNAL_H__ + +#include "EdkIIGlueBase.h" + +// +// Print primitives +// +//#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +//#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +//#define PREFIX_ZERO 0x20 +#define OUTPUT_UNICODE 0x40 +//#define RADIX_HEX 0x80 +#define FORMAT_UNICODE 0x100 +#define PAD_TO_WIDTH 0x200 +#define ARGUMENT_UNICODE 0x400 +#define PRECISION 0x800 +#define ARGUMENT_REVERSED 0x1000 + +// +// Record date and time information +// +typedef struct { + UINT16 Year; + UINT8 Month; + UINT8 Day; + UINT8 Hour; + UINT8 Minute; + UINT8 Second; + UINT8 Pad1; + UINT32 Nanosecond; + INT16 TimeZone; + UINT8 Daylight; + UINT8 Pad2; +} TIME; + +/** + Worker function that produces a Null-terminated string in an output buffer + based on a Null-terminated format string and a VA_LIST argument list. + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine. + + @param Buffer Character buffer to print the results of the parsing + of Format into. + @param BufferSize Maximum number of characters to put into buffer. + @param Flags Intial flags value. + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set. + @param Format Null-terminated format string. + @param Marker Vararg list consumed by processing Format. + + @return Number of characters printed not including the Null-terminator. + +**/ +UINTN +BasePrintLibVSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN CONST CHAR8 *Format, + IN VA_LIST Marker + ); + +/** + Worker function that produces a Null-terminated string in an output buffer + based on a Null-terminated format string and variable argument list. + + VSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + + @param Buffer Character buffer to print the results of the parsing + of Format into. + @param BufferSize Maximum number of characters to put into buffer. + Zero means no limit. + @param Flags Intial flags value. + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set + @param FormatString Null-terminated format string. + + @return Number of characters printed. + +**/ +UINTN +BasePrintLibSPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN CONST CHAR8 *FormatString, + ... + ); + +/** + Internal function that places the character into the Buffer. + + Internal function that places ASCII or Unicode character into the Buffer. + + @param Buffer Buffer to place the Unicode or ASCII string. + @param EndBuffer The end of the input Buffer. No characters will be + placed after that. + @param Length Count of character to be placed into Buffer. + @param Character Character to be placed into Buffer. + @param Increment Character increment in Buffer. + + @return Number of characters printed. + +**/ +CHAR8 * +BasePrintLibFillBuffer ( + CHAR8 *Buffer, + CHAR8 *EndBuffer, + INTN Length, + UINTN Character, + INTN Increment + ); + +/** + Internal function that convert a decimal number to a string in Buffer. + + Print worker function that convert a decimal number to a string in Buffer. + + @param Buffer Location to place the Unicode or ASCII string of Value. + @param Value Value to convert to a Decimal or Hexidecimal string in Buffer. + @param Radix Radix of the value + + @return Number of characters printed. + +**/ +UINTN +EFIAPI +BasePrintLibValueToString ( + IN OUT CHAR8 *Buffer, + IN INT64 Value, + IN UINTN Radix + ); + +/** + Internal function that converts a decimal value to a Null-terminated string. + + Converts the decimal number specified by Value to a Null-terminated + string specified by Buffer containing at most Width characters. + If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + The total number of characters placed in Buffer is returned. + If the conversion contains more than Width characters, then only the first + Width characters are returned, and the total number of characters + required to perform the conversion is returned. + Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas + are inserted every 3rd digit starting from the right. + If Value is < 0, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the optional '-' + sign character, '0' characters, digit characters for Value, and the Null-terminator + add up to Width characters. + + If Buffer is NULL, then ASSERT(). + If unsupported bits are set in Flags, then ASSERT(). + If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() + + @param Buffer Pointer to the output buffer for the produced Null-terminated + string. + @param Flags The bitmask of flags that specify left justification, zero pad, + and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of characters to place in Buffer, not including + the Null-terminator. + @param Increment Character increment in Buffer. + + @return Total number of characters required to perform the conversion. + +**/ +UINTN +BasePrintLibConvertValueToString ( + IN OUT CHAR8 *Buffer, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width, + IN UINTN Increment + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf new file mode 100644 index 0000000000..d84842b2bb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf @@ -0,0 +1,84 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BaseTimerLibLocalApic.inf +# +# Abstract: +# +# Component description file for BaseTimerLibLocalApic. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseTimerLibLocalApic +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + x86TimerLib.c + +[sources.x64] + x86TimerLib.c + +[sources.ipf] + Ipf/IpfTimerLib.c + +[sources.ebc] + Ebc/EbcTimerLib.c + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.x64] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ebc] + EdkIIGlueDxeIoLibCpuIo + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c new file mode 100644 index 0000000000..2257f11767 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ebc/EbcTimerLib.c @@ -0,0 +1,135 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EbcTimerLib.c + +Abstract: + + Timer Library functions built upon local APIC on IA32/x64. + + @bug Should use PCD to retrieve all the constants including index of + the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount + and DivideConfiguration. + +--*/ + +#include "EdkIIGlueBase.h" + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return MicroSeconds + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ) +{ + // + // EBC architecture does not support local APIC timer. + // + ASSERT (FALSE); + return MicroSeconds; +} + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return NanoSeconds + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ) +{ + // + // EBC architecture does not support local APIC timer. + // + ASSERT (FALSE); + return NanoSeconds; +} + +/** + Retrieves the current value of a 64-bit free running performance counter. + + Retrieves the current value of a 64-bit free running performance counter. The + counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ) +{ + // + // EBC architecture does not support local APIC timer. + // + ASSERT (FALSE); + return 0; +} + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + OUT UINT64 *StartValue, OPTIONAL + OUT UINT64 *EndValue OPTIONAL + ) +{ + // + // EBC architecture does not support local APIC timer. + // + ASSERT (FALSE); + return 0; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ipf/IpfTimerLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ipf/IpfTimerLib.c new file mode 100644 index 0000000000..524d973c16 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/Ipf/IpfTimerLib.c @@ -0,0 +1,178 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IpfTimerLib.c + +Abstract: + + Timer Library functions built upon local APIC on IA32/x64. + + @bug Should use PCD to retrieve all the constants including index of + the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount + and DivideConfiguration. + +--*/ + +#include "EdkIIGlueBase.h" + + +/** + Performs a delay measured as number of ticks. + + An internal function to perform a delay measured as number of ticks. It's + invoked by MicroSecondDelay() and NanoSecondDelay(). + + @param Delay Number of ticks to delay. + +**/ +STATIC +VOID +InternalIpfDelay ( + IN INT64 Delay + ) +{ + INT64 Ticks; + + // + // The target timer count is calculated here + // + Ticks = IpfReadItc () + Delay; + + // + // Wait until time out + // Delay > 2^63 could not be handled by this function + // Timer wrap-arounds are handled correctly by this function + // + while (Ticks - IpfReadItc () >= 0); +} + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return MicroSeconds + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ) +{ + InternalIpfDelay ( + GetPerformanceCounterProperties (NULL, NULL) * + MicroSeconds / + 1000000 + ); + return MicroSeconds; +} + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return NanoSeconds + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ) +{ + InternalIpfDelay ( + GetPerformanceCounterProperties (NULL, NULL) * + NanoSeconds / + 1000000000 + ); + return NanoSeconds; +} + +/** + Retrieves the current value of a 64-bit free running performance counter. + + Retrieves the current value of a 64-bit free running performance counter. The + counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ) +{ + return IpfReadItc (); +} + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + OUT UINT64 *StartValue, OPTIONAL + OUT UINT64 *EndValue OPTIONAL + ) +{ + PAL_PROC_RETURN PalRet; + UINT64 BaseFrequence; + + PalRet = PalCallStatic (NULL, 13, 0, 0, 0); + ASSERT (PalRet.Status == 0); + BaseFrequence = PalRet.r9; + + PalRet = PalCallStatic (NULL, 14, 0, 0, 0); + ASSERT (PalRet.Status == 0); + + if (StartValue != NULL) { + *StartValue = 0; + } + + if (EndValue != NULL) { + *EndValue = (UINT64)(-1); + } + + return BaseFrequence * (PalRet.r11 >> 32) / (UINT32)PalRet.r11; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c new file mode 100644 index 0000000000..be4d8c1d35 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c @@ -0,0 +1,258 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86TimerLib.c + +Abstract: + + Timer Library functions built upon local APIC on IA32/x64. + + @bug Should use PCD to retrieve all the constants including index of + the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount + and DivideConfiguration. + +--*/ + +#include "EdkIIGlueBase.h" + +// +// The following array is used in calculating the frequency of local APIC +// timer. Refer to IA-32 developers' manual for more details. +// +GLOBAL_REMOVE_IF_UNREFERENCED +CONST UINT8 mTimerLibLocalApicDivisor[] = { + 0x02, 0x04, 0x08, 0x10, + 0x02, 0x04, 0x08, 0x10, + 0x20, 0x40, 0x80, 0x01, + 0x20, 0x40, 0x80, 0x01 +}; + +/** + Internal function to retrieve the base address of local APIC. + + Internal function to retrieve the base address of local APIC. + + @return The base address of local APIC + +**/ +STATIC +UINTN +InternalX86GetApicBase ( + VOID + ) +{ + return (UINTN)AsmMsrBitFieldRead64 (27, 12, 35) << 12; +} + +/** + Internal function to return the frequency of the local APIC timer. + + Internal function to return the frequency of the local APIC timer. + + @param ApicBase The base address of memory mapped registers of local APIC. + + @return The frequency of the timer in Hz. + +**/ +STATIC +UINT32 +InternalX86GetTimerFrequency ( + IN UINTN ApicBase + ) +{ + return + PcdGet32(PcdFSBClock) / + mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + 0x3e0, 0, 3)]; +} + +/** + Internal function to read the current tick counter of local APIC. + + Internal function to read the current tick counter of local APIC. + + @param ApicBase The base address of memory mapped registers of local APIC. + + @return The tick counter read. + +**/ +STATIC +INT32 +InternalX86GetTimerTick ( + IN UINTN ApicBase + ) +{ + return MmioRead32 (ApicBase + 0x390); +} + +/** + Stalls the CPU for at least the given number of ticks. + + Stalls the CPU for at least the given number of ticks. It's invoked by + MicroSecondDelay() and NanoSecondDelay(). + + @param ApicBase The base address of memory mapped registers of local APIC. + @param Delay A period of time to delay in ticks. + +**/ +STATIC +VOID +InternalX86Delay ( + IN UINTN ApicBase, + IN UINT32 Delay + ) +{ + INT32 Ticks; + + // + // The target timer count is calculated here + // + Ticks = InternalX86GetTimerTick (ApicBase) - Delay; + + // + // Wait until time out + // Delay > 2^31 could not be handled by this function + // Timer wrap-arounds are handled correctly by this function + // + while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0); +} + +/** + Stalls the CPU for at least the given number of microseconds. + + Stalls the CPU for the number of microseconds specified by MicroSeconds. + + @param MicroSeconds The minimum number of microseconds to delay. + + @return MicroSeconds + +**/ +UINTN +EFIAPI +MicroSecondDelay ( + IN UINTN MicroSeconds + ) +{ + UINTN ApicBase; + + ApicBase = InternalX86GetApicBase (); + InternalX86Delay ( + ApicBase, + (UINT32)DivU64x32 ( + MultU64x64 ( + InternalX86GetTimerFrequency (ApicBase), + MicroSeconds + ), + 1000000u + ) + ); + return MicroSeconds; +} + +/** + Stalls the CPU for at least the given number of nanoseconds. + + Stalls the CPU for the number of nanoseconds specified by NanoSeconds. + + @param NanoSeconds The minimum number of nanoseconds to delay. + + @return NanoSeconds + +**/ +UINTN +EFIAPI +NanoSecondDelay ( + IN UINTN NanoSeconds + ) +{ + UINTN ApicBase; + + ApicBase = InternalX86GetApicBase (); + InternalX86Delay ( + ApicBase, + (UINT32)DivU64x32 ( + MultU64x64 ( + InternalX86GetTimerFrequency (ApicBase), + NanoSeconds + ), + 1000000000u + ) + ); + return NanoSeconds; +} + +/** + Retrieves the current value of a 64-bit free running performance counter. + + Retrieves the current value of a 64-bit free running performance counter. The + counter can either count up by 1 or count down by 1. If the physical + performance counter counts by a larger increment, then the counter values + must be translated. The properties of the counter can be retrieved from + GetPerformanceCounterProperties(). + + @return The current value of the free running performance counter. + +**/ +UINT64 +EFIAPI +GetPerformanceCounter ( + VOID + ) +{ + return (UINT64)(UINT32)InternalX86GetTimerTick (InternalX86GetApicBase ()); +} + +/** + Retrieves the 64-bit frequency in Hz and the range of performance counter + values. + + If StartValue is not NULL, then the value that the performance counter starts + with immediately after is it rolls over is returned in StartValue. If + EndValue is not NULL, then the value that the performance counter end with + immediately before it rolls over is returned in EndValue. The 64-bit + frequency of the performance counter in Hz is always returned. If StartValue + is less than EndValue, then the performance counter counts up. If StartValue + is greater than EndValue, then the performance counter counts down. For + example, a 64-bit free running counter that counts up would have a StartValue + of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter + that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. + + @param StartValue The value the performance counter starts with when it + rolls over. + @param EndValue The value that the performance counter ends with before + it rolls over. + + @return The frequency in Hz. + +**/ +UINT64 +EFIAPI +GetPerformanceCounterProperties ( + OUT UINT64 *StartValue, OPTIONAL + OUT UINT64 *EndValue OPTIONAL + ) +{ + UINTN ApicBase; + + ApicBase = InternalX86GetApicBase (); + + if (StartValue != NULL) { + *StartValue = MmioRead32 (ApicBase + 0x380); + } + + if (EndValue != NULL) { + *EndValue = 0; + } + + return (UINT64) InternalX86GetTimerFrequency (ApicBase);; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c new file mode 100644 index 0000000000..caa8917611 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c @@ -0,0 +1,801 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + BaseUefiDecompressLib.c + +Abstract: + + UEFI Decompress Library. + +--*/ + +#include "BaseUefiDecompressLibInternals.h" + +/** + Read NumOfBit of bits from source into mBitBuf + + Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. + + @param Sd The global scratch data + @param NumOfBits The number of bits to shift and read. + +**/ +VOID +GlueFillBuf ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +{ + // + // Left shift NumOfBits of bits in advance + // + Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits); + + // + // Copy data needed in bytes into mSbuBitBuf + // + while (NumOfBits > Sd->mBitCount) { + + Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount))); + + if (Sd->mCompSize > 0) { + // + // Get 1 byte into SubBitBuf + // + Sd->mCompSize--; + Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; + Sd->mBitCount = 8; + + } else { + // + // No more bits from the source, just pad zero bit. + // + Sd->mSubBitBuf = 0; + Sd->mBitCount = 8; + + } + } + + // + // Caculate additional bit count read to update mBitCount + // + Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits); + + // + // Copy NumOfBits of bits from mSubBitBuf into mBitBuf + // + Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount; +} + +/** + Get NumOfBits of bits out from mBitBuf + + Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent + NumOfBits of bits from source. Returns NumOfBits of bits that are + popped out. + + @param Sd The global scratch data. + @param NumOfBits The number of bits to pop and read. + + @return The bits that are popped out. + +**/ +UINT32 +GlueGetBits ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +{ + UINT32 OutBits; + + // + // Pop NumOfBits of Bits from Left + // + OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits)); + + // + // Fill up mBitBuf from source + // + FillBuf (Sd, NumOfBits); + + return OutBits; +} + +/** + Creates Huffman Code mapping table according to code length array. + + Creates Huffman Code mapping table for Extra Set, Char&Len Set + and Position Set according to code length array. + + @param Sd The global scratch data + @param NumOfChar Number of symbols in the symbol set + @param BitLen Code length array + @param TableBits The width of the mapping table + @param Table The table + + @retval 0 OK. + @retval BAD_TABLE The table is corrupted. + +**/ +UINT16 +GlueMakeTable ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfChar, + IN UINT8 *BitLen, + IN UINT16 TableBits, + OUT UINT16 *Table + ) +{ + UINT16 Count[17]; + UINT16 Weight[17]; + UINT16 Start[18]; + UINT16 *Pointer; + UINT16 Index3; + volatile UINT16 Index; + UINT16 Len; + UINT16 Char; + UINT16 JuBits; + UINT16 Avail; + UINT16 NextCode; + UINT16 Mask; + UINT16 WordOfStart; + UINT16 WordOfCount; + + + for (Index = 1; Index <= 16; Index++) { + Count[Index] = 0; + } + + for (Index = 0; Index < NumOfChar; Index++) { + Count[BitLen[Index]]++; + } + + Start[1] = 0; + + for (Index = 1; Index <= 16; Index++) { + WordOfStart = Start[Index]; + WordOfCount = Count[Index]; + Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index))); + } + + if (Start[17] != 0) { + /*(1U << 16)*/ + return (UINT16) BAD_TABLE; + } + + JuBits = (UINT16) (16 - TableBits); + + for (Index = 1; Index <= TableBits; Index++) { + Start[Index] >>= JuBits; + Weight[Index] = (UINT16) (1U << (TableBits - Index)); + } + + while (Index <= 16) { + Weight[Index] = (UINT16) (1U << (16 - Index)); + Index++; + } + + Index = (UINT16) (Start[TableBits + 1] >> JuBits); + + if (Index != 0) { + Index3 = (UINT16) (1U << TableBits); + while (Index != Index3) { + Table[Index++] = 0; + } + } + + Avail = NumOfChar; + Mask = (UINT16) (1U << (15 - TableBits)); + + for (Char = 0; Char < NumOfChar; Char++) { + + Len = BitLen[Char]; + if (Len == 0) { + continue; + } + + NextCode = (UINT16) (Start[Len] + Weight[Len]); + + if (Len <= TableBits) { + + for (Index = Start[Len]; Index < NextCode; Index++) { + Table[Index] = Char; + } + + } else { + + Index3 = Start[Len]; + Pointer = &Table[Index3 >> JuBits]; + Index = (UINT16) (Len - TableBits); + + while (Index != 0) { + if (*Pointer == 0) { + Sd->mRight[Avail] = Sd->mLeft[Avail] = 0; + *Pointer = Avail++; + } + + if (Index3 & Mask) { + Pointer = &Sd->mRight[*Pointer]; + } else { + Pointer = &Sd->mLeft[*Pointer]; + } + + Index3 <<= 1; + Index--; + } + + *Pointer = Char; + + } + + Start[Len] = NextCode; + } + // + // Succeeds + // + return 0; +} + +/** + Decodes a position value. + + Get a position value according to Position Huffman Table. + + @param Sd the global scratch data + + @return The position value decoded. + +**/ +UINT32 +GlueDecodeP ( + IN SCRATCH_DATA *Sd + ) +{ + UINT16 Val; + UINT32 Mask; + UINT32 Pos; + + Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + + if (Val >= MAXNP) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Sd->mBitBuf & Mask) { + Val = Sd->mRight[Val]; + } else { + Val = Sd->mLeft[Val]; + } + + Mask >>= 1; + } while (Val >= MAXNP); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[Val]); + + Pos = Val; + if (Val > 1) { + Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1))); + } + + return Pos; +} + +/** + Reads code lengths for the Extra Set or the Position Set. + + Read in the Extra Set or Pointion Set Length Arrary, then + generate the Huffman code mapping for them. + + @param Sd The global scratch data. + @param nn Number of symbols. + @param nbit Number of bits needed to represent nn. + @param Special The special symbol that needs to be taken care of. + + @retval 0 OK. + @retval BAD_TABLE Table is corrupted. + +**/ +UINT16 +GlueReadPTLen ( + IN SCRATCH_DATA *Sd, + IN UINT16 nn, + IN UINT16 nbit, + IN UINT16 Special + ) +{ + UINT16 Number; + UINT16 CharC; + volatile UINT16 Index; + UINT32 Mask; + + // + // Read Extra Set Code Length Array size + // + Number = (UINT16) GetBits (Sd, nbit); + + if (Number == 0) { + // + // This represents only Huffman code used + // + CharC = (UINT16) GetBits (Sd, nbit); + + for (Index = 0; Index < 256; Index++) { + Sd->mPTTable[Index] = CharC; + } + + for (Index = 0; Index < nn; Index++) { + Sd->mPTLen[Index] = 0; + } + + return 0; + } + + Index = 0; + + while (Index < Number) { + + CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3)); + + // + // If a code length is less than 7, then it is encoded as a 3-bit + // value. Or it is encoded as a series of "1"s followed by a + // terminating "0". The number of "1"s = Code length - 4. + // + if (CharC == 7) { + Mask = 1U << (BITBUFSIZ - 1 - 3); + while (Mask & Sd->mBitBuf) { + Mask >>= 1; + CharC += 1; + } + } + + FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3)); + + Sd->mPTLen[Index++] = (UINT8) CharC; + + // + // For Code&Len Set, + // After the third length of the code length concatenation, + // a 2-bit value is used to indicated the number of consecutive + // zero lengths after the third length. + // + if (Index == Special) { + CharC = (UINT16) GetBits (Sd, 2); + while ((INT16) (--CharC) >= 0) { + Sd->mPTLen[Index++] = 0; + } + } + } + + while (Index < nn) { + Sd->mPTLen[Index++] = 0; + } + + return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable); +} + +/** + Reads code lengths for Char&Len Set. + + Read in and decode the Char&Len Set Code Length Array, then + generate the Huffman Code mapping table for the Char&Len Set. + + @param Sd the global scratch data + +**/ +VOID +GlueReadCLen ( + SCRATCH_DATA *Sd + ) +{ + UINT16 Number; + UINT16 CharC; + volatile UINT16 Index; + UINT32 Mask; + + Number = (UINT16) GetBits (Sd, CBIT); + + if (Number == 0) { + // + // This represents only Huffman code used + // + CharC = (UINT16) GetBits (Sd, CBIT); + + for (Index = 0; Index < NC; Index++) { + Sd->mCLen[Index] = 0; + } + + for (Index = 0; Index < 4096; Index++) { + Sd->mCTable[Index] = CharC; + } + + return ; + } + + Index = 0; + while (Index < Number) { + CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + if (CharC >= NT) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Mask & Sd->mBitBuf) { + CharC = Sd->mRight[CharC]; + } else { + CharC = Sd->mLeft[CharC]; + } + + Mask >>= 1; + + } while (CharC >= NT); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[CharC]); + + if (CharC <= 2) { + + if (CharC == 0) { + CharC = 1; + } else if (CharC == 1) { + CharC = (UINT16) (GetBits (Sd, 4) + 3); + } else if (CharC == 2) { + CharC = (UINT16) (GetBits (Sd, CBIT) + 20); + } + + while ((INT16) (--CharC) >= 0) { + Sd->mCLen[Index++] = 0; + } + + } else { + + Sd->mCLen[Index++] = (UINT8) (CharC - 2); + + } + } + + while (Index < NC) { + Sd->mCLen[Index++] = 0; + } + + MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable); + + return ; +} + +/** + Decode a character/length value. + + Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates + Huffman code mapping table for Extra Set, Code&Len Set and + Position Set. + + @param Sd The global scratch data. + + @return The value decoded. + +**/ +UINT16 +GlueDecodeC ( + SCRATCH_DATA *Sd + ) +{ + UINT16 Index2; + UINT32 Mask; + + if (Sd->mBlockSize == 0) { + // + // Starting a new block + // Read BlockSize from block header + // + Sd->mBlockSize = (UINT16) GetBits (Sd, 16); + + // + // Read in the Extra Set Code Length Arrary, + // Generate the Huffman code mapping table for Extra Set. + // + Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3); + if (Sd->mBadTableFlag != 0) { + return 0; + } + + // + // Read in and decode the Char&Len Set Code Length Arrary, + // Generate the Huffman code mapping table for Char&Len Set. + // + ReadCLen (Sd); + + // + // Read in the Position Set Code Length Arrary, + // Generate the Huffman code mapping table for the Position Set. + // + Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1)); + if (Sd->mBadTableFlag != 0) { + return 0; + } + } + + // + // Get one code according to Code&Set Huffman Table + // + Sd->mBlockSize--; + Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)]; + + if (Index2 >= NC) { + Mask = 1U << (BITBUFSIZ - 1 - 12); + + do { + if (Sd->mBitBuf & Mask) { + Index2 = Sd->mRight[Index2]; + } else { + Index2 = Sd->mLeft[Index2]; + } + + Mask >>= 1; + } while (Index2 >= NC); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mCLen[Index2]); + + return Index2; +} + +/** + Decode the source data and put the resulting data into the destination buffer. + + Decode the source data and put the resulting data into the destination buffer. + + @param Sd The global scratch data + +**/ +VOID +GlueDecode ( + SCRATCH_DATA *Sd + ) +{ + UINT16 BytesRemain; + UINT32 DataIdx; + UINT16 CharC; + + BytesRemain = (UINT16) (-1); + + DataIdx = 0; + + for (;;) { + // + // Get one code from mBitBuf + // + CharC = DecodeC (Sd); + if (Sd->mBadTableFlag != 0) { + goto Done; + } + + if (CharC < 256) { + // + // Process an Original character + // + if (Sd->mOutBuf >= Sd->mOrigSize) { + goto Done; + } else { + // + // Write orignal character into mDstBase + // + Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC; + } + + } else { + // + // Process a Pointer + // + CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD)); + + // + // Get string length + // + BytesRemain = CharC; + + // + // Locate string position + // + DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1; + + // + // Write BytesRemain of bytes into mDstBase + // + BytesRemain--; + while ((INT16) (BytesRemain) >= 0) { + Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++]; + if (Sd->mOutBuf >= Sd->mOrigSize) { + goto Done; + } + + BytesRemain--; + } + } + } + +Done: + return ; +} + +/** + Retrieves the size of the uncompressed buffer and the size of the scratch buffer. + + Retrieves the size of the uncompressed buffer and the temporary scratch buffer + required to decompress the buffer specified by Source and SourceSize. + If the size of the uncompressed buffer or the size of the scratch buffer cannot + be determined from the compressed data specified by Source and SourceData, + then RETURN_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed + buffer is returned in DestinationSize, the size of the scratch buffer is returned + in ScratchSize, and RETURN_SUCCESS is returned. + This function does not have scratch buffer available to perform a thorough + checking of the validity of the source data. It just retrieves the "Original Size" + field from the beginning bytes of the source data and output it as DestinationSize. + And ScratchSize is specific to the decompression implementation. + + If Source is NULL, then ASSERT(). + If DestinationSize is NULL, then ASSERT(). + If ScratchSize is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param SourceSize The size, in bytes, of the source buffer. + @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer + that will be generated when the compressed buffer specified + by Source and SourceSize is decompressed.. + @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that + is required to decompress the compressed buffer specified + by Source and SourceSize. + + @retval RETURN_SUCCESS The size of destination buffer and the size of scratch + buffer are successull retrieved. + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompressGetInfo ( + IN CONST VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ) +{ + UINT32 CompressedSize; + + ASSERT (Source != NULL); + ASSERT (DestinationSize != NULL); + ASSERT (ScratchSize != NULL); + + *ScratchSize = sizeof (SCRATCH_DATA); + + if (SourceSize < 8) { + return RETURN_INVALID_PARAMETER; + } + + CopyMem (&CompressedSize, Source, sizeof (UINT32)); + CopyMem (DestinationSize, (VOID *)((UINT8 *)Source + 4), sizeof (UINT32)); + + if (SourceSize < (CompressedSize + 8)) { + return RETURN_INVALID_PARAMETER; + } + + return RETURN_SUCCESS; +} + +/** + Decompresses a compressed source buffer. + + This function is designed so that the decompression algorithm can be implemented + without using any memory services. As a result, this function is not allowed to + call any memory allocation services in its implementation. It is the caller's r + esponsibility to allocate and free the Destination and Scratch buffers. + If the compressed source data specified by Source is sucessfully decompressed + into Destination, then RETURN_SUCCESS is returned. If the compressed source data + specified by Source is not in a valid compressed data format, + then RETURN_INVALID_PARAMETER is returned. + + If Source is NULL, then ASSERT(). + If Destination is NULL, then ASSERT(). + If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT(). + + @param Source The source buffer containing the compressed data. + @param Destination The destination buffer to store the decompressed data + @param Scratch A temporary scratch buffer that is used to perform the decompression. + This is an optional parameter that may be NULL if the + required scratch buffer size is 0. + + @retval RETURN_SUCCESS Decompression is successfull + @retval RETURN_INVALID_PARAMETER The source data is corrupted + +**/ +RETURN_STATUS +EFIAPI +UefiDecompress ( + IN CONST VOID *Source, + IN OUT VOID *Destination, + IN OUT VOID *Scratch + ) +{ + volatile UINT32 Index; + UINT32 CompSize; + UINT32 OrigSize; + SCRATCH_DATA *Sd; + CONST UINT8 *Src; + UINT8 *Dst; + + ASSERT (Source != NULL); + ASSERT (Destination != NULL); + ASSERT (Scratch != NULL); + + Src = Source; + Dst = Destination; + + Sd = (SCRATCH_DATA *) Scratch; + + CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24); + OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); + + // + // If compressed file size is 0, return + // + if (OrigSize == 0) { + return RETURN_SUCCESS; + } + + Src = Src + 8; + + for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) { + ((UINT8 *) Sd)[Index] = 0; + } + // + // The length of the field 'Position Set Code Length Array Size' in Block Header. + // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4 + // For Tiano de/compression algorithm(Version 2), mPBit = 5 + // + Sd->mPBit = 4; + Sd->mSrcBase = (UINT8 *)Src; + Sd->mDstBase = Dst; + // + // CompSize and OrigSize are caculated in bytes + // + Sd->mCompSize = CompSize; + Sd->mOrigSize = OrigSize; + + // + // Fill the first BITBUFSIZ bits + // + FillBuf (Sd, BITBUFSIZ); + + // + // Decompress it + // + Decode (Sd); + + if (Sd->mBadTableFlag != 0) { + // + // Something wrong with the source + // + return RETURN_INVALID_PARAMETER; + } + + return RETURN_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf new file mode 100644 index 0000000000..bc1c6dc7c3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf @@ -0,0 +1,78 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# BaseUefiDecompressLib.inf +# +# Abstract: +# +# Component description file for BaseUefiDecompressLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueBaseUefiDecompressLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + BaseUefiDecompressLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h new file mode 100644 index 0000000000..09ec44e6e4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h @@ -0,0 +1,222 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BaseUefiDecompressLibInternals.h + +Abstract: + + Header file for Base Uefi Decompress Library. + +--*/ + +#ifndef __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__ +#define __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__ + +#include "EdkIIGlueBase.h" + +// +// Decompression algorithm begins here +// +#define BITBUFSIZ 32 +#define MAXMATCH 256 +#define THRESHOLD 3 +#define CODE_BIT 16 +#define BAD_TABLE - 1 + +// +// C: Char&Len Set; P: Position Set; T: exTra Set +// +#define NC (0xff + MAXMATCH + 2 - THRESHOLD) +#define CBIT 9 +#define MAXPBIT 5 +#define TBIT 5 +#define MAXNP ((1U << MAXPBIT) - 1) +#define NT (CODE_BIT + 3) +#if NT > MAXNP +#define NPT NT +#else +#define NPT MAXNP +#endif + +typedef struct { + UINT8 *mSrcBase; ///< Starting address of compressed data + UINT8 *mDstBase; ///< Starting address of decompressed data + UINT32 mOutBuf; + UINT32 mInBuf; + + UINT16 mBitCount; + UINT32 mBitBuf; + UINT32 mSubBitBuf; + UINT16 mBlockSize; + UINT32 mCompSize; + UINT32 mOrigSize; + + UINT16 mBadTableFlag; + + UINT16 mLeft[2 * NC - 1]; + UINT16 mRight[2 * NC - 1]; + UINT8 mCLen[NC]; + UINT8 mPTLen[NPT]; + UINT16 mCTable[4096]; + UINT16 mPTTable[256]; + + /// + /// The length of the field 'Position Set Code Length Array Size' in Block Header. + /// For EFI 1.1 de/compression algorithm, mPBit = 4 + /// For Tiano de/compression algorithm, mPBit = 5 + /// + UINT8 mPBit; +} SCRATCH_DATA; + +/** + Read NumOfBit of bits from source into mBitBuf + + Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. + + @param Sd The global scratch data + @param NumOfBits The number of bits to shift and read. + +**/ +VOID +GlueFillBuf ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ); + +/** + Get NumOfBits of bits out from mBitBuf + + Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent + NumOfBits of bits from source. Returns NumOfBits of bits that are + popped out. + + @param Sd The global scratch data. + @param NumOfBits The number of bits to pop and read. + + @return The bits that are popped out. + +**/ +UINT32 +GlueGetBits ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ); + +/** + Creates Huffman Code mapping table according to code length array. + + Creates Huffman Code mapping table for Extra Set, Char&Len Set + and Position Set according to code length array. + + @param Sd The global scratch data + @param NumOfChar Number of symbols in the symbol set + @param BitLen Code length array + @param TableBits The width of the mapping table + @param Table The table + + @retval 0 OK. + @retval BAD_TABLE The table is corrupted. + +**/ +UINT16 +GlueMakeTable ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfChar, + IN UINT8 *BitLen, + IN UINT16 TableBits, + OUT UINT16 *Table + ); + +/** + Decodes a position value. + + Get a position value according to Position Huffman Table. + + @param Sd the global scratch data + + @return The position value decoded. + +**/ +UINT32 +GlueDecodeP ( + IN SCRATCH_DATA *Sd + ); + +/** + Reads code lengths for the Extra Set or the Position Set. + + Read in the Extra Set or Pointion Set Length Arrary, then + generate the Huffman code mapping for them. + + @param Sd The global scratch data. + @param nn Number of symbols. + @param nbit Number of bits needed to represent nn. + @param Special The special symbol that needs to be taken care of. + + @retval 0 OK. + @retval BAD_TABLE Table is corrupted. + +**/ +UINT16 +GlueReadPTLen ( + IN SCRATCH_DATA *Sd, + IN UINT16 nn, + IN UINT16 nbit, + IN UINT16 Special + ); + +/** + Reads code lengths for Char&Len Set. + + Read in and decode the Char&Len Set Code Length Array, then + generate the Huffman Code mapping table for the Char&Len Set. + + @param Sd the global scratch data + +**/ +VOID +GlueReadCLen ( + SCRATCH_DATA *Sd + ); + +/** + Decode a character/length value. + + Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates + Huffman code mapping table for Extra Set, Code&Len Set and + Position Set. + + @param Sd The global scratch data. + + @return The value decoded. + +**/ +UINT16 +GlueDecodeC ( + SCRATCH_DATA *Sd + ); + +/** + Decode the source data and put the resulting data into the destination buffer. + + Decode the source data and put the resulting data into the destination buffer. + + @param Sd The global scratch data + +**/ +VOID +GlueDecode ( + SCRATCH_DATA *Sd + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf new file mode 100644 index 0000000000..64cdfeccf9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf @@ -0,0 +1,84 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# DxeHobLib.inf +# +# Abstract: +# +# Component description file for DxeHobLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeHobLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + HobLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiLib +# +# R8.x Library, GUID needed: gEfiHobListGuid +# + EdkFrameworkGuidLib + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c new file mode 100644 index 0000000000..9dc50a27a3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c @@ -0,0 +1,501 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + HobLib.c + +Abstract: + + HOB Library. + +--*/ + +#include "EdkIIGlueDxe.h" + + +STATIC VOID *mHobList = NULL; + +/** + The constructor function caches the pointer to HOB list. + + The constructor function gets the start address of HOB list from system configuration table. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +HobLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList); + ASSERT_EFI_ERROR (Status); + ASSERT (mHobList != NULL); + return Status; +} + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +{ + return mHobList; +} + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + ASSERT (HobStart != NULL); + + Hob.Raw = (UINT8 *) HobStart; + // + // Parse the HOB list until end of list or matching type is found. + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == Type) { + return Hob.Raw; + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + return NULL; +} + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16 Type + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextHob (Type, HobList); +} + +/** + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart A pointer to a Guid. + + @return The next instance of the matched GUID HOB from the starting HOB. + +**/ +VOID * +EFIAPI +GlueGetNextGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS GuidHob; + + GuidHob.Raw = (UINT8 *) HobStart; + while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) { + if (CompareGuid (Guid, &GuidHob.Guid->Name)) { + break; + } + GuidHob.Raw = GET_NEXT_HOB (GuidHob); + } + return GuidHob.Raw; +} + +/** + This function searches the first instance of a HOB among the whole HOB list. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + If Guid is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + + @return The first instance of the matched GUID HOB among the whole HOB list. + +**/ +VOID * +EFIAPI +GlueGetFirstGuidHob ( + IN CONST EFI_GUID *Guid + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextGuidHob (Guid, HobList); +} + +/** + Get the Boot Mode from the HOB list. + + This function returns the system boot mode information from the + PHIT HOB in HOB list. + + @param VOID + + @return The Boot Mode. + +**/ +EFI_BOOT_MODE +EFIAPI +GetBootModeHob ( + VOID + ) +{ + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; + + HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList (); + + return HandOffHob->BootMode; +} + +/** + Builds a HOB for a loaded PE32 module. + + This function builds a HOB for a loaded PE32 module. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If ModuleName is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param ModuleName The GUID File Name of the module. + @param MemoryAllocationModule The 64 bit physical address of the module. + @param ModuleLength The length of the module in bytes. + @param EntryPoint The 64 bit physical address of the module's entry point. + +**/ +VOID +EFIAPI +GlueBuildModuleHob ( + IN CONST EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB that describes a chunk of system memory. + + This function builds a HOB that describes a chunk of system memory. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + +**/ +VOID +EFIAPI +BuildResourceDescriptorHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a GUID HOB with a certain data length. + + This function builds a customized HOB tagged with a GUID for identification + and returns the start address of GUID HOB data so that caller can fill the customized data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidHob ( + IN CONST EFI_GUID *Guid, + IN UINTN DataLength + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); + return NULL; +} + +/** + Copies a data buffer to a newly-built HOB. + + This function builds a customized HOB tagged with a GUID for identification, + copies the input data to the HOB data field and returns the start address of the GUID HOB data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If Data is NULL and DataLength > 0, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param Data The data to be copied into the data field of the GUID HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidDataHob ( + IN CONST EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); + return NULL; +} + +/** + Builds a Firmware Volume HOB. + + This function builds a Firmware Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + +**/ +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a Capsule Volume HOB. + + This function builds a Capsule Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Capsule Volume. + @param Length The size of the Capsule Volume in bytes. + +**/ +VOID +EFIAPI +BuildCvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the CPU. + + This function builds a HOB for the CPU. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param SizeOfMemorySpace The maximum physical memory addressability of the processor. + @param SizeOfIoSpace The maximum physical I/O addressability of the processor. + +**/ +VOID +EFIAPI +BuildCpuHob ( + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the Stack. + + This function builds a HOB for the stack. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the Stack. + @param Length The length of the stack in bytes. + +**/ +VOID +EFIAPI +BuildStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the BSP store. + + This function builds a HOB for BSP store. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the BSP. + @param Length The length of the BSP store in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildBspStoreHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} + +/** + Builds a HOB for the memory allocation. + + This function builds a HOB for the memory allocation. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the memory. + @param Length The length of the memory allocation in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +GlueBuildMemoryAllocationHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + // + // PEI HOB is read only for DXE phase + // + ASSERT (FALSE); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h new file mode 100644 index 0000000000..b82557c150 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeCpuIoLibInternal.h @@ -0,0 +1,115 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DxeCpuIoLibInternal.h + +Abstract: + + Internal header file for DxeIoLibCpuIo + +--*/ + +#ifndef __DXE_CPUIO_LIB_INTERNAL_H__ +#define __DXE_CPUIO_LIB_INTERNAL_H__ + +#include "EdkIIGlueDxe.h" + +/** + Reads registers in the EFI CPU I/O space. + + Reads the I/O port specified by Port with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI CPU I/O space. + +**/ +UINT64 +EFIAPI +IoReadWorker ( + IN UINTN Port, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width + ); + +/** + Writes registers in the EFI CPU I/O space. + + Writes the I/O port specified by Port with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + @param Data The value to write to the I/O port. + + @return The paramter of Data. + +**/ +UINT64 +EFIAPI +IoWriteWorker ( + IN UINTN Port, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Data + ); + +/** + Reads memory-mapped registers in the EFI system memory space. + + Reads the MMIO registers specified by Address with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioReadWorker ( + IN UINTN Address, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width + ); + +/** + Writes memory-mapped registers in the EFI system memory space. + + Writes the MMIO registers specified by Address with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioWriteWorker ( + IN UINTN Address, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Data + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf new file mode 100644 index 0000000000..a721a14ff3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.inf @@ -0,0 +1,80 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# DxeIoLibCpuIo.inf +# +# Abstract: +# +# Component description file for DxeIoLibCpuIo. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeIoLibCpuIo +COMPONENT_TYPE = LIBRARY + +[sources.common] + IoLib.c + IoHighLevel.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueUefiBootServicesTableLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoHighLevel.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoHighLevel.c new file mode 100644 index 0000000000..3e6b58826f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoHighLevel.c @@ -0,0 +1,2271 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IoHighLevel.c + +Abstract: + + High-level Io/Mmio functions. + +--*/ + +#include "DxeCpuIoLibInternal.h" + +/** + Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoOr8 ( + IN UINTN Port, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, (UINT8) (IoRead8 (Port) | OrData)); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back + to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAnd8 ( + IN UINTN Port, + IN UINT8 AndData + ) +{ + return IoWrite8 (Port, (UINT8) (IoRead8 (Port) & AndData)); +} + +/** + Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 8-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoAndThenOr8 ( + IN UINTN Port, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 (Port, (UINT8) ((IoRead8 (Port) & AndData) | OrData)); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in an 8-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoBitFieldRead8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldWrite8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return IoWrite8 ( + Port, + BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 8-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 8-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAnd8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return IoWrite8 ( + Port, + BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 8-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 8-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT8 +EFIAPI +IoBitFieldAndThenOr8 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return IoWrite8 ( + Port, + BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoOr16 ( + IN UINTN Port, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, (UINT16) (IoRead16 (Port) | OrData)); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back + to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAnd16 ( + IN UINTN Port, + IN UINT16 AndData + ) +{ + return IoWrite16 (Port, (UINT16) (IoRead16 (Port) & AndData)); +} + +/** + Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 16-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoAndThenOr16 ( + IN UINTN Port, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 (Port, (UINT16) ((IoRead16 (Port) & AndData) | OrData)); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 16-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoBitFieldRead16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldWrite16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return IoWrite16 ( + Port, + BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 16-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 16-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAnd16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return IoWrite16 ( + Port, + BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 16-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 16-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT16 +EFIAPI +IoBitFieldAndThenOr16 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return IoWrite16 ( + Port, + BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoOr32 ( + IN UINTN Port, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) | OrData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back + to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAnd32 ( + IN UINTN Port, + IN UINT32 AndData + ) +{ + return IoWrite32 (Port, IoRead32 (Port) & AndData); +} + +/** + Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 32-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoAndThenOr32 ( + IN UINTN Port, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 32-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoBitFieldRead32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldWrite32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return IoWrite32 ( + Port, + BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 32-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 32-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAnd32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return IoWrite32 ( + Port, + BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 32-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 32-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT32 +EFIAPI +IoBitFieldAndThenOr32 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return IoWrite32 ( + Port, + BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the + result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoOr64 ( + IN UINTN Port, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) | OrData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back + to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAnd64 ( + IN UINTN Port, + IN UINT64 AndData + ) +{ + return IoWrite64 (Port, IoRead64 (Port) & AndData); +} + +/** + Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, performs a bitwise OR + between the result of the AND operation and the value specified by OrData, + and writes the result to the 64-bit I/O port specified by Port. The value + written to the I/O port is returned. This function must guarantee that all + I/O read and write operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoAndThenOr64 ( + IN UINTN Port, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData); +} + +/** + Reads a bit field of an I/O register. + + Reads the bit field in a 64-bit I/O register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoBitFieldRead64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit); +} + +/** + Writes a bit field to an I/O register. + + Writes Value to the bit field of the I/O register. The bit field is specified + by the StartBit and the EndBit. All other bits in the destination I/O + register are preserved. The value written to the I/O port is returned. Extra + left bits in Value are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldWrite64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return IoWrite64 ( + Port, + BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR + between the read result and the value specified by OrData, and writes the + result to the 64-bit I/O port specified by Port. The value written to the I/O + port is returned. This function must guarantee that all I/O read and write + operations are serialized. Extra left bits in OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the + result back to the bit field in the 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND between + the read result and the value specified by AndData, and writes the result to + the 64-bit I/O port specified by Port. The value written to the I/O port is + returned. This function must guarantee that all I/O read and write operations + are serialized. Extra left bits in AndData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAnd64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return IoWrite64 ( + Port, + BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit port, performs a bitwise AND followed by a + bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit port. + + Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed + by a bitwise inclusive OR between the read result and the value specified by + AndData, and writes the result to the 64-bit I/O port specified by Port. The + value written to the I/O port is returned. This function must guarantee that + all I/O read and write operations are serialized. Extra left bits in both + AndData and OrData are stripped. + + If 64-bit I/O port operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Port The I/O port to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with the read value from the I/O port. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the I/O port. + +**/ +UINT64 +EFIAPI +IoBitFieldAndThenOr64 ( + IN UINTN Port, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return IoWrite64 ( + Port, + BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioOr8 ( + IN UINTN Address, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) | OrData)); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result + back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAnd8 ( + IN UINTN Address, + IN UINT8 AndData + ) +{ + return MmioWrite8 (Address, (UINT8) (MmioRead8 (Address) & AndData)); +} + +/** + Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 8-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioAndThenOr8 ( + IN UINTN Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 (Address, (UINT8) ((MmioRead8 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in an 8-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioBitFieldRead8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 8-bit register is returned. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldWrite8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return MmioWrite8 ( + Address, + BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 8-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 8-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAnd8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 8-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..7. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioBitFieldAndThenOr8 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return MmioWrite8 ( + Address, + BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioOr16 ( + IN UINTN Address, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) | OrData)); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result + back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAnd16 ( + IN UINTN Address, + IN UINT16 AndData + ) +{ + return MmioWrite16 (Address, (UINT16) (MmioRead16 (Address) & AndData)); +} + +/** + Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 16-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioAndThenOr16 ( + IN UINTN Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 (Address, (UINT16) ((MmioRead16 (Address) & AndData) | OrData)); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 16-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioBitFieldRead16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 16-bit register is returned. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldWrite16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return MmioWrite16 ( + Address, + BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 16-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 16-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAnd16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 16-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..15. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioBitFieldAndThenOr16 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return MmioWrite16 ( + Address, + BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioOr32 ( + IN UINTN Address, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) | OrData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result + back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAnd32 ( + IN UINTN Address, + IN UINT32 AndData + ) +{ + return MmioWrite32 (Address, MmioRead32 (Address) & AndData); +} + +/** + Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 32-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioAndThenOr32 ( + IN UINTN Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 32-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioBitFieldRead32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 32-bit register is returned. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldWrite32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return MmioWrite32 ( + Address, + BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 32-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 32-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAnd32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 32-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..31. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioBitFieldAndThenOr32 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return MmioWrite32 ( + Address, + BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData) + ); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the + result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param OrData The value to OR with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioOr64 ( + IN UINTN Address, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) | OrData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result + back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAnd64 ( + IN UINTN Address, + IN UINT64 AndData + ) +{ + return MmioWrite64 (Address, MmioRead64 (Address) & AndData); +} + +/** + Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise + inclusive OR, and writes the result back to the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, performs a + bitwise OR between the result of the AND operation and the value specified by + OrData, and writes the result to the 64-bit MMIO register specified by + Address. The value written to the MMIO register is returned. This function + must guarantee that all MMIO read and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + + @param Address The MMIO register to write. + @param AndData The value to AND with the read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioAndThenOr64 ( + IN UINTN Address, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData); +} + +/** + Reads a bit field of a MMIO register. + + Reads the bit field in a 64-bit MMIO register. The bit field is specified by + the StartBit and the EndBit. The value of the bit field is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to read. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioBitFieldRead64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a MMIO register. + + Writes Value to the bit field of the MMIO register. The bit field is + specified by the StartBit and the EndBit. All other bits in the destination + MMIO register are preserved. The new value of the 64-bit register is returned. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param Value New value of the bit field. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldWrite64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 Value + ) +{ + return MmioWrite64 ( + Address, + BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise + inclusive OR between the read result and the value specified by OrData, and + writes the result to the 64-bit MMIO register specified by Address. The value + written to the MMIO register is returned. This function must guarantee that + all MMIO read and write operations are serialized. Extra left bits in OrData + are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param OrData The value to OR with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and + writes the result back to the bit field in the 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + between the read result and the value specified by AndData, and writes the + result to the 64-bit MMIO register specified by Address. The value written to + the MMIO register is returned. This function must guarantee that all MMIO + read and write operations are serialized. Extra left bits in AndData are + stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAnd64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData) + ); +} + +/** + Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed + by a bitwise inclusive OR, and writes the result back to the bit field in the + 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address, performs a bitwise AND + followed by a bitwise inclusive OR between the read result and the value + specified by AndData, and writes the result to the 64-bit MMIO register + specified by Address. The value written to the MMIO register is returned. + This function must guarantee that all MMIO read and write operations are + serialized. Extra left bits in both AndData and OrData are stripped. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + If StartBit is greater than 63, then ASSERT(). + If EndBit is greater than 63, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address MMIO register to write. + @param StartBit The ordinal of the least significant bit in the bit field. + Range 0..63. + @param EndBit The ordinal of the most significant bit in the bit field. + Range 0..63. + @param AndData The value to AND with read value from the MMIO register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioBitFieldAndThenOr64 ( + IN UINTN Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT64 AndData, + IN UINT64 OrData + ) +{ + return MmioWrite64 ( + Address, + BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData) + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoLib.c new file mode 100644 index 0000000000..6105c7a70c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeIoLibCpuIo/IoLib.c @@ -0,0 +1,600 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IoHighLevel.c + +Abstract: + + High-level Io/Mmio functions. + +--*/ + +#include "DxeCpuIoLibInternal.h" + +// +// Globle varible to cache pointer to CpuIo protocol. +// +STATIC EFI_CPU_IO_PROTOCOL *mCpuIo = NULL; + +/** + The constructor function caches the pointer to CpuIo protocol. + + The constructor function locates CpuIo protocol from protocol database. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +IoLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID**) &mCpuIo); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** + Reads registers in the EFI CPU I/O space. + + Reads the I/O port specified by Port with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI CPU I/O space. + +**/ +UINT64 +EFIAPI +IoReadWorker ( + IN UINTN Port, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width + ) +{ + EFI_STATUS Status; + UINT64 Data; + + Status = mCpuIo->Io.Read (mCpuIo, Width, Port, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Writes registers in the EFI CPU I/O space. + + Writes the I/O port specified by Port with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all I/O read and write operations are serialized. + + @param Port The base address of the I/O operation. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + @param Data The value to write to the I/O port. + + @return The paramter of Data. + +**/ +UINT64 +EFIAPI +IoWriteWorker ( + IN UINTN Port, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Data + ) +{ + EFI_STATUS Status; + + Status = mCpuIo->Io.Write (mCpuIo, Width, Port, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Reads memory-mapped registers in the EFI system memory space. + + Reads the MMIO registers specified by Address with registers width specified by Width. + The read value is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioReadWorker ( + IN UINTN Address, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width + ) +{ + EFI_STATUS Status; + UINT64 Data; + + Status = mCpuIo->Mem.Read (mCpuIo, Width, Address, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Writes memory-mapped registers in the EFI system memory space. + + Writes the MMIO registers specified by Address with registers width and value specified by Width + and Data respectively. Data is returned. If such operations are not supported, then ASSERT(). + This function must guarantee that all MMIO read and write operations are serialized. + + @param Address The MMIO register to read. + The caller is responsible for aligning the Address if required. + @param Width The width of the I/O operation. + + @return Data read from registers in the EFI system memory space. + +**/ +UINT64 +EFIAPI +MmioWriteWorker ( + IN UINTN Address, + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Data + ) +{ + EFI_STATUS Status; + + Status = mCpuIo->Mem.Write (mCpuIo, Width, Address, 1, &Data); + ASSERT_EFI_ERROR (Status); + + return Data; +} + +/** + Reads an 8-bit I/O port. + + Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +IoRead8 ( + IN UINTN Port + ) +{ + return (UINT8)IoReadWorker (Port, EfiCpuIoWidthUint8); +} + +/** + Writes an 8-bit I/O port. + + Writes the 8-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 8-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT8 +EFIAPI +IoWrite8 ( + IN UINTN Port, + IN UINT8 Value + ) +{ + return (UINT8)IoWriteWorker (Port, EfiCpuIoWidthUint8, Value); +} + +/** + Reads a 16-bit I/O port. + + Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +IoRead16 ( + IN UINTN Port + ) +{ + // + // Make sure Port is aligned on a 16-bit boundary. + // + ASSERT ((Port & 1) == 0); + return (UINT16)IoReadWorker (Port, EfiCpuIoWidthUint16); +} + +/** + Writes a 16-bit I/O port. + + Writes the 16-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 16-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT16 +EFIAPI +IoWrite16 ( + IN UINTN Port, + IN UINT16 Value + ) +{ + // + // Make sure Port is aligned on a 16-bit boundary. + // + ASSERT ((Port & 1) == 0); + return (UINT16)IoWriteWorker (Port, EfiCpuIoWidthUint16, Value); +} + +/** + Reads a 32-bit I/O port. + + Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +IoRead32 ( + IN UINTN Port + ) +{ + // + // Make sure Port is aligned on a 32-bit boundary. + // + ASSERT ((Port & 3) == 0); + return (UINT32)IoReadWorker (Port, EfiCpuIoWidthUint32); +} + +/** + Writes a 32-bit I/O port. + + Writes the 32-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 32-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT32 +EFIAPI +IoWrite32 ( + IN UINTN Port, + IN UINT32 Value + ) +{ + // + // Make sure Port is aligned on a 32-bit boundary. + // + ASSERT ((Port & 3) == 0); + return (UINT32)IoWriteWorker (Port, EfiCpuIoWidthUint32, Value); +} + +/** + Reads a 64-bit I/O port. + + Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned. + This function must guarantee that all I/O read and write operations are + serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +IoRead64 ( + IN UINTN Port + ) +{ + // + // Make sure Port is aligned on a 64-bit boundary. + // + ASSERT ((Port & 7) == 0); + return IoReadWorker (Port, EfiCpuIoWidthUint64); +} + +/** + Writes a 64-bit I/O port. + + Writes the 64-bit I/O port specified by Port with the value specified by Value + and returns Value. This function must guarantee that all I/O read and write + operations are serialized. + + If 64-bit I/O port operations are not supported, then ASSERT(). + + @param Port The I/O port to write. + @param Value The value to write to the I/O port. + + @return The value written the I/O port. + +**/ +UINT64 +EFIAPI +IoWrite64 ( + IN UINTN Port, + IN UINT64 Value + ) +{ + // + // Make sure Port is aligned on a 64-bit boundary. + // + ASSERT ((Port & 7) == 0); + return IoWriteWorker (Port, EfiCpuIoWidthUint64, Value); +} + +/** + Reads an 8-bit MMIO register. + + Reads the 8-bit MMIO register specified by Address. The 8-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT8 +EFIAPI +MmioRead8 ( + IN UINTN Address + ) +{ + return (UINT8)MmioReadWorker (Address, EfiCpuIoWidthUint8); +} + +/** + Writes an 8-bit MMIO register. + + Writes the 8-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 8-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT8 +EFIAPI +MmioWrite8 ( + IN UINTN Address, + IN UINT8 Value + ) +{ + return (UINT8)MmioWriteWorker (Address, EfiCpuIoWidthUint8, Value); +} + +/** + Reads a 16-bit MMIO register. + + Reads the 16-bit MMIO register specified by Address. The 16-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT16 +EFIAPI +MmioRead16 ( + IN UINTN Address + ) +{ + // + // Make sure Address is aligned on a 16-bit boundary. + // + ASSERT ((Address & 1) == 0); + return (UINT16)MmioReadWorker (Address, EfiCpuIoWidthUint16); +} + +/** + Writes a 16-bit MMIO register. + + Writes the 16-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 16-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT16 +EFIAPI +MmioWrite16 ( + IN UINTN Address, + IN UINT16 Value + ) +{ + // + // Make sure Address is aligned on a 16-bit boundary. + // + ASSERT ((Address & 1) == 0); + return (UINT16)MmioWriteWorker (Address, EfiCpuIoWidthUint16, Value); +} + +/** + Reads a 32-bit MMIO register. + + Reads the 32-bit MMIO register specified by Address. The 32-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT32 +EFIAPI +MmioRead32 ( + IN UINTN Address + ) +{ + // + // Make sure Address is aligned on a 32-bit boundary. + // + ASSERT ((Address & 3) == 0); + return (UINT32)MmioReadWorker (Address, EfiCpuIoWidthUint32); +} + +/** + Writes a 32-bit MMIO register. + + Writes the 32-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 32-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT32 +EFIAPI +MmioWrite32 ( + IN UINTN Address, + IN UINT32 Value + ) +{ + // + // Make sure Address is aligned on a 32-bit boundary. + // + ASSERT ((Address & 3) == 0); + return (UINT32)MmioWriteWorker (Address, EfiCpuIoWidthUint32, Value); +} + +/** + Reads a 64-bit MMIO register. + + Reads the 64-bit MMIO register specified by Address. The 64-bit read value is + returned. This function must guarantee that all MMIO read and write + operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to read. + + @return The value read. + +**/ +UINT64 +EFIAPI +MmioRead64 ( + IN UINTN Address + ) +{ + // + // Make sure Address is aligned on a 64-bit boundary. + // + ASSERT ((Address & 7) == 0); + return (UINT64)MmioReadWorker (Address, EfiCpuIoWidthUint64); +} + +/** + Writes a 64-bit MMIO register. + + Writes the 64-bit MMIO register specified by Address with the value specified + by Value and returns Value. This function must guarantee that all MMIO read + and write operations are serialized. + + If 64-bit MMIO register operations are not supported, then ASSERT(). + + @param Address The MMIO register to write. + @param Value The value to write to the MMIO register. + +**/ +UINT64 +EFIAPI +MmioWrite64 ( + IN UINTN Address, + IN UINT64 Value + ) +{ + // + // Make sure Address is aligned on a 64-bit boundary. + // + ASSERT ((Address & 7) == 0); + return (UINT64)MmioWriteWorker (Address, EfiCpuIoWidthUint64, Value); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf new file mode 100644 index 0000000000..ad90935a99 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# DxeMemoryAllocationLib.inf +# +# Abstract: +# +# Component description file for DxeMemoryAllocationLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeMemoryAllocationLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + MemoryAllocationLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib + EfiProtocolLib + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c new file mode 100644 index 0000000000..482faa3b7d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c @@ -0,0 +1,1079 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + MemoryAllocationLib.c + +Abstract: + + Support routines for memory allocation routines for use with drivers. + +--*/ + +#include "EdkIIGlueDxe.h" + + +/** + Allocates one or more 4KB pages of a certain memory type. + + Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated + buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. + If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + + if (Pages == 0) { + return NULL; + } + + Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + Memory = 0; + } + return (VOID *) (UINTN) Memory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData. + + Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiBootServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiRuntimeServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType. + + Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiReservedMemoryType, Pages); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the page allocation + functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with a page allocation function in the Memory Allocation Library, + then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +GlueFreePages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + + ASSERT (Pages != 0); + Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates one or more 4KB pages of a certain memory type at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment + specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned. + If there is not enough memory at the specified alignment remaining to satisfy the request, then + NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN UINTN Alignment + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + UINTN AlignedMemory; + UINTN AlignmentMask; + UINTN UnalignedPages; + UINTN RealPages; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Pages == 0) { + return NULL; + } + if (Alignment > EFI_PAGE_SIZE) { + // + // Caculate the total number of pages since alignment is larger than page size. + // + AlignmentMask = Alignment - 1; + RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment); + // + // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. + // + ASSERT (RealPages > Pages); + + Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, RealPages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask; + UnalignedPages = EFI_SIZE_TO_PAGES ((UINTN) Memory - AlignedMemory); + if (UnalignedPages > 0) { + // + // Free first unaligned page(s). + // + Status = (gBS->FreePages) (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); + UnalignedPages = RealPages - Pages - UnalignedPages; + if (UnalignedPages > 0) { + // + // Free last unaligned page(s). + // + Status = (gBS->FreePages) (Memory, UnalignedPages); + ASSERT_EFI_ERROR (Status); + } + } else { + // + // Do not over-allocate pages in this case. + // + Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + AlignedMemory = (UINTN) Memory; + } + return (VOID *) AlignedMemory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the aligned page + allocation functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the aligned page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with an aligned page allocation function in the Memory Allocation + Library, then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreeAlignedPages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + + ASSERT (Pages != 0); + Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates a buffer of a certain pool type. + + Allocates the number bytes specified by AllocationSize of a certain pool type and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePool ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN AllocationSize + ) +{ + EFI_STATUS Status; + VOID *Memory; + + Status = (gBS->AllocatePool) (MemoryType, AllocationSize, &Memory); + if (EFI_ERROR (Status)) { + Memory = NULL; + } + return Memory; +} + +/** + Allocates a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiBootServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfieservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiReservedMemoryType, AllocationSize); +} + +/** + Allocates and zeros a buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer + with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, + then NULL is returned. + + @param PoolType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize + ) +{ + VOID *Memory; + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize); +} + +/** + Copies a buffer to an allocated buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer); +} + +/** + Frees a buffer that was previously allocated with one of the pool allocation functions in the + Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, + then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +GlueFreePool ( + IN VOID *Buffer + ) +{ + EFI_STATUS Status; + + Status = (gBS->FreePool) (Buffer); + ASSERT_EFI_ERROR (Status); +} + +/** + Allocates a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *RawAddress; + UINTN AlignedAddress; + UINTN AlignmentMask; + UINTN OverAllocationSize; + UINTN RealAllocationSize; + VOID **FreePointer; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + // + // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address. + // + OverAllocationSize = sizeof (RawAddress) + AlignmentMask; + RealAllocationSize = AllocationSize + OverAllocationSize; + // + // Make sure that AllocationSize plus OverAllocationSize does not overflow. + // + ASSERT (RealAllocationSize > AllocationSize); + + RawAddress = InternalAllocatePool (PoolType, RealAllocationSize); + if (RawAddress == NULL) { + return NULL; + } + AlignedAddress = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask; + // + // Save the original memory address just before the aligned address. + // + FreePointer = (VOID **)(AlignedAddress - sizeof (RawAddress)); + *FreePointer = RawAddress; + + return (VOID *) AlignedAddress; +} + +/** + Allocates a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiBootServicesData, AllocationSize, Alignment); +} + +/** + Allocates a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated + buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory at the specified alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *Memory; + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiBootServicesData, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Copies a buffer to an allocated buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiBootServicesData, AllocationSize, Buffer, Alignment); +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment); +} + +/** + Frees a buffer that was previously allocated with one of the aligned pool allocation functions + in the Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + aligned pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation + Library, then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +FreeAlignedPool ( + IN VOID *Buffer + ) +{ + VOID *RawAddress; + VOID **FreePointer; + EFI_STATUS Status; + + // + // Get the pre-saved original address in the over-allocate pool. + // + FreePointer = (VOID **)((UINTN) Buffer - sizeof (RawAddress)); + RawAddress = *FreePointer; + + Status = (gBS->FreePool) (RawAddress); + ASSERT_EFI_ERROR (Status); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf new file mode 100644 index 0000000000..766559c18b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf @@ -0,0 +1,97 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# DxeReportStatusCodeLib.inf +# +# Abstract: +# +# Component description file for DxeReportStatusCodeLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeReportStatusCodeLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + ReportStatusCodeLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + $(EDK_SOURCE)\Foundation\Core\Dxe\ArchProtocol\StatusCode + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib +# +# when EFI_SPECIFICATION_VERSION < 0x00020000, gRT is used +# + EdkIIGlueUefiRuntimeServicesTableLib +# R8.x lib + EfiProtocolLib +# Possibly, gEfiCallerIdGuid might be used. + EdkGuidLib + ArchProtocolLib + + +[libraries.ia32] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.x64] + EdkIIGlueBaseIoLibIntrinsic + +[libraries.ebc] + EdkIIGlueDxeIoLibCpuIo + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c new file mode 100644 index 0000000000..2178d742e1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -0,0 +1,605 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ReportStatusCodeLib.c + +Abstract: + + Report Status Code Library for DXE Phase. + +--*/ + +#include "EdkIIGlueDxe.h" + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +// +// Global pointer to the Status Code Protocol +// +static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL; + +#endif + +/** + Internal worker function that reports a status code through the Status Code Protocol + + This function checks to see if a Status Code Protocol is present in the handle + database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is + returned. If a Status Code Protocol is present, then it is cached in gStatusCode, + and the ReportStatusCode() service of the Status Code Protocol is called passing in + Type, Value, Instance, CallerId, and Data. The result of this call is returned. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. This is an optional parameter that may be + NULL. + @param Data Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code. + @retval EFI_UNSUPPORTED Status Code Protocol is not available. + +**/ +STATIC +EFI_STATUS +InternalReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + + EFI_STATUS Status; + + // + // If gStatusCode is NULL, then see if a Status Code Protocol instance is present + // in the handle database. + // + if (gStatusCode == NULL) { + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status) || gStatusCode == NULL) { + return EFI_UNSUPPORTED; + } + } + + // + // A Status Code Protocol is present in the handle database, so pass in all the + // parameters to the ReportStatusCode() service of the Status Code Protocol + // + return (gStatusCode->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data); + +#else + + return (gRT->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data); + +#endif + +} + + +/** + Computes and returns the size, in bytes, of a device path. + + @param DevicePath A pointer to a device path. + + @return The size, in bytes, of DevicePath. + +**/ +STATIC +UINTN +InternalReportStatusCodeDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Subtract the start node from the end node and add in the size of the end node + // + return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath); +} + + +/** + Converts a status code to an 8-bit POST code value. + + Converts the status code specified by CodeType and Value to an 8-bit POST code + and returns the 8-bit POST code in PostCode. If CodeType is an + EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode + are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits + 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. + + If PostCode is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param PostCode A pointer to the 8-bit POST code value to return. + + @retval TRUE The status code specified by CodeType and Value was converted + to an 8-bit POST code and returned in PostCode. + @retval FALSE The status code specified by CodeType and Value could not be + converted to an 8-bit POST code value. + +**/ +BOOLEAN +EFIAPI +GlueCodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +{ + // + // If PostCode is NULL, then ASSERT() + // + ASSERT (PostCode != NULL); + + // + // Convert Value to an 8 bit post code + // + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || + ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) { + *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) | + (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f)); + return TRUE; + } + return FALSE; +} + + +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + + ASSERT (Data != NULL); + ASSERT (Filename != NULL); + ASSERT (Description != NULL); + ASSERT (LineNumber != NULL); + + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && + ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) && + ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) { + AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1); + *Filename = (CHAR8 *)(AssertData + 1); + *Description = *Filename + AsciiStrLen (*Filename) + 1; + *LineNumber = AssertData->LineNumber; + return TRUE; + } + return FALSE; +} + + +/** + Extracts DEBUG() information from a status code structure. + + Converts the status code specified by Data to the DEBUG() arguments specified + by ErrorLevel, Marker, and Format. If type GUID in Data is + EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and + Format from the optional data area of the status code buffer specified by Data. + The optional data area of Data contains a 32-bit ErrorLevel followed by Marker + which is 12 UINTN parameters, followed by a Null-terminated ASCII string for + the Format. If the DEBUG() information could be extracted from Data, then + return TRUE. Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If ErrorLevel is NULL, then ASSERT(). + If Marker is NULL, then ASSERT(). + If Format is NULL, then ASSERT(). + + @param Data Pointer to status code data buffer. + @param ErrorLevel Pointer to error level mask for a debug message. + @param Marker Pointer to the variable argument list associated with Format. + @param Format Pointer to a Null-terminated ASCII format string of a + debug message. + + @retval TRUE The status code specified by Data was converted DEBUG() arguments + specified by ErrorLevel, Marker, and Format. + @retval FALSE The status code specified by Data could not be converted to + DEBUG() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractDebugInfo ( + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +{ + EFI_DEBUG_INFO *DebugInfo; + + ASSERT (Data != NULL); + ASSERT (ErrorLevel != NULL); + ASSERT (Marker != NULL); + ASSERT (Format != NULL); + + // + // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE + // + if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) { + return FALSE; + } + + // + // Retrieve the debug information from the status code record + // + DebugInfo = (EFI_DEBUG_INFO *)(Data + 1); + + *ErrorLevel = DebugInfo->ErrorLevel; + + // + // The first 12 * UINTN bytes of the string are really an + // argument stack to support varargs on the Format string. + // + *Marker = (VA_LIST) (DebugInfo + 1); + *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12); + + return TRUE; +} + + +/** + Reports a status code. + + Reports the status code specified by the parameters Type and Value. Status + code also require an instance, caller ID, and extended data. This function + passed in a zero instance, NULL extended data, and a caller ID of + gEfiCallerIdGuid, which is the GUID for the module. + + ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() + is called while processing another any other Report Status Code Library function, + then ReportStatusCode() must return immediately. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a + device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value + ) +{ + return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL); +} + + +/** + Reports a status code with a Device Path Protocol as the extended data. + + Allocates and fills in the extended data section of a status code with the + Device Path Protocol specified by DevicePath. This function is responsible + for allocating a buffer large enough for the standard header and the device + path. The standard header is filled in with a GUID of + gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero + instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithDevicePath()must actively prevent recursion. If + ReportStatusCodeWithDevicePath() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithDevicePath() + must return EFI_DEVICE_ERROR immediately. + + If DevicePath is NULL, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + ASSERT (DevicePath != NULL); + return ReportStatusCodeWithExtendedData ( + Type, + Value, + (VOID *)DevicePath, + InternalReportStatusCodeDevicePathSize (DevicePath) + ); +} + + +/** + Reports a status code with an extended data buffer. + + Allocates and fills in the extended data section of a status code with the + extended data specified by ExtendedData and ExtendedDataSize. ExtendedData + is assumed to be one of the data structures specified in Related Definitions. + These data structure do not have the standard header, so this function is + responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled + in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported + with a zero instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithExtendedData()must actively prevent recursion. If + ReportStatusCodeWithExtendedData() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithExtendedData() + must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL, then ASSERT(). + If ExtendedDataSize is 0, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithExtendedData ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST VOID *ExtendedData, + IN UINTN ExtendedDataSize + ) +{ + ASSERT (ExtendedData != NULL); + ASSERT (ExtendedDataSize != 0); + return ReportStatusCodeEx ( + Type, + Value, + 0, + NULL, + NULL, + ExtendedData, + ExtendedDataSize + ); +} + + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ) +{ + EFI_STATUS Status; + EFI_STATUS_CODE_DATA *StatusCodeData; + + ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); + ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); + + // + // Allocate space for the Status Code Header and its buffer + // + StatusCodeData = NULL; + (gBS->AllocatePool) (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData); + if (StatusCodeData == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Fill in the extended data header + // + StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA); + StatusCodeData->Size = (UINT16)ExtendedDataSize; + if (ExtendedDataGuid == NULL) { + ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid; + } + CopyGuid (&StatusCodeData->Type, ExtendedDataGuid); + + // + // Fill in the extended data buffer + // + CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize); + + // + // Report the status code + // + if (CallerId == NULL) { + CallerId = &gEfiCallerIdGuid; + } + Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData); + + // + // Free the allocated buffer + // + (gBS->FreePool) (StatusCodeData); + + return Status; +} + + +/** + Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportProgressCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_ERROR_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportErrorCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportDebugCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c new file mode 100644 index 0000000000..31591bea70 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c @@ -0,0 +1,61 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DxeServicesTableLib.c + +Abstract: + + Dxe Services Table Lib + +--*/ + +#include "EdkIIGlueDxe.h" + +// +// Cache copy of the DXE Services Table +// +EFI_DXE_SERVICES *gDS = NULL; + +/** + The constructor function caches the pointer of DXE Services Table. + + The constructor function caches the pointer of DXE Services Table. + It will ASSERT() if that operation fails. + It will ASSERT() if the pointer of DXE Services Table is NULL. + It will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +DxeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Cache copy of the DXE Services Table + // + Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); + ASSERT_EFI_ERROR (Status); + ASSERT (gDS != NULL); + + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf new file mode 100644 index 0000000000..f3be24fbb2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# DxeServicesTableLib.inf +# +# Abstract: +# +# Component description file for DxeServicesTableLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeServicesTableLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + DxeServicesTableLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueUefiLib + EfiProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c new file mode 100644 index 0000000000..c078f41b41 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c @@ -0,0 +1,107 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DxeSmbusLib.c + +Abstract: + + Dxe Smbus Lib internal functions + +--*/ + +#include "DxeSmbusLibInternal.h" + +// +// Globle varible to cache pointer to Smbus protocol. +// +STATIC EFI_SMBUS_HC_PROTOCOL *mSmbus = NULL; + +/** + The constructor function caches the pointer to Smbus protocol. + + The constructor function locates Smbus protocol from protocol database. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmbusLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gEfiSmbusProtocolGuid, NULL, (VOID**) &mSmbus); + ASSERT_EFI_ERROR (Status); + ASSERT (mSmbus != NULL); + + return Status; +} + +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation.. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + RETURN_STATUS ReturnStatus; + EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress; + + SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress); + + ReturnStatus = mSmbus->Execute ( + mSmbus, + SmbusDeviceAddress, + SMBUS_LIB_COMMAND (SmBusAddress), + SmbusOperation, + SMBUS_LIB_PEC (SmBusAddress), + &Length, + Buffer + ); + if (Status != NULL) { + *Status = ReturnStatus; + } + + return Length; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf new file mode 100644 index 0000000000..a3819b20ea --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf @@ -0,0 +1,82 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# DxeSmbusLib.inf +# +# Abstract: +# +# Component description file for DxeSmbusLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueDxeSmbusLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + DxeSmbusLib.c + SmbusLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib + EfiProtocolLib + EdkFrameworkProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h new file mode 100644 index 0000000000..0b141bd0eb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h @@ -0,0 +1,67 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DxeSmbusLibInternal.h + +Abstract: + + Declarations of internal functions in DxeSmbusLib. + +--*/ + +#ifndef __DXE_SMBUS_LIB_INTERNAL_H__ +#define __DXE_SMBUS_LIB_INTERNAL_H__ + +#include "EdkIIGlueDxe.h" + +#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f) +#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff) +#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f) +#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0)) +#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT)) + +// +// Declaration for internal functions +// +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c new file mode 100644 index 0000000000..503d167fcc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c @@ -0,0 +1,475 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DxeSmbus.c + +Abstract: + + Dxe Smbus Lib Interfaces + +--*/ + +#include "DxeSmbusLibInternal.h" + +/** + Executes an SMBUS quick read command. + + Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickRead ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS quick write command. + + Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickWrite ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS receive byte command. + + Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + The byte received from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte received from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReceiveByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS send byte command. + + Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress. + The byte specified by Value is sent. + Only the SMBUS slave address field of SmBusAddress is required. Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to send. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusSendByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data byte command. + + Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 8-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReadDataByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS write data byte command. + + Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. + The 8-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusWriteDataByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data word command. + + Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT16 +EFIAPI +SmBusReadDataWord ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status); + + return Word; +} + +/** + Executes an SMBUS write data word command. + + Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT16 +EFIAPI +SmBusWriteDataWord ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Word = Value; + InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status); + + return Value; +} + +/** + Executes an SMBUS process call command. + + Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value returned by the process call command is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The 16-bit value returned by the process call command. + +**/ +UINT16 +EFIAPI +SmBusProcessCall ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status); + + return Value; +} + +/** + Executes an SMBUS read block command. + + Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Bytes are read from the SMBUS and stored in Buffer. + The number of bytes read is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is not zero, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes read. + +**/ +UINTN +EFIAPI +SmBusReadBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status); +} + +/** + Executes an SMBUS write block command. + + Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from Buffer. + The number of bytes written is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusWriteBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status); +} + +/** + Executes an SMBUS block process call command. + + Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If WriteBuffer is NULL, then ASSERT(). + If ReadBuffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. + @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusBlockProcessCall ( + IN UINTN SmBusAddress, + IN VOID *WriteBuffer, + OUT VOID *ReadBuffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (WriteBuffer != NULL); + ASSERT (ReadBuffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + // + // Assuming that ReadBuffer is large enough to save another memory copy. + // + ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length); + return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c new file mode 100644 index 0000000000..73ed44ffc3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c @@ -0,0 +1,181 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RuntimeLib.c + +Abstract: + + Runtime lib + +--*/ + +#include "..\RuntimeLibInternal.h" + +// +// Driver Lib Module Globals +// + +STATIC EFI_EVENT mEfiVirtualNotifyEvent; +STATIC BOOLEAN mEfiGoneVirtual = FALSE; +STATIC BOOLEAN mEfiAtRuntime = FALSE; +EFI_RUNTIME_SERVICES *mRT; + +/** + Set AtRuntime flag as TRUE after ExitBootServices + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +VOID +EFIAPI +RuntimeDriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Clear out BootService globals + // + gBS = NULL; + + mEfiAtRuntime = TRUE; +} + +/** + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +STATIC +VOID +EFIAPI +RuntimeLibVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + UINTN Index; + EFI_EVENT_NOTIFY ChildNotifyEventHandler; + + for (Index = 0; + _gDriverSetVirtualAddressMapEvent[Index] != NULL; + Index++) { + ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index]; + ChildNotifyEventHandler (Event, NULL); + } + + // + // Update global for Runtime Services Table and IO + // + EfiConvertPointer (0, (VOID **) &mRT); + + mEfiGoneVirtual = TRUE; +} + +/** + Intialize runtime Driver Lib if it has not yet been initialized. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. +**/ +EFI_STATUS +EFIAPI +RuntimeDriverLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + ASSERT (SystemTable != NULL); + mRT = SystemTable->RuntimeServices; + ASSERT (mRT != NULL); + + // + // Register SetVirtualAddressMap () notify function + // + ASSERT (gBS != NULL); + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + EFI_TPL_NOTIFY, + RuntimeLibVirtualNotifyEvent, + NULL, + &mEfiVirtualNotifyEvent + ); + + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + + @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully + @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all +**/ +EFI_STATUS +EFIAPI +RuntimeDriverLibDeconstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Close SetVirtualAddressMap () notify function + // + ASSERT (gBS != NULL); + Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + Return TRUE if ExitBootServices () has been called + + @retval TRUE If ExitBootServices () has been called +**/ +BOOLEAN +EFIAPI +EfiAtRuntime ( + VOID + ) +{ + return mEfiAtRuntime; +} + +/** + Return TRUE if SetVirtualAddressMap () has been called + + @retval TRUE If SetVirtualAddressMap () has been called +**/ +BOOLEAN +EFIAPI +EfiGoneVirtual ( + VOID + ) +{ + return mEfiGoneVirtual; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c new file mode 100644 index 0000000000..5528f84e50 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c @@ -0,0 +1,471 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RuntimeService.c + +Abstract: + + Runtime Lib + +--*/ + +#include "..\RuntimeLibInternal.h" + +VOID +EFIAPI +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Resets the entire platform. + +Arguments: + + ResetType - The type of reset to perform. + ResetStatus - The status code for the reset. + DataSize - The size, in bytes, of ResetData. + ResetData - A data buffer that includes a Null-terminated Unicode string, optionally + followed by additional binary data. + +Returns: + + None + +--*/ +{ + mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData); +} + +// +// The following functions hide the mRT local global from the call to +// runtime service in the EFI system table. +// +EFI_STATUS +EFIAPI +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device's + capabilities. + +Returns: + + Status code + +--*/ +{ + return mRT->GetTime (Time, Capabilities); +} + +EFI_STATUS +EFIAPI +EfiSetTime ( + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +{ + return mRT->SetTime (Time); +} + +EFI_STATUS +EFIAPI +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +{ + return mRT->GetWakeupTime (Enabled, Pending, Time); +} + +EFI_STATUS +EFIAPI +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +{ + return mRT->SetWakeupTime (Enable, Time); +} + + + + +EFI_STATUS +EFIAPI +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +/*++ + +Routine Description: + + Returns the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor's variable. + VendorGuid - A unique identifier for the vendor. + Attributes - If not NULL, a pointer to the memory location to return the + attributes bitmask for the variable. + DataSize - On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + Data - The buffer to return the contents of the variable. + +Returns: + + Status code + +--*/ +{ + return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + +EFI_STATUS +EFIAPI +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +/*++ + +Routine Description: + + Enumerates the current variable names. + +Arguments: + + VariableNameSize - The size of the VariableName buffer. + VariableName - On input, supplies the last VariableName that was returned + by GetNextVariableName(). + On output, returns the Nullterminated Unicode string of the + current variable. + VendorGuid - On input, supplies the last VendorGuid that was returned by + GetNextVariableName(). + On output, returns the VendorGuid of the current variable. + +Returns: + + Status code + +--*/ +{ + return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid); +} + +EFI_STATUS +EFIAPI +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ) +/*++ + +Routine Description: + + Sets the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor's variable. + VendorGuid - A unique identifier for the vendor. + Attributes - Attributes bitmask to set for the variable. + DataSize - The size in bytes of the Data buffer. + Data - The contents for the variable. + +Returns: + + Status code + +--*/ +{ + return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + +EFI_STATUS +EFIAPI +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Returns the next high 32 bits of the platform's monotonic counter. + +Arguments: + + HighCount - Pointer to returned value. + +Returns: + + Status code + +--*/ +{ + return mRT->GetNextHighMonotonicCount (HighCount); +} + +EFI_STATUS +EFIAPI +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID **Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return mRT->ConvertPointer (DebugDisposition, Address); +} + +EFI_STATUS +EFIAPI +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT LIST_ENTRY *ListHead + ) +/*++ + +Routine Description: + + Conver the standard Lib double linked list to a virtual mapping. + +Arguments: + + DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API) + + ListHead - Head of linked list to convert + +Returns: + + EFI_SUCCESS + +--*/ +{ + LIST_ENTRY *Link; + LIST_ENTRY *NextLink; + + // + // Convert all the ForwardLink & BackLink pointers in the list + // + Link = ListHead; + do { + NextLink = Link->ForwardLink; + + EfiConvertPointer ( + Link->ForwardLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->ForwardLink + ); + + EfiConvertPointer ( + Link->BackLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->BackLink + ); + + Link = NextLink; + } while (Link != ListHead); + return EFI_SUCCESS; +} + + +/** + Change the runtime addressing mode of EFI firmware from physical to virtual. + + @param MemoryMapSize The size in bytes of VirtualMap. + @param DescriptorSize The size in bytes of an entry in the VirtualMap. + @param DescriptorVersion The version of the structure entries in VirtualMap. + @param VirtualMap An array of memory descriptors which contain new virtual + address mapping information for all runtime ranges. Type + EFI_MEMORY_DESCRIPTOR is defined in the + GetMemoryMap() function description. + + @retval EFI_SUCCESS The virtual address map has been applied. + @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in + virtual address mapped mode. + @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is + invalid. + @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory + map that requires a mapping. + @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found + in the memory map. +**/ +EFI_STATUS +EFIAPI +EfiSetVirtualAddressMap ( + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize, + IN UINT32 DescriptorVersion, + IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap + ) +{ + return mRT->SetVirtualAddressMap ( + MemoryMapSize, + DescriptorSize, + DescriptorVersion, + (EFI_MEMORY_DESCRIPTOR *) VirtualMap + ); +} + + +EFI_STATUS +EFIAPI +EfiUpdateCapsule ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + return mRT->UpdateCapsule ( + CapsuleHeaderArray, + CapsuleCount, + ScatterGatherList + ); +#else + return EFI_UNSUPPORTED; +#endif +} + +EFI_STATUS +EFIAPI +EfiQueryCapsuleCapabilities ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + OUT UINT64 *MaximumCapsuleSize, + OUT EFI_RESET_TYPE *ResetType + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + return mRT->QueryCapsuleCapabilities ( + CapsuleHeaderArray, + CapsuleCount, + MaximumCapsuleSize, + ResetType + ); +#else + return EFI_UNSUPPORTED; +#endif +} + + +EFI_STATUS +EFIAPI +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) +{ +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + return mRT->QueryVariableInfo ( + Attributes, + MaximumVariableStorageSize, + RemainingVariableStorageSize, + MaximumVariableSize + ); +#else + return EFI_UNSUPPORTED; +#endif +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf new file mode 100644 index 0000000000..aa4f6acf01 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf @@ -0,0 +1,96 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkDxeRuntimeDriverLib.inf +# +# Abstract: +# +# Component description file for EdkDxeRuntimeDriverLib. +# This is the one whose name is EdkUefiRuntimeLib in EdkModulePkg in EdkII. +# For backward compatibility, we don't change the library name. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueEdkDxeRuntimeDriverLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + Common\RuntimeLib.c + Common\RuntimeService.c + +[sources.x64] + Common\RuntimeLib.c + Common\RuntimeService.c + +[sources.ipf] + Ipf\RuntimeLib.c + Ipf\RuntimeService.c + +[sources.ebc] + Common\RuntimeLib.c + Common\RuntimeService.c + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueUefiLib + EdkIIGlueBaseLib + EdkIIGlueUefiBootServicesTableLib +# +# R8.x Library +# + EfiProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[libraries.ipf] + EdkIIGlueEdkDxeSalLib + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c new file mode 100644 index 0000000000..9f262301e7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c @@ -0,0 +1,235 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RuntimeLib.c + +Abstract: + + Runtime lib + +--*/ + +#include "..\RuntimeLibInternal.h" + +// +// Driver Lib Module Globals +// +static EFI_EVENT mEfiVirtualNotifyEvent; +EFI_RUNTIME_SERVICES *mRT; + +VOID +EFIAPI +RuntimeDriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Set AtRuntime flag as TRUE after ExitBootServices + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + if (EfiAtRuntime()) { + return; + } +} + +VOID +EFIAPI +RuntimeLibVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + UINTN Index; + EFI_EVENT_NOTIFY ChildNotifyEventHandler; + + for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) { + ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index]; + ChildNotifyEventHandler (Event, NULL); + } + + // + // Update global for Runtime Services Table + // + EfiConvertPointer (0, (VOID **) &mRT); +} + +EFI_STATUS +EFIAPI +RuntimeDriverLibConstruct ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + GoVirtualChildEvent - Caller can register a virtual notification event. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + + mRT = SystemTable->RuntimeServices; + + // + // Register SetVirtualAddressMap () notify function + // + if (_gDriverSetVirtualAddressMapEvent[0] != NULL) { + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + EFI_TPL_NOTIFY, + RuntimeLibVirtualNotifyEvent, + NULL, + &mEfiVirtualNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +RuntimeDriverLibDeconstruct ( + VOID + ) +/*++ + +Routine Description: + + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully + EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all + +--*/ +{ + EFI_STATUS Status; + + // + // Close SetVirtualAddressMap () notify function + // + if (_gDriverSetVirtualAddressMapEvent[0] != NULL) { + Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} + +BOOLEAN +EFIAPI +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if ExitBootService () has been called + +Arguments: + NONE + +Returns: + TRUE - If ExitBootService () has been called + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; + SAL_RETURN_REGS ReturnReg; + + ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0); + + return (BOOLEAN) (ReturnReg.r9 == 1); +} + +BOOLEAN +EFIAPI +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; + SAL_RETURN_REGS ReturnReg; + + ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0); + + return (BOOLEAN) (ReturnReg.r9 == 1); +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c new file mode 100644 index 0000000000..d4010b264b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c @@ -0,0 +1,527 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RuntimeService.c + +Abstract: + + Runtime Lib + +--*/ + +#include "..\RuntimeLibInternal.h" + +VOID +EFIAPI +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Resets the entire platform. + +Arguments: + + ResetType - The type of reset to perform. + ResetStatus - The status code for the reset. + DataSize - The size, in bytes, of ResetData. + ResetData - A data buffer that includes a Null-terminated Unicode string, optionally + followed by additional binary data. + +Returns: + + None + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID; + + EfiCallEsalService ( + &Guid, + ResetSystem, + (UINT64) ResetType, + (UINT64) ResetStatus, + (UINT64) DataSize, + (UINT64) ResetData, + 0, + 0, + 0 + ); +} + + +// +// The following functions hide the mRT local global from the call to +// runtime service in the EFI system table. +// +EFI_STATUS +EFIAPI +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device's + capabilities. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, GetTime, (UINT64) Time, (UINT64) Capabilities, 0, 0, 0, 0, 0); + return ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiSetTime ( + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, SetTime, (UINT64) Time, 0, 0, 0, 0, 0, 0); + return ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, GetWakeupTime, (UINT64) Enabled, (UINT64) Pending, (UINT64) Time, 0, 0, 0, 0); + return ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, SetWakeupTime, (UINT64) Enable, (UINT64) Time, 0, 0, 0, 0, 0); + return ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +/*++ + +Routine Description: + + Returns the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor's variable. + VendorGuid - A unique identifier for the vendor. + Attributes - If not NULL, a pointer to the memory location to return the + attributes bitmask for the variable. + DataSize - On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + Data - The buffer to return the contents of the variable. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + EsalGetVariable, + (UINT64) VariableName, + (UINT64) VendorGuid, + (UINT64) Attributes, + (UINT64) DataSize, + (UINT64) Data, + 0, + 0 + ); + return (EFI_STATUS) ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +/*++ + +Routine Description: + + Enumerates the current variable names. + +Arguments: + + VariableNameSize - The size of the VariableName buffer. + VariableName - On input, supplies the last VariableName that was returned + by GetNextVariableName(). + On output, returns the Nullterminated Unicode string of the + current variable. + VendorGuid - On input, supplies the last VendorGuid that was returned by + GetNextVariableName(). + On output, returns the VendorGuid of the current variable. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + EsalGetNextVariableName, + (UINT64) VariableNameSize, + (UINT64) VariableName, + (UINT64) VendorGuid, + 0, + 0, + 0, + 0 + ); + return (EFI_STATUS) ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ) +/*++ + +Routine Description: + + Sets the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor's variable. + VendorGuid - A unique identifier for the vendor. + Attributes - Attributes bitmask to set for the variable. + DataSize - The size in bytes of the Data buffer. + Data - The contents for the variable. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + EsalSetVariable, + (UINT64) VariableName, + (UINT64) VendorGuid, + (UINT64) Attributes, + (UINT64) DataSize, + (UINT64) Data, + 0, + 0 + ); + return (EFI_STATUS) ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Returns the next high 32 bits of the platform's monotonic counter. + +Arguments: + + HighCount - Pointer to returned value. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, GetNextHighMonotonicCount, (UINT64) HighCount, 0, 0, 0, 0, 0, 0); + return (EFI_STATUS) ReturnReg.Status; +} + +EFI_STATUS +EFIAPI +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID **Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return mRT->ConvertPointer (DebugDisposition, Address); +} + +EFI_STATUS +EFIAPI +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT LIST_ENTRY *ListHead + ) +/*++ + +Routine Description: + + Conver the standard Lib double linked list to a virtual mapping. + +Arguments: + + DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API) + + ListHead - Head of linked list to convert + +Returns: + + EFI_SUCCESS + +--*/ +{ + LIST_ENTRY *Link; + LIST_ENTRY *NextLink; + + // + // Convert all the ForwardLink & BackLink pointers in the list + // + Link = ListHead; + do { + NextLink = Link->ForwardLink; + + EfiConvertPointer ( + Link->ForwardLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->ForwardLink + ); + + EfiConvertPointer ( + Link->BackLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->BackLink + ); + + Link = NextLink; + } while (Link != ListHead); + return EFI_SUCCESS; +} + + +/** + Change the runtime addressing mode of EFI firmware from physical to virtual. + + @param MemoryMapSize The size in bytes of VirtualMap. + @param DescriptorSize The size in bytes of an entry in the VirtualMap. + @param DescriptorVersion The version of the structure entries in VirtualMap. + @param VirtualMap An array of memory descriptors which contain new virtual + address mapping information for all runtime ranges. Type + EFI_MEMORY_DESCRIPTOR is defined in the + GetMemoryMap() function description. + + @retval EFI_SUCCESS The virtual address map has been applied. + @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in + virtual address mapped mode. + @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is + invalid. + @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory + map that requires a mapping. + @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found + in the memory map. +**/ +EFI_STATUS +EFIAPI +EfiSetVirtualAddressMap ( + IN UINTN MemoryMapSize, + IN UINTN DescriptorSize, + IN UINT32 DescriptorVersion, + IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap + ) +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + SetVirtualAddress, + (UINT64) MemoryMapSize, + (UINT64) DescriptorSize, + (UINT64) DescriptorVersion, + (UINT64) VirtualMap, + 0, + 0, + 0 + ); + + return ReturnReg.Status; +} + + +EFI_STATUS +EFIAPI +EfiUpdateCapsule ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +EFI_STATUS +EFIAPI +EfiQueryCapsuleCapabilities ( + IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray, + IN UINTN CapsuleCount, + OUT UINT64 *MaximumCapsuleSize, + OUT EFI_RESET_TYPE *ResetType + ) +{ + return EFI_UNSUPPORTED; +} + + +EFI_STATUS +EFIAPI +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h new file mode 100644 index 0000000000..925fc7b07d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + RuntimeLibInternal.h + +Abstract: + + Runtime Lib internal header file + +--*/ + +#ifndef __RUNTIMELIBINTERNAL_H__ +#define __RUNTIMELIBINTERNAL_H__ + +#include "EdkIIGlueDxe.h" + +extern EFI_RUNTIME_SERVICES *mRT; + +#endif //__RUNTIMELIBINTERNAL_H__ diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/EdkDxeSalLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/EdkDxeSalLib.inf new file mode 100644 index 0000000000..fabb4edb2f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/EdkDxeSalLib.inf @@ -0,0 +1,83 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkDxeSalLib.inf +# +# Abstract: +# +# SAL library for BS/RT drivers +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueEdkDxeSalLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + Ipf/EsalServiceLib.c + Ipf/AsmEsalServiceLib.s + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + +[libraries.ia32] + +[libraries.x64] + +[libraries.ipf] + EdkIIGlueBaseLib + EdkIIGlueUefiBootServicesTableLib + EdkProtocolLib + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s new file mode 100644 index 0000000000..c5cb881fe2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s @@ -0,0 +1,149 @@ +//++ +// Copyright (c) 2006, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// EsalLib.s +// +// Abstract: +// +// +// Revision History: +// +//-- + +.file "EsalLib.s" + +#include "IpfMacro.i" + +// +// Exports +// +.globl GetEsalEntryPoint + + +//----------------------------------------------------------------------------- +//++ +// GetEsalEntryPoint +// +// Return Esal global and PSR register. +// +// On Entry : +// +// +// Return Value: +// r8 = EFI_SAL_SUCCESS +// r9 = Physical Plabel +// r10 = Virtual Plabel +// r11 = psr +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (GetEsalEntryPoint) + + NESTED_SETUP (0,8,0,0) + +EsalCalcStart: + mov r8 = ip;; + add r8 = (EsalEntryPoint - EsalCalcStart), r8;; + mov r9 = r8;; + add r10 = 0x10, r8;; + mov r11 = psr;; + mov r8 = r0;; + + NESTED_RETURN + +PROCEDURE_EXIT (GetEsalEntryPoint) + + + + + +//----------------------------------------------------------------------------- +//++ +// SetEsalPhysicalEntryPoint +// +// Set the dispatcher entry point +// +// On Entry: +// in0 = Physical address of Esal Dispatcher +// in1 = Physical GP +// +// Return Value: +// r8 = EFI_SAL_SUCCESS +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (SetEsalPhysicalEntryPoint) + + NESTED_SETUP (2,8,0,0) + +EsalCalcStart1: + mov r8 = ip;; + add r8 = (EsalEntryPoint - EsalCalcStart1), r8;; + st8 [r8] = in0;; + add r8 = 0x08, r8;; + st8 [r8] = in1;; + mov r8 = r0;; + + NESTED_RETURN + +PROCEDURE_EXIT (SetEsalPhysicalEntryPoint) + + +//----------------------------------------------------------------------------- +//++ +// SetEsalVirtualEntryPoint +// +// Register physical address of Esal globals. +// +// On Entry : +// in0 = Virtual address of Esal Dispatcher +// in1 = Virtual GP +// +// Return Value: +// r8 = EFI_SAL_ERROR +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (SetEsalVirtualEntryPoint) + + NESTED_SETUP (2,8,0,0) + +EsalCalcStart2: + mov r8 = ip;; + add r8 = (EsalEntryPoint - EsalCalcStart2), r8;; + add r8 = 0x10, r8;; + st8 [r8] = in0;; + add r8 = 0x08, r8;; + st8 [r8] = in1;; + mov r8 = r0;; + + NESTED_RETURN + +PROCEDURE_EXIT (SetEsalVirtualEntryPoint) + + + + +.align 32 +EsalEntryPoint: + data8 0 // Physical Entry + data8 0 // GP + data8 0 // Virtual Entry + data8 0 // GP + + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c new file mode 100644 index 0000000000..377ac79a62 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c @@ -0,0 +1,288 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EsalServiceLib.c + +Abstract: + +--*/ + +#include + +#include "EdkIIGlueDxe.h" + +EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService = NULL; +EFI_PLABEL mPlabel; + +EFI_STATUS +EFIAPI +DxeSalLibInitialize ( + VOID + ) +{ + EFI_PLABEL *Plabel; + EFI_STATUS Status; + + if (mEsalBootService != NULL) { + return EFI_SUCCESS; + } + + // + // The protocol contains a function pointer, which is an indirect procedure call. + // An indirect procedure call goes through a plabel, and pointer to a function is + // a pointer to a plabel. To implement indirect procedure calls that can work in + // both physical and virtual mode, two plabels are required (one physical and one + // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it + // away. We cache it in a module global, so we can register the vitrual version. + // + Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService); + if (EFI_ERROR (Status)) { + mEsalBootService = NULL; + return EFI_SUCCESS; + } + + Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc; + + mPlabel.EntryPoint = Plabel->EntryPoint; + mPlabel.GP = Plabel->GP; + SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +DxeSalLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return DxeSalLibInitialize (); +} + +VOID +EFIAPI +DxeSalVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Fixup virtual address pointer of label. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + EfiConvertPointer (0x0, (VOID **) &mPlabel.EntryPoint); + EfiConvertPointer (EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP); + + SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP); +} + +EFI_STATUS +EFIAPI +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + Register ESAL Class Function and it's asociated global. + This function is boot service only! + +Arguments: + FunctionId - ID of function to register + ClassGuid - GUID of function class + Function - Function to register under ClassGuid/FunctionId pair + ModuleGlobal - Module global for Function. + +Returns: + EFI_SUCCESS - If ClassGuid/FunctionId Function was registered. + +--*/ +{ + DxeSalLibInitialize (); + return mEsalBootService->AddExtendedSalProc ( + mEsalBootService, + ClassGuid, + FunctionId, + Function, + ModuleGlobal + ); +} + +EFI_STATUS +EFIAPI +RegisterEsalClass ( + IN EFI_GUID *ClassGuid, + IN VOID *ModuleGlobal, + ... + ) +/*++ + +Routine Description: + + Register ESAL Class and it's asociated global. + This function is boot service only! + +Arguments: + ClassGuid - GUID of function class + ModuleGlobal - Module global for Function. + ... - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL + indicates the end of the list. + +Returns: + EFI_SUCCESS - All members of ClassGuid registered + +--*/ +{ + VA_LIST Args; + EFI_STATUS Status; + SAL_INTERNAL_EXTENDED_SAL_PROC Function; + UINT64 FunctionId; + EFI_HANDLE NewHandle; + + VA_START (Args, ModuleGlobal); + + Status = EFI_SUCCESS; + while (!EFI_ERROR (Status)) { + Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC); + if (Function == NULL) { + break; + } + + FunctionId = VA_ARG (Args, UINT64); + + Status = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal); + } + + if (EFI_ERROR (Status)) { + return Status; + } + + NewHandle = NULL; + return gBS->InstallProtocolInterface ( + &NewHandle, + ClassGuid, + EFI_NATIVE_INTERFACE, + NULL + ); +} + +SAL_RETURN_REGS +EFIAPI +EfiCallEsalService ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ) +/*++ + +Routine Description: + + Call module that is not linked direclty to this module. This code is IP + relative and hides the binding issues of virtual or physical calling. The + function that gets dispatched has extra arguments that include the registered + module global and a boolean flag to indicate if the system is in virutal mode. + +Arguments: + ClassGuid - GUID of function + FunctionId - Function in ClassGuid to call + Arg2 - Argument 2 ClassGuid/FunctionId defined + Arg3 - Argument 3 ClassGuid/FunctionId defined + Arg4 - Argument 4 ClassGuid/FunctionId defined + Arg5 - Argument 5 ClassGuid/FunctionId defined + Arg6 - Argument 6 ClassGuid/FunctionId defined + Arg7 - Argument 7 ClassGuid/FunctionId defined + Arg8 - Argument 8 ClassGuid/FunctionId defined + +Returns: + Status of ClassGuid/FuncitonId + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + SAL_EXTENDED_SAL_PROC EsalProc; + + ReturnReg = GetEsalEntryPoint (); + if (ReturnReg.Status != EFI_SAL_SUCCESS) { + return ReturnReg; + } + + // + // Look at the physical mode ESAL entry point to determine of the ESAL entry point has been initialized + // + if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) { + // + // Both the function ponter and the GP value are zero, so attempt to initialize the ESAL Entry Point + // + DxeSalLibInitialize (); + ReturnReg = GetEsalEntryPoint (); + if (ReturnReg.Status != EFI_SAL_SUCCESS) { + return ReturnReg; + } + if (*(UINT64 *)ReturnReg.r9 == 0 && *(UINT64 *)(ReturnReg.r9 + 8) == 0) { + // + // The ESAL Entry Point could not be initialized + // + ReturnReg.Status = EFI_SAL_ERROR; + return ReturnReg; + } + } + + if (ReturnReg.r11 & PSR_IT_MASK) { + // + // Virtual mode plabel to entry point + // + EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r10; + } else { + // + // Physical mode plabel to entry point + // + EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r9; + } + + return EsalProc ( + ClassGuid, + FunctionId, + Arg2, + Arg3, + Arg4, + Arg5, + Arg6, + Arg7, + Arg8 + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c new file mode 100644 index 0000000000..e0f7be081b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c @@ -0,0 +1,70 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + HiiLib.c + +Abstract: + + HII Library implementation that uses DXE protocols and services. + +--*/ + +#include "EdkIIGlueDxe.h" + +/** + This function allocates pool for an EFI_HII_PACKAGES structure + with enough space for the variable argument list of package pointers. + The allocated structure is initialized using NumberOfPackages, Guid, + and the variable length argument list of package pointers. + + @param NumberOfPackages The number of HII packages to prepare. + @param Guid Package GUID. + + @return The allocated and initialized packages. + +**/ +EFI_HII_PACKAGES * +EFIAPI +GluePreparePackages ( + IN UINTN NumberOfPackages, + IN CONST EFI_GUID *Guid OPTIONAL, + ... + ) +{ + VA_LIST Args; + EFI_HII_PACKAGES *HiiPackages; + VOID **Package; + UINTN Index; + + ASSERT (NumberOfPackages > 0); + + HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *)); + ASSERT (HiiPackages != NULL); + + HiiPackages->GuidId = (EFI_GUID *) Guid; + HiiPackages->NumberOfPackages = NumberOfPackages; + Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES)); + + VA_START (Args, Guid); + + for (Index = 0; Index < NumberOfPackages; Index++) { + *Package = VA_ARG (Args, VOID *); + Package++; + } + + VA_END (Args); + + return HiiPackages; + +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf new file mode 100644 index 0000000000..102cd8693d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# HiiLib.inf +# +# Abstract: +# +# Component description file for HiiLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueHiiLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + HiiLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueDxeMemoryAllocationLib + EfiProtocolLib + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c new file mode 100644 index 0000000000..d21e5174a3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c @@ -0,0 +1,296 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + DebugLib.c + +Abstract: + + Debug Library that fowards all messages to ReportStatusCode() + +--*/ + +#include "EdkIIGlueDxe.h" + +/** + + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ) +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)]; + EFI_DEBUG_INFO *DebugInfo; + UINTN TotalSize; + UINTN Index; + VA_LIST Marker; + UINT64 *ArgumentPointer; + + // + // If Format is NULL, then ASSERT(). + // + ASSERT (Format != NULL); + + // + // Check driver Debug Level value and global debug level + // + if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) { + return; + } + + TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1; + if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { + return; + } + + // + // Then EFI_DEBUG_INFO + // + DebugInfo = (EFI_DEBUG_INFO *)Buffer; + DebugInfo->ErrorLevel = (UINT32)ErrorLevel; + + // + // 256 byte mini Var Arg stack. That is followed by the format string. + // + VA_START (Marker, Format); + for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) { + WriteUnaligned64(ArgumentPointer, VA_ARG (Marker, UINT64)); + } + VA_END (Marker); + AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format); + + REPORT_STATUS_CODE_EX ( + EFI_DEBUG_CODE, + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED), + 0, + NULL, + &gEfiStatusCodeDataTypeDebugGuid, + DebugInfo, + TotalSize + ); +} + + +/** + + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. + + Print a message of the form "ASSERT (): \n" + to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of + PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if + DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. + + If FileName is NULL, then a string of "(NULL) Filename" is printed. + + If Description is NULL, then a string of "(NULL) Description" is printed. + + @param FileName Pointer to the name of the source file that generated the assert condition. + @param LineNumber The line number in the source file that generated the assert condition + @param Description Pointer to the description of the assert condition. + +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)]; + EFI_DEBUG_ASSERT_DATA *AssertData; + UINTN TotalSize; + CHAR8 *Temp; + UINTN FileNameLength; + UINTN DescriptionLength; + + // + // Make sure it will all fit in the passed in buffer + // + FileNameLength = AsciiStrLen (FileName); + DescriptionLength = AsciiStrLen (Description); + TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameLength + 1 + DescriptionLength + 1; + if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) { + // + // Fill in EFI_DEBUG_ASSERT_DATA + // + AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer; + AssertData->LineNumber = (UINT32)LineNumber; + + // + // Copy Ascii FileName including NULL. + // + Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName); + + // + // Copy Ascii Description + // + AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description); + + REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), + AssertData, + TotalSize + ); + } + + // + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings + // + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { + CpuBreakpoint (); + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { + CpuDeadLoop (); + } +} + + +/** + + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. + + This function fills Length bytes of Buffer with the value specified by + PcdDebugClearMemoryValue, and returns Buffer. + + If Buffer is NULL, then ASSERT(). + + If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + + @return Buffer + +**/ +VOID * +EFIAPI +DebugClearMemory ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + // + // If Buffer is NULL, then ASSERT(). + // + ASSERT (Buffer != NULL); + + // + // SetMem() checks for the the ASSERT() condition on Length and returns Buffer + // + return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); +} + + +/** + + Returns TRUE if ASSERT() macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugAssertEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugPrintEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} + + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +DebugClearMemoryEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf new file mode 100644 index 0000000000..270f7f61b4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf @@ -0,0 +1,89 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiDxeDebugLibReportStatusCode.inf +# +# Abstract: +# +# Component description file for PeiDxeDebugLibReportStatusCode. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiDxeDebugLibReportStatusCode +COMPONENT_TYPE = LIBRARY + +[sources.common] + DebugLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib +# +# R8.x +# + EdkFrameworkGuidLib +# +# +# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf +# + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf new file mode 100644 index 0000000000..9b346dd00e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf @@ -0,0 +1,83 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiDxePostCodeLibReportStatusCode.inf +# +# Abstract: +# +# Component description file for PeiDxePostCodeLibReportStatusCode. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiDxePostCodeLibReportStatusCode +COMPONENT_TYPE = LIBRARY + +[sources.common] + PostCode.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] +# +# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf +# + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c new file mode 100644 index 0000000000..62fde35544 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c @@ -0,0 +1,160 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PostCode.c + +Abstract: + + Post Code Lib + +--*/ + +#include "EdkIIGlueDxe.h" + +/** + Converts POST code value to status code value. + + This macro converts the post code to status code value. Bits 0..4 of PostCode + are mapped to bits 16..20 of status code value, and bits 5..7 of PostCode are mapped to bits + 24..26 of status code value. + + @param PostCode POST code value. + + @return The converted status code value. + +**/ +#define POST_CODE_TO_STATUS_CODE_VALUE(PostCode) \ + ((EFI_STATUS_CODE_VALUE) (((PostCode & 0x1f) << 16) | ((PostCode & 0x3) << 19))) + +/** + Sends an 32-bit value to a POST card. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + Some implementations of this library function may perform I/O operations + directly to a POST card device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventually + display the 32-bit value on the status reporting device. + + PostCode() must actively prevent recursion. If PostCode() is called while + processing another any other Report Status Code Library function, then + PostCode() must return Value immediately. + + @param Value The 32-bit value to write to the POST card. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCode ( + IN UINT32 Value + ) +{ + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, POST_CODE_TO_STATUS_CODE_VALUE (Value)); + return Value; +} + + +/** + Sends an 32-bit value to a POST and associated ASCII string. + + Sends the 32-bit value specified by Value to a POST card, and returns Value. + If Description is not NULL, then the ASCII string specified by Description is + also passed to the handler that displays the POST card value. Some + implementations of this library function may perform I/O operations directly + to a POST card device. Other implementations may send Value to ReportStatusCode(), + and the status code reporting mechanism will eventually display the 32-bit + value on the status reporting device. + + PostCodeWithDescription()must actively prevent recursion. If + PostCodeWithDescription() is called while processing another any other Report + Status Code Library function, then PostCodeWithDescription() must return Value + immediately. + + @param Value The 32-bit value to write to the POST card. + @param Description Pointer to an ASCII string that is a description of the + POST code value. This is an optional parameter that may + be NULL. + + @return Value + +**/ +UINT32 +EFIAPI +GluePostCodeWithDescription ( + IN UINT32 Value, + IN CONST CHAR8 *Description OPTIONAL + ) +{ + if (Description == NULL) { + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + POST_CODE_TO_STATUS_CODE_VALUE (Value) + ); + } else { + REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + EFI_PROGRESS_CODE, + POST_CODE_TO_STATUS_CODE_VALUE (Value), + Description, + AsciiStrSize (Description) + ); + } + + return Value; +} + + +/** + Returns TRUE if POST Codes are enabled. + + This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if POST code descriptions are enabled. + + This function returns TRUE if the + POST_CODE_PROPERTY_POST_CODE_ENABLED bit of + PcdPostCodePropertyMask is set. Otherwise FALSE is returned. + + @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is set. + @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED + bit of PcdPostCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GluePostCodeDescriptionEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c new file mode 100644 index 0000000000..55b7242ced --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c @@ -0,0 +1,573 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + HobLib.c + +Abstract: + + HOB Library. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +{ + EFI_STATUS Status; + VOID *HobList; + + Status = PeiServicesGetHobList (&HobList); + ASSERT_EFI_ERROR (Status); + ASSERT (HobList != NULL); + + return HobList; +} + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + ASSERT (HobStart != NULL); + + Hob.Raw = (UINT8 *) HobStart; + // + // Parse the HOB list until end of list or matching type is found. + // + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == Type) { + return Hob.Raw; + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + return NULL; +} + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16 Type + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextHob (Type, HobList); +} + +/** + This function searches the first instance of a HOB from the starting HOB pointer. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + If Guid is NULL, then ASSERT(). + If HobStart is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + @param HobStart A pointer to a Guid. + + @return The next instance of the matched GUID HOB from the starting HOB. + +**/ +VOID * +EFIAPI +GlueGetNextGuidHob ( + IN CONST EFI_GUID *Guid, + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS GuidHob; + + GuidHob.Raw = (UINT8 *) HobStart; + while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) { + if (CompareGuid (Guid, &GuidHob.Guid->Name)) { + break; + } + GuidHob.Raw = GET_NEXT_HOB (GuidHob); + } + return GuidHob.Raw; +} + +/** + This function searches the first instance of a HOB among the whole HOB list. + Such HOB should satisfy two conditions: + its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. + If there does not exist such HOB from the starting HOB pointer, it will return NULL. + Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () + to extract the data section and its size info respectively. + If Guid is NULL, then ASSERT(). + + @param Guid The GUID to match with in the HOB list. + + @return The first instance of the matched GUID HOB among the whole HOB list. + +**/ +VOID * +EFIAPI +GlueGetFirstGuidHob ( + IN CONST EFI_GUID *Guid + ) +{ + VOID *HobList; + + HobList = GetHobList (); + return GetNextGuidHob (Guid, HobList); +} + +/** + Get the Boot Mode from the HOB list. + + This function returns the system boot mode information from the + PHIT HOB in HOB list. + + @param VOID + + @return The Boot Mode. + +**/ +EFI_BOOT_MODE +EFIAPI +GetBootModeHob ( + VOID + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + + Status = PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + return BootMode; +} + +/** + Adds a new HOB to the HOB List. + + This internal function enables PEIMs to create various types of HOBs. + + @param Type Type of the new HOB. + @param Length Length of the new HOB to allocate. + + @return The address of new HOB. + +**/ +STATIC +VOID * +InternalPeiCreateHob ( + IN UINT16 Type, + IN UINT16 Length + ) +{ + EFI_STATUS Status; + VOID *Hob; + + Status = PeiServicesCreateHob (Type, Length, &Hob); + // + // Assume the process of HOB building is always successful. + // + ASSERT_EFI_ERROR (Status); + return Hob; +} + +/** + Builds a HOB for a loaded PE32 module. + + This function builds a HOB for a loaded PE32 module. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If ModuleName is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + + @param ModuleName The GUID File Name of the module. + @param MemoryAllocationModule The 64 bit physical address of the module. + @param ModuleLength The length of the module in bytes. + @param EntryPoint The 64 bit physical address of the module's entry point. + +**/ +VOID +EFIAPI +GlueBuildModuleHob ( + IN CONST EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +{ + EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE)); + + CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid); + Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; + Hob->MemoryAllocationHeader.MemoryLength = ModuleLength; + Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved)); + + CopyGuid (&Hob->ModuleName, ModuleName); + Hob->EntryPoint = EntryPoint; +} + +/** + Builds a HOB that describes a chunk of system memory. + + This function builds a HOB that describes a chunk of system memory. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param ResourceType The type of resource described by this HOB. + @param ResourceAttribute The resource attributes of the memory described by this HOB. + @param PhysicalStart The 64 bit physical address of memory described by this HOB. + @param NumberOfBytes The length of the memory described by this HOB in bytes. + +**/ +VOID +EFIAPI +BuildResourceDescriptorHob ( + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +{ + EFI_HOB_RESOURCE_DESCRIPTOR *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR)); + + Hob->ResourceType = ResourceType; + Hob->ResourceAttribute = ResourceAttribute; + Hob->PhysicalStart = PhysicalStart; + Hob->ResourceLength = NumberOfBytes; +} + +/** + Builds a GUID HOB with a certain data length. + + This function builds a customized HOB tagged with a GUID for identification + and returns the start address of GUID HOB data so that caller can fill the customized data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidHob ( + IN CONST EFI_GUID *Guid, + IN UINTN DataLength + ) +{ + EFI_HOB_GUID_TYPE *Hob; + + // + // Make sure that data length is not too long. + // + ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE))); + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength)); + CopyGuid (&Hob->Name, Guid); + return Hob + 1; +} + +/** + Copies a data buffer to a newly-built HOB. + + This function builds a customized HOB tagged with a GUID for identification, + copies the input data to the HOB data field and returns the start address of the GUID HOB data. + The HOB Header and Name field is already stripped. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If Guid is NULL, then ASSERT(). + If Data is NULL and DataLength > 0, then ASSERT(). + If there is no additional space for HOB creation, then ASSERT(). + If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). + + @param Guid The GUID to tag the customized HOB. + @param Data The data to be copied into the data field of the GUID HOB. + @param DataLength The size of the data payload for the GUID HOB. + + @return The start address of GUID HOB data. + +**/ +VOID * +EFIAPI +BuildGuidDataHob ( + IN CONST EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +{ + VOID *HobData; + + ASSERT (Data != NULL || DataLength == 0); + + HobData = BuildGuidHob (Guid, DataLength); + + return CopyMem (HobData, Data, DataLength); +} + +/** + Builds a Firmware Volume HOB. + + This function builds a Firmware Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Firmware Volume. + @param Length The size of the Firmware Volume in bytes. + +**/ +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_HOB_FIRMWARE_VOLUME *Hob; + + // + // Check FV Signature + // + ASSERT (((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE); + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME)); + + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; +} + +/** + Builds a Capsule Volume HOB. + + This function builds a Capsule Volume HOB. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The base address of the Capsule Volume. + @param Length The size of the Capsule Volume in bytes. + +**/ +VOID +EFIAPI +BuildCvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_HOB_CAPSULE_VOLUME *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, sizeof (EFI_HOB_CAPSULE_VOLUME)); + + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; +} + +/** + Builds a HOB for the CPU. + + This function builds a HOB for the CPU. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param SizeOfMemorySpace The maximum physical memory addressability of the processor. + @param SizeOfIoSpace The maximum physical I/O addressability of the processor. + +**/ +VOID +EFIAPI +BuildCpuHob ( + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +{ + EFI_HOB_CPU *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU)); + + Hob->SizeOfMemorySpace = SizeOfMemorySpace; + Hob->SizeOfIoSpace = SizeOfIoSpace; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); +} + +/** + Builds a HOB for the Stack. + + This function builds a HOB for the stack. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the Stack. + @param Length The length of the stack in bytes. + +**/ +VOID +EFIAPI +BuildStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_HOB_MEMORY_ALLOCATION_STACK *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK)); + + CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid); + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = EfiConventionalMemory; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); +} + +/** + Builds a HOB for the BSP store. + + This function builds a HOB for BSP store. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the BSP. + @param Length The length of the BSP store in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +BuildBspStoreHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE)); + + CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid); + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = MemoryType; + + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); +} + +/** + Builds a HOB for the memory allocation. + + This function builds a HOB for the memory allocation. + It can only be invoked during PEI phase; + for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. + If there is no additional space for HOB creation, then ASSERT(). + + @param BaseAddress The 64 bit physical address of the memory. + @param Length The length of the memory allocation in bytes. + @param MemoryType Type of memory allocated by this HOB. + +**/ +VOID +EFIAPI +GlueBuildMemoryAllocationHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +{ + EFI_HOB_MEMORY_ALLOCATION *Hob; + + Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION)); + + ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID)); + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = MemoryType; + // + // Zero the reserved space to match HOB spec + // + ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf new file mode 100644 index 0000000000..0ec70a3208 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf @@ -0,0 +1,83 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiHobLib.inf +# +# Abstract: +# +# Component description file for PeiHobLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiHobLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + HobLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGluePeiServicesLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c new file mode 100644 index 0000000000..b85575bfdd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c @@ -0,0 +1,1080 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + MemoryAllocationLib.c + +Abstract: + + Support routines for memory allocation routines for use with drivers. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + Allocates one or more 4KB pages of a certain memory type. + + Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated + buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. + If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + EFI_PEI_SERVICES **PeiServices; + + if (Pages == 0) { + return NULL; + } + + PeiServices = GetPeiServicesTablePointer (); + Status = ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + Memory = 0; + } + return (VOID *) (UINTN) Memory; +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData. + + Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiBootServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiRuntimeServicesData, Pages); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType. + + Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPages ( + IN UINTN Pages + ) +{ + return InternalAllocatePages (EfiReservedMemoryType, Pages); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the page allocation + functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with a page allocation function in the Memory Allocation Library, + then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +GlueFreePages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + // + // PEI phase does not support to free pages, so leave it as NOP. + // +} + +/** + Allocates one or more 4KB pages of a certain memory type at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment + specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned. + If there is not enough memory at the specified alignment remaining to satisfy the request, then + NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param MemoryType The type of memory to allocate. + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN UINTN Alignment + ) +{ + VOID *Memory; + UINTN AlignmentMask; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Pages == 0) { + return NULL; + } + // + // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. + // + ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment))); + // + // We would rather waste some memory to save PEI code size. + // + Memory = InternalAllocatePages (MemoryType, Pages + EFI_SIZE_TO_PAGES (Alignment)); + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask); +} + +/** + Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); +} + +/** + Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment. + + Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is + returned. If there is not enough memory at the specified alignment remaining to satisfy the + request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param Pages The number of 4 KB pages to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPages ( + IN UINTN Pages, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment); +} + +/** + Frees one or more 4KB pages that were previously allocated with one of the aligned page + allocation functions in the Memory Allocation Library. + + Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer + must have been allocated on a previous call to the aligned page allocation services of the Memory + Allocation Library. + If Buffer was not allocated with an aligned page allocation function in the Memory Allocation + Library, then ASSERT(). + If Pages is zero, then ASSERT(). + + @param Buffer Pointer to the buffer of pages to free. + @param Pages The number of 4 KB pages to free. + +**/ +VOID +EFIAPI +FreeAlignedPages ( + IN VOID *Buffer, + IN UINTN Pages + ) +{ + // + // PEI phase does not support to free pages, so leave it as NOP. + // +} + +/** + Allocates a buffer of a certain pool type. + + Allocates the number bytes specified by AllocationSize of a certain pool type and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param MemoryType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocatePool ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN AllocationSize + ) +{ + // + // If we need lots of small runtime/reserved memory type from PEI in the future, + // we can consider providing a more complex algorithm that allocates runtime pages and + // provide pool allocations from those pages. + // + return InternalAllocatePages (MemoryType, EFI_SIZE_TO_PAGES (AllocationSize)); +} + +/** + Allocates a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a + pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocatePool ( + IN UINTN AllocationSize + ) +{ + EFI_STATUS Status; + EFI_PEI_SERVICES **PeiServices; + VOID *Buffer; + + PeiServices = GetPeiServicesTablePointer (); + + Status = ((*PeiServices)->AllocatePool) (PeiServices, AllocationSize, &Buffer); + if (EFI_ERROR (Status)) { + Buffer = NULL; + } + return Buffer; +} + +/** + Allocates a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimePool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates a buffer of type EfieservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns + a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is + returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocatePool (EfiReservedMemoryType, AllocationSize); +} + +/** + Allocates and zeros a buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer + with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, + then NULL is returned. + + @param PoolType The type of memory to allocate. + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize + ) +{ + VOID *Memory; + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateZeroPool ( + IN UINTN AllocationSize + ) +{ + VOID *Memory; + + Memory = AllocatePool (AllocationSize); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize); +} + +/** + Allocates and zeros a buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the + buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a + valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the + request, then NULL is returned. + + @param AllocationSize The number of bytes to allocate and zero. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedZeroPool ( + IN UINTN AllocationSize + ) +{ + return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize); +} + +/** + Copies a buffer to an allocated buffer of a certian pool type. + + Allocates the number bytes specified by AllocationSize of a certian pool type, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocatePool (PoolType, AllocationSize); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +GlueAllocateCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = AllocatePool (AllocationSize); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies + AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory remaining to satisfy the request, then NULL is returned. + If Buffer is NULL, then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + + @param AllocationSize The number of bytes to allocate and zero. + @param Buffer The buffer to copy to the allocated buffer. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer + ) +{ + return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer); +} + +/** + Frees a buffer that was previously allocated with one of the pool allocation functions in the + Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, + then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +GlueFreePool ( + IN VOID *Buffer + ) +{ + // + // PEI phase does not support to free pool, so leave it as NOP. + // +} + +/** + Allocates a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *RawAddress; + UINTN AlignedAddress; + UINTN AlignmentMask; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + // + // Make sure that AllocationSize plus AlignmentMask does not overflow. + // + ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask)); + + RawAddress = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask); + + AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask; + + return (VOID *) AlignedAddress; +} + +/** + Allocates a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *RawAddress; + UINTN AlignedAddress; + UINTN AlignmentMask; + + // + // Alignment must be a power of two or zero. + // + ASSERT ((Alignment & (Alignment - 1)) == 0); + + if (Alignment == 0) { + AlignmentMask = Alignment; + } else { + AlignmentMask = Alignment - 1; + } + + // + // Make sure that AllocationSize plus AlignmentMask does not overflow. + // + ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask)); + + RawAddress = AllocatePool (AllocationSize + AlignmentMask); + + AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask; + + return (VOID *) AlignedAddress; +} + +/** + Allocates a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimePool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated + buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not + enough memory at the specified alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedZeroPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *Memory; + + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + VOID *Memory; + + Memory = AllocateAlignedPool (AllocationSize, Alignment); + if (Memory != NULL) { + Memory = ZeroMem (Memory, AllocationSize); + } + return Memory; +} + +/** + Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment); +} + +/** + Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an + alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the + allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there + is not enough memory at the specified alignment remaining to satisfy the request, then NULL is + returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedZeroPool ( + IN UINTN AllocationSize, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment); +} + +/** + Copies a buffer to an allocated buffer of a certain pool type at a specified alignment. + + Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment + specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid + buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining + to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param PoolType The type of pool to allocate. + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +InternalAllocateAlignedCopyPool ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + VOID *Memory; + + ASSERT (Buffer != NULL); + ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); + + Memory = AllocateAlignedPool (AllocationSize, Alignment); + if (Memory != NULL) { + Memory = CopyMem (Memory, Buffer, AllocationSize); + } + return Memory; +} + +/** + Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedRuntimeCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment); +} + +/** + Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment. + + Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an + alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, + then a valid buffer of 0 size is returned. If there is not enough memory at the specified + alignment remaining to satisfy the request, then NULL is returned. + If Alignment is not a power of two and Alignment is not zero, then ASSERT(). + + @param AllocationSize The number of bytes to allocate. + @param Buffer The buffer to copy to the allocated buffer. + @param Alignment The requested alignment of the allocation. Must be a power of two. + If Alignment is zero, then byte alignment is used. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocateAlignedReservedCopyPool ( + IN UINTN AllocationSize, + IN CONST VOID *Buffer, + IN UINTN Alignment + ) +{ + return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment); +} + +/** + Frees a buffer that was previously allocated with one of the aligned pool allocation functions + in the Memory Allocation Library. + + Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the + aligned pool allocation services of the Memory Allocation Library. + If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation + Library, then ASSERT(). + + @param Buffer Pointer to the buffer to free. + +**/ +VOID +EFIAPI +FreeAlignedPool ( + IN VOID *Buffer + ) +{ + // + // PEI phase does not support to free pool, so leave it as NOP. + // +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf new file mode 100644 index 0000000000..8cfa7f15ff --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf @@ -0,0 +1,87 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiMemoryAllocationLib.inf +# +# Abstract: +# +# Component description file for PeiMemoryAllocationLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiMemoryAllocationLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + MemoryAllocationLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiSerivcesTablePointerLib can be used to +# replaced EdkIIGluePeiServicesTablePointerLibMm7 +# + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf new file mode 100644 index 0000000000..a60f1b208d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf @@ -0,0 +1,108 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiReportStatusCodeLib.inf +# +# Abstract: +# +# Component description file for PeiReportStatusCodeLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiReportStatusCodeLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + ReportStatusCodeLib.c + +[sources.ia32] + + +[sources.x64] + + +[sources.ipf] + + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueBaseIoLibIntrinsic + EdkFrameworkGuidLib +# Possibly, gEfiCallerIdGuid might be used. + EdkGuidLib + +[libraries.ia32] + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be used +# to replace EdkIIGluePeiServicesTablePointerLibMm7 +# + + +[libraries.x64] + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be used +# to replace EdkIIGluePeiServicesTablePointerLibMm7 +# + +[libraries.ipf] + EdkIIGluePeiServicesTablePointerLibKr1 +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be used +# to replace EdkIIGluePeiServicesTablePointerLibKr1 +# + +[libraries.ebc] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c new file mode 100644 index 0000000000..5b62746976 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c @@ -0,0 +1,527 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + ReportStatusCodeLib.c + +Abstract: + + Report Status Code Lib + +--*/ + +#include "EdkIIGluePeim.h" + +// +// Define the maximum extended data size that is supported in the PEI phase +// +#define MAX_EXTENDED_DATA_SIZE 0x200 + +/** + Internal worker function that reports a status code through the Status Code Protocol + + This function checks to see if a Status Code Protocol is present in the handle + database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is + returned. If a Status Code Protocol is present, then it is cached in gStatusCode, + and the ReportStatusCode() service of the Status Code Protocol is called passing in + Type, Value, Instance, CallerId, and Data. The result of this call is returned. + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. This is an optional parameter that may be + NULL. + @param Data Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code. + @retval EFI_UNSUPPORTED Status Code Protocol is not available. + +**/ +STATIC +EFI_STATUS +InternalReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->PeiReportStatusCode ( + PeiServices, + Type, + Value, + Instance, + (EFI_GUID *)CallerId, + Data + ); +} + + +/** + Converts a status code to an 8-bit POST code value. + + Converts the status code specified by CodeType and Value to an 8-bit POST code + and returns the 8-bit POST code in PostCode. If CodeType is an + EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode + are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits + 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. + + If PostCode is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param PostCode A pointer to the 8-bit POST code value to return. + + @retval TRUE The status code specified by CodeType and Value was converted + to an 8-bit POST code and returned in PostCode. + @retval FALSE The status code specified by CodeType and Value could not be + converted to an 8-bit POST code value. + +**/ +BOOLEAN +EFIAPI +GlueCodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +{ + // + // If PostCode is NULL, then ASSERT() + // + ASSERT (PostCode != NULL); + + // + // Convert Value to an 8 bit post code + // + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || + ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) { + *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) | + (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f)); + return TRUE; + } + return FALSE; +} + + +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + + ASSERT (Data != NULL); + ASSERT (Filename != NULL); + ASSERT (Description != NULL); + ASSERT (LineNumber != NULL); + + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && + ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) && + ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) { + AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1); + *Filename = (CHAR8 *)(AssertData + 1); + *Description = *Filename + AsciiStrLen (*Filename) + 1; + *LineNumber = AssertData->LineNumber; + return TRUE; + } + return FALSE; +} + + +/** + Extracts DEBUG() information from a status code structure. + + Converts the status code specified by Data to the DEBUG() arguments specified + by ErrorLevel, Marker, and Format. If type GUID in Data is + EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and + Format from the optional data area of the status code buffer specified by Data. + The optional data area of Data contains a 32-bit ErrorLevel followed by Marker + which is 12 UINTN parameters, followed by a Null-terminated ASCII string for + the Format. If the DEBUG() information could be extracted from Data, then + return TRUE. Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If ErrorLevel is NULL, then ASSERT(). + If Marker is NULL, then ASSERT(). + If Format is NULL, then ASSERT(). + + @param Data Pointer to status code data buffer. + @param ErrorLevel Pointer to error level mask for a debug message. + @param Marker Pointer to the variable argument list associated with Format. + @param Format Pointer to a Null-terminated ASCII format string of a + debug message. + + @retval TRUE The status code specified by Data was converted DEBUG() arguments + specified by ErrorLevel, Marker, and Format. + @retval FALSE The status code specified by Data could not be converted to + DEBUG() arguments. + +**/ +BOOLEAN +EFIAPI +GlueReportStatusCodeExtractDebugInfo ( + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +{ + EFI_DEBUG_INFO *DebugInfo; + + ASSERT (Data != NULL); + ASSERT (ErrorLevel != NULL); + ASSERT (Marker != NULL); + ASSERT (Format != NULL); + + // + // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE + // + if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) { + return FALSE; + } + + // + // Retrieve the debug information from the status code record + // + DebugInfo = (EFI_DEBUG_INFO *)(Data + 1); + + *ErrorLevel = DebugInfo->ErrorLevel; + + // + // The first 12 * UINTN bytes of the string are really an + // argument stack to support varargs on the Format string. + // + *Marker = (VA_LIST) (DebugInfo + 1); + *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12); + + return TRUE; +} + + +/** + Reports a status code. + + Reports the status code specified by the parameters Type and Value. Status + code also require an instance, caller ID, and extended data. This function + passed in a zero instance, NULL extended data, and a caller ID of + gEfiCallerIdGuid, which is the GUID for the module. + + ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() + is called while processing another any other Report Status Code Library function, + then ReportStatusCode() must return immediately. + + @param Type Status code type. + @param Value Status code value. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_DEVICE_ERROR There status code could not be reported due to a + device error. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value + ) +{ + return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL); +} + + +/** + Reports a status code with a Device Path Protocol as the extended data. + + Allocates and fills in the extended data section of a status code with the + Device Path Protocol specified by DevicePath. This function is responsible + for allocating a buffer large enough for the standard header and the device + path. The standard header is filled in with a GUID of + gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero + instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithDevicePath()must actively prevent recursion. If + ReportStatusCodeWithDevicePath() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithDevicePath() + must return EFI_DEVICE_ERROR immediately. + + If DevicePath is NULL, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param DevicePath Pointer to the Device Path Protocol to be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by DevicePath. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithDevicePath ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + ASSERT (DevicePath != NULL); + return EFI_UNSUPPORTED; +} + + +/** + Reports a status code with an extended data buffer. + + Allocates and fills in the extended data section of a status code with the + extended data specified by ExtendedData and ExtendedDataSize. ExtendedData + is assumed to be one of the data structures specified in Related Definitions. + These data structure do not have the standard header, so this function is + responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled + in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported + with a zero instance and a caller ID of gEfiCallerIdGuid. + + ReportStatusCodeWithExtendedData()must actively prevent recursion. If + ReportStatusCodeWithExtendedData() is called while processing another any other + Report Status Code Library function, then ReportStatusCodeWithExtendedData() + must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL, then ASSERT(). + If ExtendedDataSize is 0, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param ExtendedData Pointer to the extended data buffer to be reported. + @param ExtendedDataSize The size, in bytes, of the extended data buffer to + be reported. + + @retval EFI_SUCCESS The status code was reported with the extended + data specified by ExtendedData and ExtendedDataSize. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the + extended data section. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeWithExtendedData ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST VOID *ExtendedData, + IN UINTN ExtendedDataSize + ) +{ + ASSERT (ExtendedData != NULL); + ASSERT (ExtendedDataSize != 0); + return ReportStatusCodeEx ( + Type, + Value, + 0, + NULL, + NULL, + ExtendedData, + ExtendedDataSize + ); +} + + +/** + Reports a status code with full parameters. + + The function reports a status code. If ExtendedData is NULL and ExtendedDataSize + is 0, then an extended data buffer is not reported. If ExtendedData is not + NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. + ExtendedData is assumed not have the standard status code header, so this function + is responsible for allocating a buffer large enough for the standard header and + the extended data passed into this function. The standard header is filled in + with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a + GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with + an instance specified by Instance and a caller ID specified by CallerId. If + CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used. + + ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() + is called while processing another any other Report Status Code Library function, + then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately. + + If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + + @param Type Status code type. + @param Value Status code value. + @param Instance Status code instance number. + @param CallerId Pointer to a GUID that identifies the caller of this + function. If this parameter is NULL, then a caller + ID of gEfiCallerIdGuid is used. + @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. + If this parameter is NULL, then a the status code + standard header is filled in with + gEfiStatusCodeSpecificDataGuid. + @param ExtendedData Pointer to the extended data buffer. This is an + optional parameter that may be NULL. + @param ExtendedDataSize The size, in bytes, of the extended data buffer. + + @retval EFI_SUCCESS The status code was reported. + @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate + the extended data section if it was specified. + @retval EFI_UNSUPPORTED Report status code is not supported + +**/ +EFI_STATUS +EFIAPI +GlueReportStatusCodeEx ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, + IN UINTN ExtendedDataSize + ) +{ + EFI_STATUS_CODE_DATA *StatusCodeData; + UINT64 Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)]; + + ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); + ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); + + if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) { + return EFI_OUT_OF_RESOURCES; + } + StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer; + StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA); + StatusCodeData->Size = (UINT16)ExtendedDataSize; + if (ExtendedDataGuid == NULL) { + ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid; + } + CopyGuid (&StatusCodeData->Type, ExtendedDataGuid); + CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize); + if (CallerId == NULL) { + CallerId = &gEfiCallerIdGuid; + } + return InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData); +} + + +/** + Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportProgressCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_ERROR_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportErrorCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0); +} + + +/** + Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled + + This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED + bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is set. + @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdReportStatusCodeProperyMask is clear. + +**/ +BOOLEAN +EFIAPI +GlueReportDebugCodeEnabled ( + VOID + ) +{ + return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c new file mode 100644 index 0000000000..58535b5139 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c @@ -0,0 +1,57 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiResourcePublicationLib.c + +Abstract: + + Resource Publication Library that uses PEI Core Services to publish system memory. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + + Declares the presence of permanent system memory in the platform. + + Declares that the system memory buffer specified by MemoryBegin and MemoryLength + as permanent memory that may be used for general purpose use by software. + The amount of memory available to software may be less than MemoryLength + if published memory has alignment restrictions. + + @param MemoryBegin The start address of the memory being declared. + @param MemoryLength The number of bytes of memory being declared. + + @retval RETURN_SUCCESS The memory buffer was published. + @retval RETURN_OUT_OF_RESOURCES There are not enough resources to publish the memory buffer + +**/ +RETURN_STATUS +EFIAPI +PublishSystemMemory ( + IN PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ) +{ + EFI_STATUS Status; + + ASSERT (MemoryLength > 0); + ASSERT (MemoryLength <= (MAX_ADDRESS - MemoryBegin + 1)); + + Status = PeiServicesInstallPeiMemory (MemoryBegin, MemoryLength); + + return (RETURN_STATUS) Status; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf new file mode 100644 index 0000000000..53de36a937 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf @@ -0,0 +1,81 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiResourcePublication.inf +# +# Abstract: +# +# Component description file for PeiResourcePublication. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiResourcePublicationLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiResourcePublicationLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGluePeiServicesLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c new file mode 100644 index 0000000000..60143519f8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c @@ -0,0 +1,393 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiServicesLib.c + +Abstract: + + PEI Services Lib + +--*/ + +#include "EdkIIGluePeim.h" + +/** + This service enables a given PEIM to register an interface into the PEI Foundation. + + @param PpiList A pointer to the list of interfaces that the caller shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *PpiList + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->InstallPpi (PeiServices, PpiList); +} + +/** + This service enables PEIMs to replace an entry in the PPI database with an alternate entry. + + @param OldPpi Pointer to the old PEI PPI Descriptors. + @param NewPpi Pointer to the new PEI PPI Descriptors. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been + installed. + +**/ +EFI_STATUS +EFIAPI +PeiServicesReInstallPpi ( + IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, + IN EFI_PEI_PPI_DESCRIPTOR *NewPpi + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi); +} + +/** + This service enables PEIMs to discover a given instance of an interface. + + @param Guid A pointer to the GUID whose corresponding interface needs to be + found. + @param Instance The N-th instance of the interface that is required. + @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. + @param Ppi A pointer to the instance of the interface. + + @retval EFI_SUCCESS The interface was successfully returned. + @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesLocatePpi ( + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi); +} + +/** + This service enables PEIMs to register a given service to be invoked when another service is + installed or reinstalled. + + @param NotifyList A pointer to the list of notification interfaces that the caller + shall install. + + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + +**/ +EFI_STATUS +EFIAPI +PeiServicesNotifyPpi ( + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->NotifyPpi (PeiServices, NotifyList); +} + +/** + This service enables PEIMs to ascertain the present value of the boot mode. + + @param BootMode A pointer to contain the value of the boot mode. + + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetBootMode ( + IN OUT EFI_BOOT_MODE *BootMode + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->GetBootMode (PeiServices, BootMode); +} + +/** + This service enables PEIMs to update the boot mode variable. + + @param BootMode The value of the boot mode to set. + + @retval EFI_SUCCESS The value was successfully updated + +**/ +EFI_STATUS +EFIAPI +PeiServicesSetBootMode ( + IN EFI_BOOT_MODE BootMode + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->SetBootMode (PeiServices, BootMode); +} + +/** + This service enables a PEIM to ascertain the address of the list of HOBs in memory. + + @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. + + @retval EFI_SUCCESS The list was successfully returned. + @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. + +**/ +EFI_STATUS +EFIAPI +PeiServicesGetHobList ( + IN OUT VOID **HobList + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->GetHobList (PeiServices, HobList); +} + +/** + This service enables PEIMs to create various types of HOBs. + + @param Type The type of HOB to be installed. + @param Length The length of the HOB to be added. + @param Hob The address of a pointer that will contain the HOB header. + + @retval EFI_SUCCESS The HOB was successfully created. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesCreateHob ( + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob); +} + +#if (PI_SPECIFICATION_VERSION < 0x00010000) +/** + This service enables PEIMs to discover additional firmware volumes. + + @param Instance This instance of the firmware volume to find. The value 0 is the + Boot Firmware Volume (BFV). + @param FwVolHeader Pointer to the firmware volume header of the volume to return. + + @retval EFI_SUCCESS The volume was found. + @retval EFI_NOT_FOUND The volume was not found. + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextVolume ( + IN UINTN Instance, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, FwVolHeader); +} + +/** + This service enables PEIMs to discover additional firmware files. + + @param SearchType A filter to find files only of this type. + @param FwVolHeader Pointer to the firmware volume header of the volume to search. + This parameter must point to a valid FFS volume. + @param FileHeader Pointer to the current file from which to begin searching. + + @retval EFI_SUCCESS The file was found. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_NOT_FOUND The header checksum was not zero. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindNextFile ( + IN EFI_FV_FILETYPE SearchType, + IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, + IN OUT EFI_FFS_FILE_HEADER **FileHeader + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FwVolHeader, FileHeader); +} + +/** + This service enables PEIMs to discover sections of a given type within a valid FFS file. + + @param SearchType The value of the section type to find. + @param FfsFileHeader A pointer to the file header that contains the set of sections to + be searched. + @param SectionData A pointer to the discovered section, if successful. + + @retval EFI_SUCCESS The section was found. + @retval EFI_NOT_FOUND The section was not found. + +**/ +EFI_STATUS +EFIAPI +PeiServicesFfsFindSectionData ( + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FfsFileHeader, SectionData); +} + +#endif + +/** + This service enables PEIMs to register the permanent memory configuration + that has been initialized with the PEI Foundation. + + @param MemoryBegin The value of a region of installed memory. + @param MemoryLength The corresponding length of a region of installed memory. + + @retval EFI_SUCCESS The region was successfully installed in a HOB. + @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + +**/ +EFI_STATUS +EFIAPI +PeiServicesInstallPeiMemory ( + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength); +} + +/** + This service enables PEIMs to allocate memory after the permanent memory has been installed by a + PEIM. + + @param MemoryType Type of memory to allocate. + @param Pages Number of pages to allocate. + @param Memory Pointer of memory allocated. + + @retval EFI_SUCCESS The memory range was successfully allocated. + @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. + @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePages ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, Memory); +} + +/** + This service allocates memory from the Hand-Off Block (HOB) heap. + + @param Size The number of bytes to allocate from the pool. + @param Buffer If the call succeeds, a pointer to a pointer to the allocate + buffer; undefined otherwise. + + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. + +**/ +EFI_STATUS +EFIAPI +PeiServicesAllocatePool ( + IN UINTN Size, + OUT VOID **Buffer + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return ((*PeiServices)->AllocatePool) (PeiServices, Size, Buffer); +} + +/** + This service resets the entire platform, including all processors and devices, and reboots the + system. + + @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. + +**/ +EFI_STATUS +EFIAPI +PeiServicesResetSystem ( + VOID + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer (); + return (*PeiServices)->PeiResetSystem (PeiServices); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf new file mode 100644 index 0000000000..efe0622a7c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf @@ -0,0 +1,86 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiServicesLib.inf +# +# Abstract: +# +# Component description file for PeiServicesLib +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiServicesLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiServicesLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be +# used to replace EdkIIGluePeiServicesTablePointerLibMm7 or +# EdkIIGluePeiServicesTablePointerLibKr1 +# + +[libraries.ia32] + EdkIIGluePeiServicesTablePointerLibMm7 + +[libraries.x64] + EdkIIGluePeiServicesTablePointerLibMm7 + +[libraries.ipf] + EdkIIGluePeiServicesTablePointerLibKr1 + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c new file mode 100644 index 0000000000..d3c0c98263 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c @@ -0,0 +1,67 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiServicesTablePointer.c + +Abstract: + + PEI Services Table Pointer Library. + +--*/ + +#include "EdkIIGluePeim.h" + +static EFI_PEI_SERVICES **gPeiServices; + +/** + The function returns the pointer to PEI services. + + The function returns the pointer to PEI services. + It will ASSERT() if the pointer to PEI services is NULL. + + @retval The pointer to PeiServices. + +**/ +EFI_PEI_SERVICES ** +GetPeiServicesTablePointer ( + VOID + ) +{ + ASSERT (gPeiServices != NULL); + return gPeiServices; +} + + +/** + The constructor function caches the pointer to PEI services. + + The constructor function caches the pointer to PEI services. + It will always return EFI_SUCCESS. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ + gPeiServices = PeiServices; + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf new file mode 100644 index 0000000000..180bee65fd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiServiceTablePointerLib.inf +# +# Abstract: +# +# Component description file for PeiServicesTablePointerLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiServicesTablePointerLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiServicesTablePointer.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/ReadKr1.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/ReadKr1.s new file mode 100644 index 0000000000..cc48f0941f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/ReadKr1.s @@ -0,0 +1,44 @@ +// Copyright (c) 2006, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// ReadKr1.s +// +// Abstract: +// +// Contains assembly code for read Kr1. +// +//-- + + .file "ReadKr1.s" + +#include "IpfMacro.i" + +//--------------------------------------------------------------------------------- +//++ +// AsmReadKr1 +// +// This routine is used to get KR1. KR1 is used to store Pei Service Table +// Pointer in archeture. +// +// Arguments : +// +// On Entry : None. +// +// Return Value: Pei Services Table. +// +//-- +//---------------------------------------------------------------------------------- +PROCEDURE_ENTRY (AsmReadKr1) + + mov r8 = ar.k1;; // Pei Services Table Pointer + br.ret.dpnt b0;; + +PROCEDURE_EXIT (AsmReadKr1) diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/WriteKr1.s b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/WriteKr1.s new file mode 100644 index 0000000000..e86f50a959 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/Ipf/WriteKr1.s @@ -0,0 +1,45 @@ +// Copyright (c) 2006, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// WriteKr1.s +// +// Abstract: +// +// Contains assembly code for write Kr1. +// +//-- + + .file "WriteKr1.s" + +#include "IpfMacro.i" + +//--------------------------------------------------------------------------------- +//++ +// AsmWriteKr1 +// +// This routine is used to Write KR1. KR1 is used to store Pei Service Table +// Pointer in archeture. +// +// Arguments : r32 Pei Services Table Pointer +// +// On Entry : None. +// +// Return Value: None. +// +//-- +//---------------------------------------------------------------------------------- +PROCEDURE_ENTRY (AsmWriteKr1) + + mov ar.k1 = r32;; // Pei Services Table Pointer + br.ret.dpnt b0;; + +PROCEDURE_EXIT (AsmWriteKr1) + \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c new file mode 100644 index 0000000000..a122ce867b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointer.c @@ -0,0 +1,68 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiServicesTablePointer.c + +Abstract: + + PEI Services Table Pointer Library. + +--*/ + +#include "PeiServicesTablePointerLibInternals.h" + +/** + The function returns the pointer to PeiServices. + + The function returns the pointer to PeiServices. + It will ASSERT() if the pointer to PeiServices is NULL. + + @retval The pointer to PeiServices. + +**/ +EFI_PEI_SERVICES ** +EFIAPI +GetPeiServicesTablePointer ( + VOID + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadKr1 (); + ASSERT (PeiServices != NULL); + return PeiServices; +} + +/** + The constructor function caches the pointer to PEI services. + + The constructor function caches the pointer to PEI services. + It will always return EFI_SUCCESS. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ + AsmWriteKr1 ((UINT64)(UINTN)PeiServices); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h new file mode 100644 index 0000000000..ee0f2a5721 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibInternals.h @@ -0,0 +1,52 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiServicesTablePointerLibInternals.h + +Abstract: + + Declarations of internal functions in PeiServicesTableLibKr1. + +--*/ + +#ifndef __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__ +#define __PEI_SERVICES_TABLE_POINTER_LIB_INTERTALS_H__ + +#include "EdkIIGluePeim.h" + +/** + Reads the current value of Kr1. + + @return The current value of Kr1. + +**/ +UINT64 +EFIAPI +AsmReadKr1 ( + VOID + ); + +/** + Writes the current value of Kr1. + + @param Value The 64-bit value to write to Kr1. + +**/ +VOID +EFIAPI +AsmWriteKr1 ( + IN UINT64 Value + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.inf new file mode 100644 index 0000000000..24b5d6be5f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibKr1/PeiServicesTablePointerLibKr1.inf @@ -0,0 +1,74 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiServiceTablePointerLibKr1.inf +# +# Abstract: +# +# Component description file for PeiServicesTablePointerLibKr1. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiServicesTablePointerLibKr1 +COMPONENT_TYPE = LIBRARY + +[sources.common] + +[sources.ipf] + PeiServicesTablePointer.c + Ipf/ReadKr1.s + Ipf/WriteKr1.s + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c new file mode 100644 index 0000000000..f91a2f582a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c @@ -0,0 +1,68 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiServicesTablePointer.c + +Abstract: + + PEI Services Table Pointer Library. + +--*/ + +#include "EdkIIGluePeim.h" + +/** + The function returns the pointer to PeiServices. + + The function returns the pointer to PeiServices. + It will ASSERT() if the pointer to PeiServices is NULL. + + @retval The pointer to PeiServices. + +**/ +EFI_PEI_SERVICES ** +EFIAPI +GetPeiServicesTablePointer ( + VOID + ) +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 (); + ASSERT (PeiServices != NULL); + return PeiServices; +} + +/** + The constructor function caches the pointer to PEI services. + + The constructor function caches the pointer to PEI services. + It will always return EFI_SUCCESS. + + @param FfsHeader Pointer to FFS header the loaded driver. + @param PeiServices Pointer to the PEI services. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +PeiServicesTablePointerLibConstructor ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +{ + AsmWriteMm7 ((UINT64)(UINTN)PeiServices); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf new file mode 100644 index 0000000000..0bcc415b63 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf @@ -0,0 +1,79 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiServiceTablePointerLibMm7.inf +# +# Abstract: +# +# Component description file for PeiServicesTablePointerLibMm7. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiServicesTablePointerLibMm7 +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiServicesTablePointer.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[libraries.common] + EdkIIGlueBaseLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c new file mode 100644 index 0000000000..4abf5f63e3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c @@ -0,0 +1,104 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiSmbusLib.c + +Abstract: + + PEI Smbus Lib internal functions + +--*/ + +#include "PeiSmbusLibInternal.h" + +/** + Gets Smbus PPIs. + + This internal function retrieves Smbus PPI from PPI database. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation. + + @return The pointer to Smbus PPI. + +**/ +EFI_PEI_SMBUS_PPI * +InternalGetSmbusPpi ( + EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_PEI_SMBUS_PPI *SmbusPpi; + + Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiPeiSmbusPpiGuid, 0, NULL, (VOID **) &SmbusPpi); + ASSERT_EFI_ERROR (Status); + ASSERT (SmbusPpi != NULL); + + return SmbusPpi; +} + +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation.. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + EFI_PEI_SMBUS_PPI *SmbusPpi; + EFI_PEI_SERVICES **PeiServices; + RETURN_STATUS ReturnStatus; + EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress; + + PeiServices = GetPeiServicesTablePointer (); + SmbusPpi = InternalGetSmbusPpi (PeiServices); + SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress); + + ReturnStatus = SmbusPpi->Execute ( + PeiServices, + SmbusPpi, + SmbusDeviceAddress, + SMBUS_LIB_COMMAND (SmBusAddress), + SmbusOperation, + SMBUS_LIB_PEC (SmBusAddress), + &Length, + Buffer + ); + if (Status != NULL) { + *Status = ReturnStatus; + } + + return Length; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf new file mode 100644 index 0000000000..c3bfa95efb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf @@ -0,0 +1,86 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiSmbusLib.inf +# +# Abstract: +# +# Component description file for PeiSmbusLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGluePeiSmbusLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiSmbusLib.c + SmbusLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords + $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId + $(EDK_SOURCE)\Foundation\Include\Pei + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGluePeiServicesTablePointerLibMm7 +# +# If necessary, EdkIIGluePeiServicesTablePointerLib can be +# used to replace EdkIIGluePeiServicesTablePointerLibMm7 +# + + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h new file mode 100644 index 0000000000..fa7251c7fa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h @@ -0,0 +1,84 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiSmbusLibInternal.h + +Abstract: + + Declarations of internal functions in PeiSmbusLib. + +--*/ + +#ifndef __PEI_SMBUS_LIB_INTERNAL_H__ +#define __PEI_SMBUS_LIB_INTERNAL_H__ + +#include "EdkIIGluePeim.h" + + +#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f) +#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff) +#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f) +#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0)) +#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT)) + +// +// Declaration for internal functions +// + +/** + Gets Smbus PPIs. + + This internal function retrieves Smbus PPI from PPI database. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation. + + @return The pointer to Smbus PPI. + +**/ +EFI_PEI_SMBUS_PPI * +InternalGetSmbusPpi ( + EFI_PEI_SERVICES **PeiServices + ); + +/** + Executes an SMBus operation to an SMBus controller. + + This function provides a standard way to execute Smbus script + as defined in the SmBus Specification. The data can either be of + the Length byte, word, or a block of data. + + @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to + execute the SMBus transactions. + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Length Signifies the number of bytes that this operation will do. The maximum number of + bytes can be revision specific and operation specific. + @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations + require this argument. The length of this buffer is identified by Length. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The actual number of bytes that are executed for this operation. + +**/ +UINTN +InternalSmBusExec ( + IN EFI_SMBUS_OPERATION SmbusOperation, + IN UINTN SmBusAddress, + IN UINTN Length, + IN OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ); + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c new file mode 100644 index 0000000000..359eb3514c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c @@ -0,0 +1,475 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiSmbus.c + +Abstract: + + Pei Smbus Lib Interfaces + +--*/ + +#include "PeiSmbusLibInternal.h" + +/** + Executes an SMBUS quick read command. + + Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickRead ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS quick write command. + + Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + If Status is not NULL, then the status of the executed command is returned in Status. + If PEC is set in SmBusAddress, then ASSERT(). + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + +**/ +VOID +EFIAPI +SmBusQuickWrite ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status); +} + +/** + Executes an SMBUS receive byte command. + + Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address field of SmBusAddress is required. + The byte received from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte received from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReceiveByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS send byte command. + + Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress. + The byte specified by Value is sent. + Only the SMBUS slave address field of SmBusAddress is required. Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Command in SmBusAddress is not zero, then ASSERT(). + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to send. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusSendByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data byte command. + + Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 8-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT8 +EFIAPI +SmBusReadDataByte ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status); + + return Byte; +} + +/** + Executes an SMBUS write data byte command. + + Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. + The 8-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 8-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT8 +EFIAPI +SmBusWriteDataByte ( + IN UINTN SmBusAddress, + IN UINT8 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT8 Byte; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Byte = Value; + InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status); + + return Value; +} + +/** + Executes an SMBUS read data word command. + + Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value read from the SMBUS is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The byte read from the SMBUS. + +**/ +UINT16 +EFIAPI +SmBusReadDataWord ( + IN UINTN SmBusAddress, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status); + + return Word; +} + +/** + Executes an SMBUS write data word command. + + Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Value is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The parameter of Value. + +**/ +UINT16 +EFIAPI +SmBusWriteDataWord ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINT16 Word; + + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Word = Value; + InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status); + + return Value; +} + +/** + Executes an SMBUS process call command. + + Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress. + The 16-bit value specified by Value is written. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + The 16-bit value returned by the process call command is returned. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is not zero, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Value The 16-bit value to write. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The 16-bit value returned by the process call command. + +**/ +UINT16 +EFIAPI +SmBusProcessCall ( + IN UINTN SmBusAddress, + IN UINT16 Value, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status); + + return Value; +} + +/** + Executes an SMBUS read block command. + + Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress. + Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. + Bytes are read from the SMBUS and stored in Buffer. + The number of bytes read is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is not zero, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes read. + +**/ +UINTN +EFIAPI +SmBusReadBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status); +} + +/** + Executes an SMBUS write block command. + + Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from Buffer. + The number of bytes written is returned, and will never return a value larger than 32-bytes. + If Status is not NULL, then the status of the executed command is returned in Status. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If Buffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusWriteBlock ( + IN UINTN SmBusAddress, + OUT VOID *Buffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (Buffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status); +} + +/** + Executes an SMBUS block process call command. + + Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress. + The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. + Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer. + If Status is not NULL, then the status of the executed command is returned in Status. + It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read. + SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. + If Length in SmBusAddress is zero or greater than 32, then ASSERT(). + If WriteBuffer is NULL, then ASSERT(). + If ReadBuffer is NULL, then ASSERT(). + If any reserved bits of SmBusAddress are set, then ASSERT(). + + @param SmBusAddress Address that encodes the SMBUS Slave Address, + SMBUS Command, SMBUS Data Length, and PEC. + @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. + @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. + @param Status Return status for the executed command. + This is an optional parameter and may be NULL. + + @return The number of bytes written. + +**/ +UINTN +EFIAPI +SmBusBlockProcessCall ( + IN UINTN SmBusAddress, + IN VOID *WriteBuffer, + OUT VOID *ReadBuffer, + OUT RETURN_STATUS *Status OPTIONAL + ) +{ + UINTN Length; + + ASSERT (WriteBuffer != NULL); + ASSERT (ReadBuffer != NULL); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); + ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); + ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + + Length = SMBUS_LIB_LENGTH (SmBusAddress); + // + // Assuming that ReadBuffer is large enough to save another memory copy. + // + ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length); + return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c new file mode 100644 index 0000000000..1727759a3c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c @@ -0,0 +1,68 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + UefiBootServicesTableLib.c + +Abstract: + + UEFI Boot Services Table Library. + +--*/ + +#include "EdkIIGlueUefi.h" + +EFI_HANDLE gImageHandle; +EFI_SYSTEM_TABLE *gST; +EFI_BOOT_SERVICES *gBS; + +/** + The constructor function caches the pointer of Boot Services Table. + + The constructor function caches the pointer of Boot Services Table through System Table. + It will ASSERT() if the pointer of System Table is NULL. + It will ASSERT() if the pointer of Boot Services Table is NULL. + It will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +UefiBootServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // Cache the Image Handle + // + gImageHandle = ImageHandle; + + // + // Cache pointer to the EFI System Table + // + gST = SystemTable; + ASSERT (gST != NULL); + + // + // Cache pointer to the EFI Boot Services Table + // + gBS = SystemTable->BootServices; + ASSERT (gBS != NULL); + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf new file mode 100644 index 0000000000..9b14aaf3ce --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf @@ -0,0 +1,77 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# UefiBootServicesTableLib.inf +# +# Abstract: +# +# Component description file for UefiBootServicesTableLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiBootServicesTableLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiBootServicesTableLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + +[libraries.ia32] + +[libraries.x64] + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c new file mode 100644 index 0000000000..d4174f337f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c @@ -0,0 +1,533 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + UefiDevicePathLib.c + +Abstract: + + Device Path services. The thing to remember is device paths are built out of + nodes. The device path is terminated by an end node that is length + sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL) + all over this file. + + The only place where multi-instance device paths are supported is in + environment varibles. Multi-instance device paths should never be placed + on a Handle. + +--*/ + +#include "EdkIIGlueUefi.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" + +/** + Returns the size of a device path in bytes. + + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @return The size of a device path in bytes. + +**/ +UINTN +EFIAPI +GlueGetDevicePathSize ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Start; + + if (DevicePath == NULL) { + return 0; + } + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Compute the size and add back in the size of the end device path structure + // + return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); +} + +/** + Creates a new device path by appending a second device path to a first device path. + + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. + + @param DevicePath A pointer to a device path data structure. + + @return A pointer to the duplicated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDuplicateDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN Size; + + // + // Compute the size + // + Size = GetDevicePathSize (DevicePath); + if (Size == 0) { + return NULL; + } + + // + // Allocate space for duplicate device path + // + NewDevicePath = AllocateCopyPool (Size, DevicePath); + + return NewDevicePath; +} + +/** + Creates a new device path by appending a second device path to a first device path. + + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. + + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePath ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL + ) +{ + UINTN Size; + UINTN Size1; + UINTN Size2; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePath2; + + // + // If there's only 1 path, just duplicate it. + // + if (FirstDevicePath == NULL) { + return DuplicateDevicePath (SecondDevicePath); + } + + if (SecondDevicePath == NULL) { + return DuplicateDevicePath (FirstDevicePath); + } + + // + // Allocate space for the combined device path. It only has one end node of + // length EFI_DEVICE_PATH_PROTOCOL. + // + Size1 = GetDevicePathSize (FirstDevicePath); + Size2 = GetDevicePathSize (SecondDevicePath); + Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); + + NewDevicePath = AllocatePool (Size); + + if (NewDevicePath != NULL) { + NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1); + // + // Over write FirstDevicePath EndNode and do the copy + // + DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + CopyMem (DevicePath2, SecondDevicePath, Size2); + } + + return NewDevicePath; +} + +/** + Creates a new path by appending the device node to the device path. + + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePath is NULL, then NULL is returned. + If DevicePathNode is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathNode ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL + ) +{ + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; + EFI_DEVICE_PATH_PROTOCOL *NextNode; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN NodeLength; + + if (DevicePath == NULL || DevicePathNode == NULL) { + return NULL; + } + // + // Build a Node that has a terminator on it + // + NodeLength = DevicePathNodeLength (DevicePathNode); + + TempDevicePath = AllocatePool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL)); + if (TempDevicePath == NULL) { + return NULL; + } + TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength); + // + // Add and end device path node to convert Node to device path + // + NextNode = NextDevicePathNode (TempDevicePath); + SetDevicePathEndNode (NextNode); + // + // Append device paths + // + NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath); + + FreePool (TempDevicePath); + + return NewDevicePath; +} + +/** + Creates a new device path by appending the specified device path instance to the specified device + path. + + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. + + @return A pointer to the new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueAppendDevicePathInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL + ) +{ + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; + UINTN SrcSize; + UINTN InstanceSize; + + if (DevicePath == NULL) { + return DuplicateDevicePath (DevicePathInstance); + } + + if (DevicePathInstance == NULL) { + return NULL; + } + + SrcSize = GetDevicePathSize (DevicePath); + InstanceSize = GetDevicePathSize (DevicePathInstance); + + NewDevicePath = AllocatePool (SrcSize + InstanceSize); + if (NewDevicePath != NULL) { + + TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);; + + while (!IsDevicePathEnd (TempDevicePath)) { + TempDevicePath = NextDevicePathNode (TempDevicePath); + } + + TempDevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; + TempDevicePath = NextDevicePathNode (TempDevicePath); + CopyMem (TempDevicePath, DevicePathInstance, InstanceSize); + } + + return NewDevicePath; +} + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueGetNextDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevPath; + EFI_DEVICE_PATH_PROTOCOL *ReturnValue; + UINT8 Temp; + + ASSERT (Size != NULL); + + if (DevicePath == NULL || *DevicePath == NULL) { + *Size = 0; + return NULL; + } + + // + // Find the end of the device path instance + // + DevPath = *DevicePath; + while (!IsDevicePathEndType (DevPath)) { + DevPath = NextDevicePathNode (DevPath); + } + + // + // Compute the size of the device path instance + // + *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL); + + // + // Make a copy and return the device path instance + // + Temp = DevPath->SubType; + DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; + ReturnValue = DuplicateDevicePath (*DevicePath); + DevPath->SubType = Temp; + + // + // If DevPath is the end of an entire device path, then another instance + // does not follow, so *DevicePath is set to NULL. + // + if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) { + *DevicePath = NULL; + } else { + *DevicePath = NextDevicePathNode (DevPath); + } + + return ReturnValue; +} + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { + // + // NodeLength is less than the size of the header. + // + return NULL; + } + + DevicePath = AllocatePool (NodeLength); + if (DevicePath != NULL) { + DevicePath->Type = NodeType; + DevicePath->SubType = NodeSubType; + SetDevicePathNodeLength (DevicePath, NodeLength); + } + + return DevicePath; +} + +/** + Determines if a device path is single or multi-instance. + + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. + + @param DevicePath A pointer to a device path data structure. + + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. + +**/ +BOOLEAN +EFIAPI +GlueIsDevicePathMultiInstance ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + CONST EFI_DEVICE_PATH_PROTOCOL *Node; + + if (DevicePath == NULL) { + return FALSE; + } + + Node = DevicePath; + while (!EfiIsDevicePathEnd (Node)) { + if (EfiIsDevicePathEndInstance (Node)) { + return TRUE; + } + + Node = EfiNextDevicePathNode (Node); + } + + return FALSE; +} + + +/** + Retrieves the device path protocol from a handle. + + This function returns the device path protocol from the handle specified by Handle. If Handle is + NULL or Handle does not contain a device path protocol, then NULL is returned. + + @param Handle The handle from which to retrieve the device path protocol. + + @return The device path protocol from the handle specified by Handle. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_STATUS Status; + + Status = gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *) &DevicePath + ); + if (EFI_ERROR (Status)) { + DevicePath = NULL; + } + return DevicePath; +} + +/** + Allocates a device path for a file and appends it to an existing device path. + + If Device is a valid device handle that contains a device path protocol, then a device path for + the file specified by FileName is allocated and appended to the device path associated with the + handle Device. The allocated device path is returned. If Device is NULL or Device is a handle + that does not support the device path protocol, then a device path containing a single device + path node for the file specified by FileName is allocated and returned. + If FileName is NULL, then ASSERT(). + + @param Device A pointer to a device handle. This parameter is optional and + may be NULL. + @param FileName A pointer to a Null-terminated Unicode string. + + @return The allocated device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GlueFileDevicePath ( + IN EFI_HANDLE Device, OPTIONAL + IN CONST CHAR16 *FileName + ) +{ + UINTN Size; + FILEPATH_DEVICE_PATH *FilePath; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_DEVICE_PATH_PROTOCOL *FileDevicePath; + + DevicePath = NULL; + + Size = StrSize (FileName); + FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH); + if (FileDevicePath != NULL) { + FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath; + FilePath->Header.Type = MEDIA_DEVICE_PATH; + FilePath->Header.SubType = MEDIA_FILEPATH_DP; + CopyMem (&FilePath->PathName, FileName, Size); + SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH); + SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header)); + + if (Device != NULL) { + DevicePath = DevicePathFromHandle (Device); + } + + DevicePath = AppendDevicePath (DevicePath, FileDevicePath); + FreePool (FileDevicePath); + } + + return DevicePath; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf new file mode 100644 index 0000000000..6c4bc04ebf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf @@ -0,0 +1,84 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# UefiDevicePathLib.inf +# +# Abstract: +# +# Component description file for UefiDevicePathLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiDevicePathLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiDevicePathLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib +# +# MemoryAllocationLib instance +# + EdkIIGlueDxeMemoryAllocationLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c new file mode 100644 index 0000000000..60ab4412a2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c @@ -0,0 +1,355 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + UefiDriverModelLib.c + +Abstract: + + UEFI Driver Model Library. + +--*/ + +#include "EdkIIGlueUefi.h" + +/** + The constructor function installs the standard EFI Driver Model Protocols. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always return EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +UefiDriverModelLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE DriverBindingHandle; + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + + // + // Install the first Driver Bindng Protocol onto ImageHandle + // + DriverBindingHandle = ImageHandle; + + // + // See if onle one Driver Binding Protocol is advertised by the driver + // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1 + // + + // + // The Driver Binding Protocol must never be NULL + // + ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL); + + // + // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol + // These are all checks against const pointers, so the optimizing compiler will only select one of the + // calls to InstallMultipleProtocolInterfaces() + // + if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + NULL + ); +#else + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + NULL + ); +#endif + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); +#else + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); +#endif + } + } + } else { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#else + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#endif + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#else + Status = gBS->InstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#endif + } + } + } + + // + // ASSERT if the call to InstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + // + // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol + // + DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding; + DriverBinding->ImageHandle = ImageHandle; + DriverBinding->DriverBindingHandle = DriverBindingHandle; + + + return EFI_SUCCESS; +} + +/** + The destructor function uninstalls the standard EFI Driver Model Protocols. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The destructor always return EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +UefiDriverModelLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE DriverBindingHandle; + + // + // See if onle one Driver Binding Protocol is advertised by the driver + // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1 + // + + // + // The Driver Binding Protocol must never be NULL + // + ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL); + + // + // Retrieve the DriverBindingHandle from the Driver Binding Protocol + // + DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle; + + // + // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol + // These are all checks against const pointers, so the optimizing compiler will only select one of the + // calls to InstallMultipleProtocolInterfaces() + // + if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + NULL + ); +#else + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + NULL + ); + +#endif + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); +#else + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + NULL + ); +#endif + } + } + } else { + if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#else + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#endif + } + } else { + if (_gDriverModelProtocolList[0].ComponentName == NULL) { + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); + } else { +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#else + Status = gBS->UninstallMultipleProtocolInterfaces ( + &DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding, + &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName, + &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration, + &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics, + NULL + ); +#endif + } + } + } + + // + // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed + // + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf new file mode 100644 index 0000000000..6618c6ae69 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf @@ -0,0 +1,67 @@ +#/*++ +# +# Copyright (c) 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# UefiDriverModelLib.inf +# +# Abstract: +# +# Component description file for UefiDriverModelLib.inf +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiDriverModelLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiDriverModelLib.c + +[sources.ia32] + +[sources.ipf,sources.x64] + +[includes.common] + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\Include + $(EDK_SOURCE)\Foundation\Core + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + +[libraries.common] + EdkIIGlueUefiBootServicesTableLib + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c new file mode 100644 index 0000000000..97bc801f3e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c @@ -0,0 +1,288 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Console.c + +Abstract: + + UEFI library functions. + +--*/ + +#include "EdkIIGlueUefi.h" + +typedef struct { + CHAR16 WChar; + UINT32 Width; +} UNICODE_WIDTH_ENTRY; + +UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = { + // + // General script area + // + {(CHAR16)0x1FFF, 1}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all narrow glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x007F, 1}, // C0 controls and basic Latin. 0x0000-0x007F + {(CHAR16)0x00FF, 1}, // C1 controls and Latin-1 support. 0x0080-0x00FF + {(CHAR16)0x017F, 1}, // Latin extended-A. 0x0100-0x017F + {(CHAR16)0x024F, 1}, // Latin extended-B. 0x0180-0x024F + {(CHAR16)0x02AF, 1}, // IPA extensions. 0x0250-0x02AF + {(CHAR16)0x02FF, 1}, // Spacing modifier letters. 0x02B0-0x02FF + {(CHAR16)0x036F, 1}, // Combining diacritical marks. 0x0300-0x036F + {(CHAR16)0x03FF, 1}, // Greek. 0x0370-0x03FF + {(CHAR16)0x04FF, 1}, // Cyrillic. 0x0400-0x04FF + {(CHAR16)0x052F, 0}, // Unassigned. As Armenian in ver3.0. 0x0500-0x052F + {(CHAR16)0x058F, 1}, // Armenian. 0x0530-0x058F + {(CHAR16)0x05FF, 1}, // Hebrew. 0x0590-0x05FF + {(CHAR16)0x06FF, 1}, // Arabic. 0x0600-0x06FF + {(CHAR16)0x08FF, 0}, // Unassigned. 0x0700-0x08FF + {(CHAR16)0x097F, 1}, // Devanagari. 0x0900-0x097F + {(CHAR16)0x09FF, 1}, // Bengali. 0x0980-0x09FF + {(CHAR16)0x0A7F, 1}, // Gurmukhi. 0x0A00-0x0A7F + {(CHAR16)0x0AFF, 1}, // Gujarati. 0x0A80-0x0AFF + {(CHAR16)0x0B7F, 1}, // Oriya. 0x0B00-0x0B7F + {(CHAR16)0x0BFF, 1}, // Tamil. (See page 7-92). 0x0B80-0x0BFF + {(CHAR16)0x0C7F, 1}, // Telugu. 0x0C00-0x0C7F + {(CHAR16)0x0CFF, 1}, // Kannada. (See page 7-100). 0x0C80-0x0CFF + {(CHAR16)0x0D7F, 1}, // Malayalam (See page 7-104). 0x0D00-0x0D7F + {(CHAR16)0x0DFF, 0}, // Unassigned. 0x0D80-0x0DFF + {(CHAR16)0x0E7F, 1}, // Thai. 0x0E00-0x0E7F + {(CHAR16)0x0EFF, 1}, // Lao. 0x0E80-0x0EFF + {(CHAR16)0x0FBF, 1}, // Tibetan. 0x0F00-0x0FBF + {(CHAR16)0x109F, 0}, // Unassigned. 0x0FC0-0x109F + {(CHAR16)0x10FF, 1}, // Georgian. 0x10A0-0x10FF + {(CHAR16)0x11FF, 1}, // Hangul Jamo. 0x1100-0x11FF + {(CHAR16)0x1DFF, 0}, // Unassigned. 0x1200-0x1DFF + {(CHAR16)0x1EFF, 1}, // Latin extended additional. 0x1E00-0x1EFF + {(CHAR16)0x1FFF, 1}, // Greek extended. 0x1F00-0x1FFF + * + */ + + // + // Symbol area + // + {(CHAR16)0x2FFF, 1}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all narrow glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x206F, 1}, // General punctuation. (See page7-154). 0x200-0x206F + {(CHAR16)0x209F, 1}, // Superscripts and subscripts. 0x2070-0x209F + {(CHAR16)0x20CF, 1}, // Currency symbols. 0x20A0-0x20CF + {(CHAR16)0x20FF, 1}, // Combining diacritical marks for symbols. 0x20D0-0x20FF + {(CHAR16)0x214F, 1}, // Letterlike sympbols. 0x2100-0x214F + {(CHAR16)0x218F, 1}, // Number forms. 0x2150-0x218F + {(CHAR16)0x21FF, 1}, // Arrows. 0x2190-0x21FF + {(CHAR16)0x22FF, 1}, // Mathematical operators. 0x2200-0x22FF + {(CHAR16)0x23FF, 1}, // Miscellaneous technical. 0x2300-0x23FF + {(CHAR16)0x243F, 1}, // Control pictures. 0x2400-0x243F + {(CHAR16)0x245F, 1}, // Optical character recognition. 0x2440-0x245F + {(CHAR16)0x24FF, 1}, // Enclosed alphanumerics. 0x2460-0x24FF + {(CHAR16)0x257F, 1}, // Box drawing. 0x2500-0x257F + {(CHAR16)0x259F, 1}, // Block elements. 0x2580-0x259F + {(CHAR16)0x25FF, 1}, // Geometric shapes. 0x25A0-0x25FF + {(CHAR16)0x26FF, 1}, // Miscellaneous symbols. 0x2600-0x26FF + {(CHAR16)0x27BF, 1}, // Dingbats. 0x2700-0x27BF + {(CHAR16)0x2FFF, 0}, // Reserved. 0x27C0-0x2FFF + * + */ + + // + // CJK phonetics and symbol area + // + {(CHAR16)0x33FF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x303F, 2}, // CJK symbols and punctuation. 0x3000-0x303F + {(CHAR16)0x309F, 2}, // Hiragana. 0x3040-0x309F + {(CHAR16)0x30FF, 2}, // Katakana. 0x30A0-0x30FF + {(CHAR16)0x312F, 2}, // Bopomofo. 0x3100-0x312F + {(CHAR16)0x318F, 2}, // Hangul compatibility jamo. 0x3130-0x318F + {(CHAR16)0x319F, 2}, // Kanbun. 0x3190-0x319F + {(CHAR16)0x31FF, 0}, // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF + {(CHAR16)0x32FF, 2}, // Enclosed CJK letters and months. 0x3200-0x32FF + {(CHAR16)0x33FF, 2}, // CJK compatibility. 0x3300-0x33FF + * + */ + + // + // CJK ideograph area + // + {(CHAR16)0x9FFF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0x4DFF, 0}, // Reserved. 0x3400-0x4DBF as CJK unified ideographs + // extension A in ver3.0. 0x3400-0x4DFF + {(CHAR16)0x9FFF, 2}, // CJK unified ideographs. 0x4E00-0x9FFF + * + */ + + // + // Reserved + // + {(CHAR16)0xABFF, 0}, // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0 + // as Yi radicals in ver3.0. 0xA000-0xABFF + // + // Hangul syllables + // + {(CHAR16)0xD7FF, 2}, + /* + * Merge the blocks and replace them with the above entry as they fall to + * the same category and they are all wide glyph. This will reduce search + * time and table size. The merge will omit the reserved code. + * + * Remove the above item if below is un-commented. + * + {(CHAR16)0xD7A3, 2}, // Hangul syllables. 0xAC00-0xD7A3 + {(CHAR16)0xD7FF, 0}, // Reserved. 0xD7A3-0xD7FF + * + */ + + // + // Surrogates area + // + {(CHAR16)0xDFFF, 0}, // Surrogates, not used now. 0xD800-0xDFFF + + // + // Private use area + // + {(CHAR16)0xF8FF, 0}, // Private use area. 0xE000-0xF8FF + + // + // Compatibility area and specials + // + {(CHAR16)0xFAFF, 2}, // CJK compatibility ideographs. 0xF900-0xFAFF + {(CHAR16)0xFB4F, 1}, // Alphabetic presentation forms. 0xFB00-0xFB4F + {(CHAR16)0xFDFF, 1}, // Arabic presentation forms-A. 0xFB50-0xFDFF + {(CHAR16)0xFE1F, 0}, // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F + {(CHAR16)0xFE2F, 1}, // Combining half marks. 0xFE20-0xFE2F + {(CHAR16)0xFE4F, 2}, // CJK compatibility forms. 0xFE30-0xFE4F + {(CHAR16)0xFE6F, 1}, // Small Form Variants. 0xFE50-0xFE6F + {(CHAR16)0xFEFF, 1}, // Arabic presentation forms-B. 0xFE70-0xFEFF + {(CHAR16)0xFFEF, 1}, // Half width and full width forms. 0xFF00-0xFFEF + {(CHAR16)0xFFFF, 0}, // Speicials. 0xFFF0-0xFFFF +}; + +/** + This function computes and returns the width of the Unicode character + specified by UnicodeChar. + + @param UnicodeChar A Unicode character. + + @retval 0 The width if UnicodeChar could not be determined. + @retval 1 UnicodeChar is a narrow glyph. + @retval 2 UnicodeChar is a wide glyph. + +**/ +UINTN +EFIAPI +GlueGetGlyphWidth ( + IN CHAR16 UnicodeChar + ) +{ + UINTN Index; + UINTN Low; + UINTN High; + UNICODE_WIDTH_ENTRY *Item; + + Item = NULL; + Low = 0; + High = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1; + while (Low <= High) { + Index = (Low + High) >> 1; + Item = &(mUnicodeWidthTable[Index]); + if (Index == 0) { + if (UnicodeChar <= Item->WChar) { + break; + } + + return 0; + } + + if (UnicodeChar > Item->WChar) { + Low = Index + 1; + } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) { + High = Index - 1; + } else { + // + // Index - 1 < UnicodeChar <= Index. Found + // + break; + } + } + + if (Low <= High) { + return Item->Width; + } + + return 0; +} + +/** + This function computes and returns the display length of + the Null-terminated Unicode string specified by String. + If String is NULL, then 0 is returned. + If any of the widths of the Unicode characters in String + can not be determined, then 0 is returned. + + @param String A pointer to a Null-terminated Unicode string. + + @return The display length of the Null-terminated Unicode string specified by String. + +**/ +UINTN +EFIAPI +UnicodeStringDisplayLength ( + IN CONST CHAR16 *String + ) +{ + UINTN Length; + UINTN Width; + + if (String == NULL) { + return 0; + } + + Length = 0; + while (*String != 0) { + Width = GetGlyphWidth (*String); + if (Width == 0) { + return 0; + } + + Length += Width; + String++; + } + + return Length; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c new file mode 100644 index 0000000000..0454dacf69 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c @@ -0,0 +1,813 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +**/ + +#include "EdkIIGlueUefi.h" +#include "Library\EdkIIGlueMemoryAllocationLib.h" + + +/** + Compare whether two names of languages are identical. + + @param Language1 Name of language 1. + @param Language2 Name of language 2. + + @retval TRUE Language 1 and language 2 are the same. + @retval FALSE Language 1 and language 2 are not the same. + +**/ +STATIC +BOOLEAN +CompareIso639LanguageCode ( + IN CONST CHAR8 *Language1, + IN CONST CHAR8 *Language2 + ) +{ + UINT32 Name1; + UINT32 Name2; + + Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1); + Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2); + + return (BOOLEAN) (Name1 == Name2); +} + +/** + This function searches the list of configuration tables stored in the EFI System + Table for a table with a GUID that matches TableGuid. If a match is found, + then a pointer to the configuration table is returned in Table, and EFI_SUCCESS + is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. + + @param TableGuid Pointer to table's GUID type.. + @param Table Pointer to the table associated with TableGuid in the EFI System Table. + + @retval EFI_SUCCESS A configuration table matching TableGuid was found. + @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found. + +**/ +EFI_STATUS +EFIAPI +EfiGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + OUT VOID **Table + ) +{ + EFI_SYSTEM_TABLE *SystemTable; + UINTN Index; + + ASSERT (TableGuid != NULL); + ASSERT (Table != NULL); + + SystemTable = gST; + *Table = NULL; + for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) { + if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) { + *Table = SystemTable->ConfigurationTable[Index].VendorTable; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +/** + This function causes the notification function to be executed for every protocol + of type ProtocolGuid instance that exists in the system when this function is + invoked. In addition, every time a protocol of type ProtocolGuid instance is + installed or reinstalled, the notification function is also executed. + + @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @return The notification event that was created. + +**/ +EFI_EVENT +EFIAPI +EfiCreateProtocolNotifyEvent( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, OPTIONAL + OUT VOID **Registration + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + // + // Create the event + // + + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &Event + ); + ASSERT_EFI_ERROR (Status); + + // + // Register for protocol notifactions on this event + // + + Status = gBS->RegisterProtocolNotify ( + ProtocolGuid, + Event, + Registration + ); + + ASSERT_EFI_ERROR (Status); + + // + // Kick the event so we will perform an initial pass of + // current installed drivers + // + + gBS->SignalEvent (Event); + return Event; +} + +/** + This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. + This event is signaled with EfiNamedEventSignal(). This provide the ability for + one or more listeners on the same event named by the GUID specified by Name. + + @param Name Supplies GUID name of the event. + @param NotifyTpl Supplies the task priority level of the event notifications. + @param NotifyFunction Supplies the function to notify when the event is signaled. + @param NotifyContext The context parameter to pass to NotifyFunction. + @param Registration A pointer to a memory location to receive the registration value. + + @retval EFI_SUCCESS A named event was created. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventListen ( + IN CONST EFI_GUID *Name, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN CONST VOID *NotifyContext, OPTIONAL + OUT VOID *Registration OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + VOID *RegistrationLocal; + + // + // Create event + // + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + (VOID *) NotifyContext, + &Event + ); + ASSERT_EFI_ERROR (Status); + + // + // The Registration is not optional to RegisterProtocolNotify(). + // To make it optional to EfiNamedEventListen(), may need to substitute with a local. + // + if (Registration != NULL) { + RegistrationLocal = Registration; + } else { + RegistrationLocal = &RegistrationLocal; + } + + // + // Register for an installation of protocol interface + // + + Status = gBS->RegisterProtocolNotify ( + (EFI_GUID *) Name, + Event, + RegistrationLocal + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + This function signals the named event specified by Name. The named event must + have been created with EfiNamedEventListen(). + + @param Name Supplies GUID name of the event. + + @retval EFI_SUCCESS A named event was signaled. + @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event. + +**/ +EFI_STATUS +EFIAPI +EfiNamedEventSignal ( + IN CONST EFI_GUID *Name + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + (EFI_GUID *) Name, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->UninstallProtocolInterface ( + Handle, + (EFI_GUID *) Name, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + Returns the current TPL. + + This function returns the current TPL. There is no EFI service to directly + retrieve the current TPL. Instead, the RaiseTPL() function is used to raise + the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level + can then immediately be restored back to the current TPL level with a call + to RestoreTPL(). + + @param VOID + + @retvale EFI_TPL The current TPL. + +**/ +EFI_TPL +EFIAPI +EfiGetCurrentTpl ( + VOID + ) +{ + EFI_TPL Tpl; + + Tpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL); + gBS->RestoreTPL (Tpl); + + return Tpl; +} + + +/** + This function initializes a basic mutual exclusion lock to the released state + and returns the lock. Each lock provides mutual exclusion access at its task + priority level. Since there is no preemption or multiprocessor support in EFI, + acquiring the lock only consists of raising to the locks TPL. + + @param Lock A pointer to the lock data structure to initialize. + @param Priority EFI TPL associated with the lock. + + @return The lock. + +**/ +EFI_LOCK * +EFIAPI +GlueEfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +{ + ASSERT (Lock != NULL); + ASSERT (Priority <= EFI_TPL_HIGH_LEVEL); + + Lock->Tpl = Priority; + Lock->OwnerTpl = EFI_TPL_APPLICATION; + Lock->Lock = EfiLockReleased ; + return Lock; +} + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it places the lock in the + acquired state. + + @param Priority The task priority level of the lock. + +**/ +VOID +EFIAPI +GlueEfiAcquireLock ( + IN EFI_LOCK *Lock + ) +{ + ASSERT (Lock != NULL); + ASSERT (Lock->Lock == EfiLockReleased); + + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + Lock->Lock = EfiLockAcquired; +} + +/** + This function raises the system's current task priority level to the task + priority level of the mutual exclusion lock. Then, it attempts to place the + lock in the acquired state. + + @param Lock A pointer to the lock to acquire. + + @retval EFI_SUCCESS The lock was acquired. + @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned. + +**/ +EFI_STATUS +EFIAPI +GlueEfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +{ + + ASSERT (Lock != NULL); + ASSERT (Lock->Lock != EfiLockUninitialized); + + if (Lock->Lock == EfiLockAcquired) { + // + // Lock is already owned, so bail out + // + return EFI_ACCESS_DENIED; + } + + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + + Lock->Lock = EfiLockAcquired; + + return EFI_SUCCESS; +} + +/** + This function transitions a mutual exclusion lock from the acquired state to + the released state, and restores the system's task priority level to its + previous level. + + @param Lock A pointer to the lock to release. + +**/ +VOID +EFIAPI +GlueEfiReleaseLock ( + IN EFI_LOCK *Lock + ) +{ + EFI_TPL Tpl; + + ASSERT (Lock != NULL); + ASSERT (Lock->Lock == EfiLockAcquired); + + Tpl = Lock->OwnerTpl; + + Lock->Lock = EfiLockReleased; + + gBS->RestoreTPL (Tpl); +} + +/** + Tests whether a controller handle is being managed by a specific driver. + + This function tests whether the driver specified by DriverBindingHandle is + currently managing the controller specified by ControllerHandle. This test + is performed by evaluating if the the protocol specified by ProtocolGuid is + present on ControllerHandle and is was opened by DriverBindingHandle with an + attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a controller to test. + @param DriverBindingHandle Specifies the driver binding handle for the + driver. + @param ProtocolGuid Specifies the protocol that the driver specified + by DriverBindingHandle opens in its Start() + function. + + @retval EFI_SUCCESS ControllerHandle is managed by the driver + specifed by DriverBindingHandle. + @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver + specifed by DriverBindingHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestManagedDevice ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE DriverBindingHandle, + IN CONST EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + VOID *ManagedInterface; + + ASSERT (ProtocolGuid != NULL); + + Status = gBS->OpenProtocol ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + &ManagedInterface, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (!EFI_ERROR (Status)) { + gBS->CloseProtocol ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + DriverBindingHandle, + ControllerHandle + ); + return EFI_UNSUPPORTED; + } + + if (Status != EFI_ALREADY_STARTED) { + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** + Tests whether a child handle is a child device of the controller. + + This function tests whether ChildHandle is one of the children of + ControllerHandle. This test is performed by checking to see if the protocol + specified by ProtocolGuid is present on ControllerHandle and opened by + ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + If ProtocolGuid is NULL, then ASSERT(). + + @param ControllerHandle A handle for a (parent) controller to test. + @param ChildHandle A child handle to test. + @param ConsumsedGuid Supplies the protocol that the child controller + opens on its parent controller. + + @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. + @retval EFI_UNSUPPORTED ChildHandle is not a child of the + ControllerHandle. + +**/ +EFI_STATUS +EFIAPI +EfiTestChildHandle ( + IN CONST EFI_HANDLE ControllerHandle, + IN CONST EFI_HANDLE ChildHandle, + IN CONST EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; + UINTN EntryCount; + UINTN Index; + + ASSERT (ProtocolGuid != NULL); + + // + // Retrieve the list of agents that are consuming the specific protocol + // on ControllerHandle. + // + Status = gBS->OpenProtocolInformation ( + ControllerHandle, + (EFI_GUID *) ProtocolGuid, + &OpenInfoBuffer, + &EntryCount + ); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + // + // Inspect if ChildHandle is one of the agents. + // + Status = EFI_UNSUPPORTED; + for (Index = 0; Index < EntryCount; Index++) { + if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) && + (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { + Status = EFI_SUCCESS; + break; + } + } + + FreePool (OpenInfoBuffer); + return Status; +} + +/** + This function looks up a Unicode string in UnicodeStringTable. If Language is + a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable + that matches the language code specified by Language, then it is returned in + UnicodeString. + + @param Language A pointer to the ISO 639-2 language code for the + Unicode string to look up and return. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. Language + must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string from UnicodeStringTable + that matches the language specified by Language. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found + in the table of Unicoide strings UnicodeStringTable, + and it was returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + @retval EFI_UNSUPPORTED The language specified by Language is not + supported by UnicodeStringTable. + +**/ +EFI_STATUS +EFIAPI +LookupUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, + OUT CHAR16 **UnicodeString + ) +{ + // + // Make sure the parameters are valid + // + if (Language == NULL || UnicodeString == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, or the Unicode String Table is empty, then the + // Unicode String specified by Language is not supported by this Unicode String Table + // + if (SupportedLanguages == NULL || UnicodeStringTable == NULL) { + return EFI_UNSUPPORTED; + } + + // + // Make sure Language is in the set of Supported Languages + // + while (*SupportedLanguages != 0) { + if (CompareIso639LanguageCode (Language, SupportedLanguages)) { + + // + // Search the Unicode String Table for the matching Language specifier + // + while (UnicodeStringTable->Language != NULL) { + if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) { + + // + // A matching string was found, so return it + // + *UnicodeString = UnicodeStringTable->UnicodeString; + return EFI_SUCCESS; + } + + UnicodeStringTable++; + } + + return EFI_UNSUPPORTED; + } + + SupportedLanguages += 3; + } + + return EFI_UNSUPPORTED; +} + +/** + This function adds a Unicode string to UnicodeStringTable. + If Language is a member of SupportedLanguages then UnicodeString is added to + UnicodeStringTable. New buffers are allocated for both Language and + UnicodeString. The contents of Language and UnicodeString are copied into + these new buffers. These buffers are automatically freed when + FreeUnicodeStringTable() is called. + + @param Language A pointer to the ISO 639-2 language code for the Unicode + string to add. + @param SupportedLanguages A pointer to the set of ISO 639-2 language codes + that the Unicode string table supports. + Language must be a member of this set. + @param UnicodeStringTable A pointer to the table of Unicode strings. + @param UnicodeString A pointer to the Unicode string to add. + + @retval EFI_SUCCESS The Unicode string that matches the language + specified by Language was found in the table of + Unicode strings UnicodeStringTable, and it was + returned in UnicodeString. + @retval EFI_INVALID_PARAMETER Language is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is NULL. + @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. + @retval EFI_UNSUPPORTED SupportedLanguages is NULL. + @retval EFI_ALREADY_STARTED A Unicode string with language Language is + already present in UnicodeStringTable. + @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another + Unicode string to UnicodeStringTable. + @retval EFI_UNSUPPORTED The language specified by Language is not a + member of SupportedLanguages. + +**/ +EFI_STATUS +EFIAPI +AddUnicodeString ( + IN CONST CHAR8 *Language, + IN CONST CHAR8 *SupportedLanguages, + IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable, + IN CONST CHAR16 *UnicodeString + ) +{ + UINTN NumberOfEntries; + EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable; + EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable; + UINTN UnicodeStringLength; + + // + // Make sure the parameter are valid + // + if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // If there are no supported languages, then a Unicode String can not be added + // + if (SupportedLanguages == NULL) { + return EFI_UNSUPPORTED; + } + + // + // If the Unicode String is empty, then a Unicode String can not be added + // + if (UnicodeString[0] == 0) { + return EFI_INVALID_PARAMETER; + } + + // + // Make sure Language is a member of SupportedLanguages + // + while (*SupportedLanguages != 0) { + if (CompareIso639LanguageCode (Language, SupportedLanguages)) { + + // + // Determine the size of the Unicode String Table by looking for a NULL Language entry + // + NumberOfEntries = 0; + if (*UnicodeStringTable != NULL) { + OldUnicodeStringTable = *UnicodeStringTable; + while (OldUnicodeStringTable->Language != NULL) { + if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) { + return EFI_ALREADY_STARTED; + } + + OldUnicodeStringTable++; + NumberOfEntries++; + } + } + + // + // Allocate space for a new Unicode String Table. It must hold the current number of + // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table + // marker + // + NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE)); + if (NewUnicodeStringTable == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // If the current Unicode String Table contains any entries, then copy them to the + // newly allocated Unicode String Table. + // + if (*UnicodeStringTable != NULL) { + CopyMem ( + NewUnicodeStringTable, + *UnicodeStringTable, + NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE) + ); + } + + // + // Allocate space for a copy of the Language specifier + // + NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language); + if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) { + (gBS->FreePool) (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Compute the length of the Unicode String + // + for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++) + ; + + // + // Allocate space for a copy of the Unicode String + // + NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool ( + (UnicodeStringLength + 1) * sizeof (CHAR16), + UnicodeString + ); + if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) { + (gBS->FreePool) (NewUnicodeStringTable[NumberOfEntries].Language); + (gBS->FreePool) (NewUnicodeStringTable); + return EFI_OUT_OF_RESOURCES; + } + + // + // Mark the end of the Unicode String Table + // + NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL; + NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL; + + // + // Free the old Unicode String Table + // + if (*UnicodeStringTable != NULL) { + (gBS->FreePool) (*UnicodeStringTable); + } + + // + // Point UnicodeStringTable at the newly allocated Unicode String Table + // + *UnicodeStringTable = NewUnicodeStringTable; + + return EFI_SUCCESS; + } + + SupportedLanguages += 3; + } + + return EFI_UNSUPPORTED; +} + +/** + This function frees the table of Unicode strings in UnicodeStringTable. + If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. + Otherwise, each language code, and each Unicode string in the Unicode string + table are freed, and EFI_SUCCESS is returned. + + @param UnicodeStringTable A pointer to the table of Unicode strings. + + @retval EFI_SUCCESS The Unicode string table was freed. + +**/ +EFI_STATUS +EFIAPI +FreeUnicodeStringTable ( + IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable + ) +{ + UINTN Index; + + // + // If the Unicode String Table is NULL, then it is already freed + // + if (UnicodeStringTable == NULL) { + return EFI_SUCCESS; + } + + // + // Loop through the Unicode String Table until we reach the end of table marker + // + for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) { + + // + // Free the Language string from the Unicode String Table + // + (gBS->FreePool) (UnicodeStringTable[Index].Language); + + // + // Free the Unicode String from the Unicode String Table + // + if (UnicodeStringTable[Index].UnicodeString != NULL) { + (gBS->FreePool) (UnicodeStringTable[Index].UnicodeString); + } + } + + // + // Free the Unicode String Table itself + // + (gBS->FreePool) (UnicodeStringTable); + + return EFI_SUCCESS; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf new file mode 100644 index 0000000000..0d6b8ac429 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf @@ -0,0 +1,89 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# UefiLib.inf +# +# Abstract: +# +# Component description file for UefiLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiLib.c + Console.c + UefiNotTiano.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + EdkIIGlueBaseLib + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiBootServicesTableLib +# +# MemoryAllocationLib instance +# + EdkIIGlueDxeMemoryAllocationLib + EfiGuidLib + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c new file mode 100644 index 0000000000..8fbfaa6a1a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c @@ -0,0 +1,382 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UefiNotTiano.c + +Abstract: + + Library functions that abstract areas of conflict between Tiano an UEFI 2.0. + + Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the + oldconflicts with library functions and supporting implementations of the old + (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way. + +--*/ + +#include "EdkIIGlueUefi.h" + +/** + An empty function to pass error checking of CreateEventEx (). + + This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error + checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0. + +**/ +STATIC +VOID +EFIAPI +InternalEmptyFuntion ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + return; +} + +/** + Create a Legacy Boot Event. + + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventLegacyBoot ( + OUT EFI_EVENT *LegacyBootEvent + ) +{ + return EfiCreateEventLegacyBootEx ( + EFI_TPL_CALLBACK, + InternalEmptyFuntion, + NULL, + LegacyBootEvent + ); +} + +/** + Create an EFI event in the Legacy Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Legacy Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If LegacyBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventLegacyBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *LegacyBootEvent + ) +{ + EFI_STATUS Status; + + ASSERT (LegacyBootEvent != NULL); + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL, + NotifyTpl, + NotifyFunction, + NotifyContext, + LegacyBootEvent + ); +#else + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &gEfiEventLegacyBootGuid, + LegacyBootEvent + ); +#endif + + return Status; +} + +/** + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to + work both ways. + + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +GlueEfiCreateEventReadyToBoot ( + OUT EFI_EVENT *ReadyToBootEvent + ) +{ + return EfiCreateEventReadyToBootEx ( + EFI_TPL_CALLBACK, + InternalEmptyFuntion, + NULL, + ReadyToBootEvent + ); +} + +/** + Create an EFI event in the Ready To Boot Event Group and allows + the caller to specify a notification function. + + This function abstracts the creation of the Ready to Boot Event. + The Framework moved from a proprietary to UEFI 2.0 based mechanism. + This library abstracts the caller from how this event is created to prevent + to code form having to change with the version of the specification supported. + If ReadyToBootEvent is NULL, then ASSERT(). + + @param NotifyTpl The task priority level of the event. + @param NotifyFunction The notification function to call when the event is signaled. + @param NotifyContext The content to pass to NotifyFunction when the event is signaled. + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +EfiCreateEventReadyToBootEx ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToBootEvent + ) +{ + EFI_STATUS Status; + + ASSERT (ReadyToBootEvent != NULL); + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL, + NotifyTpl, + NotifyFunction, + NotifyContext, + ReadyToBootEvent + ); +#else + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &gEfiEventReadyToBootGuid, + ReadyToBootEvent + ); +#endif + + return Status; +} + + +/** + Signal a Ready to Boot Event. + + Create a Ready to Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventReadyToBoot ( + VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT ReadyToBootEvent; + + Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent); + if (!EFI_ERROR (Status)) { + gBS->SignalEvent (ReadyToBootEvent); + gBS->CloseEvent (ReadyToBootEvent); + } +} + +/** + Signal a Legacy Boot Event. + + Create a legacy Boot Event. Signal it and close it. This causes other + events of the same event group to be signaled in other modules. + +**/ +VOID +EFIAPI +EfiSignalEventLegacyBoot ( + VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT LegacyBootEvent; + + Status = EfiCreateEventLegacyBoot (&LegacyBootEvent); + if (!EFI_ERROR (Status)) { + gBS->SignalEvent (LegacyBootEvent); + gBS->CloseEvent (LegacyBootEvent); + } +} + + +/** + Check to see if the Firmware Volume (FV) Media Device Path is valid + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. The return value to this + function points to a location in FvDevicePathNode and it does not allocate + new memory for the GUID pointer that is returned. + + @param FvDevicePathNode Pointer to FV device path to check. + + @retval NULL FvDevicePathNode is not valid. + @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned. + +**/ +EFI_GUID * +EFIAPI +GlueEfiGetNameGuidFromFwVolDevicePathNode ( + IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ) +{ + ASSERT (FvDevicePathNode != NULL); + +#if (EFI_SPECIFICATION_VERSION != 0x00020000) + // + // Use old Device Path + // + if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) { + return (EFI_GUID *) &FvDevicePathNode->NameGuid; + } + +#else + // + // Use the new Device path that does not conflict with the UEFI 2.0 + // + // check here : piwg or tiano + if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) { + if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) { + if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) { + return (EFI_GUID *) &FvDevicePathNode->NameGuid; + } + } + } +#endif + return NULL; +} + + +/** + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + + @param FvDevicePathNode Pointer to a FV device path node to initialize + @param NameGuid FV file name to use in FvDevicePathNode + +**/ +VOID +EFIAPI +GlueEfiInitializeFwVolDevicepathNode ( + IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN CONST EFI_GUID *NameGuid + ) +{ + ASSERT (FvDevicePathNode != NULL); + ASSERT (NameGuid != NULL); + +#if (EFI_SPECIFICATION_VERSION != 0x00020000) + // + // Use old Device Path + // + FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + +#else + // + // Use the new Device path that does not conflict with the UEFI 2.0 + // + FvDevicePathNode->Piwg.Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Piwg.Header.SubType = MEDIA_VENDOR_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + + // + // Add the GUID for generic PIWG device paths + // + CopyGuid (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid); + + // + // Add in the FW Vol File Path PIWG defined inforation + // + FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE; + +#endif + + CopyGuid (&FvDevicePathNode->NameGuid, NameGuid); + +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c new file mode 100644 index 0000000000..77ee80aaf5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + UefiRuntimeServicesTableLib.c + +Abstract: + + UEFI Runtime Services Table Library. + +--*/ + +#include "EdkIIGlueUefi.h" + +EFI_RUNTIME_SERVICES *gRT = NULL; + +/** + The constructor function caches the pointer of Runtime Services Table. + + The constructor function caches the pointer of Runtime Services Table. + It will ASSERT() if the pointer of Runtime Services Table is NULL. + It will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +UefiRuntimeServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + // + // Cache pointer to the EFI Runtime Services Table + // + gRT = SystemTable->RuntimeServices; + ASSERT (gRT != NULL); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf new file mode 100644 index 0000000000..86c499cf44 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf @@ -0,0 +1,78 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# UefiRuntimeServicesTableLib.inf +# +# Abstract: +# +# Component description file for UefiRuntimeServicesTableLib. +# +#--*/ + +[defines] +BASE_NAME = EdkIIGlueUefiRuntimeServicesTableLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + UefiRuntimeServicesTableLib.c + +[sources.ia32] + +[sources.x64] + +[sources.ipf] + +[sources.ebc] + + +[includes.common] + . + ..\..\Include + ..\..\include\Library + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath + +[libraries.common] + +[libraries.ia32] + + +[libraries.x64] + + +[nmake.common] + C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 + +[nmake.ia32] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32 + +[nmake.x64] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64 + +[nmake.ipf] + C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF + +[nmake.ebc] + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION + EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 + EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf new file mode 100644 index 0000000000..561345fb5d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf @@ -0,0 +1,84 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiCommonLib.inf +# +# Abstract: +# +# Component description file for the EFI common library. +# +#--*/ + +[defines] +BASE_NAME = EfiCommonLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + EfiCompareGuid.c + EfiCompareMem.c + ReportStatusCode.c + PostCode.c + String.c + ValueToString.c + LinkedList.c + +[sources.ia32] + Ia32\EfiCopyMem.c + Ia32\EfiSetMem.c + Ia32\EfiZeroMem.c + Ia32\LShiftU64.c + Ia32\RShiftU64.c + Ia32\MultU64x32.c + Ia32\DivU64x32.c + Ia32\Power10U64.c + Ia32\Log2.c + Ia32\GetPowerOfTwo.c + +[sources.ipf] + EfiCopyMem.c + EfiSetMem.c + EfiZeroMem.c + Math.c + +[sources.ebc] + EfiCopyMem.c + EfiSetMem.c + EfiZeroMem.c + Math.c + +[sources.x64] + x64\EfiCopyMem.asm + x64\EfiSetMem.asm + x64\EfiZeroMem.asm + Math.c + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE) + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo + $(EDK_SOURCE)\Foundation\Framework + +[libraries.common] + EdkFrameworkGuidLib + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareGuid.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareGuid.c new file mode 100644 index 0000000000..ffaec95368 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareGuid.c @@ -0,0 +1,59 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCompareGuid.c + +Abstract: + + Driver library routine to compare two GUIDs. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +BOOLEAN +EfiCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +/*++ + +Routine Description: + + Compares two GUIDs + +Arguments: + + Guid1 - guid to compare + + Guid2 - guid to compare + +Returns: + TRUE if Guid1 == Guid2 + FALSE if Guid1 != Guid2 + +--*/ +{ + UINTN Index; + + // + // compare byte by byte + // + for (Index = 0; Index < 16; ++Index) { + if (*(((UINT8*) Guid1) + Index) != *(((UINT8*) Guid2) + Index)) { + return FALSE; + } + } + return TRUE; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c new file mode 100644 index 0000000000..d640b9dc68 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c @@ -0,0 +1,76 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCompareMem.c + +Abstract: + + Generic compare-memory routine. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + + +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Length + ) +/*++ + +Routine Description: + + Compares two memory buffers of a given length. + +Arguments: + + MemOne - First memory buffer + + MemTwo - Second memory buffer + + Len - Length of Mem1 and Mem2 memory regions to compare + +Returns: + + = 0 if MemOne == MemTwo + +--*/ +{ + INTN ReturnValue; + + if (!(EFI_UINTN_ALIGNED (MemOne) || EFI_UINTN_ALIGNED (MemTwo) || EFI_UINTN_ALIGNED (Length))) { + // + // If Destination/Source/Length are aligned do UINTN conpare + // + for (; Length > 0; Length -= sizeof (INTN), MemOne = (VOID *)((UINTN)MemOne + sizeof (INTN)), MemTwo = (VOID *)((UINTN)MemTwo + sizeof (INTN))) { + if (*(INTN *)MemOne != *(INTN *)MemTwo) { + break; + } + } + } + + // + // If Destination/Source/Length not aligned do byte compare + // + for (; Length > 0; Length--, MemOne = (VOID *)((UINTN)MemOne + 1), MemTwo = (VOID *)((UINTN)MemTwo + 1)) { + ReturnValue = (INTN)(*(INT8 *)MemOne - *(INT8 *)MemTwo); + if (ReturnValue != 0) { + return ReturnValue; + } + } + + return 0; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c new file mode 100644 index 0000000000..56c1dbd3b2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c @@ -0,0 +1,69 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCopyMem.c + +Abstract: + + Implementation of the EfiCopyMem routine. This function is broken + out into its own source file so that it can be excluded from a + build for a particular platform easily if an optimized version + is desired. + +--*/ + +#include "Tiano.h" + +VOID +EfiCommonLibCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + + if (Source < Destination) { + Destination8 = (CHAR8 *) Destination + Length - 1; + Source8 = (CHAR8 *) Source + Length - 1; + while (Length--) { + *(Destination8--) = *(Source8--); + } + } else { + Destination8 = (CHAR8 *) Destination; + Source8 = (CHAR8 *) Source; + while (Length--) { + *(Destination8++) = *(Source8++); + } + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiSetMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiSetMem.c new file mode 100644 index 0000000000..c677b6c602 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiSetMem.c @@ -0,0 +1,65 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiSetMem.c + +Abstract: + + Implementation of the EfiSetMem routine. This function is broken + out into its own source file so that it can be excluded from a + build for a particular platform easily if an optimized version + is desired. + +--*/ + +#include "Tiano.h" +#include "EfiCommonLib.h" + + +VOID +EfiCommonLibSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +/*++ + +Routine Description: + + Set Buffer to Value for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + + Value - Value of the set operation. + +Returns: + + None + +--*/ +{ + INT8 *Ptr; + + if (Value == 0) { + EfiCommonLibZeroMem (Buffer, Size); + } else { + Ptr = Buffer; + while (Size--) { + *(Ptr++) = Value; + } + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiZeroMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiZeroMem.c new file mode 100644 index 0000000000..5097be51b6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiZeroMem.c @@ -0,0 +1,57 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiZeroMem.c + +Abstract: + + Implementation of the EfiSetMem routine. This function is broken + out into its own source file so that it can be excluded from a + build for a particular platform easily if an optimized version + is desired. + +--*/ + +#include "Tiano.h" + + +VOID +EfiCommonLibZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + Set Buffer to 0 for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + +Returns: + + None + +--*/ +{ + INT8 *Ptr; + + Ptr = Buffer; + while (Size--) { + *(Ptr++) = 0; + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.c new file mode 100644 index 0000000000..51aedf7c2e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.c @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DivU64x32.c + +Abstract: + + 64-bit division function for IA-32 + +--*/ + +#include "Tiano.h" + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be divided with a 32 bit value returns + 64bit result and the Remainder. + +Arguments: + + Dividend - dividend + Divisor - divisor + Remainder - buffer for remainder + +Returns: + + Dividend / Divisor + Remainder = Dividend mod Divisor + +N.B. only works for 31bit divisors!! + +--*/ +{ + __asm { + xor edx, edx ; Clear EDX + + mov eax, dword ptr Dividend[4] ; Put high 32 bits of 64-bit dividend in EAX + mov ecx, Divisor ; Put 32 bits divisor in ECX + div ecx ; Dividend Divisor Quoitent...Remainder + ; 0:EAX / ECX = EAX EDX + + push eax ; Push quoitent in stack + + mov eax, dword ptr Dividend[0] ; Put low 32 bits of 64-bit dividend in EAX + div ecx ; Leave the REMAINDER in EDX as High 32-bit of new dividend + ; Dividend Divisor Quoitent...Remainder + ; EDX:EAX / ECX = EAX EDX + + mov ecx, Remainder ; Put &REMAINDER to ecx + + jecxz Label1 ; If ecx == 0, no remainder exist, return with quoitent in EDX directly + mov dword ptr [ecx], edx ; Put EDX through REMAINDER pointer in ECX + +Label1: + pop edx ; Pop High 32-bit QUOITENT to EDX + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c new file mode 100644 index 0000000000..8ef88513c8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c @@ -0,0 +1,184 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCopyMem.c + +Abstract: + + This is the code that supports IA32-optimized CopyMem service + +--*/ + +#include "Tiano.h" + +VOID +EfiCommonLibCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Count + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +{ + UINT64 MmxSave; + __asm { + + mov ecx, Count + mov esi, Source + mov edi, Destination + + ; First off, make sure we have no overlap. That is to say, + ; if (Source == Destination) => do nothing + ; if (Source + Count <= Destination) => regular copy + ; if (Destination + Count <= Source) => regular copy + ; otherwise, do a reverse copy + mov eax, esi + add eax, ecx ; Source + Count + cmp eax, edi + jle _StartByteCopy + + mov eax, edi + add eax, ecx ; Dest + Count + cmp eax, esi + jle _StartByteCopy + + cmp esi, edi + je _CopyMemDone + jl _CopyOverlapped ; too bad -- overlaps + + ; Pick up misaligned start bytes to get destination pointer 4-byte aligned +_StartByteCopy: + cmp ecx, 0 + je _CopyMemDone ; Count == 0, all done + mov edx, edi + and dl, 3 ; check lower 2 bits of address + test dl, dl + je SHORT _CopyBlocks ; already aligned? + + ; Copy a byte + mov al, BYTE PTR [esi] ; get byte from Source + mov BYTE PTR [edi], al ; write byte to Destination + dec ecx + inc edi + inc esi + jmp _StartByteCopy ; back to top of loop + +_CopyBlocks: + ; Compute how many 64-byte blocks we can clear + mov eax, ecx ; get Count in eax + shr eax, 6 ; convert to 64-byte count + shl eax, 6 ; convert back to bytes + sub ecx, eax ; subtract from the original count + shr eax, 6 ; and this is how many 64-byte blocks + + ; If no 64-byte blocks, then skip + cmp eax, 0 + je _CopyRemainingDWords + + ; Save mm0 + movq MmxSave, mm0 + +copymmx: + + movq mm0, QWORD PTR ds:[esi] + movq QWORD PTR ds:[edi], mm0 + movq mm0, QWORD PTR ds:[esi+8] + movq QWORD PTR ds:[edi+8], mm0 + movq mm0, QWORD PTR ds:[esi+16] + movq QWORD PTR ds:[edi+16], mm0 + movq mm0, QWORD PTR ds:[esi+24] + movq QWORD PTR ds:[edi+24], mm0 + movq mm0, QWORD PTR ds:[esi+32] + movq QWORD PTR ds:[edi+32], mm0 + movq mm0, QWORD PTR ds:[esi+40] + movq QWORD PTR ds:[edi+40], mm0 + movq mm0, QWORD PTR ds:[esi+48] + movq QWORD PTR ds:[edi+48], mm0 + movq mm0, QWORD PTR ds:[esi+56] + movq QWORD PTR ds:[edi+56], mm0 + + add edi, 64 + add esi, 64 + dec eax + jnz copymmx + +; Restore mm0 + movq mm0, MmxSave + emms ; Exit MMX Instruction + + ; Copy as many DWORDS as possible +_CopyRemainingDWords: + cmp ecx, 4 + jb _CopyRemainingBytes + + mov eax, DWORD PTR [esi] ; get data from Source + mov DWORD PTR [edi], eax ; write byte to Destination + sub ecx, 4 ; decrement Count + add esi, 4 ; advance Source pointer + add edi, 4 ; advance Destination pointer + jmp _CopyRemainingDWords ; back to top + +_CopyRemainingBytes: + cmp ecx, 0 + je _CopyMemDone + mov al, BYTE PTR [esi] ; get byte from Source + mov BYTE PTR [edi], al ; write byte to Destination + dec ecx + inc esi + inc edi ; advance Destination pointer + jmp SHORT _CopyRemainingBytes ; back to top of loop + + ; + ; We do this block if the source and destination buffers overlap. To + ; handle it, copy starting at the end of the source buffer and work + ; your way back. Since this is the atypical case, this code has not + ; been optimized, and thus simply copies bytes. + ; +_CopyOverlapped: + + ; Move the source and destination pointers to the end of the range + add esi, ecx ; Source + Count + dec esi + add edi, ecx ; Dest + Count + dec edi + +_CopyOverlappedLoop: + cmp ecx, 0 + je _CopyMemDone + mov al, BYTE PTR [esi] ; get byte from Source + mov BYTE PTR [edi], al ; write byte to Destination + dec ecx + dec esi + dec edi + jmp _CopyOverlappedLoop ; back to top of loop + +_CopyMemDone: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c new file mode 100644 index 0000000000..e3b23f92a0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c @@ -0,0 +1,169 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCopyMemSSE2.c + +Abstract: + + This is the code that supports IA32-optimized CopyMem service + +--*/ + +#include "Tiano.h" + +VOID +EfiCommonLibCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Count + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +{ + __asm { + mov ecx, Count + mov esi, Source + mov edi, Destination + + ; First off, make sure we have no overlap. That is to say, + ; if (Source == Destination) => do nothing + ; if (Source + Count <= Destination) => regular copy + ; if (Destination + Count <= Source) => regular copy + ; otherwise, do a reverse copy + mov eax, esi + add eax, ecx ; Source + Count + cmp eax, edi + jle _StartByteCopy + + mov eax, edi + add eax, ecx ; Dest + Count + cmp eax, esi + jle _StartByteCopy + + cmp esi, edi + je _CopyMemDone + jl _CopyOverlapped ; too bad -- overlaps + + ; Pick up misaligned start bytes to get destination pointer 4-byte aligned +_StartByteCopy: + cmp ecx, 0 + je _CopyMemDone ; Count == 0, all done + mov edx, edi + and dl, 3 ; check lower 2 bits of address + test dl, dl + je SHORT _CopyBlocks ; already aligned? + + ; Copy a byte + mov al, BYTE PTR [esi] ; get byte from Source + mov BYTE PTR [edi], al ; write byte to Destination + dec ecx + inc edi + inc esi + jmp _StartByteCopy ; back to top of loop + +_CopyBlocks: + ; Compute how many 64-byte blocks we can clear + mov eax, ecx ; get Count in eax + shr eax, 6 ; convert to 64-byte count + shl eax, 6 ; convert back to bytes + sub ecx, eax ; subtract from the original count + shr eax, 6 ; and this is how many 64-byte blocks + + ; If no 64-byte blocks, then skip + cmp eax, 0 + je _CopyRemainingDWords + + +copyxmm: + + movdqu xmm0, OWORD PTR ds:[esi] + movdqu QWORD PTR ds:[edi], xmm0 + movdqu xmm1, OWORD PTR ds:[esi+16] + movdqu QWORD PTR ds:[edi+16], xmm1 + movdqu xmm2, OWORD PTR ds:[esi+32] + movdqu QWORD PTR ds:[edi+32], xmm2 + movdqu xmm3, OWORD PTR ds:[esi+48] + movdqu QWORD PTR ds:[edi+48], xmm3 + + add edi, 64 + add esi, 64 + dec eax + jnz copyxmm + + + ; Copy as many DWORDS as possible +_CopyRemainingDWords: + cmp ecx, 4 + jb _CopyRemainingBytes + + mov eax, DWORD PTR [esi] ; get data from Source + mov DWORD PTR [edi], eax ; write byte to Destination + sub ecx, 4 ; decrement Count + add esi, 4 ; advance Source pointer + add edi, 4 ; advance Destination pointer + jmp _CopyRemainingDWords ; back to top + +_CopyRemainingBytes: + cmp ecx, 0 + je _CopyMemDone + mov al, BYTE PTR [esi] ; get byte from Source + mov BYTE PTR [edi], al ; write byte to Destination + dec ecx + inc esi + inc edi ; advance Destination pointer + jmp SHORT _CopyRemainingBytes ; back to top of loop + + ; + ; We do this block if the source and destination buffers overlap. To + ; handle it, copy starting at the end of the source buffer and work + ; your way back. Since this is the atypical case, this code has not + ; been optimized, and thus simply copies bytes. + ; +_CopyOverlapped: + + ; Move the source and destination pointers to the end of the range + add esi, ecx ; Source + Count + dec esi + add edi, ecx ; Dest + Count + dec edi + +_CopyOverlappedLoop: + cmp ecx, 0 + je _CopyMemDone + mov al, BYTE PTR [esi] ; get byte from Source + mov BYTE PTR [edi], al ; write byte to Destination + dec ecx + dec esi + dec edi + jmp _CopyOverlappedLoop ; back to top of loop + +_CopyMemDone: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c new file mode 100644 index 0000000000..2543679c58 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c @@ -0,0 +1,139 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiSetMem.c + +Abstract: + + This is the code that supports IA32-optimized SetMem service + +--*/ + +#include "Tiano.h" + +VOID +EfiCommonLibSetMem ( + IN VOID *Buffer, + IN UINTN Count, + IN UINT8 Value + ) +/*++ + +Input: VOID *Buffer - Pointer to buffer to write + UINTN Count - Number of bytes to write + UINT8 Value - Value to write + +Output: None. + +Saves: + +Modifies: + +Description: This function is an optimized set-memory function. + +Notes: This function tries to set memory 8 bytes at a time. As a result, + it first picks up any misaligned bytes, then words, before getting + in the main loop that does the 8-byte clears. + +--*/ +{ + UINT64 QWordValue; + UINT64 MmxSave; + __asm { + mov edx, Count + test edx, edx + je _SetMemDone + + push ebx + + mov eax, Buffer + mov bl, Value + mov edi, eax + mov bh, bl + + cmp edx, 256 + jb _SetRemindingByte + + and al, 07h + test al, al + je _SetBlock + + mov eax, edi + shr eax, 3 + inc eax + shl eax, 3 + sub eax, edi + cmp eax, edx + jnb _SetRemindingByte + + sub edx, eax + mov ecx, eax + + mov al, bl + rep stosb + +_SetBlock: + mov eax, edx + shr eax, 6 + test eax, eax + je _SetRemindingByte + + shl eax, 6 + sub edx, eax + shr eax, 6 + + mov WORD PTR QWordValue[0], bx + mov WORD PTR QWordValue[2], bx + mov WORD PTR QWordValue[4], bx + mov WORD PTR QWordValue[6], bx + + + movq MmxSave, mm0 + movq mm0, QWordValue + +_B: + movq QWORD PTR ds:[edi], mm0 + movq QWORD PTR ds:[edi+8], mm0 + movq QWORD PTR ds:[edi+16], mm0 + movq QWORD PTR ds:[edi+24], mm0 + movq QWORD PTR ds:[edi+32], mm0 + movq QWORD PTR ds:[edi+40], mm0 + movq QWORD PTR ds:[edi+48], mm0 + movq QWORD PTR ds:[edi+56], mm0 + add edi, 64 + dec eax + jnz _B + +; Restore mm0 + movq mm0, MmxSave + emms ; Exit MMX Instruction + +_SetRemindingByte: + mov ecx, edx + + mov eax, ebx + shl eax, 16 + mov ax, bx + shr ecx, 2 + rep stosd + + mov ecx, edx + and ecx, 3 + rep stosb + + pop ebx + +_SetMemDone: + + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c new file mode 100644 index 0000000000..06cb5e26c3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c @@ -0,0 +1,141 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiSetMemSSE2.c + +Abstract: + + This is the code that supports IA32-optimized SetMem service + +--*/ + +#include "Tiano.h" + +VOID +EfiCommonLibSetMem ( + IN VOID *Buffer, + IN UINTN Count, + IN UINT8 Value + ) +/*++ + +Input: VOID *Buffer - Pointer to buffer to write + UINTN Count - Number of bytes to write + UINT8 Value - Value to write + +Output: None. + +Saves: + +Modifies: + +Description: This function is an optimized set-memory function. + +Notes: This function tries to set memory 8 bytes at a time. As a result, + it first picks up any misaligned bytes, then words, before getting + in the main loop that does the 8-byte clears. + +--*/ +{ + UINT64 QWordValue; + UINT64 MmxSave; + __asm { + mov edx, Count + test edx, edx + je _SetMemDone + + push ebx + + mov eax, Buffer + mov bl, Value + mov edi, eax + mov bh, bl + + cmp edx, 256 + jb _SetRemindingByte + + and al, 0fh + test al, al + je _SetBlock + + mov eax, edi + shr eax, 4 + inc eax + shl eax, 4 + sub eax, edi + cmp eax, edx + jnb _SetRemindingByte + + sub edx, eax + mov ecx, eax + + mov al, bl + rep stosb + +_SetBlock: + mov eax, edx + shr eax, 7 + test eax, eax + je _SetRemindingByte + + shl eax, 7 + sub edx, eax + shr eax, 7 + + mov WORD PTR QWordValue[0], bx + mov WORD PTR QWordValue[2], bx + mov WORD PTR QWordValue[4], bx + mov WORD PTR QWordValue[6], bx + + + movq MmxSave, mm0 + movq mm0, QWordValue + + movq2dq xmm1, mm0 + pshufd xmm1, xmm1, 0 + +_Loop: + movdqa OWORD PTR ds:[edi], xmm1 + movdqa OWORD PTR ds:[edi+16], xmm1 + movdqa OWORD PTR ds:[edi+32], xmm1 + movdqa OWORD PTR ds:[edi+48], xmm1 + movdqa OWORD PTR ds:[edi+64], xmm1 + movdqa OWORD PTR ds:[edi+80], xmm1 + movdqa OWORD PTR ds:[edi+96], xmm1 + movdqa OWORD PTR ds:[edi+112], xmm1 + add edi, 128 + dec eax + jnz _Loop + +; Restore mm0 + movq mm0, MmxSave + emms ; Exit MMX Instruction + +_SetRemindingByte: + mov ecx, edx + + mov eax, ebx + shl eax, 16 + mov ax, bx + shr ecx, 2 + rep stosd + + mov ecx, edx + and ecx, 3 + rep stosb + + pop ebx + +_SetMemDone: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.c new file mode 100644 index 0000000000..fc9ed7b621 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.c @@ -0,0 +1,122 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiZeroMem.c + +Abstract: + + This is the code that supports IA32-optimized ZeroMem service + +--*/ + +#include "Tiano.h" + +VOID +EfiCommonLibZeroMem ( + IN VOID *Buffer, + IN UINTN Count + ) +/*++ + +Input: VOID *Buffer - Pointer to buffer to clear + UINTN Count - Number of bytes to clear + +Output: None. + +Saves: + +Modifies: + +Description: This function is an optimized zero-memory function. + +Notes: This function tries to zero memory 8 bytes at a time. As a result, + it first picks up any misaligned bytes, then words, before getting + in the main loop that does the 8-byte clears. + +--*/ +{ + UINT64 MmxSave; + __asm { + mov ecx, Count + mov edi, Buffer + + ; Pick up misaligned start bytes (get pointer 4-byte aligned) +_StartByteZero: + mov eax, edi + and al, 3 ; check lower 2 bits of address + test al, al + je _ZeroBlocks ; already aligned? + cmp ecx, 0 + je _ZeroMemDone + + ; Clear the byte memory location + mov BYTE PTR [edi], 0 + inc edi + + ; Decrement our count + dec ecx + jmp _StartByteZero ; back to top of loop + +_ZeroBlocks: + + ; Compute how many 64-byte blocks we can clear + mov edx, ecx + shr ecx, 6 ; convert to 64-byte count + shl ecx, 6 ; convert back to bytes + sub edx, ecx ; subtract from the original count + shr ecx, 6 ; and this is how many 64-byte blocks + + ; If no 64-byte blocks, then skip + cmp ecx, 0 + je _ZeroRemaining + + ; Save mm0 + movq MmxSave, mm0 + + pxor mm0, mm0 ; Clear mm0 + +_B: + movq QWORD PTR ds:[edi], mm0 + movq QWORD PTR ds:[edi+8], mm0 + movq QWORD PTR ds:[edi+16], mm0 + movq QWORD PTR ds:[edi+24], mm0 + movq QWORD PTR ds:[edi+32], mm0 + movq QWORD PTR ds:[edi+40], mm0 + movq QWORD PTR ds:[edi+48], mm0 + movq QWORD PTR ds:[edi+56], mm0 + + add edi, 64 + dec ecx + jnz _B + +; Restore mm0 + movq mm0, MmxSave + emms ; Exit MMX Instruction + +_ZeroRemaining: + ; Zero out as many DWORDS as possible + mov ecx, edx + shr ecx, 2 + xor eax, eax + + rep stosd + + ; Zero out remaining as bytes + mov ecx, edx + and ecx, 03 + + rep stosb + +_ZeroMemDone: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.c new file mode 100644 index 0000000000..316ff20e8a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.c @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiZeroMemSSE2.c + +Abstract: + + This is the code that supports IA32-optimized ZeroMem service + +--*/ + +#include "Tiano.h" + +VOID +EfiCommonLibZeroMem ( + IN VOID *Buffer, + IN UINTN Count + ) +/*++ + +Input: VOID *Buffer - Pointer to buffer to clear + UINTN Count - Number of bytes to clear + +Output: None. + +Saves: + +Modifies: + +Description: This function is an optimized zero-memory function. + +Notes: This function tries to zero memory 8 bytes at a time. As a result, + it first picks up any misaligned bytes, then words, before getting + in the main loop that does the 8-byte clears. + +--*/ +{ + __asm { + mov ecx, Count + mov edi, Buffer + + ; Pick up misaligned start bytes (get pointer 4-byte aligned) +_StartByteZero: + mov eax, edi + and al, 3 ; check lower 2 bits of address + test al, al + je _ZeroBlocks ; already aligned? + cmp ecx, 0 + je _ZeroMemDone + + ; Clear the byte memory location + mov BYTE PTR [edi], 0 + inc edi + + ; Decrement our count + dec ecx + jmp _StartByteZero ; back to top of loop + +_ZeroBlocks: + + ; Compute how many 64-byte blocks we can clear + mov edx, ecx + shr ecx, 6 ; convert to 64-byte count + shl ecx, 6 ; convert back to bytes + sub edx, ecx ; subtract from the original count + shr ecx, 6 ; and this is how many 64-byte blocks + + ; If no 64-byte blocks, then skip + cmp ecx, 0 + je _ZeroRemaining + + xorps xmm1, xmm1 + +_B: + movdqu OWORD PTR ds:[edi], xmm1 + movdqu OWORD PTR ds:[edi+16], xmm1 + movdqu OWORD PTR ds:[edi+32], xmm1 + movdqu OWORD PTR ds:[edi+48], xmm1 + + add edi, 64 + dec ecx + jnz _B + + +_ZeroRemaining: + ; Zero out as many DWORDS as possible + mov ecx, edx + shr ecx, 2 + xor eax, eax + + rep stosd + + ; Zero out remaining as bytes + mov ecx, edx + and ecx, 03 + + rep stosb + +_ZeroMemDone: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c new file mode 100644 index 0000000000..665fa02136 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.c @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GetPowerOfTwo.c + +Abstract: + + Calculates the largest integer that is both + a power of two and less than Input + +--*/ + +#include "Tiano.h" + +UINT64 +GetPowerOfTwo ( + IN UINT64 Input + ) +/*++ + +Routine Description: + + Calculates the largest integer that is both + a power of two and less than Input + +Arguments: + + Input - value to calculate power of two + +Returns: + + the largest integer that is both a power of + two and less than Input + +--*/ +{ + __asm { + xor eax, eax + mov edx, eax + mov ecx, dword ptr Input[4] + jecxz _F + bsr ecx, ecx + bts edx, ecx + jmp _Exit +_F: + mov ecx, dword ptr Input[0] + jecxz _Exit + bsr ecx, ecx + bts eax, ecx +_Exit: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.c new file mode 100644 index 0000000000..0636b12d72 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.c @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LShiftU64.c + +Abstract: + + 64-bit left shift function for IA-32 + +--*/ + +#include "Tiano.h" + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be left shifted by 32 bits and + returns the shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift left. + +Returns: + + Value shifted left identified by the Count. + +--*/ +{ + __asm { + + mov eax, dword ptr Operand[0] + mov edx, dword ptr Operand[4] + + ; + ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EAX is not touched + ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move eax to edx later. + ; + mov ecx, Count + and ecx, 63 + shld edx, eax, cl + shl eax, cl + + ; + ; Since Count is 32 - 63, eax will have been shifted by 0 - 31 + ; If shifted by 32 or more, set lower 32 bits to zero. + ; + cmp ecx, 32 + jc short _LShiftU64_Done + + mov edx, eax + xor eax, eax + +_LShiftU64_Done: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c new file mode 100644 index 0000000000..7e6db880e1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Log2.c @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Log2.c + +Abstract: + + 64-bit integer logarithm function for IA-32 + +--*/ + +#include "Tiano.h" + +UINT8 +Log2 ( + IN UINT64 Operand + ) +/*++ + +Routine Description: + + Calculates and floors logarithms based on 2 + +Arguments: + + Operand - value to calculate logarithm + +Returns: + + The largest integer that is less than or equal + to the logarithm of Operand based on 2 + +--*/ +{ + __asm { + mov ecx, 64 + + cmp dword ptr Operand[0], 0 + jne _Log2_Wend + cmp dword ptr Operand[4], 0 + jne _Log2_Wend + mov cl, 0FFH + jmp _Log2_Done + +_Log2_Wend: + dec ecx + cmp ecx, 32 + jae _Log2_Higher + bt dword ptr Operand[0], ecx + jmp _Log2_Bit + +_Log2_Higher: + mov eax, ecx + sub eax, 32 + bt dword ptr Operand[4], eax + +_Log2_Bit: + jc _Log2_Done + jmp _Log2_Wend + +_Log2_Done: + mov al, cl + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.c new file mode 100644 index 0000000000..a102b0e684 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.c @@ -0,0 +1,64 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MultU64x32.c + +Abstract: + + 64-bit Multiplication function for IA-32 + +--*/ + +#include "Tiano.h" + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be multiplied with a 32 bit + value returns 64bit result. + No checking if the result is greater than 64bits + +Arguments: + + Multiplicand - multiplicand + Multiplier - multiplier + +Returns: + + Multiplicand * Multiplier + +--*/ +{ + __asm { + mov eax, dword ptr Multiplicand[0] + mul Multiplier + push eax + push edx + mov eax, dword ptr Multiplicand[4] + mul Multiplier + ; + ; The value in edx stored by second multiplication overflows + ; the output and should be discarded. So here we overwrite it + ; with the edx value of first multiplication. + ; + pop edx + add edx, eax + pop eax + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c new file mode 100644 index 0000000000..e8e1652db2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c @@ -0,0 +1,67 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Power10U64.c + +Abstract: + + Calculates Operand * 10 ^ Power + +--*/ + +#include "Tiano.h" + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ); + +UINT64 +Power10U64 ( + IN UINT64 Operand, + IN UINTN Power + ) +/*++ + +Routine Description: + + Raise 10 to the power of Power, and multiply the result with Operand + +Arguments: + + Operand - multiplicand + Power - power + +Returns: + + Operand * 10 ^ Power + +--*/ +{ + __asm { + mov ecx, Power + jcxz _Power10U64_Done + +_Power10U64_Wend: + push 10 + push dword ptr Operand[4] + push dword ptr Operand[0] + call MultU64x32 + mov dword ptr Operand[0], eax + mov dword ptr Operand[4], edx + loop _Power10U64_Wend + +_Power10U64_Done: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c new file mode 100644 index 0000000000..bc909eb78d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.c @@ -0,0 +1,71 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RShiftU64.c + +Abstract: + + 64-bit right shift function for IA-32 + +--*/ + +#include "Tiano.h" + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + This routine allows a 64 bit value to be right shifted by 32 bits and returns the + shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) +Arguments: + Operand - Value to be shifted + Count - Number of times to shift right. + +Returns: + + Value shifted right identified by the Count. + +--*/ +{ + __asm { + + mov eax, dword ptr Operand[0] + mov edx, dword ptr Operand[4] + + ; + ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EDX is not touched + ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move edx to eax later. + ; + mov ecx, Count + and ecx, 63 + shrd eax, edx, cl + shr edx, cl + + cmp ecx, 32 + jc short _RShiftU64_Done + + ; + ; Since Count is 32 - 63, edx will have been shifted by 0 - 31 + ; If shifted by 32 or more, set upper 32 bits to zero. + ; + mov eax, edx + xor edx, edx + +_RShiftU64_Done: + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c new file mode 100644 index 0000000000..64e683ec89 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c @@ -0,0 +1,216 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Math.c + +Abstract: + + Math worker functions. + +--*/ + +#include "Tiano.h" + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be left shifted by 32 bits and + returns the shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift left. + +Returns: + + Value shifted left identified by the Count. + +--*/ +{ + return Operand << Count; +} + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be multiplied with a 32 bit + value returns 64bit result. + No checking if the result is greater than 64bits + +Arguments: + + Multiplicand - multiplicand + Multiplier - multiplier + +Returns: + + Multiplicand * Multiplier + +--*/ +{ + return Multiplicand * Multiplier; +} + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be right shifted by 32 bits and returns the + shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift right. + +Returns: + + Value shifted right identified by the Count. + +--*/ +{ + return Operand >> Count; +} + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be divided with a 32 bit value returns + 64bit result and the Remainder. + +Arguments: + + Dividend - dividend + Divisor - divisor + Remainder - buffer for remainder + +Returns: + + Dividend / Divisor + Remainder = Dividend mod Divisor + +--*/ +{ + if (Remainder != NULL) { + *Remainder = Dividend % Divisor; + } + + return Dividend / Divisor; +} + +UINT8 +Log2 ( + IN UINT64 Operand + ) +/*++ + +Routine Description: + + This function computes rounded down log2 of the Operand. This is an equivalent + of the position of the highest bit set in the Operand treated as a mask. + E.g., Log2 (0x0001) == 0, Log2 (0x0002) == 1, Log2 (0x0003) == 1, Log2 (0x0005) == 2 + Log2 (0x4000) == 14, Log2 (0x8000) == 15, Log2 (0xC000) == 15, Log2 (0xFFFF) == 15, etc. + +Arguments: + Operand - value of which the Log2 is to be computed. + +Returns: + Rounded down log2 of the Operand or 0xFF if zero passed in. + +--*/ +{ + UINT8 Bitpos; + Bitpos = 0; + + if (Operand == 0) { + return (0xff); + } + + while (Operand != 0) { + Operand >>= 1; + Bitpos++; + } + return (Bitpos - 1); + +} + +UINT64 +GetPowerOfTwo ( + IN UINT64 Operand + ) +/*++ + +Routine Description: + + Calculates the largest integer that is both + a power of two and less than Input + +Arguments: + + Operand - value to calculate power of two + +Returns: + + the largest integer that is both a power of + two and less than Input + +--*/ +{ + UINT8 Bitpos; + Bitpos = 0; + + if (Operand == 0) { + return 0; + } + + while (Operand != 0) { + Operand >>= 1; + Bitpos++; + } + + Operand = 1; + Bitpos--; + while (Bitpos != 0) { + Operand <<= 1; + Bitpos--; + } + + return Operand; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c new file mode 100644 index 0000000000..b64ccaee73 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c @@ -0,0 +1,384 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + misc.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "pei.h" +#include "cpuio.h" +#include "pcicfg.h" +#include "pcicfg2.h" +#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo) + +// +// Modular variable used by common libiary in PEI phase +// +EFI_GUID mPeiCpuIoPpiGuid = PEI_CPU_IO_PPI_GUID; +#if (PI_SPECIFICATION_VERSION < 0x00010000) +EFI_GUID mPeiPciCfgPpiGuid = PEI_PCI_CFG_PPI_GUID; +PEI_PCI_CFG_PPI *PciCfgPpi = NULL; +#else +EFI_GUID mPeiPciCfgPpiGuid = EFI_PEI_PCI_CFG2_PPI_GUID; +EFI_PEI_PCI_CFG2_PPI *PciCfgPpi = NULL; +#endif +EFI_PEI_SERVICES **mPeiServices = NULL; +PEI_CPU_IO_PPI *CpuIoPpi = NULL; + +// +// Modular variable used by common libiary in DXE phase +// +EFI_SYSTEM_TABLE *mST = NULL; +EFI_BOOT_SERVICES *mBS = NULL; +EFI_RUNTIME_SERVICES *mRT = NULL; + +EFI_STATUS +EfiInitializeCommonDriverLib ( + IN EFI_HANDLE ImageHandle, + IN VOID *SystemTable + ) +/*++ + +Routine Description: + + Initialize lib function calling phase: PEI or DXE + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS + +--*/ +{ + EFI_STATUS Status; + + mPeiServices = NULL; + CpuIoPpi = NULL; + PciCfgPpi = NULL; + + if (ImageHandle == NULL) { + // + // The function is called in PEI phase, use PEI interfaces + // + mPeiServices = (EFI_PEI_SERVICES **) SystemTable; + ASSERT (mPeiServices == NULL); + + CpuIoPpi = (**mPeiServices).CpuIo; + PciCfgPpi = (**mPeiServices).PciCfg; + + } else { + // + // ImageHandle is not NULL. The function is called in DXE phase + // + mST = SystemTable; + ASSERT (mST != NULL); + + mBS = mST->BootServices; + mRT = mST->RuntimeServices; + ASSERT (mBS != NULL); + ASSERT (mRT != NULL); + + // + // Should be at EFI_D_INFO, but lets us know things are running + // + DEBUG ((EFI_D_INFO, "EfiInitializeCommonDriverLib: Started in DXE\n")); + return EFI_SUCCESS; + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +EfiCommonIoWrite ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io write operation. + +Arguments: + + Width - Width of write operation + Address - Start IO address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo; + + if (mPeiServices == NULL) { + // + // The function is called in PEI phase, use PEI interfaces + // + Status = CpuIoPpi->Io.Write ( + mPeiServices, + CpuIoPpi, + Width, + Address, + Count, + Buffer + ); + } else { + // + // The function is called in DXE phase + // + Status = mBS->LocateProtocol ( + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + (VOID **) &RootBridgeIo + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = RootBridgeIo->Io.Write (RootBridgeIo, Width, Address, Count, Buffer); + } + + return Status; +} + + +EFI_STATUS +EfiCommonIoRead ( + IN UINT8 Width, + IN UINTN Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Io read operation. + +Arguments: + + Width - Width of read operation + Address - Start IO address to read + Count - Read count + Buffer - Buffer to store result + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo; + + if (mPeiServices == NULL) { + // + // The function is called in PEI phase, use PEI interfaces + // + Status = CpuIoPpi->Io.Read ( + mPeiServices, + CpuIoPpi, + Width, + Address, + Count, + Buffer + ); + } else { + // + // The function is called in DXE phase + // + Status = mBS->LocateProtocol ( + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + (VOID **) &RootBridgeIo + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = RootBridgeIo->Io.Read (RootBridgeIo, Width, Address, Count, Buffer); + } + + return Status; +} + + +EFI_STATUS +EfiCommonPciWrite ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci write operation + +Arguments: + + Width - Width of PCI write + Address - PCI address to write + Count - Write count + Buffer - Buffer to write to the address + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + UINTN Index; + UINT8 *Buffer8; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo; + + if (mPeiServices == NULL) { + // + // The function is called in PEI phase, use PEI interfaces + // + Buffer8 = Buffer; + for (Index = 0; Index < Count; Index++) { + Status = PciCfgPpi->Write ( + mPeiServices, + PciCfgPpi, + Width, + Address, + Buffer8 + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + Buffer8 += Width; + } + + } else { + // + // The function is called in DXE phase + // + Status = mBS->LocateProtocol ( + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + (VOID **) &RootBridgeIo + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = RootBridgeIo->Pci.Write ( + RootBridgeIo, + Width, + Address, + Count, + Buffer + ); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiCommonPciRead ( + IN UINT8 Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Pci read operation + +Arguments: + + Width - Width of PCI read + Address - PCI address to read + Count - Read count + Buffer - Output buffer for the read + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + UINTN Index; + UINT8 *Buffer8; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo; + + if (mPeiServices == NULL) { + // + // The function is called in PEI phase, use PEI interfaces + // + Buffer8 = Buffer; + for (Index = 0; Index < Count; Index++) { + Status = PciCfgPpi->Read ( + mPeiServices, + PciCfgPpi, + Width, + Address, + Buffer8 + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + Buffer8 += Width; + } + + } else { + // + // The function is called in DXE phase + // + Status = mBS->LocateProtocol ( + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + (VOID **) &RootBridgeIo + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = RootBridgeIo->Pci.Read ( + RootBridgeIo, + Width, + Address, + Count, + Buffer + ); + } + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/PostCode.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/PostCode.c new file mode 100644 index 0000000000..31232bebdc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/PostCode.c @@ -0,0 +1,62 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PostCode.c + +Abstract: + + Worker functions for PostCode + +--*/ + +#include "TianoCommon.h" +#include "EfiCommonLib.h" + +BOOLEAN +CodeTypeToPostCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + OUT UINT8 *PostCode + ) +/*++ + +Routine Description: + + Convert code value to an 8 bit post code + +Arguments: + + CodeType - Code type + Value - Code value + PostCode - Post code as output + +Returns: + + TRUE - Successfully converted + + FALSE - Convertion failed + +--*/ +{ + // + // Convert Value to an 8 bit post code + // + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || + ((CodeType & EFI_STATUS_CODE_TYPE_MASK)== EFI_ERROR_CODE)) { + *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5); + *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f); + return TRUE; + } + + return FALSE; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c new file mode 100644 index 0000000000..4a9fca82bc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c @@ -0,0 +1,338 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ReportStatusCode.c + +Abstract: + + Worker functions for ReportStatusCode + +--*/ + +#include "TianoCommon.h" +#include "EfiCommonLib.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + + +VOID * +EfiConstructStatusCodeData ( + IN UINT16 DataSize, + IN EFI_GUID *TypeGuid, + IN OUT EFI_STATUS_CODE_DATA *Data + ) +/*++ + +Routine Description: + + Construct stanader header for optional data passed into ReportStatusCode + +Arguments: + + DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header + TypeGuid - GUID to place in EFI_STATUS_CODE_DATA + Data - Buffer to use. + +Returns: + + Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA + +--*/ +{ + Data->HeaderSize = sizeof (EFI_STATUS_CODE_DATA); + Data->Size = (UINT16)(DataSize - sizeof (EFI_STATUS_CODE_DATA)); + EfiCommonLibCopyMem (&Data->Type, TypeGuid, sizeof (EFI_GUID)); + + return (VOID *)(Data + 1); +} + +EFI_STATUS +EfiDebugVPrintWorker ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + + The Format string might be truncated to fit into the status code struture + which has the max size of EFI_STATUS_CODE_DATA_MAX_SIZE. + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + Marker - VarArgs + + BufferSize - Size of Buffer. + + Buffer - Caller allocated buffer, contains ReportStatusCode extended data + +Returns: + + Status code + + EFI_SUCCESS - Successfully printed + +--*/ +{ + UINTN Index; + UINTN FormatStrLen; + UINTN RemainingStrLen; + UINT64 *Ptr; + EFI_DEBUG_INFO *EfiDebug; + + + // + // Build the type specific EFI_STATUS_CODE_DATA in order + // + + // + // Fill in EFI_STATUS_CODE_DATA to Buffer. + // + EfiDebug = (EFI_DEBUG_INFO *)EfiConstructStatusCodeData ( + (UINT16)BufferSize, + &gEfiStatusCodeDataTypeDebugGuid, + Buffer + ); + + // + // Then EFI_DEBUG_INFO + // + EfiDebug->ErrorLevel = (UINT32)ErrorLevel; + + // + // 12 * sizeof (UINT64) byte mini Var Arg stack. + // That is followed by the format string. + // + for (Index = 0, Ptr = (UINT64 *)(EfiDebug + 1); Index < 12; Index++, Ptr++) { + *Ptr = VA_ARG (Marker, UINT64); + } + + // + // Place Ascii Format string at the end + // Truncate it to fit into the status code structure + // + FormatStrLen = EfiAsciiStrLen (Format); + RemainingStrLen = EFI_STATUS_CODE_DATA_MAX_SIZE + - sizeof (EFI_STATUS_CODE_DATA) + - sizeof (EFI_DEBUG_INFO) + - 12 * sizeof (UINT64) - 1; + if (FormatStrLen > RemainingStrLen) { + FormatStrLen = RemainingStrLen; + } + EfiCommonLibCopyMem (Ptr, Format, FormatStrLen); + *((CHAR8 *) Ptr + FormatStrLen) = '\0'; + + return EFI_SUCCESS; +} + + + +EFI_STATUS +EfiDebugAssertWorker ( + IN CHAR8 *Filename, + IN INTN LineNumber, + IN CHAR8 *Description, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded DEADLOOP (). + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + Filename - File name of failing routine. + + LineNumber - Line number of failing ASSERT(). + + Description - Description, usually the assertion, + + BufferSize - Size of Buffer. + + Buffer - Caller allocated buffer, contains ReportStatusCode extendecd data + +Returns: + + Status code + + EFI_BUFFER_TOO_SMALL - Buffer not large enough + + EFI_SUCCESS - Function successfully done. + +--*/ +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + UINTN TotalSize; + CHAR8 *EndOfStr; + + // + // Make sure it will all fit in the passed in buffer + // + TotalSize = sizeof (EFI_STATUS_CODE_DATA) + sizeof (EFI_DEBUG_ASSERT_DATA); + TotalSize += EfiAsciiStrLen (Filename) + EfiAsciiStrLen (Description); + if (TotalSize > BufferSize) { + return EFI_BUFFER_TOO_SMALL; + } + + // + // Fill in EFI_STATUS_CODE_DATA + // + AssertData = (EFI_DEBUG_ASSERT_DATA *) + EfiConstructStatusCodeData ( + (UINT16)(TotalSize - sizeof (EFI_STATUS_CODE_DATA)), + &gEfiStatusCodeDataTypeAssertGuid, + Buffer + ); + + // + // Fill in EFI_DEBUG_ASSERT_DATA + // + AssertData->LineNumber = (UINT32)LineNumber; + + // + // Copy Ascii FileName including NULL. + // + EndOfStr = EfiAsciiStrCpy ((CHAR8 *)(AssertData + 1), Filename); + + // + // Copy Ascii Description + // + EfiAsciiStrCpy (EndOfStr, Description); + return EFI_SUCCESS; +} + + + +BOOLEAN +ReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +/*++ + +Routine Description: + + Extract assert information from status code data. + +Arguments: + + CodeType - Code type + Value - Code value + Data - Optional data associated with this status code. + Filename - Filename extracted from Data + Description - Description extracted from Data + LineNumber - Line number extracted from Data + +Returns: + + TRUE - Successfully extracted + + FALSE - Extraction failed + +--*/ +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && + ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED)) { + // + // Assume if we have an uncontained unrecoverable error that the data hub + // may not work. So we will print out data here. If we had an IPMI controller, + // or error log we could wack the hardware here. + // + if ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE && (Data != NULL)) { + // + // ASSERT (Expresion) - + // ExtendedData == FileName + // Instance == Line Nuber + // NULL == String of Expresion + // + AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1); + *Filename = (CHAR8 *)(AssertData + 1); + *Description = *Filename + EfiAsciiStrLen (*Filename) + 1; + *LineNumber = AssertData->LineNumber; + return TRUE; + } + } + return FALSE; +} + + +BOOLEAN +ReportStatusCodeExtractDebugInfo ( + IN EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format + ) +/*++ + +Routine Description: + + Extract debug information from status code data. + +Arguments: + + Data - Optional data associated with status code. + ErrorLevel - Error level extracted from Data + Marker - VA_LIST extracted from Data + Format - Format string extracted from Data + +Returns: + + TRUE - Successfully extracted + + FALSE - Extraction failed + +--*/ +{ + EFI_DEBUG_INFO *DebugInfo; + + if ((Data == NULL) || (!EfiCompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid))) { + return FALSE; + } + + DebugInfo = (EFI_DEBUG_INFO *)(Data + 1); + + *ErrorLevel = DebugInfo->ErrorLevel; + + // + // The first 12 * UINTN bytes of the string are really an + // arguement stack to support varargs on the Format string. + // + *Marker = (VA_LIST) (DebugInfo + 1); + *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12); + + return TRUE; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/String.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/String.c new file mode 100644 index 0000000000..150f650598 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/String.c @@ -0,0 +1,802 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + String.c + +Abstract: + + Unicode string primatives + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "EfiCommonLib.h" + +VOID +EfiStrCpy ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +/*++ + +Routine Description: + Copy the Unicode string Source to Destination. + +Arguments: + Destination - Location to copy string + Source - String to copy + +Returns: + NONE + +--*/ +{ + while (*Source) { + *(Destination++) = *(Source++); + } + *Destination = 0; +} + +VOID +EfiStrnCpy ( + OUT CHAR16 *Dst, + IN CHAR16 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Copy a string from source to destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +{ + UINTN Index; + UINTN SrcLen; + + SrcLen = EfiStrLen (Src); + + Index = 0; + while (Index < Length && Index < SrcLen) { + Dst[Index] = Src[Index]; + Index++; + } + for (Index = SrcLen; Index < Length; Index++) { + Dst[Index] = 0; + } +} + +UINTN +EfiStrLen ( + IN CHAR16 *String + ) +/*++ + +Routine Description: + Return the number of Unicode characters in String. This is not the same as + the length of the string in bytes. + +Arguments: + String - String to process + +Returns: + Number of Unicode characters in String + +--*/ +{ + UINTN Length; + + for (Length=0; *String; String++, Length++); + return Length; +} + + +UINTN +EfiStrSize ( + IN CHAR16 *String + ) +/*++ + +Routine Description: + Return the number bytes in the Unicode String. This is not the same as + the length of the string in characters. The string size includes the NULL + +Arguments: + String - String to process + +Returns: + Number of bytes in String + +--*/ +{ + return ((EfiStrLen (String) + 1) * sizeof (CHAR16)); +} + + +INTN +EfiStrCmp ( + IN CHAR16 *String, + IN CHAR16 *String2 + ) +/*++ + +Routine Description: + Compare the Unicode string pointed by String to the string pointed by String2. + +Arguments: + String - String to process + + String2 - The other string to process + +Returns: + Return a positive integer if String is lexicall greater than String2; Zero if + the two strings are identical; and a negative interger if String is lexically + less than String2. + +--*/ +{ + while (*String) { + if (*String != *String2) { + break; + } + + String += 1; + String2 += 1; + } + + return *String - *String2; +} + +INTN +EfiStrnCmp ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN UINTN Length + ) +/*++ + +Routine Description: + This function compares the Unicode string String to the Unicode + string String2 for len characters. If the first len characters + of String is identical to the first len characters of String2, + then 0 is returned. If substring of String sorts lexicographically + after String2, the function returns a number greater than 0. If + substring of String sorts lexicographically before String2, the + function returns a number less than 0. + +Arguments: + String - Compare to String2 + String2 - Compare to String + Length - Number of Unicode characters to compare + +Returns: + 0 - The substring of String and String2 is identical. + > 0 - The substring of String sorts lexicographically after String2 + < 0 - The substring of String sorts lexicographically before String2 + +--*/ +{ + while (*String && Length != 0) { + if (*String != *String2) { + break; + } + String += 1; + String2 += 1; + Length -= 1; + } + return Length > 0 ? *String - *String2 : 0; +} + +VOID +EfiStrCat ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +{ + EfiStrCpy (Destination + EfiStrLen (Destination), Source); +} + +VOID +EfiStrnCat ( + IN CHAR16 *Dest, + IN CHAR16 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +{ + EfiStrnCpy (Dest + EfiStrLen (Dest), Src, Length); +} + +UINTN +EfiAsciiStrLen ( + IN CHAR8 *String + ) +/*++ + +Routine Description: + Return the number of Ascii characters in String. This is not the same as + the length of the string in bytes. + +Arguments: + String - String to process + +Returns: + Number of Ascii characters in String + +--*/ +{ + UINTN Length; + + for (Length=0; *String; String++, Length++); + return Length; +} + + +CHAR8 * +EfiAsciiStrCpy ( + IN CHAR8 *Destination, + IN CHAR8 *Source + ) +/*++ + +Routine Description: + Copy the Ascii string Source to Destination. + +Arguments: + Destination - Location to copy string + Source - String to copy + +Returns: + Pointer just pass the end of Destination + +--*/ +{ + while (*Source) { + *(Destination++) = *(Source++); + } + *Destination = 0; + return Destination + 1; +} + +VOID +EfiAsciiStrnCpy ( + OUT CHAR8 *Dst, + IN CHAR8 *Src, + IN UINTN Length + ) +/*++ + +Routine Description: + Copy the Ascii string from source to destination + +Arguments: + Dst Destination string + Src Source string + Length Length of destination string + +Returns: + +--*/ +{ + UINTN Index; + UINTN SrcLen; + + SrcLen = EfiAsciiStrLen (Src); + + Index = 0; + while (Index < Length && Index < SrcLen) { + Dst[Index] = Src[Index]; + Index++; + } + for (Index = SrcLen; Index < Length; Index++) { + Dst[Index] = 0; + } +} + +UINTN +EfiAsciiStrSize ( + IN CHAR8 *String + ) +/*++ + +Routine Description: + Return the number bytes in the Ascii String. This is not the same as + the length of the string in characters. The string size includes the NULL + +Arguments: + String - String to process + +Returns: + Number of bytes in String + +--*/ +{ + return (EfiAsciiStrLen (String) + 1); +} + + +INTN +EfiAsciiStrCmp ( + IN CHAR8 *String, + IN CHAR8 *String2 + ) +/*++ + +Routine Description: + Compare the Ascii string pointed by String to the string pointed by String2. + +Arguments: + String - String to process + + String2 - The other string to process + +Returns: + Return a positive integer if String is lexicall greater than String2; Zero if + the two strings are identical; and a negative interger if String is lexically + less than String2. +--*/ +{ + while (*String) { + if (*String != *String2) { + break; + } + + String += 1; + String2 += 1; + } + + return *String - *String2; +} + +INTN +EfiAsciiStrnCmp ( + IN CHAR8 *String, + IN CHAR8 *String2, + IN UINTN Length + ) +{ + if (Length == 0) { + return 0; + } + + while ((*String != '\0') && + (*String == *String2) && + (Length > 1)) { + String++; + String2++; + Length--; + } + return *String - *String2; +} + +VOID +EfiAsciiStrCat ( + IN CHAR8 *Destination, + IN CHAR8 *Source + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +{ + EfiAsciiStrCpy (Destination + EfiAsciiStrLen (Destination), Source); +} + +VOID +EfiAsciiStrnCat ( + IN CHAR8 *Destination, + IN CHAR8 *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +{ + EfiAsciiStrnCpy (Destination + EfiAsciiStrLen (Destination), Source, Length); +} + +BOOLEAN +IsHexDigit ( + OUT UINT8 *Digit, + IN CHAR16 Char + ) +/*++ + + Routine Description: + Determines if a Unicode character is a hexadecimal digit. + The test is case insensitive. + + Arguments: + Digit - Pointer to byte that receives the value of the hex character. + Char - Unicode character to test. + + Returns: + TRUE - If the character is a hexadecimal digit. + FALSE - Otherwise. + +--*/ +{ + if ((Char >= L'0') && (Char <= L'9')) { + *Digit = (UINT8) (Char - L'0'); + return TRUE; + } + + if ((Char >= L'A') && (Char <= L'F')) { + *Digit = (UINT8) (Char - L'A' + 0x0A); + return TRUE; + } + + if ((Char >= L'a') && (Char <= L'f')) { + *Digit = (UINT8) (Char - L'a' + 0x0A); + return TRUE; + } + + return FALSE; +} + +CHAR16 +NibbleToHexChar ( + IN UINT8 Nibble + ) +/*++ + + Routine Description: + Converts the low nibble of a byte to hex unicode character. + + Arguments: + Nibble - lower nibble of a byte. + + Returns: + Hex unicode character. + +--*/ +{ + Nibble &= 0x0F; + if (Nibble <= 0x9) { + return (CHAR16)(Nibble + L'0'); + } + + return (CHAR16)(Nibble - 0xA + L'A'); +} + +EFI_STATUS +HexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ) +/*++ + + Routine Description: + Converts Unicode string to binary buffer. + The conversion may be partial. + The first character in the string that is not hex digit stops the conversion. + At a minimum, any blob of data could be represented as a hex string. + + Arguments: + Buf - Pointer to buffer that receives the data. + Len - Length in bytes of the buffer to hold converted data. + If routine return with EFI_SUCCESS, containing length of converted data. + If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired. + Str - String to be converted from. + ConvertedStrLen - Length of the Hex String consumed. + + Returns: + EFI_SUCCESS: Routine Success. + EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data. + EFI_ + +--*/ +{ + UINTN HexCnt; + UINTN Idx; + UINTN BufferLength; + UINT8 Digit; + UINT8 Byte; + + // + // Find out how many hex characters the string has. + // + for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++); + + if (HexCnt == 0) { + *Len = 0; + return EFI_SUCCESS; + } + // + // Two Unicode characters make up 1 buffer byte. Round up. + // + BufferLength = (HexCnt + 1) / 2; + + // + // Test if buffer is passed enough. + // + if (BufferLength > (*Len)) { + *Len = BufferLength; + return EFI_BUFFER_TOO_SMALL; + } + + *Len = BufferLength; + + for (Idx = 0; Idx < HexCnt; Idx++) { + + IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]); + + // + // For odd charaters, write the lower nibble for each buffer byte, + // and for even characters, the upper nibble. + // + if ((Idx & 1) == 0) { + Byte = Digit; + } else { + Byte = Buf[Idx / 2]; + Byte &= 0x0F; + Byte |= Digit << 4; + } + + Buf[Idx / 2] = Byte; + } + + if (ConvertedStrLen != NULL) { + *ConvertedStrLen = HexCnt; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +BufToHexString ( + IN OUT CHAR16 *Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ) +/*++ + + Routine Description: + Converts binary buffer to Unicode string. + At a minimum, any blob of data could be represented as a hex string. + + Arguments: + Str - Pointer to the string. + HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character. + If routine return with EFI_SUCCESS, containing length of hex string buffer. + If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired. + Buf - Buffer to be converted from. + Len - Length in bytes of the buffer to be converted. + + Returns: + EFI_SUCCESS: Routine success. + EFI_BUFFER_TOO_SMALL: The hex string buffer is too small. + +--*/ +{ + UINTN Idx; + UINT8 Byte; + UINTN StrLen; + + // + // Make sure string is either passed or allocate enough. + // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer. + // Plus the Unicode termination character. + // + StrLen = Len * 2; + if (StrLen > ((*HexStringBufferLength) - 1)) { + *HexStringBufferLength = StrLen + 1; + return EFI_BUFFER_TOO_SMALL; + } + + *HexStringBufferLength = StrLen + 1; + // + // Ends the string. + // + Str[StrLen] = L'\0'; + + for (Idx = 0; Idx < Len; Idx++) { + + Byte = Buf[Idx]; + Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte); + Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4)); + } + + return EFI_SUCCESS; +} + +VOID +EfiStrTrim ( + IN OUT CHAR16 *str, + IN CHAR16 CharC + ) +/*++ + +Routine Description: + + Removes (trims) specified leading and trailing characters from a string. + +Arguments: + + str - Pointer to the null-terminated string to be trimmed. On return, + str will hold the trimmed string. + CharC - Character will be trimmed from str. + +Returns: + +--*/ +{ + CHAR16 *p1; + CHAR16 *p2; + + if (*str == 0) { + return; + } + + // + // Trim off the leading and trailing characters c + // + for (p1 = str; *p1 && *p1 == CharC; p1++) { + ; + } + + p2 = str; + if (p2 == p1) { + while (*p1) { + p2++; + p1++; + } + } else { + while (*p1) { + *p2 = *p1; + p1++; + p2++; + } + *p2 = 0; + } + + + for (p1 = str + EfiStrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) { + ; + } + if (p1 != str + EfiStrLen(str) - 1) { + *(p1 + 1) = 0; + } +} +CHAR16* +EfiStrStr ( + IN CHAR16 *String, + IN CHAR16 *StrCharSet + ) +/*++ + +Routine Description: + + Find a substring. + +Arguments: + + String - Null-terminated string to search. + StrCharSet - Null-terminated string to search for. + +Returns: + The address of the first occurrence of the matching substring if successful, or NULL otherwise. +--*/ +{ + CHAR16 *Src; + CHAR16 *Sub; + + Src = String; + Sub = StrCharSet; + + while ((*String != L'\0') && (*StrCharSet != L'\0')) { + if (*String++ != *StrCharSet++) { + String = ++Src; + StrCharSet = Sub; + } + } + if (*StrCharSet == L'\0') { + return Src; + } else { + return NULL; + } +} + +CHAR8* +EfiAsciiStrStr ( + IN CHAR8 *String, + IN CHAR8 *StrCharSet + ) +/*++ + +Routine Description: + + Find a Ascii substring. + +Arguments: + + String - Null-terminated Ascii string to search. + StrCharSet - Null-terminated Ascii string to search for. + +Returns: + The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise. +--*/ +{ + CHAR8 *Src; + CHAR8 *Sub; + + Src = String; + Sub = StrCharSet; + + while ((*String != '\0') && (*StrCharSet != '\0')) { + if (*String++ != *StrCharSet++) { + String = ++Src; + StrCharSet = Sub; + } + } + if (*StrCharSet == '\0') { + return Src; + } else { + return NULL; + } +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c new file mode 100644 index 0000000000..1d4c77eb97 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ValueToString.c @@ -0,0 +1,213 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ValueToString.c + +Abstract: + + Routines changing value to Hex or Dec string + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +static CHAR16 mHexStr[] = { L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', + L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F' }; + +UINTN +EfiValueToHexStr ( + IN OUT CHAR16 *Buffer, + IN UINT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + VSPrint worker function that prints a Value as a hex number in Buffer + +Arguments: + + Buffer - Location to place ascii hex string of Value. + + Value - Hex value to convert to a string in Buffer. + + Flags - Flags to use in printing Hex string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +{ + CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE]; + CHAR16 *TempStr; + CHAR16 Prefix; + CHAR16 *BufferPtr; + UINTN Count; + UINTN Index; + + TempStr = TempBuffer; + BufferPtr = Buffer; + + // + // Count starts at one since we will null terminate. Each iteration of the + // loop picks off one nibble. Oh yea TempStr ends up backwards + // + Count = 0; + + if (Width > CHARACTER_NUMBER_FOR_VALUE - 1) { + Width = CHARACTER_NUMBER_FOR_VALUE - 1; + } + + do { + Index = ((UINTN)Value & 0xf); + *(TempStr++) = mHexStr[Index]; + Value = RShiftU64 (Value, 4); + Count++; + } while (Value != 0); + + if (Flags & PREFIX_ZERO) { + Prefix = '0'; + } else { + Prefix = ' '; + } + + Index = Count; + if (!(Flags & LEFT_JUSTIFY)) { + for (; Index < Width; Index++) { + *(TempStr++) = Prefix; + } + } + + // + // Reverse temp string into Buffer. + // + if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) { + TempStr = TempBuffer + Width; + } + Index = 0; + while (TempStr != TempBuffer) { + *(BufferPtr++) = *(--TempStr); + Index++; + } + + *BufferPtr = 0; + return Index; +} + + +UINTN +EfiValueToString ( + IN OUT CHAR16 *Buffer, + IN INT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + VSPrint worker function that prints a Value as a decimal number in Buffer + +Arguments: + + Buffer - Location to place ascii decimal number string of Value. + + Value - Decimal value to convert to a string in Buffer. + + Flags - Flags to use in printing decimal string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +{ + CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE]; + CHAR16 *TempStr; + CHAR16 *BufferPtr; + UINTN Count; + UINTN ValueCharNum; + UINTN Remainder; + CHAR16 Prefix; + UINTN Index; + BOOLEAN ValueIsNegative; + + TempStr = TempBuffer; + BufferPtr = Buffer; + Count = 0; + ValueCharNum = 0; + ValueIsNegative = FALSE; + + if (Width > CHARACTER_NUMBER_FOR_VALUE - 1) { + Width = CHARACTER_NUMBER_FOR_VALUE - 1; + } + + if (Value < 0) { + Value = -Value; + ValueIsNegative = TRUE; + } + + do { + Value = (INT64)DivU64x32 ((UINT64)Value, 10, &Remainder); + *(TempStr++) = (CHAR16)(Remainder + '0'); + ValueCharNum++; + Count++; + if ((Flags & COMMA_TYPE) == COMMA_TYPE) { + if (ValueCharNum % 3 == 0 && Value != 0) { + *(TempStr++) = ','; + Count++; + } + } + } while (Value != 0); + + if (ValueIsNegative) { + *(TempStr++) = '-'; + Count++; + } + + if ((Flags & PREFIX_ZERO) && !ValueIsNegative) { + Prefix = '0'; + } else { + Prefix = ' '; + } + + Index = Count; + if (!(Flags & LEFT_JUSTIFY)) { + for (; Index < Width; Index++) { + *(TempStr++) = Prefix; + } + } + + // + // Reverse temp string into Buffer. + // + if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) { + TempStr = TempBuffer + Width; + } + Index = 0; + while (TempStr != TempBuffer) { + *(BufferPtr++) = *(--TempStr); + Index++; + } + + *BufferPtr = 0; + return Index; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/linkedlist.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/linkedlist.c new file mode 100644 index 0000000000..4278762ade --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/linkedlist.c @@ -0,0 +1,356 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LinkedList.c + +Abstract: + + Linked List Library Functions + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + + +VOID +InitializeListHead ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Initialize the head of the List. The caller must allocate the memory + for the EFI_LIST. This function must be called before the other linked + list macros can be used. + +Arguments: + + List - Pointer to list head to initialize + +Returns: + + None. + +--*/ + +{ + List->ForwardLink = List; + List->BackLink = List; +} + + +BOOLEAN +IsListEmpty ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Return TRUE is the list contains zero nodes. Otherzise return FALSE. + The list must have been initialized with InitializeListHead () before using + this function. + +Arguments: + + List - Pointer to list head to test + + +Returns: + + Return TRUE is the list contains zero nodes. Otherzise return FALSE. + +--*/ +{ + return (BOOLEAN)(List->ForwardLink == List); +} + + +VOID +RemoveEntryList ( + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Remove Node from the doubly linked list. It is the caller's responsibility + to free any memory used by the entry if needed. The list must have been + initialized with InitializeListHead () before using this function. + +Arguments: + + Entry - Element to remove from the list. + +Returns: + + None + +--*/ +{ + EFI_LIST_ENTRY *_ForwardLink; + EFI_LIST_ENTRY *_BackLink; + + _ForwardLink = Entry->ForwardLink; + _BackLink = Entry->BackLink; + _BackLink->ForwardLink = _ForwardLink; + _ForwardLink->BackLink = _BackLink; + + DEBUG_CODE ( + Entry->ForwardLink = (EFI_LIST_ENTRY *) EFI_BAD_POINTER; + Entry->BackLink = (EFI_LIST_ENTRY *) EFI_BAD_POINTER; + ) +} + + +VOID +InsertTailList ( + EFI_LIST_ENTRY *ListHead, + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Insert a Node into the end of a doubly linked list. The list must have + been initialized with InitializeListHead () before using this function. + +Arguments: + + ListHead - Head of doubly linked list + + Entry - Element to insert at the end of the list. + +Returns: + + None + +--*/ +{ + EFI_LIST_ENTRY *_ListHead; + EFI_LIST_ENTRY *_BackLink; + + _ListHead = ListHead; + _BackLink = _ListHead->BackLink; + Entry->ForwardLink = _ListHead; + Entry->BackLink = _BackLink; + _BackLink->ForwardLink = Entry; + _ListHead->BackLink = Entry; +} + + + +VOID +InsertHeadList ( + EFI_LIST_ENTRY *ListHead, + EFI_LIST_ENTRY *Entry + ) +/*++ + +Routine Description: + + Insert a Node into the start of a doubly linked list. The list must have + been initialized with InitializeListHead () before using this function. + +Arguments: + + ListHead - Head of doubly linked list + + Entry - Element to insert to beginning of list + +Returns: + + None + +--*/ +{ + EFI_LIST_ENTRY *_ListHead; + EFI_LIST_ENTRY *_ForwardLink; + + _ListHead = ListHead; + _ForwardLink = _ListHead->ForwardLink; + Entry->ForwardLink = _ForwardLink; + Entry->BackLink = _ListHead; + _ForwardLink->BackLink = Entry; + _ListHead->ForwardLink = Entry; +} + +VOID +SwapListEntries ( + EFI_LIST_ENTRY *Entry1, + EFI_LIST_ENTRY *Entry2 + ) +/*++ + +Routine Description: + + Swap the location of the two elements of a doubly linked list. Node2 + is placed in front of Node1. The list must have been initialized with + InitializeListHead () before using this function. + +Arguments: + + Entry1 - Element in the doubly linked list in front of Node2. + + Entry2 - Element in the doubly linked list behind Node1. + +Returns: + + None + +--*/ +{ + EFI_LIST_ENTRY *Entry1ForwardLink; + EFI_LIST_ENTRY *Entry1BackLink; + EFI_LIST_ENTRY *Entry2ForwardLink; + EFI_LIST_ENTRY *Entry2BackLink; + + Entry2ForwardLink = Entry2->ForwardLink; + Entry2BackLink = Entry2->BackLink; + Entry1ForwardLink = Entry1->ForwardLink; + Entry1BackLink = Entry1->BackLink; + Entry2BackLink->ForwardLink = Entry2ForwardLink; + Entry2ForwardLink->BackLink = Entry2BackLink; + Entry2->ForwardLink = Entry1; + Entry2->BackLink = Entry1BackLink; + Entry1BackLink->ForwardLink = Entry2; + Entry1->BackLink = Entry2; +} + + +EFI_LIST_ENTRY * +GetFirstNode ( + EFI_LIST_ENTRY *List + ) +/*++ + +Routine Description: + + Return the first node pointed to by the list head. The list must + have been initialized with InitializeListHead () before using this + function and must contain data. + +Arguments: + + List - The head of the doubly linked list. + +Returns: + + Pointer to the first node, if the list contains nodes. The list will + return a null value--that is, the value of List--when the list is empty. + See the description of IsNull for more information. + + +--*/ +{ + return List->ForwardLink; +} + + +EFI_LIST_ENTRY * +GetNextNode ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Returns the node following Node in the list. The list must + have been initialized with InitializeListHead () before using this + function and must contain data. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node in the list. This value MUST NOT be the literal value NULL. + See the description of IsNull for more information. + +Returns: + + Pointer to the next node, if one exists. Otherwise, returns a null value, + which is actually a pointer to List. + See the description of IsNull for more information. + +--*/ +{ + if (Node == List) { + return List; + } + return Node->ForwardLink; +} + + +BOOLEAN +IsNull ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Determines whether the given node is null. Note that Node is null + when its value is equal to the value of List. It is an error for + Node to be the literal value NULL [(VOID*)0x0]. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node to test. MUST NOT be the literal value NULL. See + the description above. + +Returns: + + Returns true if the node is null. + +--*/ +{ + return (BOOLEAN)(Node == List); +} + + +BOOLEAN +IsNodeAtEnd ( + EFI_LIST_ENTRY *List, + EFI_LIST_ENTRY *Node + ) +/*++ + +Routine Description: + + Determines whether the given node is at the end of the list. Used + to walk the list. The list must have been initialized with + InitializeListHead () before using this function and must contain + data. + +Arguments: + + List - The head of the list. MUST NOT be the literal value NULL. + Node - The node to test. MUST NOT be the literal value NULL. + See the description of IsNull for more information. + +Returns: + + Returns true if the list is the tail. + +--*/ +{ + if (IsNull (List, Node)) { + return FALSE; + } + return (BOOLEAN)(List->BackLink == Node); +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm new file mode 100644 index 0000000000..9d1e04b2ba --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm @@ -0,0 +1,74 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CopyMem.asm +; +; Abstract: +; +; CopyMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; EfiCommonLibCopyMem ( +; OUT VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +EfiCommonLibCopyMem PROC USES rsi rdi + cmp rdx, rcx ; if Source == Destination, do nothing + je @CopyMemDone + cmp r8, 0 ; if Count == 0, do nothing + je @CopyMemDone + mov rsi, rdx ; rsi <- Source + mov rdi, rcx ; rdi <- Destination + lea r9, [rsi + r8 - 1] ; r9 <- End of Source + cmp rsi, rdi + mov rax, rdi ; rax <- Destination as return value + jae @F + cmp r9, rdi + jae @CopyBackward ; Copy backward if overlapped +@@: + mov rcx, r8 + and r8, 7 + shr rcx, 3 ; rcx <- # of Qwords to copy + jz @CopyBytes + DB 49h, 0fh, 7eh, 0c2h ; movd r10, mm0 (Save mm0 in r10) +@@: + DB 0fh, 6fh, 06h ; movd mm0, [rsi] + DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0 + add rsi, 8 + add rdi, 8 + loop @B + DB 49h, 0fh, 6eh, 0c2h ; movd mm0, r10 (Restore mm0) + jmp @CopyBytes +@CopyBackward: + mov rsi, r9 ; rsi <- End of Source + lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination + std ; set direction flag +@CopyBytes: + mov rcx, r8 + rep movsb ; Copy bytes backward + cld +@CopyMemDone: + ret +EfiCommonLibCopyMem ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm new file mode 100644 index 0000000000..9e60e94951 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm @@ -0,0 +1,80 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; CopyMem.asm +; +; Abstract: +; +; CopyMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EfiCommonLibCopyMem ( +; OUT VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ +EfiCommonLibCopyMem PROC USES rsi rdi + cmp rdx, rcx ; if Source == Destination, do nothing + je @CopyMemDone + cmp r8, 0 ; if Count == 0, do nothing + je @CopyMemDone + mov rsi, rdx ; rsi <- Source + mov rdi, rcx ; rdi <- Destination + lea r9, [rsi + r8 - 1] ; r9 <- End of Source + cmp rsi, rdi + mov rax, rdi ; rax <- Destination as return value + jae @F ; Copy forward if Source > Destination + cmp r9, rdi ; Overlapped? + jae @CopyBackward ; Copy backward if overlapped +@@: + xor rcx, rcx + sub rcx, rdi ; rcx <- -rdi + and rcx, 15 ; rcx + rsi should be 16 bytes aligned + jz @F ; skip if rcx == 0 + cmp rcx, r8 + cmova rcx, r8 + sub r8, rcx + rep movsb +@@: + mov rcx, r8 + and r8, 15 + shr rcx, 4 ; rcx <- # of DQwords to copy + jz @CopyBytes +@@: + movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned + movdqa [rdi], xmm0 ; rdi should be 16-byte aligned + add rsi, 16 + add rdi, 16 + loop @B + jmp @CopyBytes ; copy remaining bytes +@CopyBackward: + mov rsi, r9 ; rsi <- Last byte of Source + lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination + std +@CopyBytes: + mov rcx, r8 + rep movsb + cld +@CopyMemDone: + ret +EfiCommonLibCopyMem ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm new file mode 100644 index 0000000000..7568a520fd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm @@ -0,0 +1,60 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetMem.asm +; +; Abstract: +; +; SetMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; EfiCommonLibSetMem ( +; OUT VOID *Buffer, +; IN UINTN Size, +; IN UINT8 Value +; ); +;------------------------------------------------------------------------------ +EfiCommonLibSetMem PROC USES rdi + cmp rdx, 0 ; if Size == 0, do nothing + je @SetDone + mov rax, r8 + mov ah, al + DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax + mov r8, rcx + mov rdi, r8 ; rdi <- Buffer + mov rcx, rdx + and edx, 7 + shr rcx, 3 + jz @SetBytes + DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h +@@: + DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0 + add rdi, 8 + loop @B +@SetBytes: + mov ecx, edx + rep stosb + mov rax, r8 +@SetDone: + ret +EfiCommonLibSetMem ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm new file mode 100644 index 0000000000..8667d7e142 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm @@ -0,0 +1,67 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SetMem.asm +; +; Abstract: +; +; SetMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EfiCommonLibSetMem ( +; OUT VOID *Buffer, +; IN UINTN Size, +; IN UINT8 Value +; ); +;------------------------------------------------------------------------------ +EfiCommonLibSetMem PROC USES rdi + cmp rdx, 0 ; if Size == 0, do nothing + je @SetDone + mov rdi, rcx ; rdi <- Buffer + mov al, r8b ; al <- Value + xor rcx, rcx + sub rcx, rdi + and rcx, 15 ; rcx + rdi aligns on 16-byte boundary + jz @F + cmp rcx, rdx + cmova rcx, rdx + sub rdx, rcx + rep stosb +@@: + mov rcx, rdx + and rdx, 15 + shr rcx, 4 + jz @SetBytes + mov ah, al ; ax <- Value repeats twice + movd xmm0, eax ; xmm0[0..16] <- Value repeats twice + pshuflw xmm0, xmm0, 0 ; xmm0[0..63] <- Value repeats 8 times + movlhps xmm0, xmm0 ; xmm0 <- Value repeats 16 times +@@: + movdqa [rdi], xmm0 ; rdi should be 16-byte aligned + add rdi, 16 + loop @B +@SetBytes: + mov ecx, edx ; high 32 bits of rcx are always zero + rep stosb +@SetDone: + ret +EfiCommonLibSetMem ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm new file mode 100644 index 0000000000..5f2c077673 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm @@ -0,0 +1,53 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ZeroMem.asm +; +; Abstract: +; +; ZeroMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID * +; EfiCommonLibZeroMem ( +; IN VOID *Buffer, +; IN UINTN Size +; ); +;------------------------------------------------------------------------------ +EfiCommonLibZeroMem PROC USES rdi + mov rdi, rcx + mov rcx, rdx + mov r8, rdi + and edx, 7 + shr rcx, 3 + jz @ZeroBytes + DB 0fh, 0efh, 0c0h ; pxor mm0, mm0 +@@: + DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0 + add rdi, 8 + loop @B +@ZeroBytes: + xor eax, eax + mov ecx, edx + rep stosb + mov rax, r8 + ret +EfiCommonLibZeroMem ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm new file mode 100644 index 0000000000..58cf76e1af --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm @@ -0,0 +1,60 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ZeroMem.asm +; +; Abstract: +; +; ZeroMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EfiCommonLibZeroMem ( +; IN VOID *Buffer, +; IN UINTN Size +; ); +;------------------------------------------------------------------------------ +EfiCommonLibZeroMem PROC USES rdi + mov rdi, rcx + xor rcx, rcx + xor eax, eax + sub rcx, rdi + and rcx, 15 + jz @F + cmp rcx, rdx + cmova rcx, rdx + sub rdx, rcx + rep stosb +@@: + mov rcx, rdx + and edx, 15 + shr rcx, 4 + jz @ZeroBytes + pxor xmm0, xmm0 +@@: + movdqa [rdi], xmm0 ; rdi should be 16-byte aligned + add rdi, 16 + loop @B +@ZeroBytes: + mov ecx, edx + rep stosb + ret +EfiCommonLibZeroMem ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c new file mode 100644 index 0000000000..c28fd0386f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c @@ -0,0 +1,603 @@ + +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +MemoryAllocationModule Name: + + Peihoblib.c + +Abstract: + + PEI Library Functions + +--*/ + +#include "Tiano.h" +#include "PeiHob.h" +#include "peihoblib.h" +#include "peilib.h" +#include EFI_GUID_DEFINITION(MemoryAllocationHob) + + +EFI_PEI_HOB_POINTERS +BuildHobEndOfHobList ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Builds an end of HOB list HOB + +Arguments: + + HobStart - The HOB to build + +Returns: + + A pointer to the next HOB + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = HobStart; + + Hob.Header->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST; + Hob.Header->HobLength = sizeof(EFI_HOB_GENERIC_HEADER); + + Hob.Header++; + return Hob; +} + +EFI_STATUS +BuildHobHandoffInfoTable ( + IN VOID *HobStart, + IN UINT16 Version, + IN EFI_BOOT_MODE BootMode, + IN EFI_PHYSICAL_ADDRESS EfiMemoryTop, + IN EFI_PHYSICAL_ADDRESS EfiMemoryBottom, + IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop, + IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom + ) +/*++ + +Routine Description: + + Builds a HandoffInformationTable Information Table HOB + +Arguments: + + HobStart - Start pointer of hob list + Version - The version number pertaining to the PHIT HOB definition. + BootMode - The system boot mode as determined during the HOB producer phase. + EfiMemoryTop - The highest address location of memory that is allocated for use by the HOB + producer phase. + EfiMemoryBottom - The lowest address location of memory that is allocated for use by the HOB + producer phase. + EfiFreeMemoryTop - The highest address location of free memory that is currently available for use + by the HOB producer phase. + EfiFreeMemoryBottom - The lowest address location of free memory that is available for + use by the HOB producer phase. + +Returns: + + EFI_SUCCESS + +--*/ +{ + EFI_PEI_HOB_POINTERS HandOffHob; + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HobEnd; + + + HandOffHob.Raw = HobStart; + Hob.Raw = HobStart; + Hob.Header->HobType = EFI_HOB_TYPE_HANDOFF; + Hob.Header->HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE); + + Hob.HandoffInformationTable->Version = Version; + Hob.HandoffInformationTable->BootMode = BootMode; + + Hob.HandoffInformationTable->EfiMemoryTop = EfiMemoryTop; + Hob.HandoffInformationTable->EfiMemoryBottom = EfiMemoryBottom; + Hob.HandoffInformationTable->EfiFreeMemoryTop = EfiFreeMemoryTop; + Hob.HandoffInformationTable->EfiFreeMemoryBottom = EfiFreeMemoryBottom; + + HobEnd.Raw = (VOID*)(Hob.HandoffInformationTable + 1); + Hob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd.Raw; + Hob = BuildHobEndOfHobList (HobEnd.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + + + +EFI_STATUS +BuildHobModule ( + IN VOID *HobStart, + IN EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +/*++ + +Routine Description: + + Builds a HOB for a loaded PE32 module + +Arguments: + + HobStart - Start pointer of hob list + + ModuleName - The GUID File Name of the HON from the Firmware Volume + + MemoryAllocationModule - The 64 bit physical address of the module + + ModuleLength - The length of the module in bytes + + EntryPoint - The 64 bit physical address of the entry point to the module + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList); + + Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION; + Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_MODULE); + + CopyMem(&(Hob.MemoryAllocationModule->ModuleName), ModuleName, sizeof(EFI_GUID)); + CopyMem(&(Hob.MemoryAllocationModule->MemoryAllocationHeader.Name), &gEfiHobMemeryAllocModuleGuid, sizeof(EFI_GUID)); + Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; + Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength = ModuleLength; + Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryType = EfiConventionalMemory; + + Hob.MemoryAllocationModule->EntryPoint = EntryPoint; + + Hob.MemoryAllocationModule++; + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + +EFI_STATUS +BuildHobResourceDescriptor ( + IN VOID * HobStart, + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +/*++ + +Routine Description: + + Builds a HOB that describes a chunck of system memory + +Arguments: + + HobStart - Start pointer of hob list + + ResourceType - The type of memory described by this HOB + + ResourceAttribute - The memory attributes of the memory described by this HOB + + PhysicalStart - The 64 bit physical address of memory described by this HOB + + NumberOfBytes - The length of the memoty described by this HOB in bytes + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID *)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList); + + Hob.Header->HobType = EFI_HOB_TYPE_RESOURCE_DESCRIPTOR; + Hob.Header->HobLength = sizeof(EFI_HOB_RESOURCE_DESCRIPTOR); + + Hob.ResourceDescriptor->ResourceType = ResourceType; + Hob.ResourceDescriptor->ResourceAttribute = ResourceAttribute; + Hob.ResourceDescriptor->PhysicalStart = PhysicalStart; + Hob.ResourceDescriptor->ResourceLength = NumberOfBytes; + + Hob.ResourceDescriptor++; + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + +EFI_STATUS +BuildHobGuidType ( + IN VOID *HobStart, + IN EFI_GUID *Guid, + IN VOID *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + Builds a custom HOB that is tagged with a GUID for identification + +Arguments: + + HobStart - Start pointer of hob list + + Guid - The GUID of the custome HOB type + + Buffer - A pointer to the data for the custom HOB type + + BufferSize - The size in byte of BufferSize + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + UINTN Length; + + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID *)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList; + + + Hob.Header->HobType = EFI_HOB_TYPE_GUID_EXTENSION; + Length = sizeof(EFI_HOB_GUID_TYPE) + BufferSize; + Hob.Header->HobLength = (UINT16)Length; + CopyMem(&Hob.Guid->Name, Guid, sizeof(EFI_GUID)); + CopyMem(Hob.Raw + sizeof(EFI_HOB_GUID_TYPE), Buffer, BufferSize); + Hob.Raw += Length; + + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + +EFI_STATUS +BuildHobFvDescriptor ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a Firmware Volume HOB + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The base address of the Firmware Volume + + Length - The size of the Firmware Volume in bytes + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList); + + Hob.Header->HobType = EFI_HOB_TYPE_FV; + Hob.Header->HobLength = sizeof(EFI_HOB_FIRMWARE_VOLUME); + + Hob.FirmwareVolume->BaseAddress = BaseAddress; + Hob.FirmwareVolume->Length = Length; + + Hob.FirmwareVolume++; + + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + +EFI_STATUS +BuildHobCpu ( + IN VOID *HobStart, + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +/*++ + +Routine Description: + + Builds a HOB for the CPU + +Arguments: + + HobStart - Start pointer of hob list + + SizeOfMemorySpace - Identifies the maximum + physical memory addressibility of the processor. + + SizeOfIoSpace - Identifies the maximum physical I/O addressibility + of the processor. + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList; + + Hob.Header->HobType = EFI_HOB_TYPE_CPU; + Hob.Header->HobLength = sizeof(EFI_HOB_CPU); + + Hob.Cpu->SizeOfMemorySpace = SizeOfMemorySpace; + Hob.Cpu->SizeOfIoSpace = SizeOfIoSpace; + + Hob.Cpu++; + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + + + +EFI_STATUS +BuildHobStack ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a HOB for the Stack + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The 64 bit physical address of the Stack + + Length - The length of the stack in bytes + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList; + + Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION; + Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_STACK); + + CopyMem(&(Hob.MemoryAllocationStack->AllocDescriptor.Name), &gEfiHobMemeryAllocStackGuid, sizeof(EFI_GUID)); + (Hob.MemoryAllocationStack->AllocDescriptor).MemoryBaseAddress = BaseAddress; + (Hob.MemoryAllocationStack->AllocDescriptor).MemoryLength = Length; + (Hob.MemoryAllocationStack->AllocDescriptor).MemoryType = EfiConventionalMemory; + + Hob.MemoryAllocationStack++; + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + + + +EFI_STATUS +BuildHobBspStore ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for the bsp store + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The 64 bit physical address of bsp store + + Length - The length of the bsp store in bytes + + MemoryType - Memory type of the bsp store + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID *)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList; + Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION; + Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_BSP_STORE); + + (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryBaseAddress = BaseAddress; + (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryLength = Length; + (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryType = MemoryType; + CopyMem(&(Hob.MemoryAllocationBspStore->AllocDescriptor).Name, &gEfiHobMemeryAllocBspStoreGuid, sizeof(EFI_GUID)); + Hob.MemoryAllocationBspStore++; + + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + + +EFI_STATUS +BuildMemoryAllocationHob ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_GUID *Name, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for memory allocation + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The base address of memory allocated by this HOB. + + Length - The length in bytes of memory allocated by this HOB. + + Name - A GUID that defines the memory allocation region¡¯s type and purpose, + as well as other fields within the memory allocation HOB. + + MemoryType - Defines the type of memory allocated by this HOB. + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_PEI_HOB_POINTERS HandOffHob; + + + HandOffHob.Raw = HobStart; + Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList; + + Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION; + Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION); + + if (Name != NULL) { + CopyMem(&(Hob.MemoryAllocation->AllocDescriptor.Name), &Name, sizeof(EFI_GUID)); + } else { + ZeroMem(&Hob.MemoryAllocation->AllocDescriptor.Name, sizeof(EFI_GUID)); + } + + (Hob.MemoryAllocation->AllocDescriptor).MemoryBaseAddress = BaseAddress; + (Hob.MemoryAllocation->AllocDescriptor).MemoryLength = Length; + (Hob.MemoryAllocation->AllocDescriptor).MemoryType = MemoryType; + + Hob.MemoryAllocation++; + HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + Hob = BuildHobEndOfHobList(Hob.Raw); + HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw; + return EFI_SUCCESS; +} + +EFI_STATUS +GetFirstGuidHob ( + IN VOID **HobStart, + IN EFI_GUID *Guid, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL + ) +/*++ + +Routine Description: + + This function searches the first instance of a HOB among the whole HOB list. + +Arguments: + + HobStart - A pointer to the start pointer of hob list. + + Guid - A pointer to the GUID to match with in the HOB list. + + Buffer - A pointer to the pointer to the data for the custom HOB type. + + BufferSize - A Pointer to the size in byte of BufferSize. + +Returns: + EFI_SUCCESS + The first instance of the matched GUID HOB among the whole HOB list + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_HOB_POINTERS GuidHob; + + GuidHob.Raw = *HobStart; + + for (Status = EFI_NOT_FOUND; EFI_ERROR (Status); ) { + + if (END_OF_HOB_LIST (GuidHob)) { + return EFI_NOT_FOUND; + } + + if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) { + if ( ((INT32 *)Guid)[0] == ((INT32 *)&GuidHob.Guid->Name)[0] && + ((INT32 *)Guid)[1] == ((INT32 *)&GuidHob.Guid->Name)[1] && + ((INT32 *)Guid)[2] == ((INT32 *)&GuidHob.Guid->Name)[2] && + ((INT32 *)Guid)[3] == ((INT32 *)&GuidHob.Guid->Name)[3] ) { + Status = EFI_SUCCESS; + *Buffer = (VOID *)((UINT8 *)(&GuidHob.Guid->Name) + sizeof (EFI_GUID)); + if (BufferSize) { + *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE); + } + } + } + + GuidHob.Raw = GET_NEXT_HOB (GuidHob); + } + + return Status; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.inf b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.inf new file mode 100644 index 0000000000..6efd3ecd11 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.inf @@ -0,0 +1,49 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiHobLib.inf +# +# Abstract: +# +# Component description file for the PEI library. +# +#--*/ + +[defines] +BASE_NAME = PeiHobLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiHobLib.c + +[sources.ia32] + +[sources.ipf] + +[libraries.common] + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Framework + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h new file mode 100644 index 0000000000..f2cfdb865c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h @@ -0,0 +1,1341 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiLib.h + +Abstract: + + PEI Library Functions + +--*/ + +#ifndef _PEI_LIB_H_ +#define _PEI_LIB_H_ + +#include "Tiano.h" +#include "Pei.h" +#include "peiHobLib.h" +#include EFI_PROTOCOL_DEFINITION (Decompress) +#include EFI_PROTOCOL_DEFINITION (TianoDecompress) +#include EFI_GUID_DEFINITION (PeiPeCoffLoader) +#include EFI_PPI_DEFINITION (FindFv) + + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + +typedef struct { + UINT32 PeiServiceTable; +} PEI_IDT_TABLE; + + +VOID * +EFIAPI +ScanGuid ( + IN VOID *Buffer, + IN UINTN Length, + IN EFI_GUID *Guid + ) +/*++ + +Routine Description: + + Scans a target buffer for a GUID, and returns a pointer to the matching GUID + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from + the lowest address to the highest address at 128-bit increments for the 128-bit + GUID value that matches Guid. If a match is found, then a pointer to the matching + GUID in the target buffer is returned. If no match is found, then NULL is returned. + If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). + If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT(). + +Arguments: + + Buffer - Pointer to the target buffer to scan. + Length - Number of bytes in Buffer to scan. + Guid - Value to search for in the target buffer. + +Returns: + A pointer to the matching Guid in the target buffer or NULL otherwise. + +--*/ +; + +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +/*++ + +Routine Description: + + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT(). + +Arguments: + + Address - The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + Length - The number of bytes to invalidate from the instruction cache. + + Returns: + Address + +**/ +; + +EFI_STATUS +EFIAPI +PeiLibFfsFindNextVolume ( + IN UINTN Instance, + IN OUT EFI_PEI_FV_HANDLE *VolumeHandle + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindNextVolume. + +Arguments: + + Instance - The Fv Volume Instance. + VolumeHandle - Pointer to the current Fv Volume to search. + +Returns: + EFI_STATUS + +--*/ +; + +EFI_STATUS +EFIAPI +PeiLibFfsFindNextFile ( + IN EFI_FV_FILETYPE SearchType, + IN EFI_PEI_FV_HANDLE FwVolHeader, + IN OUT EFI_PEI_FILE_HANDLE *FileHeader + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindNextFile. + +Arguments: + + SearchType - Filter to find only file of this type. + FwVolHeader - Pointer to the current FV to search. + FileHandle - Pointer to the file matching SearchType in FwVolHeader. + - NULL if file not found + +Returns: + EFI_STATUS + +--*/ +; + +EFI_STATUS +EFIAPI +PeiLibFfsFindFileByName ( + IN EFI_GUID *FileName, + IN EFI_PEI_FV_HANDLE VolumeHandle, + OUT EFI_PEI_FILE_HANDLE *FileHandle + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindFileByName. + +Arguments: + + FileName - File name to search. + VolumeHandle - The current FV to search. + FileHandle - Pointer to the file matching name in VolumeHandle. + - NULL if file not found + +Returns: + EFI_STATUS + +--*/ +; + +EFI_STATUS +EFIAPI +PeiLibFfsFindSectionData ( + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindSectionData. + +Arguments: + + SearchType - Filter to find only sections of this type. + FileHandle - Pointer to the current file to search. + SectionData - Pointer to the Section matching SectionType in FfsFileHeader. + - NULL if section not found + +Returns: + EFI_STATUS +--*/ +; + +EFI_STATUS +EFIAPI +PeiLibFfsGetVolumeInfo ( + IN EFI_PEI_FV_HANDLE *VolumeHandle, + OUT EFI_FV_INFO *VolumeInfo + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsGetVolumeInfo. + +Arguments: + + VolumeHandle - The handle to Fv Volume. + VolumeInfo - The pointer to volume information. + +Returns: + EFI_STATUS +--*/ +; + +EFI_STATUS +EFIAPI +PeiServicesLocatePpi ( + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function LocatePpi. + +Arguments: + + Guid - Pointer to GUID of the PPI. + Instance - Instance Number to discover. + PpiDescriptor - Pointer to reference the found descriptor. If not NULL, + returns a pointer to the descriptor (includes flags, etc) + Ppi - Pointer to reference the found PPI + +Returns: + + Status - EFI_SUCCESS if the PPI is in the database + EFI_NOT_FOUND if the PPI is not in the database +--*/ +; + +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Build FvHob. + +Arguments: + + BaseAddress - Fv base address. + Length - Fv Length. + +Returns: + NONE. + +--*/ +; + +VOID +EFIAPI +BuildFvHob2 ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_GUID *FvNameGuid, + IN EFI_GUID *FileNameGuid + ) +/*++ + +Routine Description: + + Build FvHob2. + +Arguments: + + BaseAddress - Fv base address. + Length - Fv length. + FvNameGuid - Fv name. + FileNameGuid - File name which contians encapsulated Fv. + +Returns: + NONE. +--*/ +; + + +VOID +EFIAPI +BuildGuidDataHob ( + IN EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +/*++ + +Routine Description: + + Build Guid data Hob. + +Arguments: + + Guid - guid to build data hob. + Data - data to build data hob. + DataLength - the length of data. + +Returns: + NONE + +--*/ +; + +VOID * +EFIAPI +AllocatePages ( + IN UINTN Pages + ) +/*++ + +Routine Description: + + Allocate Memory. + +Arguments: + + Pages - Pages to allocate. + +Returns: + Address if successful to allocate memory. + NULL if fail to allocate memory. + +--*/ +; + +VOID +SetPeiServicesTablePointer ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Save PeiService pointer so that it can be retrieved anywhere. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + +Returns: + NONE + +--*/ +; + +EFI_PEI_SERVICES ** +GetPeiServicesTablePointer ( + VOID + ) +/*++ + +Routine Description: + + Get PeiService pointer. + +Arguments: + + NONE. + +Returns: + The direct pointer to PeiServiceTable. + +--*/ +; + +VOID +MigrateIdtTable ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Migrate IDT from CAR to real memory where preceded with 4 bytes for + storing PeiService pointer. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + +Returns: + + NONE. + +--*/ +; + + +UINTN +ReadIdtBase ( + VOID + ) +/*++ + +Routine Description: + + Read IDT Register BaseAddress. + +Arguments: + + NONE + +Returns: + IDT Register BaseAddress. + +--*/ +; + + +UINT16 +ReadIdtLimit ( + VOID + ) +/*++ + +Routine Description: + + Read IDT Register Limit. + +Arguments: + + NONE + +Returns: + IDT Register Limit. + +--*/ +; + + +VOID +SetIdtBase ( + UINT32 IdtBase, + UINT16 IdtLimit + ) +/*++ + +Routine Description: + + Set IDT Register BaseAddress. + +Arguments: + + IdtBase - IDT.BaseAddress + IdtLimit - IDT.Limit + +Returns: + NONE +--*/ +; + +VOID +AsmWriteKr7 ( + UINT64 Address + ) +/*++ + +Routine Description: + + Write 64 bit into Kernel Register7 on IPF. + +Arguments: + + Address - Data to write into kr7. + +Returns: + NONE + +--*/ +; + + +UINT64 +AsmReadKr7 ( + VOID + ) +/*++ + +Routine Description: + + Read 64 bit from Kernel Register7 on IPF. + +Arguments: + + NONE + +Returns: + Data in kr7. + +--*/ +; + +#endif + +VOID +PeiCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +; + +VOID +ZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + Set Buffer to zero for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + +Returns: + + None + +--*/ +; + +VOID +CopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +; + +BOOLEAN +CompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +/*++ + +Routine Description: + + Compares two GUIDs + +Arguments: + + Guid1 - guid to compare + Guid2 - guid to compare + +Returns: + = TRUE if Guid1 == Guid2 + = FALSE if Guid1 != Guid2 + +--*/ +; + +EFI_STATUS +InstallEfiPeiPeCoffLoader ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL **This, + IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi + ) +/*++ + +Routine Description: + + Install EFI Pei PE coff loader protocol. + +Arguments: + + PeiServices - The PEI core services table. + + This - Pointer to get Pei PE coff loader protocol as output + + ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform + +Returns: + + EFI_SUCCESS + +--*/ +; + +EFI_STATUS +InstallEfiPeiPeCoffLoader64 ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT EFI_PEI_PE_COFF_LOADER_PROTOCOL **This, + IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi + ); + + + +EFI_STATUS +InstallEfiDecompress ( + EFI_DECOMPRESS_PROTOCOL **This + ) +/*++ + +Routine Description: + + Install EFI decompress protocol. + +Arguments: + + This - Pointer to get decompress protocol as output + +Returns: + + EFI_SUCCESS - EFI decompress protocol successfully installed. + +--*/ +; + +EFI_STATUS +InstallTianoDecompress ( + EFI_TIANO_DECOMPRESS_PROTOCOL **This + ) +/*++ + +Routine Description: + + Install Tiano decompress protocol. + +Arguments: + + This - Pointer to get decompress protocol as output + +Returns: + + EFI_SUCCESS - Tiano decompress protocol successfully installed. + +--*/ +; + +VOID +PeiPerfMeasure ( + EFI_PEI_SERVICES **PeiServices, + IN UINT16 *Token, + IN EFI_FFS_FILE_HEADER *FileHeader, + IN BOOLEAN EntryExit, + IN UINT64 Value + ) +/*++ + +Routine Description: + + Log a timestamp count. + +Arguments: + + PeiServices - Pointer to the PEI Core Services table + + Token - Pointer to Token Name + + FileHeader - Pointer to the file header + + EntryExit - Indicates start or stop measurement + + Value - The start time or the stop time + +Returns: + +--*/ +; + +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ) +/*++ + +Routine Description: + + Get timer value. + +Arguments: + + TimerValue - Pointer to the returned timer value + +Returns: + + EFI_SUCCESS - Successfully got timer value + +--*/ +; + +#ifdef EFI_PEI_PERFORMANCE +#define PEI_PERF_START(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, FALSE, Value) +#define PEI_PERF_END(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, TRUE, Value) +#else +#define PEI_PERF_START(Ps, Token, FileHeader, Value) +#define PEI_PERF_END(Ps, Token, FileHeader, Value) +#endif + +#ifdef EFI_NT_EMULATOR +EFI_STATUS +PeCoffLoaderWinNtLoadAsDll ( + IN CHAR8 *PdbFileName, + IN VOID **ImageEntryPoint, + OUT VOID **ModHandle + ) +/*++ + +Routine Description: + + Loads the .DLL file is present when a PE/COFF file is loaded. This provides source level + debugging for drivers that have cooresponding .DLL files on the local system. + +Arguments: + + PdbFileName - The name of the .PDB file. This was found from the PE/COFF + file's debug directory entry. + + ImageEntryPoint - A pointer to the DLL entry point of the .DLL file was loaded. + + ModHandle - Pointer to loaded library. + +Returns: + + EFI_SUCCESS - The .DLL file was loaded, and the DLL entry point is returned in ImageEntryPoint + + EFI_NOT_FOUND - The .DLL file could not be found + + EFI_UNSUPPORTED - The .DLL file was loaded, but the entry point to the .DLL file could not + determined. + +--*/ +; + +#endif +// +// hob.c +// +EFI_STATUS +PeiBuildHobModule ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS Module, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +/*++ + +Routine Description: + + Builds a HOB for a loaded PE32 module + +Arguments: + + PeiServices - The PEI core services table. + ModuleName - The GUID File Name of the module + Memory - The 64 bit physical address of the module + ModuleLength - The length of the module in bytes + EntryPoint - The 64 bit physical address of the entry point + to the module + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobResourceDescriptor ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +/*++ + +Routine Description: + + Builds a HOB that describes a chunck of system memory + +Arguments: + + PeiServices - The PEI core services table. + + ResourceType - The type of resource described by this HOB + + ResourceAttribute - The resource attributes of the memory described by this HOB + + PhysicalStart - The 64 bit physical address of memory described by this HOB + + NumberOfBytes - The length of the memoty described by this HOB in bytes + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobGuid ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID *Guid, + IN UINTN DataLength, + IN OUT VOID **Hob + ) +/*++ + +Routine Description: + + Builds a custom HOB that is tagged with a GUID for identification + +Arguments: + + PeiServices - The PEI core services table. + + Guid - The GUID of the custome HOB type + + DataLength - The size of the data payload for the GUIDed HOB + + Hob - Pointer to the Hob + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobGuidData ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +/*++ + +Routine Description: + + Builds a custom HOB that is tagged with a GUID for identification + +Arguments: + + PeiServices - The PEI core services table. + + Guid - The GUID of the custome HOB type + + Data - The data to be copied into the GUIDed HOB data field. + + DataLength - The data field length. + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobFv ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a Firmware Volume HOB + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The base address of the Firmware Volume + + Length - The size of the Firmware Volume in bytes + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobCpu ( + IN EFI_PEI_SERVICES **PeiServices, + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +/*++ + +Routine Description: + + Builds a HOB for the CPU + +Arguments: + + PeiServices - The PEI core services table. + + SizeOfMemorySpace - Identifies the maximum + physical memory addressibility of the processor. + + SizeOfIoSpace - Identifies the maximum physical I/O addressibility + of the processor. + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobStack ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a HOB for the Stack + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The 64 bit physical address of the Stack + + Length - The length of the stack in bytes + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobBspStore ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for the bsp store + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The 64 bit physical address of the bsp store + + Length - The length of the bsp store in bytes + + MemoryType - Memory type + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +EFI_STATUS +PeiBuildHobMemoryAllocation ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_GUID *Name, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for the memory allocation + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The 64 bit physical address of the memory + + Length - The length of the memory allocation in bytes + + Name - Name for Hob + + MemoryType - Memory type + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +; + +// +// print.c +// +UINTN +AvSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN StrSize, + IN CONST CHAR8 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + AvSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + +Arguments: + + StartOfBuffer - Ascii buffer to print the results of the parsing of Format into. + + StrSize - Maximum number of characters to put into buffer. Zero means + no limit. + + FormatString - Ascii format string see file header for more details. + + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + ASPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Ascii buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +; + +// +// math.c +// +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be multiplied with a 32 bit + value returns 64bit result. + No checking if the result is greater than 64bits + +Arguments: + + Multiplicand - multiplicand + Multiplier - multiplier + +Returns: + + Multiplicand * Multiplier + +--*/ +; + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be divided with a 32 bit value returns + 64bit result and the Remainder. + N.B. only works for 31bit divisors!! + +Arguments: + + Dividend - dividend + Divisor - divisor + Remainder - buffer for remainder + +Returns: + + Dividend / Divisor + Remainder = Dividend mod Divisor + +--*/ +; + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be right shifted by 32 bits and returns the + shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift right. + +Returns: + + Value shifted right identified by the Count. + +--*/ +; + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be left shifted by 32 bits and + returns the shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + Count - Number of times to shift left. + +Returns: + + Value shifted left identified by the Count. + +--*/ +; + +VOID +RegisterNativeCpuIo ( + IN EFI_PEI_SERVICES **PeiServices, + IN VOID *CpuIo + ) +/*++ + +Routine Description: + + Register a native Cpu IO + +Arguments: + + PeiServices - Calling context + CpuIo - CpuIo instance to register + +Returns: + + None + +--*/ +; + +VOID +GetNativeCpuIo ( + IN EFI_PEI_SERVICES **PeiServices, + OUT VOID **CpuIo + ) +/*++ + +Routine Description: + + Get registered Cpu IO. + +Arguments: + + PeiServices - Calling context + CpuIo - CpuIo instance registered before + +Returns: + + None + +--*/ +; + +EFI_STATUS +FindFv ( + IN EFI_FIND_FV_PPI *This, + IN EFI_PEI_SERVICES **PeiServices, + IN OUT UINT8 *FvNumber, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FVAddress + ) +/*++ + +Routine Description: + + Search Fv in Hob. + +Arguments: + + This - Interface pointer that implement the Find Fv PPI + + PeiServices - Pointer to the PEI Service Table + + FvNumber - On input, the number of the fireware volume which supports FFS to locate + On output, the next FV number which supports FFS. + + FVAddress - The address of the volume which supports FFS to discover + +Returns: + + EFI_SUCCESS - An addtional FV which supports FFS found + EFI_OUT_OF_RESOURCES - There are no fireware volume which supports FFS for given fvnumber + EFI_INVALID_PARAMETER - FvAddress is NULL + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/peihoblib.h b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/peihoblib.h new file mode 100644 index 0000000000..23101754b1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/peihoblib.h @@ -0,0 +1,345 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiHobLib.h + +Abstract: + + +--*/ + +#ifndef _EFI_PEI_HOB_LIB_H_ +#define _EFI_PEI_HOB_LIB_H_ + +#include "PeiApi.h" // EFI_PEI_SERVICES definition +#define EFI_STACK_SIZE 0x20000 +#define EFI_BSP_STORE_SIZE 0x4000 + +EFI_STATUS +BuildHobHandoffInfoTable ( + IN VOID *HobStart, + IN UINT16 Version, + IN EFI_BOOT_MODE BootMode, + IN EFI_PHYSICAL_ADDRESS EfiMemoryTop, + IN EFI_PHYSICAL_ADDRESS EfiMemoryBottom, + IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop, + IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom + ) +/*++ + +Routine Description: + + Builds a HandoffInformationTable Information Table HOB + +Arguments: + + HobStart - Start pointer of hob list + Version - The version number pertaining to the PHIT HOB definition. + BootMode - The system boot mode as determined during the HOB producer phase. + EfiMemoryTop - The highest address location of memory that is allocated for use by the HOB + producer phase. + EfiMemoryBottom - The lowest address location of memory that is allocated for use by the HOB + producer phase. + EfiFreeMemoryTop - The highest address location of free memory that is currently available for use + by the HOB producer phase. + EfiFreeMemoryBottom - The lowest address location of free memory that is available for + use by the HOB producer phase. + +Returns: + + EFI_SUCCESS + +--*/ +; + +EFI_STATUS +BuildHobModule ( + IN VOID *HobStart, + IN EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS Module, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +/*++ + +Routine Description: + + Builds a HOB for a loaded PE32 module + +Arguments: + + HobStart - Start pointer of hob list + + ModuleName - The GUID File Name of the HON from the Firmware Volume + + Module - The 64 bit physical address of the module + + ModuleLength - The length of the module in bytes + + EntryPoint - The 64 bit physical address of the entry point to the module + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +BuildHobResourceDescriptor ( + IN VOID *HobStart, + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +/*++ + +Routine Description: + + Builds a HOB that describes a chunck of system memory + +Arguments: + + HobStart - Start pointer of hob list + + ResourceType - The type of memory described by this HOB + + ResourceAttribute - The memory attributes of the memory described by this HOB + + PhysicalStart - The 64 bit physical address of memory described by this HOB + + NumberOfBytes - The length of the memoty described by this HOB in bytes + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +BuildHobGuidType ( + IN VOID *HobStart, + IN EFI_GUID *Guid, + IN VOID *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + Builds a custom HOB that is tagged with a GUID for identification + +Arguments: + + HobStart - Start pointer of hob list + + Guid - The GUID of the custome HOB type + + Buffer - A pointer to the data for the custom HOB type + + BufferSize - The size in byte of BufferSize + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +BuildHobFvDescriptor ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a Firmware Volume HOB + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The base address of the Firmware Volume + + Length - The size of the Firmware Volume in bytes + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +BuildHobCpu ( + IN VOID *HobStart, + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +/*++ + +Routine Description: + + Builds a HOB for the CPU + +Arguments: + + HobStart - Start pointer of hob list + + SizeOfMemorySpace - Identifies the maximum + physical memory addressibility of the processor. + + SizeOfIoSpace - Identifies the maximum physical I/O addressibility + of the processor. + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +BuildHobStack ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a HOB for the Stack + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The 64 bit physical address of the Stack + + Length - The length of the stack in bytes + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +BuildHobBspStore ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for the bsp store + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The 64 bit physical address of bsp store + + Length - The length of the bsp store in bytes + + MemoryType - Memory type of the bsp store + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +BuildMemoryAllocationHob ( + IN VOID *HobStart, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_GUID *Name, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for memory allocation + +Arguments: + + HobStart - Start pointer of hob list + + BaseAddress - The base address of memory allocated by this HOB. + + Length - The length in bytes of memory allocated by this HOB. + + Name - A GUID that defines the memory allocation region¡¯s type and purpose, + as well as other fields within the memory allocation HOB. + + MemoryType - Defines the type of memory allocated by this HOB. + +Returns: + + EFI_SUCCESS + EFI_NOT_AVAILABLE_YET + +--*/ +; + +EFI_STATUS +GetFirstGuidHob ( + IN VOID **HobStart, + IN EFI_GUID *Guid, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL + ) +/*++ + +Routine Description: + + This function searches the first instance of a HOB among the whole HOB list. + +Arguments: + + HobStart - A pointer to the start pointer of hob list. + + Guid - A pointer to the GUID to match with in the HOB list. + + Buffer - A pointer to the pointer to the data for the custom HOB type. + + BufferSize - A Pointer to the size in byte of BufferSize. + +Returns: + EFI_SUCCESS + The first instance of the matched GUID HOB among the whole HOB list + +--*/ +; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Debug.c new file mode 100644 index 0000000000..c5a8b913c3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Debug.c @@ -0,0 +1,131 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Debug.c + +Abstract: + + Support for Debug primatives. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include "EfiPrintLib.h" +#include "EfiStatusCode.h" +#include "EfiCommonLib.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +VOID +PeiDebugAssert ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ) +/*++ + +Routine Description: + + Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded DEADLOOP (). + +Arguments: + + PeiServices - The PEI core services table. + + FileName - File name of failing routine. + + LineNumber - Line number of failing ASSERT(). + + Description - Description, usually the assertion, + +Returns: + + None + +--*/ +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; + + EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer); + + // + // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable, + // we want get enough information if assert. + // + (**PeiServices).PeiReportStatusCode ( + (EFI_PEI_SERVICES**)PeiServices, + (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), + 0, + &gEfiCallerIdGuid, + (EFI_STATUS_CODE_DATA *) Buffer + ); + + EFI_DEADLOOP (); +} + + +VOID +PeiDebugPrint ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + +Arguments: + + PeiServices - The PEI core services table. + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + ... - Print arguments + +Returns: + + None + +--*/ +{ + VA_LIST Marker; + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; + + VA_START (Marker, Format); + EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer); + + // + // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable, + // we want get enough information if assert. + // + (**PeiServices).PeiReportStatusCode ( + (EFI_PEI_SERVICES**)PeiServices, + EFI_DEBUG_CODE, + (EFI_SOFTWARE_PEI_MODULE | EFI_DC_UNSPECIFIED), + 0, + &gEfiCallerIdGuid, + (EFI_STATUS_CODE_DATA *) Buffer + ); + + return ; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c new file mode 100644 index 0000000000..43446a37dd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c @@ -0,0 +1,1104 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Decompress.c + +Abstract: + + Decompressor. Algorithm Ported from OPSD code (Decomp.asm) + +--*/ + +#include "TianoCommon.h" +#include EFI_PROTOCOL_DEFINITION (Decompress) +#include EFI_PROTOCOL_DEFINITION (TianoDecompress) + +EFI_STATUS +EFIAPI +EfiGetInfo ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ); + +EFI_STATUS +EFIAPI +EfiDecompress ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ); + +EFI_STATUS +EFIAPI +TianoGetInfo ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ); + +EFI_STATUS +EFIAPI +TianoDecompress ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ); + +// +// The protocol instance +// + +EFI_DECOMPRESS_PROTOCOL mEfiDecompress = { + EfiGetInfo, + EfiDecompress +}; + +EFI_TIANO_DECOMPRESS_PROTOCOL mTianoDecompress = { + TianoGetInfo, + TianoDecompress +}; + +EFI_STATUS +InstallEfiDecompress ( + IN OUT EFI_DECOMPRESS_PROTOCOL **This + ) +/*++ + +Routine Description: + + Install EFI decompress protocol. + +Arguments: + + This - Pointer to get decompress protocol as output + +Returns: + + EFI_SUCCESS - EFI decompress protocol successfully installed. + +--*/ +{ + *This = &mEfiDecompress; + return EFI_SUCCESS; +} + +EFI_STATUS +InstallTianoDecompress ( + EFI_TIANO_DECOMPRESS_PROTOCOL **This + ) +/*++ + +Routine Description: + + Install Tiano decompress protocol. + +Arguments: + + This - Pointer to get decompress protocol as output + +Returns: + + EFI_SUCCESS - Tiano decompress protocol successfully installed. + +--*/ +{ + *This = &mTianoDecompress; + return EFI_SUCCESS; +} +// +// Decompression algorithm begins here +// +#define BITBUFSIZ 32 +#define MAXMATCH 256 +#define THRESHOLD 3 +#define CODE_BIT 16 +#define UINT8_MAX 0xff +#define BAD_TABLE - 1 + +// +// C: Char&Len Set; P: Position Set; T: exTra Set +// +#define NC (0xff + MAXMATCH + 2 - THRESHOLD) +#define CBIT 9 +#define MAXPBIT 5 +#define TBIT 5 +#define MAXNP ((1U << MAXPBIT) - 1) +#define NT (CODE_BIT + 3) +#if NT > MAXNP +#define NPT NT +#else +#define NPT MAXNP +#endif + +typedef struct { + UINT8 *mSrcBase; // Starting address of compressed data + UINT8 *mDstBase; // Starting address of decompressed data + UINT32 mOutBuf; + UINT32 mInBuf; + + UINT16 mBitCount; + UINT32 mBitBuf; + UINT32 mSubBitBuf; + UINT16 mBlockSize; + UINT32 mCompSize; + UINT32 mOrigSize; + + UINT16 mBadTableFlag; + + UINT16 mLeft[2 * NC - 1]; + UINT16 mRight[2 * NC - 1]; + UINT8 mCLen[NC]; + UINT8 mPTLen[NPT]; + UINT16 mCTable[4096]; + UINT16 mPTTable[256]; + + // + // The length of the field 'Position Set Code Length Array Size' in Block Header. + // For EFI 1.1 de/compression algorithm, mPBit = 4 + // For Tiano de/compression algorithm, mPBit = 5 + // + UINT8 mPBit; +} SCRATCH_DATA; + +STATIC +VOID +FillBuf ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +/*++ + +Routine Description: + + Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. + +Arguments: + + Sd - The global scratch data + NumOfBits - The number of bits to shift and read. + +Returns: (VOID) + +--*/ +{ + Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits); + + while (NumOfBits > Sd->mBitCount) { + + Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount))); + + if (Sd->mCompSize > 0) { + // + // Get 1 byte into SubBitBuf + // + Sd->mCompSize--; + Sd->mSubBitBuf = 0; + Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; + Sd->mBitCount = 8; + + } else { + // + // No more bits from the source, just pad zero bit. + // + Sd->mSubBitBuf = 0; + Sd->mBitCount = 8; + + } + } + + Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits); + Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount; +} + +STATIC +UINT32 +GetBits ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +/*++ + +Routine Description: + + Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent + NumOfBits of bits from source. Returns NumOfBits of bits that are + popped out. + +Arguments: + + Sd - The global scratch data. + NumOfBits - The number of bits to pop and read. + +Returns: + + The bits that are popped out. + +--*/ +{ + UINT32 OutBits; + + OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits)); + + FillBuf (Sd, NumOfBits); + + return OutBits; +} + +STATIC +UINT16 +MakeTable ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfChar, + IN UINT8 *BitLen, + IN UINT16 TableBits, + OUT UINT16 *Table + ) +/*++ + +Routine Description: + + Creates Huffman Code mapping table according to code length array. + +Arguments: + + Sd - The global scratch data + NumOfChar - Number of symbols in the symbol set + BitLen - Code length array + TableBits - The width of the mapping table + Table - The table + +Returns: + + 0 - OK. + BAD_TABLE - The table is corrupted. + +--*/ +{ + UINT16 Count[17]; + UINT16 Weight[17]; + UINT16 Start[18]; + UINT16 *Pointer; + UINT16 Index3; + UINT16 Index; + UINT16 Len; + UINT16 Char; + UINT16 JuBits; + UINT16 Avail; + UINT16 NextCode; + UINT16 Mask; + + for (Index = 1; Index <= 16; Index++) { + Count[Index] = 0; + } + + for (Index = 0; Index < NumOfChar; Index++) { + Count[BitLen[Index]]++; + } + + Start[1] = 0; + + for (Index = 1; Index <= 16; Index++) { + Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index))); + } + + if (Start[17] != 0) { + /*(1U << 16)*/ + return (UINT16) BAD_TABLE; + } + + JuBits = (UINT16) (16 - TableBits); + + for (Index = 1; Index <= TableBits; Index++) { + Start[Index] >>= JuBits; + Weight[Index] = (UINT16) (1U << (TableBits - Index)); + } + + while (Index <= 16) { + Weight[Index++] = (UINT16) (1U << (16 - Index)); + } + + Index = (UINT16) (Start[TableBits + 1] >> JuBits); + + if (Index != 0) { + Index3 = (UINT16) (1U << TableBits); + while (Index != Index3) { + Table[Index++] = 0; + } + } + + Avail = NumOfChar; + Mask = (UINT16) (1U << (15 - TableBits)); + + for (Char = 0; Char < NumOfChar; Char++) { + + Len = BitLen[Char]; + if (Len == 0) { + continue; + } + + NextCode = (UINT16) (Start[Len] + Weight[Len]); + + if (Len <= TableBits) { + + for (Index = Start[Len]; Index < NextCode; Index++) { + Table[Index] = Char; + } + + } else { + + Index3 = Start[Len]; + Pointer = &Table[Index3 >> JuBits]; + Index = (UINT16) (Len - TableBits); + + while (Index != 0) { + if (*Pointer == 0) { + Sd->mRight[Avail] = Sd->mLeft[Avail] = 0; + *Pointer = Avail++; + } + + if (Index3 & Mask) { + Pointer = &Sd->mRight[*Pointer]; + } else { + Pointer = &Sd->mLeft[*Pointer]; + } + + Index3 <<= 1; + Index--; + } + + *Pointer = Char; + + } + + Start[Len] = NextCode; + } + // + // Succeeds + // + return 0; +} + +STATIC +UINT32 +DecodeP ( + IN SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Decodes a position value. + +Arguments: + + Sd - the global scratch data + +Returns: + + The position value decoded. + +--*/ +{ + UINT16 Val; + UINT32 Mask; + UINT32 Pos; + + Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + + if (Val >= MAXNP) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Sd->mBitBuf & Mask) { + Val = Sd->mRight[Val]; + } else { + Val = Sd->mLeft[Val]; + } + + Mask >>= 1; + } while (Val >= MAXNP); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[Val]); + + Pos = Val; + if (Val > 1) { + Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1))); + } + + return Pos; +} + +STATIC +UINT16 +ReadPTLen ( + IN SCRATCH_DATA *Sd, + IN UINT16 nn, + IN UINT16 nbit, + IN UINT16 Special + ) +/*++ + +Routine Description: + + Reads code lengths for the Extra Set or the Position Set + +Arguments: + + Sd - The global scratch data + nn - Number of symbols + nbit - Number of bits needed to represent nn + Special - The special symbol that needs to be taken care of + +Returns: + + 0 - OK. + BAD_TABLE - Table is corrupted. + +--*/ +{ + UINT16 Number; + UINT16 CharC; + UINT16 Index; + UINT32 Mask; + + Number = (UINT16) GetBits (Sd, nbit); + + if (Number == 0) { + CharC = (UINT16) GetBits (Sd, nbit); + + for (Index = 0; Index < 256; Index++) { + Sd->mPTTable[Index] = CharC; + } + + for (Index = 0; Index < nn; Index++) { + Sd->mPTLen[Index] = 0; + } + + return 0; + } + + Index = 0; + + while (Index < Number) { + + CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3)); + + if (CharC == 7) { + Mask = 1U << (BITBUFSIZ - 1 - 3); + while (Mask & Sd->mBitBuf) { + Mask >>= 1; + CharC += 1; + } + } + + FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3)); + + Sd->mPTLen[Index++] = (UINT8) CharC; + + if (Index == Special) { + CharC = (UINT16) GetBits (Sd, 2); + while ((INT16) (--CharC) >= 0) { + Sd->mPTLen[Index++] = 0; + } + } + } + + while (Index < nn) { + Sd->mPTLen[Index++] = 0; + } + + return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable); +} + +STATIC +VOID +ReadCLen ( + SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Reads code lengths for Char&Len Set. + +Arguments: + + Sd - the global scratch data + +Returns: (VOID) + +--*/ +{ + UINT16 Number; + UINT16 CharC; + UINT16 Index; + UINT32 Mask; + + Number = (UINT16) GetBits (Sd, CBIT); + + if (Number == 0) { + CharC = (UINT16) GetBits (Sd, CBIT); + + for (Index = 0; Index < NC; Index++) { + Sd->mCLen[Index] = 0; + } + + for (Index = 0; Index < 4096; Index++) { + Sd->mCTable[Index] = CharC; + } + + return ; + } + + Index = 0; + while (Index < Number) { + + CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + if (CharC >= NT) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Mask & Sd->mBitBuf) { + CharC = Sd->mRight[CharC]; + } else { + CharC = Sd->mLeft[CharC]; + } + + Mask >>= 1; + + } while (CharC >= NT); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[CharC]); + + if (CharC <= 2) { + + if (CharC == 0) { + CharC = 1; + } else if (CharC == 1) { + CharC = (UINT16) (GetBits (Sd, 4) + 3); + } else if (CharC == 2) { + CharC = (UINT16) (GetBits (Sd, CBIT) + 20); + } + + while ((INT16) (--CharC) >= 0) { + Sd->mCLen[Index++] = 0; + } + + } else { + + Sd->mCLen[Index++] = (UINT8) (CharC - 2); + + } + } + + while (Index < NC) { + Sd->mCLen[Index++] = 0; + } + + MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable); + + return ; +} + +STATIC +UINT16 +DecodeC ( + SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Decode a character/length value. + +Arguments: + + Sd - The global scratch data. + +Returns: + + The value decoded. + +--*/ +{ + UINT16 Index2; + UINT32 Mask; + + if (Sd->mBlockSize == 0) { + // + // Starting a new block + // + Sd->mBlockSize = (UINT16) GetBits (Sd, 16); + Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3); + if (Sd->mBadTableFlag != 0) { + return 0; + } + + ReadCLen (Sd); + + Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1)); + if (Sd->mBadTableFlag != 0) { + return 0; + } + } + + Sd->mBlockSize--; + Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)]; + + if (Index2 >= NC) { + Mask = 1U << (BITBUFSIZ - 1 - 12); + + do { + if (Sd->mBitBuf & Mask) { + Index2 = Sd->mRight[Index2]; + } else { + Index2 = Sd->mLeft[Index2]; + } + + Mask >>= 1; + } while (Index2 >= NC); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mCLen[Index2]); + + return Index2; +} + +STATIC +VOID +Decode ( + SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Decode the source data and put the resulting data into the destination buffer. + +Arguments: + + Sd - The global scratch data + +Returns: (VOID) + + --*/ +{ + UINT16 BytesRemain; + UINT32 DataIdx; + UINT16 CharC; + + BytesRemain = (UINT16) (-1); + + DataIdx = 0; + + for (;;) { + CharC = DecodeC (Sd); + if (Sd->mBadTableFlag != 0) { + return ; + } + + if (CharC < 256) { + // + // Process an Original character + // + if (Sd->mOutBuf >= Sd->mOrigSize) { + return ; + } else { + Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC; + } + + } else { + // + // Process a Pointer + // + CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD)); + + BytesRemain = CharC; + + DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1; + + BytesRemain--; + while ((INT16) (BytesRemain) >= 0) { + Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++]; + if (Sd->mOutBuf >= Sd->mOrigSize) { + return ; + } + + BytesRemain--; + } + } + } + + return ; +} + +EFI_STATUS +GetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + UINT8 *Src; + + *ScratchSize = sizeof (SCRATCH_DATA); + + Src = Source; + if (SrcSize < 8) { + return EFI_INVALID_PARAMETER; + } + + *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); + return EFI_SUCCESS; +} + +EFI_STATUS +Decompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize, + IN UINT8 Version + ) +/*++ + +Routine Description: + + The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + Version - The version of de/compression algorithm. + Version 1 for EFI 1.1 de/compression algorithm. + Version 2 for Tiano de/compression algorithm. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + UINT32 Index; + UINT32 CompSize; + UINT32 OrigSize; + EFI_STATUS Status; + SCRATCH_DATA *Sd; + UINT8 *Src; + UINT8 *Dst; + + Status = EFI_SUCCESS; + Src = Source; + Dst = Destination; + + if (ScratchSize < sizeof (SCRATCH_DATA)) { + return EFI_INVALID_PARAMETER; + } + + Sd = (SCRATCH_DATA *) Scratch; + + if (SrcSize < 8) { + return EFI_INVALID_PARAMETER; + } + + CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24); + OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); + + // + // If compressed file size is 0, return + // + if (OrigSize == 0) { + return Status; + } + + if (SrcSize < CompSize + 8) { + return EFI_INVALID_PARAMETER; + } + + if (DstSize != OrigSize) { + return EFI_INVALID_PARAMETER; + } + + Src = Src + 8; + + for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) { + ((UINT8 *) Sd)[Index] = 0; + } + // + // The length of the field 'Position Set Code Length Array Size' in Block Header. + // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4 + // For Tiano de/compression algorithm(Version 2), mPBit = 5 + // + switch (Version) { + case 1: + Sd->mPBit = 4; + break; + + case 2: + Sd->mPBit = 5; + break; + + default: + // + // Currently, only have 2 versions + // + return EFI_INVALID_PARAMETER; + } + + Sd->mSrcBase = Src; + Sd->mDstBase = Dst; + Sd->mCompSize = CompSize; + Sd->mOrigSize = OrigSize; + + // + // Fill the first BITBUFSIZ bits + // + FillBuf (Sd, BITBUFSIZ); + + // + // Decompress it + // + Decode (Sd); + + if (Sd->mBadTableFlag != 0) { + // + // Something wrong with the source + // + Status = EFI_INVALID_PARAMETER; + } + + return Status; +} + +EFI_STATUS +EFIAPI +EfiGetInfo ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + return GetInfo ( + Source, + SrcSize, + DstSize, + ScratchSize + ); +} + +EFI_STATUS +EFIAPI +EfiDecompress ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + // + // For EFI 1.1 de/compression algorithm, the version is 1. + // + return Decompress ( + Source, + SrcSize, + Destination, + DstSize, + Scratch, + ScratchSize, + 1 + ); +} + +EFI_STATUS +EFIAPI +TianoGetInfo ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + return GetInfo ( + Source, + SrcSize, + DstSize, + ScratchSize + ); +} + +EFI_STATUS +EFIAPI +TianoDecompress ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + // + // For Tiano de/compression algorithm, the version is 2. + // + return Decompress ( + Source, + SrcSize, + Destination, + DstSize, + Scratch, + ScratchSize, + 2 + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/FindFv.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/FindFv.c new file mode 100644 index 0000000000..fcff7a648d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/FindFv.c @@ -0,0 +1,179 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + FindFv.c + +Abstract: + + Library function to find fv by hob. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include "PeiLib.h" +#include "PeiHobLib.h" +#include "EfiCommonLib.h" +#include EFI_GUID_DEFINITION (FirmwareFileSystem) + +static +VOID * +GetHob ( + IN UINT16 Type, + IN VOID *HobStart + ) +/*++ + +Routine Description: + + This function returns the first instance of a HOB type in a HOB list. + +Arguments: + + Type The HOB type to return. + HobStart The first HOB in the HOB list. + +Returns: + + HobStart There were no HOBs found with the requested type. + else Returns the first HOB with the matching type. + +--*/ +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = HobStart; + // + // Return input if not found + // + if (HobStart == NULL) { + return HobStart; + } + + // + // Parse the HOB list, stop if end of list or matching type found. + // + while (!END_OF_HOB_LIST (Hob)) { + + if (Hob.Header->HobType == Type) { + break; + } + + Hob.Raw = GET_NEXT_HOB (Hob); + } + + // + // Return input if not found + // + if (END_OF_HOB_LIST (Hob)) { + return HobStart; + } + + return (VOID *) (Hob.Raw); +} + +EFI_STATUS +FindFv ( + IN EFI_FIND_FV_PPI *This, + IN EFI_PEI_SERVICES **PeiServices, + IN OUT UINT8 *FvNumber, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FvAddress + ) +/*++ + +Routine Description: + + Search Fv which supports FFS. + +Arguments: + + This - Interface pointer that implement the Find Fv PPI + + PeiServices - Pointer to the PEI Service Table + + FvNumber - On input, the number of the fireware volume which supports FFS to locate + On output, the next FV number which supports FFS. + + FVAddress - The address of the volume which supports FFS to discover + +Returns: + + EFI_SUCCESS - An addtional FV which supports FFS found + EFI_OUT_OF_RESOURCES - There are no fireware volume which supports FFS for given fvnumber + EFI_INVALID_PARAMETER - FvAddress is NULL + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_HOB_POINTERS HobStart; + EFI_PEI_HOB_POINTERS Hob; + EFI_HOB_FIRMWARE_VOLUME *FvHob; + UINT8 FvIndex; + + if (FvAddress == NULL){ + return EFI_INVALID_PARAMETER; + } + + Hob.Raw = NULL; + FvIndex = 0; + + // + // Get the Hob table pointer + // + Status = (*PeiServices)->GetHobList ( + PeiServices, + &HobStart.Raw + ); + + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Loop to search the wanted FirmwareVolume which supports FFS + // + // + while (FvIndex <= *FvNumber) { + + Hob.Raw = GetHob (EFI_HOB_TYPE_FV, HobStart.Raw); + + // + // If the Hob is not EFI_HOB_TYPE_FV, it indicates that + // we have finished all FV volumes search, and there is no + // the FFS FV specified by FvNumber. + // + if (Hob.Header->HobType != EFI_HOB_TYPE_FV) { + *FvNumber = 0; + return EFI_OUT_OF_RESOURCES; + } + + HobStart.Raw = Hob.Raw + Hob.Header->HobLength; + FvHob = Hob.FirmwareVolume; + *FvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvHob->BaseAddress); + // + // Check if the FV supports FFS + // + if (EfiCompareGuid (&((*FvAddress)->FileSystemGuid), &gEfiFirmwareFileSystemGuid)) { + FvIndex++; + } + } + + // + // Return the next FV number which supports FFS. + // + (*FvNumber)++; + + return EFI_SUCCESS; + +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Hob/Hob.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Hob/Hob.c new file mode 100644 index 0000000000..eb1ae2d437 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Hob/Hob.c @@ -0,0 +1,521 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + hob.c + +Abstract: + + PEI Library Functions + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include "peilib.h" +#include EFI_GUID_DEFINITION (MemoryAllocationHob) + + +EFI_STATUS +PeiBuildHobModule ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID *ModuleName, + IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule, + IN UINT64 ModuleLength, + IN EFI_PHYSICAL_ADDRESS EntryPoint + ) +/*++ + +Routine Description: + + Builds a HOB for a loaded PE32 module + +Arguments: + + PeiServices - The PEI core services table. + ModuleName - The GUID File Name of the module + MemoryAllocationModule - The 64 bit physical address of the module + ModuleLength - The length of the module in bytes + EntryPoint - The 64 bit physical address of the entry point + to the module + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob; + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_MEMORY_ALLOCATION, + sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE), + &Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Hob->MemoryAllocationHeader.Name = gEfiHobMemeryAllocModuleGuid; + Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; + Hob->MemoryAllocationHeader.MemoryLength = ModuleLength; + Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode; + (*PeiServices)->SetMem ( + Hob->MemoryAllocationHeader.Reserved, + sizeof (Hob->MemoryAllocationHeader.Reserved), + 0 + ); + + Hob->ModuleName = *ModuleName; + Hob->EntryPoint = EntryPoint; + + return EFI_SUCCESS; +} + + +EFI_STATUS +PeiBuildHobResourceDescriptor ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_RESOURCE_TYPE ResourceType, + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, + IN EFI_PHYSICAL_ADDRESS PhysicalStart, + IN UINT64 NumberOfBytes + ) +/*++ + +Routine Description: + + Builds a HOB that describes a chunck of system memory + +Arguments: + + PeiServices - The PEI core services table. + + ResourceType - The type of resource described by this HOB + + ResourceAttribute - The resource attributes of the memory described by this HOB + + PhysicalStart - The 64 bit physical address of memory described by this HOB + + NumberOfBytes - The length of the memoty described by this HOB in bytes + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_RESOURCE_DESCRIPTOR *Hob; + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, + sizeof (EFI_HOB_RESOURCE_DESCRIPTOR), + &Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Hob->ResourceType = ResourceType; + Hob->ResourceAttribute = ResourceAttribute; + Hob->PhysicalStart = PhysicalStart; + Hob->ResourceLength = NumberOfBytes; + + return EFI_SUCCESS; +} + + +EFI_STATUS +PeiBuildHobGuid ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID *Guid, + IN UINTN DataLength, + OUT VOID **Hob + ) +/*++ + +Routine Description: + + Builds a custom HOB that is tagged with a GUID for identification + +Arguments: + + PeiServices - The PEI core services table. + Guid - The GUID of the custome HOB type + DataLength - The size of the data payload for the GUIDed HOB + Hob - Pointer to pointer to the created Hob + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_GUID_EXTENSION, + (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength), + Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + ((EFI_HOB_GUID_TYPE *)(*Hob))->Name = *Guid; + + return EFI_SUCCESS; +} + + +EFI_STATUS +PeiBuildHobGuidData ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +/*++ + +Routine Description: + + Builds a custom HOB that is tagged with a GUID for identification + +Arguments: + + PeiServices - The PEI core services table. + + Guid - The GUID of the custome HOB type + + Data - The data to be copied into the GUIDed HOB data field. + + DataLength - The data field length. + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + + EFI_HOB_GUID_TYPE *Hob; + + Status = PeiBuildHobGuid ( + PeiServices, + Guid, + DataLength, + &Hob + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + Hob++; + (*PeiServices)->CopyMem (Hob, Data, DataLength); + + return EFI_SUCCESS; +} + + +EFI_STATUS +PeiBuildHobFv ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a Firmware Volume HOB + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The base address of the Firmware Volume + + Length - The size of the Firmware Volume in bytes + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_FIRMWARE_VOLUME *Hob; + + // + // Check FV Signature + // + PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE); + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_FV, + sizeof (EFI_HOB_FIRMWARE_VOLUME), + &Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; + + return EFI_SUCCESS; +} + + +EFI_STATUS +PeiBuildHobCpu ( + IN EFI_PEI_SERVICES **PeiServices, + IN UINT8 SizeOfMemorySpace, + IN UINT8 SizeOfIoSpace + ) +/*++ + +Routine Description: + + Builds a HOB for the CPU + +Arguments: + + PeiServices - The PEI core services table. + + SizeOfMemorySpace - Identifies the maximum + physical memory addressibility of the processor. + + SizeOfIoSpace - Identifies the maximum physical I/O addressibility + of the processor. + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_CPU *Hob; + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_CPU, + sizeof (EFI_HOB_CPU), + &Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Hob->SizeOfMemorySpace = SizeOfMemorySpace; + Hob->SizeOfIoSpace = SizeOfIoSpace; + (*PeiServices)->SetMem ( + Hob->Reserved, + sizeof (Hob->Reserved), + 0 + ); + + return EFI_SUCCESS; +} + + + +EFI_STATUS +PeiBuildHobStack ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Builds a HOB for the Stack + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The 64 bit physical address of the Stack + + Length - The length of the stack in bytes + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_MEMORY_ALLOCATION_STACK *Hob; + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_MEMORY_ALLOCATION, + sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK), + &Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Hob->AllocDescriptor.Name = gEfiHobMemeryAllocStackGuid; + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = EfiConventionalMemory; + (*PeiServices)->SetMem ( + Hob->AllocDescriptor.Reserved, + sizeof (Hob->AllocDescriptor.Reserved), + 0 + ); + + return EFI_SUCCESS; +} + + + +EFI_STATUS +PeiBuildHobBspStore ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for the bsp store + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The 64 bit physical address of the bsp + + Length - The length of the bsp store in bytes + + MemoryType - Memory type + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob; + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_MEMORY_ALLOCATION, + sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE), + &Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Hob->AllocDescriptor.Name = gEfiHobMemeryAllocBspStoreGuid; + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = MemoryType; + (*PeiServices)->SetMem ( + Hob->AllocDescriptor.Reserved, + sizeof (Hob->AllocDescriptor.Reserved), + 0 + ); + + return EFI_SUCCESS; +} + + +EFI_STATUS +PeiBuildHobMemoryAllocation ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_GUID *Name, + IN EFI_MEMORY_TYPE MemoryType + ) +/*++ + +Routine Description: + + Builds a HOB for the memory allocation. + +Arguments: + + PeiServices - The PEI core services table. + + BaseAddress - The 64 bit physical address of the memory + + Length - The length of the memory allocation in bytes + + Name - Name for Hob + + MemoryType - Memory type + +Returns: + + EFI_SUCCESS - Hob is successfully built. + Others - Errors occur while creating new Hob + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_MEMORY_ALLOCATION *Hob; + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_MEMORY_ALLOCATION, + sizeof (EFI_HOB_MEMORY_ALLOCATION), + &Hob + ); + if (EFI_ERROR (Status)) { + return Status; + } + + if (Name != NULL) { + Hob->AllocDescriptor.Name = *Name; + } else { + (*PeiServices)->SetMem(&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID), 0); + } + + Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob->AllocDescriptor.MemoryLength = Length; + Hob->AllocDescriptor.MemoryType = MemoryType; + (*PeiServices)->SetMem ( + Hob->AllocDescriptor.Reserved, + sizeof (Hob->AllocDescriptor.Reserved), + 0 + ); + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/HwAccess.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/HwAccess.s new file mode 100644 index 0000000000..931f9302a2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/HwAccess.s @@ -0,0 +1,77 @@ +//++ +// Copyright (c) 2007, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// HWAccess.s +// +// Abstract: +// +// Contains an implementation of Read/Write Kr7 for the Itanium-based architecture. +// +// +// +// Revision History: +// +//-- + + .file "HWAccess.s" +#include "IpfMacro.i" + + +//---------------------------------------------------------------------------------- +//++ +//VOID +//AsmWriteKr7 ( +// UINT64 +// ); +// +// This routine saves the given input value into the kernel register 7 +// +// Arguments : +// +// On Entry : 64 bit value to be saved. +// +// Return Value: None +// +//-- +//---------------------------------------------------------------------------------- +PROCEDURE_ENTRY (AsmWriteKr7) + NESTED_SETUP (1,2,0,0) + mov ar.k7 = in0;; + NESTED_RETURN + +PROCEDURE_EXIT (AsmWriteKr7) + +//--------------------------------------------------------------------------------- +//++ +//UINT64 +//AsmReadKr7 ( +// VOID +// ); +// +// This routine returns the value of the kernel register 7 +// +// Arguments : +// +// On Entry : None +// +// Return Value: 64bit Value of the register. +// +//-- +//---------------------------------------------------------------------------------- +PROCEDURE_ENTRY (AsmReadKr7) + NESTED_SETUP (0,2,0,0) + mov r8 = ar.k7;; + NESTED_RETURN +PROCEDURE_EXIT (AsmReadKr7) +//---------------------------------------------------------------------------------- + + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c new file mode 100644 index 0000000000..d56d949679 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c @@ -0,0 +1,268 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeCoffLoaderEx.c + +Abstract: + + Fixes Intel Itanium(TM) specific relocation types + + +Revision History + +--*/ + +#include "TianoCommon.h" +#include "EfiImage.h" + +#define EXT_IMM64(Value, Address, Size, InstPos, ValPos) \ + Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos) + +#define INS_IMM64(Value, Address, Size, InstPos, ValPos) \ + *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \ + ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos) + +#define IMM64_IMM7B_INST_WORD_X 3 +#define IMM64_IMM7B_SIZE_X 7 +#define IMM64_IMM7B_INST_WORD_POS_X 4 +#define IMM64_IMM7B_VAL_POS_X 0 + +#define IMM64_IMM9D_INST_WORD_X 3 +#define IMM64_IMM9D_SIZE_X 9 +#define IMM64_IMM9D_INST_WORD_POS_X 18 +#define IMM64_IMM9D_VAL_POS_X 7 + +#define IMM64_IMM5C_INST_WORD_X 3 +#define IMM64_IMM5C_SIZE_X 5 +#define IMM64_IMM5C_INST_WORD_POS_X 13 +#define IMM64_IMM5C_VAL_POS_X 16 + +#define IMM64_IC_INST_WORD_X 3 +#define IMM64_IC_SIZE_X 1 +#define IMM64_IC_INST_WORD_POS_X 12 +#define IMM64_IC_VAL_POS_X 21 + +#define IMM64_IMM41a_INST_WORD_X 1 +#define IMM64_IMM41a_SIZE_X 10 +#define IMM64_IMM41a_INST_WORD_POS_X 14 +#define IMM64_IMM41a_VAL_POS_X 22 + +#define IMM64_IMM41b_INST_WORD_X 1 +#define IMM64_IMM41b_SIZE_X 8 +#define IMM64_IMM41b_INST_WORD_POS_X 24 +#define IMM64_IMM41b_VAL_POS_X 32 + +#define IMM64_IMM41c_INST_WORD_X 2 +#define IMM64_IMM41c_SIZE_X 23 +#define IMM64_IMM41c_INST_WORD_POS_X 0 +#define IMM64_IMM41c_VAL_POS_X 40 + +#define IMM64_SIGN_INST_WORD_X 3 +#define IMM64_SIGN_SIZE_X 1 +#define IMM64_SIGN_INST_WORD_POS_X 27 +#define IMM64_SIGN_VAL_POS_X 63 + +EFI_STATUS +PeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +/*++ + +Routine Description: + + Performs an Itanium-based specific relocation fixup + +Arguments: + + Reloc - Pointer to the relocation record + + Fixup - Pointer to the address to fix up + + FixupData - Pointer to a buffer to log the fixups + + Adjust - The offset to adjust the fixup + +Returns: + + Status code + +--*/ +{ + UINT64 *F64; + UINT64 FixupVal; + + switch ((*Reloc) >> 12) { + + case EFI_IMAGE_REL_BASED_IA64_IMM64: + + // + // Align it to bundle address before fixing up the + // 64-bit immediate value of the movl instruction. + // + + Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15)); + FixupVal = (UINT64)0; + + // + // Extract the lower 32 bits of IMM64 from bundle + // + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X, + IMM64_IMM7B_SIZE_X, + IMM64_IMM7B_INST_WORD_POS_X, + IMM64_IMM7B_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X, + IMM64_IMM9D_SIZE_X, + IMM64_IMM9D_INST_WORD_POS_X, + IMM64_IMM9D_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X, + IMM64_IMM5C_SIZE_X, + IMM64_IMM5C_INST_WORD_POS_X, + IMM64_IMM5C_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IC_INST_WORD_X, + IMM64_IC_SIZE_X, + IMM64_IC_INST_WORD_POS_X, + IMM64_IC_VAL_POS_X + ); + + EXT_IMM64(FixupVal, + (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X, + IMM64_IMM41a_SIZE_X, + IMM64_IMM41a_INST_WORD_POS_X, + IMM64_IMM41a_VAL_POS_X + ); + + // + // Update 64-bit address + // + FixupVal += Adjust; + + // + // Insert IMM64 into bundle + // + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X), + IMM64_IMM7B_SIZE_X, + IMM64_IMM7B_INST_WORD_POS_X, + IMM64_IMM7B_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X), + IMM64_IMM9D_SIZE_X, + IMM64_IMM9D_INST_WORD_POS_X, + IMM64_IMM9D_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X), + IMM64_IMM5C_SIZE_X, + IMM64_IMM5C_INST_WORD_POS_X, + IMM64_IMM5C_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X), + IMM64_IC_SIZE_X, + IMM64_IC_INST_WORD_POS_X, + IMM64_IC_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X), + IMM64_IMM41a_SIZE_X, + IMM64_IMM41a_INST_WORD_POS_X, + IMM64_IMM41a_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X), + IMM64_IMM41b_SIZE_X, + IMM64_IMM41b_INST_WORD_POS_X, + IMM64_IMM41b_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X), + IMM64_IMM41c_SIZE_X, + IMM64_IMM41c_INST_WORD_POS_X, + IMM64_IMM41c_VAL_POS_X + ); + + INS_IMM64(FixupVal, + ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X), + IMM64_SIGN_SIZE_X, + IMM64_SIGN_INST_WORD_POS_X, + IMM64_SIGN_VAL_POS_X + ); + + F64 = (UINT64 *) Fixup; + if (*FixupData != NULL) { + *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64)); + *(UINT64 *)(*FixupData) = *F64; + *FixupData = *FixupData + sizeof(UINT64); + } + break; + + default: + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +/*++ +Routine Description: + + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IPF, EBC, + images. Calling the entry point in a correct mannor is up to the + consumer of this library. + +Arguments: + + Machine - Machine type from the PE Header. + +Returns: + + TRUE - if this PE/COFF loader can load the image + FALSE - if this PE/COFF loader cannot load the image + +--*/ +{ + if ((Machine == EFI_IMAGE_MACHINE_IA64) || (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h new file mode 100644 index 0000000000..8f18ff0408 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h @@ -0,0 +1,87 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeCoffLoaderEx.h + +Abstract: + + Fixes Intel Itanium(TM) specific relocation types + + +Revision History + +--*/ + +#ifndef _PE_COFF_LOADER_EX_H_ +#define _PE_COFF_LOADER_EX_H_ + + +EFI_STATUS +PeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +/*++ + +Routine Description: + + Performs an Itanium-based specific relocation fixup + +Arguments: + + Reloc - Pointer to the relocation record + + Fixup - Pointer to the address to fix up + + FixupData - Pointer to a buffer to log the fixups + + Adjust - The offset to adjust the fixup + +Returns: + + Status code + +--*/ +; + +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +/*++ +Routine Description: + + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IPF, EBC, + images. Calling the entry point in a correct mannor is up to the + consumer of this library. + +Arguments: + + Machine - Machine type from the PE Header. + +Returns: + + TRUE - if this PE/COFF loader can load the image + FALSE - if this PE/COFF loader cannot load the image + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c new file mode 100644 index 0000000000..7c77dd1bd8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c @@ -0,0 +1,108 @@ +/*++ + +Copyright 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiServicePointer.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "PeiApi.h" +#include "PeiLib.h" + + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + +VOID +SetPeiServicesTablePointer ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Save PeiService pointer so that it can be retrieved anywhere. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + PhyscialAddress - The physcial address of variable PeiServices. + +Returns: + NONE + +--*/ + +{ + // + // For Itanium Processor Family processors, the EFI_PEI_SERVICES** + // is stored in kernel register7. + // + AsmWriteKr7((UINT64)(UINTN)PeiServices); +} + + +EFI_PEI_SERVICES ** +GetPeiServicesTablePointer ( + VOID + ) +/*++ + +Routine Description: + + Get PeiService pointer. + +Arguments: + + NONE. + +Returns: + The direct pointer to PeiServiceTable. + +--*/ + +{ + // + // For Itanium Processor Family processors, the EFI_PEI_SERVICES** + // is stored in kernel register7. + // + return (EFI_PEI_SERVICES **)(UINTN)AsmReadKr7(); +} + +VOID +MigrateIdtTable ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Migrate IDT from CAR to real memory where preceded with 4 bytes for + storing PeiService pointer. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + +Returns: + + NONE. + +--*/ +{ + return; +} + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s new file mode 100644 index 0000000000..5814bb71b7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s @@ -0,0 +1,61 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// PerformancePrimitives.s +// +// Abstract: +// +// +// Revision History: +// +//-- + +.file "PerformancePrimitives.s" + +#include "IpfMacro.i" + +//----------------------------------------------------------------------------- +//++ +// GetTimerValue +// +// Implementation of CPU-based time service +// +// On Entry : +// EFI_STATUS +// GetTimerValue ( +// OUT UINT64 *TimerValue +// ) +// +// Return Value: +// r8 = Status +// r9 = 0 +// r10 = 0 +// r11 = 0 +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (GetTimerValue) + + NESTED_SETUP (1,8,0,0) + mov r8 = ar.itc;; + st8 [r32]= r8 + mov r8 = r0 + mov r9 = r0 + mov r10 = r0 + mov r11 = r0 + NESTED_RETURN + +PROCEDURE_EXIT (GetTimerValue) +//--------------------------------------------------------------------------- + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s new file mode 100644 index 0000000000..08ff773b27 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s @@ -0,0 +1,122 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// SwitchStack.s +// +// Abstract: +// +// Contains an implementation of a stack switch for the Itanium-based architecture. +// +// +// +// Revision History: +// +//-- + + .file "SwitchStack.s" + +#include +#include + +// Define hardware RSE Configuration Register +// +// RS Configuration (RSC) bit field positions + +#define RSC_MODE 0 +#define RSC_PL 2 +#define RSC_BE 4 +// RSC bits 5-15 reserved +#define RSC_MBZ0 5 +#define RSC_MBZ0_V 0x3ff +#define RSC_LOADRS 16 +#define RSC_LOADRS_LEN 14 +// RSC bits 30-63 reserved +#define RSC_MBZ1 30 +#define RSC_MBZ1_V 0x3ffffffffULL + +// RSC modes +// Lazy +#define RSC_MODE_LY (0x0) +// Store intensive +#define RSC_MODE_SI (0x1) +// Load intensive +#define RSC_MODE_LI (0x2) +// Eager +#define RSC_MODE_EA (0x3) + +// RSC Endian bit values +#define RSC_BE_LITTLE 0 +#define RSC_BE_BIG 1 + +// RSC while in kernel: enabled, little endian, pl = 0, eager mode +#define RSC_KERNEL ((RSC_MODE_EA<> Count; +} + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be multiplied with a 32 bit + value returns 64bit result. + No checking if the result is greater than 64bits + +Arguments: + + Multiplicand - multiplicand + Multiplier - multiplier + +Returns: + + Multiplicand * Multiplier + +--*/ +{ + return Multiplicand * Multiplier; +} + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be divided with a 32 bit value returns + 64bit result and the Remainder. + N.B. only works for 31bit divisors!! + +Arguments: + + Dividend - dividend + Divisor - divisor + Remainder - buffer for remainder + +Returns: + + Dividend / Divisor + Remainder = Dividend mod Divisor + +--*/ +{ + if (Remainder) { + *Remainder = Dividend % Divisor; + } + + return Dividend / Divisor; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s new file mode 100644 index 0000000000..e48a5e427d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s @@ -0,0 +1,106 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// pioflush.s +// +// Abstract: +// +// +// Revision History: +// +//-- + + .file "pioflush.c" + .radix D + .section .text, "ax", "progbits" + .align 32 + .section .pdata, "a", "progbits" + .align 4 + .section .xdata, "a", "progbits" + .align 8 + .section .data, "wa", "progbits" + .align 16 + .section .rdata, "a", "progbits" + .align 16 + .section .bss, "wa", "nobits" + .align 16 + .section .tls$, "was", "progbits" + .align 16 + .section .sdata, "was", "progbits" + .align 16 + .section .sbss, "was", "nobits" + .align 16 + .section .srdata, "as", "progbits" + .align 16 + .section .rdata, "a", "progbits" + .align 16 + .section .rtcode, "ax", "progbits" + .align 32 + .type RtPioICacheFlush# ,@function + .global RtPioICacheFlush# +// Function compile flags: /Ogsy + .section .rtcode + +// Begin code for function: RtPioICacheFlush: + .proc RtPioICacheFlush# + .align 32 +RtPioICacheFlush: +// File e:\tmp\pioflush.c + { .mii //R-Addr: 0X00 + alloc r3=2, 0, 0, 0 //11, 00000002H + cmp4.leu p0,p6=32, r33;; //15, 00000020H + (p6) mov r33=32;; //16, 00000020H + } + { .mii //R-Addr: 0X010 + nop.m 0 + zxt4 r29=r33;; //21 + dep.z r30=r29, 0, 5;; //21, 00000005H + } + { .mii //R-Addr: 0X020 + cmp4.eq p0,p7=r0, r30 //21 + shr.u r28=r29, 5;; //19, 00000005H + (p7) adds r28=1, r28;; //22, 00000001H + } + { .mii //R-Addr: 0X030 + nop.m 0 + shl r27=r28, 5;; //25, 00000005H + zxt4 r26=r27;; //25 + } + { .mfb //R-Addr: 0X040 + add r31=r26, r32 //25 + nop.f 0 + nop.b 0 + } +$L143: + { .mii //R-Addr: 0X050 + fc r32 //27 + adds r32=32, r32;; //28, 00000020H + cmp.ltu p14,p15=r32, r31 //29 + } + { .mfb //R-Addr: 0X060 + nop.m 0 + nop.f 0 + (p14) br.cond.dptk.few $L143#;; //29, 880000/120000 + } + { .mmi + sync.i;; + srlz.i + nop.i 0;; + } + { .mfb //R-Addr: 0X070 + nop.m 0 + nop.f 0 + br.ret.sptk.few b0;; //31 + } +// End code for function: + .endp RtPioICacheFlush# +// END diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/processor.c new file mode 100644 index 0000000000..e6d5c40435 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/processor.c @@ -0,0 +1,118 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Processor.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "EfiJump.h" +#include "PeiHob.h" +#include EFI_GUID_DEFINITION (PeiFlushInstructionCache) +#include EFI_GUID_DEFINITION (PeiTransferControl) + +EFI_STATUS +WinNtFlushInstructionCacheFlush ( + IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ); + +EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = { + SetJump, + LongJump, + sizeof (EFI_JUMP_BUFFER) +}; + +EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = { + WinNtFlushInstructionCacheFlush +}; + +EFI_STATUS +InstallEfiPeiTransferControl ( + IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This + ) +/*++ + +Routine Description: + + Installs the pointer to the transfer control mechanism + +Arguments: + + This - Pointer to transfer control mechanism. + +Returns: + + EFI_SUCCESS - Successfully installed. + +--*/ +{ + *This = &mTransferControl; + return EFI_SUCCESS; +} + +EFI_STATUS +InstallEfiPeiFlushInstructionCache ( + IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This + ) +/*++ + +Routine Description: + + Installs the pointer to the flush instruction cache mechanism + +Arguments: + + This - Pointer to flush instruction cache mechanism. + +Returns: + + EFI_SUCCESS - Successfully installed + +--*/ +{ + *This = &mFlushInstructionCache; + return EFI_SUCCESS; +} + +EFI_STATUS +WinNtFlushInstructionCacheFlush ( + IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + This routine would provide support for flushing the CPU instruction cache. + +Arguments: + + This - Pointer to CPU Architectural Protocol interface + Start - Start adddress in memory to flush + Length - Length of memory to flush + +Returns: + + Status + EFI_SUCCESS + +--*/ +{ + RtPioICacheFlush ((UINT8 *) Start, (UINTN) Length); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s new file mode 100644 index 0000000000..4606437117 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s @@ -0,0 +1,325 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// setjmp.s +// +// Abstract: +// +// Contains an implementation of setjmp and longjmp for the +// Itanium-based architecture. +// +// +// +// Revision History: +// +//-- + + .file "setjmp.s" + +#include +#include + +// int SetJump(struct jmp_buffer save) +// +// Setup a non-local goto. +// +// Description: +// +// SetJump stores the current register set in the area pointed to +// by "save". It returns zero. Subsequent calls to "LongJump" will +// restore the registers and return non-zero to the same location. +// +// On entry, r32 contains the pointer to the jmp_buffer +// + +PROCEDURE_ENTRY(SetJump) + // + // Make sure buffer is aligned at 16byte boundary + // + mov r32 = r33 + + add r10 = -0x10,r0 ;; // mask the lower 4 bits + and r32 = r32, r10;; + add r32 = 0x10, r32;; // move to next 16 byte boundary + + add r10 = J_PREDS, r32 // skip Unats & pfs save area + add r11 = J_BSP, r32 + // + // save immediate context + // + mov r2 = ar.bsp // save backing store pointer + mov r3 = pr // save predicates + ;; + // + // save user Unat register + // + mov r16 = ar.lc // save loop count register + mov r14 = ar.unat // save user Unat register + + st8 [r10] = r3, J_LC-J_PREDS + st8 [r11] = r2, J_R4-J_BSP + ;; + st8 [r10] = r16, J_R5-J_LC + st8 [r32] = r14, J_NATS // Note: Unat at the + // beginning of the save area + mov r15 = ar.pfs + ;; + // + // save preserved general registers & NaT's + // + st8.spill [r11] = r4, J_R6-J_R4 + ;; + st8.spill [r10] = r5, J_R7-J_R5 + ;; + st8.spill [r11] = r6, J_SP-J_R6 + ;; + st8.spill [r10] = r7, J_F3-J_R7 + ;; + st8.spill [r11] = sp, J_F2-J_SP + ;; + // + // save spilled Unat and pfs registers + // + mov r2 = ar.unat // save Unat register after spill + ;; + st8 [r32] = r2, J_PFS-J_NATS // save unat for spilled regs + ;; + st8 [r32] = r15 // save pfs + // + // save floating registers + // + stf.spill [r11] = f2, J_F4-J_F2 + stf.spill [r10] = f3, J_F5-J_F3 + ;; + stf.spill [r11] = f4, J_F16-J_F4 + stf.spill [r10] = f5, J_F17-J_F5 + ;; + stf.spill [r11] = f16, J_F18-J_F16 + stf.spill [r10] = f17, J_F19-J_F17 + ;; + stf.spill [r11] = f18, J_F20-J_F18 + stf.spill [r10] = f19, J_F21-J_F19 + ;; + stf.spill [r11] = f20, J_F22-J_F20 + stf.spill [r10] = f21, J_F23-J_F21 + ;; + stf.spill [r11] = f22, J_F24-J_F22 + stf.spill [r10] = f23, J_F25-J_F23 + ;; + stf.spill [r11] = f24, J_F26-J_F24 + stf.spill [r10] = f25, J_F27-J_F25 + ;; + stf.spill [r11] = f26, J_F28-J_F26 + stf.spill [r10] = f27, J_F29-J_F27 + ;; + stf.spill [r11] = f28, J_F30-J_F28 + stf.spill [r10] = f29, J_F31-J_F29 + ;; + stf.spill [r11] = f30, J_FPSR-J_F30 + stf.spill [r10] = f31, J_B0-J_F31 // size of f31 + fpsr + // + // save FPSR register & branch registers + // + mov r2 = ar.fpsr // save fpsr register + mov r3 = b0 + ;; + st8 [r11] = r2, J_B1-J_FPSR + st8 [r10] = r3, J_B2-J_B0 + mov r2 = b1 + mov r3 = b2 + ;; + st8 [r11] = r2, J_B3-J_B1 + st8 [r10] = r3, J_B4-J_B2 + mov r2 = b3 + mov r3 = b4 + ;; + st8 [r11] = r2, J_B5-J_B3 + st8 [r10] = r3 + mov r2 = b5 + ;; + st8 [r11] = r2 + ;; + // + // return + // + mov r8 = r0 // return 0 from setjmp + mov ar.unat = r14 // restore unat + br.ret.sptk b0 + +PROCEDURE_EXIT(SetJump) + + +// +// void LongJump(struct jmp_buffer *) +// +// Perform a non-local goto. +// +// Description: +// +// LongJump initializes the register set to the values saved by a +// previous 'SetJump' and jumps to the return location saved by that +// 'SetJump'. This has the effect of unwinding the stack and returning +// for a second time to the 'SetJump'. +// + +PROCEDURE_ENTRY(LongJump) + // + // Make sure buffer is aligned at 16byte boundary + // + mov r32 = r33 + + add r10 = -0x10,r0 ;; // mask the lower 4 bits + and r32 = r32, r10;; + add r32 = 0x10, r32;; // move to next 16 byte boundary + + // + // caching the return value as we do invala in the end + // +/// mov r8 = r33 // return value + mov r8 = 1 // For now return hard coded 1 + + // + // get immediate context + // + mov r14 = ar.rsc // get user RSC conf + add r10 = J_PFS, r32 // get address of pfs + add r11 = J_NATS, r32 + ;; + ld8 r15 = [r10], J_BSP-J_PFS // get pfs + ld8 r2 = [r11], J_LC-J_NATS // get unat for spilled regs + ;; + mov ar.unat = r2 + ;; + ld8 r16 = [r10], J_PREDS-J_BSP // get backing store pointer + mov ar.rsc = r0 // put RSE in enforced lazy + mov ar.pfs = r15 + ;; + + // + // while returning from longjmp the BSPSTORE and BSP needs to be + // same and discard all the registers allocated after we did + // setjmp. Also, we need to generate the RNAT register since we + // did not flushed the RSE on setjmp. + // + mov r17 = ar.bspstore // get current BSPSTORE + ;; + cmp.ltu p6,p7 = r17, r16 // is it less than BSP of +(p6) br.spnt.few .flush_rse + mov r19 = ar.rnat // get current RNAT + ;; + loadrs // invalidate dirty regs + br.sptk.many .restore_rnat // restore RNAT + +.flush_rse: + flushrs + ;; + mov r19 = ar.rnat // get current RNAT + mov r17 = r16 // current BSPSTORE + ;; +.restore_rnat: + // + // check if RNAT is saved between saved BSP and curr BSPSTORE + // + dep r18 = 1,r16,3,6 // get RNAT address + ;; + cmp.ltu p8,p9 = r18, r17 // RNAT saved on RSE + ;; +(p8) ld8 r19 = [r18] // get RNAT from RSE + ;; + mov ar.bspstore = r16 // set new BSPSTORE + ;; + mov ar.rnat = r19 // restore RNAT + mov ar.rsc = r14 // restore RSC conf + + + ld8 r3 = [r11], J_R4-J_LC // get lc register + ld8 r2 = [r10], J_R5-J_PREDS // get predicates + ;; + mov pr = r2, -1 + mov ar.lc = r3 + // + // restore preserved general registers & NaT's + // + ld8.fill r4 = [r11], J_R6-J_R4 + ;; + ld8.fill r5 = [r10], J_R7-J_R5 + ld8.fill r6 = [r11], J_SP-J_R6 + ;; + ld8.fill r7 = [r10], J_F2-J_R7 + ld8.fill sp = [r11], J_F3-J_SP + ;; + // + // restore floating registers + // + ldf.fill f2 = [r10], J_F4-J_F2 + ldf.fill f3 = [r11], J_F5-J_F3 + ;; + ldf.fill f4 = [r10], J_F16-J_F4 + ldf.fill f5 = [r11], J_F17-J_F5 + ;; + ldf.fill f16 = [r10], J_F18-J_F16 + ldf.fill f17 = [r11], J_F19-J_F17 + ;; + ldf.fill f18 = [r10], J_F20-J_F18 + ldf.fill f19 = [r11], J_F21-J_F19 + ;; + ldf.fill f20 = [r10], J_F22-J_F20 + ldf.fill f21 = [r11], J_F23-J_F21 + ;; + ldf.fill f22 = [r10], J_F24-J_F22 + ldf.fill f23 = [r11], J_F25-J_F23 + ;; + ldf.fill f24 = [r10], J_F26-J_F24 + ldf.fill f25 = [r11], J_F27-J_F25 + ;; + ldf.fill f26 = [r10], J_F28-J_F26 + ldf.fill f27 = [r11], J_F29-J_F27 + ;; + ldf.fill f28 = [r10], J_F30-J_F28 + ldf.fill f29 = [r11], J_F31-J_F29 + ;; + ldf.fill f30 = [r10], J_FPSR-J_F30 + ldf.fill f31 = [r11], J_B0-J_F31 ;; + + // + // restore branch registers and fpsr + // + ld8 r16 = [r10], J_B1-J_FPSR // get fpsr + ld8 r17 = [r11], J_B2-J_B0 // get return pointer + ;; + mov ar.fpsr = r16 + mov b0 = r17 + ld8 r2 = [r10], J_B3-J_B1 + ld8 r3 = [r11], J_B4-J_B2 + ;; + mov b1 = r2 + mov b2 = r3 + ld8 r2 = [r10], J_B5-J_B3 + ld8 r3 = [r11] + ;; + mov b3 = r2 + mov b4 = r3 + ld8 r2 = [r10] + ld8 r21 = [r32] // get user unat + ;; + mov b5 = r2 + mov ar.unat = r21 + + // + // invalidate ALAT + // + invala ;; + + br.ret.sptk b0 +PROCEDURE_EXIT(LongJump) + + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c new file mode 100644 index 0000000000..c276aa8bda --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c @@ -0,0 +1,1387 @@ +/*++ + +Copyright (c) 2005 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeCoffLoader.c + +Abstract: + + Tiano PE/COFF loader + +Revision History + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include "PeiLib.h" +#include "PeCoffLoaderEx.h" + +#ifdef EFI_NT_EMULATOR +#include "peilib.h" +#include "EfiHobLib.h" +#include EFI_PPI_DEFINITION (NtLoadAsDll) +#endif + +STATIC +EFI_STATUS +PeCoffLoaderGetPeHeader ( + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ); + +STATIC +VOID* +PeCoffLoaderImageAddress ( + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + IN UINTN Address + ); + +EFI_STATUS +EFIAPI +PeCoffLoaderGetImageInfo ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +EFI_STATUS +EFIAPI +PeCoffLoaderRelocateImage ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +EFI_STATUS +EFIAPI +PeCoffLoaderLoadImage ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +EFI_STATUS +EFIAPI +PeCoffLoaderUnloadImage ( + IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE) +VOID +AsmEfiSetBreakSupport ( + IN UINTN LoadAddr + ); +#endif + +EFI_PEI_PE_COFF_LOADER_PROTOCOL mPeCoffLoader = { + PeCoffLoaderGetImageInfo, + PeCoffLoaderLoadImage, + PeCoffLoaderRelocateImage, + PeCoffLoaderUnloadImage +}; + +#ifdef EFI_NT_EMULATOR +EFI_NT_LOAD_AS_DLL_PPI *mPeCoffLoaderWinNtLoadAsDll = NULL; +#endif + +EFI_STATUS +InstallEfiPeiPeCoffLoader ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT EFI_PEI_PE_COFF_LOADER_PROTOCOL **This, + IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi + ) +/*++ + +Routine Description: + + Install PE/COFF loader PPI + +Arguments: + + PeiServices - General purpose services available to every PEIM + + This - Pointer to get Pei PE coff loader protocol as output + + ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform + +Returns: + + EFI_SUCCESS + +--*/ +{ + EFI_STATUS Status; + + Status = EFI_SUCCESS; + +#ifdef EFI_NT_EMULATOR + // + // For use by PEI Core and Modules + // + if (NULL != PeiServices) { + Status = (**PeiServices).LocatePpi ( + PeiServices, + &gEfiNtLoadAsDllPpiGuid, + 0, + NULL, + &mPeCoffLoaderWinNtLoadAsDll + ); + } else { + // + // Now in SecMain or ERM usage, bind appropriately + // + PEI_ASSERT (PeiServices, (NULL != ThisPpi)); + + mPeCoffLoaderWinNtLoadAsDll = (EFI_NT_LOAD_AS_DLL_PPI *) ThisPpi; + PEI_ASSERT (PeiServices, (NULL != mPeCoffLoaderWinNtLoadAsDll)); + } +#endif + + if (NULL != This) { + *This = &mPeCoffLoader; + } + + return Status; +} + +STATIC +EFI_STATUS +PeCoffLoaderGetPeHeader ( + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr + ) +/*++ + +Routine Description: + + Retrieves the PE or TE Header from a PE/COFF or TE image + +Arguments: + + ImageContext - The context of the image being loaded + + PeHdr - The buffer in which to return the PE32, PE32+, or TE header + +Returns: + + EFI_SUCCESS if the PE or TE Header is read, + Otherwise, the error status from reading the PE/COFF or TE image using the ImageRead function. + +--*/ +{ + EFI_STATUS Status; + EFI_IMAGE_DOS_HEADER DosHdr; + UINTN Size; + UINT16 Magic; + + // + // Read the DOS image header to check for it's existance + // + Size = sizeof (EFI_IMAGE_DOS_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &Size, + &DosHdr + ); + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return Status; + } + + ImageContext->PeCoffHeaderOffset = 0; + if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image + // header + // + ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew; + } + + // + // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much + // data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic + // determins if this is a PE32 or PE32+ image. The magic is in the same + // location in both images. + // + Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + ImageContext->PeCoffHeaderOffset, + &Size, + Hdr.Pe32 + ); + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return Status; + } + + // + // Use Signature to figure out if we understand the image format + // + if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { + ImageContext->IsTeImage = TRUE; + ImageContext->Machine = Hdr.Te->Machine; + ImageContext->ImageType = (UINT16)(Hdr.Te->Subsystem); + ImageContext->ImageSize = 0; + ImageContext->SectionAlignment = 4096; + ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize; + + } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + ImageContext->IsTeImage = FALSE; + ImageContext->Machine = Hdr.Pe32->FileHeader.Machine; + + // + // NOTE: We use Machine to identify PE32/PE32+, instead of Magic. + // It is for backward-compatibility consideration, because + // some system will generate PE32+ image with PE32 Magic. + // + if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else { + Magic = Hdr.Pe32->OptionalHeader.Magic; + } + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC || + Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + // + // PE32 and PE32+ have the same offset for these fields. + // We use PE32 for both PE32 and PE32+ headers here. + // + ImageContext->ImageType = Hdr.Pe32->OptionalHeader.Subsystem; + ImageContext->ImageSize = (UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage; + ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment; + ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; + + } else { + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE; + return EFI_UNSUPPORTED; + } + } else { + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE; + return EFI_UNSUPPORTED; + } + + if (!PeCoffLoaderImageFormatSupported (ImageContext->Machine)) { + // + // If the PE/COFF loader does not support the image type return + // unsupported. This library can suport lots of types of images + // this does not mean the user of this library can call the entry + // point of the image. + // + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +PeCoffLoaderCheckImageType ( + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +/*++ + +Routine Description: + + Checks the PE or TE header of a PE/COFF or TE image to determine if it supported + +Arguments: + + ImageContext - The context of the image being loaded + +Returns: + + EFI_SUCCESS if the PE/COFF or TE image is supported + EFI_UNSUPPORTED of the PE/COFF or TE image is not supported. + +--*/ +{ + switch (ImageContext->ImageType) { + + case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION: + ImageContext->ImageCodeMemoryType = EfiLoaderCode; + ImageContext->ImageDataMemoryType = EfiLoaderData; + break; + + case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER: + ImageContext->ImageCodeMemoryType = EfiBootServicesCode; + ImageContext->ImageDataMemoryType = EfiBootServicesData; + break; + + case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER: + case EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER: + ImageContext->ImageCodeMemoryType = EfiRuntimeServicesCode; + ImageContext->ImageDataMemoryType = EfiRuntimeServicesData; + break; + + default: + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM; + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +PeCoffLoaderGetImageInfo ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +/*++ + +Routine Description: + + Retrieves information on a PE/COFF image + +Arguments: + + This - Calling context + + ImageContext - The context of the image being loaded + +Returns: + + EFI_SUCCESS if the information on the PE/COFF image was collected. + EFI_UNSUPPORTED of the PE/COFF image is not supported. + Otherwise, the error status from reading the PE/COFF image using the + ImageContext->ImageRead() function + + EFI_INVALID_PARAMETER - ImageContext is NULL. + +--*/ +{ + EFI_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *DebugDirectoryEntry; + UINTN Size; + UINTN Index; + UINTN DebugDirectoryEntryRva; + UINTN DebugDirectoryEntryFileOffset; + UINTN SectionHeaderOffset; + EFI_IMAGE_SECTION_HEADER SectionHeader; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + if (NULL == ImageContext) { + return EFI_INVALID_PARAMETER; + } + + // + // Assume success + // + ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS; + + Hdr.Union = &HdrData; + Status = PeCoffLoaderGetPeHeader (ImageContext, Hdr); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Verify machine type + // + Status = PeCoffLoaderCheckImageType (ImageContext); + if (EFI_ERROR (Status)) { + return Status; + } + + Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; + + // + // Retrieve the base address of the image + // + if (!(ImageContext->IsTeImage)) { + + // + // NOTE: We use Machine to identify PE32/PE32+, instead of Magic. + // It is for backward-compatibility consideration, because + // some system will generate PE32+ image with PE32 Magic. + // + if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else { + Magic = Hdr.Pe32->OptionalHeader.Magic; + } + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + ImageContext->ImageAddress = Hdr.Pe32->OptionalHeader.ImageBase; + } else { + // + // Use PE32+ offset + // + ImageContext->ImageAddress = Hdr.Pe32Plus->OptionalHeader.ImageBase; + } + } else { + ImageContext->ImageAddress = (EFI_PHYSICAL_ADDRESS)(Hdr.Te->ImageBase); + } + + // + // Initialize the alternate destination address to 0 indicating that it + // should not be used. + // + ImageContext->DestinationAddress = 0; + + // + // Initialize the codeview pointer. + // + ImageContext->CodeView = NULL; + ImageContext->PdbPointer = NULL; + + // + // Three cases with regards to relocations: + // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable + // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable + // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but + // has no base relocs to apply + // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid. + // + // Look at the file header to determine if relocations have been stripped, and + // save this info in the image context for later use. + // + if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) { + ImageContext->RelocationsStripped = TRUE; + } else { + ImageContext->RelocationsStripped = FALSE; + } + + if (!(ImageContext->IsTeImage)) { + // + // Use PE32 to access fields that have same offset in PE32 and PE32+ + // + ImageContext->ImageSize = (UINT64) Hdr.Pe32->OptionalHeader.SizeOfImage; + ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment; + ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + } + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { + + DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; + + // + // Determine the file offset of the debug directory... This means we walk + // the sections to find which section contains the RVA of the debug + // directory + // + DebugDirectoryEntryFileOffset = 0; + + SectionHeaderOffset = (UINTN)( + ImageContext->PeCoffHeaderOffset + + sizeof (UINT32) + + sizeof (EFI_IMAGE_FILE_HEADER) + + Hdr.Pe32->FileHeader.SizeOfOptionalHeader + ); + + for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) { + // + // Read section header from file + // + Size = sizeof (EFI_IMAGE_SECTION_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + SectionHeaderOffset, + &Size, + &SectionHeader + ); + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && + DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { + + DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData; + break; + } + + SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); + } + + if (DebugDirectoryEntryFileOffset != 0) { + for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) { + // + // Read next debug directory entry + // + Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugDirectoryEntryFileOffset, + &Size, + &DebugEntry + ); + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)); + if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) { + ImageContext->ImageSize += DebugEntry.SizeOfData; + } + + return EFI_SUCCESS; + } + } + } + } + } else { + // + // Because Te image only extracts base relocations and debug directory entries from + // Pe image and in Te image header there is not a field to describe the imagesize, + // we use the largest VirtualAddress plus Size in each directory entry to describe the imagesize + // + ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size); + ImageContext->SectionAlignment = 4096; + ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) Hdr.Te->BaseOfCode - (UINTN) Hdr.Te->StrippedSize; + + DebugDirectoryEntry = &Hdr.Te->DataDirectory[1]; + DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress; + SectionHeaderOffset = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER)); + + DebugDirectoryEntryFileOffset = 0; + + for (Index = 0; Index < Hdr.Te->NumberOfSections; Index++) { + // + // Read section header from file + // + Size = sizeof (EFI_IMAGE_SECTION_HEADER); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + SectionHeaderOffset, + &Size, + &SectionHeader + ); + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress && + DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) { + DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - + SectionHeader.VirtualAddress + + SectionHeader.PointerToRawData + + sizeof (EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize; + break; + } + + SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); + } + + if (DebugDirectoryEntryFileOffset != 0) { + for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) { + // + // Read next debug directory entry + // + Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY); + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugDirectoryEntryFileOffset, + &Size, + &DebugEntry + ); + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return Status; + } + + if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)); + return EFI_SUCCESS; + } + } + } + } + + return EFI_SUCCESS; +} + +STATIC +VOID * +PeCoffLoaderImageAddress ( + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, + IN UINTN Address + ) +/*++ + +Routine Description: + + Converts an image address to the loaded address + +Arguments: + + ImageContext - The context of the image being loaded + + Address - The address to be converted to the loaded address + +Returns: + + NULL if the address can not be converted, otherwise, the converted address + +--*/ +{ + if (Address >= ImageContext->ImageSize) { + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return NULL; + } + + return (CHAR8 *) ((UINTN) ImageContext->ImageAddress + Address); +} + +EFI_STATUS +EFIAPI +PeCoffLoaderRelocateImage ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +/*++ + +Routine Description: + + Relocates a PE/COFF image in memory + +Arguments: + + This - Calling context + + ImageContext - Contains information on the loaded image to relocate + +Returns: + + EFI_SUCCESS if the PE/COFF image was relocated + EFI_LOAD_ERROR if the image is not a valid PE/COFF image + EFI_UNSUPPORTED not support + +--*/ +{ + EFI_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_IMAGE_DATA_DIRECTORY *RelocDir; + UINT64 Adjust; + EFI_IMAGE_BASE_RELOCATION *RelocBase; + EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd; + UINT16 *Reloc; + UINT16 *RelocEnd; + CHAR8 *Fixup; + CHAR8 *FixupBase; + UINT16 *F16; + UINT32 *F32; + UINT64 *F64; + CHAR8 *FixupData; + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; +#ifdef EFI_NT_EMULATOR + VOID *DllEntryPoint; + VOID *ModHandle; + + ModHandle = NULL; +#endif + + if (NULL == ImageContext) { + return EFI_INVALID_PARAMETER; + } + + // + // Assume success + // + ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS; + + // + // If there are no relocation entries, then we are done + // + if (ImageContext->RelocationsStripped) { + return EFI_SUCCESS; + } + + // + // If the destination address is not 0, use that rather than the + // image address as the relocation target. + // + if (ImageContext->DestinationAddress != 0) { + BaseAddress = ImageContext->DestinationAddress; + } else { + BaseAddress = ImageContext->ImageAddress; + } + + if (!(ImageContext->IsTeImage)) { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); + + // + // NOTE: We use Machine to identify PE32/PE32+, instead of Magic. + // It is for backward-compatibility consideration, because + // some system will generate PE32+ image with PE32 Magic. + // + if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else { + Magic = Hdr.Pe32->OptionalHeader.Magic; + } + + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase; + Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress; + + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } else { + // + // Use PE32+ offset + // + Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase; + Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress; + + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + RelocDir = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } + + // + // Find the relocation block + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { + RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress); + RelocBaseEnd = PeCoffLoaderImageAddress ( + ImageContext, + RelocDir->VirtualAddress + RelocDir->Size - 1 + ); + } else { + // + // Set base and end to bypass processing below. + // + RelocBase = RelocBaseEnd = 0; + } + } else { + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase); + Hdr.Te->ImageBase = (UINT64) (BaseAddress); + + // + // Find the relocation block + // + RelocDir = &Hdr.Te->DataDirectory[0]; + RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)( + ImageContext->ImageAddress + + RelocDir->VirtualAddress + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1); + } + + // + // Run the relocation information and apply the fixups + // + FixupData = ImageContext->FixupData; + while (RelocBase < RelocBaseEnd) { + + Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION)); + RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock); + if (!(ImageContext->IsTeImage)) { + FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress); + } else { + FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress + + RelocBase->VirtualAddress + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + } + + if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) || + (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + + (UINTN)ImageContext->ImageSize)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION; + return EFI_LOAD_ERROR; + } + + // + // Run this relocation record + // + while (Reloc < RelocEnd) { + + Fixup = FixupBase + (*Reloc & 0xFFF); + switch ((*Reloc) >> 12) { + case EFI_IMAGE_REL_BASED_ABSOLUTE: + break; + + case EFI_IMAGE_REL_BASED_HIGH: + F16 = (UINT16 *) Fixup; + *F16 = (UINT16) (*F16 + (UINT16)(((UINT32)Adjust) >> 16)); + if (FixupData != NULL) { + *(UINT16 *) FixupData = *F16; + FixupData = FixupData + sizeof (UINT16); + } + break; + + case EFI_IMAGE_REL_BASED_LOW: + F16 = (UINT16 *) Fixup; + *F16 = (UINT16) (*F16 + (UINT16) Adjust); + if (FixupData != NULL) { + *(UINT16 *) FixupData = *F16; + FixupData = FixupData + sizeof (UINT16); + } + break; + + case EFI_IMAGE_REL_BASED_HIGHLOW: + F32 = (UINT32 *) Fixup; + *F32 = *F32 + (UINT32) Adjust; + if (FixupData != NULL) { + FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); + *(UINT32 *) FixupData = *F32; + FixupData = FixupData + sizeof (UINT32); + } + break; + + case EFI_IMAGE_REL_BASED_DIR64: + // + // For X64 and IPF + // + F64 = (UINT64 *) Fixup; + *F64 = *F64 + (UINT64) Adjust; + if (FixupData != NULL) { + FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64)); + *(UINT64 *)(FixupData) = *F64; + FixupData = FixupData + sizeof(UINT64); + } + break; + + case EFI_IMAGE_REL_BASED_HIGHADJ: + // + // Return the same EFI_UNSUPPORTED return code as + // PeCoffLoaderRelocateImageEx() returns if it does not recognize + // the relocation type. + // + ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION; + return EFI_UNSUPPORTED; + + default: + // + // The common code does not handle some of the stranger IPF relocations + // PeCoffLoaderRelocateImageEx () addes support for these complex fixups + // on IPF and is a No-Op on other archtiectures. + // + Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust); + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION; + return Status; + } + } + + // + // Next relocation record + // + Reloc += 1; + } + + // + // Next reloc block + // + RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; + } + +#ifdef EFI_NT_EMULATOR + DllEntryPoint = NULL; + ImageContext->ModHandle = NULL; + // + // Load the DLL if it's not an EBC image. + // + if ((ImageContext->PdbPointer != NULL) && + (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) { + Status = mPeCoffLoaderWinNtLoadAsDll->Entry ( + ImageContext->PdbPointer, + &DllEntryPoint, + &ModHandle + ); + + if (!EFI_ERROR (Status) && DllEntryPoint != NULL) { + ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint; + ImageContext->ModHandle = ModHandle; + } + } +#endif + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +PeCoffLoaderLoadImage ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, + IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +/*++ + +Routine Description: + + Loads a PE/COFF image into memory + +Arguments: + + This - Calling context + + ImageContext - Contains information on image to load into memory + +Returns: + + EFI_SUCCESS if the PE/COFF image was loaded + EFI_BUFFER_TOO_SMALL if the caller did not provide a large enough buffer + EFI_LOAD_ERROR if the image is a runtime driver with no relocations + EFI_INVALID_PARAMETER if the image address is invalid + +--*/ +{ + EFI_STATUS Status; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT CheckContext; + EFI_IMAGE_SECTION_HEADER *FirstSection; + EFI_IMAGE_SECTION_HEADER *Section; + UINTN NumberOfSections; + UINTN Index; + CHAR8 *Base; + CHAR8 *End; + CHAR8 *MaxEnd; + EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry; + UINTN Size; + UINT32 TempDebugEntryRva; + UINT32 NumberOfRvaAndSizes; + UINT16 Magic; + + if (NULL == ImageContext) { + return EFI_INVALID_PARAMETER; + } + + // + // Assume success + // + ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS; + + // + // Copy the provided context info into our local version, get what we + // can from the original image, and then use that to make sure everything + // is legit. + // + CopyMem (&CheckContext, ImageContext, sizeof (EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT)); + + Status = PeCoffLoaderGetImageInfo (This, &CheckContext); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Make sure there is enough allocated space for the image being loaded + // + if (ImageContext->ImageSize < CheckContext.ImageSize) { + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE; + return EFI_BUFFER_TOO_SMALL; + } + if (ImageContext->ImageAddress == 0) { + // + // Image cannot be loaded into 0 address. + // + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return EFI_INVALID_PARAMETER; + } + // + // If there's no relocations, then make sure it's not a runtime driver, + // and that it's being loaded at the linked address. + // + if (CheckContext.RelocationsStripped) { + // + // If the image does not contain relocations and it is a runtime driver + // then return an error. + // + if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) { + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM; + return EFI_LOAD_ERROR; + } + // + // If the image does not contain relocations, and the requested load address + // is not the linked address, then return an error. + // + if (CheckContext.ImageAddress != ImageContext->ImageAddress) { + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS; + return EFI_INVALID_PARAMETER; + } + } + // + // Make sure the allocated space has the proper section alignment + // + if (!(ImageContext->IsTeImage)) { + if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) { + ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT; + return EFI_INVALID_PARAMETER; + } + } + // + // Read the entire PE/COFF or TE header into memory + // + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &ImageContext->SizeOfHeaders, + (VOID *) (UINTN) ImageContext->ImageAddress + ); + + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); + + FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( + (UINTN)ImageContext->ImageAddress + + ImageContext->PeCoffHeaderOffset + + sizeof(UINT32) + + sizeof(EFI_IMAGE_FILE_HEADER) + + Hdr.Pe32->FileHeader.SizeOfOptionalHeader + ); + NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + 0, + &ImageContext->SizeOfHeaders, + (VOID *)(UINTN)ImageContext->ImageAddress + ); + + Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); + + FirstSection = (EFI_IMAGE_SECTION_HEADER *) ( + (UINTN)ImageContext->ImageAddress + + sizeof(EFI_TE_IMAGE_HEADER) + ); + NumberOfSections = (UINTN) (Hdr.Te->NumberOfSections); + + } + + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return EFI_LOAD_ERROR; + } + + // + // Load each section of the image + // + Section = FirstSection; + for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) { + + // + // Compute sections address + // + Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress); + End = PeCoffLoaderImageAddress ( + ImageContext, + Section->VirtualAddress + Section->Misc.VirtualSize - 1 + ); + if (ImageContext->IsTeImage) { + Base = (CHAR8 *)((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize); + End = (CHAR8 *)((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize); + } + + if (End > MaxEnd) { + MaxEnd = End; + } + // + // If the base start or end address resolved to 0, then fail. + // + if ((Base == NULL) || (End == NULL)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_SECTION_NOT_LOADED; + return EFI_LOAD_ERROR; + } + + // + // Read the section + // + Size = (UINTN) Section->Misc.VirtualSize; + if ((Size == 0) || (Size > Section->SizeOfRawData)) { + Size = (UINTN) Section->SizeOfRawData; + } + + if (Section->SizeOfRawData) { + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + Section->PointerToRawData, + &Size, + Base + ); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize, + &Size, + Base + ); + } + + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return Status; + } + } + + // + // If raw size is less then virt size, zero fill the remaining + // + + if (Size < Section->Misc.VirtualSize) { + ZeroMem (Base + Size, Section->Misc.VirtualSize - Size); + } + + // + // Next Section + // + Section += 1; + } + + Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; + + // + // Get image's entry point + // + if (!(ImageContext->IsTeImage)) { + + // + // NOTE: We use Machine to identify PE32/PE32+, instead of Magic. + // It is for backward-compatibility consideration, because + // some system will generate PE32+ image with PE32 Magic. + // + if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) { + Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; + } else { + Magic = Hdr.Pe32->OptionalHeader.Magic; + } + + // + // Sizes of AddressOfEntryPoint are different so we need to do this safely + // + ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress ( + ImageContext, + (UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint + ); + + } else { + ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) ( + (UINTN)ImageContext->ImageAddress + + (UINTN)Hdr.Te->AddressOfEntryPoint + + (UINTN)sizeof(EFI_TE_IMAGE_HEADER) - + (UINTN)Hdr.Te->StrippedSize + ); + } + + // + // Determine the size of the fixup data + // + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + if (!(ImageContext->IsTeImage)) { + if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // Use PE32 offset + // + NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } else { + // + // Use PE32+ offset + // + NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes; + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]; + } + + if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { + ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); + } else { + ImageContext->FixupDataSize = 0; + } + } else { + DirectoryEntry = &Hdr.Te->DataDirectory[0]; + ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN); + } + // + // Consumer must allocate a buffer for the relocation fixup log. + // Only used for runtime drivers. + // + ImageContext->FixupData = NULL; + + // + // Load the Codeview info if present + // + if (ImageContext->DebugDirectoryEntryRva != 0) { + if (!(ImageContext->IsTeImage)) { + DebugEntry = PeCoffLoaderImageAddress ( + ImageContext, + ImageContext->DebugDirectoryEntryRva + ); + } else { + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)( + ImageContext->ImageAddress + + ImageContext->DebugDirectoryEntryRva + + sizeof(EFI_TE_IMAGE_HEADER) - + Hdr.Te->StrippedSize + ); + } + + if (DebugEntry != NULL) { + TempDebugEntryRva = DebugEntry->RVA; + if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) { + Section--; + if ((UINTN)Section->SizeOfRawData < Section->Misc.VirtualSize) { + TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize; + } else { + TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData; + } + } + + if (TempDebugEntryRva != 0) { + if (!(ImageContext->IsTeImage)) { + ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva); + } else { + ImageContext->CodeView = (VOID *)( + (UINTN)ImageContext->ImageAddress + + (UINTN)TempDebugEntryRva + + (UINTN)sizeof (EFI_TE_IMAGE_HEADER) - + (UINTN) Hdr.Te->StrippedSize + ); + } + + if (ImageContext->CodeView == NULL) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return EFI_LOAD_ERROR; + } + + if (DebugEntry->RVA == 0) { + Size = DebugEntry->SizeOfData; + if (!(ImageContext->IsTeImage)) { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugEntry->FileOffset, + &Size, + ImageContext->CodeView + ); + } else { + Status = ImageContext->ImageRead ( + ImageContext->Handle, + DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize, + &Size, + ImageContext->CodeView + ); + // + // Should we apply fix up to this field according to the size difference between PE and TE? + // Because now we maintain TE header fields unfixed, this field will also remain as they are + // in original PE image. + // + } + + if (EFI_ERROR (Status)) { + ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ; + return EFI_LOAD_ERROR; + } + + DebugEntry->RVA = TempDebugEntryRva; + } + + switch (*(UINT32 *) ImageContext->CodeView) { + case CODEVIEW_SIGNATURE_NB10: + ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY); + break; + + case CODEVIEW_SIGNATURE_RSDS: + ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY); + break; + + default: + break; + } + } + } + } + +#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE) + AsmEfiSetBreakSupport ((UINTN)(ImageContext->ImageAddress)); +#endif + + return Status; +} + +EFI_STATUS +EFIAPI +PeCoffLoaderUnloadImage ( + IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) +/*++ + +Routine Description: + + Unload a PE/COFF image from memory + +Arguments: + + ImageContext - Contains information on image to load into memory + +Returns: + + EFI_SUCCESS + +--*/ +{ +#ifdef EFI_NT_EMULATOR + // + // Calling Win32 API free library + // + mPeCoffLoaderWinNtLoadAsDll->FreeLibrary (ImageContext->ModHandle); + +#endif + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c new file mode 100644 index 0000000000..c2d5bb3c34 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c @@ -0,0 +1,648 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiLib.c + +Abstract: + + PEI Library Functions + +--*/ + +#include "TianoCommon.h" +#include "PeiHob.h" +#include "Pei.h" +#include "PeiLib.h" + + +VOID +PeiCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ); + +VOID +ZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + Set Buffer to zero for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + +Returns: + + None + +--*/ +{ + INT8 *Ptr; + + Ptr = Buffer; + while (Size--) { + *(Ptr++) = 0; + } +} + +VOID +PeiCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + + Destination8 = Destination; + Source8 = Source; + if (((Source8 + Length) <= Destination8) || (Source8 >= Destination8)) { + while (Length--) { + *(Destination8++) = *(Source8++); + } + } else { + while (Length--) { + *(Destination8 + Length) = *(Source8 + Length); + } + } +} + +VOID +CopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + + Destination8 = Destination; + Source8 = Source; + if (((Source8 + Length) <= Destination8) || (Source8 >= Destination8)) { + while (Length--) { + *(Destination8++) = *(Source8++); + } + } else { + while (Length--) { + *(Destination8 + Length) = *(Source8 + Length); + } + } +} + + +BOOLEAN +CompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +/*++ + +Routine Description: + + Compares two GUIDs + +Arguments: + + Guid1 - guid to compare + Guid2 - guid to compare + +Returns: + = TRUE if Guid1 == Guid2 + = FALSE if Guid1 != Guid2 + +--*/ +{ + if ((((INT32 *) Guid1)[0] - ((INT32 *) Guid2)[0]) == 0) { + if ((((INT32 *) Guid1)[1] - ((INT32 *) Guid2)[1]) == 0) { + if ((((INT32 *) Guid1)[2] - ((INT32 *) Guid2)[2]) == 0) { + if ((((INT32 *) Guid1)[3] - ((INT32 *) Guid2)[3]) == 0) { + return TRUE; + } + } + } + } + + return FALSE; +} + + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + +VOID * +EFIAPI +ScanGuid ( + IN VOID *Buffer, + IN UINTN Length, + IN EFI_GUID *Guid + ) +/*++ + +Routine Description: + + Scans a target buffer for a GUID, and returns a pointer to the matching GUID + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from + the lowest address to the highest address at 128-bit increments for the 128-bit + GUID value that matches Guid. If a match is found, then a pointer to the matching + GUID in the target buffer is returned. If no match is found, then NULL is returned. + If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). + If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT(). + +Arguments: + + Buffer - Pointer to the target buffer to scan. + Length - Number of bytes in Buffer to scan. + Guid - Value to search for in the target buffer. + +Returns: + A pointer to the matching Guid in the target buffer or NULL otherwise. + +--*/ +{ + EFI_GUID *GuidPtr; + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + PEI_ASSERT(PeiServices, (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0)); + PEI_ASSERT(PeiServices, (Length <= (EFI_MAX_ADDRESS - (UINTN)Buffer + 1))); + PEI_ASSERT(PeiServices, ((Length & (sizeof (*GuidPtr) - 1)) == 0)); + + GuidPtr = (EFI_GUID*)Buffer; + Buffer = GuidPtr + Length / sizeof (*GuidPtr); + while (GuidPtr < (EFI_GUID*)Buffer) { + if (CompareGuid (GuidPtr, Guid)) { + return (VOID*)GuidPtr; + } + GuidPtr++; + } + return NULL; +} + + +VOID * +EFIAPI +InvalidateInstructionCacheRange ( + IN VOID *Address, + IN UINTN Length + ) +/*++ + +Routine Description: + + Invalidates a range of instruction cache lines in the cache coherency domain + of the calling CPU. + + Invalidates the instruction cache lines specified by Address and Length. If + Address is not aligned on a cache line boundary, then entire instruction + cache line containing Address is invalidated. If Address + Length is not + aligned on a cache line boundary, then the entire instruction cache line + containing Address + Length -1 is invalidated. This function may choose to + invalidate the entire instruction cache if that is more efficient than + invalidating the specified range. If Length is 0, the no instruction cache + lines are invalidated. Address is returned. + + If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT(). + +Arguments: + + Address - The base address of the instruction cache lines to + invalidate. If the CPU is in a physical addressing mode, then + Address is a physical address. If the CPU is in a virtual + addressing mode, then Address is a virtual address. + + Length - The number of bytes to invalidate from the instruction cache. + + Returns: + Address + +**/ +{ + PEI_ASSERT(GetPeiServicesTablePointer() , (Length <= EFI_MAX_ADDRESS - (UINTN)Address + 1)); + return Address; +} + + +EFI_STATUS +EFIAPI +PeiLibFfsFindNextVolume ( + IN UINTN Instance, + IN OUT EFI_PEI_FV_HANDLE *VolumeHandle + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindNextVolume. + +Arguments: + + Instance - The Fv Volume Instance. + VolumeHandle - Pointer to the current Fv Volume to search. + +Returns: + EFI_STATUS + +--*/ + +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle); +} + +EFI_STATUS +EFIAPI +PeiLibFfsFindNextFile ( + IN EFI_FV_FILETYPE SearchType, + IN EFI_PEI_FV_HANDLE FwVolHeader, + IN OUT EFI_PEI_FILE_HANDLE *FileHeader + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindNextFile. + +Arguments: + + SearchType - Filter to find only file of this type. + FwVolHeader - Pointer to the current FV to search. + FileHandle - Pointer to the file matching SearchType in FwVolHeader. + - NULL if file not found + +Returns: + EFI_STATUS + +--*/ +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, &FwVolHeader, &FileHeader); +} + + +EFI_STATUS +EFIAPI +PeiLibFfsFindFileByName ( + IN EFI_GUID *FileName, + IN EFI_PEI_FV_HANDLE VolumeHandle, + OUT EFI_PEI_FILE_HANDLE *FileHandle + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindFileByName. + +Arguments: + + FileName - File name to search. + VolumeHandle - The current FV to search. + FileHandle - Pointer to the file matching name in VolumeHandle. + - NULL if file not found + +Returns: + EFI_STATUS + +--*/ +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + return (*PeiServices)->FfsFindFileByName (FileName, VolumeHandle, FileHandle); +} + + + +EFI_STATUS +EFIAPI +PeiLibFfsFindSectionData ( + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsFindSectionData. + +Arguments: + + SearchType - Filter to find only sections of this type. + FileHandle - Pointer to the current file to search. + SectionData - Pointer to the Section matching SectionType in FfsFileHeader. + - NULL if section not found + +Returns: + EFI_STATUS +--*/ +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, &FfsFileHeader, SectionData); +} + +EFI_STATUS +EFIAPI +PeiLibFfsGetVolumeInfo ( + IN EFI_PEI_FV_HANDLE *VolumeHandle, + OUT EFI_FV_INFO *VolumeInfo + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function FfsGetVolumeInfo. + +Arguments: + + VolumeHandle - The handle to Fv Volume. + VolumeInfo - The pointer to volume information. + +Returns: + EFI_STATUS +--*/ +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + return (*PeiServices)->FfsGetVolumeInfo (VolumeHandle, VolumeInfo); +} + + + +VOID +EFIAPI +BuildFvHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Build FvHob. + +Arguments: + + BaseAddress - Fv base address. + Length - Fv Length. + +Returns: + NONE. +--*/ +{ + + EFI_STATUS Status; + EFI_HOB_FIRMWARE_VOLUME *Hob; + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + + // + // Check FV Signature + // + PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE); + + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_FV, + sizeof (EFI_HOB_FIRMWARE_VOLUME), + &Hob + ); + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; +} + +VOID +EFIAPI +BuildFvHob2 ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_GUID *FvNameGuid, + IN EFI_GUID *FileNameGuid + ) +/*++ + +Routine Description: + + Build FvHob2. + +Arguments: + + BaseAddress - Fv base address. + Length - Fv length. + FvNameGuid - Fv name. + FileNameGuid - File name which contians encapsulated Fv. + +Returns: + NONE. +--*/ +{ + + EFI_STATUS Status; + EFI_HOB_FIRMWARE_VOLUME2 *Hob; + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + + // + // Check FV Signature + // + PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE); + + Status = (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_FV2, + sizeof (EFI_HOB_FIRMWARE_VOLUME2), + &Hob + ); + Hob->BaseAddress = BaseAddress; + Hob->Length = Length; + CopyMem ((VOID*)&Hob->FvName, FvNameGuid, sizeof(EFI_GUID)); + CopyMem ((VOID*)&Hob->FileName, FileNameGuid, sizeof(EFI_GUID)); +} + +EFI_STATUS +EFIAPI +PeiServicesLocatePpi ( + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ) +/*++ + +Routine Description: + + The wrapper of Pei Core Service function LocatePpi. + +Arguments: + + Guid - Pointer to GUID of the PPI. + Instance - Instance Number to discover. + PpiDescriptor - Pointer to reference the found descriptor. If not NULL, + returns a pointer to the descriptor (includes flags, etc) + Ppi - Pointer to reference the found PPI + +Returns: + + Status - EFI_SUCCESS if the PPI is in the database + EFI_NOT_FOUND if the PPI is not in the database +--*/ +{ + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi); +} + + +VOID +EFIAPI +BuildGuidDataHob ( + IN EFI_GUID *Guid, + IN VOID *Data, + IN UINTN DataLength + ) +/*++ + +Routine Description: + + Build Guid data Hob. + +Arguments: + + Guid - guid to build data hob. + Data - data to build data hob. + DataLength - the length of data. + +Returns: + NONE +--*/ +{ + VOID *HobData; + EFI_HOB_GUID_TYPE *Hob; + EFI_PEI_SERVICES **PeiServices; + + PeiServices = GetPeiServicesTablePointer(); + (*PeiServices)->CreateHob ( + PeiServices, + EFI_HOB_TYPE_GUID_EXTENSION, + (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength), + &Hob + ); + CopyMem ((VOID*)&Hob->Name, (VOID*)Guid, sizeof(EFI_GUID)); + + HobData = Hob + 1; + + CopyMem (HobData, Data, DataLength); +} + + +VOID * +EFIAPI +AllocatePages ( + IN UINTN Pages + ) +/*++ + +Routine Description: + + Allocate Memory. + +Arguments: + + Pages - Pages to allocate. + +Returns: + = Address if successful to allocate memory. + = NULL if fail to allocate memory. + +--*/ +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + EFI_PEI_SERVICES **PeiServices; + + if (Pages == 0) { + return NULL; + } + + PeiServices = GetPeiServicesTablePointer(); + Status = (*PeiServices)->AllocatePages (PeiServices, EfiBootServicesData, Pages, &Memory); + if (EFI_ERROR (Status)) { + Memory = 0; + } + return (VOID *) (UINTN) Memory; + +} + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.inf b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.inf new file mode 100644 index 0000000000..b5168416a9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.inf @@ -0,0 +1,104 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# PeiLib.inf +# +# Abstract: +# +# Component description file for the PEI library. +# +#--*/ + +[defines] +BASE_NAME = PeiLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + PeiLib.c + PeCoffLoader.c + Decompress.c + Debug.c + Hob\Hob.c + perf.c + print\print.c + print\print.h + FindFv.c + +[sources.ia32] +# ia32\Math.c + ia32\PeCoffLoaderEx.c + ia32\PeCoffLoaderEx.h + ia32\PerformancePrimitives.c + ia32\Processor.c + ia32\ProcessorAsms.Asm + ia32\SupportItpDebug.asm + ia32\efijump.h + ia32\ReadIdt.asm + ia32\WriteIdt.asm + ia32\PeiServicePointer.c + +[sources.x64] + x64\PeCoffLoaderEx.c + x64\PeCoffLoaderEx.h + x64\PerformancePrimitives.c + x64\Processor.c + x64\ProcessorAsms.Asm + x64\SupportItpDebug.asm + x64\efijump.h + x64\PeiServicePointer.c + +[sources.ipf] +# ipf\Math.c + ipf\PeCoffLoaderEx.c + ipf\PeCoffLoaderEx.h + ipf\PerformancePrimitives.s + ipf\Processor.c + ipf\EfiJump.h + ipf\SetJmp.s + ipf\Asm.h + ipf\PioFlush.s + ipf\SwitchStack.s + ipf\Ia_64Gen.h + ipf\HwAccess.s + ipf\PeiServicePointer.c + + +[libraries.common] + EdkGuidLib + EfiCommonLib + +[libraries.ia32] + CpuIA32Lib + +[libraries.x64] + CpuIA32Lib + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include + +[includes.ia32.Nt32] + $(EDK_SOURCE)\Sample\Platform\Nt32 + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Perf.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Perf.c new file mode 100644 index 0000000000..cfc265ee66 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Perf.c @@ -0,0 +1,233 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Perf.c + +Abstract: + + Support for performance primitives. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include "PeiLib.h" +#include "PeiHob.h" + +#include EFI_GUID_DEFINITION (PeiPerformanceHob) + +// +// Perfomance HOB data definitions +// + +#define MAX_PEI_PERF_LOG_ENTRIES 28 + +// +// Prototype functions +// +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ); + + +VOID +PeiPerfMeasure ( + EFI_PEI_SERVICES **PeiServices, + IN UINT16 *Token, + IN EFI_FFS_FILE_HEADER *FileHeader, + IN BOOLEAN EntryExit, + IN UINT64 Value + ) +/*++ + +Routine Description: + + Log a timestamp count. + +Arguments: + + PeiServices - Pointer to the PEI Core Services table + + Token - Pointer to Token Name + + FileHeader - Pointer to the file header + + EntryExit - Indicates start or stop measurement + + Value - The start time or the stop time + +Returns: + +--*/ +{ + EFI_STATUS Status; + EFI_HOB_GUID_TYPE *Hob; + EFI_HOB_GUID_DATA_PERFORMANCE_LOG *PerfHobData; + PEI_PERFORMANCE_MEASURE_LOG_ENTRY *Log; + EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor; + UINT64 TimeCount; + INTN Index; + UINTN Index2; + EFI_GUID *Guid; + EFI_GUID *CheckGuid; + + TimeCount = 0; + // + // Get the END time as early as possible to make it more accurate. + // + if (EntryExit) { + GetTimerValue (&TimeCount); + } + + // + // Locate the Pei Performance Log Hob. + // + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gEfiPeiPerformanceHobGuid, + 0, + &PerfHobDescriptor, + NULL + ); + + // + // If the Performance Hob was not found, build and install one. + // + if (EFI_ERROR(Status)) { + Status = PeiBuildHobGuid ( + PeiServices, + &gEfiPeiPerformanceHobGuid, + (sizeof(EFI_HOB_GUID_DATA_PERFORMANCE_LOG) + + ((MAX_PEI_PERF_LOG_ENTRIES-1) * + sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY)) + + sizeof(EFI_PEI_PPI_DESCRIPTOR) + ), + &Hob + ); + ASSERT_PEI_ERROR(PeiServices, Status); + + PerfHobData = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)(Hob+1); + PerfHobData->NumberOfEntries = 0; + + PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(PerfHobData+1) + + (sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY) * + (MAX_PEI_PERF_LOG_ENTRIES-1) + ) + ); + PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST); + PerfHobDescriptor->Guid = &gEfiPeiPerformanceHobGuid; + PerfHobDescriptor->Ppi = NULL; + + (*PeiServices)->InstallPpi ( + PeiServices, + PerfHobDescriptor + ); + } + + PerfHobData = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)(((UINT8 *)(PerfHobDescriptor)) - + ((sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY) * + (MAX_PEI_PERF_LOG_ENTRIES-1) + ) + + sizeof(EFI_HOB_GUID_DATA_PERFORMANCE_LOG) + ) + ); + + if (PerfHobData->NumberOfEntries >= MAX_PEI_PERF_LOG_ENTRIES) { + return; + } + + if (!EntryExit) { + Log = &(PerfHobData->Log[PerfHobData->NumberOfEntries]); + (*PeiServices)->SetMem (Log, sizeof(PEI_PERFORMANCE_MEASURE_LOG_ENTRY), 0); + + // + // If not NULL pointer, copy the file name + // + if (FileHeader != NULL) { + Log->Name = FileHeader->Name; + } + + // + // Copy the description string + // + (*PeiServices)->CopyMem ( + &(Log->DescriptionString), + Token, + (PEI_PERF_MAX_DESC_STRING-1) * sizeof(UINT16) + ); + + // + // Get the start time as late as possible to make it more accurate. + // + GetTimerValue (&TimeCount); + + // + // Record the time stamp. + // + if (Value != 0) { + Log->StartTimeCount = Value; + } else { + Log->StartTimeCount = TimeCount; + } + Log->StopTimeCount = 0; + + // + // Increment the number of valid log entries. + // + PerfHobData->NumberOfEntries++; + + } else { + + for (Index = PerfHobData->NumberOfEntries-1; Index >= 0; Index--) { + Log = NULL; + for (Index2 = 0; Index2 < PEI_PERF_MAX_DESC_STRING; Index2++) { + if (PerfHobData->Log[Index].DescriptionString[Index2] == 0) { + Log = &(PerfHobData->Log[Index]); + break; + } + if (PerfHobData->Log[Index].DescriptionString[Index2] != + Token[Index2]) { + break; + } + } + if (Log != NULL) { + if (FileHeader != NULL) { + Guid = &(Log->Name); + CheckGuid = &(FileHeader->Name); + if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) && + (((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) && + (((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) && + (((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3])) { + if (Value != 0) { + Log->StopTimeCount = Value; + } else { + Log->StopTimeCount = TimeCount; + } + break; + } + } else { + if (Value != 0) { + Log->StopTimeCount = Value; + } else { + Log->StopTimeCount = TimeCount; + } + break; + } + } + } + + } + + return; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c new file mode 100644 index 0000000000..458bb9ce4a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c @@ -0,0 +1,795 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.c + +Abstract: + + Basic Ascii AvSPrintf() function named AvSPrint(). AvSPrint() enables very + simple implemenation of debug prints. + + You can not Print more than PEI_LIB_MAX_PRINT_BUFFER characters at a + time. This makes the implementation very simple. + + AvSPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S', 's' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include "PeiLib.h" +#include "Print.h" + +STATIC +CHAR8 * +GetFlagsAndWidth ( + IN CHAR8 *Format, + OUT UINTN *Flags, + OUT UINTN *Width, + IN OUT VA_LIST *Marker + ); + +STATIC +UINTN +ValueToString ( + IN OUT CHAR8 *Buffer, + IN INT64 Value, + IN UINTN Flags, + IN UINTN Width + ); + +STATIC +UINTN +ValueTomHexStr ( + IN OUT CHAR8 *Buffer, + IN UINT64 Value, + IN UINTN Flags, + IN UINTN Width + ); + +STATIC +UINTN +GuidToString ( + IN EFI_GUID *Guid, + IN OUT CHAR8 *Buffer, + IN UINTN BufferSize + ); + +STATIC +UINTN +TimeToString ( + IN EFI_TIME *Time, + IN OUT CHAR8 *Buffer, + IN UINTN BufferSize + ); + +STATIC +UINTN +EfiStatusToString ( + IN EFI_STATUS Status, + OUT CHAR8 *Buffer, + IN UINTN BufferSize + ); + + +UINTN +ASPrint ( + OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + ASPrint function to process format and place the results in Buffer. + +Arguments: + + Buffer - Ascii buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means no + limit. + + Format - Ascii format string see file header for more details. + + ... - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Return; + VA_LIST Marker; + + VA_START(Marker, Format); + Return = AvSPrint(Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + + +UINTN +AvSPrint ( + OUT CHAR8 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR8 *FormatString, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + AvSPrint function to process format and place the results in Buffer. Since a + VA_LIST is used this rountine allows the nesting of Vararg routines. Thus + this is the main print working routine + +Arguments: + + StartOfBuffer - Ascii buffer to print the results of the parsing of Format into. + + BufferSize - Maximum number of characters to put into buffer. Zero means + no limit. + + FormatString - Ascii format string see file header for more details. + + Marker - Vararg list consumed by processing Format. + +Returns: + + Number of characters printed. + +--*/ +{ + CHAR8 TempBuffer[CHARACTER_NUMBER_FOR_VALUE]; + CHAR8 *Buffer; + CHAR8 *AsciiStr; + CHAR16 *UnicodeStr; + CHAR8 *Format; + UINTN Index; + UINTN Flags; + UINTN Width; + UINTN Count; + UINTN BufferLeft; + UINT64 Value; + EFI_GUID *TmpGUID; + + // + // Process the format string. Stop if Buffer is over run. + // + Buffer = StartOfBuffer; + Format = (CHAR8 *) FormatString; + BufferLeft = BufferSize; + for (Index = 0; (*Format != '\0') && (Index < BufferSize - 1); Format++) { + if (*Format != '%') { + if ((*Format == '\n') && (Index < BufferSize - 2)) { + // + // If carage return add line feed + // + Buffer[Index++] = '\r'; + BufferLeft -= sizeof (CHAR8); + } + + Buffer[Index++] = *Format; + BufferLeft -= sizeof (CHAR8); + } else { + + // + // Now it's time to parse what follows after % + // + Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker); + switch (*Format) { + case 'X': + Flags |= PREFIX_ZERO; + Width = sizeof (UINT64) * 2; + + // + // break skiped on purpose + // + case 'x': + if ((Flags & LONG_TYPE) == LONG_TYPE) { + Value = VA_ARG (Marker, UINT64); + } else { + Value = VA_ARG (Marker, UINTN); + } + + ValueTomHexStr (TempBuffer, Value, Flags, Width); + AsciiStr = TempBuffer; + + for (; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++) { + Buffer[Index++] = *AsciiStr; + } + break; + + case 'd': + if ((Flags & LONG_TYPE) == LONG_TYPE) { + Value = VA_ARG (Marker, UINT64); + } else { + Value = (UINTN) VA_ARG (Marker, UINTN); + } + + ValueToString (TempBuffer, Value, Flags, Width); + AsciiStr = TempBuffer; + + for (; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++) { + Buffer[Index++] = *AsciiStr; + } + break; + + case 's': + case 'S': + UnicodeStr = (CHAR16 *) VA_ARG (Marker, CHAR8 *); + if (UnicodeStr == NULL) { + UnicodeStr = L""; + } + + for (Count = 0; (*UnicodeStr != '\0') && (Index < BufferSize - 1); UnicodeStr++, Count++) { + Buffer[Index++] = (CHAR8) *UnicodeStr; + } + // + // Add padding if needed + // + for (; (Count < Width) && (Index < BufferSize - 1); Count++) { + Buffer[Index++] = ' '; + } + + break; + + case 'a': + AsciiStr = (CHAR8 *) VA_ARG (Marker, CHAR8 *); + if (AsciiStr == NULL) { + AsciiStr = ""; + } + + for (Count = 0; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++, Count++) { + Buffer[Index++] = *AsciiStr; + } + // + // Add padding if needed + // + for (; (Count < Width) && (Index < BufferSize - 1); Count++) { + Buffer[Index++] = ' '; + } + break; + + case 'c': + Buffer[Index++] = (CHAR8) VA_ARG (Marker, UINTN); + break; + + case 'g': + TmpGUID = VA_ARG (Marker, EFI_GUID *); + if (TmpGUID != NULL) { + Index += GuidToString ( + TmpGUID, + &Buffer[Index], + BufferLeft + ); + } + break; + + case 't': + Index += TimeToString ( + VA_ARG (Marker, EFI_TIME *), + &Buffer[Index], + BufferLeft + ); + break; + + case 'r': + Index += EfiStatusToString ( + VA_ARG (Marker, EFI_STATUS), + &Buffer[Index], + BufferLeft + ); + break; + + case '%': + Buffer[Index++] = *Format; + break; + + default: + // + // if the type is unknown print it to the screen + // + Buffer[Index++] = *Format; + } + + BufferLeft = BufferSize - Index; + } + } + + Buffer[Index++] = '\0'; + + return &Buffer[Index] - StartOfBuffer; +} + + + +STATIC +CHAR8 * +GetFlagsAndWidth ( + IN CHAR8 *Format, + OUT UINTN *Flags, + OUT UINTN *Width, + IN OUT VA_LIST *Marker + ) +/*++ + +Routine Description: + + AvSPrint worker function that parses flag and width information from the + Format string and returns the next index into the Format string that needs + to be parsed. See file headed for details of Flag and Width. + +Arguments: + + Format - Current location in the AvSPrint format string. + + Flags - Returns flags + + Width - Returns width of element + + Marker - Vararg list that may be paritally consumed and returned. + +Returns: + + Pointer indexed into the Format string for all the information parsed + by this routine. + +--*/ +{ + UINTN Count; + BOOLEAN Done; + + *Flags = 0; + *Width = 0; + for (Done = FALSE; !Done; ) { + Format++; + + switch (*Format) { + + case '-': *Flags |= LEFT_JUSTIFY; break; + case '+': *Flags |= PREFIX_SIGN; break; + case ' ': *Flags |= PREFIX_BLANK; break; + case ',': *Flags |= COMMA_TYPE; break; + case 'L': + case 'l': *Flags |= LONG_TYPE; break; + + case '*': + *Width = VA_ARG (*Marker, UINTN); + break; + + case '0': + *Flags |= PREFIX_ZERO; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + Count = 0; + do { + Count = (Count * 10) + *Format - '0'; + Format++; + } while ((*Format >= '0') && (*Format <= '9')); + Format--; + *Width = Count; + break; + + default: + Done = TRUE; + } + } + return Format; +} + +static CHAR8 mHexStr[] = { '0','1','2','3','4','5','6','7', + '8','9','A','B','C','D','E','F' }; + +STATIC +UINTN +ValueTomHexStr ( + IN OUT CHAR8 *Buffer, + IN UINT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + AvSPrint worker function that prints a Value as a hex number in Buffer + +Arguments: + + Buffer - Location to place ascii hex string of Value. + + Value - Hex value to convert to a string in Buffer. + + Flags - Flags to use in printing Hex string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +{ + CHAR8 TempBuffer[CHARACTER_NUMBER_FOR_VALUE]; + CHAR8 *TempStr; + CHAR8 Prefix; + CHAR8 *BufferPtr; + UINTN Count; + UINTN Index; + + TempStr = TempBuffer; + BufferPtr = Buffer; + + // + // Count starts at one since we will null terminate. Each iteration of the + // loop picks off one nibble. Oh yea TempStr ends up backwards + // + Count = 0; + do { + *(TempStr++) = mHexStr[Value & 0x0f]; + Value = RShiftU64 (Value, 4); + Count++; + } while (Value != 0); + + if (Flags & PREFIX_ZERO) { + Prefix = '0'; + } else if (!(Flags & LEFT_JUSTIFY)) { + Prefix = ' '; + } else { + Prefix = 0x00; + } + for (Index = Count; Index < Width; Index++) { + *(TempStr++) = Prefix; + } + + // + // Reverse temp string into Buffer. + // + if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) { + TempStr = TempBuffer + Width; + } + Index = 0; + while (TempStr != TempBuffer) { + *(BufferPtr++) = *(--TempStr); + Index++; + } + + *BufferPtr = 0; + return Index; +} + +STATIC +UINTN +ValueToString ( + IN OUT CHAR8 *Buffer, + IN INT64 Value, + IN UINTN Flags, + IN UINTN Width + ) +/*++ + +Routine Description: + + AvSPrint worker function that prints a Value as a decimal number in Buffer + +Arguments: + + Buffer - Location to place ascii decimal number string of Value. + + Value - Decimal value to convert to a string in Buffer. + + Flags - Flags to use in printing decimal string, see file header for details. + + Width - Width of hex value. + +Returns: + + Number of characters printed. + +--*/ +{ + CHAR8 TempBuffer[CHARACTER_NUMBER_FOR_VALUE]; + CHAR8 *TempStr; + CHAR8 *BufferPtr; + UINTN Count; + UINTN NumberCount; + UINTN Remainder; + BOOLEAN Negative; + UINTN Index; + + Negative = FALSE; + TempStr = TempBuffer; + BufferPtr = Buffer; + Count = 0; + NumberCount = 0; + + if (Value < 0) { + Negative = TRUE; + Value = -Value; + } + + do { + Value = (INT64)DivU64x32 ((UINT64)Value, 10, &Remainder); + *(TempStr++) = (CHAR8)(Remainder + '0'); + Count++; + NumberCount++; + if ((Flags & COMMA_TYPE) == COMMA_TYPE) { + if (NumberCount % 3 == 0 && Value != 0) { + *(TempStr++) = ','; + Count++; + } + } + } while (Value != 0); + + if (Negative) { + *(BufferPtr++) = '-'; + Count++; + } + + // + // Reverse temp string into Buffer. + // + if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) { + TempStr = TempBuffer + Width; + } + Index = 0; + while (TempStr != TempBuffer) { + *(BufferPtr++) = *(--TempStr); + } + + *BufferPtr = 0; + return Index; +} + +STATIC +UINTN +GuidToString ( + IN EFI_GUID *Guid, + IN CHAR8 *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + AvSPrint worker function that prints an EFI_GUID. + +Arguments: + + Guid - Pointer to GUID to print. + + Buffer - Buffe to print Guid into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + + Size = ASPrint ( + Buffer, + BufferSize, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + (UINTN)Guid->Data1, + (UINTN)Guid->Data2, + (UINTN)Guid->Data3, + (UINTN)Guid->Data4[0], + (UINTN)Guid->Data4[1], + (UINTN)Guid->Data4[2], + (UINTN)Guid->Data4[3], + (UINTN)Guid->Data4[4], + (UINTN)Guid->Data4[5], + (UINTN)Guid->Data4[6], + (UINTN)Guid->Data4[7] + ); + + // + // ASPrint will null terminate the string. The -1 skips the null + // + return Size - 1; +} + + +STATIC +UINTN +TimeToString ( + IN EFI_TIME *Time, + OUT CHAR8 *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + AvSPrint worker function that prints EFI_TIME. + +Arguments: + + Time - Pointer to EFI_TIME sturcture to print. + + Buffer - Buffer to print Time into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + + Size = ASPrint ( + Buffer, + BufferSize, + "%02d/%02d/%04d %02d:%02d", + (UINTN)Time->Month, + (UINTN)Time->Day, + (UINTN)Time->Year, + (UINTN)Time->Hour, + (UINTN)Time->Minute + ); + + // + // ASPrint will null terminate the string. The -1 skips the null + // + return Size - 1; +} + +STATIC +UINTN +EfiStatusToString ( + IN EFI_STATUS Status, + OUT CHAR8 *Buffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + AvSPrint worker function that prints EFI_STATUS as a string. If string is + not known a hex value will be printed. + +Arguments: + + Status - EFI_STATUS sturcture to print. + + Buffer - Buffer to print EFI_STATUS message string into. + + BufferSize - Size of Buffer. + +Returns: + + Number of characters printed. + +--*/ +{ + UINTN Size; + CHAR8 *Desc; + + if (Status == EFI_SUCCESS) { + Desc = "Success"; + } else if (Status == EFI_LOAD_ERROR) { + Desc = "Load Error"; + } else if (Status == EFI_INVALID_PARAMETER) { + Desc = "Invalid Parameter"; + } else if (Status == EFI_UNSUPPORTED) { + Desc = "Unsupported"; + } else if (Status == EFI_BAD_BUFFER_SIZE) { + Desc = "Bad Buffer Size"; + } else if (Status == EFI_BUFFER_TOO_SMALL) { + Desc = "Buffer Too Small"; + } else if (Status == EFI_NOT_READY) { + Desc = "Not Ready"; + } else if (Status == EFI_DEVICE_ERROR) { + Desc = "Device Error"; + } else if (Status == EFI_WRITE_PROTECTED) { + Desc = "Write Protected"; + } else if (Status == EFI_OUT_OF_RESOURCES) { + Desc = "Out of Resources"; + } else if (Status == EFI_VOLUME_CORRUPTED) { + Desc = "Volume Corrupt"; + } else if (Status == EFI_VOLUME_FULL) { + Desc = "Volume Full"; + } else if (Status == EFI_NO_MEDIA) { + Desc = "No Media"; + } else if (Status == EFI_MEDIA_CHANGED) { + Desc = "Media changed"; + } else if (Status == EFI_NOT_FOUND) { + Desc = "Not Found"; + } else if (Status == EFI_ACCESS_DENIED) { + Desc = "Access Denied"; + } else if (Status == EFI_NO_RESPONSE) { + Desc = "No Response"; + } else if (Status == EFI_NO_MAPPING) { + Desc = "No mapping"; + } else if (Status == EFI_TIMEOUT) { + Desc = "Time out"; + } else if (Status == EFI_NOT_STARTED) { + Desc = "Not started"; + } else if (Status == EFI_ALREADY_STARTED) { + Desc = "Already started"; + } else if (Status == EFI_ABORTED) { + Desc = "Aborted"; + } else if (Status == EFI_ICMP_ERROR) { + Desc = "ICMP Error"; + } else if (Status == EFI_TFTP_ERROR) { + Desc = "TFTP Error"; + } else if (Status == EFI_PROTOCOL_ERROR) { + Desc = "Protocol Error"; + } else if (Status == EFI_WARN_UNKNOWN_GLYPH) { + Desc = "Warning Unknown Glyph"; + } else if (Status == EFI_WARN_DELETE_FAILURE) { + Desc = "Warning Delete Failure"; + } else if (Status == EFI_WARN_WRITE_FAILURE) { + Desc = "Warning Write Failure"; + } else if (Status == EFI_WARN_BUFFER_TOO_SMALL) { + Desc = "Warning Buffer Too Small"; + } else { + Desc = NULL; + } + // + // If we found a match, copy the message to the user's buffer. Otherwise + // sprint the hex status code to their buffer. + // + if (Desc != NULL) { + Size = ASPrint (Buffer, BufferSize, "%a", Desc); + } else { + Size = ASPrint (Buffer, BufferSize, "%X", Status); + } + return Size - 1; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.h new file mode 100644 index 0000000000..66415230c6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.h @@ -0,0 +1,38 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.h + +Abstract: + + Private data for Print.c + +--*/ + +#ifndef _PRINT_H_ +#define _PRINT_H_ + +#define LEFT_JUSTIFY 0x01 +#define PREFIX_SIGN 0x02 +#define PREFIX_BLANK 0x04 +#define COMMA_TYPE 0x08 +#define LONG_TYPE 0x10 +#define PREFIX_ZERO 0x20 + +// +// Largest number of characters that can be printed out. +// +#define PEI_LIB_MAX_PRINT_BUFFER (80 * 4) + +#include "EfiCommonLib.h" +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c new file mode 100644 index 0000000000..97b7f4cb9c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c @@ -0,0 +1,93 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeCoffLoaderEx.c + +Abstract: + + IA-32 Specific relocation fixups + +Revision History + +--*/ + +#include "TianoCommon.h" +#include "EfiImage.h" + +EFI_STATUS +PeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +/*++ + +Routine Description: + + Performs an IA-32 specific relocation fixup + +Arguments: + + Reloc - Pointer to the relocation record + + Fixup - Pointer to the address to fix up + + FixupData - Pointer to a buffer to log the fixups + + Adjust - The offset to adjust the fixup + +Returns: + + EFI_UNSUPPORTED - relocate unsupported + +--*/ +{ + return EFI_UNSUPPORTED; +} + +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +/*++ +Routine Description: + + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + +Arguments: + + Machine - Machine type from the PE Header. + +Returns: + + TRUE - if this PE/COFF loader can load the image + FALSE - if this PE/COFF loader cannot load the image + +--*/ +{ + if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || + (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h new file mode 100644 index 0000000000..82173020de --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h @@ -0,0 +1,85 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeCoffLoaderEx.h + +Abstract: + + IA-32 Specific relocation fixups + +Revision History + +--*/ + +#ifndef _PE_COFF_LOADER_EX_H_ +#define _PE_COFF_LOADER_EX_H_ + +EFI_STATUS +PeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +/*++ + +Routine Description: + + Performs an IA-32 specific relocation fixup + +Arguments: + + Reloc - Pointer to the relocation record + + Fixup - Pointer to the address to fix up + + FixupData - Pointer to a buffer to log the fixups + + Adjust - The offset to adjust the fixup + +Returns: + + EFI_UNSUPPORTED - relocate unsupported + +--*/ +; + +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +/*++ +Routine Description: + + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + +Arguments: + + Machine - Machine type from the PE Header. + +Returns: + + TRUE - if this PE/COFF loader can load the image + FALSE - if this PE/COFF loader cannot load the image + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c new file mode 100644 index 0000000000..54241b2f5a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c @@ -0,0 +1,152 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiServicePointer.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "PeiApi.h" +#include "PeiLib.h" + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + +#ifdef EFI_NT_EMULATOR +EFI_PEI_SERVICES **gPeiServices; +#endif + + +VOID +SetPeiServicesTablePointer ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Save PeiService pointer so that it can be retrieved anywhere. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + PhyscialAddress - The physcial address of variable PeiServices. + +Returns: + NONE + +--*/ +{ + +#ifdef EFI_NT_EMULATOR + + // + // For NT32, set EFI_PEI_SERVICES** to global variable. + // + gPeiServices = PeiServices; +#else + + // + // For X86 processor,the EFI_PEI_SERVICES** is stored in the + // 4 bytes immediately preceding the Interrupt Descriptor Table. + // + UINTN IdtBaseAddress; + IdtBaseAddress = (UINTN)ReadIdtBase(); + *(UINTN*)(IdtBaseAddress - 4) = (UINTN)PeiServices; + +#endif +} + + +EFI_PEI_SERVICES ** +GetPeiServicesTablePointer ( + VOID + ) +/*++ + +Routine Description: + + Get PeiService pointer. + +Arguments: + + NONE. + +Returns: + The direct pointer to PeiServiceTable. + +--*/ +{ + EFI_PEI_SERVICES **PeiServices; + +#ifdef EFI_NT_EMULATOR + + // + // For NT32, set EFI_PEI_SERVICES** to global variable. + // + PeiServices = gPeiServices; +#else + + // + // For X86 processor,the EFI_PEI_SERVICES** is stored in the + // 4 bytes immediately preceding the Interrupt Descriptor Table. + // + UINTN IdtBaseAddress; + IdtBaseAddress = (UINTN)ReadIdtBase(); + PeiServices = (EFI_PEI_SERVICES **)(UINTN)(*(UINTN*)(IdtBaseAddress - 4)); +#endif + return PeiServices; +} + + +VOID +MigrateIdtTable ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Migrate IDT from CAR to real memory where preceded with 4 bytes for + storing PeiService pointer. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + +Returns: + + NONE. + +--*/ +{ +#ifndef EFI_NT_EMULATOR + UINT16 IdtEntrySize; + UINTN OldIdtBase; + UINTN Size; + VOID *NewIdtBase; + EFI_STATUS Status; + + IdtEntrySize = ReadIdtLimit(); + OldIdtBase = ReadIdtBase(); + Size = sizeof(PEI_IDT_TABLE) + (IdtEntrySize + 1); + Status = (*PeiServices)->AllocatePool (PeiServices, Size, &NewIdtBase); + ASSERT_PEI_ERROR (PeiServices, Status); + (*PeiServices)->CopyMem ((VOID*)((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), (VOID*)OldIdtBase, (IdtEntrySize + 1)); + SetIdtBase(((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), IdtEntrySize); + SetPeiServicesTablePointer(PeiServices); +#endif +} + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c new file mode 100644 index 0000000000..1050ae5cc2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c @@ -0,0 +1,47 @@ +/*++ + +Copyright 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PerformancePrimitives.c + +Abstract: + + Support for Performance library + +--*/ + +#include "TianoCommon.h" +#include "CpuIA32.h" + +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ) +/*++ + +Routine Description: + + Get timer value. + +Arguments: + + TimerValue - Pointer to the returned timer value + +Returns: + + EFI_SUCCESS - Successfully got timer value + +--*/ +{ + *TimerValue = EfiReadTsc (); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/Processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/Processor.c new file mode 100644 index 0000000000..4010db25a2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/Processor.c @@ -0,0 +1,140 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Processor.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "EfiJump.h" +#include EFI_GUID_DEFINITION (PeiFlushInstructionCache) +#include EFI_GUID_DEFINITION (PeiTransferControl) + +// +// Prototypes +// +EFI_STATUS +EFIAPI +TransferControlSetJump ( + IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, + IN EFI_JUMP_BUFFER *Jump + ); + +EFI_STATUS +EFIAPI +TransferControlLongJump ( + IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, + IN EFI_JUMP_BUFFER *Jump + ); + +EFI_STATUS +EFIAPI +FlushInstructionCacheFlush ( + IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ); + +// +// Table declarations +// +EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = { + TransferControlSetJump, + TransferControlLongJump, + sizeof (EFI_JUMP_BUFFER) +}; + +EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = { + FlushInstructionCacheFlush +}; + + +EFI_STATUS +InstallEfiPeiTransferControl ( + IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This + ) +/*++ + +Routine Description: + + Installs the pointer to the transfer control mechanism + +Arguments: + + This - Pointer to transfer control mechanism. + +Returns: + + EFI_SUCCESS - Successfully installed. + +--*/ +{ + *This = &mTransferControl; + return EFI_SUCCESS; +} + +EFI_STATUS +InstallEfiPeiFlushInstructionCache ( + IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This + ) +/*++ + +Routine Description: + + Installs the pointer to the flush instruction cache mechanism + +Arguments: + + This - Pointer to flush instruction cache mechanism. + +Returns: + + EFI_SUCCESS - Successfully installed + +--*/ +{ + *This = &mFlushInstructionCache; + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +FlushInstructionCacheFlush ( + IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + This routine would provide support for flushing the CPU instruction cache. + In the case of IA32, this flushing is not necessary and is thus not implemented. + +Arguments: + + This - Pointer to CPU Architectural Protocol interface + Start - Start adddress in memory to flush + Length - Length of memory to flush + +Returns: + + Status + EFI_SUCCESS + +--*/ +{ + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm new file mode 100644 index 0000000000..bf0d5cbed7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm @@ -0,0 +1,223 @@ +; +; Copyright (c) 2004, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ProcessorAsms.Asm +; +; Abstract: +; This is separated from processor.c to allow this functions to be built with /O1 +; +; Notes: +; - Masm uses "This", "ebx", etc as a directive. +; - H2INC is still not embedded in our build process so I translated the struc manually. +; - Unreferenced variables/arguments (This, NewBsp, NewStack) were causing compile errors and +; did not know of "pragma" mechanism in MASM and I did not want to reduce the warning level. +; Instead, I did a dummy referenced. +; + + .686P + .MMX + .MODEL SMALL + .CODE + +EFI_SUCCESS equ 0 +EFI_WARN_RETURN_FROM_LONG_JUMP equ 5 + +; +; Generated by h2inc run manually +; +_EFI_JUMP_BUFFER STRUCT 2t +_ebx DWORD ? +_esi DWORD ? +_edi DWORD ? +_ebp DWORD ? +_esp DWORD ? +_eip DWORD ? +_EFI_JUMP_BUFFER ENDS + +EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER + +TransferControlSetJump PROTO C \ + _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ + Jump:PTR EFI_JUMP_BUFFER + +TransferControlLongJump PROTO C \ + _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ + Jump:PTR EFI_JUMP_BUFFER + +SwitchStacks PROTO C \ + EntryPoint:PTR DWORD, \ + Parameter:DWORD, \ + NewStack:PTR DWORD, \ + NewBsp:PTR DWORD + +SwitchIplStacks PROTO C \ + EntryPoint:PTR DWORD, \ + Parameter1:DWORD, \ + Parameter2:DWORD, \ + NewStack:PTR DWORD, \ + NewBsp:PTR DWORD + +; +;Routine Description: +; +; This routine implements the IA32 variant of the SetJump call. Its +; responsibility is to store system state information for a possible +; subsequent LongJump. +; +;Arguments: +; +; Pointer to CPU context save buffer. +; +;Returns: +; +; EFI_SUCCESS +; +TransferControlSetJump PROC C \ + _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ + Jump:PTR EFI_JUMP_BUFFER + + mov eax, _This + mov ecx, Jump + mov (EFI_JUMP_BUFFER PTR [ecx])._ebx, ebx + mov (EFI_JUMP_BUFFER PTR [ecx])._esi, esi + mov (EFI_JUMP_BUFFER PTR [ecx])._edi, edi + mov eax, [ebp] + mov (EFI_JUMP_BUFFER PTR [ecx])._ebp, eax + lea eax, [ebp+4] + mov (EFI_JUMP_BUFFER PTR [ecx])._esp, eax + mov eax, [ebp+4] + mov (EFI_JUMP_BUFFER PTR [ecx])._eip, eax + mov eax, EFI_SUCCESS + + ret + +TransferControlSetJump ENDP + +; +; Routine Description: +; +; This routine implements the IA32 variant of the LongJump call. Its +; responsibility is restore the system state to the Context Buffer and +; pass control back. +; +; Arguments: +; +; Pointer to CPU context save buffer. +; +; Returns: +; +; EFI_WARN_RETURN_FROM_LONG_JUMP +; + +TransferControlLongJump PROC C \ + _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \ + Jump:PTR EFI_JUMP_BUFFER + + push ebx + push esi + push edi + + mov eax, _This + ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP + mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP + mov ecx, Jump + mov ebx, (EFI_JUMP_BUFFER PTR [ecx])._ebx + mov esi, (EFI_JUMP_BUFFER PTR [ecx])._esi + mov edi, (EFI_JUMP_BUFFER PTR [ecx])._edi + mov ebp, (EFI_JUMP_BUFFER PTR [ecx])._ebp + mov esp, (EFI_JUMP_BUFFER PTR [ecx])._esp + add esp, 4 ;pop the eip + jmp DWORD PTR (EFI_JUMP_BUFFER PTR [ecx])._eip + mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP + + pop edi + pop esi + pop ebx + ret + +TransferControlLongJump ENDP + +; +; Routine Description: +; This allows the caller to switch the stack and goes to the new entry point +; +; Arguments: +; EntryPoint - Pointer to the location to enter +; Parameter - Parameter to pass in +; NewStack - New Location of the stack +; NewBsp - New BSP +; +; Returns: +; +; Nothing. Goes to the Entry Point passing in the new parameters +; +SwitchStacks PROC C \ + EntryPoint:PTR DWORD, \ + Parameter:DWORD, \ + NewStack:PTR DWORD, \ + NewBsp:PTR DWORD + + push ebx + mov eax, NewBsp + mov ebx, Parameter + mov ecx, EntryPoint + mov eax, NewStack + mov esp, eax + push ebx + push 0 + jmp ecx + + pop ebx + ret + +SwitchStacks ENDP + +; +; Routine Description: +; This allows the caller to switch the stack and goes to the new entry point +; +; Arguments: +; EntryPoint - Pointer to the location to enter +; Parameter1/Parameter2 - Parameter to pass in +; NewStack - New Location of the stack +; NewBsp - New BSP +; +; Returns: +; +; Nothing. Goes to the Entry Point passing in the new parameters +; +SwitchIplStacks PROC C \ + EntryPoint:PTR DWORD, \ + Parameter1:DWORD, \ + Parameter2:DWORD, \ + NewStack:PTR DWORD, \ + NewBsp:PTR DWORD + + push ebx + mov eax, NewBsp + mov ebx, Parameter1 + mov edx, Parameter2 + mov ecx, EntryPoint + mov eax, NewStack + mov esp, eax + + push edx + push ebx + call ecx + + pop ebx + ret + +SwitchIplStacks ENDP + + END + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ReadIdt.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ReadIdt.asm new file mode 100644 index 0000000000..27d5254d51 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/ReadIdt.asm @@ -0,0 +1,60 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; ReadIdtBase.Asm +; +; Abstract: +; +; ReadIdtBase function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586 + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; UINTN +; ReadIdtBase ( +; void +; ) +; +; Abstract: Returns physical address of IDTR +; +ReadIdtBase PROC C PUBLIC + LOCAL IdtrBuf:FWORD + sidt IdtrBuf + mov eax, DWORD PTR IdtrBuf + 2 + ret +ReadIdtBase ENDP + +;------------------------------------------------------------------------------ +; UINT16 +; ReadIdtLimit ( +; void +; ) +; +; Abstract: Returns Limit of IDTR +; +ReadIdtLimit PROC C PUBLIC + LOCAL IdtrBuf:FWORD + sidt IdtrBuf + mov ax, WORD PTR IdtrBuf + ret +ReadIdtLimit ENDP + + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/SupportItpDebug.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/SupportItpDebug.asm new file mode 100644 index 0000000000..bc0f70a0fb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/SupportItpDebug.asm @@ -0,0 +1,69 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SupportItpDebug.asm +; +; Abstract: +; +; This is the code for debuging IA32, to add a break hook at loading every module +; +;------------------------------------------------------------------------------ + +; PROC:PRIVATE + .686P + .MMX + .MODEL SMALL + .CODE + +AsmEfiSetBreakSupport PROTO C LoadAddr:DWORD + +;------------------------------------------------------------------------------ +; VOID +; AsmEfiSetBreakSupport ( +; IN UINTN LoadAddr +; ) +;------------------------------------------------------------------------------ + +AsmEfiSetBreakSupport PROC C LoadAddr:DWORD + + mov eax, LoadAddr + mov dx, 60000 + out dx, eax + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + ret + +AsmEfiSetBreakSupport ENDP + END diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/WriteIdt.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/WriteIdt.asm new file mode 100644 index 0000000000..c4634996fc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/WriteIdt.asm @@ -0,0 +1,49 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; WriteIdt.Asm +; +; Abstract: +; +; SetIdtBase function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .586p + .model flat,C + .mmx + .code + +;------------------------------------------------------------------------------ +; void +; SetIdtBase ( +; UINT32 IdtBase, +; UINT16 IdtLimit +; ) +; +; Abstract: Set IDTR with the given physical address +; +SetIdtBase PROC C PUBLIC IdtBase:DWORD, IdtLimit:WORD + LOCAL IdtrBuf:FWORD + + mov eax, IdtBase + mov cx, IdtLimit + mov DWORD PTR IdtrBuf + 2, eax ; write IDT base address + mov WORD PTR IdtrBuf, cx ; write ITD limit + lidt FWORD PTR IdtrBuf + ret +SetIdtBase ENDP + + END \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/efijump.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/efijump.h new file mode 100644 index 0000000000..cdd7ca8c84 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/ia32/efijump.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiJump.h + +Abstract: + + This is the Setjump/Longjump pair for an IA32 processor. + +--*/ + +#ifndef _EFI_JUMP_H_ +#define _EFI_JUMP_H_ + +typedef struct { + UINT32 ebx; + UINT32 esi; + UINT32 edi; + UINT32 ebp; + UINT32 esp; + UINT32 eip; +} EFI_JUMP_BUFFER; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/EfiJump.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/EfiJump.h new file mode 100644 index 0000000000..5a37d87dba --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/EfiJump.h @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiJump.h + +Abstract: + + This is the Setjump/Longjump pair for an x64 processor. + +--*/ + +#ifndef _EFI_JUMP_H_ +#define _EFI_JUMP_H_ + +typedef struct { + UINT64 Rbx; + UINT64 Rsp; + UINT64 Rbp; + UINT64 Rdi; + UINT64 Rsi; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 Rip; +} EFI_JUMP_BUFFER; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/IdtDumb.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/IdtDumb.c new file mode 100644 index 0000000000..03802c152d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/IdtDumb.c @@ -0,0 +1,41 @@ +/*++ + +Copyright 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + IdtDumb.c + +Abstract: + +--*/ + +#include "Tiano.h" + +UINTN +ReadIdtBase ( + VOID + ) +{ + + return 0; +} + + +VOID +UpdateIdt ( + UINT32 IdtBase, + UINT16 IdtLimit + ) +{ + return; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Math.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Math.c new file mode 100644 index 0000000000..8c7cb68af2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Math.c @@ -0,0 +1,117 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Math.c + +Abstract: + + 64-bit Math worker functions for x64 + +--*/ + +#include "Efi.h" +#include "Pei.h" +#include "PeiLib.h" + + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be left shifted by 32 bits and returns the + shifted value. + Count is valid up 63. (Only Bits 0-5 is valid for Count) + +Arguments: + + Operand - Value to be shifted + + Count - Number of times to shift left. + +Returns: + + Value shifted left identified by the Count. + +--*/ +{ + return Operand << Count; +} + + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be multiplied with a 32 bit value returns + 64bit result. + No checking if the result is greater than 64bits + +Arguments: + + Multiplicand - + + Multiplier - + +Returns: + + Multiplicand * Multiplier + +--*/ +{ + return Multiplicand * Multiplier; +} +} + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +/*++ + +Routine Description: + + This routine allows a 64 bit value to be divided with a 32 bit value returns + 64bit result and the Remainder. + +Arguments: + + Dividend - + + Divisor - + + Remainder - + +Returns: + + Dividend / Divisor + Remainder = Dividend mod Divisor + +N.B. only works for 31bit divisors!! + +--*/ +{ + return Dividend/Divisor; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c new file mode 100644 index 0000000000..589bd0021a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c @@ -0,0 +1,87 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeCoffLoaderEx.c + +Abstract: + + x64 Specific relocation fixups + +Revision History + +--*/ + +#include "TianoCommon.h" +#include "EfiImage.h" + +EFI_STATUS +PeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +/*++ + +Routine Description: + Performs an x64 specific relocation fixup + +Arguments: + Reloc - Pointer to the relocation record + Fixup - Pointer to the address to fix up + FixupData - Pointer to a buffer to log the fixups + Adjust - The offset to adjust the fixup + +Returns: + EFI_UNSUPPORTED - relocate unsupported + +--*/ +{ + return EFI_UNSUPPORTED; +} + +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +/*++ +Routine Description: + + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + +Arguments: + + Machine - Machine type from the PE Header. + +Returns: + + TRUE - if this PE/COFF loader can load the image + FALSE - if this PE/COFF loader cannot load the image + +--*/ +{ + if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) || + (Machine == EFI_IMAGE_MACHINE_EBC)) { + return TRUE; + } + + return FALSE; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h new file mode 100644 index 0000000000..948fb01316 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h @@ -0,0 +1,85 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeCoffLoaderEx.h + +Abstract: + + x64 Specific relocation fixups + +Revision History + +--*/ + +#ifndef _PE_COFF_LOADER_EX_H_ +#define _PE_COFF_LOADER_EX_H_ + +EFI_STATUS +PeCoffLoaderRelocateImageEx ( + IN UINT16 *Reloc, + IN OUT CHAR8 *Fixup, + IN OUT CHAR8 **FixupData, + IN UINT64 Adjust + ) +/*++ + +Routine Description: + + Performs an x64 specific relocation fixup + +Arguments: + + Reloc - Pointer to the relocation record + + Fixup - Pointer to the address to fix up + + FixupData - Pointer to a buffer to log the fixups + + Adjust - The offset to adjust the fixup + +Returns: + + EFI_UNSUPPORTED - relocate unsupported + +--*/ +; + +BOOLEAN +PeCoffLoaderImageFormatSupported ( + IN UINT16 Machine + ) +/*++ +Routine Description: + + Returns TRUE if the machine type of PE/COFF image is supported. Supported + does not mean the image can be executed it means the PE/COFF loader supports + loading and relocating of the image type. It's up to the caller to support + the entry point. + + This function implies the basic PE/COFF loader/relocator supports IA32, EBC, + & X64 images. Calling the entry point in a correct mannor is up to the + consumer of this library. + +Arguments: + + Machine - Machine type from the PE Header. + +Returns: + + TRUE - if this PE/COFF loader can load the image + FALSE - if this PE/COFF loader cannot load the image + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c new file mode 100644 index 0000000000..cdbf334db7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c @@ -0,0 +1,98 @@ +/*++ + +Copyright 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PeiServicePointer.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "PeiApi.h" + + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + +VOID +SetPeiServicesTablePointer ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Save PeiService pointer so that it can be retrieved anywhere. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + PhyscialAddress - The physcial address of variable PeiServices. + +Returns: + NONE + +--*/ +{ + return; +} + +EFI_PEI_SERVICES ** +GetPeiServicesTablePointer ( + VOID + ) +/*++ + +Routine Description: + + Get PeiService pointer. + +Arguments: + + NONE. + +Returns: + The direct pointer to PeiServiceTable. + +--*/ +{ + return NULL; +} + + +VOID +MigrateIdtTable ( + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Migrate IDT from CAR to real memory where preceded with 4 bytes for + storing PeiService pointer. + +Arguments: + + PeiServices - The direct pointer to PeiServiceTable. + +Returns: + + NONE. + +--*/ +{ + return; +} + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c new file mode 100644 index 0000000000..f6ff7833df --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + PerformancePrimitives.c + +Abstract: + + Support for Performance library + +--*/ + +#include "TianoCommon.h" +#include "CpuIA32.h" + +EFI_STATUS +GetTimerValue ( + OUT UINT64 *TimerValue + ) +{ + *TimerValue = EfiReadTsc (); + return EFI_SUCCESS; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Processor.c new file mode 100644 index 0000000000..63cf8486c0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/Processor.c @@ -0,0 +1,149 @@ +/*++ + +Copyright 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Processor.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "EfiJump.h" +#include EFI_GUID_DEFINITION (PeiFlushInstructionCache) +#include EFI_GUID_DEFINITION (PeiTransferControl) + +// +// Prototypes +// +EFI_STATUS +EFIAPI +TransferControlSetJump ( + IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, + IN EFI_JUMP_BUFFER *Jump + ); + +EFI_STATUS +EFIAPI +TransferControlLongJump ( + IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, + IN EFI_JUMP_BUFFER *Jump + ); + +EFI_STATUS +EFIAPI +FlushInstructionCacheFlush ( + IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ); + +// +// Table declarations +// +EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = { + TransferControlSetJump, + TransferControlLongJump, + sizeof (EFI_JUMP_BUFFER) +}; + +EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = { + FlushInstructionCacheFlush +}; + + +EFI_STATUS +EFIAPI +InstallEfiPeiTransferControl( + IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This + ) +/*++ + +Routine Description: + + Installs the pointer to the transfer control mechanism + +Arguments: + + This - Pointer to transfer control mechanism. + +Returns: + + This - Pointer to transfer control mechanism. + +--*/ +{ + *This = &mTransferControl; + mTransferControl.SetJump = TransferControlSetJump; + mTransferControl.LongJump = TransferControlLongJump; + return EFI_SUCCESS; +} + + +EFI_STATUS +EFIAPI +InstallEfiPeiFlushInstructionCache ( + IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This + ) +/*++ + +Routine Description: + + Installs the pointer to the flush instruction cache mechanism + +Arguments: + + This - Pointer to flush instruction cache mechanism. + +Returns: + + This - Pointer to flush instruction cache mechanism. + +--*/ +{ + *This = &mFlushInstructionCache; + mFlushInstructionCache.Flush = FlushInstructionCacheFlush; + return EFI_SUCCESS; +} + + +EFI_STATUS +EFIAPI +FlushInstructionCacheFlush ( + IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + This routine would provide support for flushing the CPU instruction cache. + In the case of IA32, this flushing is not necessary and is thus not implemented. + +Arguments: + + Pointer to CPU Architectural Protocol interface + Start adddress in memory to flush + Length of memory to flush + +Returns: + + Status + EFI_SUCCESS + +--*/ +{ + return EFI_SUCCESS; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm new file mode 100644 index 0000000000..11a840e0fa --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm @@ -0,0 +1,158 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2005 - 2007, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; ProcessorAsms.Asm +; +; Abstract: +; This is separated from processor.c to allow this functions to be built with /O1 +; +; +;------------------------------------------------------------------------------ + +text SEGMENT + + +; +; Routine Description: +; This allows the caller to switch the stack and goes to the new entry point +; +; Arguments: +; EntryPoint - Pointer to the location to enter // rcx +; Parameter - Parameter to pass in // rdx +; NewStack - New Location of the stack // r8 +; NewBsp - New BSP // r9 - not used +; +; Returns: +; Nothing. Goes to the Entry Point passing in the new parameters +; +SwitchStacks PROC PUBLIC + + ; Adjust stack for + ; 1) leave 4 registers space + ; 2) let it 16 bytes aligned after call + sub r8, 20h + and r8w, 0fff0h ; do not assume 16 bytes aligned + + mov rsp, r8 ; rsp = NewStack + mov r10, rcx ; save EntryPoint + mov rcx, rdx ; Arg1 = Parameter + call r10 ; r10 = copy of EntryPoint + ; + ; no ret as we have a new stack and we jumped to the new location + ; + ret + +SwitchStacks ENDP + + +EFI_SUCCESS equ 0 +EFI_WARN_RETURN_FROM_LONG_JUMP equ 5 + +; +; Generated by h2inc run manually +; +_EFI_JUMP_BUFFER STRUCT 2t +_rbx QWORD ? +_rsp QWORD ? +_rbp QWORD ? +_rdi QWORD ? +_rsi QWORD ? +_r10 QWORD ? +_r11 QWORD ? +_r12 QWORD ? +_r13 QWORD ? +_r14 QWORD ? +_r15 QWORD ? +_rip QWORD ? +_EFI_JUMP_BUFFER ENDS + +EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER + + +; +;Routine Description: +; +; This routine implements the x64 variant of the SetJump call. Its +; responsibility is to store system state information for a possible +; subsequent LongJump. +; +;Arguments: +; +; Pointer to CPU context save buffer. +; +;Returns: +; +; EFI_SUCCESS +; +; EFI_STATUS +; EFIAPI +; TransferControlLongJump ( +; IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, +; IN EFI_JUMP_BUFFER *Jump +; ); +; +; rcx - *This +; rdx - JumpBuffer +; +PUBLIC TransferControlSetJump +TransferControlSetJump PROC + mov (EFI_JUMP_BUFFER PTR [rdx])._rbx, rbx + mov (EFI_JUMP_BUFFER PTR [rdx])._rsp, rsp + mov (EFI_JUMP_BUFFER PTR [rdx])._rbp, rbp + mov (EFI_JUMP_BUFFER PTR [rdx])._rdi, rdi + mov (EFI_JUMP_BUFFER PTR [rdx])._rsi, rsi + mov (EFI_JUMP_BUFFER PTR [rdx])._r10, r10 + mov (EFI_JUMP_BUFFER PTR [rdx])._r11, r11 + mov (EFI_JUMP_BUFFER PTR [rdx])._r12, r12 + mov (EFI_JUMP_BUFFER PTR [rdx])._r13, r13 + mov (EFI_JUMP_BUFFER PTR [rdx])._r14, r14 + mov (EFI_JUMP_BUFFER PTR [rdx])._r15, r15 + mov rax, QWORD PTR [rsp+0] + mov (EFI_JUMP_BUFFER PTR [rdx])._rip, rax + mov rax, EFI_SUCCESS + ret + +TransferControlSetJump ENDP + +; +; EFI_STATUS +; EFIAPI +; TransferControlLongJump ( +; IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, // rcx +; IN EFI_JUMP_BUFFER *Jump // rdx +; ); +; +; +PUBLIC TransferControlLongJump +TransferControlLongJump PROC + ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP + mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP + mov rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx + mov rsp, (EFI_JUMP_BUFFER PTR [rdx])._rsp + mov rbp, (EFI_JUMP_BUFFER PTR [rdx])._rbp + mov rdi, (EFI_JUMP_BUFFER PTR [rdx])._rdi + mov rsi, (EFI_JUMP_BUFFER PTR [rdx])._rsi + mov r10, (EFI_JUMP_BUFFER PTR [rdx])._r10 + mov r11, (EFI_JUMP_BUFFER PTR [rdx])._r11 + mov r12, (EFI_JUMP_BUFFER PTR [rdx])._r12 + mov r13, (EFI_JUMP_BUFFER PTR [rdx])._r13 + mov r14, (EFI_JUMP_BUFFER PTR [rdx])._r14 + mov r15, (EFI_JUMP_BUFFER PTR [rdx])._r15 + add rsp, 8 ;pop the eip + jmp QWORD PTR (EFI_JUMP_BUFFER PTR [rdx])._rip + ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP + mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP + ret +TransferControlLongJump ENDP + +text ENDS +END diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.asm new file mode 100644 index 0000000000..ff8af5a4c0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.asm @@ -0,0 +1,76 @@ +;------------------------------------------------------------------------------ +; +; Copyright (c) 2006, Intel Corporation +; All rights reserved. This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +; Module Name: +; +; SupportItpDebug.asm +; +; Abstract: +; +; This is the code for debuging X64, to add a break hook at loading every module +; +;------------------------------------------------------------------------------ + +; PROC:PRIVATE + .CODE + +;------------------------------------------------------------------------------ +; VOID +; AsmEfiSetBreakSupport ( +; IN UINTN LoadAddr // rcx +; ) +;------------------------------------------------------------------------------ + +AsmEfiSetBreakSupport PROC PUBLIC + + mov dx, 60000 + out dx, eax + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + ret + +AsmEfiSetBreakSupport ENDP + END + diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c new file mode 100644 index 0000000000..55e831ca19 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c @@ -0,0 +1,154 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Debug.c + +Abstract: + + Support for Debug primatives. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +#define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8) + +VOID +EfiDebugAssert ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ) +/*++ + +Routine Description: + + Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded BREAKPOINT (). + +Arguments: + + FileName - File name of failing routine. + + LineNumber - Line number of failing ASSERT (). + + Description - Description, usually the assertion, + +Returns: + + None + +--*/ +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE64]; + + EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer); + + EfiReportStatusCode ( + (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), + (EFI_SOFTWARE_DXE_RT_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), + 0, + &gEfiCallerIdGuid, + (EFI_STATUS_CODE_DATA *) Buffer + ); + + // + // Put break point in module that contained the error. + // + EFI_BREAKPOINT (); +} + +VOID +EfiDebugVPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker + ) +/*++ + +Routine Description: + + Worker function for DEBUG (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + Marker - VarArgs + +Returns: + + None + +--*/ +{ + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE64]; + + if (!(gRtErrorLevel & ErrorLevel)) { + return ; + } + + EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer); + + EfiReportStatusCode ( + EFI_DEBUG_CODE, + (EFI_SOFTWARE_DXE_RT_DRIVER | EFI_DC_UNSPECIFIED), + (UINT32) ErrorLevel, + &gEfiCallerIdGuid, + (EFI_STATUS_CODE_DATA *) Buffer + ); + + return ; +} + +VOID +EfiDebugPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ) +/*++ + +Routine Description: + + Worker function for DEBUG (). If Error Logging hub is loaded log ASSERT + information. If Error Logging hub is not loaded do nothing. + + We use UINT64 buffers due to IPF alignment concerns. + +Arguments: + + ErrorLevel - If error level is set do the debug print. + + Format - String to use for the print, followed by Print arguments. + + ... - VAR args for Format + +Returns: + + None + +--*/ +{ + VA_LIST Marker; + + VA_START (Marker, Format); + EfiDebugVPrint (ErrorLevel, Format, Marker); + VA_END (Marker); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c new file mode 100644 index 0000000000..0ec1a0869f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ebc/RuntimeLib.c @@ -0,0 +1,316 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RuntimeLib.c + +Abstract: + + Light weight lib to support Tiano drivers. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) + +// +// Driver Lib Module Globals +// +static EFI_RUNTIME_SERVICES *mRT; +static EFI_EVENT mRuntimeNotifyEvent = NULL; +static BOOLEAN mRuntimeLibInitialized = FALSE; +static BOOLEAN mEfiGoneVirtual = FALSE; + +// +// Runtime Global, but you should use the Lib functions +// +BOOLEAN mEfiAtRuntime = FALSE; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL; +#endif + +EFI_STATUS +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return mRT->ConvertPointer (DebugDisposition, Address); +} + +VOID +EFIAPI +RuntimeDriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Set AtRuntime flag as TRUE after ExitBootServices + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + mEfiAtRuntime = TRUE; +} + +EFI_STATUS +EfiInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY GoVirtualChildEvent + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + GoVirtualChildEvent - Caller can register a virtual notification event. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + + if (mRuntimeLibInitialized) { + return EFI_ALREADY_STARTED; + } + + mRuntimeLibInitialized = TRUE; + + gST = SystemTable; + ASSERT (gST != NULL); + + gBS = SystemTable->BootServices; + ASSERT (gBS != NULL); + mRT = SystemTable->RuntimeServices; + ASSERT (mRT != NULL); + + Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); + ASSERT_EFI_ERROR (Status); + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status)) { + gStatusCode = NULL; + } +#endif + + // + // Register our ExitBootServices () notify function + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + EFI_TPL_NOTIFY, + RuntimeDriverExitBootServices, + NULL, + &mRuntimeNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // To NOT register SetVirtualAddressMap () notify function, + // because we do not know how to trigger it without our EBC driver. + // + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiShutdownRuntimeDriverLib ( + VOID + ) +/*++ + +Routine Description: + + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully + EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all + +--*/ +{ + EFI_STATUS Status; + + if (!mRuntimeLibInitialized) { + // + // You must call EfiInitializeRuntimeDriverLib() first + // + return EFI_UNSUPPORTED; + } + + mRuntimeLibInitialized = FALSE; + + // + // Close our ExitBootServices () notify function + // + if (mRuntimeNotifyEvent != NULL) { + Status = gBS->CloseEvent (mRuntimeNotifyEvent); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} + +BOOLEAN +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if ExitBootServices () has been called + +Arguments: + NONE + +Returns: + TRUE - If ExitBootServices () has been called + +--*/ +{ + return mEfiAtRuntime; +} + +BOOLEAN +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + +--*/ +{ + return mEfiGoneVirtual; +} + +EFI_STATUS +EfiReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +{ + return EFI_UNSUPPORTED; +} +// +// Cache Flush Routine. +// +EFI_STATUS +EfiCpuFlushCache ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Flush cache with specified range. + +Arguments: + + Start - Start address + Length - Length in bytes + +Returns: + + Status code + + EFI_SUCCESS - success + +--*/ +{ + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf new file mode 100644 index 0000000000..aea21c42c7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf @@ -0,0 +1,79 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EfiRuntimeLib.inf +# +# Abstract: +# +# Component description file for the EFI runtime library. +# +#--*/ + +[defines] +BASE_NAME = EfiRuntimeLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + Debug.c + Event.c + Io.c + LibGlobals.c + GetImage.c + RtDevicePath.c + +[sources.ia32] + Ia32\RuntimeLib.c + Ia32\IoLib.c + Ia32\Lock.c + Ia32\PlatformIoLib.c + Ia32\Fvb.c + +[sources.x64] + x64\RuntimeLib.c + x64\IoLib.c + x64\Lock.c + x64\PlatformIoLib.c + x64\Fvb.c + +[sources.ipf] + Ipf\RuntimeLib.c + Ipf\Lock.c + Ipf\Fvb.c + Ipf\EsalLib.s + Ipf\IpfCpuCache.s + +[sources.ebc] + Ebc\RuntimeLib.c + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[libraries.common] + EdkGuidLib + EdkProtocolLib + EdkFrameworkProtocolLib + EfiGuidLib + EfiProtocolLib + ArchProtocolLib + EfiCommonLib + +[nmake.common] + diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c new file mode 100644 index 0000000000..830938bf3a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c @@ -0,0 +1,353 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Event.c + +Abstract: + + Support for Event lib fucntions. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" + +EFI_EVENT +RtEfiLibCreateProtocolNotifyEvent ( + IN EFI_GUID *ProtocolGuid, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT VOID **Registration + ) +/*++ + +Routine Description: + + Create a protocol notification event and return it. + +Arguments: + + ProtocolGuid - Protocol to register notification event on. + + NotifyTpl - Maximum TPL to single the NotifyFunction. + + NotifyFunction - EFI notification routine. + + NotifyContext - Context passed into Event when it is created. + + Registration - Registration key returned from RegisterProtocolNotify(). + +Returns: + + The EFI_EVENT that has been registered to be signaled when a ProtocolGuid + is added to the system. + +--*/ +{ + EFI_STATUS Status; + EFI_EVENT Event; + + // + // Create the event + // + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + NotifyTpl, + NotifyFunction, + NotifyContext, + &Event + ); + ASSERT (!EFI_ERROR (Status)); + + // + // Register for protocol notifactions on this event + // + Status = gBS->RegisterProtocolNotify ( + ProtocolGuid, + Event, + Registration + ); + + ASSERT (!EFI_ERROR (Status)); + + // + // Kick the event so we will perform an initial pass of + // current installed drivers + // + gBS->SignalEvent (Event); + return Event; +} + +EFI_STATUS +EfiLibGetSystemConfigurationTable ( + IN EFI_GUID *TableGuid, + IN OUT VOID **Table + ) +/*++ + +Routine Description: + + Return the EFI 1.0 System Tabl entry with TableGuid + +Arguments: + + TableGuid - Name of entry to return in the system table + Table - Pointer in EFI system table associated with TableGuid + +Returns: + + EFI_SUCCESS - Table returned; + EFI_NOT_FOUND - TableGuid not in EFI system table + +--*/ +{ + UINTN Index; + + for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { + if (EfiCompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) { + *Table = gST->ConfigurationTable[Index].VendorTable; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +EFI_STATUS +EfiConvertList ( + IN UINTN DebugDisposition, + IN OUT EFI_LIST_ENTRY *ListHead + ) +/*++ + +Routine Description: + + Conver the standard Lib double linked list to a virtual mapping. + +Arguments: + + DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API) + + ListHead - Head of linked list to convert + +Returns: + + EFI_SUCCESS + +--*/ +{ + EFI_LIST_ENTRY *Link; + EFI_LIST_ENTRY *NextLink; + + // + // Convert all the ForwardLink & BackLink pointers in the list + // + Link = ListHead; + do { + NextLink = Link->ForwardLink; + + EfiConvertPointer ( + Link->ForwardLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->ForwardLink + ); + + EfiConvertPointer ( + Link->BackLink == ListHead ? DebugDisposition : 0, + (VOID **) &Link->BackLink + ); + + Link = NextLink; + } while (Link != ListHead); + return EFI_SUCCESS; +} + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +STATIC +VOID +EFIAPI +EventNotifySignalAllNullEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // This null event is a size efficent way to enusre that + // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly. + // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into + // CreateEventEx() and this function is used to make the + // old error checking in CreateEvent() for Tiano extensions + // function. + // + return; +} + +#endif + +EFI_STATUS +EFIAPI +RtEfiCreateEventLegacyBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *LegacyBootEvent + ) +/*++ + +Routine Description: + Create a Legacy Boot Event. + Tiano extended the CreateEvent Type enum to add a legacy boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification by + declaring a GUID for the legacy boot event class. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Returns: + EFI_SUCCESS Event was created. + Other Event was not created. + +--*/ +{ + EFI_STATUS Status; + UINT32 EventType; + EFI_EVENT_NOTIFY WorkerNotifyFunction; + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + + if (NotifyFunction == NULL) { + EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL; + } else { + EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT; + } + WorkerNotifyFunction = NotifyFunction; + + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + LegacyBootEvent + ); +#else + + EventType = EFI_EVENT_NOTIFY_SIGNAL; + if (NotifyFunction == NULL) { + // + // CreatEventEx will check NotifyFunction is NULL or not + // + WorkerNotifyFunction = EventNotifySignalAllNullEvent; + } else { + WorkerNotifyFunction = NotifyFunction; + } + + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + &gEfiEventLegacyBootGuid, + LegacyBootEvent + ); +#endif + return Status; +} + +EFI_STATUS +EFIAPI +RtEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +{ + EFI_STATUS Status; + UINT32 EventType; + EFI_EVENT_NOTIFY WorkerNotifyFunction; + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + + if (NotifyFunction == NULL) { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL; + } else { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT; + } + WorkerNotifyFunction = NotifyFunction; + + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + ReadyToBootEvent + ); +#else + + EventType = EFI_EVENT_NOTIFY_SIGNAL; + if (NotifyFunction == NULL) { + // + // CreatEventEx will check NotifyFunction is NULL or not + // + WorkerNotifyFunction = EventNotifySignalAllNullEvent; + } else { + WorkerNotifyFunction = NotifyFunction; + } + + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + &gEfiEventReadyToBootGuid, + ReadyToBootEvent + ); +#endif + return Status; +} \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c new file mode 100644 index 0000000000..990acffac1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c @@ -0,0 +1,221 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GetImage.c + +Abstract: + + Image data extraction support for common use. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include "EfiImageFormat.h" + +#include EFI_PROTOCOL_CONSUMER (LoadedImage) + +EFI_STATUS +GetImageFromFv ( +#if (PI_SPECIFICATION_VERSION < 0x00010000) + IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv, +#else + IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, +#endif + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size + ) +{ + EFI_STATUS Status; + EFI_FV_FILETYPE FileType; + EFI_FV_FILE_ATTRIBUTES Attributes; + UINT32 AuthenticationStatus; + + // + // Read desired section content in NameGuid file + // + *Buffer = NULL; + *Size = 0; + Status = Fv->ReadSection ( + Fv, + NameGuid, + SectionType, + 0, + Buffer, + Size, + &AuthenticationStatus + ); + + if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) { + // + // Try reading PE32 section, since the TE section does not exist + // + *Buffer = NULL; + *Size = 0; + Status = Fv->ReadSection ( + Fv, + NameGuid, + EFI_SECTION_PE32, + 0, + Buffer, + Size, + &AuthenticationStatus + ); + } + + if (EFI_ERROR (Status) && + ((SectionType == EFI_SECTION_TE) || (SectionType == EFI_SECTION_PE32))) { + // + // Try reading raw file, since the desired section does not exist + // + *Buffer = NULL; + *Size = 0; + Status = Fv->ReadFile ( + Fv, + NameGuid, + Buffer, + Size, + &FileType, + &Attributes, + &AuthenticationStatus + ); + } + + return Status; +} + +EFI_STATUS +GetImage ( + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size + ) +{ + return GetImageEx (NULL, NameGuid, SectionType, Buffer, Size, FALSE); +} + +EFI_STATUS +GetImageEx ( + IN EFI_HANDLE ImageHandle, + IN EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + OUT VOID **Buffer, + OUT UINTN *Size, + BOOLEAN WithinImageFv + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_FIRMWARE_VOLUME_PROTOCOL *ImageFv; + EFI_FIRMWARE_VOLUME_PROTOCOL *Fv; +#else + EFI_FIRMWARE_VOLUME2_PROTOCOL *ImageFv; + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; +#endif + + if (ImageHandle == NULL && WithinImageFv) { + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_FOUND; + ImageFv = NULL; + if (ImageHandle != NULL) { + Status = gBS->HandleProtocol ( + ImageHandle, + &gEfiLoadedImageProtocolGuid, + &LoadedImage + ); + if (EFI_ERROR (Status)) { + return Status; + } + Status = gBS->HandleProtocol ( + LoadedImage->DeviceHandle, + #if (PI_SPECIFICATION_VERSION < 0x00010000) + &gEfiFirmwareVolumeProtocolGuid, + #else + &gEfiFirmwareVolume2ProtocolGuid, + #endif + &ImageFv + ); + if (!EFI_ERROR (Status)) { + Status = GetImageFromFv (ImageFv, NameGuid, SectionType, Buffer, Size); + } + } + + if (Status == EFI_SUCCESS || WithinImageFv) { + return Status; + } + + Status = gBS->LocateHandleBuffer ( + ByProtocol, + #if (PI_SPECIFICATION_VERSION < 0x00010000) + &gEfiFirmwareVolumeProtocolGuid, + #else + &gEfiFirmwareVolume2ProtocolGuid, + #endif + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Find desired image in all Fvs + // + for (Index = 0; Index < HandleCount; ++Index) { + Status = gBS->HandleProtocol ( + HandleBuffer[Index], + #if (PI_SPECIFICATION_VERSION < 0x00010000) + &gEfiFirmwareVolumeProtocolGuid, + #else + &gEfiFirmwareVolume2ProtocolGuid, + #endif + (VOID**)&Fv + ); + + if (EFI_ERROR (Status)) { + gBS->FreePool(HandleBuffer); + return Status; + } + + if (ImageFv != NULL && Fv == ImageFv) { + continue; + } + + Status = GetImageFromFv (Fv, NameGuid, SectionType, Buffer, Size); + + if (!EFI_ERROR (Status)) { + break; + } + } + gBS->FreePool(HandleBuffer); + + // + // Not found image + // + if (Index == HandleCount) { + return EFI_NOT_FOUND; + } + + return EFI_SUCCESS; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c new file mode 100644 index 0000000000..b7571b4c15 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c @@ -0,0 +1,339 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Io.c + +Abstract: + + Light weight lib functions that wrape IoRead (), IoWrite, MemRead (), + and MemWrite (). + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" + +UINT8 +IoRead8 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a one byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +{ + UINT8 Buffer; + + EfiIoRead (EfiCpuIoWidthUint8, Address, 1, &Buffer); + return Buffer; +} + +UINT16 +IoRead16 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a two byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +{ + UINT16 Buffer; + + EfiIoRead (EfiCpuIoWidthUint16, Address, 1, &Buffer); + return Buffer; +} + +UINT32 +IoRead32 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a four byte IO read + +Arguments: + Address - IO address to read + +Returns: + Data read + +--*/ +{ + UINT32 Buffer; + + EfiIoRead (EfiCpuIoWidthUint32, Address, 1, &Buffer); + return Buffer; +} + +VOID +IoWrite8 ( + IN UINT64 Address, + IN UINT8 Data + ) +/*++ + +Routine Description: + Do a one byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +{ + EfiIoWrite (EfiCpuIoWidthUint8, Address, 1, &Data); +} + +VOID +IoWrite16 ( + IN UINT64 Address, + IN UINT16 Data + ) +/*++ + +Routine Description: + Do a two byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +{ + EfiIoWrite (EfiCpuIoWidthUint16, Address, 1, &Data); +} + +VOID +IoWrite32 ( + IN UINT64 Address, + IN UINT32 Data + ) +/*++ + +Routine Description: + Do a four byte IO write + +Arguments: + Address - IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +{ + EfiIoWrite (EfiCpuIoWidthUint32, Address, 1, &Data); +} + +UINT8 +MemRead8 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a one byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +{ + UINT8 Buffer; + + EfiMemRead (EfiCpuIoWidthUint8, Address, 1, &Buffer); + return Buffer; +} + +UINT16 +MemRead16 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a two byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +{ + UINT16 Buffer; + + EfiMemRead (EfiCpuIoWidthUint16, Address, 1, &Buffer); + return Buffer; +} + +UINT32 +MemRead32 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a four byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +{ + UINT32 Buffer; + + EfiMemRead (EfiCpuIoWidthUint32, Address, 1, &Buffer); + return Buffer; +} + +UINT64 +MemRead64 ( + IN UINT64 Address + ) +/*++ + +Routine Description: + Do a eight byte Memory mapped IO read + +Arguments: + Address - Memory mapped IO address to read + +Returns: + Data read + +--*/ +{ + UINT64 Buffer; + + EfiMemRead (EfiCpuIoWidthUint64, Address, 1, &Buffer); + return Buffer; +} + +VOID +MemWrite8 ( + IN UINT64 Address, + IN UINT8 Data + ) +/*++ + +Routine Description: + Do a one byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +{ + EfiMemWrite (EfiCpuIoWidthUint8, Address, 1, &Data); +} + +VOID +MemWrite16 ( + IN UINT64 Address, + IN UINT16 Data + ) +/*++ + +Routine Description: + Do a two byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +{ + EfiMemWrite (EfiCpuIoWidthUint16, Address, 1, &Data); +} + +VOID +MemWrite32 ( + IN UINT64 Address, + IN UINT32 Data + ) +/*++ + +Routine Description: + Do a four byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +{ + EfiMemWrite (EfiCpuIoWidthUint32, Address, 1, &Data); +} + +VOID +MemWrite64 ( + IN UINT64 Address, + IN UINT64 Data + ) +/*++ + +Routine Description: + Do a eight byte Memory mapped IO write + +Arguments: + Address - Memory mapped IO address to write + Data - Data to write to Address + +Returns: + NONE + +--*/ +{ + EfiMemWrite (EfiCpuIoWidthUint64, Address, 1, &Data); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s new file mode 100644 index 0000000000..92f35ccb05 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s @@ -0,0 +1,149 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// EsalLib.s +// +// Abstract: +// +// +// Revision History: +// +//-- + +.file "EsalLib.s" + +#include "IpfMacro.i" + +// +// Exports +// +.global GetEsalEntryPoint + + +//----------------------------------------------------------------------------- +//++ +// GetEsalEntryPoint +// +// Return Esal global and PSR register. +// +// On Entry : +// +// +// Return Value: +// r8 = EFI_SAL_SUCCESS +// r9 = Physical Plabel +// r10 = Virtual Plabel +// r11 = psr +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (GetEsalEntryPoint) + + NESTED_SETUP (0,8,0,0) + +EsalCalcStart: + mov r8 = ip;; + add r8 = (EsalEntryPoint - EsalCalcStart), r8;; + mov r9 = r8;; + add r10 = 0x10, r8;; + mov r11 = psr;; + mov r8 = r0;; + + NESTED_RETURN + +PROCEDURE_EXIT (GetEsalEntryPoint) + + + + + +//----------------------------------------------------------------------------- +//++ +// SetEsalPhysicalEntryPoint +// +// Set the dispatcher entry point +// +// On Entry: +// in0 = Physical address of Esal Dispatcher +// in1 = Physical GP +// +// Return Value: +// r8 = EFI_SAL_SUCCESS +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (SetEsalPhysicalEntryPoint) + + NESTED_SETUP (2,8,0,0) + +EsalCalcStart1: + mov r8 = ip;; + add r8 = (EsalEntryPoint - EsalCalcStart1), r8;; + st8 [r8] = in0;; + add r8 = 0x08, r8;; + st8 [r8] = in1;; + mov r8 = r0;; + + NESTED_RETURN + +PROCEDURE_EXIT (SetEsalPhysicalEntryPoint) + + +//----------------------------------------------------------------------------- +//++ +// SetEsalVirtualEntryPoint +// +// Register physical address of Esal globals. +// +// On Entry : +// in0 = Virtual address of Esal Dispatcher +// in1 = Virtual GP +// +// Return Value: +// r8 = EFI_SAL_ERROR +// +// As per static calling conventions. +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (SetEsalVirtualEntryPoint) + + NESTED_SETUP (2,8,0,0) + +EsalCalcStart2: + mov r8 = ip;; + add r8 = (EsalEntryPoint - EsalCalcStart2), r8;; + add r8 = 0x10, r8;; + st8 [r8] = in0;; + add r8 = 0x08, r8;; + st8 [r8] = in1;; + mov r8 = r0;; + + NESTED_RETURN + +PROCEDURE_EXIT (SetEsalVirtualEntryPoint) + + + + +.align 32 +EsalEntryPoint: + data8 0 // Physical Entry + data8 0 // GP + data8 0 // Virtual Entry + data8 0 // GP + + diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c new file mode 100644 index 0000000000..266c6b1951 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c @@ -0,0 +1,334 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Fvb.c + +Abstract: + + Light weight lib to support Tiano Firmware Volume Block + protocol abstraction at runtime. + + All these functions convert EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID + class function to the Runtime Lib function. There is a 1 to 1 mapping. + + If you are using any of these lib functions.you must first call FvbInitialize (). + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include "SalApi.h" + +EFI_STATUS +EfiFvbInitialize ( + VOID + ) +/*++ + +Routine Description: + Initialize globals and register Fvb Protocol notification function. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +{ + return EFI_SUCCESS; +} +// +// The following functions wrap Fvb protocol in the Runtime Lib functions. +// The Instance translates into Fvb instance. The Fvb order defined by HOBs and +// thus the sequence of FVB protocol addition define Instance. +// +// EfiFvbInitialize () must be called before any of the following functions +// must be called. +// +EFI_STATUS +EfiFvbReadBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Reads specified number of bytes into a buffer from the specified block + +Arguments: + Instance - The FV instance to be read from + Lba - The logical block address to be read from + Offset - Offset into the block at which to begin reading + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes read + Buffer - Pointer to a caller allocated buffer that will be + used to hold the data read + +Returns: + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService (&Guid, Read, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status; +} + +EFI_STATUS +EfiFvbWriteBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Writes specified number of bytes from the input buffer to the block + +Arguments: + Instance - The FV instance to be written to + Lba - The starting logical block index to write to + Offset - Offset into the block at which to begin writing + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes actually written + Buffer - Pointer to a caller allocated buffer that contains + the source for the write + +Returns: + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService (&Guid, Write, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status; +} + +EFI_STATUS +EfiFvbEraseBlock ( + IN UINTN Instance, + IN UINTN Lba + ) +/*++ + +Routine Description: + Erases and initializes a firmware volume block + +Arguments: + Instance - The FV instance to be erased + Lba - The logical block index to be erased + +Returns: + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService (&Guid, EraseBlock, Instance, Lba, 0, 0, 0, 0, 0).Status; +} + +EFI_STATUS +EfiFvbGetVolumeAttributes ( + IN UINTN Instance, + OUT EFI_FVB_ATTRIBUTES *Attributes + ) +/*++ + +Routine Description: + Retrieves attributes, insures positive polarity of attribute bits, returns + resulting attributes in output parameter + +Arguments: + Instance - The FV instance whose attributes is going to be + returned + Attributes - Output buffer which contains attributes + +Returns: + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status; +} + +EFI_STATUS +EfiFvbSetVolumeAttributes ( + IN UINTN Instance, + IN EFI_FVB_ATTRIBUTES Attributes + ) +/*++ + +Routine Description: + Modifies the current settings of the firmware volume according to the + input parameter, and returns the new setting of the volume + +Arguments: + Instance - The FV instance whose attributes is going to be + modified + Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES + containing the desired firmware volume settings. + On successful return, it contains the new settings + of the firmware volume + +Returns: + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status; +} + +EFI_STATUS +EfiFvbGetPhysicalAddress ( + IN UINTN Instance, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress + ) +/*++ + +Routine Description: + Retrieves the physical address of a memory mapped FV + +Arguments: + Instance - The FV instance whose base address is going to be + returned + BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS + that on successful return, contains the base address + of the firmware volume. + +Returns: + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService (&Guid, GetPhysicalAddress, Instance, (UINT64) BaseAddress, 0, 0, 0, 0, 0).Status; +} + +EFI_STATUS +EfiFvbGetBlockSize ( + IN UINTN Instance, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks + ) +/*++ + +Routine Description: + Retrieve the size of a logical block + +Arguments: + Instance - The FV instance whose block size is going to be + returned + Lba - Indicates which block to return the size for. + BlockSize - A pointer to a caller allocated UINTN in which + the size of the block is returned + NumOfBlocks - a pointer to a caller allocated UINTN in which the + number of consecutive blocks starting with Lba is + returned. All blocks in this range have a size of + BlockSize + +Returns: + EFI_SUCCESS - The firmware volume was read successfully and + contents are in Buffer + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService ( + &Guid, + GetBlockSize, + Instance, + Lba, + (UINT64) BlockSize, + (UINT64) NumOfBlocks, + 0, + 0, + 0 + ).Status; +} + +EFI_STATUS +EfiFvbEraseCustomBlockRange ( + IN UINTN Instance, + IN EFI_LBA StartLba, + IN UINTN OffsetStartLba, + IN EFI_LBA LastLba, + IN UINTN OffsetLastLba + ) +/*++ + +Routine Description: + Erases and initializes a specified range of a firmware volume + +Arguments: + Instance - The FV instance to be erased + StartLba - The starting logical block index to be erased + OffsetStartLba - Offset into the starting block at which to + begin erasing + LastLba - The last logical block index to be erased + OffsetLastLba - Offset into the last block at which to end erasing + +Returns: + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; + + return EfiCallEsalService ( + &Guid, + EraseCustomBlockRange, + Instance, + StartLba, + OffsetStartLba, + LastLba, + OffsetLastLba, + 0, + 0 + ).Status; +} +EFI_STATUS +EfiFvbShutdown ( + VOID + ) +/*++ + +Routine Description: + Release resources allocated in EfiFvbInitialize. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +{ + return EFI_SUCCESS; +} \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s new file mode 100644 index 0000000000..8e387c2932 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s @@ -0,0 +1,88 @@ +//++ +// Copyright (c) 2004, Intel Corporation +// All rights reserved. This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// Module Name: +// +// IpfCpuCache.s +// +// Abstract: +// +// Contains Misc assembly procedures to support IPF CPU AP. +// +// Revision History: +// +//-- + +.file "IpfCpuCache.s" + +#include "IpfMacro.i" +#include "IpfDefines.h" + +//----------------------------------------------------------------------------- +//++ +// Flush Cache +// +// Arguments : + +// Input = in0 = Starting Address to Flush. +// Input = in1 = Length in bytes. +// Input = b0 = return branch register. +// On Entry : +// +// Return Value: +// +// VOID +// SalFlushCache ( +// IN UINT64 BaseToFlush, +// IN UINT64 LengthToFlush +// ); +// +//-- +//--------------------------------------------------------------------------- +PROCEDURE_ENTRY (SalFlushCache) + + NESTED_SETUP (5,8,0,0) + + mov loc2 = ar.lc + + mov loc3 = in0 // Start address. + mov loc4 = in1;; // Length in bytes. + + cmp.eq p6,p7 = loc4, r0;; // If Length is zero then don't flush any cache + (p6) br.spnt.many DoneFlushingC;; + + add loc4 = loc4,loc3 + mov loc5 = 1;; + sub loc4 = loc4, loc5 ;; // the End address to flush + + dep loc3 = r0,loc3,0,5 + dep loc4 = r0,loc4,0,5;; + shr loc3 = loc3,5 + shr loc4 = loc4,5;; // 32 byte cache line + + sub loc4 = loc4,loc3;; // total flush count, It should be add 1 but + // the br.cloop will first execute one time + mov loc3 = in0 + mov loc5 = 32 + mov ar.lc = loc4;; + +StillFlushingC: + fc loc3;; + sync.i;; + srlz.i;; + add loc3 = loc5,loc3;; + br.cloop.sptk.few StillFlushingC;; + +DoneFlushingC: + mov ar.lc = loc2 + NESTED_RETURN + +PROCEDURE_EXIT (SalFlushCache) + diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c new file mode 100644 index 0000000000..e7de9985a3 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c @@ -0,0 +1,170 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Lock.c + +Abstract: + + Support for locking lib services. These primitives may be implemented + as Esal calls but since these result in small code that us position + independent, we can use lib functions. ESAL calls have a significant + software overhead and too deep nesting is bad for the stack. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +extern +BOOLEAN +EfiAtRuntime ( + VOID + ); + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. There is + no concept of TPL at runtime hence priority is + ignored. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - Ignored + + +Returns: + + An initialized Efi Lock structure. + +--*/ +{ + Lock->Tpl = Priority; + Lock->OwnerTpl = 0; + Lock->Lock = 0; +} + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. For now, + only allow one level of nesting. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +{ + if (Lock->Lock != 0) { + // + // Lock is already owned, so bail out + // + return EFI_ACCESS_DENIED; + } + + if (!EfiAtRuntime ()) { + // + // The check is just debug code for core inplementation. It must + // always be true in a driver + // + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + } + + Lock->Lock += 1; + return EFI_SUCCESS; +} + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + Lock owned + +--*/ +{ + EFI_STATUS Status; + + Status = EfiAcquireLockOrFail (Lock); + + // + // Lock was already locked. + // + ASSERT_EFI_ERROR (Status); +} + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock. + +Arguments: + + Lock - The lock to release + +Returns: + + Lock unowned + +--*/ +{ + EFI_TPL Tpl; + + Tpl = Lock->OwnerTpl; + + ASSERT (Lock->Lock == 1); + Lock->Lock -= 1; + + if (!EfiAtRuntime ()) { + // + // The check is just debug code for core inplementation. It must + // always be true in a driver + // + gBS->RestoreTPL (Tpl); + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c new file mode 100644 index 0000000000..ae66cf43e0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c @@ -0,0 +1,1317 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RuntimeLib.c + +Abstract: + + Light weight lib to support Tiano Sal drivers. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService) +#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid) +#include "IpfDefines.h" +#include "SalApi.h" + +// +// Worker functions in EsalLib.s +// +SAL_RETURN_REGS +GetEsalEntryPoint ( + VOID + ); + +SAL_RETURN_REGS +SetEsalPhysicalEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ); + +SAL_RETURN_REGS +SetEsalVirtualEntryPoint ( + IN UINT64 EntryPoint, + IN UINT64 Gp + ); + +VOID +SalFlushCache ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ); + +// +// Module Globals. It's not valid to use these after the +// EfiRuntimeLibVirtualNotifyEvent has fired. +// +static EFI_EVENT mEfiVirtualNotifyEvent; +static EFI_RUNTIME_SERVICES *mRT; +static EFI_PLABEL mPlabel; +static EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService; +static BOOLEAN mRuntimeLibInitialized = FALSE; + +VOID +EFIAPI +EfiRuntimeLibVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Fixup internal data so that EFI and SAL can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + EFI_EVENT_NOTIFY ChildNotify; + + if (Context != NULL) { + // + // Call child event + // + ChildNotify = (EFI_EVENT_NOTIFY) (UINTN) Context; + ChildNotify (Event, NULL); + } + + mRT->ConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &mPlabel.EntryPoint); + mRT->ConvertPointer (EFI_INTERNAL_POINTER | EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP); + + SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP); + + // + // Clear out BootService globals + // + gBS = NULL; + gST = NULL; + mRT = NULL; + + // + // Pointers don't work you must use a direct lib call + // +} + +EFI_STATUS +EfiInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY GoVirtualChildEvent + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + GoVirtualChildEvent - Caller can register a virtual notification event. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + EFI_PLABEL *Plabel; + + if (mRuntimeLibInitialized) { + return EFI_ALREADY_STARTED; + } + + mRuntimeLibInitialized = TRUE; + + gST = SystemTable; + gBS = SystemTable->BootServices; + mRT = SystemTable->RuntimeServices; + Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); + ASSERT_EFI_ERROR (Status); + + // + // The protocol contains a function pointer, which is an indirect procedure call. + // An indirect procedure call goes through a plabel, and pointer to a function is + // a pointer to a plabel. To implement indirect procedure calls that can work in + // both physical and virtual mode, two plabels are required (one physical and one + // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it + // away. We cache it in a module global, so we can register the vitrual version. + // + Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService); + ASSERT_EFI_ERROR (Status); + + Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc; + + mPlabel.EntryPoint = Plabel->EntryPoint; + mPlabel.GP = Plabel->GP; + + SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP); + + // + // Create a Virtual address change notification event. Pass in the callers + // GoVirtualChildEvent so it's get passed to the event as contex. + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + EFI_TPL_NOTIFY, + EfiRuntimeLibVirtualNotifyEvent, + (VOID *) GoVirtualChildEvent, + &mEfiVirtualNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiShutdownRuntimeDriverLib ( + VOID + ) +/*++ + +Routine Description: + + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully + EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all + +--*/ +{ + EFI_STATUS Status; + + if (!mRuntimeLibInitialized) { + // + // You must call EfiInitializeRuntimeDriverLib() first + // + return EFI_UNSUPPORTED; + } + + mRuntimeLibInitialized = FALSE; + + // + // Close SetVirtualAddressMap () notify function + // + Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +EFI_STATUS +RegisterEsalFunction ( + IN UINT64 FunctionId, + IN EFI_GUID *ClassGuid, + IN SAL_INTERNAL_EXTENDED_SAL_PROC Function, + IN VOID *ModuleGlobal + ) +/*++ + +Routine Description: + + Register ESAL Class Function and it's asociated global. + This function is boot service only! + +Arguments: + FunctionId - ID of function to register + ClassGuid - GUID of function class + Function - Function to register under ClassGuid/FunctionId pair + ModuleGlobal - Module global for Function. + +Returns: + EFI_SUCCESS - If ClassGuid/FunctionId Function was registered. + +--*/ +{ + return mEsalBootService->AddExtendedSalProc ( + mEsalBootService, + ClassGuid, + FunctionId, + Function, + ModuleGlobal + ); +} + +EFI_STATUS +RegisterEsalClass ( + IN EFI_GUID *ClassGuid, + IN VOID *ModuleGlobal, + ... + ) +/*++ + +Routine Description: + + Register ESAL Class and it's asociated global. + This function is boot service only! + +Arguments: + ClassGuid - GUID of function class + ModuleGlobal - Module global for Function. + ... - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL + indicates the end of the list. + +Returns: + EFI_SUCCESS - All members of ClassGuid registered + +--*/ +{ + VA_LIST Args; + EFI_STATUS Status; + SAL_INTERNAL_EXTENDED_SAL_PROC Function; + UINT64 FunctionId; + EFI_HANDLE NewHandle; + + VA_START (Args, ModuleGlobal); + + Status = EFI_SUCCESS; + while (!EFI_ERROR (Status)) { + Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC); + if (Function == NULL) { + break; + } + + FunctionId = VA_ARG (Args, UINT64); + + Status = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal); + } + + if (EFI_ERROR (Status)) { + return Status; + } + + NewHandle = NULL; + return gBS->InstallProtocolInterface ( + &NewHandle, + ClassGuid, + EFI_NATIVE_INTERFACE, + NULL + ); +} + +SAL_RETURN_REGS +EfiCallEsalService ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ) +/*++ + +Routine Description: + + Call module that is not linked direclty to this module. This code is IP + relative and hides the binding issues of virtual or physical calling. The + function that gets dispatched has extra arguments that include the registered + module global and a boolean flag to indicate if the system is in virutal mode. + +Arguments: + ClassGuid - GUID of function + FunctionId - Function in ClassGuid to call + Arg2 - Argument 2 ClassGuid/FunctionId defined + Arg3 - Argument 3 ClassGuid/FunctionId defined + Arg4 - Argument 4 ClassGuid/FunctionId defined + Arg5 - Argument 5 ClassGuid/FunctionId defined + Arg6 - Argument 6 ClassGuid/FunctionId defined + Arg7 - Argument 7 ClassGuid/FunctionId defined + Arg8 - Argument 8 ClassGuid/FunctionId defined + +Returns: + Status of ClassGuid/FuncitonId + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + SAL_EXTENDED_SAL_PROC EsalProc; + + ReturnReg = GetEsalEntryPoint (); + if (ReturnReg.Status != EFI_SAL_SUCCESS) { + return ReturnReg; + } + + if (ReturnReg.r11 & PSR_IT_MASK) { + // + // Virtual mode plabel to entry point + // + EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r10; + } else { + // + // Physical mode plabel to entry point + // + EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r9; + } + + return EsalProc ( + ClassGuid, + FunctionId, + Arg2, + Arg3, + Arg4, + Arg5, + Arg6, + Arg7, + Arg8 + ); +} + +EFI_STATUS +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return mRT->ConvertPointer (DebugDisposition, Address); +} + +BOOLEAN +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; + SAL_RETURN_REGS ReturnReg; + + ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0); + + return (BOOLEAN) (ReturnReg.r9 == 1); +} + +BOOLEAN +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if ExitBootService () has been called + +Arguments: + NONE + +Returns: + TRUE - If ExitBootService () has been called + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; + SAL_RETURN_REGS ReturnReg; + + ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0); + + return (BOOLEAN) (ReturnReg.r9 == 1); +} + +EFI_STATUS +EfiReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID; + SAL_RETURN_REGS ReturnReg; + + + ReturnReg = EfiCallEsalService ( + &Guid, + StatusCode, + (UINT64) CodeType, + (UINT64) Value, + (UINT64) Instance, + (UINT64) CallerId, + (UINT64) Data, + 0, + 0 + ); + + return (EFI_STATUS) ReturnReg.Status; +} +// +// Sal Reset Driver Class +// +VOID +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Resets the entire platform. + +Arguments: + + ResetType - The type of reset to perform. + ResetStatus - The status code for the reset. + DataSize - The size, in bytes, of ResetData. + ResetData - A data buffer that includes a Null-terminated Unicode string, optionally + followed by additional binary data. + +Returns: + + None + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID; + + EfiCallEsalService ( + &Guid, + ResetSystem, + (UINT64) ResetType, + (UINT64) ResetStatus, + (UINT64) DataSize, + (UINT64) ResetData, + 0, + 0, + 0 + ); +} +// +// Sal MTC Driver Class +// +EFI_STATUS +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Returns the next high 32 bits of the platform¡¯s monotonic counter. + +Arguments: + + HighCount - Pointer to returned value. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, GetNextHighMonotonicCount, (UINT64) HighCount, 0, 0, 0, 0, 0, 0); + return (EFI_STATUS) ReturnReg.Status; +} +// +// Sal Variable Driver Class +// +EFI_STATUS +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +/*++ + +Routine Description: + + Returns the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - If not NULL, a pointer to the memory location to return the + attributes bitmask for the variable. + DataSize - On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + Data - The buffer to return the contents of the variable. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + EsalGetVariable, + (UINT64) VariableName, + (UINT64) VendorGuid, + (UINT64) Attributes, + (UINT64) DataSize, + (UINT64) Data, + 0, + 0 + ); + return (EFI_STATUS) ReturnReg.Status; +} + +EFI_STATUS +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +/*++ + +Routine Description: + + Enumerates the current variable names. + +Arguments: + + VariableNameSize - The size of the VariableName buffer. + VariableName - On input, supplies the last VariableName that was returned + by GetNextVariableName(). + On output, returns the Nullterminated Unicode string of the + current variable. + VendorGuid - On input, supplies the last VendorGuid that was returned by + GetNextVariableName(). + On output, returns the VendorGuid of the current variable. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + EsalGetNextVariableName, + (UINT64) VariableNameSize, + (UINT64) VariableName, + (UINT64) VendorGuid, + 0, + 0, + 0, + 0 + ); + return (EFI_STATUS) ReturnReg.Status; +} + +EFI_STATUS +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ) +/*++ + +Routine Description: + + Sets the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - Attributes bitmask to set for the variable. + DataSize - The size in bytes of the Data buffer. + Data - The contents for the variable. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + EsalSetVariable, + (UINT64) VariableName, + (UINT64) VendorGuid, + (UINT64) Attributes, + (UINT64) DataSize, + (UINT64) Data, + 0, + 0 + ); + return (EFI_STATUS) ReturnReg.Status; +} + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +EFI_STATUS +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) +/*++ + +Routine Description: + + This code returns information about the EFI variables. + +Arguments: + + Attributes Attributes bitmask to specify the type of variables + on which to return information. + MaximumVariableStorageSize Pointer to the maximum size of the storage space available + for the EFI variables associated with the attributes specified. + RemainingVariableStorageSize Pointer to the remaining size of the storage space available + for the EFI variables associated with the attributes specified. + MaximumVariableSize Pointer to the maximum size of the individual EFI variables + associated with the attributes specified. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService ( + &Guid, + EsalQueryVariableInfo, + (UINT64) Attributes, + (UINT64) MaximumVariableStorageSize, + (UINT64) RemainingVariableStorageSize, + (UINT64) MaximumVariableSize, + 0, + 0, + 0 + ); + return (EFI_STATUS) ReturnReg.Status; +} + +#endif + +// +// Sal RTC Driver Class. +// +EFI_STATUS +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, GetTime, (UINT64) Time, (UINT64) Capabilities, 0, 0, 0, 0, 0); + return ReturnReg.Status; +} + +EFI_STATUS +EfiSetTime ( + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, SetTime, (UINT64) Time, 0, 0, 0, 0, 0, 0); + return ReturnReg.Status; +} + +EFI_STATUS +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, GetWakeupTime, (UINT64) Enabled, (UINT64) Pending, (UINT64) Time, 0, 0, 0, 0); + return ReturnReg.Status; +} + +EFI_STATUS +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +{ + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, SetWakeupTime, (UINT64) Enable, (UINT64) Time, 0, 0, 0, 0, 0); + return ReturnReg.Status; +} + + + +// +// Base IO Services +// +EFI_STATUS +EfiIoRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO read into Buffer. + +Arguments: + Width - Width of read transaction, and repeat operation to use + Address - IO address to read + Count - Number of times to read the IO address. + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +{ + + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0); + + return ReturnReg.Status; + +} + +EFI_STATUS +EfiIoWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +{ + + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, IoWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0); + + return ReturnReg.Status; + +} + +EFI_STATUS +EfiMemRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a Memory mapped IO read into Buffer. + +Arguments: + Width - Width of each read transaction. + Address - Memory mapped IO address to read + Count - Number of Width quanta to read + Buffer - Buffer to read data into. size is Width * Count + +Returns: + Status code + +--*/ +{ + + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0); + + return ReturnReg.Status; + +} + +EFI_STATUS +EfiMemWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a memory mapped IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + Status code + +--*/ +{ + + SAL_RETURN_REGS ReturnReg; + + EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID; + + ReturnReg = EfiCallEsalService (&Guid, MemWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0); + + return ReturnReg.Status; + +} + + +#define EFI_PCI_ADDRESS_IPF(_seg, _bus, _devfunc, _reg) \ + (((_seg) << 24) | ((_bus) << 16) | ((_devfunc) << 8) | (_reg)) & 0xFFFFFFFF + +// +// PCI Class Functions +// +UINT8 +PciRead8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID; + UINT64 Address; + SAL_RETURN_REGS Return; + + Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register); + Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 1, 0, 0, 0, 0, 0); + + return (UINT8) Return.r9; +} + + +UINT16 +PciRead16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID; + UINT64 Address; + SAL_RETURN_REGS Return; + + Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register); + Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 2, 0, 0, 0, 0, 0); + + return (UINT16) Return.r9; +} + +UINT32 +PciRead32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID; + UINT64 Address; + SAL_RETURN_REGS Return; + + Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register); + Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 4, 0, 0, 0, 0, 0); + + return (UINT32) Return.r9; +} + +VOID +PciWrite8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT8 Data + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID; + UINT64 Address; + + Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register); + EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 1, Data, 0, 0, 0, 0); +} + +VOID +PciWrite16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT16 Data + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + None. + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID; + UINT64 Address; + + Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register); + EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 2, Data, 0, 0, 0, 0); +} + +VOID +PciWrite32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT32 Data + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID; + UINT64 Address; + + Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register); + EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 4, Data, 0, 0, 0, 0); +} + +// +// Stall class functions +// +VOID +EfiStall ( + IN UINTN Microseconds + ) +/*++ + +Routine Description: + Delay for at least the request number of microseconds + +Arguments: + Microseconds - Number of microseconds to delay. + +Returns: + NONE + +--*/ +{ + EFI_GUID Guid = EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID; + + if (EfiAtRuntime ()) { + EfiCallEsalService (&Guid, Stall, Microseconds, 4, 0, 0, 0, 0, 0); + } else { + gBS->Stall (Microseconds); + } +} +// +// Cache Flush Routine. +// +EFI_STATUS +EfiCpuFlushCache ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Flush cache with specified range. + +Arguments: + + Start - Start address + Length - Length in bytes + +Returns: + + Status code + + EFI_SUCCESS - success + +--*/ +{ + SalFlushCache (Start, Length); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c new file mode 100644 index 0000000000..7f141ec254 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LibGlobals.c + +Abstract: + + Lib Globals + + gBS - Pointer to the EFI Boot Services Table + gST - Pointer to EFI System Table + gRtErrorLevel - Error level used with DEBUG () macro + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_GUID_DEFINITION (StatusCodeDataTypeId) + +// +// Lib globals that can ONLY be used at BootServices time! +// +EFI_BOOT_SERVICES *gBS; +EFI_SYSTEM_TABLE *gST; +EFI_DXE_SERVICES *gDS = NULL; +UINTN gRtErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD; diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c new file mode 100644 index 0000000000..ac777802d7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c @@ -0,0 +1,705 @@ +/*++ + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RtDevicePath.c + +Abstract: + + Device Path services. The thing to remember is device paths are built out of + nodes. The device path is terminated by an end node that is length + sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL) + all over this file. + + The only place where multi-instance device paths are supported is in + environment varibles. Multi-instance device paths should never be placed + on a Handle. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include "RtDevicePath.h" +#include EFI_GUID_DEFINITION (FrameworkDevicePath) +#include EFI_PROTOCOL_DEFINITION (DevicePath) + +STATIC +VOID * +InternalAllocatePool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool. + +Arguments: + + AllocationSize - The size to allocate + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = NULL; + gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory); + return Memory; +} + +STATIC +VOID * +InternalAllocateCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool and use a buffer provided by + caller to fill it. + +Arguments: + + AllocationSize - The size to allocate + + Buffer - Buffer that will be filled into the buffer allocated + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = NULL; + gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory); + if (Memory != NULL) { + gBS->CopyMem (Memory, Buffer, AllocationSize); + } + + return Memory; +} + +STATIC +VOID * +InternalAllocateZeroPool ( + IN UINTN AllocationSize + ) +/*++ + +Routine Description: + + Allocate BootServicesData pool and zero it. + +Arguments: + + AllocationSize - The size to allocate + +Returns: + + Pointer of the buffer allocated. + +--*/ +{ + VOID *Memory; + + Memory = InternalAllocatePool (AllocationSize); + if (Memory != NULL) { + gBS->SetMem (Memory, AllocationSize, 0); + } + + return Memory; +} + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ) +/*++ + +Routine Description: + Function retrieves the next device path instance from a device path data structure. + +Arguments: + DevicePath - A pointer to a device path data structure. + + Size - A pointer to the size of a device path instance in bytes. + +Returns: + + This function returns a pointer to the current device path instance. + In addition, it returns the size in bytes of the current device path instance in Size, + and a pointer to the next device path instance in DevicePath. + If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *DevPath; + EFI_DEVICE_PATH_PROTOCOL *ReturnValue; + UINT8 Temp; + + if (*DevicePath == NULL) { + if (Size != NULL) { + *Size = 0; + } + + return NULL; + } + + // + // Find the end of the device path instance + // + DevPath = *DevicePath; + while (!IsDevicePathEndType (DevPath)) { + DevPath = NextDevicePathNode (DevPath); + } + + // + // Compute the size of the device path instance + // + if (Size != NULL) { + *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL); + } + + // + // Make a copy and return the device path instance + // + Temp = DevPath->SubType; + DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; + ReturnValue = RtEfiDuplicateDevicePath (*DevicePath); + DevPath->SubType = Temp; + + // + // If DevPath is the end of an entire device path, then another instance + // does not follow, so *DevicePath is set to NULL. + // + if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) { + *DevicePath = NULL; + } else { + *DevicePath = NextDevicePathNode (DevPath); + } + + return ReturnValue; +} + +BOOLEAN +RtEfiIsDevicePathMultiInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + Return TRUE is this is a multi instance device path. + +Arguments: + DevicePath - A pointer to a device path data structure. + + +Returns: + TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi + instance. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *Node; + + if (DevicePath == NULL) { + return FALSE; + } + + Node = DevicePath; + while (!EfiIsDevicePathEnd (Node)) { + if (EfiIsDevicePathEndInstance (Node)) { + return TRUE; + } + + Node = EfiNextDevicePathNode (Node); + } + + return FALSE; +} + +UINTN +RtEfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + + Calculate the space size of a device path. + +Arguments: + + DevicePath - A specified device path + +Returns: + + The size. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *Start; + + if (DevicePath == NULL) { + return 0; + } + + // + // Search for the end of the device path structure + // + Start = DevicePath; + while (!EfiIsDevicePathEnd (DevicePath)) { + DevicePath = EfiNextDevicePathNode (DevicePath); + } + + // + // Compute the size and add back in the size of the end device path structure + // + return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); +} + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +/*++ + +Routine Description: + + Get the device path protocol interface installed on a specified handle. + +Arguments: + + Handle - a specified handle + +Returns: + + The device path protocol interface installed on that handle. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + DevicePath = NULL; + gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *) &DevicePath + ); + return DevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiDuplicateDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +/*++ + +Routine Description: + + Duplicate a device path structure. + +Arguments: + + DevicePath - The device path to duplicated. + +Returns: + + The duplicated device path. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN Size; + + if (DevicePath == NULL) { + return NULL; + } + + // + // Compute the size + // + Size = RtEfiDevicePathSize (DevicePath); + if (Size == 0) { + return NULL; + } + + // + // Allocate space for duplicate device path + // + NewDevicePath = InternalAllocateCopyPool (Size, DevicePath); + + return NewDevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +/*++ + +Routine Description: + Function is used to append a Src1 and Src2 together. + +Arguments: + Src1 - A pointer to a device path data structure. + + Src2 - A pointer to a device path data structure. + +Returns: + + A pointer to the new device path is returned. + NULL is returned if space for the new device path could not be allocated from pool. + It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed. + +--*/ +{ + UINTN Size; + UINTN Size1; + UINTN Size2; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath; + + // + // If there's only 1 path, just duplicate it + // + if (!Src1) { + ASSERT (!IsDevicePathUnpacked (Src2)); + return RtEfiDuplicateDevicePath (Src2); + } + + if (!Src2) { + ASSERT (!IsDevicePathUnpacked (Src1)); + return RtEfiDuplicateDevicePath (Src1); + } + + // + // Allocate space for the combined device path. It only has one end node of + // length EFI_DEVICE_PATH_PROTOCOL + // + Size1 = RtEfiDevicePathSize (Src1); + Size2 = RtEfiDevicePathSize (Src2); + Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); + + NewDevicePath = InternalAllocateCopyPool (Size, Src1); + + if (NewDevicePath != NULL) { + + // + // Over write Src1 EndNode and do the copy + // + SecondDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + EfiCopyMem (SecondDevicePath, Src2, Size2); + } + + return NewDevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Node + ) +/*++ + +Routine Description: + Function is used to append a device path node to the end of another device path. + +Arguments: + Src1 - A pointer to a device path data structure. + + Node - A pointer to a device path data structure. + +Returns: + This function returns a pointer to the new device path. + If there is not enough temporary pool memory available to complete this function, + then NULL is returned. + + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *Temp; + EFI_DEVICE_PATH_PROTOCOL *NextNode; + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + UINTN NodeLength; + + // + // Build a Node that has a terminator on it + // + NodeLength = DevicePathNodeLength (Node); + + Temp = InternalAllocateCopyPool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL), Node); + if (Temp == NULL) { + return NULL; + } + + // + // Add and end device path node to convert Node to device path + // + NextNode = NextDevicePathNode (Temp); + SetDevicePathEndNode (NextNode); + + // + // Append device paths + // + NewDevicePath = RtEfiAppendDevicePath (Src1, Temp); + gBS->FreePool (Temp); + return NewDevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ) +/*++ + +Routine Description: + + This function allocates a device path for a file and appends it to an existiong + device path. + +Arguments: + Device - A pointer to a device handle. + + FileName - A pointer to a Null-terminated Unicodestring. + +Returns: + A device path contain the file name. + +--*/ +{ + UINTN Size; + FILEPATH_DEVICE_PATH *FilePath; + EFI_DEVICE_PATH_PROTOCOL *Eop; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + for (Size = 0; FileName[Size] != 0; Size++) + ; + Size = (Size + 1) * 2; + + FilePath = InternalAllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL)); + + DevicePath = NULL; + + if (FilePath != NULL) { + + // + // Build a file path + // + FilePath->Header.Type = MEDIA_DEVICE_PATH; + FilePath->Header.SubType = MEDIA_FILEPATH_DP; + SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH); + EfiCopyMem (FilePath->PathName, FileName, Size); + Eop = NextDevicePathNode (&FilePath->Header); + SetDevicePathEndNode (Eop); + + // + // Append file path to device's device path + // + + DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath; + if (Device != NULL) { + DevicePath = RtEfiAppendDevicePath ( + RtEfiDevicePathFromHandle (Device), + DevicePath + ); + + gBS->FreePool (FilePath); + } + } + + return DevicePath; +} + +EFI_DEVICE_PATH_PROTOCOL * +RtEfiAppendDevicePathInstance ( + IN EFI_DEVICE_PATH_PROTOCOL *Src, + IN EFI_DEVICE_PATH_PROTOCOL *Instance + ) +/*++ + +Routine Description: + + Append a device path instance to another. + +Arguments: + + Src - The device path instance to be appended with. + Instance - The device path instance appending the other. + +Returns: + + The contaction of these two. + +--*/ +{ + UINT8 *Ptr; + EFI_DEVICE_PATH_PROTOCOL *DevPath; + UINTN SrcSize; + UINTN InstanceSize; + + if (Src == NULL) { + return RtEfiDuplicateDevicePath (Instance); + } + + SrcSize = RtEfiDevicePathSize (Src); + InstanceSize = RtEfiDevicePathSize (Instance); + + Ptr = InternalAllocateCopyPool (SrcSize + InstanceSize, Src); + if (Ptr != NULL) { + + DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr; + + while (!IsDevicePathEnd (DevPath)) { + DevPath = NextDevicePathNode (DevPath); + } + // + // Convert the End to an End Instance, since we are + // appending another instacne after this one its a good + // idea. + // + DevPath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; + + DevPath = NextDevicePathNode (DevPath); + EfiCopyMem (DevPath, Instance, InstanceSize); + } + + return (EFI_DEVICE_PATH_PROTOCOL *) Ptr; +} + +VOID +EFIAPI +RtEfiInitializeFwVolDevicepathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN EFI_GUID *NameGuid + ) +/*++ + +Routine Description: + + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + +Arguments: + + FvDevicePathNode - Pointer to a FV device path node to initialize + NameGuid - FV file name to use in FvDevicePathNode + +Returns: + + None + +--*/ +{ +#if (EFI_SPECIFICATION_VERSION != 0x00020000) + // + // Use old Device Path + // + FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + +#else + // + // Use the new Device path that does not conflict with the UEFI 2.0 + // + FvDevicePathNode->Piwg.Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Piwg.Header.SubType = MEDIA_VENDOR_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + + // + // Add the GUID for generic PIWG device paths + // + EfiCopyMem (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid, sizeof(EFI_GUID)); + + // + // Add in the FW Vol File Path PIWG defined inforation + // + FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE; + +#endif + EfiCopyMem (&FvDevicePathNode->NameGuid, NameGuid, sizeof(EFI_GUID)); +} + +EFI_GUID * +EFIAPI +RtEfiGetNameGuidFromFwVolDevicePathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode + ) +/*++ + +Routine Description: + + Check to see if the Firmware Volume (FV) Media Device Path is valid. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. The return value to this + function points to a location in FvDevicePathNode and it does not allocate + new memory for the GUID pointer that is returned. + +Arguments: + + FvDevicePathNode - Pointer to FV device path to check + +Returns: + + NULL - FvDevicePathNode is not valid. + Other - FvDevicePathNode is valid and pointer to NameGuid was returned. + +--*/ +{ +#if (EFI_SPECIFICATION_VERSION != 0x00020000) + // + // Use old Device Path + // + if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) { + return &FvDevicePathNode->NameGuid; + } + +#else + // + // Use the new Device path that does not conflict with the UEFI 2.0 + // + if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH && + DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) { + if (EfiCompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) { + if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) { + return &FvDevicePathNode->NameGuid; + } + } + } +#endif + return NULL; +} + diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c new file mode 100644 index 0000000000..1cecb47852 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c @@ -0,0 +1,617 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Fvb.c + +Abstract: + + Firmware Volume Block Protocol Runtime Abstraction + + mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the + index in the mFvbEntry array. This should be the same sequence as the FVB's + were described in the HOB. We have to remember the handle so we can tell if + the protocol has been reinstalled and it needs updateing. + + If you are using any of these lib functions.you must first call FvbInitialize (). + +Key: + FVB - Firmware Volume Block + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_PROTOCOL_DEFINITION (FvbExtension) + +// +// Lib will ASSERT if more FVB devices than this are added to the system. +// +UINTN mFvbCount; +VOID *mFvbRegistration; +VOID *mFvbExtRegistration; +static EFI_EVENT mEfiFvbVirtualNotifyEvent; +BOOLEAN gEfiFvbInitialized = FALSE; +EFI_EVENT mFvbEvent; + +BOOLEAN +IsMemoryRuntime ( + IN VOID *Address + ) +/*++ + +Routine Description: + Check whether an address is runtime memory or not. + +Arguments: + + Address - The Address being checked. + +Returns: + TRUE - The address is runtime memory. + FALSE - The address is not runtime memory. + +--*/ +{ + EFI_STATUS Status; + UINT8 TmpMemoryMap[1]; + UINTN MapKey; + UINTN DescriptorSize; + UINT32 DescriptorVersion; + UINTN MemoryMapSize; + EFI_MEMORY_DESCRIPTOR *MemoryMap; + EFI_MEMORY_DESCRIPTOR *MemoryMapPtr; + BOOLEAN IsRuntime; + UINTN Index; + + IsRuntime = FALSE; + + // + // Get System MemoryMapSize + // + MemoryMapSize = 1; + Status = gBS->GetMemoryMap ( + &MemoryMapSize, + (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap, + &MapKey, + &DescriptorSize, + &DescriptorVersion + ); + ASSERT (Status == EFI_BUFFER_TOO_SMALL); + // + // Enlarge space here, because we will allocate pool now. + // + MemoryMapSize += EFI_PAGE_SIZE; + Status = gBS->AllocatePool ( + EfiBootServicesData, + MemoryMapSize, + (VOID**)&MemoryMap + ); + ASSERT_EFI_ERROR (Status); + + // + // Get System MemoryMap + // + Status = gBS->GetMemoryMap ( + &MemoryMapSize, + MemoryMap, + &MapKey, + &DescriptorSize, + &DescriptorVersion + ); + ASSERT_EFI_ERROR (Status); + + MemoryMapPtr = MemoryMap; + // + // Search the request Address + // + for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) { + if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) && + ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart + + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) { + // + // Found it + // + if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) { + IsRuntime = TRUE; + } + break; + } + // + // Get next item + // + MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize); + } + + // + // Done + // + gBS->FreePool (MemoryMapPtr); + + return IsRuntime; +} + +VOID +EFIAPI +FvbNotificationFunction ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is + reinstalled. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + None + +--*/ +{ + EFI_STATUS Status; + UINTN BufferSize; + EFI_HANDLE Handle; + UINTN Index; + UINTN UpdateIndex; + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; + EFI_FVB_EXTENSION_PROTOCOL *FvbExtension; + + while (TRUE) { + BufferSize = sizeof (Handle); + Status = gBS->LocateHandle ( + ByRegisterNotify, + &gEfiFirmwareVolumeBlockProtocolGuid, + mFvbRegistration, + &BufferSize, + &Handle + ); + if (EFI_ERROR (Status)) { + // + // Exit Path of While Loop.... + // + break; + } + + UpdateIndex = MAX_FVB_COUNT; + for (Index = 0; Index < mFvbCount; Index++) { + if (mFvbEntry[Index].Handle == Handle) { + // + // If the handle is already in the table just update the protocol + // + UpdateIndex = Index; + break; + } + } + + if (UpdateIndex == MAX_FVB_COUNT) { + // + // Use the next free slot for a new entry + // + UpdateIndex = mFvbCount; + } + // + // The array does not have enough entries + // + ASSERT (UpdateIndex < MAX_FVB_COUNT); + + // + // Get the interface pointer and if it's ours, skip it. + // We check Runtime here, because it has no reason to register + // a boot time FVB protocol. + // + Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &Fvb); + ASSERT_EFI_ERROR (Status); + if (IsMemoryRuntime (Fvb)) { + // + // Increase mFvbCount if we need to add a new entry + // + if (UpdateIndex == mFvbCount) { + mFvbCount++; + } + mFvbEntry[UpdateIndex].Handle = Handle; + mFvbEntry[UpdateIndex].Fvb = Fvb; + mFvbEntry[UpdateIndex].FvbExtension = NULL; + + Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, &FvbExtension); + if ((Status == EFI_SUCCESS) && IsMemoryRuntime (FvbExtension)) { + mFvbEntry[UpdateIndex].FvbExtension = FvbExtension; + } + } + } +} + +EFI_STATUS +EfiFvbInitialize ( + VOID + ) +/*++ + +Routine Description: + Initialize globals and register Fvb Protocol notification function. + +Arguments: + None + +Returns: + EFI_SUCCESS - Fvb is successfully initialized + others - Fail to initialize + +--*/ +{ + UINTN Status; + mFvbCount = 0; + + Status = gBS->AllocatePool ( + EfiRuntimeServicesData, + (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT, + (VOID *) &mFvbEntry + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + EfiZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT); + + mFvbEvent = RtEfiLibCreateProtocolNotifyEvent ( + &gEfiFirmwareVolumeBlockProtocolGuid, + EFI_TPL_CALLBACK, + FvbNotificationFunction, + NULL, + &mFvbRegistration + ); + + // + // Register SetVirtualAddressMap () notify function + // + // Status = gBS->CreateEvent ( + // EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + // EFI_TPL_NOTIFY, + // EfiRuntimeLibFvbVirtualNotifyEvent, + // NULL, + // &mEfiFvbVirtualNotifyEvent + // ); + // ASSERT_EFI_ERROR (Status); + // + gEfiFvbInitialized = TRUE; + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiFvbShutdown ( + VOID + ) +/*++ + +Routine Description: + Release resources allocated in EfiFvbInitialize. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +{ + gBS->FreePool ((VOID *) mFvbEntry); + gBS->CloseEvent (mFvbEvent); + gEfiFvbInitialized = FALSE; + return EFI_SUCCESS; +} + +// +// The following functions wrap Fvb protocol in the Runtime Lib functions. +// The Instance translates into Fvb instance. The Fvb order defined by HOBs and +// thus the sequence of FVB protocol addition define Instance. +// +// EfiFvbInitialize () must be called before any of the following functions +// must be called. +// + +EFI_STATUS +EfiFvbReadBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Reads specified number of bytes into a buffer from the specified block + +Arguments: + Instance - The FV instance to be read from + Lba - The logical block address to be read from + Offset - Offset into the block at which to begin reading + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes read + Buffer - Pointer to a caller allocated buffer that will be + used to hold the data read + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer); +} + +EFI_STATUS +EfiFvbWriteBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Writes specified number of bytes from the input buffer to the block + +Arguments: + Instance - The FV instance to be written to + Lba - The starting logical block index to write to + Offset - Offset into the block at which to begin writing + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes actually written + Buffer - Pointer to a caller allocated buffer that contains + the source for the write + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer); +} + +EFI_STATUS +EfiFvbEraseBlock ( + IN UINTN Instance, + IN EFI_LBA Lba + ) +/*++ + +Routine Description: + Erases and initializes a firmware volume block + +Arguments: + Instance - The FV instance to be erased + Lba - The logical block index to be erased + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, -1); +} + +EFI_STATUS +EfiFvbGetVolumeAttributes ( + IN UINTN Instance, + OUT EFI_FVB_ATTRIBUTES *Attributes + ) +/*++ + +Routine Description: + Retrieves attributes, insures positive polarity of attribute bits, returns + resulting attributes in output parameter + +Arguments: + Instance - The FV instance whose attributes is going to be + returned + Attributes - Output buffer which contains attributes + +Returns: + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->GetVolumeAttributes (mFvbEntry[Instance].Fvb, Attributes); +} + +EFI_STATUS +EfiFvbSetVolumeAttributes ( + IN UINTN Instance, + IN EFI_FVB_ATTRIBUTES Attributes + ) +/*++ + +Routine Description: + Modifies the current settings of the firmware volume according to the + input parameter, and returns the new setting of the volume + +Arguments: + Instance - The FV instance whose attributes is going to be + modified + Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES + containing the desired firmware volume settings. + On successful return, it contains the new settings + of the firmware volume + +Returns: + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->SetVolumeAttributes (mFvbEntry[Instance].Fvb, &Attributes); +} + +EFI_STATUS +EfiFvbGetPhysicalAddress ( + IN UINTN Instance, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress + ) +/*++ + +Routine Description: + Retrieves the physical address of a memory mapped FV + +Arguments: + Instance - The FV instance whose base address is going to be + returned + BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS + that on successful return, contains the base address + of the firmware volume. + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress); +} + +EFI_STATUS +EfiFvbGetBlockSize ( + IN UINTN Instance, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks + ) +/*++ + +Routine Description: + Retrieve the size of a logical block + +Arguments: + Instance - The FV instance whose block size is going to be + returned + Lba - Indicates which block to return the size for. + BlockSize - A pointer to a caller allocated UINTN in which + the size of the block is returned + NumOfBlocks - a pointer to a caller allocated UINTN in which the + number of consecutive blocks starting with Lba is + returned. All blocks in this range have a size of + BlockSize + +Returns: + EFI_SUCCESS - The firmware volume was read successfully and + contents are in Buffer + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks); +} + +EFI_STATUS +EfiFvbEraseCustomBlockRange ( + IN UINTN Instance, + IN EFI_LBA StartLba, + IN UINTN OffsetStartLba, + IN EFI_LBA LastLba, + IN UINTN OffsetLastLba + ) +/*++ + +Routine Description: + Erases and initializes a specified range of a firmware volume + +Arguments: + Instance - The FV instance to be erased + StartLba - The starting logical block index to be erased + OffsetStartLba - Offset into the starting block at which to + begin erasing + LastLba - The last logical block index to be erased + OffsetLastLba - Offset into the last block at which to end erasing + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + + EFI_UNSUPPORTED - not support + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + if (!(mFvbEntry[Instance].FvbExtension)) { + return EFI_UNSUPPORTED; + } + + if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) { + return EFI_UNSUPPORTED; + } + + return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock ( + mFvbEntry[Instance].FvbExtension, + StartLba, + OffsetStartLba, + LastLba, + OffsetLastLba + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c new file mode 100644 index 0000000000..363347173a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c @@ -0,0 +1,130 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IoLib.c + +Abstract: + + Light weight lib to support Tiano drivers. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (CpuIo) + +extern EFI_CPU_IO_PROTOCOL *gCpuIo; + +EFI_STATUS +EfiIoRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO read into Buffer. + +Arguments: + Width - Width of read transaction, and repeat operation to use + Address - IO address to read + Count - Number of times to read the IO address. + Buffer - Buffer to read data into. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Io.Read (gCpuIo, Width, Address, Count, Buffer); +} + +EFI_STATUS +EfiIoWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Io.Write (gCpuIo, Width, Address, Count, Buffer); +} + +EFI_STATUS +EfiMemRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a Memory mapped IO read into Buffer. + +Arguments: + Width - Width of each read transaction. + Address - Memory mapped IO address to read + Count - Number of Width quanta to read + Buffer - Buffer to read data into. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Mem.Read (gCpuIo, Width, Address, Count, Buffer); +} + +EFI_STATUS +EfiMemWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a memory mapped IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Mem.Write (gCpuIo, Width, Address, Count, Buffer); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c new file mode 100644 index 0000000000..6b6147e127 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c @@ -0,0 +1,177 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Lock.c + +Abstract: + + Support for locking lib services. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +extern +BOOLEAN +EfiAtRuntime ( + VOID + ); + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + Note on a check build ASSERT()s are used to ensure proper + lock usage. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - The task priority level of the lock + + +Returns: + + An initialized Efi Lock structure. + +--*/ +{ + Lock->Tpl = Priority; + Lock->OwnerTpl = 0; + Lock->Lock = 0; +} + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +{ + if (Lock->Lock != 0) { + // + // Lock is already owned, so bail out + // + return EFI_ACCESS_DENIED; + } + + if (!EfiAtRuntime ()) { + // + // The check is just debug code for core inplementation. It must + // always be true in a driver + // + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + } + + Lock->Lock += 1; + return EFI_SUCCESS; +} + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + Lock owned + +--*/ +{ + EFI_STATUS Status; + + Status = EfiAcquireLockOrFail (Lock); + + // + // Lock was already locked. + // + ASSERT_EFI_ERROR (Status); +} + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + +Arguments: + + Lock - The lock to release + +Returns: + + Lock unowned + +--*/ +{ + EFI_TPL Tpl; + + Tpl = Lock->OwnerTpl; + + ASSERT (Lock->Lock == 1); + Lock->Lock -= 1; + + if (!EfiAtRuntime ()) { + // + // The check is just debug code for core inplementation. It must + // always be true in a driver + // + gBS->RestoreTPL (Tpl); + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c new file mode 100644 index 0000000000..ae7f6e58a8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c @@ -0,0 +1,407 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PlatformIoLib.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (CpuIo) + +#define PCI_CONFIG_INDEX_PORT 0xcf8 +#define PCI_CONFIG_DATA_PORT 0xcfc +#define REFRESH_CYCLE_TOGGLE_BIT 0x10 + +UINT32 +GetPciAddress ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Constructs PCI Address 32 bits + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + PciAddress to be written to Config Port + +--*/ +{ + UINT32 Data; + + Data = (((UINT32) Segment) << 24); + Data |= (((UINT32) Bus) << 16); + Data |= (((UINT32) DevFunc) << 8); + Data |= (UINT32) Register; + + return Data; + +} + +UINT8 +PciRead8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + UINT8 Data; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return 0; + } + + EfiIoRead (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); + + return Data; +} + +UINT16 +PciRead16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + UINT16 Data; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return 0; + } + + EfiIoRead (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); + + return Data; +} + +UINT32 +PciRead32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + UINT32 Data; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return 0; + } + + EfiIoRead (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); + + return Data; +} + +VOID +PciWrite8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT8 Data + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return ; + } + + EfiIoWrite (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); +} + +VOID +PciWrite16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT16 Data + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return ; + } + + EfiIoWrite (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); +} + +VOID +PciWrite32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT32 Data + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return ; + } + + EfiIoWrite (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); +} +// +// Delay Primative +// +VOID +EfiStall ( + IN UINTN Microseconds + ) +/*++ + +Routine Description: + Delay for at least the request number of microseconds + +Arguments: + Microseconds - Number of microseconds to delay. + +Returns: + NONE + +--*/ +{ + UINT8 Data; + UINT8 InitialState; + UINTN CycleIterations; + + CycleIterations = 0; + Data = 0; + InitialState = 0; + + if (EfiAtRuntime ()) { + // + // The time-source is 30 us granular, so calibrate the timing loop + // based on this baseline + // Error is possible 30us. + // + CycleIterations = (Microseconds - 1) / 30 + 1; + + // + // Use the DMA Refresh timer in port 0x61. Cheap but effective. + // The only issue is that the granularity is 30us, and we want to + // guarantee "at least" one full transition to avoid races. + // + // + // _____________/----------\__________/-------- + // + // |<--15us-->|<--15us-->| + // + // --------------------------------------------------> Time (us) + // + while (CycleIterations--) { + EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data); + Data &= REFRESH_CYCLE_TOGGLE_BIT; + InitialState = Data; + + // + // Capture first transition (strictly less than one period) + // + while (InitialState == Data) { + EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data); + Data &= REFRESH_CYCLE_TOGGLE_BIT; + } + + InitialState = Data; + // + // Capture next transition (guarantee at least one full pulse) + // + while (InitialState == Data) { + EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data); + Data &= REFRESH_CYCLE_TOGGLE_BIT; + } + } + } else { + gBS->Stall (Microseconds); + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c new file mode 100644 index 0000000000..d1a9080bf8 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c @@ -0,0 +1,842 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RuntimeLib.c + +Abstract: + + Light weight lib to support Tiano drivers. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) + +// +// Driver Lib Module Globals +// +static EFI_RUNTIME_SERVICES *mRT; +static EFI_EVENT mRuntimeNotifyEvent = NULL; +static EFI_EVENT mEfiVirtualNotifyEvent = NULL; +static BOOLEAN mRuntimeLibInitialized = FALSE; +static BOOLEAN mEfiGoneVirtual = FALSE; + +// +// Runtime Global, but you should use the Lib functions +// +EFI_CPU_IO_PROTOCOL *gCpuIo; +BOOLEAN mEfiAtRuntime = FALSE; +FVB_ENTRY *mFvbEntry; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL; +#endif + +EFI_STATUS +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return mRT->ConvertPointer (DebugDisposition, Address); +} + +EFI_STATUS +EfiConvertInternalPointer ( + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Call EfiConvertPointer() to convert internal pointer. + +Arguments: + + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return EfiConvertPointer (EFI_INTERNAL_POINTER, Address); +} + +VOID +EFIAPI +EfiRuntimeLibFvbVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Convert all pointers in mFvbEntry after ExitBootServices. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + UINTN Index; + if (mFvbEntry != NULL) { + for (Index = 0; Index < MAX_FVB_COUNT; Index++) { + if (NULL != mFvbEntry[Index].Fvb) { + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb); + } + + if (NULL != mFvbEntry[Index].FvbExtension) { + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension); + } + } + + EfiConvertInternalPointer ((VOID **) &mFvbEntry); + } +} + +VOID +EFIAPI +RuntimeDriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Set AtRuntime flag as TRUE after ExitBootServices + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + mEfiAtRuntime = TRUE; +} + +extern BOOLEAN gEfiFvbInitialized; + +VOID +EFIAPI +EfiRuntimeLibVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + EFI_EVENT_NOTIFY ChildNotifyEventHandler; + + if (Context != NULL) { + ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context; + ChildNotifyEventHandler (Event, NULL); + } + + if (gEfiFvbInitialized) { + EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context); + } + // + // Update global for Runtime Services Table and IO + // + EfiConvertInternalPointer ((VOID **) &gCpuIo); +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + if (gStatusCode != NULL) { + EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode); + EfiConvertInternalPointer ((VOID **) &gStatusCode); + } +#endif + EfiConvertInternalPointer ((VOID **) &mRT); + + // + // Clear out BootService globals + // + gBS = NULL; + gST = NULL; + mEfiGoneVirtual = TRUE; +} + +EFI_STATUS +EfiInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY GoVirtualChildEvent + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + GoVirtualChildEvent - Caller can register a virtual notification event. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + + if (mRuntimeLibInitialized) { + return EFI_ALREADY_STARTED; + } + + mRuntimeLibInitialized = TRUE; + + gST = SystemTable; + ASSERT (gST != NULL); + + gBS = SystemTable->BootServices; + ASSERT (gBS != NULL); + mRT = SystemTable->RuntimeServices; + ASSERT (mRT != NULL); + + Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); + ASSERT_EFI_ERROR (Status); + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status)) { + gStatusCode = NULL; + } +#endif + + Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo); + if (EFI_ERROR (Status)) { + gCpuIo = NULL; + } + + // + // Register our ExitBootServices () notify function + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + EFI_TPL_NOTIFY, + RuntimeDriverExitBootServices, + NULL, + &mRuntimeNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Register SetVirtualAddressMap () notify function + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + EFI_TPL_NOTIFY, + EfiRuntimeLibVirtualNotifyEvent, + (VOID *) (UINTN) GoVirtualChildEvent, + &mEfiVirtualNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiShutdownRuntimeDriverLib ( + VOID + ) +/*++ + +Routine Description: + + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully + EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all + +--*/ +{ + EFI_STATUS Status; + + if (!mRuntimeLibInitialized) { + // + // You must call EfiInitializeRuntimeDriverLib() first + // + return EFI_UNSUPPORTED; + } + + mRuntimeLibInitialized = FALSE; + + // + // Close our ExitBootServices () notify function + // + if (mRuntimeNotifyEvent != NULL) { + Status = gBS->CloseEvent (mRuntimeNotifyEvent); + ASSERT_EFI_ERROR (Status); + } + + // + // Close SetVirtualAddressMap () notify function + // + if (mEfiVirtualNotifyEvent != NULL) { + Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiInitializeSmmDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + + if (mRuntimeLibInitialized) { + return EFI_ALREADY_STARTED; + } + + mRuntimeLibInitialized = TRUE; + + gST = SystemTable; + ASSERT (gST != NULL); + + gBS = SystemTable->BootServices; + ASSERT (gBS != NULL); + mRT = SystemTable->RuntimeServices; + ASSERT (mRT != NULL); + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status)) { + gStatusCode = NULL; + } +#endif + + Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo); + if (EFI_ERROR (Status)) { + gCpuIo = NULL; + } + + return EFI_SUCCESS; +} + +BOOLEAN +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if ExitBootServices () has been called + +Arguments: + NONE + +Returns: + TRUE - If ExitBootServices () has been called + +--*/ +{ + return mEfiAtRuntime; +} + +BOOLEAN +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + +--*/ +{ + return mEfiGoneVirtual; +} +// +// The following functions hide the mRT local global from the call to +// runtime service in the EFI system table. +// +EFI_STATUS +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + +Returns: + + Status code + +--*/ +{ + return mRT->GetTime (Time, Capabilities); +} + +EFI_STATUS +EfiSetTime ( + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +{ + return mRT->SetTime (Time); +} + +EFI_STATUS +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +{ + return mRT->GetWakeupTime (Enabled, Pending, Time); +} + +EFI_STATUS +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +{ + return mRT->SetWakeupTime (Enable, Time); +} + +EFI_STATUS +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +/*++ + +Routine Description: + + Returns the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - If not NULL, a pointer to the memory location to return the + attributes bitmask for the variable. + DataSize - On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + Data - The buffer to return the contents of the variable. + +Returns: + + Status code + +--*/ +{ + return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + +EFI_STATUS +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +/*++ + +Routine Description: + + Enumerates the current variable names. + +Arguments: + + VariableNameSize - The size of the VariableName buffer. + VariableName - On input, supplies the last VariableName that was returned + by GetNextVariableName(). + On output, returns the Nullterminated Unicode string of the + current variable. + VendorGuid - On input, supplies the last VendorGuid that was returned by + GetNextVariableName(). + On output, returns the VendorGuid of the current variable. + +Returns: + + Status code + +--*/ +{ + return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid); +} + +EFI_STATUS +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ) +/*++ + +Routine Description: + + Sets the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - Attributes bitmask to set for the variable. + DataSize - The size in bytes of the Data buffer. + Data - The contents for the variable. + +Returns: + + Status code + +--*/ +{ + return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +EFI_STATUS +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) + +/*++ + +Routine Description: + + This code returns information about the EFI variables. + +Arguments: + + Attributes Attributes bitmask to specify the type of variables + on which to return information. + MaximumVariableStorageSize Pointer to the maximum size of the storage space available + for the EFI variables associated with the attributes specified. + RemainingVariableStorageSize Pointer to the remaining size of the storage space available + for the EFI variables associated with the attributes specified. + MaximumVariableSize Pointer to the maximum size of the individual EFI variables + associated with the attributes specified. + +Returns: + + Status code + +--*/ +{ + return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize); +} + +#endif + +EFI_STATUS +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Returns the next high 32 bits of the platform¡¯s monotonic counter. + +Arguments: + + HighCount - Pointer to returned value. + +Returns: + + Status code + +--*/ +{ + return mRT->GetNextHighMonotonicCount (HighCount); +} + +VOID +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Resets the entire platform. + +Arguments: + + ResetType - The type of reset to perform. + ResetStatus - The status code for the reset. + DataSize - The size, in bytes, of ResetData. + ResetData - A data buffer that includes a Null-terminated Unicode string, optionally + followed by additional binary data. + +Returns: + + None + +--*/ +{ + mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData); +} + +EFI_STATUS +EfiReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + if (gStatusCode == NULL) { + return EFI_UNSUPPORTED; + } + Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data); +#else + if (mRT == NULL) { + return EFI_UNSUPPORTED; + } + // + // Check whether EFI_RUNTIME_SERVICES has Tiano Extension + // + Status = EFI_UNSUPPORTED; + if (mRT->Hdr.Revision == EFI_SPECIFICATION_VERSION && + mRT->Hdr.HeaderSize == sizeof (EFI_RUNTIME_SERVICES) && + mRT->ReportStatusCode != NULL) { + Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data); + } +#endif + return Status; +} +// +// Cache Flush Routine. +// +EFI_STATUS +EfiCpuFlushCache ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Flush cache with specified range. + +Arguments: + + Start - Start address + Length - Length in bytes + +Returns: + + Status code + + EFI_SUCCESS - success + +--*/ +{ + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c new file mode 100644 index 0000000000..de151cdda0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c @@ -0,0 +1,620 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Fvb.c + +Abstract: + + Firmware Volume Block Protocol Runtime Abstraction + + mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the + index in the mFvbEntry array. This should be the same sequence as the FVB's + were described in the HOB. We have to remember the handle so we can tell if + the protocol has been reinstalled and it needs updateing. + + If you are using any of these lib functions.you must first call FvbInitialize (). + +Key: + FVB - Firmware Volume Block + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_PROTOCOL_DEFINITION (FvbExtension) + +// +// Lib will ASSERT if more FVB devices than this are added to the system. +// +UINTN mFvbCount; +VOID *mFvbRegistration; +VOID *mFvbExtRegistration; +static EFI_EVENT mEfiFvbVirtualNotifyEvent; +BOOLEAN gEfiFvbInitialized = FALSE; +EFI_EVENT mFvbEvent; + +BOOLEAN +IsMemoryRuntime ( + IN VOID *Address + ) +/*++ + +Routine Description: + Check whether an address is runtime memory or not. + +Arguments: + + Address - The Address being checked. + +Returns: + TRUE - The address is runtime memory. + FALSE - The address is not runtime memory. + +--*/ +{ + EFI_STATUS Status; + UINT8 TmpMemoryMap[1]; + UINTN MapKey; + UINTN DescriptorSize; + UINT32 DescriptorVersion; + UINTN MemoryMapSize; + EFI_MEMORY_DESCRIPTOR *MemoryMap; + EFI_MEMORY_DESCRIPTOR *MemoryMapPtr; + BOOLEAN IsRuntime; + UINTN Index; + + IsRuntime = FALSE; + + // + // Get System MemoryMapSize + // + MemoryMapSize = 1; + Status = gBS->GetMemoryMap ( + &MemoryMapSize, + (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap, + &MapKey, + &DescriptorSize, + &DescriptorVersion + ); + ASSERT (Status == EFI_BUFFER_TOO_SMALL); + // + // Enlarge space here, because we will allocate pool now. + // + MemoryMapSize += EFI_PAGE_SIZE; + Status = gBS->AllocatePool ( + EfiBootServicesData, + MemoryMapSize, + (VOID**)&MemoryMap + ); + ASSERT_EFI_ERROR (Status); + + // + // Get System MemoryMap + // + Status = gBS->GetMemoryMap ( + &MemoryMapSize, + MemoryMap, + &MapKey, + &DescriptorSize, + &DescriptorVersion + ); + ASSERT_EFI_ERROR (Status); + + MemoryMapPtr = MemoryMap; + // + // Search the request Address + // + for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) { + if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) && + ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart + + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) { + // + // Found it + // + if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) { + IsRuntime = TRUE; + } + break; + } + // + // Get next item + // + MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize); + } + + // + // Done + // + gBS->FreePool (MemoryMapPtr); + + return IsRuntime; +} + +VOID +EFIAPI +FvbNotificationFunction ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is + reinstalled. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + None + +--*/ +{ + EFI_STATUS Status; + UINTN BufferSize; + EFI_HANDLE Handle; + UINTN Index; + UINTN UpdateIndex; + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; + EFI_FVB_EXTENSION_PROTOCOL *FvbExtension; + + while (TRUE) { + BufferSize = sizeof (Handle); + Status = gBS->LocateHandle ( + ByRegisterNotify, + &gEfiFirmwareVolumeBlockProtocolGuid, + mFvbRegistration, + &BufferSize, + &Handle + ); + if (EFI_ERROR (Status)) { + // + // Exit Path of While Loop.... + // + break; + } + + UpdateIndex = MAX_FVB_COUNT; + for (Index = 0; Index < mFvbCount; Index++) { + if (mFvbEntry[Index].Handle == Handle) { + // + // If the handle is already in the table just update the protocol + // + UpdateIndex = Index; + break; + } + } + + if (UpdateIndex == MAX_FVB_COUNT) { + // + // Use the next free slot for a new entry + // + UpdateIndex = mFvbCount; + } + // + // The array does not have enough entries + // + ASSERT (UpdateIndex < MAX_FVB_COUNT); + + // + // Get the interface pointer and if it's ours, skip it. + // We check Runtime here, because it has no reason to register + // a boot time FVB protocol. + // + Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &Fvb); + ASSERT_EFI_ERROR (Status); + if (IsMemoryRuntime (Fvb)) { + // + // Increase mFvbCount if we need to add a new entry + // + if (UpdateIndex == mFvbCount) { + mFvbCount++; + } + mFvbEntry[UpdateIndex].Handle = Handle; + mFvbEntry[UpdateIndex].Fvb = Fvb; + mFvbEntry[UpdateIndex].FvbExtension = NULL; + + Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, &FvbExtension); + if ((Status == EFI_SUCCESS) && IsMemoryRuntime (FvbExtension)) { + mFvbEntry[UpdateIndex].FvbExtension = FvbExtension; + } + } + } +} + +EFI_STATUS +EfiFvbInitialize ( + VOID + ) +/*++ + +Routine Description: + Initialize globals and register Fvb Protocol notification function. + +Arguments: + None + +Returns: + EFI_SUCCESS - Fvb is successfully initialized + others - Fail to initialize + +--*/ +{ + UINTN Status; + mFvbCount = 0; + + Status = gBS->AllocatePool ( + EfiRuntimeServicesData, + (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT, + (VOID *) &mFvbEntry + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + EfiZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT); + + mFvbEvent = RtEfiLibCreateProtocolNotifyEvent ( + &gEfiFirmwareVolumeBlockProtocolGuid, + EFI_TPL_CALLBACK, + FvbNotificationFunction, + NULL, + &mFvbRegistration + ); + + // + // Register SetVirtualAddressMap () notify function + // + // Status = gBS->CreateEvent ( + // EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + // EFI_TPL_NOTIFY, + // EfiRuntimeLibFvbVirtualNotifyEvent, + // NULL, + // &mEfiFvbVirtualNotifyEvent + // ); + // ASSERT_EFI_ERROR (Status); + // + gEfiFvbInitialized = TRUE; + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiFvbShutdown ( + VOID + ) +/*++ + +Routine Description: + Release resources allocated in EfiFvbInitialize. + +Arguments: + None + +Returns: + EFI_SUCCESS + +--*/ +{ + gBS->FreePool ((VOID *) mFvbEntry); + + gBS->CloseEvent (mFvbEvent); + + gEfiFvbInitialized = FALSE; + + return EFI_SUCCESS; +} + +// +// The following functions wrap Fvb protocol in the Runtime Lib functions. +// The Instance translates into Fvb instance. The Fvb order defined by HOBs and +// thus the sequence of FVB protocol addition define Instance. +// +// EfiFvbInitialize () must be called before any of the following functions +// must be called. +// + +EFI_STATUS +EfiFvbReadBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Reads specified number of bytes into a buffer from the specified block + +Arguments: + Instance - The FV instance to be read from + Lba - The logical block address to be read from + Offset - Offset into the block at which to begin reading + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes read + Buffer - Pointer to a caller allocated buffer that will be + used to hold the data read + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer); +} + +EFI_STATUS +EfiFvbWriteBlock ( + IN UINTN Instance, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ) +/*++ + +Routine Description: + Writes specified number of bytes from the input buffer to the block + +Arguments: + Instance - The FV instance to be written to + Lba - The starting logical block index to write to + Offset - Offset into the block at which to begin writing + NumBytes - Pointer that on input contains the total size of + the buffer. On output, it contains the total number + of bytes actually written + Buffer - Pointer to a caller allocated buffer that contains + the source for the write + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer); +} + +EFI_STATUS +EfiFvbEraseBlock ( + IN UINTN Instance, + IN EFI_LBA Lba + ) +/*++ + +Routine Description: + Erases and initializes a firmware volume block + +Arguments: + Instance - The FV instance to be erased + Lba - The logical block index to be erased + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, -1); +} + +EFI_STATUS +EfiFvbGetVolumeAttributes ( + IN UINTN Instance, + OUT EFI_FVB_ATTRIBUTES *Attributes + ) +/*++ + +Routine Description: + Retrieves attributes, insures positive polarity of attribute bits, returns + resulting attributes in output parameter + +Arguments: + Instance - The FV instance whose attributes is going to be + returned + Attributes - Output buffer which contains attributes + +Returns: + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->GetVolumeAttributes (mFvbEntry[Instance].Fvb, Attributes); +} + +EFI_STATUS +EfiFvbSetVolumeAttributes ( + IN UINTN Instance, + IN EFI_FVB_ATTRIBUTES Attributes + ) +/*++ + +Routine Description: + Modifies the current settings of the firmware volume according to the + input parameter, and returns the new setting of the volume + +Arguments: + Instance - The FV instance whose attributes is going to be + modified + Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES + containing the desired firmware volume settings. + On successful return, it contains the new settings + of the firmware volume + +Returns: + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->SetVolumeAttributes (mFvbEntry[Instance].Fvb, &Attributes); +} + +EFI_STATUS +EfiFvbGetPhysicalAddress ( + IN UINTN Instance, + OUT EFI_PHYSICAL_ADDRESS *BaseAddress + ) +/*++ + +Routine Description: + Retrieves the physical address of a memory mapped FV + +Arguments: + Instance - The FV instance whose base address is going to be + returned + BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS + that on successful return, contains the base address + of the firmware volume. + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress); +} + +EFI_STATUS +EfiFvbGetBlockSize ( + IN UINTN Instance, + IN EFI_LBA Lba, + OUT UINTN *BlockSize, + OUT UINTN *NumOfBlocks + ) +/*++ + +Routine Description: + Retrieve the size of a logical block + +Arguments: + Instance - The FV instance whose block size is going to be + returned + Lba - Indicates which block to return the size for. + BlockSize - A pointer to a caller allocated UINTN in which + the size of the block is returned + NumOfBlocks - a pointer to a caller allocated UINTN in which the + number of consecutive blocks starting with Lba is + returned. All blocks in this range have a size of + BlockSize + +Returns: + EFI_SUCCESS - The firmware volume was read successfully and + contents are in Buffer + + EFI_INVALID_PARAMETER - invalid parameter + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks); +} + +EFI_STATUS +EfiFvbEraseCustomBlockRange ( + IN UINTN Instance, + IN EFI_LBA StartLba, + IN UINTN OffsetStartLba, + IN EFI_LBA LastLba, + IN UINTN OffsetLastLba + ) +/*++ + +Routine Description: + Erases and initializes a specified range of a firmware volume + +Arguments: + Instance - The FV instance to be erased + StartLba - The starting logical block index to be erased + OffsetStartLba - Offset into the starting block at which to + begin erasing + LastLba - The last logical block index to be erased + OffsetLastLba - Offset into the last block at which to end erasing + +Returns: + + Status code + + EFI_INVALID_PARAMETER - invalid parameter + + EFI_UNSUPPORTED - not support + +--*/ +{ + if (Instance >= mFvbCount) { + return EFI_INVALID_PARAMETER; + } + + if (!(mFvbEntry[Instance].FvbExtension)) { + return EFI_UNSUPPORTED; + } + + if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) { + return EFI_UNSUPPORTED; + } + + return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock ( + mFvbEntry[Instance].FvbExtension, + StartLba, + OffsetStartLba, + LastLba, + OffsetLastLba + ); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c new file mode 100644 index 0000000000..bb244ce3d0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c @@ -0,0 +1,130 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IoLib.c + +Abstract: + + Light weight lib to support Tiano drivers. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (CpuIo) + +extern EFI_CPU_IO_PROTOCOL *gCpuIo; + +EFI_STATUS +EfiIoRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO read into Buffer. + +Arguments: + Width - Width of read transaction, and repeat operation to use + Address - IO address to read + Count - Number of times to read the IO address. + Buffer - Buffer to read data into. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Io.Read (gCpuIo, Width, Address, Count, Buffer); +} + +EFI_STATUS +EfiIoWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform an IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Io.Write (gCpuIo, Width, Address, Count, Buffer); +} + +EFI_STATUS +EfiMemRead ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a Memory mapped IO read into Buffer. + +Arguments: + Width - Width of each read transaction. + Address - Memory mapped IO address to read + Count - Number of Width quanta to read + Buffer - Buffer to read data into. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Mem.Read (gCpuIo, Width, Address, Count, Buffer); +} + +EFI_STATUS +EfiMemWrite ( + IN EFI_CPU_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + Perform a memory mapped IO write into Buffer. + +Arguments: + Width - Width of write transaction, and repeat operation to use + Address - IO address to write + Count - Number of times to write the IO address. + Buffer - Buffer to write data from. size is Width * Count + +Returns: + BugBug: Check with Mike to see if I can find this #define some ware else + +--*/ +{ + return gCpuIo->Mem.Write (gCpuIo, Width, Address, Count, Buffer); +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c new file mode 100644 index 0000000000..d815d0c206 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c @@ -0,0 +1,177 @@ +/*++ + +Copyright (c) 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Lock.c + +Abstract: + + Support for locking lib services. + +--*/ + +#include "Tiano.h" +#include "EfiDriverLib.h" + +extern +BOOLEAN +EfiAtRuntime ( + VOID + ); + +VOID +EfiInitializeLock ( + IN OUT EFI_LOCK *Lock, + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + Note on a check build ASSERT()s are used to ensure proper + lock usage. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + + Priority - The task priority level of the lock + + +Returns: + + An initialized Efi Lock structure. + +--*/ +{ + Lock->Tpl = Priority; + Lock->OwnerTpl = 0; + Lock->Lock = 0; +} + +EFI_STATUS +EfiAcquireLockOrFail ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + +Arguments: + + Lock - The EFI_LOCK structure to initialize + +Returns: + + EFI_SUCCESS - Lock Owned. + EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned. + +--*/ +{ + if (Lock->Lock != 0) { + // + // Lock is already owned, so bail out + // + return EFI_ACCESS_DENIED; + } + + if (!EfiAtRuntime ()) { + // + // The check is just debug code for core inplementation. It must + // always be true in a driver + // + Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl); + } + + Lock->Lock += 1; + return EFI_SUCCESS; +} + +VOID +EfiAcquireLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + +Arguments: + + Lock - The lock to acquire + +Returns: + + Lock owned + +--*/ +{ + EFI_STATUS Status; + + Status = EfiAcquireLockOrFail (Lock); + + // + // Lock was already locked. + // + ASSERT_EFI_ERROR (Status); +} + +VOID +EfiReleaseLock ( + IN EFI_LOCK *Lock + ) +/*++ + +Routine Description: + + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + +Arguments: + + Lock - The lock to release + +Returns: + + Lock unowned + +--*/ +{ + EFI_TPL Tpl; + + Tpl = Lock->OwnerTpl; + + ASSERT (Lock->Lock == 1); + Lock->Lock -= 1; + + if (!EfiAtRuntime ()) { + // + // The check is just debug code for core inplementation. It must + // always be true in a driver + // + gBS->RestoreTPL (Tpl); + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c new file mode 100644 index 0000000000..c85de471b9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c @@ -0,0 +1,409 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PlatformIoLib.c + +Abstract: + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (CpuIo) + +#define PCI_CONFIG_INDEX_PORT 0xcf8 +#define PCI_CONFIG_DATA_PORT 0xcfc +#define REFRESH_CYCLE_TOGGLE_BIT 0x10 + +UINT32 +GetPciAddress ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Constructs PCI Address 32 bits + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + PciAddress to be written to Config Port + +--*/ +{ + UINT32 Data; + + Data = 0; + + Data = (((UINT32) Segment) << 24); + Data |= (((UINT32) Bus) << 16); + Data |= (((UINT32) DevFunc) << 8); + Data |= (UINT32) Register; + + return Data; + +} + +UINT8 +PciRead8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + UINT8 Data; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return 0; + } + + EfiIoRead (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); + + return Data; +} + +UINT16 +PciRead16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + UINT16 Data; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return 0; + } + + EfiIoRead (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); + + return Data; +} + +UINT32 +PciRead32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle read + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + +Returns: + Data read from PCI config space + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + UINT32 Data; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return 0; + } + + EfiIoRead (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); + + return Data; +} + +VOID +PciWrite8 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT8 Data + ) +/*++ + +Routine Description: + Perform an one byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return ; + } + + EfiIoWrite (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); +} + +VOID +PciWrite16 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT16 Data + ) +/*++ + +Routine Description: + Perform an two byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return ; + } + + EfiIoWrite (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); +} + +VOID +PciWrite32 ( + UINT8 Segment, + UINT8 Bus, + UINT8 DevFunc, + UINT8 Register, + UINT32 Data + ) +/*++ + +Routine Description: + Perform an four byte PCI config cycle write + +Arguments: + Segment - PCI Segment ACPI _SEG + Bus - PCI Bus + DevFunc - PCI Device(7:3) and Func(2:0) + Register - PCI config space register + Data - Data to write + +Returns: + NONE + +--*/ +{ + EFI_STATUS Status; + UINT32 PciAddress; + UINT32 PciAddress1; + + PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register); + // + // Set bit 31 for PCI config access + // + PciAddress1 = PciAddress; + PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000)); + + Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress); + + if (EFI_ERROR (Status)) { + return ; + } + + EfiIoWrite (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data); +} +// +// Delay Primative +// +VOID +EfiStall ( + IN UINTN Microseconds + ) +/*++ + +Routine Description: + Delay for at least the request number of microseconds + +Arguments: + Microseconds - Number of microseconds to delay. + +Returns: + NONE + +--*/ +{ + UINT8 Data; + UINT8 InitialState; + UINTN CycleIterations; + + CycleIterations = 0; + Data = 0; + InitialState = 0; + + if (EfiAtRuntime ()) { + // + // The time-source is 30 us granular, so calibrate the timing loop + // based on this baseline + // Error is possible 30us. + // + CycleIterations = (Microseconds - 1) / 30 + 1; + + // + // Use the DMA Refresh timer in port 0x61. Cheap but effective. + // The only issue is that the granularity is 30us, and we want to + // guarantee "at least" one full transition to avoid races. + // + // + // _____________/----------\__________/-------- + // + // |<--15us-->|<--15us-->| + // + // --------------------------------------------------> Time (us) + // + while (CycleIterations--) { + EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data); + Data &= REFRESH_CYCLE_TOGGLE_BIT; + InitialState = Data; + + // + // Capture first transition (strictly less than one period) + // + while (InitialState == Data) { + EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data); + Data &= REFRESH_CYCLE_TOGGLE_BIT; + } + + InitialState = Data; + // + // Capture next transition (guarantee at least one full pulse) + // + while (InitialState == Data) { + EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data); + Data &= REFRESH_CYCLE_TOGGLE_BIT; + } + } + } else { + gBS->Stall (Microseconds); + } +} diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c new file mode 100644 index 0000000000..d9d5f70f46 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c @@ -0,0 +1,843 @@ +/*++ + +Copyright (c) 2005 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + RuntimeLib.c + +Abstract: + + Light weight lib to support Tiano drivers. + +--*/ + +#include "Tiano.h" +#include "EfiRuntimeLib.h" +#include EFI_PROTOCOL_DEFINITION (CpuIo) +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock) +#include EFI_GUID_DEFINITION (StatusCodeCallerId) +#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) + +// +// Driver Lib Module Globals +// +static EFI_RUNTIME_SERVICES *mRT; +static EFI_EVENT mRuntimeNotifyEvent = NULL; +static EFI_EVENT mEfiVirtualNotifyEvent = NULL; +static BOOLEAN mRuntimeLibInitialized = FALSE; +static BOOLEAN mEfiGoneVirtual = FALSE; + +// +// Runtime Global, but you should use the Lib functions +// +EFI_CPU_IO_PROTOCOL *gCpuIo; +BOOLEAN mEfiAtRuntime = FALSE; +FVB_ENTRY *mFvbEntry; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) +static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL; +#endif + +EFI_STATUS +EfiConvertPointer ( + IN UINTN DebugDisposition, + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Determines the new virtual address that is to be used on subsequent memory accesses. + +Arguments: + + DebugDisposition - Supplies type information for the pointer being converted. + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return mRT->ConvertPointer (DebugDisposition, Address); +} + +EFI_STATUS +EfiConvertInternalPointer ( + IN OUT VOID *Address + ) +/*++ + +Routine Description: + + Call EfiConvertPointer() to convert internal pointer. + +Arguments: + + Address - A pointer to a pointer that is to be fixed to be the value needed + for the new virtual address mappings being applied. + +Returns: + + Status code + +--*/ +{ + return EfiConvertPointer (EFI_INTERNAL_POINTER, Address); +} + +VOID +EFIAPI +EfiRuntimeLibFvbVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Convert all pointers in mFvbEntry after ExitBootServices. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + UINTN Index; + if (mFvbEntry != NULL) { + for (Index = 0; Index < MAX_FVB_COUNT; Index++) { + if (NULL != mFvbEntry[Index].Fvb) { + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb); + } + + if (NULL != mFvbEntry[Index].FvbExtension) { + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock); + EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension); + } + } + + EfiConvertInternalPointer ((VOID **) &mFvbEntry); + } +} + +VOID +EFIAPI +RuntimeDriverExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Set AtRuntime flag as TRUE after ExitBootServices + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + mEfiAtRuntime = TRUE; +} + +extern BOOLEAN gEfiFvbInitialized; + +VOID +EFIAPI +EfiRuntimeLibVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +/*++ + +Routine Description: + + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + +Arguments: + + Event - The Event that is being processed + + Context - Event Context + +Returns: + + None + +--*/ +{ + EFI_EVENT_NOTIFY ChildNotifyEventHandler; + + if (Context != NULL) { + ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context; + ChildNotifyEventHandler (Event, NULL); + } + + if (gEfiFvbInitialized) { + EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context); + } + // + // Update global for Runtime Services Table and IO + // + EfiConvertInternalPointer ((VOID **) &gCpuIo); +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + if (gStatusCode != NULL) { + EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode); + EfiConvertInternalPointer ((VOID **) &gStatusCode); + } +#endif + EfiConvertInternalPointer ((VOID **) &mRT); + + // + // Clear out BootService globals + // + gBS = NULL; + gST = NULL; + mEfiGoneVirtual = TRUE; +} + +EFI_STATUS +EfiInitializeRuntimeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_EVENT_NOTIFY GoVirtualChildEvent + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + + GoVirtualChildEvent - Caller can register a virtual notification event. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + + if (mRuntimeLibInitialized) { + return EFI_ALREADY_STARTED; + } + + mRuntimeLibInitialized = TRUE; + + gST = SystemTable; + ASSERT (gST != NULL); + + gBS = SystemTable->BootServices; + ASSERT (gBS != NULL); + mRT = SystemTable->RuntimeServices; + ASSERT (mRT != NULL); + + Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); + ASSERT_EFI_ERROR (Status); + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status)) { + gStatusCode = NULL; + } +#endif + + Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo); + if (EFI_ERROR (Status)) { + gCpuIo = NULL; + } + + // + // Register our ExitBootServices () notify function + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + EFI_TPL_NOTIFY, + RuntimeDriverExitBootServices, + NULL, + &mRuntimeNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Register SetVirtualAddressMap () notify function + // + Status = gBS->CreateEvent ( + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + EFI_TPL_NOTIFY, + EfiRuntimeLibVirtualNotifyEvent, + (VOID *) (UINTN) GoVirtualChildEvent, + &mEfiVirtualNotifyEvent + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiShutdownRuntimeDriverLib ( + VOID + ) +/*++ + +Routine Description: + + This routine will free some resources which have been allocated in + EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, + it must call this routine to free the allocated resource before the exiting. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully + EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all + +--*/ +{ + EFI_STATUS Status; + + if (!mRuntimeLibInitialized) { + // + // You must call EfiInitializeRuntimeDriverLib() first + // + return EFI_UNSUPPORTED; + } + + mRuntimeLibInitialized = FALSE; + + // + // Close our ExitBootServices () notify function + // + if (mRuntimeNotifyEvent != NULL) { + Status = gBS->CloseEvent (mRuntimeNotifyEvent); + ASSERT_EFI_ERROR (Status); + } + + // + // Close SetVirtualAddressMap () notify function + // + if (mEfiVirtualNotifyEvent != NULL) { + Status = gBS->CloseEvent (mEfiVirtualNotifyEvent); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EfiInitializeSmmDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize runtime Driver Lib if it has not yet been initialized. + +Arguments: + + ImageHandle - The firmware allocated handle for the EFI image. + + SystemTable - A pointer to the EFI System Table. + +Returns: + + EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started. + +--*/ +{ + EFI_STATUS Status; + + if (mRuntimeLibInitialized) { + return EFI_ALREADY_STARTED; + } + + mRuntimeLibInitialized = TRUE; + + gST = SystemTable; + ASSERT (gST != NULL); + + gBS = SystemTable->BootServices; + ASSERT (gBS != NULL); + mRT = SystemTable->RuntimeServices; + ASSERT (mRT != NULL); + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode); + if (EFI_ERROR (Status)) { + gStatusCode = NULL; + } +#endif + + Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo); + if (EFI_ERROR (Status)) { + gCpuIo = NULL; + } + + return EFI_SUCCESS; +} + +BOOLEAN +EfiAtRuntime ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if ExitBootServices () has been called + +Arguments: + NONE + +Returns: + TRUE - If ExitBootServices () has been called + +--*/ +{ + return mEfiAtRuntime; +} + +BOOLEAN +EfiGoneVirtual ( + VOID + ) +/*++ + +Routine Description: + Return TRUE if SetVirtualAddressMap () has been called + +Arguments: + NONE + +Returns: + TRUE - If SetVirtualAddressMap () has been called + +--*/ +{ + return mEfiGoneVirtual; +} +// +// The following functions hide the mRT local global from the call to +// runtime service in the EFI system table. +// +EFI_STATUS +EfiGetTime ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities + ) +/*++ + +Routine Description: + + Returns the current time and date information, and the time-keeping + capabilities of the hardware platform. + +Arguments: + + Time - A pointer to storage to receive a snapshot of the current time. + Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s + capabilities. + +Returns: + + Status code + +--*/ +{ + return mRT->GetTime (Time, Capabilities); +} + +EFI_STATUS +EfiSetTime ( + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the current local time and date information. + +Arguments: + + Time - A pointer to the current time. + +Returns: + + Status code + +--*/ +{ + return mRT->SetTime (Time); +} + +EFI_STATUS +EfiGetWakeupTime ( + OUT BOOLEAN *Enabled, + OUT BOOLEAN *Pending, + OUT EFI_TIME *Time + ) +/*++ + +Routine Description: + + Returns the current wakeup alarm clock setting. + +Arguments: + + Enabled - Indicates if the alarm is currently enabled or disabled. + Pending - Indicates if the alarm signal is pending and requires acknowledgement. + Time - The current alarm setting. + +Returns: + + Status code + +--*/ +{ + return mRT->GetWakeupTime (Enabled, Pending, Time); +} + +EFI_STATUS +EfiSetWakeupTime ( + IN BOOLEAN Enable, + IN EFI_TIME *Time + ) +/*++ + +Routine Description: + + Sets the system wakeup alarm clock time. + +Arguments: + + Enable - Enable or disable the wakeup alarm. + Time - If Enable is TRUE, the time to set the wakeup alarm for. + If Enable is FALSE, then this parameter is optional, and may be NULL. + +Returns: + + Status code + +--*/ +{ + return mRT->SetWakeupTime (Enable, Time); +} + +EFI_STATUS +EfiGetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID * VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data + ) +/*++ + +Routine Description: + + Returns the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - If not NULL, a pointer to the memory location to return the + attributes bitmask for the variable. + DataSize - On input, the size in bytes of the return Data buffer. + On output the size of data returned in Data. + Data - The buffer to return the contents of the variable. + +Returns: + + Status code + +--*/ +{ + return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + +EFI_STATUS +EfiGetNextVariableName ( + IN OUT UINTN *VariableNameSize, + IN OUT CHAR16 *VariableName, + IN OUT EFI_GUID *VendorGuid + ) +/*++ + +Routine Description: + + Enumerates the current variable names. + +Arguments: + + VariableNameSize - The size of the VariableName buffer. + VariableName - On input, supplies the last VariableName that was returned + by GetNextVariableName(). + On output, returns the Nullterminated Unicode string of the + current variable. + VendorGuid - On input, supplies the last VendorGuid that was returned by + GetNextVariableName(). + On output, returns the VendorGuid of the current variable. + +Returns: + + Status code + +--*/ +{ + return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid); +} + +EFI_STATUS +EfiSetVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data + ) +/*++ + +Routine Description: + + Sets the value of a variable. + +Arguments: + + VariableName - A Null-terminated Unicode string that is the name of the + vendor¡¯s variable. + VendorGuid - A unique identifier for the vendor. + Attributes - Attributes bitmask to set for the variable. + DataSize - The size in bytes of the Data buffer. + Data - The contents for the variable. + +Returns: + + Status code + +--*/ +{ + return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); +} + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + +EFI_STATUS +EfiQueryVariableInfo ( + IN UINT32 Attributes, + OUT UINT64 *MaximumVariableStorageSize, + OUT UINT64 *RemainingVariableStorageSize, + OUT UINT64 *MaximumVariableSize + ) + +/*++ + +Routine Description: + + This code returns information about the EFI variables. + +Arguments: + + Attributes Attributes bitmask to specify the type of variables + on which to return information. + MaximumVariableStorageSize Pointer to the maximum size of the storage space available + for the EFI variables associated with the attributes specified. + RemainingVariableStorageSize Pointer to the remaining size of the storage space available + for the EFI variables associated with the attributes specified. + MaximumVariableSize Pointer to the maximum size of the individual EFI variables + associated with the attributes specified. + +Returns: + + Status code + +--*/ +{ + return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize); +} + +#endif + + +EFI_STATUS +EfiGetNextHighMonotonicCount ( + OUT UINT32 *HighCount + ) +/*++ + +Routine Description: + + Returns the next high 32 bits of the platform¡¯s monotonic counter. + +Arguments: + + HighCount - Pointer to returned value. + +Returns: + + Status code + +--*/ +{ + return mRT->GetNextHighMonotonicCount (HighCount); +} + +VOID +EfiResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData + ) +/*++ + +Routine Description: + + Resets the entire platform. + +Arguments: + + ResetType - The type of reset to perform. + ResetStatus - The status code for the reset. + DataSize - The size, in bytes, of ResetData. + ResetData - A data buffer that includes a Null-terminated Unicode string, optionally + followed by additional binary data. + +Returns: + + None + +--*/ +{ + mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData); +} + +EFI_STATUS +EfiReportStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Status Code reporter + +Arguments: + + CodeType - Type of Status Code. + + Value - Value to output for Status Code. + + Instance - Instance Number of this status code. + + CallerId - ID of the caller of this status code. + + Data - Optional data associated with this status code. + +Returns: + + Status code + +--*/ +{ + EFI_STATUS Status; + +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + if (gStatusCode == NULL) { + return EFI_UNSUPPORTED; + } + Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data); +#else + if (mRT == NULL) { + return EFI_UNSUPPORTED; + } + // + // Check whether EFI_RUNTIME_SERVICES has Tiano Extension + // + Status = EFI_UNSUPPORTED; + if (mRT->Hdr.Revision == EFI_SPECIFICATION_VERSION && + mRT->Hdr.HeaderSize == sizeof (EFI_RUNTIME_SERVICES) && + mRT->ReportStatusCode != NULL) { + Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data); + } +#endif + return Status; +} + +// +// Cache Flush Routine. +// +EFI_STATUS +EfiCpuFlushCache ( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length + ) +/*++ + +Routine Description: + + Flush cache with specified range. + +Arguments: + + Start - Start address + Length - Length in bytes + +Returns: + + Status code + + EFI_SUCCESS - success + +--*/ +{ + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm new file mode 100644 index 0000000000..f6e70d2e7c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm @@ -0,0 +1,51 @@ +;***************************************************************************** +;* +;* Copyright (c) 2006, Intel Corporation +;* All rights reserved. This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* Module Name: +;* +;* Fx.asm +;* +;* Abstract: +;* +;* AsmFxRestore and AsmFxSave function +;* +;***************************************************************************** + + .586P + .model flat,C + .xmm + .code + +;------------------------------------------------------------------------------ +; VOID +; AsmFxSave ( +; OUT IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +AsmFxSave PROC + mov eax, [esp + 4] + fxsave [eax] + ret +AsmFxSave ENDP + +;------------------------------------------------------------------------------ +; VOID +; AsmFxRestore ( +; IN CONST IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +AsmFxRestore PROC + mov eax, [esp + 4] + fxrstor [eax] + ret +AsmFxRestore ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm new file mode 100644 index 0000000000..b59583effd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm @@ -0,0 +1,199 @@ +;***************************************************************************** +;* +;* Copyright (c) 2006 - 2007, Intel Corporation +;* All rights reserved. This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* Module Name: +;* +;* Thunk.asm +;* +;* Abstract: +;* +;* Real mode thunk +;* +;***************************************************************************** + + .686p + +EXTERNDEF C mCode16Size:DWORD + +CONST SEGMENT FLAT "DATA" READONLY + +mCode16Size DD _TEXT16SIZE + +CONST ENDS + +_DATA SEGMENT FLAT "DATA" + +NullSegSel DQ 0 +_16BitCsSel LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh ; 16-bit segment + DB 0 +_16BitSsSel LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh ; 16-bit segment + DB 0 + +_16Gdtr LABEL FWORD + DW $ - offset NullSegSel - 1 + DD offset NullSegSel + +_DATA ENDS + +_TEXT SEGMENT FLAT "CODE" PARA + +IA32_REGS STRUC 4t +_EDI DD ? +_ESI DD ? +_EBP DD ? +_ESP DD ? +_EBX DD ? +_EDX DD ? +_ECX DD ? +_EAX DD ? +_DS DW ? +_ES DW ? +_FS DW ? +_GS DW ? +_EFLAGS DD ? +_EIP DD ? +_CS DW ? +_SS DW ? +IA32_REGS ENDS + +_STK16 STRUC 1t +RetEip DD ? +RetCs DW ? +ThunkFlags DW ? +SavedEsp DD ? +SavedSs DW ? +SavedGdtr FWORD ? +SavedCr0 DD ? +SavedCr4 DD ? +_STK16 ENDS + + ASSUME ds:_DATA + +__Thunk16 PROC USES ebp ebx esi edi ds es fs gs + ASSUME esi:PTR IA32_REGS + mov esi, [esp + 36] + movzx edx, [esi]._SS + mov edi, [esi]._ESP + add edi, - sizeof (_STK16) - sizeof (IA32_REGS) + push edi ; save stack offset + imul eax, edx, 16 ; eax <- edx*16 + add edi, eax ; edi <- linear address of 16-bit stack + push sizeof (IA32_REGS) / 4 + pop ecx + rep movsd ; copy context to 16-bit stack + pop ebx ; ebx <- 16-bit stack offset + mov eax, offset @F ; return offset + stosd + mov eax, cs ; return segment + stosw + mov eax, [esp + 40] ; THUNK flags + stosw + mov eax, esp + stosd ; save esp + mov eax, ss ; save ss + stosw + sgdt fword ptr [edi] ; save GDTR + sidt fword ptr [esp + 36] ; save IDTR + mov esi, cr0 + mov [edi + 6], esi ; save CR0 + and esi, NOT 80000001h ; esi <- CR0 to set + mov eax, cr4 + mov [edi + 10], eax ; save CR4 + and al, NOT 30h ; clear PAE & PSE + mov edi, edx ; edi <- 16-bit stack segment + mov edx, [esp + 44] + shl edx, 16 + push edx + pop edx + mov dx, _16BitSsSel - NullSegSel + lgdt _16Gdtr ; load 16-bit GDTR + DB 0eah + DD offset @16Bit + DW _16BitCsSel - NullSegSel ; jmp far 8:@16Bit +@16Bit: + mov ss, dx + mov cr0, esi ; disable protected mode + mov cr4, eax ; disable PAE & PSE + db 67h, 0FFh, 06Ch, 024h, 0FCh ; jmp dword ptr [esp-4] +@@: + mov eax, ss + shl eax, 4 + add eax, esp ; eax <- address of 16-bit stack + lss esp, fword ptr (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedEsp + lidt fword ptr [esp + 36] ; restore IDTR + ret +__Thunk16 ENDP + +_TEXT ENDS + +_TEXT16 SEGMENT USE16 "CODE" PARA + +_Code16Addr PROC C +_Code16Addr ENDP + +RealMode PROC + mov ss, di ; set up stack + mov esp, ebx + lidt fword ptr cs:[_16Idtr - _Code16Addr] + popad + pop ds + pop es + pop fs + pop gs + add sp, 4 ; skip EFlags + test (_STK16 ptr [esp + 8]).ThunkFlags, 1 + jz @F + pushf +@@: + push cs +; push @FarCallRet - _Code16Addr + DB 68h ; push /iw + DW @FarCallRet - _Code16Addr + jz @F + jmp fword ptr [esp + 6] +@@: + jmp fword ptr [esp + 4] +@FarCallRet: + pushfd + push gs + push fs + push es + push ds + pushad + cli + DB 66h + lgdt (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedGdtr + mov eax, (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedCr4 + mov cr4, eax + mov eax, (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedCr0 + mov cr0, eax ; restore CR0 + jmp fword ptr (_STK16 ptr [esp + sizeof (IA32_REGS)]).RetEip +RealMode ENDP + +_16Idtr FWORD (1 SHL 10) - 1 + +_TEXT16END: + +_TEXT16SIZE = _TEXT16END - _Code16Addr + +_TEXT16 ENDS + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h new file mode 100644 index 0000000000..226c0160b9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h @@ -0,0 +1,348 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Thunk16Lib.h + +Abstract: + + Real Mode Thunk Header file + +--*/ + +#ifndef __THUNK_16_LIB_H__ +#define __THUNK_16_LIB_H__ +#include "Tiano.h" + +// +// Thunk Flags +// +#define THUNK_SAVE_FP_STATE 0x1 +#define THUNK_USER_STACK 0x2 +#define THUNK_INTERRUPT 0x10000 + +// +// Byte packed structure for 16-bit Real Mode FLAGS +// +typedef union { + struct { + UINT32 CF:1; // Carry Flag + UINT32 Reserved_0:1; // Reserved + UINT32 PF:1; // Parity Flag + UINT32 Reserved_1:1; // Reserved + UINT32 AF:1; // Auxiliary Carry Flag + UINT32 Reserved_2:1; // Reserved + UINT32 ZF:1; // Zero Flag + UINT32 SF:1; // Sign Flag + UINT32 TF:1; // Trap Flag + UINT32 IF:1; // Interrupt Enable Flag + UINT32 DF:1; // Direction Flag + UINT32 OF:1; // Overflow Flag + UINT32 IOPL:2; // I/O Privilege Level + UINT32 NT:1; // Nested Task + UINT32 Reserved_3:1; // Reserved + } Bits; + UINTN UintN; +} IA32_FLAGS16; + +// +// Byte packed structure for EFLAGS +// 32-bits on IA32 +// 64-bits on X64 +// + +typedef union { + struct { + UINT32 CF:1; // Carry Flag + UINT32 Reserved_0:1; // Reserved + UINT32 PF:1; // Parity Flag + UINT32 Reserved_1:1; // Reserved + UINT32 AF:1; // Auxiliary Carry Flag + UINT32 Reserved_2:1; // Reserved + UINT32 ZF:1; // Zero Flag + UINT32 SF:1; // Sign Flag + UINT32 TF:1; // Trap Flag + UINT32 IF:1; // Interrupt Enable Flag + UINT32 DF:1; // Direction Flag + UINT32 OF:1; // Overflow Flag + UINT32 IOPL:2; // I/O Privilege Level + UINT32 NT:1; // Nested Task + UINT32 Reserved_3:1; // Reserved + UINT32 RF:1; // Resume Flag + UINT32 VM:1; // Virtual 8086 Mode + UINT32 AC:1; // Alignment Check + UINT32 VIF:1; // Virtual Interrupt Flag + UINT32 VIP:1; // Virtual Interrupt Pending + UINT32 ID:1; // ID Flag + UINT32 Reserved_4:10; // Reserved + } Bits; + UINTN UintN; +} IA32_EFLAGS32; + +// +// Byte packed structure for an FP/SSE/SSE2 context +// +typedef struct { + UINT8 Buffer[512]; +} IA32_FX_BUFFER; + +// +// Structures for the 16-bit real mode thunks +// +typedef struct { + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 Reserved3; + UINT32 Reserved4; + UINT8 BL; + UINT8 BH; + UINT16 Reserved5; + UINT8 DL; + UINT8 DH; + UINT16 Reserved6; + UINT8 CL; + UINT8 CH; + UINT16 Reserved7; + UINT8 AL; + UINT8 AH; + UINT16 Reserved8; +} IA32_BYTE_REGS; + +typedef struct { + UINT16 DI; + UINT16 Reserved1; + UINT16 SI; + UINT16 Reserved2; + UINT16 BP; + UINT16 Reserved3; + UINT16 SP; + UINT16 Reserved4; + UINT16 BX; + UINT16 Reserved5; + UINT16 DX; + UINT16 Reserved6; + UINT16 CX; + UINT16 Reserved7; + UINT16 AX; + UINT16 Reserved8; + UINT16 DS; + UINT16 ES; + UINT16 FS; + UINT16 GS; + IA32_FLAGS16 Flags; + UINT16 IP; + UINT16 Reserved10; + UINT16 CS; + UINT16 SS; +} IA32_WORD_REGS; + +typedef struct { + UINT32 EDI; + UINT32 ESI; + UINT32 EBP; + UINT32 ESP; + UINT32 EBX; + UINT32 EDX; + UINT32 ECX; + UINT32 EAX; + UINT16 DS; + UINT16 ES; + UINT16 FS; + UINT16 GS; + IA32_EFLAGS32 EFLAGS; + UINT32 EIP; + UINT16 CS; + UINT16 SS; +} IA32_DWORD_REGS; + +typedef union { + IA32_DWORD_REGS E; + IA32_WORD_REGS X; + IA32_BYTE_REGS H; +} IA32_REGISTER_SET; + +// +// Byte packed structure for an 16-bit real mode thunks +// +typedef struct { + UINT32 RealModeBuffer; + UINT32 DefaultStack; +} THUNK_CONTEXT; + +// +// 16-bit thunking services +// + +UINTN +EFIAPI +AsmThunk16GetProperties ( + OUT UINTN *MinimumStackSize OPTIONAL + ) +/*++ + +Routine Description: + + Returns the properties of this real mode thunk implementation. Currently + there are 2 properties has been defined, the minimum real mode buffer size + and the minimum stack size. + +Arguments: + + MinimumStackSize - The minimum size required for a 16-bit stack. + +Returns: + + The minimum size of the real mode buffer needed by this thunk implementation + is returned. + +--*/ +; + +THUNK_CONTEXT * +EFIAPI +AsmThunk16SetProperties ( + OUT THUNK_CONTEXT *ThunkContext, + IN VOID *RealModeBuffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + Tell this real mode thunk implementation the address and size of the real + mode buffer needed. + +Arguments: + + ThunkContext - The thunk context whose properties to set. + RealModeBuffer - The address of the buffer allocated by caller. It should be + aligned on a 16-byte boundary. + This buffer must be in identity mapped pages. + BufferSize - The size of RealModeBuffer. Must be larger than the minimum + size required as returned by AsmThunk16GetProperties(). + +Returns: + + None + +--*/ +; + +VOID +EFIAPI +AsmThunk16Destroy ( + IN OUT THUNK_CONTEXT *ThunkContext + ) +/*++ + +Routine Description: + + Reset all internal states to their initial values. The caller should not + release the real mode buffer until after a call to this function. + +Arguments: + + ThunkContext - The thunk context to destroy. + +Returns: + + None + +--*/ +; + +IA32_REGISTER_SET * +EFIAPI +AsmThunk16FarCall86 ( + IN THUNK_CONTEXT *ThunkContext, + IN OUT IA32_REGISTER_SET *RegisterSet, + IN UINT32 ThunkFlags + ) +/*++ + +Routine Description: + + Make a far call to 16-bit code. + + NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts + disabled because of GDTR and IDTR manipulations. + This function must be placed in identity mapped pages. + +Arguments: + + ThunkContext - Thunk context to use. + RegisterSet - CPU registers would be set to the values contained in this + structure before making the far call. Then CPU registers are + copied back to this structure. + CS:EIP points to the real mode code being called on input. + SS:ESP points to the real mode stack if THUNK_USER_STACK is + set on input, otherwise ignored. + EFlages is ignored on input. + On output, values of CS, EIP, SS and ESP should be ignored. + ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and + THUNK_USER_STACK. + THUNK_SAVE_FP_STATE - FPU state would be saved/restored + before/after calling real mode code. + THUNK_USER_STACK - The stack specified by SS:ESP would be + used instead of the default stack. + +Returns: + + RegisterSet is returned. + +--*/ +; + +IA32_REGISTER_SET * +EFIAPI +AsmThunk16Int86 ( + IN THUNK_CONTEXT *ThunkContext, + IN UINT8 IntNumber, + IN OUT IA32_REGISTER_SET *RegisterSet, + IN UINT32 ThunkFlags + ) +/*++ + +Routine Description: + + Invoke a 16-bit interrupt handler. + + NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts + disabled because of GDTR and IDTR manipulations. + This function must be placed in identity mapped pages. + +Arguments: + + ThunkContext - Thunk context to use. + IntNumber - The ordinal of the interrupt handler ranging from 0 to 255. + RegisterSet - CPU registers would be set to the values contained in this + structure before making the far call. Then CPU registers are + copied back to this structure. + SS:ESP points to the real mode stack if THUNK_USER_STACK is + set on input, otherwise ignored. + EFlages is ignored on input. + On output, values of CS, EIP, SS and ESP should be ignored. + ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and + THUNK_USER_STACK. + THUNK_SAVE_FP_STATE - FPU state would be saved/restored + before/after calling real mode code. + THUNK_USER_STACK - The stack specified by SS:ESP would be + used instead of the default stack. + +Returns: + + RegisterSet is returned. + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.inf b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.inf new file mode 100644 index 0000000000..5134caf080 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.inf @@ -0,0 +1,49 @@ +#/*++ +# +# Copyright (c) 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Thunk16Lib.inf +# +# Abstract: +# +#--*/ + +[defines] +BASE_NAME = Thunk16Lib +COMPONENT_TYPE = LIBRARY + +[sources.common] + x86Thunk.c + +[sources.ia32] + Ia32\Thunk16.asm + Ia32\Fx.asm + +[sources.x64] + X64\Thunk16.asm + X64\Fx.asm + +[includes.common] + . + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[libraries.common] + + +[nmake.common] diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm new file mode 100644 index 0000000000..77490b44b5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm @@ -0,0 +1,46 @@ +;***************************************************************************** +;* +;* Copyright (c) 2006, Intel Corporation +;* All rights reserved. This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* Module Name: +;* +;* Fx.asm +;* +;* Abstract: +;* +;* AsmFxRestore and AsmFxSave function +;* +;***************************************************************************** + + .code + +;------------------------------------------------------------------------------ +; VOID +; AsmFxSave ( +; OUT IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +AsmFxSave PROC + fxsave [rcx] + ret +AsmFxSave ENDP + +;------------------------------------------------------------------------------ +; VOID +; AsmFxRestore ( +; IN CONST IA32_FX_BUFFER *Buffer +; ); +;------------------------------------------------------------------------------ +AsmFxRestore PROC + fxrstor [rcx] + ret +AsmFxRestore ENDP + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm new file mode 100644 index 0000000000..641e8d285f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm @@ -0,0 +1,216 @@ +;***************************************************************************** +;* +;* Copyright (c) 2006, Intel Corporation +;* All rights reserved. This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* Module Name: +;* +;* Thunk.asm +;* +;* Abstract: +;* +;* Real mode thunk +;* +;***************************************************************************** + +EXTERNDEF mCode16Size:QWORD + + .const + +mCode16Size DQ _Code16End - _Code16Addr + + .data + +NullSegSel DQ 0 +_16CsSegSel LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 9bh + DB 8fh ; 16-bit segment + DB 0 +_16DsSegSel LABEL QWORD + DW -1 + DW 0 + DB 0 + DB 93h + DB 8fh ; 16-bit segment + DB 0 + +_16Gdtr LABEL FWORD + DW $ - offset NullSegSel - 1 + DQ offset NullSegSel + + .code + +IA32_REGS STRUC 4t +_EDI DD ? +_ESI DD ? +_EBP DD ? +_ESP DD ? +_EBX DD ? +_EDX DD ? +_ECX DD ? +_EAX DD ? +_DS DW ? +_ES DW ? +_FS DW ? +_GS DW ? +_RFLAGS DQ ? +_EIP DD ? +_CS DW ? +_SS DW ? +IA32_REGS ENDS + +_STK16 STRUC 1t +RetEip DD ? +RetCs DW ? +ThunkFlags DW ? +SavedGdtr FWORD ? +Resvd1 DW ? +SavedCr0 DD ? +SavedCr4 DD ? +_STK16 ENDS + +_Thunk16 PROC USES rbp rbx rsi rdi r12 r13 r14 r15 + + push fs + push gs + + mov r12d, ds + mov r13d, es + mov r14d, ss + mov r15, rsp + mov rsi, rcx + movzx r10, (IA32_REGS ptr [rsi])._SS + xor rdi, rdi + mov edi, (IA32_REGS ptr [rsi])._ESP + add rdi, - sizeof (IA32_REGS) - sizeof (_STK16) + push rdi + imul rax, r10, 16 + add rdi, rax + push sizeof (IA32_REGS) / 4 + pop rcx + rep movsd + pop rbx ; rbx <- 16-bit stack offset + lea eax, @F ; return offset + stosd + mov eax, cs ; return segment + stosw + mov eax, edx ; THUNK Flags + stosw + sgdt fword ptr [rsp + 58h] ; save GDTR + mov rax, [rsp + 58h] + stosq + mov rax, cr0 ; save CR0 + mov esi, eax ; esi <- CR0 to set + stosd + mov rax, cr4 ; save CR4 + stosd + sidt fword ptr [rsp + 58h] ; save IDTR + and esi, 07ffffffeh ; clear PE & PG bits + mov rdi, r10 ; rdi <- 16-bit stack segment + + shl r8, 16 + push r8 ; far jmp address + lea eax, @16Bit + push rax + mov word ptr [rsp + 4], 8 + lgdt _16Gdtr + retf +@16Bit: + DB 66h + mov ecx, 0c0000080h + mov cr0, rsi ; disable PE & PG + rdmsr + and ah, NOT 1 + wrmsr ; clear LME bit + mov rax, cr4 + and al, NOT 30h ; clear PAE & PSE + mov cr4, rax + retf +@@: + xor rax, rax + mov eax, ss + shl eax, 4 + add eax, esp ; rax <- address of 16-bit stack + mov rsp, r15 + lidt fword ptr [rsp + 58h] ; restore IDTR + mov ds, r12d + mov es, r13d + mov ss, r14d + pop gs + pop fs + ret +_Thunk16 ENDP + + ALIGN 10h + +_Code16Addr PROC +_Code16Addr ENDP + +RealMode PROC + mov ss, edi + mov sp, bx ; set up 16-bit stack + DB 2eh, 0fh, 1, 1eh + DW _16Idtr - _Code16Addr ; lidt _16Idtr + DB 66h, 61h ; popad + DB 1fh ; pop ds + DB 7 ; pop es + pop fs + pop gs + + add esp, 8 ; skip RFLAGS + DB 67h, 0f7h, 44h, 24h, 0eh, 1, 0 ; test [esp + 0eh], 1 + jz @F + pushfq ; pushf, actually +@@: + DB 0eh ; push cs + DB 68h ; push /iw + DW @FarCallRet - _Code16Addr + jz @F + DB 66h + jmp fword ptr [esp + 6] +@@: + DB 66h + jmp fword ptr [esp + 4] +@FarCallRet: + DB 66h + push 0 ; push a dword of zero + pushf ; pushfd, actually + push gs + push fs + DB 6 ; push es + DB 1eh ; push ds + DB 66h, 60h ; pushad + cli + + DB 66h + lgdt (_STK16 ptr [esp + sizeof(IA32_REGS)]).SavedGdtr + DB 66h + mov eax, (_STK16 ptr [esp + sizeof(IA32_REGS)]).SavedCr4 + mov cr4, rax + DB 66h + mov ecx, 0c0000080h + rdmsr + or ah, 1 + wrmsr ; set LME + DB 66h + mov eax, (_STK16 ptr [esp + sizeof(IA32_REGS)]).SavedCr0 + mov cr0, rax + DB 66h + jmp fword ptr (_STK16 ptr [esp + sizeof(IA32_REGS)]).RetEip + +RealMode ENDP + +_16Idtr FWORD (1 SHL 10) - 1 + +_Code16End: + + END diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/x86Thunk.c b/EdkCompatibilityPkg/Foundation/Library/Thunk16/x86Thunk.c new file mode 100644 index 0000000000..9bd77e24ca --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/x86Thunk.c @@ -0,0 +1,320 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + x86Thunk.c + +Abstract: + + Real Mode Thunk Functions + +--*/ + +#include "Thunk16Lib.h" +#include "EfiCommonLib.h" + +#define IA32API __cdecl + +extern CONST UINTN mCode16Size; + +extern +IA32_REGISTER_SET * +IA32API +_Thunk16 ( + IN OUT IA32_REGISTER_SET *RegisterSet, + IN UINT32 ThunkFlags, + IN UINT32 RealModeCs + ); + +extern +VOID +IA32API +_Code16Addr ( + VOID + ); + +VOID +IA32API +AsmFxRestore ( + IN CONST IA32_FX_BUFFER *Buffer + ); + +VOID +IA32API +AsmFxSave ( + OUT IA32_FX_BUFFER *Buffer + ); + +// +// Implementation +// +STATIC +IA32_REGISTER_SET * +AsmThunk16 ( + IN THUNK_CONTEXT *ThunkContext, + IN OUT IA32_REGISTER_SET *RegisterSet, + IN UINT32 ThunkFlags + ) +/*++ + +Routine Description: + + Do the 16-bit thunk code. + + NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts + disabled because of GDTR and IDTR manipulations. + This function must be placed in identity mapped pages. + +Arguments: + + ThunkContext - Thunk context to use. + RegisterSet - CPU registers would be set to the values contained in this + structure before making the far call. Then CPU registers are + copied back to this structure. + SS:ESP points to the real mode stack if THUNK_USER_STACK is + set on input, otherwise ignored. + EFlages is ignored on input. + On output, values of CS, EIP, SS and ESP should be ignored. + ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and + THUNK_USER_STACK. + THUNK_SAVE_FP_STATE - FPU state would be saved/restored + before/after calling real mode code. + THUNK_USER_STACK - The stack specified by SS:ESP would be + used instead of the default stack. + +Returns: + + RegisterSet is returned. + +--*/ +{ + IA32_FX_BUFFER *FpSavedState; + UINT8 FpBuffer[sizeof (*FpSavedState) + 0x10]; + + FpSavedState = (IA32_FX_BUFFER*)(((UINTN)FpBuffer + 0xf) & ~0xf); + + if (!(ThunkFlags & THUNK_USER_STACK)) { + RegisterSet->E.ESP = (UINT16)ThunkContext->DefaultStack; + RegisterSet->E.SS = (UINT16)((ThunkContext->DefaultStack >> 4) & 0xf000); + } + + if (ThunkFlags & THUNK_SAVE_FP_STATE) { + AsmFxSave (FpSavedState); + } + + EfiCommonLibCopyMem ( + RegisterSet, + _Thunk16 ( + RegisterSet, + (UINT16)(ThunkFlags >> 16), + ThunkContext->RealModeBuffer >> 4 + ), + sizeof (*RegisterSet) + ); + + if (ThunkFlags & THUNK_SAVE_FP_STATE) { + AsmFxRestore (FpSavedState); + } + + return RegisterSet; +} + +UINTN +EFIAPI +AsmThunk16GetProperties ( + OUT UINTN *MinimumStackSize + ) +/*++ + +Routine Description: + + Returns the properties of this real mode thunk implementation. Currently + there are 2 properties has been defined, the minimum real mode buffer size + and the minimum stack size. + +Arguments: + + MinimumStackSize - The minimum size required for a 16-bit stack. + +Returns: + + The minimum size of the real mode buffer needed by this thunk implementation + is returned. + +--*/ +{ + // + // This size should be large enough to hold the register set as well as saved + // CPU contexts including GDTR, CR0 and CR4 + // + if (MinimumStackSize) { + *MinimumStackSize = sizeof (IA32_REGISTER_SET) + 0x200; + } + + return mCode16Size; +} + +THUNK_CONTEXT * +EFIAPI +AsmThunk16SetProperties ( + OUT THUNK_CONTEXT *ThunkContext, + IN VOID *RealModeBuffer, + IN UINTN BufferSize + ) +/*++ + +Routine Description: + + Tell this real mode thunk implementation the address and size of the real + mode buffer needed. + +Arguments: + + ThunkContext - The thunk context whose properties to set. + RealModeBuffer - The address of the buffer allocated by caller. It should be + aligned on a 16-byte boundary. + This buffer must be in identity mapped pages. + BufferSize - The size of RealModeBuffer. Must be larger than the minimum + size required as returned by AsmThunk16GetProperties(). + +Returns: + + None + +--*/ +{ + BufferSize &= ~3; + + ThunkContext->RealModeBuffer = (UINT32)(UINTN)RealModeBuffer; + ThunkContext->DefaultStack = (UINT32)(ThunkContext->RealModeBuffer + BufferSize); + EfiCommonLibCopyMem (RealModeBuffer, (VOID*)(UINTN)_Code16Addr, mCode16Size); + + return ThunkContext; +} + +VOID +EFIAPI +AsmThunk16Destroy ( + IN OUT THUNK_CONTEXT *ThunkContext + ) +/*++ + +Routine Description: + + Reset all internal states to their initial values. The caller should not + release the real mode buffer until after a call to this function. + +Arguments: + + ThunkContext - The thunk context to destroy. + +Returns: + + None + +--*/ +{ + ThunkContext->RealModeBuffer = 0; +} + +IA32_REGISTER_SET * +EFIAPI +AsmThunk16FarCall86 ( + IN THUNK_CONTEXT *ThunkContext, + IN OUT IA32_REGISTER_SET *RegisterSet, + IN UINT32 Flags + ) +/*++ + +Routine Description: + + Make a far call to 16-bit code. + + NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts + disabled because of GDTR and IDTR manipulations. + This function must be placed in identity mapped pages. + +Arguments: + + ThunkContext - Thunk context to use. + RegisterSet - CPU registers would be set to the values contained in this + structure before making the far call. Then CPU registers are + copied back to this structure. + CS:EIP points to the real mode code being called on input. + SS:ESP points to the real mode stack if THUNK_USER_STACK is + set on input, otherwise ignored. + EFlages is ignored on input. + On output, values of CS, EIP, SS and ESP should be ignored. + ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and + THUNK_USER_STACK. + THUNK_SAVE_FP_STATE - FPU state would be saved/restored + before/after calling real mode code. + THUNK_USER_STACK - The stack specified by SS:ESP would be + used instead of the default stack. + +Returns: + + RegisterSet is returned. + +--*/ +{ + return AsmThunk16 (ThunkContext, RegisterSet, Flags); +} + +IA32_REGISTER_SET * +EFIAPI +AsmThunk16Int86 ( + IN THUNK_CONTEXT *ThunkContext, + IN UINT8 IntNumber, + IN OUT IA32_REGISTER_SET *RegisterSet, + IN UINT32 Flags + ) +/*++ + +Routine Description: + + Invoke a 16-bit interrupt handler. + + NOTE: This function must be called on TPL_HIGH_LEVEL or with interrupts + disabled because of GDTR and IDTR manipulations. + This function must be placed in identity mapped pages. + +Arguments: + + ThunkContext - Thunk context to use. + IntNumber - The ordinal of the interrupt handler ranging from 0 to 255. + RegisterSet - CPU registers would be set to the values contained in this + structure before making the far call. Then CPU registers are + copied back to this structure. + SS:ESP points to the real mode stack if THUNK_USER_STACK is + set on input, otherwise ignored. + EFlages is ignored on input. + On output, values of CS, EIP, SS and ESP should be ignored. + ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and + THUNK_USER_STACK. + THUNK_SAVE_FP_STATE - FPU state would be saved/restored + before/after calling real mode code. + THUNK_USER_STACK - The stack specified by SS:ESP would be + used instead of the default stack. + +Returns: + + RegisterSet is returned. + +--*/ +{ + RegisterSet->E.EIP = (UINT16)((UINT32 *)NULL)[IntNumber]; + RegisterSet->E.CS = (UINT16)(((UINT32 *)NULL)[IntNumber] >> 16); + + return AsmThunk16 (ThunkContext, RegisterSet, Flags | THUNK_INTERRUPT); +} diff --git a/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c b/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c new file mode 100644 index 0000000000..9293d10a21 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BaseMemoryTest.c + +Abstract: + + PEI memory test PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (BaseMemoryTest) + +EFI_GUID gPeiBaseMemoryTestPpiGuid = PEI_BASE_MEMORY_TEST_GUID; + +EFI_GUID_STRING(&gPeiBaseMemoryTestPpiGuid, "PeiBaseMemoryTest", "Pei Base Memory Test PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h b/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h new file mode 100644 index 0000000000..9498c1644e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + BaseMemoryTest.h + +Abstract: + + Pei memory test PPI as defined in Tiano + + Used to Pei memory test in PEI + +--*/ + +#ifndef _BASE_MEMORY_TEST_H_ +#define _BASE_MEMORY_TEST_H_ + +#define PEI_BASE_MEMORY_TEST_GUID \ + { \ + 0xb6ec423c, 0x21d2, 0x490d, 0x85, 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74 \ + } + +EFI_FORWARD_DECLARATION (PEI_BASE_MEMORY_TEST_PPI); + +typedef enum { + Ignore, + Quick, + Sparse, + Extensive +} PEI_MEMORY_TEST_OP; + +typedef +EFI_STATUS +(EFIAPI *PEI_BASE_MEMORY_TEST) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_BASE_MEMORY_TEST_PPI * This, + IN EFI_PHYSICAL_ADDRESS BeginAddress, + IN UINT64 MemoryLength, + IN PEI_MEMORY_TEST_OP Operation, + OUT EFI_PHYSICAL_ADDRESS * ErrorAddress + ); + +typedef struct _PEI_BASE_MEMORY_TEST_PPI { + PEI_BASE_MEMORY_TEST BaseMemoryTest; +} PEI_BASE_MEMORY_TEST_PPI; + +extern EFI_GUID gPeiBaseMemoryTestPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Ppi/EdkPpiLib.inf b/EdkCompatibilityPkg/Foundation/Ppi/EdkPpiLib.inf new file mode 100644 index 0000000000..1fc4350bc0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/EdkPpiLib.inf @@ -0,0 +1,51 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkPpiLib.inf +# +# Abstract: +# +# Component description file for the Edk PPI library. +# +#--*/ + +[defines] +BASE_NAME= EdkPpiLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Framework + +[nmake.common] + +[sources.common] + BaseMemoryTest\BaseMemoryTest.h + BaseMemoryTest\BaseMemoryTest.c + FlashMap\FlashMap.h + FlashMap\FlashMap.c + PeiInMemory\PeiInMemory.h + PeiInMemory\PeiInMemory.c + StatusCodeMemory\StatusCodeMemory.h + StatusCodeMemory\StatusCodeMemory.c + OperatorPresence\OperatorPresence.h + OperatorPresence\OperatorPresence.c diff --git a/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.c b/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.c new file mode 100644 index 0000000000..db90583dbf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FlashMap.c + +Abstract: + + Flash Map PPI GUID as defined in Tiano + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (FlashMap) + +EFI_GUID gPeiFlashMapPpiGuid = PEI_FLASH_MAP_PPI_GUID; + +EFI_GUID_STRING(&gPeiFlashMapPpiGuid, "Flash Map", "Flash Map PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.h b/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.h new file mode 100644 index 0000000000..7203055bf1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/FlashMap/FlashMap.h @@ -0,0 +1,59 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FlashMap.h + +Abstract: + + FlashMap PPI defined in Tiano + + This code abstracts FlashMap access + +--*/ + +#ifndef _PEI_FLASH_MAP_PPI_H_ +#define _PEI_FLASH_MAP_PPI_H_ + +#define PEI_FLASH_MAP_PPI_GUID \ + { \ + 0xf34c2fa0, 0xde88, 0x4270, 0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c \ + } + +#include "EfiFlashMap.h" + +EFI_FORWARD_DECLARATION (PEI_FLASH_MAP_PPI); + +// +// Functions +// +typedef +EFI_STATUS +(EFIAPI *PEI_GET_FLASH_AREA_INFO) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_FLASH_MAP_PPI * This, + IN EFI_FLASH_AREA_TYPE AreaType, + IN EFI_GUID * AreaTypeGuid, + OUT UINT32 *NumEntries, + OUT EFI_FLASH_SUBAREA_ENTRY **Entries + ); + +// +// PEI_FLASH_MAP_PPI +// +typedef struct _PEI_FLASH_MAP_PPI { + PEI_GET_FLASH_AREA_INFO GetAreaInfo; +} PEI_FLASH_MAP_PPI; + +extern EFI_GUID gPeiFlashMapPpiGuid; + +#endif // _PEI_FLASH_MAP_PPI_H_ diff --git a/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.c b/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.c new file mode 100644 index 0000000000..a5a2e145fe --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + OperatorPresence.c + +Abstract: + + PPI GUID definition for PEI_OPERATOR_PRESENCE_PPI + +--*/ + +#include + +#include EFI_PPI_DEFINITION (OperatorPresence) + +EFI_GUID gPeiOperatorPresencePpiGuid = PEI_OPERATOR_PRESENCE_PPI_GUID; + +EFI_GUID_STRING(&gPeiOperatorPresencePpiGuid, "OperatorPresence", "Operator Presence Detection"); diff --git a/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.h b/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.h new file mode 100644 index 0000000000..8d866deaee --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/OperatorPresence/OperatorPresence.h @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + OperatorPresence.h + +Abstract: + + PPI published by the PEIM who's responsible for detecting operator presence + +--*/ + +#ifndef _PEI_OPERATOR_PRESENCE_H_ +#define _PEI_OPERATOR_PRESENCE_H_ + +#define PEI_OPERATOR_PRESENCE_PPI_GUID \ + { 0x20a7378c, 0xaa83, 0x4ce1, 0x82, 0x1f, 0x47, 0x40, 0xee, 0x1b, 0x3f, 0x9f } + +typedef struct _PEI_OPERATOR_PRESENCE_PPI { + BOOLEAN OperatorPresent; +} PEI_OPERATOR_PRESENCE_PPI; + +extern EFI_GUID gPeiOperatorPresencePpiGuid; + +#endif // _PEI_OPERATOR_PRESENCE_H_ diff --git a/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.c b/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.c new file mode 100644 index 0000000000..c081660420 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.c @@ -0,0 +1,33 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiInMemory.c + +Abstract: + + Capsule on Fat Usb Disk GUID. + + This is the contract between the recovery module and device recovery module + in order to convey the name of a given recovery module type + +--*/ + +#include "Tiano.h" +#include "PeiBind.h" +#include "PeiApi.h" +#include EFI_PPI_DEFINITION(PeiInMemory) + +EFI_GUID gPeiInMemoryGuid = PEI_IN_MEMORY_GUID; + +EFI_GUID_STRING(&gPeiInMemoryGuid, "PeiInMemory", "PEIM In Memory"); + diff --git a/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.h b/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.h new file mode 100644 index 0000000000..571c61773d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/PeiInMemory/PeiInMemory.h @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiInMemory.h + +Abstract: + + +--*/ + +#ifndef _PEI_IN_MEMORY_H +#define _PEI_IN_MEMORY_H + +#define PEI_IN_MEMORY_GUID \ + {0x643b8786, 0xb417, 0x48d2, 0x8f, 0x5e, 0x78, 0x19, 0x93, 0x1c, 0xae, 0xd8} + +extern EFI_GUID gPeiInMemoryGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c b/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c new file mode 100644 index 0000000000..683baefe94 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCodeMemory.c + +Abstract: + + Status Code Memory descriptor + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (StatusCodeMemory) + +EFI_GUID gPeiStatusCodeMemoryPpiGuid = PEI_STATUS_CODE_MEMORY_PPI_GUID; + +EFI_GUID_STRING(&gPeiStatusCodeMemoryPpiGuid, "StatusCodeMemory", "Status Code memory descriptor."); diff --git a/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h b/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h new file mode 100644 index 0000000000..46543f17e5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StatusCodeMemory.h + +Abstract: + + Status Code memory descriptor PPI. Contains information about memory that + the Status Code PEIM may use to journal Status Codes. + +--*/ + +#ifndef _PEI_STATUS_CODE_MEMORY_PPI_H_ +#define _PEI_STATUS_CODE_MEMORY_PPI_H_ + +// +// GUID definition +// +#define PEI_STATUS_CODE_MEMORY_PPI_GUID \ + { 0x26f8ab01, 0xd3cd, 0x489c, 0x98, 0x4f, 0xdf, 0xde, 0xf7, 0x68, 0x39, 0x5b } + +// +// Data types +// +typedef struct { + EFI_STATUS_CODE_TYPE Type; + EFI_STATUS_CODE_VALUE Value; + UINT32 Instance; +} EFI_STATUS_CODE_ENTRY; + +// +// PPI definition +// +typedef struct { + UINTN FirstEntry; + UINTN LastEntry; + EFI_PHYSICAL_ADDRESS Address; + UINTN Length; +} PEI_STATUS_CODE_MEMORY_PPI; + +extern EFI_GUID gPeiStatusCodeMemoryPpiGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c new file mode 100644 index 0000000000..991559805d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ConsoleControl.c + +Abstract: + + Abstraction of a Text mode or GOP/UGA screen + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (ConsoleControl) + + +EFI_GUID gEfiConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiConsoleControlProtocolGuid, "Console Control Protocol", "Console Control Protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h new file mode 100644 index 0000000000..5185cc7d33 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h @@ -0,0 +1,122 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ConsoleControl.h + +Abstract: + + Abstraction of a Text mode or GOP/UGA screen + +--*/ + +#ifndef __CONSOLE_CONTROL_H__ +#define __CONSOLE_CONTROL_H__ + +#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \ + { 0xf42f7782, 0x12e, 0x4c12, 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } + +typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL; + + +typedef enum { + EfiConsoleControlScreenText, + EfiConsoleControlScreenGraphics, + EfiConsoleControlScreenMaxValue +} EFI_CONSOLE_CONTROL_SCREEN_MODE; + + +typedef +EFI_STATUS +(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE) ( + IN EFI_CONSOLE_CONTROL_PROTOCOL *This, + OUT EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode, + OUT BOOLEAN *GopUgaExists, OPTIONAL + OUT BOOLEAN *StdInLocked OPTIONAL + ) +/*++ + + Routine Description: + Return the current video mode information. Also returns info about existence + of Graphics Output devices or UGA Draw devices in system, and if the Std In + device is locked. All the arguments are optional and only returned if a non + NULL pointer is passed in. + + Arguments: + This - Protocol instance pointer. + Mode - Are we in text of grahics mode. + GopUgaExists - TRUE if Console Spliter has found a GOP or UGA device + StdInLocked - TRUE if StdIn device is keyboard locked + + Returns: + EFI_SUCCESS - Mode information returned. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) ( + IN EFI_CONSOLE_CONTROL_PROTOCOL *This, + OUT EFI_CONSOLE_CONTROL_SCREEN_MODE Mode + ) +/*++ + + Routine Description: + Set the current mode to either text or graphics. Graphics is + for Quiet Boot. + + Arguments: + This - Protocol instance pointer. + Mode - Mode to set the + + Returns: + EFI_SUCCESS - Mode information returned. + +--*/ +; + + +typedef +EFI_STATUS +(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN) ( + IN EFI_CONSOLE_CONTROL_PROTOCOL *This, + IN CHAR16 *Password + ) +/*++ + + Routine Description: + Lock Std In devices until Password is typed. + + Arguments: + This - Protocol instance pointer. + Password - Password needed to unlock screen. NULL means unlock keyboard + + Returns: + EFI_SUCCESS - Mode information returned. + EFI_DEVICE_ERROR - Std In not locked + +--*/ +; + + + +typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL { + EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode; + EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode; + EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn; +} EFI_CONSOLE_CONTROL_PROTOCOL; + +extern EFI_GUID gEfiConsoleControlProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c b/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c new file mode 100644 index 0000000000..cfe4a0ac0c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CustomizedDecompress.c + +Abstract: + + The GUID for the user Customized Decompress Protocol + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(CustomizedDecompress) + +EFI_GUID gEfiCustomizedDecompressProtocolGuid = EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiCustomizedDecompressProtocolGuid, "Cutomized Decompress", "Customized Decompression Protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h b/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h new file mode 100644 index 0000000000..8e237456ea --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h @@ -0,0 +1,139 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CustomizedDecompress.h + +Abstract: + + The user Customized Decompress Protocol Interface + +--*/ + +#ifndef _CUSTOMIZED_DECOMPRESS_H_ +#define _CUSTOMIZED_DECOMPRESS_H_ + +#define EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL_GUID \ + { 0x9a44198e, 0xa4a2, 0x44e6, 0x8a, 0x1f, 0x39, 0xbe, 0xfd, 0xac, 0x89, 0x6f } + +EFI_FORWARD_DECLARATION (EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_CUSTOMIZED_DECOMPRESS_GET_INFO) ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); +/*++ + +Routine Description: + + The GetInfo() function retrieves the size of the uncompressed buffer + and the temporary scratch buffer required to decompress the buffer + specified by Source and SourceSize. If the size of the uncompressed + buffer or the size of the scratch buffer cannot be determined from + the compressed data specified by Source and SourceData, then + EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed + buffer is returned in DestinationSize, the size of the scratch buffer is + returned in ScratchSize, and EFI_SUCCESS is returned. + + The GetInfo() function does not have scratch buffer available to perform + a thorough checking of the validity of the source data. It just retrieves + the 'Original Size' field from the beginning bytes of the source data and + output it as DestinationSize. And ScratchSize is specific to the decompression + implementation. + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SourceSize - The size, in bytes, of source buffer. + DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer + that will be generated when the compressed buffer specified + by Source and SourceSize is decompressed. + ScratchSize - A pointer to the size, in bytes, of the scratch buffer that + is required to decompress the compressed buffer specified by + Source and SourceSize. + +Returns: + EFI_SUCCESS - The size of the uncompressed data was returned in DestinationSize + and the size of the scratch buffer was returned in ScratchSize. + EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch + buffer cannot be determined from the compressed data specified by + Source and SourceData. + +--*/ + + +typedef +EFI_STATUS +(EFIAPI *EFI_CUSTOMIZED_DECOMPRESS_DECOMPRESS) ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID* Source, + IN UINT32 SourceSize, + IN OUT VOID* Destination, + IN UINT32 DestinationSize, + IN OUT VOID* Scratch, + IN UINT32 ScratchSize + ); +/*++ + +Routine Description: + + The Decompress() function extracts decompressed data to its original form. + + This protocol is designed so that the decompression algorithm can be + implemented without using any memory services. As a result, the + Decompress() function is not allowed to call AllocatePool() or + AllocatePages() in its implementation. It is the caller's responsibility + to allocate and free the Destination and Scratch buffers. + + If the compressed source data specified by Source and SourceSize is + sucessfully decompressed into Destination, then EFI_SUCCESS is returned. + If the compressed source data specified by Source and SourceSize is not in + a valid compressed data format, then EFI_INVALID_PARAMETER is returned. + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SourceSize - The size of source data. + Destination - On output, the destination buffer that contains + the uncompressed data. + DestinationSize - The size of destination buffer. The size of destination + buffer needed is obtained from GetInfo(). + Scratch - A temporary scratch buffer that is used to perform the + decompression. + ScratchSize - The size of scratch buffer. The size of scratch buffer needed + is obtained from GetInfo(). + +Returns: + + EFI_SUCCESS - Decompression completed successfully, and the uncompressed + buffer is returned in Destination. + EFI_INVALID_PARAMETER + - The source buffer specified by Source and SourceSize is + corrupted (not in a valid compressed format). + +--*/ + +typedef struct _EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL { + EFI_CUSTOMIZED_DECOMPRESS_GET_INFO GetInfo; + EFI_CUSTOMIZED_DECOMPRESS_DECOMPRESS Decompress; +} EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL; + +extern EFI_GUID gEfiCustomizedDecompressProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.c b/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.c new file mode 100644 index 0000000000..3303fc3dca --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugAssert.c + +Abstract: + + This protocol allows provides debug services to a driver. This is not + debugger support, but things like ASSERT() and DEBUG() macros + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(DebugAssert) + + +EFI_GUID gEfiDebugAssertProtocolGuid = EFI_DEBUG_ASSERT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDebugAssertProtocolGuid, "EFI Debug Assert", "Efi Debug Assert Protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.h b/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.h new file mode 100644 index 0000000000..174869329e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DebugAssert/DebugAssert.h @@ -0,0 +1,89 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugAssert.h + +Abstract: + + This protocol allows provides debug services to a driver. This is not + debugger support, but things like ASSERT() and DEBUG() macros + +--*/ + +#ifndef _DEBUG_ASSERT_H_ +#define _DEBUG_ASSERT_H_ + + +#define EFI_DEBUG_ASSERT_PROTOCOL_GUID \ + { 0xbe499c92, 0x7d4b, 0x11d4, 0xbc, 0xee, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_DEBUG_ASSERT_PROTOCOL); + + +typedef +EFI_STATUS +(EFIAPI *EFI_DEBUG_ASSERT) ( + IN EFI_DEBUG_ASSERT_PROTOCOL *This, + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DEBUG_PRINT) ( + IN EFI_DEBUG_ASSERT_PROTOCOL *This, + IN UINTN ErrorLevel, + IN CHAR8 *Format, + IN VA_LIST Marker + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_POST_CODE) ( + IN EFI_DEBUG_ASSERT_PROTOCOL *This, + IN UINT16 PostCode, + IN CHAR8 *PostCodeString OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_ERROR_LEVEL) ( + IN EFI_DEBUG_ASSERT_PROTOCOL *This, + IN UINTN *ErrorLevel + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_ERROR_LEVEL) ( + IN EFI_DEBUG_ASSERT_PROTOCOL *This, + IN UINTN ErrorLevel + ); + +typedef struct _EFI_DEBUG_ASSERT_PROTOCOL { + + EFI_DEBUG_ASSERT Assert; + EFI_DEBUG_PRINT Print; + EFI_POST_CODE PostCode; + + EFI_GET_ERROR_LEVEL GetErrorLevel; + EFI_SET_ERROR_LEVEL SetErrorLevel; + +} EFI_DEBUG_ASSERT_PROTOCOL; + +extern EFI_GUID gEfiDebugAssertProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.c b/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.c new file mode 100644 index 0000000000..3efa66185e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugMask.c + +Abstract: + + This protocol is used to abstract the Debug Mask serivces for + the specific driver or application image. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(DebugMask) + + +EFI_GUID gEfiDebugMaskProtocolGuid = EFI_DEBUG_MASK_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDebugMaskProtocolGuid, "DebugMask Protocol", "Efi Debug Mask Protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.h b/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.h new file mode 100644 index 0000000000..8a8e638fae --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DebugMask/DebugMask.h @@ -0,0 +1,68 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugMask.h + +Abstract: + + This protocol is used to abstract the Debug Mask serivces for + the specific driver or application image. + +--*/ + +#ifndef _DEBUG_MASK_H_ +#define _DEBUG_MASK_H_ + +// +//4C8A2451-C207-405b-9694-99EA13251341 +// +#define EFI_DEBUG_MASK_PROTOCOL_GUID \ + { 0x4c8a2451, 0xc207, 0x405b, 0x96, 0x94, 0x99, 0xea, 0x13, 0x25, 0x13, 0x41 } + + +#define EFI_DEBUG_MASK_REVISION 0x00010000 + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_DEBUG_MASK_PROTOCOL); + +// +// DebugMask member functions definition +// +typedef +EFI_STATUS +(EFIAPI * EFI_GET_DEBUG_MASK) ( + IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context + IN OUT UINTN *CurrentDebugMask // Ptr to store current debug mask + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_DEBUG_MASK) ( + IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context + IN UINTN NewDebugMask // New Debug Mask value to set + ); + +// +// DebugMask protocol definition +// +typedef struct _EFI_DEBUG_MASK_PROTOCOL { + INT64 Revision; + EFI_GET_DEBUG_MASK GetDebugMask; + EFI_SET_DEBUG_MASK SetDebugMask; +} EFI_DEBUG_MASK_PROTOCOL; + +extern EFI_GUID gEfiDebugMaskProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.c b/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.c new file mode 100644 index 0000000000..e8c4773e44 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugSerialIo.c + +Abstract: + + Debug Serial IO protocol. + + Abstraction of a basic serial device. Targeted at 16550 UART, but + could be much more generic. + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (DebugSerialIo) + +EFI_GUID gEfiDebugSerialIoProtocolGuid = EFI_DEBUG_SERIAL_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDebugSerialIoProtocolGuid, "DebugSerialIo Protocol", "EFI 1.0 DebugSerial IO Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.h b/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.h new file mode 100644 index 0000000000..22278f5207 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DebugSerialIO/DebugSerialIo.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DebugSerialIo.h + +Abstract: + + Debug Serial IO protocol. + + Abstraction of a basic serial device. Targeted at 16550 UART, but + could be much more generic. + +--*/ + +#ifndef _DEBUG_SERIAL_IO_H_ +#define _DEBUG_SERIAL_IO_H_ + +#define EFI_DEBUG_SERIAL_IO_PROTOCOL_GUID \ +{ 0xe683dc4f, 0x9ed, 0x4f22, { 0x86, 0x6b, 0x8e, 0x40, 0x46, 0x94, 0x7c, 0x6c } } + +EFI_FORWARD_DECLARATION (EFI_DEBUG_SERIAL_IO_PROTOCOL); + +#include EFI_PROTOCOL_DEFINITION (SerialIo) + +extern EFI_GUID gEfiDebugSerialIoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.c b/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.c new file mode 100644 index 0000000000..fb09f3093f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DiskInfo.c + +Abstract: + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (DiskInfo) + +EFI_GUID gEfiDiskInfoProtocolGuid = EFI_DISK_INFO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiDiskInfoProtocolGuid, "Disk Info Protocol", "Disk Info Protocol"); + +EFI_GUID gEfiDiskInfoIdeInterfaceGuid = EFI_DISK_INFO_IDE_INTERFACE_GUID; +EFI_GUID gEfiDiskInfoScsiInterfaceGuid = EFI_DISK_INFO_SCSI_INTERFACE_GUID; +EFI_GUID gEfiDiskInfoUsbInterfaceGuid = EFI_DISK_INFO_USB_INTERFACE_GUID; diff --git a/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.h b/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.h new file mode 100644 index 0000000000..3de25d9817 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/DiskInfo/DiskInfo.h @@ -0,0 +1,174 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DiskInfo.h + +Abstract: + + Disk Info protocol is used to export Inquiry Data for a drive. + Its needed to support low level formating of drives in a mannor + thats DOS compatible. + +--*/ + +#ifndef __DISK_INFO_H__ +#define __DISK_INFO_H__ + +#define EFI_DISK_INFO_PROTOCOL_GUID \ + { \ + 0xd432a67f, 0x14dc, 0x484b, 0xb3, 0xbb, 0x3f, 0x2, 0x91, 0x84, 0x93, 0x27 \ + } + +EFI_FORWARD_DECLARATION (EFI_DISK_INFO_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_INFO_INQUIRY) ( + IN EFI_DISK_INFO_PROTOCOL * This, + IN OUT VOID *InquiryData, + IN OUT UINT32 *IntquiryDataSize + ) +/*++ + + Routine Description: + Return the results of the Inquiry command to a drive in InquiryData. + Data format of Inquiry data is defined by the Interface GUID. + + Arguments: + This - Protocol instance pointer. + InquiryData - Results of Inquiry command to device + InquiryDataSize - Size of InquiryData in bytes. + + Returns: + EFI_SUCCESS - InquiryData valid + EFI_NOT_FOUND - Device does not support this data class + EFI_DEVICE_ERROR - Error reading InquiryData from device + EFI_BUFFER_TOO_SMALL - IntquiryDataSize not big enough + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_INFO_IDENTIFY) ( + IN EFI_DISK_INFO_PROTOCOL * This, + IN OUT VOID *IdentifyData, + IN OUT UINT32 *IdentifyDataSize + ) +/*++ + + Routine Description: + Return the results of the Identify command to a drive in IdentifyData. + Data format of Identify data is defined by the Interface GUID. + + Arguments: + This - Protocol instance pointer. + IdentifyData - Results of Identify command to device + IdentifyDataSize - Size of IdentifyData in bytes. + + Returns: + EFI_SUCCESS - IdentifyData valid + EFI_NOT_FOUND - Device does not support this data class + EFI_DEVICE_ERROR - Error reading IdentifyData from device + EFI_BUFFER_TOO_SMALL - IdentifyDataSize not big enough + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_INFO_SENSE_DATA) ( + IN EFI_DISK_INFO_PROTOCOL * This, + IN OUT VOID *SenseData, + IN OUT UINT32 *SenseDataSize, + OUT UINT8 *SenseDataNumber + ) +/*++ + + Routine Description: + Return the results of the Request Sense command to a drive in SenseData. + Data format of Sense data is defined by the Interface GUID. + + Arguments: + This - Protocol instance pointer. + SenseData - Results of Request Sense command to device + SenseDataSize - Size of SenseData in bytes. + SenseDataNumber - Type of SenseData + + Returns: + EFI_SUCCESS - InquiryData valid + EFI_NOT_FOUND - Device does not support this data class + EFI_DEVICE_ERROR - Error reading InquiryData from device + EFI_BUFFER_TOO_SMALL - SenseDataSize not big enough + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_INFO_WHICH_IDE) ( + IN EFI_DISK_INFO_PROTOCOL * This, + OUT UINT32 *IdeChannel, + OUT UINT32 *IdeDevice + ) +/*++ + + Routine Description: + Return the results of the Request Sense command to a drive in SenseData. + Data format of Sense data is defined by the Interface GUID. + + Arguments: + This - Protocol instance pointer. + IdeChannel - Primary or Secondary + IdeDevice - Master or Slave + + Returns: + EFI_SUCCESS - IdeChannel and IdeDevice are valid + EFI_UNSUPPORTED - This is not an IDE device + +--*/ +; + +// +// GUIDs for EFI_DISK_INFO_PROTOCOL.Interface. Defines the format of the +// buffers returned by member functions +// +#define EFI_DISK_INFO_IDE_INTERFACE_GUID \ + { \ + 0x5e948fe3, 0x26d3, 0x42b5, 0xaf, 0x17, 0x61, 0x2, 0x87, 0x18, 0x8d, 0xec \ + } +extern EFI_GUID gEfiDiskInfoIdeInterfaceGuid; + +#define EFI_DISK_INFO_SCSI_INTERFACE_GUID \ + { \ + 0x8f74baa, 0xea36, 0x41d9, 0x95, 0x21, 0x21, 0xa7, 0xf, 0x87, 0x80, 0xbc \ + } +extern EFI_GUID gEfiDiskInfoScsiInterfaceGuid; + +#define EFI_DISK_INFO_USB_INTERFACE_GUID \ + { \ + 0xcb871572, 0xc11a, 0x47b5, 0xb4, 0x92, 0x67, 0x5e, 0xaf, 0xa7, 0x77, 0x27 \ + } +extern EFI_GUID gEfiDiskInfoUsbInterfaceGuid; + +typedef struct _EFI_DISK_INFO_PROTOCOL { + EFI_GUID Interface; + EFI_DISK_INFO_INQUIRY Inquiry; + EFI_DISK_INFO_IDENTIFY Identify; + EFI_DISK_INFO_SENSE_DATA SenseData; + EFI_DISK_INFO_WHICH_IDE WhichIde; +} EFI_DISK_INFO_PROTOCOL; + +extern EFI_GUID gEfiDiskInfoProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/EdkProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Protocol/EdkProtocolLib.inf new file mode 100644 index 0000000000..7d769c0ecc --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/EdkProtocolLib.inf @@ -0,0 +1,111 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkProtocolLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME= EdkProtocolLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + +[nmake.common] + +[sources.common] + ConsoleControl\ConsoleControl.h + ConsoleControl\ConsoleControl.c + CustomizedDecompress\CustomizedDecompress.c + CustomizedDecompress\CustomizedDecompress.h + DebugAssert\DebugAssert.h + DebugAssert\DebugAssert.c + DebugMask\DebugMask.h + DebugMask\DebugMask.c + DebugSerialIo\DebugSerialIo.h + DebugSerialIo\DebugSerialIo.c + DiskInfo\DiskInfo.h + DiskInfo\DiskInfo.c + EfiOemBadging\EfiOemBadging.h + EfiOemBadging\EfiOemBadging.c + FaultTolerantWriteLite\FaultTolerantWriteLite.h + FaultTolerantWriteLite\FaultTolerantWriteLite.c + FirmwareVolumeDispatch\FirmwareVolumeDispatch.h + FirmwareVolumeDispatch\FirmwareVolumeDispatch.c + FvbExtension\FvbExtension.h + FvbExtension\FvbExtension.c + GenericMemoryTest\GenericMemoryTest.h + GenericMemoryTest\GenericMemoryTest.c + GuidedSectionExtraction\GuidedSectionExtraction.h + GuidedSectionExtraction\GuidedSectionExtraction.c + IsaAcpi\IsaAcpi.h + IsaAcpi\IsaAcpi.c + IsaIo\IsaIo.h + IsaIo\IsaIo.c + LegacyBiosThunk\LegacyBiosThunk.h + LegacyBiosThunk\LegacyBiosThunk.c + LoadPe32Image\LoadPe32Image.h + LoadPe32Image\LoadPe32Image.c + NicIp4Config\NicIp4Config.h + NicIp4Config\NicIp4Config.c + PciHotPlugRequest\PciHotPlugRequest.h + PciHotPlugRequest\PciHotPlugRequest.c + Performance\Performance.h + Performance\Performance.c + PlatformMemTest\PlatformMemTest.h + PlatformMemTest\PlatformMemTest.c + Print\Print.h + Print\Print.c + PxeDhcp4\PxeDhcp4.h + PxeDhcp4\PxeDhcp4.c + PxeDhcp4Callback\PxeDhcp4Callback.h + PxeDhcp4Callback\PxeDhcp4Callback.c + Tcp\Tcp.h + Tcp\Tcp.c + TianoDecompress\TianoDecompress.h + TianoDecompress\TianoDecompress.c + UgaSplash\UgaSplash.h + UgaSplash\UgaSplash.c + UsbAtapi\UsbAtapi.h + UsbAtapi\UsbAtapi.c + VariableStore\VariableStore.h + VariableStore\VariableStore.c + VirtualMemoryAccess\VirtualMemoryAccess.h + VirtualMemoryAccess\VirtualMemoryAccess.c + TcgService\TcgService.h + TcgService\TcgService.c + Ps2Policy\Ps2Policy.h + Ps2Policy\Ps2Policy.c + VgaMiniPort\VgaMiniPort.h + VgaMiniPort\VgaMiniPort.c + +[sources.ipf] + ExtendedSalBootService\ExtendedSalBootService.c + ExtendedSalBootService\ExtendedSalBootService.h + ExtendedSalGuid\ExtendedSalGuid.c + ExtendedSalGuid\ExtendedSalGuid.h diff --git a/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c b/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c new file mode 100644 index 0000000000..bb48e17e78 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiOEMBadging.c + +Abstract: + + EFI OEM Badging Protocol definition source file + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (EfiOEMBadging) + +EFI_GUID gEfiOEMBadgingProtocolGuid = EFI_OEM_BADGING_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiOEMBadgingProtocolGuid, "OEM Badging Protocol", "OEM Badging Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h b/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h new file mode 100644 index 0000000000..0dceb7fc02 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h @@ -0,0 +1,79 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiOEMBadging.h + +Abstract: + + EFI OEM Badging Protocol definition header file + +Revision History + +--*/ + +#ifndef _EFI_OEM_BADGING_H_ +#define _EFI_OEM_BADGING_H_ + +// +// GUID for EFI OEM Badging Protocol +// +#define EFI_OEM_BADGING_PROTOCOL_GUID \ + { 0x170e13c0, 0xbf1b, 0x4218, 0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc } + + +EFI_FORWARD_DECLARATION (EFI_OEM_BADGING_PROTOCOL); + +typedef enum { + EfiBadgingFormatBMP, + EfiBadgingFormatJPEG, + EfiBadgingFormatTIFF, + EfiBadgingFormatGIF, + EfiBadgingFormatUnknown +} EFI_BADGING_FORMAT; + +typedef enum { + EfiBadgingDisplayAttributeLeftTop, + EfiBadgingDisplayAttributeCenterTop, + EfiBadgingDisplayAttributeRightTop, + EfiBadgingDisplayAttributeCenterRight, + EfiBadgingDisplayAttributeRightBottom, + EfiBadgingDisplayAttributeCenterBottom, + EfiBadgingDisplayAttributeLeftBottom, + EfiBadgingDisplayAttributeCenterLeft, + EfiBadgingDisplayAttributeCenter, + EfiBadgingDisplayAttributeCustomized +} EFI_BADGING_DISPLAY_ATTRIBUTE; + + +typedef +EFI_STATUS +(EFIAPI *EFI_BADGING_GET_IMAGE) ( + IN EFI_OEM_BADGING_PROTOCOL *This, + IN OUT UINT32 *Instance, + OUT EFI_BADGING_FORMAT *Format, + OUT UINT8 **ImageData, + OUT UINTN *ImageSize, + OUT EFI_BADGING_DISPLAY_ATTRIBUTE *Attribute, + OUT UINTN *CoordinateX, + OUT UINTN *CoordinateY +); + + +typedef struct _EFI_OEM_BADGING_PROTOCOL { + EFI_BADGING_GET_IMAGE GetImage; +} EFI_OEM_BADGING_PROTOCOL; + + +extern EFI_GUID gEfiOEMBadgingProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c new file mode 100644 index 0000000000..9613745b12 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ExtendedSalBootService.c + +Abstract: + + This is a protocol creates infrastructure to register Extended Sal Procs. + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(ExtendedSalBootService) + +EFI_GUID gEfiExtendedSalBootServiceProtocolGuid = EXTENDED_SAL_BOOT_SERVICE_PROTOCOL_GUID; +EFI_GUID_STRING(&gEfiExtendedSalBootServiceProtocolGuid, "EXT SAL", "Extended Sal Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h new file mode 100644 index 0000000000..8c7e1053cb --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h @@ -0,0 +1,118 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ExtendedSalBootService.h + +Abstract: + +--*/ + +#ifndef _EXTENDED_SAL_PROTOCOL_H_ +#define _EXTENDED_SAL_PROTOCOL_H_ + +#include "SalApi.h" +#include "LinkedList.h" +#include EFI_PROTOCOL_CONSUMER (CpuIo) + + +#define EXTENDED_SAL_BOOT_SERVICE_PROTOCOL_GUID \ + {0xde0ee9a4,0x3c7a,0x44f2,0xb7,0x8b,0xe3,0xcc,0xd6,0x9c,0x3a,0xf7} + +#define EXTENDED_SAL_SIGNATURE EFI_SIGNATURE_32('e', 's', 'a', 'l') + +#define SAL_MIN_STATE_SIZE 0x400 * 1 +#define PAL_SCARTCH_SIZE 0x400 * 3 +#define ALIGN_MINSTATE_SIZE 512 +#define MAX_SAL_RECORD_SIZE 8*1024 + +#define SAL_RUNTIMESERVICE + +typedef UINT16 EFI_SAL_PROCESSOR_ID; + +EFI_FORWARD_DECLARATION (EXTENDED_SAL_BOOT_SERVICE_PROTOCOL); + +typedef +SAL_RUNTIMESERVICE +SAL_RETURN_REGS +(EFIAPI *SAL_EXTENDED_SAL_PROC) ( + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8 + ); + +typedef +SAL_RUNTIMESERVICE +SAL_RETURN_REGS +(EFIAPI *SAL_INTERNAL_EXTENDED_SAL_PROC) ( + IN UINT64 FunctionId, + IN UINT64 Arg2, + IN UINT64 Arg3, + IN UINT64 Arg4, + IN UINT64 Arg5, + IN UINT64 Arg6, + IN UINT64 Arg7, + IN UINT64 Arg8, + IN SAL_EXTENDED_SAL_PROC ExtendedSalProc, + IN BOOLEAN VirtualMode, + IN VOID *ModuleGlobal + ); + +typedef +EFI_STATUS +(EFIAPI *EXTENDED_SAL_ADD_SST_INFO) ( + IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *This, + IN UINT16 SalAVersion, + IN UINT16 SalBVersion, + IN CHAR8 *OemId, + IN CHAR8 *ProductId + ); + +typedef +EFI_STATUS +(EFIAPI *EXTENDED_SAL_ADD_SST_ENTRY) ( + IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *This, + IN UINT8 EntryType, + IN UINT8 *TableEntry, + IN UINTN EntrySize + ); + +typedef +EFI_STATUS +(EFIAPI *EXTENDED_SAL_REGISTER_INTERNAL_PROC) ( + IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *This, + IN EFI_GUID *ClassGuid, + IN UINT64 FunctionId, + IN SAL_INTERNAL_EXTENDED_SAL_PROC InternalSalProc, + IN VOID *PhysicalModuleGlobal + ); + +// +// Extended Sal Boot Service Protocol Interface +// +typedef struct _EXTENDED_SAL_BOOT_SERVICE_PROTOCOL{ + EXTENDED_SAL_ADD_SST_INFO AddSalSystemTableInfo; + EXTENDED_SAL_ADD_SST_ENTRY AddSalSystemTableEntry; + EXTENDED_SAL_REGISTER_INTERNAL_PROC AddExtendedSalProc; + SAL_EXTENDED_SAL_PROC ExtendedSalProc; + SAL_PROC SalProc; +} EXTENDED_SAL_BOOT_SERVICE_PROTOCOL; + +extern EFI_GUID gEfiExtendedSalBootServiceProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c new file mode 100644 index 0000000000..2d8624dc32 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ExtendedSalGuid.c + +Abstract: + + The Extended SAL Lock Services protocol as defined in SAL CIS. + + This protocol is installed by the entity that supplies low level + lock primitives that work in dual mode. There are 3 functions + as defined below. + +--*/ + + + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(ExtendedSalGuid) + +EFI_GUID gEfiExtendedSalBaseIoServicesProtocolGuid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalStallServicesProtocolGuid = EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalLockServicesProtocolGuid = EFI_EXTENDED_SAL_LOCK_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalVirtualServicesProtocolGuid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalRtcServicesProtocolGuid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalVariableServicesProtocolGuid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalMtcServicesProtocolGuid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalResetServicesProtocolGuid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalStatusCodeServicesProtocolGuid = EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalFvBlockServicesProtocolGuid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalMpServicesProtocolGuid = EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalPalServicesProtocolGuid = EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalBaseServicesProtocolGuid = EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalMcaServicesProtocolGuid = EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalPciServicesProtocolGuid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalCacheServicesProtocolGuid = EFI_EXTENDED_SAL_CACHE_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalMcaLogServicesProtocolGuid = EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalElogServicesProtocolGuid = EFI_EXTENDED_SAL_ELOG_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalSensorServicesProtocolGuid = EFI_EXTENDED_SAL_SENSOR_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalSmComLayerServicesProtocolGuid = EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_PROTOCOL_GUID; +EFI_GUID gEfiExtendedSalSstGuid = EFI_EXTENDED_SAL_SST_GUID; + + +EFI_GUID_STRING(&gEfiExtendedSalBaseIoServicesProtocolGuid, "SAL IO", "Extended SAL Base IO Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalStallServicesProtocolGuid, "SAL STALL", "Extended SAL Stall Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalLockServicesProtocolGuid, "SAL LOCK", "Extended SAL Lock Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalVirtualServicesProtocolGuid, "SAL VIRT", "Extended SAL Virtual Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalRtcServicesProtocolGuid, "SAL RTC", "Extended SAL Lock RTC Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalVariableServicesProtocolGuid, "SAL VARIABLE", "Extended SAL Variable Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalMtcServicesProtocolGuid, "SAL MTC", "Extended SAL MTC Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalResetServicesProtocolGuid, "SAL RESET", "Extended SAL Reset Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalStatusCodeServicesProtocolGuid, "SAL STATUS CODE", "Extended SAL Status Call Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalFvBlockServicesProtocolGuid, "SAL FVB", "Extended SAL FVB Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalMpServicesProtocolGuid, "SAL MP", "Extended SAL MP Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalPalServicesProtocolGuid, "SAL PAL", "Extended SAL PAL Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalBaseServicesProtocolGuid, "SAL BASE", "Extended SAL Base Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalBaseServicesProtocolGuid, "SAL MCA", "Extended SAL MCA Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalPciServicesProtocolGuid, "SAL PCI", "Extended SAL PCI Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalCacheServicesProtocolGuid, "SAL CACHE", "Extended SAL Cache Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalMcaLogServicesProtocolGuid, "MCA LOG", "Extended SAL MCA LOG Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalElogServicesProtocolGuid, "ELOG", "Extended SAL ELOG Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalSensorServicesProtocolGuid, "SENSOR", "Extended SAL SENSOR Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalSmComLayerServicesProtocolGuid, "SAL SM COM", "Extended SAL SM COM Services Protocol"); +EFI_GUID_STRING(&gEfiExtendedSalSstGuid, "SST SET UP", "SAL System Table Header Set up"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h new file mode 100644 index 0000000000..44361c19b7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h @@ -0,0 +1,283 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ExtendedSalGuid.h + +Abstract: + + +--*/ + +#ifndef _EXTENDED_SAL_GUID_H_ +#define _EXTENDED_SAL_GUID_H_ + +// +// Extended SAL Services protocol GUIDs +// + +#define EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID \ + { 0x5aea42b5, 0x31e1, 0x4515, 0xbc, 0x31, 0xb8, 0xd5, 0x25, 0x75, 0x65, 0xa6 } + +#define EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID \ + { 0x53a58d06, 0xac27, 0x4d8c, 0xb5, 0xe9, 0xf0, 0x8a, 0x80, 0x65, 0x41, 0x70 } + +#define EFI_EXTENDED_SAL_LOCK_SERVICES_PROTOCOL_GUID \ + { 0x76b75c23, 0xfe4f, 0x4e17, 0xa2, 0xad, 0x1a, 0x65, 0x3d, 0xbb, 0x49, 0x4a } + +#define EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID \ + { 0xc1a74056, 0x260e, 0x4871, 0xa0, 0x31, 0xe6, 0x45, 0xa6, 0x5b, 0x6e, 0x11 } + +#define EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID \ + { 0x7e97a470, 0xefdb, 0x4d02, 0x8f, 0xce, 0x61, 0x90, 0xd2, 0x7b, 0xa2, 0x96 } + +#define EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID \ + { 0x4ecb6c53, 0xc641, 0x4370, 0x8c, 0xb2, 0x3b, 0x0e, 0x49, 0x6e, 0x83, 0x78 } + +#define EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID \ + { 0x899afd18, 0x75e8, 0x408b, 0xa4, 0x1a, 0x6e, 0x2e, 0x7e, 0xcd, 0xf4, 0x54 } + +#define EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID \ + { 0x7d019990, 0x8ce1, 0x46f5, 0xa7, 0x76, 0x3c, 0x51, 0x98, 0x67, 0x6a, 0xa0 } + +#define EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID \ + { 0xdbd91d, 0x55e9, 0x420f, 0x96, 0x39, 0x5e, 0x9f, 0x84, 0x37, 0xb4, 0x4f } + +#define EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID \ + { 0xa2271df1, 0xbcbb, 0x4f1d, 0x98, 0xa9, 0x06, 0xbc, 0x17, 0x2f, 0x07, 0x1a } + +#define EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID \ + { 0x697d81a2, 0xcf18, 0x4dc0, 0x9e, 0x0d, 0x06, 0x11, 0x3b, 0x61, 0x8a, 0x3f } + +#define EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID \ + { 0xe1cd9d21, 0x0fc2, 0x438d, 0x97, 0x03, 0x04, 0xe6, 0x6d, 0x96, 0x1e, 0x57 } + +#define EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID \ + { 0xd9e9fa06, 0x0fe0, 0x41c3, 0x96, 0xfb, 0x83, 0x42, 0x5a, 0x33, 0x94, 0xf8 } + +#define EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID \ + { 0x2a591128, 0x6cc7, 0x42b1, 0x8a, 0xf0, 0x58, 0x93, 0x3b, 0x68, 0x2d, 0xbb } + +#define EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID \ + { 0xa46b1a31, 0xad66, 0x4905, 0x92, 0xf6, 0x2b, 0x46, 0x59, 0xdc, 0x30, 0x63 } + +#define EFI_EXTENDED_SAL_CACHE_SERVICES_PROTOCOL_GUID \ + { 0xedc9494, 0x2743, 0x4ba5, 0x88, 0x18, 0x0a, 0xef, 0x52, 0x13, 0xf1, 0x88 } + +#define EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID \ + { 0xcb3fd86e, 0x38a3, 0x4c03, 0x9a, 0x5c, 0x90, 0xcf, 0xa3, 0xa2, 0xab, 0x7a } + +#define EFI_EXTENDED_SAL_ELOG_SERVICES_PROTOCOL_GUID \ + { 0xd5e4ee5f, 0x3e0a, 0x453c, 0xa7, 0x25, 0xb6, 0x92, 0xbb, 0x6, 0x36, 0x5a } + +#define EFI_EXTENDED_SAL_SENSOR_SERVICES_PROTOCOL_GUID \ + { 0x4a153b6e, 0x85a1, 0x4982, 0x98, 0xf4, 0x6a, 0x8c, 0xfc, 0xa4, 0xab, 0xa1 } + +#define EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_PROTOCOL_GUID \ + { 0x4356799, 0x81b7, 0x4e08, 0xa3, 0x8d, 0xd9, 0x78, 0xfa, 0x47, 0xba, 0x42 } + +#define EFI_EXTENDED_SAL_SST_GUID \ + { 0x38802700, 0x868a, 0x4b4e, 0x81, 0xd4, 0x4f, 0x1b, 0xdc, 0xcf, 0xb4, 0x6f } + +// +// Extended Sal Proc Function IDs. +// + +// +// BugBug: These enums are name colisions waiting to happen. They should all be +// prefixed with Esal! It might be better to just make them #define, so +// they would be all caps. +// + +typedef enum { + IoRead, + IoWrite, + MemRead, + MemWrite +} EFI_EXTENDED_SAL_BASE_IO_SERVICES_FUNC_ID; + +typedef enum { + Stall +} EFI_EXTENDED_SAL_STALL_FUNC_ID; + + +typedef enum { + InitializeLockService, + AcquireLockService, + ReleaseLockService, + MaxLockServiceFunctionId +} EFI_EXTENDED_SAL_LOCK_SERVICES_FUNC_ID; + +// +// BugBug : Covert the first 3 functions into a lib functions +// and move SalRegisterPhysicalAddress to SAL BASE Class +// +typedef enum { + SetVirtualAddress, + IsVirtual, + IsEfiRuntime, + SalRegisterPhysicalAddress +} EFI_EXTENDED_SAL_VIRTUAL_SERVICES_FUNC_ID; + +typedef enum { + GetTime, + SetTime, + GetWakeupTime, + SetWakeupTime, + GetRtcFreq, + InitializeThreshold, + BumpThresholdCount, + GetThresholdCount +} EFI_EXTENDED_SAL_RTC_SERVICES_FUNC_ID; + +typedef enum { + EsalGetVariable, + EsalGetNextVariableName, + EsalSetVariable +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + , + EsalQueryVariableInfo +#endif +} EFI_EXTENDED_SAL_VARIABLE_SERVICES_FUNC_ID; + +typedef enum { + GetNextHighMonotonicCount +} EFI_EXTENDED_SAL_MTC_SERVICES_FUNC_ID; + +typedef enum { + ResetSystem +} EFI_EXTENDED_SAL_RESET_SERVICES_FUNC_ID; + +typedef enum { + StatusCode +} EFI_EXTENDED_SAL_STATUS_CODE_FUNC_ID; + +typedef enum { + ReportStatusCode +} EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_FUNC_ID; + +typedef enum { + Read, + Write, + EraseBlock, + GetVolumeAttributes, + SetVolumeAttributes, + GetPhysicalAddress, + GetBlockSize, + EraseCustomBlockRange, +} EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_FUNC_ID; + +typedef enum { + AddCpuData, + RemoveCpuData, + ModifyCpuData, + GetCpuDataByID, + GetCpuDataByIndex, + SendIpi, + CurrentProcInfo, + NumProcessors, + SetMinState, + GetMinState +} EFI_EXTENDED_SAL_MP_SERVICES_FUNC_ID; + +typedef enum { + PalProc, + SetNewPalEntry, + GetNewPalEntry +} EFI_EXTENDED_SAL_PAL_SERVICES_FUNC_ID; + +typedef enum { + SalSetVectors, + SalMcRendez, + SalMcSetParams, + EsalGetVectors, + EsalMcGetParams, + EsalMcGetMcParams, + EsalGetMcCheckinFlags, + EsalGetPlatformBaseFreq +} EFI_EXTENDED_SAL_BASE_SERVICES_FUNC_ID; + +typedef enum { + McaGetStateInfo, + McaRegisterCpu +} EFI_EXTENDED_SAL_MCA_SERVICES_FUNC_ID; + +typedef enum { + SalPciConfigRead, + SalPciConfigWrite +} EFI_EXTENDED_SAL_PCI_SERVICES_FUNC_ID; + +typedef enum { + SalCacheInit, + SalCacheFlush +} EFI_EXTENDED_SAL_CACHE_SERVICES_FUNC_ID; + +typedef enum { + SalGetStateInfo, + SalGetStateInfoSize, + SalClearStateInfo, + EsalGetStateBuffer, + EsalSaveStateBuffer +} EFI_EXTENDED_SAL_MCA_LOG_SERVICES_FUNC_ID; + +typedef enum { + SalSetEventLogData, + SalGetEventLogData, + SalEraseEventLogData, + SalActivateEventLogData +} EFI_EXTENDED_SAL_ELOG_SERVICES_FUNC_ID; + +typedef enum { + EsalGetComControllerInfo, + EsalSendComData, + EsalReceiveComData +} EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_FUNC_ID; + +typedef enum { + SalUpdatePal +} EFI_EXTENDED_SAL_UPDATE_PAL_SERVICES_FUNC_ID; + +typedef enum { + EsalReadSensorInfo, + EsalReadSensorStatus, + EsalRearmSensor, + EsalReadSensorData +} EFI_EXTENDED_SAL_SENSOR_SERVICES_FUNC_ID; + +typedef struct { + UINT64 ProtoData; +} ESAL_GUID_DUMMY_PROTOCOL; + +extern EFI_GUID gEfiExtendedSalBaseIoServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalStallServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalLockServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalVirtualServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalRtcServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalVariableServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalMtcServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalResetServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalStatusCodeServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalFvBlockServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalMpServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalPalServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalBaseServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalMcaServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalPciServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalCacheServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalMcaLogServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalElogServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalSensorServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalSmComLayerServicesProtocolGuid; +extern EFI_GUID gEfiExtendedSalSstGuid; + + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c b/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c new file mode 100644 index 0000000000..da6120c98e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FaultTolerantWriteLite.c + +Abstract: + + This is a simple fault tolerant write driver, based on PlatformFd library. + And it only supports write BufferSize <= SpareAreaLength. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(FaultTolerantWriteLite) + +EFI_GUID gEfiFaultTolerantWriteLiteProtocolGuid = EFI_FTW_LITE_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiFaultTolerantWriteLiteProtocolGuid, "FaultTolerantWriteLite Protocol", + "Fault Tolerant Write Lite protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h b/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h new file mode 100644 index 0000000000..bbddd38cdd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FaultTolerantWriteLite.h + +Abstract: + + This is a simple fault tolerant write driver, based on PlatformFd library. + And it only supports write BufferSize <= SpareAreaLength. + +--*/ + +#ifndef _FW_FAULT_TOLERANT_WRITE_LITE_PROTOCOL_H_ +#define _FW_FAULT_TOLERANT_WRITE_LITE_PROTOCOL_H_ + +#define EFI_FTW_LITE_PROTOCOL_GUID \ +{ 0x3f557189, 0x8dae, 0x45ae, 0xa0, 0xb3, 0x2b, 0x99, 0xca, 0x7a, 0xa7, 0xa0 } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_FTW_LITE_PROTOCOL); + +// +// Protocol API definitions +// + +typedef +EFI_STATUS +(EFIAPI * EFI_FTW_LITE_WRITE) ( + IN EFI_FTW_LITE_PROTOCOL *This, + IN EFI_HANDLE FvbHandle, + IN EFI_LBA Lba, + IN UINTN Offset, + IN UINTN *NumBytes, + IN VOID *Buffer + ); +/*++ + +Routine Description: + + Starts a target block update. This records information about the write + in fault tolerant storage and will complete the write in a recoverable + manner, ensuring at all times that either the original contents or + the modified contents are available. + +Arguments: + + This - Calling context + FvBlockHandle - The handle of FVB protocol that provides services for + reading, writing, and erasing the target block. + Lba - The logical block address of the target block. + Offset - The offset within the target block to place the data. + Length - The number of bytes to write to the target block. + Buffer - The data to write. + +Returns: + + EFI_SUCCESS - The function completed successfully + EFI_ABORTED - The function could not complete successfully. + EFI_BAD_BUFFER_SIZE - The write would span a block boundary, + which is not a valid action. + EFI_ACCESS_DENIED - No writes have been allocated. + EFI_NOT_READY - The last write has not been completed. + Restart () must be called to complete it. + +--*/ + +// +// Protocol declaration +// +typedef struct _EFI_FTW_LITE_PROTOCOL { + EFI_FTW_LITE_WRITE Write; +} EFI_FTW_LITE_PROTOCOL; + +extern EFI_GUID gEfiFaultTolerantWriteLiteProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c b/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c new file mode 100644 index 0000000000..0d1e30453a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c @@ -0,0 +1,32 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolumeDispatch.c + +Abstract: + + Firmware Volume Dispatch protocol as defined in the Tiano Firmware Volume + specification. + + Presence of this protocol tells the dispatch to dispatch from this Firmware + Volume + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch) + +EFI_GUID gEfiFirmwareVolumeDispatchProtocolGuid = EFI_FIRMWARE_VOLUME_DISPATCH_PROTOCOL_GUID; + +EFI_GUID_STRING (&gEfiFirmwareVolumeDispatchProtocolGuid, "FirmwareVolumeDispatch Protocol", + "Firmware Volume Dispatch protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h b/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h new file mode 100644 index 0000000000..e23a94116a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FirmwareVolumeDispatch.h + +Abstract: + + Firmware Volume Dispatch protocol as defined in the Tiano Firmware Volume + specification. + + Presence of this protocol tells the dispatch to dispatch from this Firmware + Volume + +--*/ + +#ifndef __FIRMWARE_VOLUME_DISPATCH_H__ +#define __FIRMWARE_VOLUME_DISPATCH_H__ + +#define EFI_FIRMWARE_VOLUME_DISPATCH_PROTOCOL_GUID \ + { 0x7aa35a69, 0x506c, 0x444f, 0xa7, 0xaf, 0x69, 0x4b, 0xf5, 0x6f, 0x71, 0xc8 } + + +extern EFI_GUID gEfiFirmwareVolumeDispatchProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.c b/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.c new file mode 100644 index 0000000000..e9243af8ae --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FvbExtension.c + +Abstract: + + IPMI Extension Protocol to extend the FVB functionality to multiple erase blocks + at different block offsets. + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(FvbExtension) + +EFI_GUID gEfiFvbExtensionProtocolGuid = EFI_FVB_EXTENSION_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiFvbExtensionProtocolGuid, "FVB EXTENSION", "FVB EXTENSION"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.h b/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.h new file mode 100644 index 0000000000..4ebc857b70 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/FvbExtension/FvbExtension.h @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FvbExtension.h + +Abstract: + + FVB Extension protocol that extends the FVB Class in a component fashion. + +--*/ + +#ifndef _FVB_EXTENSION_H_ +#define _FVB_EXTENSION_H_ + +#define EFI_FVB_EXTENSION_PROTOCOL_GUID \ + {0x53a4c71b, 0xb581, 0x4170, 0x91, 0xb3, 0x8d, 0xb8, 0x7a, 0x4b, 0x5c, 0x46 } + +EFI_FORWARD_DECLARATION (EFI_FVB_EXTENSION_PROTOCOL); + +// +// FVB Extension Function Prototypes +// +typedef +EFI_STATUS +(EFIAPI * EFI_FV_ERASE_CUSTOM_BLOCK) ( + IN EFI_FVB_EXTENSION_PROTOCOL *This, + IN EFI_LBA StartLba, + IN UINTN OffsetStartLba, + IN EFI_LBA LastLba, + IN UINTN OffsetLastLba +); + +// +// IPMI TRANSPORT PROTOCOL +// +typedef struct _EFI_FVB_EXTENSION_PROTOCOL { + EFI_FV_ERASE_CUSTOM_BLOCK EraseFvbCustomBlock; + } EFI_FVB_EXTENSION_PROTOCOL; + +extern EFI_GUID gEfiFvbExtensionProtocolGuid; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c b/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c new file mode 100644 index 0000000000..f9ad8f51b9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenericMemoryTest.c + +Abstract: + + The generic memory test protocol is used to test EFI memory. + + For more information please look at EfiMemoryTest.doc + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (GenericMemoryTest) + +EFI_GUID gEfiGenericMemTestProtocolGuid = EFI_GENERIC_MEMORY_TEST_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiGenericMemTestProtocolGuid, "GenericMemoryTest Protocol", "Tiano Generic Memory Test Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h b/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h new file mode 100644 index 0000000000..c43615ab5e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h @@ -0,0 +1,154 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenericMemoryTest.h + +Abstract: + + The EFI generic memory test protocol + For more information please look at EfiMemoryTest.doc + +--*/ + +#ifndef __GENERIC_MEMORY_TEST_H__ +#define __GENERIC_MEMORY_TEST_H__ + +#define EFI_GENERIC_MEMORY_TEST_PROTOCOL_GUID \ + { 0x309de7f1, 0x7f5e, 0x4ace, 0xb4, 0x9c, 0x53, 0x1b, 0xe5, 0xaa, 0x95, 0xef} + +EFI_FORWARD_DECLARATION (EFI_GENERIC_MEMORY_TEST_PROTOCOL); + +typedef enum { + IGNORE, + QUICK, + SPARSE, + EXTENSIVE, + MAXLEVEL +} EXTENDMEM_COVERAGE_LEVEL; + +typedef +EFI_STATUS +(EFIAPI *EFI_MEMORY_TEST_INIT) ( + IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, + IN EXTENDMEM_COVERAGE_LEVEL Level, + OUT BOOLEAN *RequireSoftECCInit + ) +/*++ + + Routine Description: + Initialize the generic memory test. + + Arguments: + This - Protocol instance pointer. + Level - The coverage level of the memory test. + RequireSoftECCInit - Indicate if the memory need software ECC init. + + Returns: + EFI_SUCCESS - The generic memory test initialized correctly. + EFI_NO_MEDIA - There is not any non-tested memory found, in this + function if not any non-tesed memory found means + that the memory test driver have not detect any + non-tested extended memory of current system. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_PERFORM_MEMORY_TEST) ( + IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, + OUT UINT64 *TestedMemorySize, + OUT UINT64 *TotalMemorySize, + OUT BOOLEAN *ErrorOut, + IN BOOLEAN IfTestAbort + ) +/*++ + + Routine Description: + Perform the memory test. + + Arguments: + This - Protocol instance pointer. + TestedMemorySize - Return the tested extended memory size. + TotalMemorySize - Return the whole system physical memory size, this + value may be changed if in some case some error + DIMMs be disabled. + ErrorOut - Any time the memory error occurs, this will be TRUE. + IfTestAbort - Indicate if the user press "ESC" to skip the memory + test. + + Returns: + EFI_SUCCESS - One block of memory test ok, the block size is hide + internally. + EFI_NOT_FOUND - Indicate all the non-tested memory blocks have + already go through. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_MEMORY_TEST_FINISHED) ( + IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This + ) +/*++ + + Routine Description: + The memory test finished. + + Arguments: + This - Protocol instance pointer. + + Returns: + EFI_SUCCESS - Successful free all the generic memory test driver + allocated resource and notify to platform memory + test driver that memory test finished. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_MEMORY_TEST_COMPATIBLE_RANGE) ( + IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINT64 Length + ) +/*++ + + Routine Description: + Provide capability to test compatible range which used by some sepcial + driver required using memory range before BDS perform memory test. + + Arguments: + This - Protocol instance pointer. + StartAddress - The start address of the memory range. + Length - The memory range's length. + + Return: + EFI_SUCCESS - The compatible memory range pass the memory test. + EFI_DEVICE_ERROR - The compatible memory range test find memory error + and also return return the error address. + +--*/ +; + +typedef struct _EFI_GENERIC_MEMORY_TEST_PROTOCOL { + EFI_MEMORY_TEST_INIT MemoryTestInit; + EFI_PERFORM_MEMORY_TEST PerformMemoryTest; + EFI_MEMORY_TEST_FINISHED Finished; + EFI_MEMORY_TEST_COMPATIBLE_RANGE CompatibleRangeTest; +} EFI_GENERIC_MEMORY_TEST_PROTOCOL; + +extern EFI_GUID gEfiGenericMemTestProtocolGuid; +#endif \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c b/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c new file mode 100644 index 0000000000..a3743fe305 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidedSectionExtraction.c + +Abstract: + + GUIDed section extraction protocol as defined in the Tiano File Image + Format specification. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction) + +// +// may add more GUIDed section extraction protocol GUID here. +// +EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID; + +EFI_GUID_STRING + ( + &gEfiSectionExtractionProtocolGuid, "CRC32 GUIDed Section Extraction Protocol", + "Tiano CRC32 GUIDed Section Extraction Protocol" + ); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h b/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h new file mode 100644 index 0000000000..9deb5c89be --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h @@ -0,0 +1,73 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidedSectionExtraction.h + +Abstract: + + GUIDed section extraction protocol as defined in the Tiano File + Image Format specification. + + This interface provides a means of decoding a GUID defined encapsulation + section. There may be multiple different GUIDs associated with the GUIDed + section extraction protocol. That is, all instances of the GUIDed section + extraction protocol must have the same interface structure. + +--*/ + +#ifndef _GUIDED_SECTION_EXTRACTION_PROTOCOL_H +#define _GUIDED_SECTION_EXTRACTION_PROTOCOL_H + +#include "EfiFirmwareFileSystem.h" + +// +// Protocol GUID definition. Each GUIDed section extraction protocol has the +// same interface but with different GUID. All the GUIDs is defined here. +// May add multiple GUIDs here. +// +#define EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID \ + { \ + 0xFC1BCDB0, 0x7D31, 0x49aa, 0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 \ + } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL); + +// +// Protocol member functions +// +typedef +EFI_STATUS +(EFIAPI *EFI_EXTRACT_GUIDED_SECTION) ( + IN EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL * This, + IN VOID *InputSection, + OUT VOID **OutputBuffer, + OUT UINTN *OutputSize, + OUT UINT32 *AuthenticationStatus + ); + +// +// Protocol definition +// +typedef struct _EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL { + EFI_EXTRACT_GUIDED_SECTION ExtractSection; +} EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL; + +// +// may add other GUID here +// +extern EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.c b/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.c new file mode 100644 index 0000000000..aafd75cb4d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IsaAcpi.c + +Abstract: + + EFI ISA ACPI Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (IsaAcpi) + +EFI_GUID gEfiIsaAcpiProtocolGuid = EFI_ISA_ACPI_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiIsaAcpiProtocolGuid, "ISA Acpi Protocol", "ISA Acpi Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.h b/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.h new file mode 100644 index 0000000000..e9c879bf73 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/IsaAcpi/IsaAcpi.h @@ -0,0 +1,177 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IsaAcpi.h + +Abstract: + + EFI ISA Acpi Protocol + +Revision History + +--*/ + +#ifndef _ISA_ACPI_H_ +#define _ISA_ACPI_H_ + +#define EFI_ISA_ACPI_PROTOCOL_GUID \ + {0x64a892dc, 0x5561, 0x4536, 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55} + +EFI_FORWARD_DECLARATION (EFI_ISA_ACPI); + +// +// Resource Attribute definition +// +#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE 0x01 +#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_EDGE_SENSITIVE 0x02 +#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_LEVEL_SENSITIVE 0x04 +#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_LEVEL_SENSITIVE 0x08 + +#define EFI_ISA_ACPI_DMA_SPEED_TYPE_MASK 0x03 + +#define EFI_ISA_ACPI_DMA_SPEED_TYPE_COMPATIBILITY 0x00 +#define EFI_ISA_ACPI_DMA_SPEED_TYPE_A 0x01 +#define EFI_ISA_ACPI_DMA_SPEED_TYPE_B 0x02 +#define EFI_ISA_ACPI_DMA_SPEED_TYPE_F 0x03 +#define EFI_ISA_ACPI_DMA_COUNT_BY_BYTE 0x04 +#define EFI_ISA_ACPI_DMA_COUNT_BY_WORD 0x08 +#define EFI_ISA_ACPI_DMA_BUS_MASTER 0x10 +#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT 0x20 +#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT 0x40 +#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_16_BIT 0x80 + +#define EFI_ISA_ACPI_MEMORY_WIDTH_MASK 0x03 + +#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT 0x00 +#define EFI_ISA_ACPI_MEMORY_WIDTH_16_BIT 0x01 +#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT_AND_16_BIT 0x02 +#define EFI_ISA_ACPI_MEMORY_WRITEABLE 0x04 +#define EFI_ISA_ACPI_MEMORY_CACHEABLE 0x08 +#define EFI_ISA_ACPI_MEMORY_SHADOWABLE 0x10 +#define EFI_ISA_ACPI_MEMORY_EXPANSION_ROM 0x20 + +#define EFI_ISA_ACPI_IO_DECODE_10_BITS 0x01 +#define EFI_ISA_ACPI_IO_DECODE_16_BITS 0x02 + +// +// Resource List definition: +// at first, the resource was defined as below +// but in the future, it will be defined again that follow ACPI spec: ACPI resource type +// so that, in this driver, we can interpret the ACPI table and get the ISA device information. +// + +typedef enum { + EfiIsaAcpiResourceEndOfList, + EfiIsaAcpiResourceIo, + EfiIsaAcpiResourceMemory, + EfiIsaAcpiResourceDma, + EfiIsaAcpiResourceInterrupt +} EFI_ISA_ACPI_RESOURCE_TYPE; + +typedef struct { + EFI_ISA_ACPI_RESOURCE_TYPE Type; + UINT32 Attribute; + UINT32 StartRange; + UINT32 EndRange; +} EFI_ISA_ACPI_RESOURCE; + +typedef struct { + UINT32 HID; + UINT32 UID; +} EFI_ISA_ACPI_DEVICE_ID; + +typedef struct { + EFI_ISA_ACPI_DEVICE_ID Device; + EFI_ISA_ACPI_RESOURCE *ResourceItem; +} EFI_ISA_ACPI_RESOURCE_LIST; + +// +// Prototypes for the ISA ACPI Protocol +// +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_DEVICE_ENUMERATE) ( + IN EFI_ISA_ACPI *This, + OUT EFI_ISA_ACPI_DEVICE_ID **Device + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_SET_DEVICE_POWER) ( + IN EFI_ISA_ACPI *This, + IN EFI_ISA_ACPI_DEVICE_ID *Device, + IN BOOLEAN OnOff + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_GET_CUR_RESOURCE) ( + IN EFI_ISA_ACPI *This, + IN EFI_ISA_ACPI_DEVICE_ID *Device, + OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_GET_POS_RESOURCE) ( + IN EFI_ISA_ACPI *This, + IN EFI_ISA_ACPI_DEVICE_ID *Device, + OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_SET_RESOURCE) ( + IN EFI_ISA_ACPI *This, + IN EFI_ISA_ACPI_DEVICE_ID *Device, + IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_ENABLE_DEVICE) ( + IN EFI_ISA_ACPI *This, + IN EFI_ISA_ACPI_DEVICE_ID *Device, + IN BOOLEAN Enable + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_INIT_DEVICE) ( + IN EFI_ISA_ACPI *This, + IN EFI_ISA_ACPI_DEVICE_ID *Device + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_ACPI_INTERFACE_INIT) ( + IN EFI_ISA_ACPI *This + ); + +// +// Interface structure for the ISA ACPI Protocol +// +typedef struct _EFI_ISA_ACPI { + EFI_ISA_ACPI_DEVICE_ENUMERATE DeviceEnumerate; + EFI_ISA_ACPI_SET_DEVICE_POWER SetPower; + EFI_ISA_ACPI_GET_CUR_RESOURCE GetCurResource; + EFI_ISA_ACPI_GET_POS_RESOURCE GetPosResource; + EFI_ISA_ACPI_SET_RESOURCE SetResource; + EFI_ISA_ACPI_ENABLE_DEVICE EnableDevice; + EFI_ISA_ACPI_INIT_DEVICE InitDevice; + EFI_ISA_ACPI_INTERFACE_INIT InterfaceInit; +} EFI_ISA_ACPI_PROTOCOL; + +extern EFI_GUID gEfiIsaAcpiProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.c b/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.c new file mode 100644 index 0000000000..3b868be1bd --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.c @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IsaIo.c + +Abstract: + + EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL + based on macro SIZE_REDUCTION_ISA_COMBINED. + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (IsaIo) + +#ifndef SIZE_REDUCTION_ISA_COMBINED +// +// EFI_ISA_IO_PROTOCOL +// +EFI_GUID gEfiIsaIoProtocolGuid = EFI_ISA_IO_PROTOCOL_GUID; +EFI_GUID_STRING(&gEfiIsaIoProtocolGuid, "ISA IO Protocol", "ISA IO Protocol"); + +#else +// +// EFI_LIGHT_ISA_IO_PROTOCOL +// +EFI_GUID gEfiLightIsaIoProtocolGuid = EFI_LIGHT_ISA_IO_PROTOCOL_GUID; +EFI_GUID_STRING(&gEfiLightIsaIoProtocolGuid, "Light ISA IO Protocol", "Light ISA IO Protocol"); +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.h b/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.h new file mode 100644 index 0000000000..efedbee1d2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/IsaIo/IsaIo.h @@ -0,0 +1,362 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + IsaIo.h + +Abstract: + + EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL + based on macro SIZE_REDUCTION_ISA_COMBINED. + +Revision History + +--*/ + +#ifndef _EFI_ISA_IO_H +#define _EFI_ISA_IO_H + +// +// Common definitions for Light ISA I/O Protocol and ISA I/O Protocol +// + +#include EFI_PROTOCOL_DEFINITION(IsaAcpi) + +typedef enum { + EfiIsaIoWidthUint8, + EfiIsaIoWidthUint16, + EfiIsaIoWidthUint32, + EfiIsaIoWidthReserved, + EfiIsaIoWidthFifoUint8, + EfiIsaIoWidthFifoUint16, + EfiIsaIoWidthFifoUint32, + EfiIsaIoWidthFifoReserved, + EfiIsaIoWidthFillUint8, + EfiIsaIoWidthFillUint16, + EfiIsaIoWidthFillUint32, + EfiIsaIoWidthFillReserved, + EfiIsaIoWidthMaximum +} EFI_ISA_IO_PROTOCOL_WIDTH; + +// +// Attributes for common buffer allocations +// +#define EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x080 // Map a memory range so write are combined +#define EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED 0x800 // Map a memory range so all r/w accesses are cached +#define EFI_ISA_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 // Disable a memory range + +// +// Channel attribute for DMA operations +// +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE 0x001 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A 0x002 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B 0x004 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C 0x008 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8 0x010 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16 0x020 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE 0x040 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE 0x080 +#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE 0x100 + +typedef enum { + EfiIsaIoOperationBusMasterRead, + EfiIsaIoOperationBusMasterWrite, + EfiIsaIoOperationBusMasterCommonBuffer, + EfiIsaIoOperationSlaveRead, + EfiIsaIoOperationSlaveWrite, + EfiIsaIoOperationMaximum +} EFI_ISA_IO_PROTOCOL_OPERATION; + +#ifndef SIZE_REDUCTION_ISA_COMBINED + +// +// Specific for ISA I/O Protocol +// + +#define EFI_INTERFACE_DEFINITION_FOR_ISA_IO EFI_ISA_IO_PROTOCOL +#define EFI_ISA_IO_PROTOCOL_VERSION &gEfiIsaIoProtocolGuid +#define EFI_ISA_IO_OPERATION_TOKEN EfiIsaIoOperationBusMasterWrite + + +// +// Global ID for the ISA I/O Protocol +// + +#define EFI_ISA_IO_PROTOCOL_GUID \ + { 0x7ee2bd44, 0x3da0, 0x11d4, 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +EFI_FORWARD_DECLARATION (EFI_ISA_IO_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_IO_PROTOCOL_IO_MEM) ( + IN EFI_ISA_IO_PROTOCOL *This, + IN EFI_ISA_IO_PROTOCOL_WIDTH Width, + IN UINT32 Offset, + IN UINTN Count, + IN OUT VOID *Buffer + ); + +typedef struct { + EFI_ISA_IO_PROTOCOL_IO_MEM Read; + EFI_ISA_IO_PROTOCOL_IO_MEM Write; +} EFI_ISA_IO_PROTOCOL_ACCESS; + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_IO_PROTOCOL_COPY_MEM) ( + IN EFI_ISA_IO_PROTOCOL *This, + IN EFI_ISA_IO_PROTOCOL_WIDTH Width, + IN UINT32 DestOffset, + IN UINT32 SrcOffset, + IN UINTN Count + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_IO_PROTOCOL_MAP) ( + IN EFI_ISA_IO_PROTOCOL *This, + IN EFI_ISA_IO_PROTOCOL_OPERATION Operation, + IN UINT8 ChannelNumber OPTIONAL, + IN UINT32 ChannelAttributes, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_IO_PROTOCOL_UNMAP) ( + IN EFI_ISA_IO_PROTOCOL *This, + IN VOID *Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER) ( + IN EFI_ISA_IO_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + OUT VOID **HostAddress, + IN UINT64 Attributes + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_IO_PROTOCOL_FREE_BUFFER) ( + IN EFI_ISA_IO_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_ISA_IO_PROTOCOL_FLUSH) ( + IN EFI_ISA_IO_PROTOCOL *This + ); + +// +// Interface structure for the ISA I/O Protocol +// +typedef struct _EFI_ISA_IO_PROTOCOL { + EFI_ISA_IO_PROTOCOL_ACCESS Mem; + EFI_ISA_IO_PROTOCOL_ACCESS Io; + EFI_ISA_IO_PROTOCOL_COPY_MEM CopyMem; + EFI_ISA_IO_PROTOCOL_MAP Map; + EFI_ISA_IO_PROTOCOL_UNMAP Unmap; + EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; + EFI_ISA_IO_PROTOCOL_FREE_BUFFER FreeBuffer; + EFI_ISA_IO_PROTOCOL_FLUSH Flush; + EFI_ISA_ACPI_RESOURCE_LIST *ResourceList; + UINT32 RomSize; + VOID *RomImage; +} EFI_ISA_IO_PROTOCOL; + +extern EFI_GUID gEfiIsaIoProtocolGuid; + +#else + +// +// Specific for Light ISA I/O Protocol +// + +#define EFI_INTERFACE_DEFINITION_FOR_ISA_IO EFI_LIGHT_ISA_IO_PROTOCOL +#define EFI_ISA_IO_PROTOCOL_VERSION &gEfiLightIsaIoProtocolGuid +#define EFI_ISA_IO_OPERATION_TOKEN EfiIsaIoOperationSlaveWrite + +#define ADD_SERIAL_NAME(x, y) + +// +// Global ID for the Light ISA I/O Protocol +// + +#define EFI_LIGHT_ISA_IO_PROTOCOL_GUID \ + { 0x7cc7ed80, 0x9a68, 0x4781, 0x80, 0xe4, 0xda, 0x16, 0x99, 0x10, 0x5a, 0xfe } + +EFI_FORWARD_DECLARATION (EFI_LIGHT_ISA_IO_PROTOCOL); + + +typedef +EFI_STATUS +(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_IO_MEM) ( + IN EFI_LIGHT_ISA_IO_PROTOCOL *This, + IN EFI_ISA_IO_PROTOCOL_WIDTH Width, + IN UINT32 Offset, + IN UINTN Count, + IN OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Performs an ISA I/O Read/Write Cycle + EFI_LIGHT_ISA_IO_PROTOCOL doesn't verfiy access for I/O operation. + +Arguments: + + This - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance. + Width - Signifies the width of the I/O operation. + Offset - The offset in ISA I/O space to start the I/O operation. + Count - The number of I/O operations to perform. + Buffer - The source/destination buffer + +Returns: + + EFI_SUCCESS - The data was read from or written to the device sucessfully. + EFI_UNSUPPORTED - The Offset is not valid for this device. + EFI_INVALID_PARAMETER - Width or Count, or both, were invalid. + EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources. + +--*/ +; + +typedef struct { + EFI_LIGHT_ISA_IO_PROTOCOL_IO_MEM Read; + EFI_LIGHT_ISA_IO_PROTOCOL_IO_MEM Write; +} EFI_LIGHT_ISA_IO_PROTOCOL_ACCESS; + + +typedef +EFI_STATUS +(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_MAP) ( + IN EFI_LIGHT_ISA_IO_PROTOCOL *This, + IN EFI_ISA_IO_PROTOCOL_OPERATION Operation, + IN UINT8 ChannelNumber OPTIONAL, + IN UINT32 ChannelAttributes, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +/*++ + +Routine Description: + + Maps a memory region for DMA, EFI_LIGHT_ISA_IO_PROTOCOL only supports + Slave read/write operation to save code size. + +Arguments: + + This - A pointer to the EFI_LIGHT_ISA_IO_PROTOCOL instance. + Operation - Indicates the type of DMA (slave or bus master), and if + the DMA operation is going to read or write to system memory. + ChannelNumber - The slave channel number to use for this DMA operation. + If Operation and ChannelAttributes shows that this device + performs bus mastering DMA, then this field is ignored. + The legal range for this field is 0..7. + ChannelAttributes - The attributes of the DMA channel to use for this DMA operation + HostAddress - The system memory address to map to the device. + NumberOfBytes - On input the number of bytes to map. On output the number + of bytes that were mapped. + DeviceAddress - The resulting map address for the bus master device to use + to access the hosts HostAddress. + Mapping - A resulting value to pass to EFI_ISA_IO.Unmap(). + +Returns: + + EFI_SUCCESS - The range was mapped for the returned NumberOfBytes. + EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined. + EFI_UNSUPPORTED - The HostAddress can not be mapped as a common buffer. + EFI_DEVICE_ERROR - The system hardware could not map the requested address. + EFI_OUT_OF_RESOURCES - The memory pages could not be allocated. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_UNMAP) ( + IN EFI_LIGHT_ISA_IO_PROTOCOL *This, + IN VOID *Mapping + ) +/*++ + +Routine Description: + + Unmaps a memory region for DMA + +Arguments: + + This - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance. + Mapping - The mapping value returned from EFI_ISA_IO.Map(). + +Returns: + + EFI_SUCCESS - The range was unmapped. + EFI_DEVICE_ERROR - The data was not committed to the target system memory. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_LIGHT_ISA_IO_PROTOCOL_FLUSH) ( + IN EFI_LIGHT_ISA_IO_PROTOCOL *This + ) +/*++ + +Routine Description: + + Flushes a DMA buffer + +Arguments: + + This - A pointer to the EFI_ISA_IO_PROTOCOL or EFI_LIGHT_ISA_IO_PROTOCOL instance. + +Returns: + + EFI_SUCCESS - The buffers were flushed. + EFI_DEVICE_ERROR - The buffers were not flushed due to a hardware error. + +--*/ +; + +// +// Interface structure for the Light ISA I/O Protocol +// +typedef struct _EFI_LIGHT_ISA_IO_PROTOCOL { + EFI_LIGHT_ISA_IO_PROTOCOL_ACCESS Io; + EFI_LIGHT_ISA_IO_PROTOCOL_MAP Map; + EFI_LIGHT_ISA_IO_PROTOCOL_UNMAP Unmap; + EFI_LIGHT_ISA_IO_PROTOCOL_FLUSH Flush; + EFI_ISA_ACPI_RESOURCE_LIST *ResourceList; + UINT32 RomSize; + VOID *RomImage; +} EFI_LIGHT_ISA_IO_PROTOCOL; + +extern EFI_GUID gEfiLightIsaIoProtocolGuid; + +#endif + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.c b/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.c new file mode 100644 index 0000000000..a9d29dd48a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LegacyBiosThunk.c + +Abstract: + + Legacy BIOS Thunk Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (LegacyBiosThunk) + +EFI_GUID gEfiLegacyBiosThunkProtocolGuid = EFI_LEGACY_BIOS_THUNK_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLegacyBiosThunkProtocolGuid, "Legacy BIOS Thunk Protocol", "Legacy BIOS Thunk Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.h b/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.h new file mode 100644 index 0000000000..80ee5ab66d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/LegacyBiosThunk/LegacyBiosThunk.h @@ -0,0 +1,120 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LegacyBiosThunk.h + +Abstract: + + The EFI Legacy BIOS Thunk Protocol is used to abstract Thunk16 call. + + Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow + well known naming conventions. + + Thunk - A thunk is a transition from one processor mode to another. A Thunk + is a transition from native EFI mode to 16-bit mode. A reverse thunk + would be a transition from 16-bit mode to native EFI mode. + + + Note: Note: Note: Note: Note: Note: Note: + + You most likely should not use this protocol! Find the EFI way to solve the + problem to make your code portable + + Note: Note: Note: Note: Note: Note: Note: + +Revision History + +--*/ + +#ifndef _EFI_LEGACY_BIOS_THUNK_H_ +#define _EFI_LEGACY_BIOS_THUNK_H_ + +#include EFI_PROTOCOL_DEFINITION (LegacyBios) + +#define EFI_LEGACY_BIOS_THUNK_PROTOCOL_GUID \ + { \ + 0x4c51a7ba, 0x7195, 0x442d, 0x87, 0x92, 0xbe, 0xea, 0x6e, 0x2f, 0xf6, 0xec \ + } + +EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_THUNK_PROTOCOL); + +typedef +BOOLEAN +(EFIAPI *EFI_LEGACY_BIOS_THUNK_INT86) ( + IN EFI_LEGACY_BIOS_THUNK_PROTOCOL * This, + IN UINT8 BiosInt, + IN OUT EFI_IA32_REGISTER_SET * Regs + ) +/*++ + + Routine Description: + Thunk to 16-bit real mode and execute a software interrupt with a vector + of BiosInt. Regs will contain the 16-bit register context on entry and + exit. + + Arguments: + This - Protocol instance pointer. + BiosInt - Processor interrupt vector to invoke + Reg - Register contexted passed into (and returned) from thunk to + 16-bit mode + + Returns: + FALSE - Thunk completed, and there were no BIOS errors in the target code. + See Regs for status. + TRUE - There was a BIOS erro in the target code. + +--*/ +; + +typedef +BOOLEAN +(EFIAPI *EFI_LEGACY_BIOS_THUNK_FARCALL86) ( + IN EFI_LEGACY_BIOS_THUNK_PROTOCOL * This, + IN UINT16 Segment, + IN UINT16 Offset, + IN EFI_IA32_REGISTER_SET * Regs, + IN VOID *Stack, + IN UINTN StackSize + ) +/*++ + + Routine Description: + Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the + 16-bit register context on entry and exit. Arguments can be passed on + the Stack argument + + Arguments: + This - Protocol instance pointer. + Segment - Segemnt of 16-bit mode call + Offset - Offset of 16-bit mdoe call + Reg - Register contexted passed into (and returned) from thunk to + 16-bit mode + Stack - Caller allocated stack used to pass arguments + StackSize - Size of Stack in bytes + + Returns: + FALSE - Thunk completed, and there were no BIOS errors in the target code. + See Regs for status. + TRUE - There was a BIOS erro in the target code. + +--*/ +; + +typedef struct _EFI_LEGACY_BIOS_THUNK_PROTOCOL { + EFI_LEGACY_BIOS_THUNK_INT86 Int86; + EFI_LEGACY_BIOS_THUNK_FARCALL86 FarCall86; +} EFI_LEGACY_BIOS_THUNK_PROTOCOL; + +extern EFI_GUID gEfiLegacyBiosThunkProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c b/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c new file mode 100644 index 0000000000..c113919359 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadPe32Image.c + +Abstract: + + Load PE32 Image Protocol + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (LoadPe32Image) + +EFI_GUID gEfiLoadPeImageGuid = PE32_IMAGE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiLoadPeImageGuid, "LoadPe32Image Protocol", "Tiano Load Pe32 Image Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h b/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h new file mode 100644 index 0000000000..07f8e4cd85 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h @@ -0,0 +1,64 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + LoadPe32Image.h + +Abstract: + + Load PE32 Image Protocol + +--*/ + +#ifndef _LOAD_PE32_IMAGE_H_ +#define _LOAD_PE32_IMAGE_H_ + +#define PE32_IMAGE_PROTOCOL_GUID \ + {0x5cb5c776,0x60d5,0x45ee,0x88,0x3c,0x45,0x27,0x8,0xcd,0x74,0x3f } + +#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_NONE 0x00 +#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION 0x01 +#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION 0x02 + +EFI_FORWARD_DECLARATION (EFI_PE32_IMAGE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *LOAD_PE_IMAGE) ( + IN EFI_PE32_IMAGE_PROTOCOL *This, + IN EFI_HANDLE ParentImageHandle, + IN EFI_DEVICE_PATH_PROTOCOL *FilePath, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL, + OUT UINTN *NumberOfPages OPTIONAL, + OUT EFI_HANDLE *ImageHandle, + OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL, + IN UINT32 Attribute + ); + +typedef +EFI_STATUS +(EFIAPI *UNLOAD_PE_IMAGE) ( + IN EFI_PE32_IMAGE_PROTOCOL *This, + IN EFI_HANDLE ImageHandle + ); + +typedef struct _EFI_PE32_IMAGE_PROTOCOL { + LOAD_PE_IMAGE LoadPeImage; + UNLOAD_PE_IMAGE UnLoadPeImage; +} EFI_PE32_IMAGE_PROTOCOL; + +extern EFI_GUID gEfiLoadPeImageGuid; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.c b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.c new file mode 100644 index 0000000000..102bb14d62 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.c @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + NicIp4Config.c + +Abstract: + +--*/ + +#include "EfiSpec.h" +#include EFI_PROTOCOL_DEFINITION (NicIp4Config) + +EFI_GUID gEfiNicIp4ConfigProtocolGuid = EFI_NIC_IP4_CONFIG_PROTOCOL_GUID; + +EFI_GUID_STRING ( + &gEfiNicIp4ConfigProtocolGuid, + "NicIP4Config Protocol", + "NicIP4Config Protocol" + ); + +EFI_GUID gEfiNicIp4ConfigVariableGuid = EFI_NIC_IP4_CONFIG_VARIABLE_GUID; + +EFI_GUID_STRING( + &gEfiNicIp4ConfigVariableGuid, + "Ip4 Static Config", + "Ip4 Configuration Data" + ); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h new file mode 100644 index 0000000000..76e4255b9d --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h @@ -0,0 +1,118 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + NicIp4Config.h + +Abstract: + +--*/ + +#ifndef _NIC_IP4_CONFIG_H_ +#define _NIC_IP4_CONFIG_H_ + +#include EFI_PROTOCOL_DEFINITION (Ip4Config) + +#define EFI_NIC_IP4_CONFIG_PROTOCOL_GUID \ + {0xdca3d4d, 0x12da, 0x4728, 0xbf, 0x7e, 0x86, 0xce, 0xb9, 0x28, 0xd0, 0x67} + +#define EFI_NIC_IP4_CONFIG_VARIABLE_GUID \ + {0xd8944553, 0xc4dd, 0x41f4, 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b} + +#define EFI_NIC_IP4_CONFIG_VARIABLE L"EfiNicIp4ConfigVariable" + + +typedef struct _EFI_NIC_IP4_CONFIG_PROTOCOL EFI_NIC_IP4_CONFIG_PROTOCOL; + +typedef enum { + // + // Config source: dhcp or static + // + IP4_CONFIG_SOURCE_DHCP = 0, + IP4_CONFIG_SOURCE_STATIC, + IP4_CONFIG_SOURCE_MAX, + + IP4_NIC_NAME_LENGTH = 64, + MAX_IP4_CONFIG_IN_VARIABLE = 16, +}; + +// +// The following structures are used by drivers/applications other +// than EFI_IP4_PROTOCOL, such as ifconfig shell application, to +// communicate the IP configuration information to EFI_IP4_CONFIG_PROTOCOL. +// EFI_IP4_CONFIG_PROTOCOL in turn is used by EFI_IP4_PROTOCOL to get +// the default IP4 configuration. ifconfig can't use the EFI_IP4_PROTOCOL +// because it don't know how to configure the default IP address even +// it has got the address. +// +// NIC_ADDR contains the interface's type and MAC address to identify +// a specific NIC. NIC_IP4_CONFIG_INFO contains the IP4 configure +// parameters for that NIC. IP4_CONFIG_VARIABLE is the EFI variable to +// save the configuration. NIC_IP4_CONFIG_INFO and IP4_CONFIG_VARIABLE +// is of variable length. +// +// EFI_NIC_IP4_CONFIG_PROTOCOL is a priority protocol, not defined by UEFI2.0 +// +typedef struct { + UINT16 Type; + UINT8 Len; + EFI_MAC_ADDRESS MacAddr; +} NIC_ADDR; + +typedef struct { + NIC_ADDR NicAddr; // Link layer address to identify the NIC + UINT32 Source; // Static or DHCP + BOOLEAN Perment; // Survive the reboot or not + EFI_IP4_IPCONFIG_DATA Ip4Info; // IP addresses +} NIC_IP4_CONFIG_INFO; + +typedef struct { + UINT32 Len; // Total length of the variable + UINT16 CheckSum; // CheckSum, the same as IP4 head checksum + UINT32 Count; // Number of NIC_IP4_CONFIG_INFO follows + NIC_IP4_CONFIG_INFO ConfigInfo; +} IP4_CONFIG_VARIABLE; + +typedef +EFI_STATUS +(EFIAPI *EFI_NIC_IP4_CONFIG_GET_INFO) ( + IN EFI_NIC_IP4_CONFIG_PROTOCOL *This, + IN OUT UINTN *Len, + OUT NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_NIC_IP4_CONFIG_SET_INFO) ( + IN EFI_NIC_IP4_CONFIG_PROTOCOL *This, + IN NIC_IP4_CONFIG_INFO *NicConfig, OPTIONAL + IN BOOLEAN ReConfig + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_NIC_IP4_CONFIG_GET_NAME) ( + IN EFI_NIC_IP4_CONFIG_PROTOCOL *This, + IN UINT16 *Name, OPTIONAL + IN NIC_ADDR *NicAddr OPTIONAL + ); + +typedef +struct _EFI_NIC_IP4_CONFIG_PROTOCOL { + EFI_NIC_IP4_CONFIG_GET_NAME GetName; + EFI_NIC_IP4_CONFIG_GET_INFO GetInfo; + EFI_NIC_IP4_CONFIG_SET_INFO SetInfo; +}; + +extern EFI_GUID gEfiNicIp4ConfigVariableGuid; +extern EFI_GUID gEfiNicIp4ConfigProtocolGuid; +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c b/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c new file mode 100644 index 0000000000..53bb2f589b --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHotPlugRequest.c + +Abstract: + + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (PciHotPlugRequest) + +EFI_GUID gEfiPciHotPlugRequestProtocolGuid = EFI_PCI_HOTPLUG_REQUEST_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPciHotPlugRequestProtocolGuid, "Pci Hot Plug Request Protocol", "Tiano Hot Plug Request Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h b/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h new file mode 100644 index 0000000000..7a734730b4 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h @@ -0,0 +1,55 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PciHotPlugRequest.h + +Abstract: + + + +--*/ + +#ifndef _PCI_HOTPLUG_REQUEST_H_ +#define _PCI_HOTPLUG_REQUEST_H_ + +#define EFI_PCI_HOTPLUG_REQUEST_PROTOCOL_GUID \ +{0x19cb87ab,0x2cb9,0x4665,0x83,0x60,0xdd,0xcf,0x60,0x54,0xf7,0x9d} + +typedef enum { + EfiPciHotPlugRequestAdd, + EfiPciHotplugRequestRemove +} EFI_PCI_HOTPLUG_OPERATION; + +EFI_FORWARD_DECLARATION (EFI_PCI_HOTPLUG_REQUEST_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_HOTPLUG_REQUEST_NOTIFY) ( + IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL *This, + IN EFI_PCI_HOTPLUG_OPERATION Operation, + IN EFI_HANDLE Controller, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL, + IN OUT UINT8 *NumberOfChildren, + IN OUT EFI_HANDLE *ChildHandleBuffer +); + + + +typedef struct _EFI_PCI_HOTPLUG_REQUEST_PROTOCOL { + EFI_PCI_HOTPLUG_REQUEST_NOTIFY Notify; +} EFI_PCI_HOTPLUG_REQUEST_PROTOCOL; + + +extern EFI_GUID gEfiPciHotPlugRequestProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.c b/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.c new file mode 100644 index 0000000000..f9ecf1e163 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Performance.c + +Abstract: + + DXE performance checking infrastructure + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (Performance) + +EFI_GUID gEfiPerformanceProtocolGuid = EFI_PERFORMANCE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPerformanceProtocolGuid, "Performance Protocol", "Performance Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h b/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h new file mode 100644 index 0000000000..ab502ffc57 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h @@ -0,0 +1,103 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Performance.h + +Abstract: + + +--*/ + +#ifndef _EFI_PERFORMANCE_H_ +#define _EFI_PERFORMANCE_H_ + +#define EFI_PERFORMANCE_PROTOCOL_GUID \ + { 0xFFECFFFF, 0x923C, 0x14d2, 0x9E, 0x3F, 0x22, 0xA0, 0xC9, 0x69, 0x56, 0x3B } + +#define EFI_NULL_GUID \ + { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + + +EFI_FORWARD_DECLARATION (EFI_PERFORMANCE_PROTOCOL); + +#define DXE_TOK L"DXE" +#define SHELL_TOK L"SHELL" +#define PEI_TOK L"PEI" +#define BDS_TOK L"BDS" +#define DRIVERBINDING_START_TOK L"DriverBinding:Start" +#define DRIVERBINDING_SUPPORT_TOK L"DriverBinding:Support" +#define START_IMAGE_TOK L"StartImage" +#define LOAD_IMAGE_TOK L"LoadImage" + +#define DXE_PHASE 0 +#define SHELL_PHASE 1 +#define PEI_PHASE 2 + +#define EFI_PERF_TOKEN_LENGTH 32 +#define EFI_PERF_HOST_LENGTH 32 +#define EFI_PERF_PDBFILENAME_LENGTH 28 + +typedef struct { + EFI_HANDLE Handle; + UINT16 Token[EFI_PERF_TOKEN_LENGTH]; + UINT16 Host[EFI_PERF_HOST_LENGTH]; + UINT64 StartTick; + UINT64 EndTick; + EFI_GUID GuidName; + UINT8 PdbFileName[EFI_PERF_PDBFILENAME_LENGTH]; + UINT8 Phase; +} EFI_GAUGE_DATA ; + + +typedef +EFI_STATUS +(EFIAPI * EFI_PERF_START_GAUGE) ( + IN EFI_PERFORMANCE_PROTOCOL *This, + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PERF_END_GAUGE) ( + IN EFI_PERFORMANCE_PROTOCOL *This, + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN UINT64 Ticker + ); + + +typedef +EFI_GAUGE_DATA * +(EFIAPI * EFI_PERF_GET_GAUGE) ( + IN EFI_PERFORMANCE_PROTOCOL *This, + IN EFI_HANDLE Handle, + IN UINT16 *Token, + IN UINT16 *Host, + IN EFI_GAUGE_DATA *PrevGauge + ); + + +typedef struct _EFI_PERFORMANCE_PROTOCOL{ + EFI_PERF_START_GAUGE StartGauge; + EFI_PERF_END_GAUGE EndGauge; + EFI_PERF_GET_GAUGE GetGauge; +} EFI_PERFORMANCE_PROTOCOL; + +extern EFI_GUID gEfiPerformanceProtocolGuid; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c b/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c new file mode 100644 index 0000000000..6e0f3e8e95 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PlatformMemTest.c + +Abstract: + + // TBD defined in the Tiano specification?? + + The Platform memory test protocol is used to provide platform specific + information and functionality for memory test + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (PlatformMemTest) + +EFI_GUID gEfiPlatformMemTestGuid = EFI_PLATFORM_MEMTEST_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPlatformMemTestGuid, "Platform Memory Test Protocol", "Platform MemTest protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h b/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h new file mode 100644 index 0000000000..356563edaf --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h @@ -0,0 +1,258 @@ + + /*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PlatformMemtest.h + +Abstract: + This files defines the protocol produced by platform memory test driver. + +--*/ + +#ifndef __PLATFORM_MEMTEST_H__ +#define __PLATFORM_MEMTEST_H__ + + +#include EFI_PROTOCOL_CONSUMER (Hii) +#include EFI_PROTOCOL_CONSUMER (GenericMemoryTest) + + +#define EFI_PLATFORM_MEMTEST_PROTOCOL_GUID \ + { 0x859ba18, 0x7dd7, 0x4ed7, 0xa8, 0x8e, 0x10, 0x9c, 0x63, 0x91, 0x7b, 0xdd } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_PLATFORM_MEMTEST_PROTOCOL); + + +// +// Basic type definitions +// +typedef UINT16 EFI_DIMM_ID; +#define EFI_INVALID_DIMM_ID 0xFFFF + +// +// This describes the capabilities +// +typedef struct { + UINT32 HwCap; + EFI_PHYSICAL_ADDRESS InitBlockSize; + EFI_PHYSICAL_ADDRESS TestBlockSize; +} EFI_PLATFORM_MEMTEST_CAPABILITIES; + +// +// This defines the platform driver phases to use in notify phase +// +typedef enum { + EfiMemtestPhaseBegin, + EfiMemtestPhaseEnd, + EfiMemtestPhaseMaximum +} EFI_MEMTEST_PHASE ; + + +// +// Definitions of Capability bits +// +#define EFI_MEMTEST_CAP_NONE 0X00000000 +#define EFI_MEMTEST_CAP_ECC 0X00000001 +#define EFI_MEMTEST_CAP_HW_TEST 0X00000002 +#define EFI_MEMTEST_CAP_HW_INIT 0X00000004 + +// +// This describes the pattern for testing all memory cells +// +typedef struct { + UINT32 Count; // Number of patterns + UINT32 Width; // Width of patterns + VOID *Pattern; // Array of patterns +}EFI_MEMTEST_DATA_PATTERN; + +// +// This describes the data and address line patterns +// +typedef struct { + UINT32 Count; // Number of patterns + EFI_PHYSICAL_ADDRESS *Address; // Array of addresses + EFI_PHYSICAL_ADDRESS *Pattern; // Array of patterns +} EFI_MEMTEST_ADDRESS_PATTERN; + + +#define EFI_INVALID_DIMM_ID 0xFFFF + +// +// DIMM information exported by the platform driver +// + +typedef struct { + EFI_DIMM_ID DimmId; + STRING_REF DimmReference; +} EFI_MEMTEST_DIMM_INFO; + + +// +// Various types of errors +// +typedef enum { + EfiMemtestCorrectableError = 1, + EfiMemtestUncorrectableError, + EfiMemtestErrorMaximum, +} EFI_DIMM_ERROR; + +// +// Actions to be taken. +// +typedef enum { + EfiMemtestActionReport = 1, + EfiMemtestActionDisableMem, + EfiMemtestActionMaximum, +} EFI_MEMTEST_ERROR_ACTION; + + +// +// Structure indicating a policy entry. +// + +typedef struct { + EFI_DIMM_ERROR ErrorType; + UINT32 Threshold; + EFI_MEMTEST_ERROR_ACTION Action; +} EFI_MEMTEST_POLICY_ENTRY; + + + +// +// Error Information. +// +typedef struct { + EFI_DIMM_ERROR Error; + EFI_DIMM_ID DimmId; +} EFI_PLATFORM_MEMTEST_ERROR; + + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_MEMTEST_NOTIFY_PHASE) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + IN EFI_MEMTEST_PHASE Phase + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_MEMTEST_GET_PLATFORM_INFO) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + OUT EFI_PLATFORM_MEMTEST_CAPABILITIES *Capabilities, + OUT EFI_MEMTEST_ADDRESS_PATTERN *AddressPattern, + OUT EFI_MEMTEST_DATA_PATTERN *DataPattern, + OUT EFI_MEMTEST_DATA_PATTERN *MemoryPattern, + OUT UINT32 *EntryCount, + OUT EFI_MEMTEST_POLICY_ENTRY **PolicyGrid + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_GET_NEXT_DIMM_INFO) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + IN OUT EFI_MEMTEST_DIMM_INFO *DimmInfo + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_MEMTEST_INITIALIZE_MEMORY) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS Start, + IN EFI_PHYSICAL_ADDRESS Size + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_HW_MEMORY_TEST) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + IN EXTENDMEM_COVERAGE_LEVEL Level, + IN EFI_PHYSICAL_ADDRESS Start, + IN EFI_PHYSICAL_ADDRESS Size, + OUT UINTN *ErrorCount, + OUT EFI_PLATFORM_MEMTEST_ERROR **ErrorInfo + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_FLUSH_BUFFER) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_CHECK_FOR_ERROR) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + OUT UINT32 *ErrorCount, + OUT EFI_PLATFORM_MEMTEST_ERROR **ErrorInfo + + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_LOCATE_BAD_DIMM) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS FailingAddress, + IN UINT8 Expected, + IN UINT8 Found, + OUT UINT32 *ErrorInfoCount, + OUT EFI_PLATFORM_MEMTEST_ERROR **ErrorInfoBuffer + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_CLEAR_ERROR) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_DISABLE_DIMM) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + IN UINT16 *DimmCount, + IN EFI_DIMM_ID *DimmIds, + IN BOOLEAN RebootRequired + + ); + +typedef +EFI_STATUS +(EFIAPI * EFI_PLATFORM_MEMTEST_OVERLAP) ( + IN EFI_PLATFORM_MEMTEST_PROTOCOL *This, + IN EFI_DIMM_ID DimmId, + IN EFI_PHYSICAL_ADDRESS start, + IN EFI_PHYSICAL_ADDRESS Size, + OUT BOOLEAN *Overlap + ); + +typedef struct _EFI_PLATFORM_MEMTEST_PROTOCOL { + EFI_PLATFORM_MEMTEST_NOTIFY_PHASE NotifyPhase; + EFI_PLATFORM_MEMTEST_GET_PLATFORM_INFO GetPlatformInfo; + EFI_PLATFORM_MEMTEST_GET_NEXT_DIMM_INFO GetNextDimmInfo; + EFI_PLATFORM_MEMTEST_INITIALIZE_MEMORY InitializeMem; + EFI_PLATFORM_MEMTEST_HW_MEMORY_TEST HwTest; + EFI_PLATFORM_MEMTEST_FLUSH_BUFFER FlushBuffer; + EFI_PLATFORM_MEMTEST_CHECK_FOR_ERROR CheckError; + EFI_PLATFORM_MEMTEST_LOCATE_BAD_DIMM LocateBadDimm; + EFI_PLATFORM_MEMTEST_CLEAR_ERROR ClearError; + EFI_PLATFORM_MEMTEST_DISABLE_DIMM DisableDimm; + EFI_PLATFORM_MEMTEST_OVERLAP Overlap; +} EFI_PLATFORM_MEMTEST_PROTOCOL; + + + +extern EFI_GUID gEfiPlatformMemTestGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.c b/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.c new file mode 100644 index 0000000000..b9ff6f945c --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.c + +Abstract: + + This file defines the Print protocol interface to provide a unified + print function + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (Print) + +EFI_GUID gEfiPrintProtocolGuid = EFI_PRINT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPrintProtocolGuid, "Print Protocol", "Print 1.0 protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.h b/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.h new file mode 100644 index 0000000000..eba79cd072 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Print/Print.h @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Print.h + +Abstract: + + This file defines the Print protocol + +--*/ + +#ifndef _PPRINT_H_ +#define _PPRINT_H_ + +#define EFI_PRINT_PROTOCOL_GUID \ + { 0xdf2d868e, 0x32fc, 0x4cf0, 0x8e, 0x6b, 0xff, 0xd9, 0x5d, 0x13, 0x43, 0xd0 } + +// +// Forward reference for pure ANSI compatability +// +EFI_FORWARD_DECLARATION (EFI_PRINT_PROTOCOL); + +typedef struct _EFI_PRINT_PROTOCOL EFI_PRINT_PROTOCOL; + +typedef +UINTN +(EFIAPI *EFI_VSPRINT) ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ); + +typedef struct _EFI_PRINT_PROTOCOL { + EFI_VSPRINT VSPrint; +} EFI_PRINT_PROTOCOL; + + +extern EFI_GUID gEfiPrintProtocolGuid; + +#endif \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.c b/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.c new file mode 100644 index 0000000000..9884125e7e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Ps2Policy.c + +Abstract: + + Protocol used for PS/2 Policy definition. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (Ps2Policy) + +EFI_GUID gEfiPs2PolicyProtocolGuid = EFI_PS2_POLICY_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPs2PolicyProtocolGuid, "PS2 Policy", "Policy for Configuring PS2"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.h b/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.h new file mode 100644 index 0000000000..4b270400a7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Ps2Policy/Ps2Policy.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Ps2Policy.h + +Abstract: + + Protocol used for PS/2 Policy definition. + +--*/ + +#ifndef _PS2_POLICY_PROTOCOL_H_ +#define _PS2_POLICY_PROTOCOL_H_ + +EFI_FORWARD_DECLARATION (EFI_PS2_POLICY_PROTOCOL); + +#define EFI_PS2_POLICY_PROTOCOL_GUID \ + { \ + 0x4df19259, 0xdc71, 0x4d46, 0xbe, 0xf1, 0x35, 0x7b, 0xb5, 0x78, 0xc4, 0x18 \ + } + +#define EFI_KEYBOARD_CAPSLOCK 0x0004 +#define EFI_KEYBOARD_NUMLOCK 0x0002 +#define EFI_KEYBOARD_SCROLLLOCK 0x0001 + +typedef +EFI_STATUS +(EFIAPI *EFI_PS2_INIT_HARDWARE) ( + IN EFI_HANDLE Handle + ); + +typedef struct _EFI_PS2_POLICY_PROTOCOL { + UINT8 KeyboardLight; + EFI_PS2_INIT_HARDWARE Ps2InitHardware; +} EFI_PS2_POLICY_PROTOCOL; + +extern EFI_GUID gEfiPs2PolicyProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c new file mode 100644 index 0000000000..7daeed7551 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeDhcp4.c + +Abstract: + PxeDhcp4 GUID declaration + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (PxeDhcp4) + +EFI_GUID gEfiPxeDhcp4ProtocolGuid = EFI_PXE_DHCP4_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPxeDhcp4ProtocolGuid, "PXE DHCP4 Protocol", "PXE DHCPv4 Protocol"); + +/* EOF - PxeDhcp4.c */ diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h new file mode 100644 index 0000000000..50101d3802 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h @@ -0,0 +1,350 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeDhcp4.h + +Abstract: + EFI PXE DHCPv4 protocol definition + +--*/ + +#ifndef _PXEDHCP4_H_ +#define _PXEDHCP4_H_ + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +// +// PXE DHCPv4 GUID definition +// + +#define EFI_PXE_DHCP4_PROTOCOL_GUID \ + { 0x03c4e624, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x29, 0x3f, 0xc1, 0x4d } + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +// +// Interface definition +// + +EFI_FORWARD_DECLARATION (EFI_PXE_DHCP4_PROTOCOL); + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +// +// Descriptions of the DHCP version 4 header and options can be found +// in RFC-2131 and RFC-2132 at www.ietf.org +// + +#pragma pack(1) +typedef struct { + + UINT8 op; +#define BOOTP_REQUEST 1 +#define BOOTP_REPLY 2 + + UINT8 htype; + + UINT8 hlen; + + UINT8 hops; + + UINT32 xid; + + UINT16 secs; +#define DHCP4_INITIAL_SECONDS 4 + + UINT16 flags; +#define DHCP4_BROADCAST_FLAG 0x8000 + + UINT32 ciaddr; + + UINT32 yiaddr; + + UINT32 siaddr; + + UINT32 giaddr; + + UINT8 chaddr[16]; + + UINT8 sname[64]; + + UINT8 fname[128]; + +// +// This is the minimum option length as specified in RFC-2131. +// The packet must be padded out this far with DHCP4_PAD. +// DHCPv4 packets are usually 576 bytes in length. This length +// includes the IPv4 and UDPv4 headers but not the media header. +// Note: Not all DHCP relay agents will forward DHCPv4 packets +// if they are less than 384 bytes or exceed 576 bytes. Even if +// the underlying hardware can handle smaller and larger packets, +// many older relay agents will not accept them. +// + UINT32 magik; +#define DHCP4_MAGIK_NUMBER 0x63825363 + + UINT8 options[308]; + +} DHCP4_HEADER; +#pragma pack() + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +// +// DHCPv4 packet definition. Room for 576 bytes including IP and +// UDP header. +// + +#define DHCP4_MAX_PACKET_SIZE 576 +#define DHCP4_UDP_HEADER_SIZE 8 +#define DHCP4_IP_HEADER_SIZE 20 + +#pragma pack(1) +typedef union _DHCP4_PACKET { + UINT32 _force_data_alignment; + + UINT8 raw[1500]; + + DHCP4_HEADER dhcp4; +} DHCP4_PACKET; +#pragma pack() + +#define DHCP4_SERVER_PORT 67 +#define DHCP4_CLIENT_PORT 68 + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +// +// DHCPv4 and PXE option numbers. +// + +#define DHCP4_PAD 0 +#define DHCP4_END 255 +#define DHCP4_SUBNET_MASK 1 +#define DHCP4_TIME_OFFSET 2 +#define DHCP4_ROUTER_LIST 3 +#define DHCP4_TIME_SERVERS 4 +#define DHCP4_NAME_SERVERS 5 +#define DHCP4_DNS_SERVERS 6 +#define DHCP4_LOG_SERVERS 7 +#define DHCP4_COOKIE_SERVERS 8 +#define DHCP4_LPR_SREVERS 9 +#define DHCP4_IMPRESS_SERVERS 10 +#define DHCP4_RESOURCE_LOCATION_SERVERS 11 +#define DHCP4_HOST_NAME 12 +#define DHCP4_BOOT_FILE_SIZE 13 +#define DHCP4_DUMP_FILE 14 +#define DHCP4_DOMAIN_NAME 15 +#define DHCP4_SWAP_SERVER 16 +#define DHCP4_ROOT_PATH 17 +#define DHCP4_EXTENSION_PATH 18 +#define DHCP4_IP_FORWARDING 19 +#define DHCP4_NON_LOCAL_SOURCE_ROUTE 20 +#define DHCP4_POLICY_FILTER 21 +#define DHCP4_MAX_DATAGRAM_SIZE 22 +#define DHCP4_DEFAULT_TTL 23 +#define DHCP4_MTU_AGING_TIMEOUT 24 +#define DHCP4_MTU_SIZES 25 +#define DHCP4_MTU_TO_USE 26 +#define DHCP4_ALL_SUBNETS_LOCAL 27 +#define DHCP4_BROADCAST_ADDRESS 28 +#define DHCP4_PERFORM_MASK_DISCOVERY 29 +#define DHCP4_RESPOND_TO_MASK_REQ 30 +#define DHCP4_PERFORM_ROUTER_DISCOVERY 31 +#define DHCP4_ROUTER_SOLICIT_ADDRESS 32 +#define DHCP4_STATIC_ROUTER_LIST 33 +#define DHCP4_USE_ARP_TRAILERS 34 +#define DHCP4_ARP_CACHE_TIMEOUT 35 +#define DHCP4_ETHERNET_ENCAPSULATION 36 +#define DHCP4_TCP_DEFAULT_TTL 37 +#define DHCP4_TCP_KEEP_ALIVE_INT 38 +#define DHCP4_KEEP_ALIVE_GARBAGE 39 +#define DHCP4_NIS_DOMAIN_NAME 40 +#define DHCP4_NIS_SERVERS 41 +#define DHCP4_NTP_SERVERS 42 +#define DHCP4_VENDOR_SPECIFIC 43 +# define PXE_MTFTP_IP 1 +# define PXE_MTFTP_CPORT 2 +# define PXE_MTFTP_SPORT 3 +# define PXE_MTFTP_TMOUT 4 +# define PXE_MTFTP_DELAY 5 +# define PXE_DISCOVERY_CONTROL 6 +# define PXE_DISABLE_BROADCAST_DISCOVERY 0x01 +# define PXE_DISABLE_MULTICAST_DISCOVERY 0x02 +# define PXE_ACCEPT_ONLY_PXE_BOOT_SERVERS 0x04 +# define PXE_DO_NOT_PROMPT 0x08 +# define PXE_DISCOVERY_MCAST_ADDR 7 +# define PXE_BOOT_SERVERS 8 +# define PXE_BOOT_MENU 9 +# define PXE_BOOT_PROMPT 10 +# define PXE_MCAST_ADDRS_ALLOC 11 +# define PXE_CREDENTIAL_TYPES 12 +# define PXE_BOOT_ITEM 71 +#define DHCP4_NBNS_SERVERS 44 +#define DHCP4_NBDD_SERVERS 45 +#define DHCP4_NETBIOS_NODE_TYPE 46 +#define DHCP4_NETBIOS_SCOPE 47 +#define DHCP4_XWINDOW_SYSTEM_FONT_SERVERS 48 +#define DHCP4_XWINDOW_SYSTEM_DISPLAY_MANAGERS 49 +#define DHCP4_REQUESTED_IP_ADDRESS 50 +#define DHCP4_LEASE_TIME 51 +#define DHCP4_OPTION_OVERLOAD 52 +# define DHCP4_OVERLOAD_FNAME 1 +# define DHCP4_OVERLOAD_SNAME 2 +# define DHCP4_OVERLOAD_FNAME_AND_SNAME 3 +#define DHCP4_MESSAGE_TYPE 53 +# define DHCP4_MESSAGE_TYPE_DISCOVER 1 +# define DHCP4_MESSAGE_TYPE_OFFER 2 +# define DHCP4_MESSAGE_TYPE_REQUEST 3 +# define DHCP4_MESSAGE_TYPE_DECLINE 4 +# define DHCP4_MESSAGE_TYPE_ACK 5 +# define DHCP4_MESSAGE_TYPE_NAK 6 +# define DHCP4_MESSAGE_TYPE_RELEASE 7 +# define DHCP4_MESSAGE_TYPE_INFORM 8 +#define DHCP4_SERVER_IDENTIFIER 54 +#define DHCP4_PARAMETER_REQUEST_LIST 55 +#define DHCP4_ERROR_MESSAGE 56 +#define DHCP4_MAX_MESSAGE_SIZE 57 +# define DHCP4_DEFAULT_MAX_MESSAGE_SIZE 576 +#define DHCP4_RENEWAL_TIME 58 +#define DHCP4_REBINDING_TIME 59 +#define DHCP4_CLASS_IDENTIFIER 60 +#define DHCP4_CLIENT_IDENTIFIER 61 +#define DHCP4_NISPLUS_DOMAIN_NAME 64 +#define DHCP4_NISPLUS_SERVERS 65 +#define DHCP4_TFTP_SERVER_NAME 66 +#define DHCP4_BOOTFILE 67 +#define DHCP4_MOBILE_IP_HOME_AGENTS 68 +#define DHCP4_SMPT_SERVERS 69 +#define DHCP4_POP3_SERVERS 70 +#define DHCP4_NNTP_SERVERS 71 +#define DHCP4_WWW_SERVERS 72 +#define DHCP4_FINGER_SERVERS 73 +#define DHCP4_IRC_SERVERS 74 +#define DHCP4_STREET_TALK_SERVERS 75 +#define DHCP4_STREET_TALK_DIR_ASSIST_SERVERS 76 +#define DHCP4_NDS_SERVERS 85 +#define DHCP4_NDS_TREE_NAME 86 +#define DHCP4_NDS_CONTEXT 87 +#define DHCP4_SYSTEM_ARCHITECTURE 93 +#define DHCP4_NETWORK_ARCHITECTURE 94 +#define DHCP4_PLATFORM_ID 97 + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +// +// DHCP4 option format. +// + +#pragma pack(1) +typedef struct { + UINT8 op; + UINT8 len; + UINT8 data[1]; +} DHCP4_OP; +#pragma pack() + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +typedef struct { + DHCP4_PACKET Discover; + DHCP4_PACKET Offer; + DHCP4_PACKET Request; + DHCP4_PACKET AckNak; + BOOLEAN SetupCompleted; + BOOLEAN InitCompleted; + BOOLEAN SelectCompleted; + BOOLEAN IsBootp; + BOOLEAN IsAck; +} EFI_PXE_DHCP4_DATA; + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_DHCP4_RUN) ( + IN EFI_PXE_DHCP4_PROTOCOL *This, + IN OPTIONAL UINTN OpLen, + IN OPTIONAL VOID *OpList + ); + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_DHCP4_SETUP) ( + IN EFI_PXE_DHCP4_PROTOCOL *This, + IN OPTIONAL EFI_PXE_DHCP4_DATA * NewData + ); + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_DHCP4_INIT) ( + IN EFI_PXE_DHCP4_PROTOCOL *This, + IN UINTN SecondsTimeout, + OUT UINTN *Offers, + OUT DHCP4_PACKET **OfferList + ); + +#define DHCP4_MIN_SECONDS 1 +#define DHCP4_MAX_SECONDS 60 + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_DHCP4_SELECT) ( + IN EFI_PXE_DHCP4_PROTOCOL *This, + IN UINTN SecondsTimeout, + IN DHCP4_PACKET * offer + ); + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_DHCP4_RENEW) ( + IN EFI_PXE_DHCP4_PROTOCOL *This, + UINTN seconds_timeout + ); + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_DHCP4_REBIND) ( + IN EFI_PXE_DHCP4_PROTOCOL *This, + UINTN seconds_timeout + ); + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +typedef +EFI_STATUS +(EFIAPI *EFI_PXE_DHCP4_RELEASE) ( + IN EFI_PXE_DHCP4_PROTOCOL * This + ); + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +#define EFI_PXE_DHCP4_PROTOCOL_REVISION 0x00010000 + +typedef struct _EFI_PXE_DHCP4_PROTOCOL { + UINT64 Revision; + EFI_PXE_DHCP4_RUN Run; + EFI_PXE_DHCP4_SETUP Setup; + EFI_PXE_DHCP4_INIT Init; + EFI_PXE_DHCP4_SELECT Select; + EFI_PXE_DHCP4_RENEW Renew; + EFI_PXE_DHCP4_REBIND Rebind; + EFI_PXE_DHCP4_RELEASE Release; + EFI_PXE_DHCP4_DATA *Data; +} EFI_PXE_DHCP4_PROTOCOL; + +// +// +// + +extern EFI_GUID gEfiPxeDhcp4ProtocolGuid; + +#endif /* _PXEDHCP4_H_ */ +/* EOF - PxeDhcp4.h */ diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c new file mode 100644 index 0000000000..39101c7572 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeDhcp4Callback.c + +Abstract: + PxeDhcp4Callback protocol GUID definition. + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (PxeDhcp4CallBack) + +EFI_GUID gEfiPxeDhcp4CallbackProtocolGuid = EFI_PXE_DHCP4_CALLBACK_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiPxeDhcp4CallbackProtocolGuid, "PXE DHCP4 Callback Protocol", "PXE DHCP IPv4 Callback Protocol"); + +/* EOF - PxeDhcp4Callback.c */ diff --git a/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h new file mode 100644 index 0000000000..9c1b07a806 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h @@ -0,0 +1,86 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + PxeDhcp4Callback.h + +Abstract: + EFI PXE DHCP4 Callback protocol definition. + +--*/ + +#ifndef _PXE_DHCP4CALLBACK_H +#define _PXE_DHCP4CALLBACK_H + +#include "..\PxeDhcp4\PxeDhcp4.h" + +// +// GUID definition +// + +#define EFI_PXE_DHCP4_CALLBACK_PROTOCOL_GUID \ +{ 0xc1544c01, 0x92a4, 0x4198, 0x8a, 0x84, 0x77, 0x85, 0x83, 0xc2, 0x36, 0x21 } + + +// +// Revision number +// + +#define EFI_PXE_DHCP4_CALLBACK_INTERFACE_REVISION 0x00010000 + +// +// Interface definition +// + +EFI_FORWARD_DECLARATION (EFI_PXE_DHCP4_CALLBACK_PROTOCOL); + +typedef enum { + EFI_PXE_DHCP4_FUNCTION_FIRST, + EFI_PXE_DHCP4_FUNCTION_INIT, + EFI_PXE_DHCP4_FUNCTION_SELECT, + EFI_PXE_DHCP4_FUNCTION_RENEW, + EFI_PXE_DHCP4_FUNCTION_REBIND, + EFI_PXE_DHCP4_FUNCTION_LAST +} EFI_PXE_DHCP4_FUNCTION; + +typedef enum { + EFI_PXE_DHCP4_CALLBACK_STATUS_FIRST, + EFI_PXE_DHCP4_CALLBACK_STATUS_ABORT, + EFI_PXE_DHCP4_CALLBACK_STATUS_IGNORE_ABORT, + EFI_PXE_DHCP4_CALLBACK_STATUS_KEEP_ABORT, + EFI_PXE_DHCP4_CALLBACK_STATUS_CONTINUE, + EFI_PXE_DHCP4_CALLBACK_STATUS_IGNORE_CONTINUE, + EFI_PXE_DHCP4_CALLBACK_STATUS_KEEP_CONTINUE, + EFI_PXE_DHCP4_CALLBACK_STATUS_LAST +} EFI_PXE_DHCP4_CALLBACK_STATUS; + +typedef +EFI_PXE_DHCP4_CALLBACK_STATUS +(EFIAPI *EFI_PXE_DHCP4_CALLBACK) ( + IN EFI_PXE_DHCP4_PROTOCOL *This, + IN EFI_PXE_DHCP4_FUNCTION Function, + IN UINT32 PacketLen, + IN DHCP4_PACKET *Packet OPTIONAL + ); + +typedef struct _EFI_PXE_DHCP4_CALLBACK_PROTOCOL { + UINT64 Revision; + EFI_PXE_DHCP4_CALLBACK Callback; +} EFI_PXE_DHCP4_CALLBACK_PROTOCOL; + +// +// GUID declaration +// + +extern EFI_GUID gEfiPxeDhcp4CallbackProtocolGuid; + +#endif /* _PXE_DHCP4CALLBACK_H */ +/* EOF - PxeDhcp4Callback.h */ diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.c b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.c new file mode 100644 index 0000000000..2af838d532 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.c @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TcgService.c + +Abstract: + + TcgService Protocol GUID as defined in TCG_EFI_Protocol_1_20_Final + + See http://trustedcomputinggroup.org for the latest specification + +--*/ + +#include + +#include EFI_PROTOCOL_DEFINITION(TcgService) + +EFI_GUID gEfiTcgProtocolGuid = EFI_TCG_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiTcgServiceProtocolGuid, "TcgService", "TCG Services Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h new file mode 100644 index 0000000000..0a8cf7d77a --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h @@ -0,0 +1,128 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TcgService.h + +Abstract: + + TCG Service Protocol as defined in TCG_EFI_Protocol_1_20_Final + + See http://trustedcomputinggroup.org for the latest specification + +--*/ + +#ifndef _TCG_SERVICE_PROTOCOL_H_ +#define _TCG_SERVICE_PROTOCOL_H_ + +#include + +#define EFI_TCG_PROTOCOL_GUID \ + {0xf541796d, 0xa62e, 0x4954, 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd} + +#define TSS_EVENT_DATA_MAX_SIZE 256 + +EFI_FORWARD_DECLARATION (EFI_TCG_PROTOCOL); + +// +// Set structure alignment to 1-byte +// +#pragma pack (push, 1) + +typedef struct { + UINT8 Major; + UINT8 Minor; + UINT8 RevMajor; + UINT8 RevMinor; +} TCG_VERSION; + +typedef struct _TCG_EFI_BOOT_SERVICE_CAPABILITY { + UINT8 Size; // Size of this structure + TCG_VERSION StructureVersion; + TCG_VERSION ProtocolSpecVersion; + UINT8 HashAlgorithmBitmap; // Hash algorithms + // this protocol is capable of : 01=SHA-1 + BOOLEAN TPMPresentFlag; // 00h = TPM not present + BOOLEAN TPMDeactivatedFlag; // 01h = TPM currently deactivated +} TCG_EFI_BOOT_SERVICE_CAPABILITY; + +typedef UINT32 TCG_ALGORITHM_ID; + +// +// Restore original structure alignment +// +#pragma pack (pop) + +typedef +EFI_STATUS +(EFIAPI *EFI_TCG_STATUS_CHECK) ( + IN EFI_TCG_PROTOCOL *This, + OUT TCG_EFI_BOOT_SERVICE_CAPABILITY + *ProtocolCapability, + OUT UINT32 *TCGFeatureFlags, + OUT EFI_PHYSICAL_ADDRESS *EventLogLocation, + OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCG_HASH_ALL) ( + IN EFI_TCG_PROTOCOL *This, + IN UINT8 *HashData, + IN UINT64 HashDataLen, + IN TCG_ALGORITHM_ID AlgorithmId, + IN OUT UINT64 *HashedDataLen, + IN OUT UINT8 **HashedDataResult + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCG_LOG_EVENT) ( + IN EFI_TCG_PROTOCOL *This, + IN TCG_PCR_EVENT *TCGLogData, + IN OUT UINT32 *EventNumber, + IN UINT32 Flags + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCG_PASS_THROUGH_TO_TPM) ( + IN EFI_TCG_PROTOCOL *This, + IN UINT32 TpmInputParamterBlockSize, + IN UINT8 *TpmInputParamterBlock, + IN UINT32 TpmOutputParameterBlockSize, + IN UINT8 *TpmOutputParameterBlock + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCG_HASH_LOG_EXTEND_EVENT) ( + IN EFI_TCG_PROTOCOL *This, + IN UINT8 *HashData, + IN UINT64 HashDataLen, + IN TCG_ALGORITHM_ID AlgorithmId, + IN OUT TCG_PCR_EVENT *TCGLogData, + IN OUT UINT32 *EventNumber, + OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry + ); + +typedef struct _EFI_TCG_PROTOCOL { + EFI_TCG_STATUS_CHECK StatusCheck; + EFI_TCG_HASH_ALL HashAll; + EFI_TCG_LOG_EVENT LogEvent; + EFI_TCG_PASS_THROUGH_TO_TPM PassThroughToTpm; + EFI_TCG_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; +} EFI_TCG_PROTOCOL; + +extern EFI_GUID gEfiTcgProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.c b/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.c new file mode 100644 index 0000000000..8575d076d1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Tcp.c + +Abstract: + + +Revision History + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(Tcp) + + +EFI_GUID gEfiTcpProtocolGuid = EFI_TCP_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiTcpProtocolGuid, "Transmission Control Protocol", "EFI Transmission Control Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.h b/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.h new file mode 100644 index 0000000000..f1b79fa6e1 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/Tcp/Tcp.h @@ -0,0 +1,110 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + tcp.h + +Abstract: + + EFI Transmission Control Protocol + + + +Revision History + +--*/ + + +#ifndef _EFITCP_H +#define _EFITCP_H + + +#include EFI_PROTOCOL_DEFINITION(PxeBaseCode) + +// +// PXE Base Code protocol +// + +#define EFI_TCP_PROTOCOL_GUID \ + { 0x02b3d5f2, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } + +EFI_FORWARD_DECLARATION (EFI_TCP_PROTOCOL); + + +typedef UINT16 EFI_PXE_BASE_CODE_TCP_PORT; + +// +// Port Receive Filter definitions +// +#define EFI_PXE_BASE_CODE_MAX_PORTCNT 8 +typedef struct { + UINT8 Filters; + UINT8 IpCnt; + UINT16 reserved; + EFI_IP_ADDRESS IpList[EFI_PXE_BASE_CODE_MAX_PORTCNT]; +} EFI_TCP_PORT_FILTER; + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP_WRITE) ( + IN EFI_PXE_BASE_CODE_PROTOCOL *This, + IN UINT16 OpFlags, + IN UINT16 *UrgentPointer, + IN UINT32 *SequenceNumber, + IN UINT32 *AckNumber, + IN UINT16 *HlenResCode, + IN UINT16 *Window, + IN EFI_IP_ADDRESS *DestIp, + IN UINT16 *DestPort, + IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL + IN EFI_IP_ADDRESS *SrcIp, OPTIONAL + IN UINT16 *SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN UINTN *BufferSize, + IN VOID *BufferPtr + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP_READ) ( + IN EFI_PXE_BASE_CODE_PROTOCOL *This, + IN UINT16 OpFlags, + IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL + IN OUT UINT16 *DestPort, OPTIONAL + IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL + IN OUT UINT16 *SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN OUT UINTN *BufferSize, + IN VOID *BufferPtr + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_TCP_SET_PORT_FILTER) ( + IN EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_TCP_PORT_FILTER *NewFilter + ); + +// +// TCP Protocol structure +// +typedef struct _EFI_TCP_PROTOCOL { + EFI_TCP_WRITE TcpWrite; + EFI_TCP_READ TcpRead; + EFI_TCP_SET_PORT_FILTER SetPortFilter; +} EFI_TCP_PROTOCOL; + +extern EFI_GUID gEfiTcpProtocolGuid; + +#endif /* _EFITCP_H */ diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.c b/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.c new file mode 100644 index 0000000000..bdee96d389 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoDecompress.c + +Abstract: + + The GUID for the Tiano Decompress Protocol + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION(TianoDecompress) + +EFI_GUID gEfiTianoDecompressProtocolGuid = EFI_TIANO_DECOMPRESS_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiTianoDecompressProtocolGuid, "Tiano Decompress", "Tiano Decompression Protocol"); + diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.h b/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.h new file mode 100644 index 0000000000..7ca8532db7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/TianoDecompress/TianoDecompress.h @@ -0,0 +1,139 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoDecompress.h + +Abstract: + + The Tiano Decompress Protocol Interface + +--*/ + +#ifndef _TIANO_DECOMPRESS_H_ +#define _TIANO_DECOMPRESS_H_ + +#define EFI_TIANO_DECOMPRESS_PROTOCOL_GUID \ + { 0xe84cf29c, 0x191f, 0x4eae, 0x96, 0xe1, 0xf4, 0x6a, 0xec, 0xea, 0xea, 0x0b } + +EFI_FORWARD_DECLARATION (EFI_TIANO_DECOMPRESS_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_TIANO_DECOMPRESS_GET_INFO) ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); +/*++ + +Routine Description: + + The GetInfo() function retrieves the size of the uncompressed buffer + and the temporary scratch buffer required to decompress the buffer + specified by Source and SourceSize. If the size of the uncompressed + buffer or the size of the scratch buffer cannot be determined from + the compressed data specified by Source and SourceData, then + EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed + buffer is returned in DestinationSize, the size of the scratch buffer is + returned in ScratchSize, and EFI_SUCCESS is returned. + + The GetInfo() function does not have scratch buffer available to perform + a thorough checking of the validity of the source data. It just retrieves + the 'Original Size' field from the beginning bytes of the source data and + output it as DestinationSize. And ScratchSize is specific to the decompression + implementation. + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SourceSize - The size, in bytes, of source buffer. + DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer + that will be generated when the compressed buffer specified + by Source and SourceSize is decompressed. + ScratchSize - A pointer to the size, in bytes, of the scratch buffer that + is required to decompress the compressed buffer specified by + Source and SourceSize. + +Returns: + EFI_SUCCESS - The size of the uncompressed data was returned in DestinationSize + and the size of the scratch buffer was returned in ScratchSize. + EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch + buffer cannot be determined from the compressed data specified by + Source and SourceData. + +--*/ + + +typedef +EFI_STATUS +(EFIAPI *EFI_TIANO_DECOMPRESS_DECOMPRESS) ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID* Source, + IN UINT32 SourceSize, + IN OUT VOID* Destination, + IN UINT32 DestinationSize, + IN OUT VOID* Scratch, + IN UINT32 ScratchSize + ); +/*++ + +Routine Description: + + The Decompress() function extracts decompressed data to its original form. + + This protocol is designed so that the decompression algorithm can be + implemented without using any memory services. As a result, the + Decompress() function is not allowed to call AllocatePool() or + AllocatePages() in its implementation. It is the caller's responsibility + to allocate and free the Destination and Scratch buffers. + + If the compressed source data specified by Source and SourceSize is + sucessfully decompressed into Destination, then EFI_SUCCESS is returned. + If the compressed source data specified by Source and SourceSize is not in + a valid compressed data format, then EFI_INVALID_PARAMETER is returned. + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SourceSize - The size of source data. + Destination - On output, the destination buffer that contains + the uncompressed data. + DestinationSize - The size of destination buffer. The size of destination + buffer needed is obtained from GetInfo(). + Scratch - A temporary scratch buffer that is used to perform the + decompression. + ScratchSize - The size of scratch buffer. The size of scratch buffer needed + is obtained from GetInfo(). + +Returns: + + EFI_SUCCESS - Decompression completed successfully, and the uncompressed + buffer is returned in Destination. + EFI_INVALID_PARAMETER + - The source buffer specified by Source and SourceSize is + corrupted (not in a valid compressed format). + +--*/ + +typedef struct _EFI_TIANO_DECOMPRESS_PROTOCOL { + EFI_TIANO_DECOMPRESS_GET_INFO GetInfo; + EFI_TIANO_DECOMPRESS_DECOMPRESS Decompress; +} EFI_TIANO_DECOMPRESS_PROTOCOL; + +extern EFI_GUID gEfiTianoDecompressProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.c b/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.c new file mode 100644 index 0000000000..ca6ef68a10 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.c @@ -0,0 +1,29 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UgaSplash.c + +Abstract: + + UGA Splash protocol. + + Abstraction of a very simple graphics device splash screen. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (UgaSplash) + +EFI_GUID gEfiUgaSplashProtocolGuid = EFI_UGA_SPLASH_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiUgaSplashProtocolGuid, "UGA Splash Protocol", "UGA Splash Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.h b/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.h new file mode 100644 index 0000000000..91f17a8108 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/UgaSplash/UgaSplash.h @@ -0,0 +1,45 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UgaSplash.h + +Abstract: + + UGA Splash screen protocol. + + Abstraction of a very simple graphics device. + +--*/ + +#ifndef __UGA_SPLASH_H__ +#define __UGA_SPLASH_H__ + +#include EFI_PROTOCOL_DEFINITION (GraphicsOutput) +#include EFI_PROTOCOL_DEFINITION (UgaDraw) + + +#define EFI_UGA_SPLASH_PROTOCOL_GUID \ + { 0xa45b3a0d, 0x2e55, 0x4c03, 0xad, 0x9c, 0x27, 0xd4, 0x82, 0xb, 0x50, 0x7e } + +typedef struct _EFI_UGA_SPLASH_PROTOCOL EFI_UGA_SPLASH_PROTOCOL; + + +typedef struct _EFI_UGA_SPLASH_PROTOCOL { + UINT32 PixelWidth; + UINT32 PixelHeight; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Image; +} EFI_UGA_SPLASH_PROTOCOL; + +extern EFI_GUID gEfiUgaSplashProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.c b/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.c new file mode 100644 index 0000000000..2a0d0c1670 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.c @@ -0,0 +1,31 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UsbAtapi.c + +Abstract: + + EFI USB Atapi Protocol + +Revision History + +--*/ + +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (UsbIo) +#include EFI_PROTOCOL_DEFINITION (UsbAtapi) + +EFI_GUID gEfiUsbAtapiProtocolGuid = EFI_USB_ATAPI_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiUsbAtapiProtocolGuid, "Usb Atapi Protocol", "Usb Atapi Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.h b/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.h new file mode 100644 index 0000000000..3fdc76e1d5 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/UsbAtapi/usbatapi.h @@ -0,0 +1,83 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UsbAtapi.h + +Abstract: + + EFI Atapi Protocol definition. + +Revision History + +--*/ + +#ifndef _EFI_USB_ATAPI_H +#define _EFI_USB_ATAPI_H + +// +// Transfer protocol types +// +#define BOT 0x50 +#define CBI0 0x00 +#define CBI1 0x01 + +// +// SubClass Code (defines command set) +// +#define EFI_USB_SUBCLASS_RBC 0x01 +#define EFI_USB_SUBCLASS_ATAPI 0x02 +#define EFI_USB_SUBCLASS_QIC_157 0x03 +#define EFI_USB_SUBCLASS_UFI 0x04 +#define EFI_USB_SUBCLASS_SFF_8070i 0x05 +#define EFI_USB_SUBCLASS_SCSI 0x06 +#define EFI_USB_SUBCLASS_RESERVED_LOW 0x07 +#define EFI_USB_SUBCLASS_RESERVED_HIGH 0xff +// +// Global GUID for transfer protocol interface +// +#define EFI_USB_ATAPI_PROTOCOL_GUID \ + { 0x2B2F68DA, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } + +EFI_FORWARD_DECLARATION (EFI_USB_ATAPI_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_ATAPI_PACKET_CMD) ( + IN EFI_USB_ATAPI_PROTOCOL *This, + IN VOID *Command, + IN UINT8 CommandSize, + IN VOID *DataBuffer, + IN UINT32 BufferLength, + IN EFI_USB_DATA_DIRECTION Direction, + IN UINT16 TimeOutInMilliSeconds +); + +typedef +EFI_STATUS +(EFIAPI *EFI_USB_MASS_STORAGE_RESET) ( + IN EFI_USB_ATAPI_PROTOCOL *This, + IN BOOLEAN ExtendedVerification +); + +// +// Protocol Interface Structure +// +typedef struct _EFI_USB_ATAPI_PROTOCOL { + EFI_USB_ATAPI_PACKET_CMD UsbAtapiPacketCmd; + EFI_USB_MASS_STORAGE_RESET UsbAtapiReset; + UINT32 CommandProtocol; +} EFI_USB_ATAPI_PROTOCOL; + +extern EFI_GUID gEfiUsbAtapiProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.c b/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.c new file mode 100644 index 0000000000..2fe8493a17 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.c @@ -0,0 +1,36 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VariableStore.c + +Abstract: + +Revision History + +--*/ + +// +// The variable store protocol interface is specific to the reference +// implementation. The initialization code adds variable store devices +// to the system, and the FW connects to the devices to provide the +// variable store interfaces through these devices. +// +// +// Variable Store Device protocol +// +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (VariableStore) + +EFI_GUID gEfiVariableStoreProtocolGuid = EFI_VARIABLE_STORE_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiVariableStoreProtocolGuid, "Variable Storage Protocol", "Tiano Variable Storage Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.h b/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.h new file mode 100644 index 0000000000..5ab888b558 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/VariableStore/VariableStore.h @@ -0,0 +1,105 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VariableStore.h + +Abstract: + +Revision History + +--*/ + +#ifndef _VARIABLE_STORE_H +#define _VARIABLE_STORE_H + +// +// The variable store protocol interface is specific to the reference +// implementation. The initialization code adds variable store devices +// to the system, and the FW connects to the devices to provide the +// variable store interfaces through these devices. +// + +// +// Variable Store Device protocol +// +#define EFI_VARIABLE_STORE_PROTOCOL_GUID \ + { 0xf088cd91, 0xa046, 0x11d2, 0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + +EFI_FORWARD_DECLARATION (EFI_VARIABLE_STORE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_CLEAR_STORE) ( + IN EFI_VARIABLE_STORE_PROTOCOL *This, + IN OUT VOID *Scratch + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_READ_STORE) ( + IN EFI_VARIABLE_STORE_PROTOCOL *This, + IN UINTN Offset, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UPDATE_STORE) ( + IN EFI_VARIABLE_STORE_PROTOCOL *This, + IN UINTN Offset, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_CLEANUP_STORE) ( + IN EFI_VARIABLE_STORE_PROTOCOL *This + ); + +typedef struct _EFI_VARIABLE_STORE_PROTOCOL { + + // + // Number of banks and bank size + // + UINT32 Attributes; + UINT32 BankSize; + + // + // Functions to access the storage banks + // + EFI_CLEAR_STORE ClearStore; + EFI_READ_STORE ReadStore; + EFI_UPDATE_STORE UpdateStore; + EFI_CLEANUP_STORE CleanupStore; + +} EFI_VARIABLE_STORE_PROTOCOL; + +// +// +// ClearStore() - A function to clear the requested storage bank. A cleared +// bank contains all "on" bits. +// +// ReadStore() - Read data from the requested store. +// +// UpdateStore() - Updates data on the requested store. The FW will only +// ever issue updates to clear bits in the store. Updates must +// be performed in LSb to MSb order of the update buffer. +// +// CleanupStore() - Do garbage collection and reclaim operation. +// + +extern EFI_GUID gEfiVariableStoreProtocolGuid; + +#endif // _VARIABLE_STORE_H diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c b/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c new file mode 100644 index 0000000000..edc3989b50 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + VgaMiniPort.c + +Abstract: + + EFI VGA Mini Port Protocol + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (VgaMiniPort) + +EFI_GUID gEfiVgaMiniPortProtocolGuid = EFI_VGA_MINI_PORT_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiVgaMiniPortProtocolGuid, "VGA Mini Port Protocol", "EFI VGA Mini Port Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h b/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h new file mode 100644 index 0000000000..40304ab64e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h @@ -0,0 +1,70 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + VgaMiniPort.h + +Abstract: + + Vga Mini port binding for a VGA controller + +--*/ + +#ifndef _VGA_MINI_PORT_H +#define _VGA_MINI_PORT_H + +#define EFI_VGA_MINI_PORT_PROTOCOL_GUID \ + { \ + 0xc7735a2f, 0x88f5, 0x4882, 0xae, 0x63, 0xfa, 0xac, 0x8c, 0x8b, 0x86, 0xb3 \ + } + +EFI_FORWARD_DECLARATION (EFI_VGA_MINI_PORT_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_VGA_MINI_PORT_SET_MODE) ( + IN EFI_VGA_MINI_PORT_PROTOCOL * This, + IN UINTN ModeNumber + ); + +/*++ + + Routine Description: + Sets the text display mode of a VGA controller + + Arguments: + This - Protocol instance pointer. + Mode - Mode number. 0 - 80x25 1-80x50 + + Returns: + EFI_SUCCESS - The mode was set + EFI_DEVICE_ERROR - The device is not functioning properly. + +--*/ +typedef struct _EFI_VGA_MINI_PORT_PROTOCOL { + EFI_VGA_MINI_PORT_SET_MODE SetMode; + + UINT64 VgaMemoryOffset; + UINT64 CrtcAddressRegisterOffset; + UINT64 CrtcDataRegisterOffset; + + UINT8 VgaMemoryBar; + UINT8 CrtcAddressRegisterBar; + UINT8 CrtcDataRegisterBar; + + UINT8 MaxMode; +} EFI_VGA_MINI_PORT_PROTOCOL; + +extern EFI_GUID gEfiVgaMiniPortProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c b/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c new file mode 100644 index 0000000000..cfc5e0de53 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c @@ -0,0 +1,27 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VirtualMemoryAccess.c + +Abstract: + + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (VirtualMemoryAccess) + +EFI_GUID gEfiVirtualMemoryAccessProtocolGuid = EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL_GUID; + +EFI_GUID_STRING + (&gEfiVirtualMemoryAccessProtocolGuid, "Virtual Memory Access Protocol", "Tiano Virtual Memory Access Protocol"); diff --git a/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h b/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h new file mode 100644 index 0000000000..c0e1fde856 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h @@ -0,0 +1,64 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VirtualmemoryAccess.h + +Abstract: + + +--*/ + +#ifndef _VIRTUAL_MEMORY_ACCESS_H_ +#define _VIRTUAL_MEMORY_ACCESS_H_ + +#define EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL_GUID \ + {0x745d377a, 0xb988, 0x47b2, 0xb1, 0x8f, 0xbb, 0xc8, 0xd, 0xc5, 0x66, 0x98} + + +EFI_FORWARD_DECLARATION (EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_MAP) ( + IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS MappingAddress, + IN UINTN NumberOfBytes, + IN EFI_PHYSICAL_ADDRESS MappedAddress +); + +typedef +EFI_STATUS +(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_UNMAP) ( + IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS MappedAddress, + IN UINTN PageSizeInByte +); + +typedef +EFI_STATUS +(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_GET_PAGE_SIZE) ( + IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This, + IN UINTN *PageSizeInByte +); + + +typedef struct _EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL { + EFI_VIRTUAL_MEMORY_ACCESS_GET_PAGE_SIZE GetPageSize; + EFI_VIRTUAL_MEMORY_ACCESS_MAP Map; + EFI_VIRTUAL_MEMORY_ACCESS_UNMAP UnMap; +} EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL; + +extern EFI_GUID gEfiVirtualMemoryAccessProtocolGuid; + +#endif + diff --git a/EdkCompatibilityPkg/License.txt b/EdkCompatibilityPkg/License.txt new file mode 100644 index 0000000000..67db1ea720 --- /dev/null +++ b/EdkCompatibilityPkg/License.txt @@ -0,0 +1,30 @@ +Copyright (c) 2004, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + . Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + + . Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + + . Neither the name of the Intel Corporation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt new file mode 100644 index 0000000000..2954da97cf --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133.txt @@ -0,0 +1,1766 @@ +======================================================================= +List of Implemented Fixes and Changes for Maintenance Releases of PCCTS + + + For a summary of the most significant changes see CHANGES_SUMMARY.TXT + +======================================================================= + + DISCLAIMER + + The software and these notes are provided "as is". They may include + typographical or technical errors and their authors disclaims all + liability of any kind or nature for damages due to error, fault, + defect, or deficiency regardless of cause. All warranties of any + kind, either express or implied, including, but not limited to, the + implied warranties of merchantability and fitness for a particular + purpose are disclaimed. + + + ------------------------------------------------------- + Note: Items #153 to #1 are now in a separate file named + CHANGES_FROM_133_BEFORE_MR13.txt + ------------------------------------------------------- + +#261. (Changed in MR19) Defer token fetch for C++ mode + + Item #216 has been revised to indicate that use of the defer fetch + option (ZZDEFER_FETCH) requires dlg option -i. + +#260. (MR22) Raise default lex buffer size from 8,000 to 32,000 bytes. + + ZZLEXBUFSIZE is the size (in bytes) of the buffer used by dlg + generated lexers. The default value has been raised to 32,000 and + the value used by antlr, dlg, and sorcerer has also been raised to + 32,000. + +#259. (MR22) Default function arguments in C++ mode. + + If a rule is declared: + + rr [int i = 0] : .... + + then the declaration generated by pccts resembles: + + void rr(int i = 0); + + however, the definition must omit the default argument: + + void rr(int i) {...} + + In the past the default value was not omitted. In MR22 + the generated code resembles: + + void rr(int i /* = 0 */ ) {...} + + Implemented by Volker H. Simonis (simonis@informatik.uni-tuebingen.de) + +#258. (MR22) Using a base class for your parser + + In item #102 (MR10) the class statement was extended to allow one + to specify a base class other than ANTLRParser for the generated + parser. It turned out that this was less than useful because + the constructor still specified ANTLRParser as the base class. + + The class statement now uses the first identifier appearing after + the ":" as the name of the base class. For example: + + class MyParser : public FooParser { + + Generates in MyParser.h: + + class MyParser : public FooParser { + + Generates in MyParser.cpp something that resembles: + + MyParser::MyParser(ANTLRTokenBuffer *input) : + FooParser(input,1,0,0,4) + { + token_tbl = _token_tbl; + traceOptionValueDefault=1; // MR10 turn trace ON + } + + The base class must constructor must have a signature similar to + that of ANTLRParser. + +#257. (MR21a) Removed dlg statement that -i has no effect in C++ mode. + + This was incorrect. + +#256. (MR21a) Malformed syntax graph causes crash after error message. + + In the past, certain kinds of errors in the very first grammar + element could cause the construction of a malformed graph + representing the grammar. This would eventually result in a + fatal internal error. The code has been changed to be more + resistant to this particular error. + +#255. (MR21a) ParserBlackBox(FILE* f) + + This constructor set openByBlackBox to the wrong value. + + Reported by Kees Bakker (kees_bakker@tasking.nl). + +#254. (MR21a) Reporting syntax error at end-of-file + + When there was a syntax error at the end-of-file the syntax + error routine would substitute "" for the programmer's + end-of-file symbol. This substitution is now done only when + the programmer does not define his own end-of-file symbol + or the symbol begins with the character "@". + + Reported by Kees Bakker (kees_bakker@tasking.nl). + +#253. (MR21) Generation of block preamble (-preamble and -preamble_first) + + The antlr option -preamble causes antlr to insert the code + BLOCK_PREAMBLE at the start of each rule and block. It does + not insert code before rules references, token references, or + actions. By properly defining the macro BLOCK_PREAMBLE the + user can generate code which is specific to the start of blocks. + + The antlr option -preamble_first is similar, but inserts the + code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol + PreambleFirst_123 is equivalent to the first set defined by + the #FirstSetSymbol described in Item #248. + + I have not investigated how these options interact with guess + mode (syntactic predicates). + +#252. (MR21) Check for null pointer in trace routine + + When some trace options are used when the parser is generated + without the trace enabled, the current rule name may be a + NULL pointer. A guard was added to check for this in + restoreState. + + Reported by Douglas E. Forester (dougf@projtech.com). + +#251. (MR21) Changes to #define zzTRACE_RULES + + The macro zzTRACE_RULES was being use to pass information to + AParser.h. If this preprocessor symbol was not properly + set the first time AParser.h was #included, the declaration + of zzTRACEdata would be omitted (it is used by the -gd option). + Subsequent #includes of AParser.h would be skipped because of + the #ifdef guard, so the declaration of zzTracePrevRuleName would + never be made. The result was that proper compilation was very + order dependent. + + The declaration of zzTRACEdata was made unconditional and the + problem of removing unused declarations will be left to optimizers. + + Diagnosed by Douglas E. Forester (dougf@projtech.com). + +#250. (MR21) Option for EXPERIMENTAL change to error sets for blocks + + The antlr option -mrblkerr turns on an experimental feature + which is supposed to provide more accurate syntax error messages + for k=1, ck=1 grammars. When used with k>1 or ck>1 grammars the + behavior should be no worse than the current behavior. + + There is no problem with the matching of elements or the computation + of prediction expressions in pccts. The task is only one of listing + the most appropriate tokens in the error message. The error sets used + in pccts error messages are approximations of the exact error set when + optional elements in (...)* or (...)+ are involved. While entirely + correct, the error messages are sometimes not 100% accurate. + + There is also a minor philosophical issue. For example, suppose the + grammar expects the token to be an optional A followed by Z, and it + is X. X, of course, is neither A nor Z, so an error message is appropriate. + Is it appropriate to say "Expected Z" ? It is correct, it is accurate, + but it is not complete. + + When k>1 or ck>1 the problem of providing the exactly correct + list of tokens for the syntax error messages ends up becoming + equivalent to evaluating the prediction expression for the + alternatives twice. However, for k=1 ck=1 grammars the prediction + expression can be computed easily and evaluated cheaply, so I + decided to try implementing it to satisfy a particular application. + This application uses the error set in an interactive command language + to provide prompts which list the alternatives available at that + point in the parser. The user can then enter additional tokens to + complete the command line. To do this required more accurate error + sets then previously provided by pccts. + + In some cases the default pccts behavior may lead to more robust error + recovery or clearer error messages then having the exact set of tokens. + This is because (a) features like -ge allow the use of symbolic names for + certain sets of tokens, so having extra tokens may simply obscure things + and (b) the error set is use to resynchronize the parser, so a good + choice is sometimes more important than having the exact set. + + Consider the following example: + + Note: All examples code has been abbreviated + to the absolute minimum in order to make the + examples concise. + + star1 : (A)* Z; + + The generated code resembles: + + old new (with -mrblkerr) + ------------- -------------------- + for (;;) { for (;;) { + match(A); match(A); + } } + match(Z); if (! A and ! Z) then + FAIL(...{A,Z}...); + } + match(Z); + + + With input X + old message: Found X, expected Z + new message: Found X, expected A, Z + + For the example: + + star2 : (A|B)* Z; + + old new (with -mrblkerr) + ------------- -------------------- + for (;;) { for (;;) { + if (!A and !B) break; if (!A and !B) break; + if (...) { if (...) { + + } } + else { else { + FAIL(...{A,B,Z}...) FAIL(...{A,B}...); + } } + } } + match(B); if (! A and ! B and !Z) then + FAIL(...{A,B,Z}...); + } + match(B); + + With input X + old message: Found X, expected Z + new message: Found X, expected A, B, Z + With input A X + old message: Found X, expected Z + new message: Found X, expected A, B, Z + + This includes the choice of looping back to the + star block. + + The code for plus blocks: + + plus1 : (A)+ Z; + + The generated code resembles: + + old new (with -mrblkerr) + ------------- -------------------- + do { do { + match(A); match(A); + } while (A) } while (A) + match(Z); if (! A and ! Z) then + FAIL(...{A,Z}...); + } + match(Z); + + With input A X + old message: Found X, expected Z + new message: Found X, expected A, Z + + This includes the choice of looping back to the + plus block. + + For the example: + + plus2 : (A|B)+ Z; + + old new (with -mrblkerr) + ------------- -------------------- + do { do { + if (A) { + match(A); + } else if (B) { + match(B); + } else { + if (cnt > 1) break; + FAIL(...{A,B,Z}...) FAIL(...{A,B}...); + } } + cnt++; + } } + + match(Z); if (! A and ! B and !Z) then + FAIL(...{A,B,Z}...); + } + match(B); + + With input X + old message: Found X, expected A, B, Z + new message: Found X, expected A, B + With input A X + old message: Found X, expected Z + new message: Found X, expected A, B, Z + + This includes the choice of looping back to the + star block. + +#249. (MR21) Changes for DEC/VMS systems + + Jean-François Piéronne (jfp@altavista.net) has updated some + VMS related command files and fixed some minor problems related + to building pccts under the DEC/VMS operating system. For DEC/VMS + users the most important differences are: + + a. Revised makefile.vms + b. Revised genMMS for genrating VMS style makefiles. + +#248. (MR21) Generate symbol for first set of an alternative + + pccts can generate a symbol which represents the tokens which may + appear at the start of a block: + + rr : #FirstSetSymbol(rr_FirstSet) ( Foo | Bar ) ; + + This will generate the symbol rr_FirstSet of type SetWordType with + elements Foo and Bar set. The bits can be tested using code similar + to the following: + + if (set_el(Foo, &rr_FirstSet)) { ... + + This can be combined with the C array zztokens[] or the C++ routine + tokenName() to get the print name of the token in the first set. + + The size of the set is given by the newly added enum SET_SIZE, a + protected member of the generated parser's class. The number of + elements in the generated set will not be exactly equal to the + value of SET_SIZE because of synthetic tokens created by #tokclass, + #errclass, the -ge option, and meta-tokens such as epsilon, and + end-of-file. + + The #FirstSetSymbol must appear immediately before a block + such as (...)+, (...)*, and {...}, and (...). It may not appear + immediately before a token, a rule reference, or action. However + a token or rule reference can be enclosed in a (...) in order to + make the use of #pragma FirstSetSymbol legal. + + rr_bad : #FirstSetSymbol(rr_bad_FirstSet) Foo; // Illegal + + rr_ok : #FirstSetSymbol(rr_ok_FirstSet) (Foo); // Legal + + Do not confuse FirstSetSymbol sets with the sets used for testing + lookahead. The sets used for FirstSetSymbol have one element per bit, + so the number of bytes is approximately the largest token number + divided by 8. The sets used for testing lookahead store 8 lookahead + sets per byte, so the length of the array is approximately the largest + token number. + + If there is demand, a similar routine for follow sets can be added. + +#247. (MR21) Misleading error message on syntax error for optional elements. + + Prior to MR21, tokens which were optional did not appear in syntax + error messages if the block which immediately followed detected a + syntax error. + + Consider the following grammar which accepts Number, Word, and Other: + + rr : {Number} Word; + + For this rule the code resembles: + + if (LA(1) == Number) { + match(Number); + consume(); + } + match(Word); + + Prior to MR21, the error message for input "$ a" would be: + + line 1: syntax error at "$" missing Word + + With MR21 the message will be: + + line 1: syntax error at "$" expecting Word, Number. + + The generate code resembles: + + if ( (LA(1)==Number) ) { + zzmatch(Number); + consume(); + } + else { + if ( (LA(1)==Word) ) { + /* nothing */ + } + else { + FAIL(... message for both Number and Word ...); + } + } + match(Word); + + The code generated for optional blocks in MR21 is slightly longer + than the previous versions, but it should give better error messages. + + The code generated for: + + { a | b | c } + + should now be *identical* to: + + ( a | b | c | ) + + which was not the case prior to MR21. + + Reported by Sue Marvin (sue@siara.com). + +#246. (Changed in MR21) Use of $(MAKE) for calls to make + + Calls to make from the makefiles were replaced with $(MAKE) + because of problems when using gmake. + + Reported with fix by Sunil K.Vallamkonda (sunil@siara.com). + +#245. (Changed in MR21) Changes to genmk + + The following command line options have been added to genmk: + + -cfiles ... + + To add a user's C or C++ files into makefile automatically. + The list of files must be enclosed in apostrophes. This + option may be specified multiple times. + + -compiler ... + + The name of the compiler to use for $(CCC) or $(CC). The + default in C++ mode is "CC". The default in C mode is "cc". + + -pccts_path ... + + The value for $(PCCTS), the pccts directory. The default + is /usr/local/pccts. + + Contributed by Tomasz Babczynski (t.babczynski@ict.pwr.wroc.pl). + +#244. (Changed in MR21) Rename variable "not" in antlr.g + + When antlr.g is compiled with a C++ compiler, a variable named + "not" causes problems. Reported by Sinan Karasu + (sinan.karasu@boeing.com). + +#243 (Changed in MR21) Replace recursion with iteration in zzfree_ast + + Another refinement to zzfree_ast in ast.c to limit recursion. + + NAKAJIMA Mutsuki (muc@isr.co.jp). + + +#242. (Changed in MR21) LineInfoFormatStr + + Added an #ifndef/#endif around LineInfoFormatStr in pcctscfg.h. + +#241. (Changed in MR21) Changed macro PURIFY to a no-op + + *********************** + *** NOT IMPLEMENTED *** + *********************** + + The PURIFY macro was changed to a no-op because it was causing + problems when passing C++ objects. + + The old definition: + + #define PURIFY(r,s) memset((char *) &(r),'\\0',(s)); + + The new definition: + + #define PURIFY(r,s) /* nothing */ +#endif + +#240. (Changed in MR21) sorcerer/h/sorcerer.h _MATCH and _MATCHRANGE + + Added test for NULL token pointer. + + Suggested by Peter Keller (keller@ebi.ac.uk) + +#239. (Changed in MR21) C++ mode AParser::traceGuessFail + + If tracing is turned on when the code has been generated + without trace code, a failed guess generates a trace report + even though there are no other trace reports. This + make the behavior consistent with other parts of the + trace system. + + Reported by David Wigg (wiggjd@sbu.ac.uk). + +#238. (Changed in MR21) Namespace version #include files + + Changed reference from CStdio to cstdio (and other + #include file names) in the namespace version of pccts. + Should have known better. + +#237. (Changed in MR21) ParserBlackBox(FILE*) + + In the past, ParserBlackBox would close the FILE in the dtor + even though it was not opened by ParserBlackBox. The problem + is that there were two constructors, one which accepted a file + name and did an fopen, the other which accepted a FILE and did + not do an fopen. There is now an extra member variable which + remembers whether ParserBlackBox did the open or not. + + Suggested by Mike Percy (mpercy@scires.com). + +#236. (Changed in MR21) tmake now reports down pointer problem + + When ASTBase::tmake attempts to update the down pointer of + an AST it checks to see if the down pointer is NULL. If it + is not NULL it does not do the update and returns NULL. + An attempt to update the down pointer is almost always a + result of a user error. This can lead to difficult to find + problems during tree construction. + + With this change, the routine calls a virtual function + reportOverwriteOfDownPointer() which calls panic to + report the problem. Users who want the old behavior can + redefined the virtual function in their AST class. + + Suggested by Sinan Karasu (sinan.karasu@boeing.com) + +#235. (Changed in MR21) Made ANTLRParser::resynch() virtual + + Suggested by Jerry Evans (jerry@swsl.co.uk). + +#234. (Changed in MR21) Implicit int for function return value + + ATokenBuffer:bufferSize() did not specify a type for the + return value. + + Reported by Hai Vo-Ba (hai@fc.hp.com). + +#233. (Changed in MR20) Converted to MSVC 6.0 + + Due to external circumstances I have had to convert to MSVC 6.0 + The MSVC 5.0 project files (.dsw and .dsp) have been retained as + xxx50.dsp and xxx50.dsw. The MSVC 6.0 files are named xxx60.dsp + and xxx60.dsw (where xxx is the related to the directory/project). + +#232. (Changed in MR20) Make setwd bit vectors protected in parser.h + + The access for the setwd array in the parser header was not + specified. As a result, it would depend on the code which + preceded it. In MR20 it will always have access "protected". + + Reported by Piotr Eljasiak (eljasiak@zt.gdansk.tpsa.pl). + +#231. (Changed in MR20) Error in token buffer debug code. + + When token buffer debugging is selected via the pre-processor + symbol DEBUG_TOKENBUFFER there is an erroneous check in + AParser.cpp: + + #ifdef DEBUG_TOKENBUFFER + if (i >= inputTokens->bufferSize() || + inputTokens->minTokens() < LLk ) /* MR20 Was "<=" */ + ... + #endif + + Reported by David Wigg (wiggjd@sbu.ac.uk). + +#230. (Changed in MR20) Fixed problem with #define for -gd option + + There was an error in setting zzTRACE_RULES for the -gd (trace) option. + + Reported by Gary Funck (gary@intrepid.com). + +#229. (Changed in MR20) Additional "const" for literals + + "const" was added to the token name literal table. + "const" was added to some panic() and similar routine + +#228. (Changed in MR20) dlg crashes on "()" + + The following token defintion will cause DLG to crash. + + #token "()" + + When there is a syntax error in a regular expression + many of the dlg routines return a structure which has + null pointers. When this is accessed by callers it + generates the crash. + + I have attempted to fix the more common cases. + + Reported by Mengue Olivier (dolmen@bigfoot.com). + +#227. (Changed in MR20) Array overwrite + + Steveh Hand (sassth@unx.sas.com) reported a problem which + was traced to a temporary array which was not properly + resized for deeply nested blocks. This has been fixed. + +#226. (Changed in MR20) -pedantic conformance + + G. Hobbelt (i_a@mbh.org) and THM made many, many minor + changes to create prototypes for all the functions and + bring antlr, dlg, and sorcerer into conformance with + the gcc -pedantic option. + + This may require uses to add pccts/h/pcctscfg.h to some + files or makefiles in order to have __USE_PROTOS defined. + +#225 (Changed in MR20) AST stack adjustment in C mode + + The fix in #214 for AST stack adjustment in C mode missed + some cases. + + Reported with fix by Ger Hobbelt (i_a@mbh.org). + +#224 (Changed in MR20) LL(1) and LL(2) with #pragma approx + + This may take a record for the oldest, most trival, lexical + error in pccts. The regular expressions for LL(1) and LL(2) + lacked an escape for the left and right parenthesis. + + Reported by Ger Hobbelt (i_a@mbh.org). + +#223 (Changed in MR20) Addition of IBM_VISUAL_AGE directory + + Build files for antlr, dlg, and sorcerer under IBM Visual Age + have been contributed by Anton Sergeev (ags@mlc.ru). They have + been placed in the pccts/IBM_VISUAL_AGE directory. + +#222 (Changed in MR20) Replace __STDC__ with __USE_PROTOS + + Most occurrences of __STDC__ replaced with __USE_PROTOS due to + complaints from several users. + +#221 (Changed in MR20) Added #include for DLexerBase.h to PBlackBox. + + Added #include for DLexerBase.h to PBlackBox. + +#220 (Changed in MR19) strcat arguments reversed in #pred parse + + The arguments to strcat are reversed when creating a print + name for a hash table entry for use with #pred feature. + + Problem diagnosed and fix reported by Scott Harrington + (seh4@ix.netcom.com). + +#219. (Changed in MR19) C Mode routine zzfree_ast + + Changes to reduce use of recursion for AST trees with only right + links or only left links in the C mode routine zzfree_ast. + + Implemented by SAKAI Kiyotaka (ksakai@isr.co.jp). + +#218. (Changed in MR19) Changes to support unsigned char in C mode + + Changes to antlr.h and err.h to fix omissions in use of zzchar_t + + Implemented by SAKAI Kiyotaka (ksakai@isr.co.jp). + +#217. (Changed in MR19) Error message when dlg -i and -CC options selected + + *** This change was rescinded by item #257 *** + + The parsers generated by pccts in C++ mode are not able to support the + interactive lexer option (except, perhaps, when using the deferred fetch + parser option.(Item #216). + + DLG now warns when both -i and -CC are selected. + + This warning was suggested by David Venditti (07751870267-0001@t-online.de). + +#216. (Changed in MR19) Defer token fetch for C++ mode + + Implemented by Volker H. Simonis (simonis@informatik.uni-tuebingen.de) + + Normally, pccts keeps the lookahead token buffer completely filled. + This requires max(k,ck) tokens of lookahead. For some applications + this can cause deadlock problems. For example, there may be cases + when the parser can't tell when the input has been completely consumed + until the parse is complete, but the parse can't be completed because + the input routines are waiting for additional tokens to fill the + lookahead buffer. + + When the ANTLRParser class is built with the pre-processor option + ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred + until LA(i) or LT(i) is called. + + To test whether this option has been built into the ANTLRParser class + use "isDeferFetchEnabled()". + + Using the -gd trace option with the default tracein() and traceout() + routines will defeat the effort to defer the fetch because the + trace routines print out information about the lookahead token at + the start of the rule. + + Because the tracein and traceout routines are virtual it is + easy to redefine them in your parser: + + class MyParser { + << + virtual void tracein(ANTLRChar * ruleName) + { fprintf(stderr,"Entering: %s\n", ruleName); } + virtual void traceout(ANTLRChar * ruleName) + { fprintf(stderr,"Leaving: %s\n", ruleName); } + >> + + The originals for those routines are pccts/h/AParser.cpp + + This requires use of the dlg option -i (interactive lexer). + + This is experimental. The interaction with guess mode (syntactic + predicates)is not known. + +#215. (Changed in MR19) Addition of reset() to DLGLexerBase + + There was no obvious way to reset the lexer for reuse. The + reset() method now does this. + + Suggested by David Venditti (07751870267-0001@t-online.de). + +#214. (Changed in MR19) C mode: Adjust AST stack pointer at exit + + In C mode the AST stack pointer needs to be reset if there will + be multiple calls to the ANTLRx macros. + + Reported with fix by Paul D. Smith (psmith@baynetworks.com). + +#213. (Changed in MR18) Fatal error with -mrhoistk (k>1 hoisting) + + When rearranging code I forgot to un-comment a critical line of + code that handles hoisting of predicates with k>1 lookahead. This + is now fixed. + + Reported by Reinier van den Born (reinier@vnet.ibm.com). + +#212. (Changed in MR17) Mac related changes by Kenji Tanaka + + Kenji Tanaka (kentar@osa.att.ne.jp) has made a number of changes for + Macintosh users. + + a. The following Macintosh MPW files aid in installing pccts on Mac: + + pccts/MPW_Read_Me + + pccts/install68K.mpw + pccts/installPPC.mpw + + pccts/antlr/antlr.r + pccts/antlr/antlr68K.make + pccts/antlr/antlrPPC.make + + pccts/dlg/dlg.r + pccts/dlg/dlg68K.make + pccts/dlg/dlgPPC.make + + pccts/sorcerer/sor.r + pccts/sorcerer/sor68K.make + pccts/sorcerer/sorPPC.make + + They completely replace the previous Mac installation files. + + b. The most significant is a change in the MAC_FILE_CREATOR symbol + in pcctscfg.h: + + old: #define MAC_FILE_CREATOR 'MMCC' /* Metrowerks C/C++ Text files */ + new: #define MAC_FILE_CREATOR 'CWIE' /* Metrowerks C/C++ Text files */ + + c. Added calls to special_fopen_actions() where necessary. + +#211. (Changed in MR16a) C++ style comment in dlg + + This has been fixed. + +#210. (Changed in MR16a) Sor accepts \r\n, \r, or \n for end-of-line + + A user requested that Sorcerer be changed to accept other forms + of end-of-line. + +#209. (Changed in MR16) Name of files changed. + + Old: CHANGES_FROM_1.33 + New: CHANGES_FROM_133.txt + + Old: KNOWN_PROBLEMS + New: KNOWN_PROBLEMS.txt + +#208. (Changed in MR16) Change in use of pccts #include files + + There were problems with MS DevStudio when mixing Sorcerer and + PCCTS in the same source file. The problem is caused by the + redefinition of setjmp in the MS header file setjmp.h. In + setjmp.h the pre-processor symbol setjmp was redefined to be + _setjmp. A later effort to execute #include resulted + in an effort to #include <_setjmp.h>. I'm not sure whether this + is a bug or a feature. In any case, I decided to fix it by + avoiding the use of pre-processor symbols in #include statements + altogether. This has the added benefit of making pre-compiled + headers work again. + + I've replaced statements: + + old: #include PCCTS_SETJMP_H + new: #include "pccts_setjmp.h" + + Where pccts_setjmp.h contains: + + #ifndef __PCCTS_SETJMP_H__ + #define __PCCTS_SETJMP_H__ + + #ifdef PCCTS_USE_NAMESPACE_STD + #include + #else + #include + #endif + + #endif + + A similar change has been made for other standard header files + required by pccts and sorcerer: stdlib.h, stdarg.h, stdio.h, etc. + + Reported by Jeff Vincent (JVincent@novell.com) and Dale Davis + (DalDavis@spectrace.com). + +#207. (Changed in MR16) dlg reports an invalid range for: [\0x00-\0xff] + + dlg will report that this is an invalid range. + + Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl): + + I think this problem is not specific to unsigned chars + because dlg reports no error for the range [\0x00-\0xfe]. + + I've found that information on range is kept in field + letter (unsigned char) of Attrib struct. Unfortunately + the letter value internally is for some reasons increased + by 1, so \0xff is represented here as 0. + + That's why dlg complains about the range [\0x00-\0xff] in + dlg_p.g: + + if ($$.letter > $2.letter) { + error("invalid range ", zzline); + } + + The fix is: + + if ($$.letter > $2.letter && 255 != $$2.letter) { + error("invalid range ", zzline); + } + +#206. (Changed in MR16) Free zzFAILtext in ANTLRParser destructor + + The ANTLRParser destructor now frees zzFAILtext. + + Problem and fix reported by Manfred Kogler (km@cast.uni-linz.ac.at). + +#205. (Changed in MR16) DLGStringReset argument now const + + Changed: void DLGStringReset(DLGChar *s) {...} + To: void DLGStringReset(const DLGChar *s) {...} + + Suggested by Dale Davis (daldavis@spectrace.com) + +#204. (Changed in MR15a) Change __WATCOM__ to __WATCOMC__ in pcctscfg.h + + Reported by Oleg Dashevskii (olegdash@my-dejanews.com). + +#203. (Changed in MR15) Addition of sorcerer to distribution kit + + I have finally caved in to popular demand. The pccts 1.33mr15 + kit will include sorcerer. The separate sorcerer kit will be + discontinued. + +#202. (Changed) in MR15) Organization of MS Dev Studio Projects in Kit + + Previously there was one workspace that contained projects for + all three parts of pccts: antlr, dlg, and sorcerer. Now each + part (and directory) has its own workspace/project and there + is an additional workspace/project to build a library from the + .cpp files in the pccts/h directory. + + The library build will create pccts_debug.lib or pccts_release.lib + according to the configuration selected. + + If you don't want to build pccts 1.33MR15 you can download a + ready-to-run kit for win32 from http://www.polhode.com/win32.zip. + The ready-to-run for win32 includes executables, a pre-built static + library for the .cpp files in the pccts/h directory, and a sample + application + + You will need to define the environment variable PCCTS to point to + the root of the pccts directory hierarchy. + +#201. (Changed in MR15) Several fixes by K.J. Cummings (cummings@peritus.com) + + Generation of SETJMP rather than SETJMP_H in gen.c. + + (Sor B19) Declaration of ref_vars_inits for ref_var_inits in + pccts/sorcerer/sorcerer.h. + +#200. (Changed in MR15) Remove operator=() in AToken.h + + User reported that WatCom couldn't handle use of + explicit operator =(). Replace with equivalent + using cast operator. + +#199. (Changed in MR15) Don't allow use of empty #tokclass + + Change antlr.g to disallow empty #tokclass sets. + + Reported by Manfred Kogler (km@cast.uni-linz.ac.at). + +#198. Revised ANSI C grammar due to efforts by Manuel Kessler + + Manuel Kessler (mlkessler@cip.physik.uni-wuerzburg.de) + + Allow trailing ... in function parameter lists. + Add bit fields. + Allow old-style function declarations. + Support cv-qualified pointers. + Better checking of combinations of type specifiers. + Release of memory for local symbols on scope exit. + Allow input file name on command line as well as by redirection. + + and other miscellaneous tweaks. + + This is not part of the pccts distribution kit. It must be + downloaded separately from: + + http://www.polhode.com/ansi_mr15.zip + +#197. (Changed in MR14) Resetting the lookahead buffer of the parser + + Explanation and fix by Sinan Karasu (sinan.karasu@boeing.com) + + Consider the code used to prime the lookahead buffer LA(i) + of the parser when init() is called: + + void + ANTLRParser:: + prime_lookahead() + { + int i; + for(i=1;i<=LLk; i++) consume(); + dirty=0; + //lap = 0; // MR14 - Sinan Karasu (sinan.karusu@boeing.com) + //labase = 0; // MR14 + labase=lap; // MR14 + } + + When the parser is instantiated, lap=0,labase=0 is set. + + The "for" loop runs LLk times. In consume(), lap = lap +1 (mod LLk) is + computed. Therefore, lap(before the loop) == lap (after the loop). + + Now the only problem comes in when one does an init() of the parser + after an Eof has been seen. At that time, lap could be non zero. + Assume it was lap==1. Now we do a prime_lookahead(). If LLk is 2, + then + + consume() + { + NLA = inputTokens->getToken()->getType(); + dirty--; + lap = (lap+1)&(LLk-1); + } + + or expanding NLA, + + token_type[lap&(LLk-1)]) = inputTokens->getToken()->getType(); + dirty--; + lap = (lap+1)&(LLk-1); + + so now we prime locations 1 and 2. In prime_lookahead it used to set + lap=0 and labase=0. Now, the next token will be read from location 0, + NOT 1 as it should have been. + + This was never caught before, because if a parser is just instantiated, + then lap and labase are 0, the offending assignment lines are + basically no-ops, since the for loop wraps around back to 0. + +#196. (Changed in MR14) Problems with "(alpha)? beta" guess + + Consider the following syntactic predicate in a grammar + with 2 tokens of lookahead (k=2 or ck=2): + + rule : ( alpha )? beta ; + alpha : S t ; + t : T U + | T + ; + beta : S t Z ; + + When antlr computes the prediction expression with one token + of lookahead for alts 1 and 2 of rule t it finds an ambiguity. + + Because the grammar has a lookahead of 2 it tries to compute + two tokens of lookahead for alts 1 and 2 of t. Alt 1 clearly + has a lookahead of (T U). Alt 2 is one token long so antlr + tries to compute the follow set of alt 2, which means finding + the things which can follow rule t in the context of (alpha)?. + This cannot be computed, because alpha is only part of a rule, + and antlr can't tell what part of beta is matched by alpha and + what part remains to be matched. Thus it impossible for antlr + to properly determine the follow set of rule t. + + Prior to 1.33MR14, the follow of (alpha)? was computed as + FIRST(beta) as a result of the internal representation of + guess blocks. + + With MR14 the follow set will be the empty set for that context. + + Normally, one expects a rule appearing in a guess block to also + appear elsewhere. When the follow context for this other use + is "ored" with the empty set, the context from the other use + results, and a reasonable follow context results. However if + there is *no* other use of the rule, or it is used in a different + manner then the follow context will be inaccurate - it was + inaccurate even before MR14, but it will be inaccurate in a + different way. + + For the example given earlier, a reasonable way to rewrite the + grammar: + + rule : ( alpha )? beta + alpha : S t ; + t : T U + | T + ; + beta : alpha Z ; + + If there are no other uses of the rule appearing in the guess + block it will generate a test for EOF - a workaround for + representing a null set in the lookahead tests. + + If you encounter such a problem you can use the -alpha option + to get additional information: + + line 2: error: not possible to compute follow set for alpha + in an "(alpha)? beta" block. + + With the antlr -alpha command line option the following information + is inserted into the generated file: + + #if 0 + + Trace of references leading to attempt to compute the follow set of + alpha in an "(alpha)? beta" block. It is not possible for antlr to + compute this follow set because it is not known what part of beta has + already been matched by alpha and what part remains to be matched. + + Rules which make use of the incorrect follow set will also be incorrect + + 1 #token T alpha/2 line 7 brief.g + 2 end alpha alpha/3 line 8 brief.g + 2 end (...)? block at start/1 line 2 brief.g + + #endif + + At the moment, with the -alpha option selected the program marks + any rules which appear in the trace back chain (above) as rules with + possible problems computing follow set. + + Reported by Greg Knapen (gregory.knapen@bell.ca). + +#195. (Changed in MR14) #line directive not at column 1 + + Under certain circunstances a predicate test could generate + a #line directive which was not at column 1. + + Reported with fix by David Kågedal (davidk@lysator.liu.se) + (http://www.lysator.liu.se/~davidk/). + +#194. (Changed in MR14) (C Mode only) Demand lookahead with #tokclass + + In C mode with the demand lookahead option there is a bug in the + code which handles matches for #tokclass (zzsetmatch and + zzsetmatch_wsig). + + The bug causes the lookahead pointer to get out of synchronization + with the current token pointer. + + The problem was reported with a fix by Ger Hobbelt (hobbelt@axa.nl). + +#193. (Changed in MR14) Use of PCCTS_USE_NAMESPACE_STD + + The pcctscfg.h now contains the following definitions: + + #ifdef PCCTS_USE_NAMESPACE_STD + #define PCCTS_STDIO_H + #define PCCTS_STDLIB_H + #define PCCTS_STDARG_H + #define PCCTS_SETJMP_H + #define PCCTS_STRING_H + #define PCCTS_ASSERT_H + #define PCCTS_ISTREAM_H + #define PCCTS_IOSTREAM_H + #define PCCTS_NAMESPACE_STD namespace std {}; using namespace std; + #else + #define PCCTS_STDIO_H + #define PCCTS_STDLIB_H + #define PCCTS_STDARG_H + #define PCCTS_SETJMP_H + #define PCCTS_STRING_H + #define PCCTS_ASSERT_H + #define PCCTS_ISTREAM_H + #define PCCTS_IOSTREAM_H + #define PCCTS_NAMESPACE_STD + #endif + + The runtime support in pccts/h uses these pre-processor symbols + consistently. + + Also, antlr and dlg have been changed to generate code which uses + these pre-processor symbols rather than having the names of the + #include files hard-coded in the generated code. + + This required the addition of "#include pcctscfg.h" to a number of + files in pccts/h. + + It appears that this sometimes causes problems for MSVC 5 in + combination with the "automatic" option for pre-compiled headers. + In such cases disable the "automatic" pre-compiled headers option. + + Suggested by Hubert Holin (Hubert.Holin@Bigfoot.com). + +#192. (Changed in MR14) Change setText() to accept "const ANTLRChar *" + + Changed ANTLRToken::setText(ANTLRChar *) to setText(const ANTLRChar *). + This allows literal strings to be used to initialize tokens. Since + the usual token implementation (ANTLRCommonToken) makes a copy of the + input string, this was an unnecessary limitation. + + Suggested by Bob McWhirter (bob@netwrench.com). + +#191. (Changed in MR14) HP/UX aCC compiler compatibility problem + + Needed to explicitly declare zzINF_DEF_TOKEN_BUFFER_SIZE and + zzINF_BUFFER_TOKEN_CHUNK_SIZE as ints in pccts/h/AParser.cpp. + + Reported by David Cook (dcook@bmc.com). + +#190. (Changed in MR14) IBM OS/2 CSet compiler compatibility problem + + Name conflict with "_cs" in pccts/h/ATokenBuffer.cpp + + Reported by David Cook (dcook@bmc.com). + +#189. (Changed in MR14) -gxt switch in C mode + + The -gxt switch in C mode didn't work because of incorrect + initialization. + + Reported by Sinan Karasu (sinan@boeing.com). + +#188. (Changed in MR14) Added pccts/h/DLG_stream_input.h + + This is a DLG stream class based on C++ istreams. + + Contributed by Hubert Holin (Hubert.Holin@Bigfoot.com). + +#187. (Changed in MR14) Rename config.h to pcctscfg.h + + The PCCTS configuration file has been renamed from config.h to + pcctscfg.h. The problem with the original name is that it led + to name collisions when pccts parsers were combined with other + software. + + All of the runtime support routines in pccts/h/* have been + changed to use the new name. Existing software can continue + to use pccts/h/config.h. The contents of pccts/h/config.h is + now just "#include "pcctscfg.h". + + I don't have a record of the user who suggested this. + +#186. (Changed in MR14) Pre-processor symbol DllExportPCCTS class modifier + + Classes in the C++ runtime support routines are now declared: + + class DllExportPCCTS className .... + + By default, the pre-processor symbol is defined as the empty + string. This if for use by MSVC++ users to create DLL classes. + + Suggested by Manfred Kogler (km@cast.uni-linz.ac.at). + +#185. (Changed in MR14) Option to not use PCCTS_AST base class for ASTBase + + Normally, the ASTBase class is derived from PCCTS_AST which contains + functions useful to Sorcerer. If these are not necessary then the + user can define the pre-processor symbol "PCCTS_NOT_USING_SOR" which + will cause the ASTBase class to replace references to PCCTS_AST with + references to ASTBase where necessary. + + The class ASTDoublyLinkedBase will contain a pure virtual function + shallowCopy() that was formerly defined in class PCCTS_AST. + + Suggested by Bob McWhirter (bob@netwrench.com). + +#184. (Changed in MR14) Grammars with no tokens generate invalid tokens.h + + Reported by Hubert Holin (Hubert.Holin@bigfoot.com). + +#183. (Changed in MR14) -f to specify file with names of grammar files + + In DEC/VMS it is difficult to specify very long command lines. + The -f option allows one to place the names of the grammar files + in a data file in order to bypass limitations of the DEC/VMS + command language interpreter. + + Addition supplied by Bernard Giroud (b_giroud@decus.ch). + +#182. (Changed in MR14) Output directory option for DEC/VMS + + Fix some problems with the -o option under DEC/VMS. + + Fix supplied by Bernard Giroud (b_giroud@decus.ch). + +#181. (Changed in MR14) Allow chars > 127 in DLGStringInput::nextChar() + + Changed DLGStringInput to cast the character using (unsigned char) + so that languages with character codes greater than 127 work + without changes. + + Suggested by Manfred Kogler (km@cast.uni-linz.ac.at). + +#180. (Added in MR14) ANTLRParser::getEofToken() + + Added "ANTLRToken ANTLRParser::getEofToken() const" to match the + setEofToken routine. + + Requested by Manfred Kogler (km@cast.uni-linz.ac.at). + +#179. (Fixed in MR14) Memory leak for BufFileInput subclass of DLGInputStream + + The BufFileInput class described in Item #142 neglected to release + the allocated buffer when an instance was destroyed. + + Reported by Manfred Kogler (km@cast.uni-linz.ac.at). + +#178. (Fixed in MR14) Bug in "(alpha)? beta" guess blocks first sets + + In 1.33 vanilla, and all maintenance releases prior to MR14 + there is a bug in the handling of guess blocks which use the + "long" form: + + (alpha)? beta + + inside a (...)*, (...)+, or {...} block. + + This problem does *not* apply to the case where beta is omitted + or when the syntactic predicate is on the leading edge of an + alternative. + + The problem is that both alpha and beta are stored in the + syntax diagram, and that some analysis routines would fail + to skip the alpha portion when it was not on the leading edge. + Consider the following grammar with -ck 2: + + r : ( (A)? B )* C D + + | A B /* forces -ck 2 computation for old antlr */ + /* reports ambig for alts 1 & 2 */ + + | B C /* forces -ck 2 computation for new antlr */ + /* reports ambig for alts 1 & 3 */ + ; + + The prediction expression for the first alternative should be + LA(1)={B C} LA(2)={B C D}, but previous versions of antlr + would compute the prediction expression as LA(1)={A C} LA(2)={B D} + + Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) who provided + a very clear example of the problem and identified the probable cause. + +#177. (Changed in MR14) #tokdefs and #token with regular expression + + In MR13 the change described by Item #162 caused an existing + feature of antlr to fail. Prior to the change it was possible + to give regular expression definitions and actions to tokens + which were defined via the #tokdefs directive. + + This now works again. + + Reported by Manfred Kogler (km@cast.uni-linz.ac.at). + +#176. (Changed in MR14) Support for #line in antlr source code + + Note: this was implemented by Arpad Beszedes (beszedes@inf.u-szeged.hu). + + In 1.33MR14 it is possible for a pre-processor to generate #line + directives in the antlr source and have those line numbers and file + names used in antlr error messages and in the #line directives + generated by antlr. + + The #line directive may appear in the following forms: + + #line ll "sss" xx xx ... + + where ll represents a line number, "sss" represents the name of a file + enclosed in quotation marks, and xxx are arbitrary integers. + + The following form (without "line") is not supported at the moment: + + # ll "sss" xx xx ... + + The result: + + zzline + + is replaced with ll from the # or #line directive + + FileStr[CurFile] + + is updated with the contents of the string (if any) + following the line number + + Note + ---- + The file-name string following the line number can be a complete + name with a directory-path. Antlr generates the output files from + the input file name (by replacing the extension from the file-name + with .c or .cpp). + + If the input file (or the file-name from the line-info) contains + a path: + + "../grammar.g" + + the generated source code will be placed in "../grammar.cpp" (i.e. + in the parent directory). This is inconvenient in some cases + (even the -o switch can not be used) so the path information is + removed from the #line directive. Thus, if the line-info was + + #line 2 "../grammar.g" + + then the current file-name will become "grammar.g" + + In this way, the generated source code according to the grammar file + will always be in the current directory, except when the -o switch + is used. + +#175. (Changed in MR14) Bug when guess block appears at start of (...)* + + In 1.33 vanilla and all maintenance releases prior to 1.33MR14 + there is a bug when a guess block appears at the start of a (...)+. + Consider the following k=1 (ck=1) grammar: + + rule : + ( (STAR)? ZIP )* ID ; + + Prior to 1.33MR14, the generated code resembled: + + ... + zzGUESS_BLOCK + while ( 1 ) { + if ( ! LA(1)==STAR) break; + zzGUESS + if ( !zzrv ) { + zzmatch(STAR); + zzCONSUME; + zzGUESS_DONE + zzmatch(ZIP); + zzCONSUME; + ... + + Note that the routine uses STAR for the prediction expression + rather than ZIP. With 1.33MR14 the generated code resembles: + + ... + while ( 1 ) { + if ( ! LA(1)==ZIP) break; + ... + + This problem existed only with (...)* blocks and was caused + by the slightly more complicate graph which represents (...)* + blocks. This caused the analysis routine to compute the first + set for the alpha part of the "(alpha)? beta" rather than the + beta part. + + Both (...)+ and {...} blocks handled the guess block correctly. + + Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) who provided + a very clear example of the problem and identified the probable cause. + +#174. (Changed in MR14) Bug when action precedes syntactic predicate + + In 1.33 vanilla, and all maintenance releases prior to MR14, + there was a bug when a syntactic predicate was immediately + preceded by an action. Consider the following -ck 2 grammar: + + rule : + <> + (alpha)? beta C + | A B + ; + + alpha : A ; + beta : A B; + + Prior to MR14, the code generated for the first alternative + resembled: + + ... + zzGUESS + if ( !zzrv && LA(1)==A && LA(2)==A) { + alpha(); + zzGUESS_DONE + beta(); + zzmatch(C); + zzCONSUME; + } else { + ... + + The prediction expression (i.e. LA(1)==A && LA(2)==A) is clearly + wrong because LA(2) should be matched to B (first[2] of beta is {B}). + + With 1.33MR14 the prediction expression is: + + ... + if ( !zzrv && LA(1)==A && LA(2)==B) { + alpha(); + zzGUESS_DONE + beta(); + zzmatch(C); + zzCONSUME; + } else { + ... + + This will only affect users in which alpha is shorter than + than max(k,ck) and there is an action immediately preceding + the syntactic predicate. + + This problem was reported by reported by Arpad Beszedes + (beszedes@inf.u-szeged.hu) who provided a very clear example + of the problem and identified the presence of the init-action + as the likely culprit. + +#173. (Changed in MR13a) -glms for Microsoft style filenames with -gl + + With the -gl option antlr generates #line directives using the + exact name of the input files specified on the command line. + An oddity of the Microsoft C and C++ compilers is that they + don't accept file names in #line directives containing "\" + even though these are names from the native file system. + + With -glms option, the "\" in file names appearing in #line + directives is replaced with a "/" in order to conform to + Microsoft compiler requirements. + + Reported by Erwin Achermann (erwin.achermann@switzerland.org). + +#172. (Changed in MR13) \r\n in antlr source counted as one line + + Some MS software uses \r\n to indicate a new line. Antlr + now recognizes this in counting lines. + + Reported by Edward L. Hepler (elh@ece.vill.edu). + +#171. (Changed in MR13) #tokclass L..U now allowed + + The following is now allowed: + + #tokclass ABC { A..B C } + + Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov) + +#170. (Changed in MR13) Suppression for predicates with lookahead depth >1 + + In MR12 the capability for suppression of predicates with lookahead + depth=1 was introduced. With MR13 this had been extended to + predicates with lookahead depth > 1 and released for use by users + on an experimental basis. + + Consider the following grammar with -ck 2 and the predicate in rule + "a" with depth 2: + + r1 : (ab)* "@" + ; + + ab : a + | b + ; + + a : (A B)? => <>? A B C + ; + + b : A B C + ; + + Normally, the predicate would be hoisted into rule r1 in order to + determine whether to call rule "ab". However it should *not* be + hoisted because, even if p is false, there is a valid alternative + in rule b. With "-mrhoistk on" the predicate will be suppressed. + + If "-info p" command line option is present the following information + will appear in the generated code: + + while ( (LA(1)==A) + #if 0 + + Part (or all) of predicate with depth > 1 suppressed by alternative + without predicate + + pred << p(LATEXT(2))>>? + depth=k=2 ("=>" guard) rule a line 8 t1.g + tree context: + (root = A + B + ) + + The token sequence which is suppressed: ( A B ) + The sequence of references which generate that sequence of tokens: + + 1 to ab r1/1 line 1 t1.g + 2 ab ab/1 line 4 t1.g + 3 to b ab/2 line 5 t1.g + 4 b b/1 line 11 t1.g + 5 #token A b/1 line 11 t1.g + 6 #token B b/1 line 11 t1.g + + #endif + + A slightly more complicated example: + + r1 : (ab)* "@" + ; + + ab : a + | b + ; + + a : (A B)? => <>? (A B | D E) + ; + + b : <>? D E + ; + + + In this case, the sequence (D E) in rule "a" which lies behind + the guard is used to suppress the predicate with context (D E) + in rule b. + + while ( (LA(1)==A || LA(1)==D) + #if 0 + + Part (or all) of predicate with depth > 1 suppressed by alternative + without predicate + + pred << q(LATEXT(2))>>? + depth=k=2 rule b line 11 t2.g + tree context: + (root = D + E + ) + + The token sequence which is suppressed: ( D E ) + The sequence of references which generate that sequence of tokens: + + 1 to ab r1/1 line 1 t2.g + 2 ab ab/1 line 4 t2.g + 3 to a ab/1 line 4 t2.g + 4 a a/1 line 8 t2.g + 5 #token D a/1 line 8 t2.g + 6 #token E a/1 line 8 t2.g + + #endif + && + #if 0 + + pred << p(LATEXT(2))>>? + depth=k=2 ("=>" guard) rule a line 8 t2.g + tree context: + (root = A + B + ) + + #endif + + (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) ) { + ab(); + ... + +#169. (Changed in MR13) Predicate test optimization for depth=1 predicates + + When the MR12 generated a test of a predicate which had depth 1 + it would use the depth >1 routines, resulting in correct but + inefficient behavior. In MR13, a bit test is used. + +#168. (Changed in MR13) Token expressions in context guards + + The token expressions appearing in context guards such as: + + (A B)? => <>? someRule + + are computed during an early phase of antlr processing. As + a result, prior to MR13, complex expressions such as: + + ~B + L..U + ~L..U + TokClassName + ~TokClassName + + were not computed properly. This resulted in incorrect + context being computed for such expressions. + + In MR13 these context guards are verified for proper semantics + in the initial phase and then re-evaluated after complex token + expressions have been computed in order to produce the correct + behavior. + + Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu). + +#167. (Changed in MR13) ~L..U + + Prior to MR13, the complement of a token range was + not properly computed. + +#166. (Changed in MR13) token expression L..U + + The token U was represented as an unsigned char, restricting + the use of L..U to cases where U was assigned a token number + less than 256. This is corrected in MR13. + +#165. (Changed in MR13) option -newAST + + To create ASTs from an ANTLRTokenPtr antlr usually calls + "new AST(ANTLRTokenPtr)". This option generates a call + to "newAST(ANTLRTokenPtr)" instead. This allows a user + to define a parser member function to create an AST object. + + Similar changes for ASTBase::tmake and ASTBase::link were not + thought necessary since they do not create AST objects, only + use existing ones. + +#164. (Changed in MR13) Unused variable _astp + + For many compilations, we have lived with warnings about + the unused variable _astp. It turns out that this varible + can *never* be used because the code which references it was + commented out. + + This investigation was sparked by a note from Erwin Achermann + (erwin.achermann@switzerland.org). + +#163. (Changed in MR13) Incorrect makefiles for testcpp examples + + All the examples in pccts/testcpp/* had incorrect definitions + in the makefiles for the symbol "CCC". Instead of CCC=CC they + had CC=$(CCC). + + There was an additional problem in testcpp/1/test.g due to the + change in ANTLRToken::getText() to a const member function + (Item #137). + + Reported by Maurice Mass (maas@cuci.nl). + +#162. (Changed in MR13) Combining #token with #tokdefs + + When it became possible to change the print-name of a + #token (Item #148) it became useful to give a #token + statement whose only purpose was to giving a print name + to the #token. Prior to this change this could not be + combined with the #tokdefs feature. + +#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h + +#160. (Changed in MR13) Omissions in list of names for remap.h + + When a user selects the -gp option antlr creates a list + of macros in remap.h to rename some of the standard + antlr routines from zzXXX to userprefixXXX. + + There were number of omissions from the remap.h name + list related to the new trace facility. This was reported, + along with a fix, by Bernie Solomon (bernard@ug.eds.com). + +#159. (Changed in MR13) Violations of classic C rules + + There were a number of violations of classic C style in + the distribution kit. This was reported, along with fixes, + by Bernie Solomon (bernard@ug.eds.com). + +#158. (Changed in MR13) #header causes problem for pre-processors + + A user who runs the C pre-processor on antlr source suggested + that another syntax be allowed. With MR13 such directives + such as #header, #pragma, etc. may be written as "\#header", + "\#pragma", etc. For escaping pre-processor directives inside + a #header use something like the following: + + \#header + << + \#include + >> + +#157. (Fixed in MR13) empty error sets for rules with infinite recursion + + When the first set for a rule cannot be computed due to infinite + left recursion and it is the only alternative for a block then + the error set for the block would be empty. This would result + in a fatal error. + + Reported by Darin Creason (creason@genedax.com) + +#156. (Changed in MR13) DLGLexerBase::getToken() now public + +#155. (Changed in MR13) Context behind predicates can suppress + + With -mrhoist enabled the context behind a guarded predicate can + be used to suppress other predicates. Consider the following grammar: + + r0 : (r1)+; + + r1 : rp + | rq + ; + rp : <

>? B ; + rq : (A)? => <>? (A|B); + + In earlier versions both predicates "p" and "q" would be hoisted into + rule r0. With MR12c predicate p is suppressed because the context which + follows predicate q includes "B" which can "cover" predicate "p". In + other words, in trying to decide in r0 whether to call r1, it doesn't + really matter whether p is false or true because, either way, there is + a valid choice within r1. + +#154. (Changed in MR13) Making hoist suppression explicit using <> + + A common error, even among experienced pccts users, is to code + an init-action to inhibit hoisting rather than a leading action. + An init-action does not inhibit hoisting. + + This was coded: + + rule1 : <<;>> rule2 + + This is what was meant: + + rule1 : <<;>> <<;>> rule2 + + With MR13, the user can code: + + rule1 : <<;>> <> rule2 + + The following will give an error message: + + rule1 : <> rule2 + + If the <> appears as an init-action rather than a leading + action an error message is issued. The meaning of an init-action + containing "nohoist" is unclear: does it apply to just one + alternative or to all alternatives ? + + + + + + + + + ------------------------------------------------------- + Note: Items #153 to #1 are now in a separate file named + CHANGES_FROM_133_BEFORE_MR13.txt + ------------------------------------------------------- diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt new file mode 100644 index 0000000000..5e2c020964 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_FROM_133_before_mr13.txt @@ -0,0 +1,3666 @@ + + ------------------------------------------------------------ + This is the second part of a two part file. + This is a list of changes to pccts 1.33 prior to MR13 + For more recent information see CHANGES_FROM_133.txt + ------------------------------------------------------------ + + DISCLAIMER + + The software and these notes are provided "as is". They may include + typographical or technical errors and their authors disclaims all + liability of any kind or nature for damages due to error, fault, + defect, or deficiency regardless of cause. All warranties of any + kind, either express or implied, including, but not limited to, the + implied warranties of merchantability and fitness for a particular + purpose are disclaimed. + + +#153. (Changed in MR12b) Bug in computation of -mrhoist suppression set + + Consider the following grammar with k=1 and "-mrhoist on": + + r1 : (A)? => ((p>>? x /* l1 */ + | r2 /* l2 */ + ; + r2 : A /* l4 */ + | (B)? => <>? y /* l5 */ + ; + + In earlier versions the mrhoist routine would see that both l1 and + l2 contained predicates and would assume that this prevented either + from acting to suppress the other predicate. In the example above + it didn't realize the A at line l4 is capable of suppressing the + predicate at l1 even though alt l2 contains (indirectly) a predicate. + + This is fixed in MR12b. + + Reported by Reinier van den Born (reinier@vnet.ibm.com) + +#153. (Changed in MR12a) Bug in computation of -mrhoist suppression set + + An oversight similar to that described in Item #152 appeared in + the computation of the set that "covered" a predicate. If a + predicate expression included a term such as p=AND(q,r) the context + of p was taken to be context(q) & context(r), when it should have + been context(q) | context(r). This is fixed in MR12a. + +#152. (Changed in MR12) Bug in generation of predicate expressions + + The primary purpose for MR12 is to make quite clear that MR11 is + obsolete and to fix the bug related to predicate expressions. + + In MR10 code was added to optimize the code generated for + predicate expression tests. Unfortunately, there was a + significant oversight in the code which resulted in a bug in + the generation of code for predicate expression tests which + contained predicates combined using AND: + + r0 : (r1)* "@" ; + r1 : (AAA)? => <

>? r2 ; + r2 : (BBB)? => <>? Q + | (BBB)? => <>? Q + ; + + In MR11 (and MR10 when using "-mrhoist on") the code generated + for r0 to predict r1 would be equivalent to: + + if ( LA(1)==Q && + (LA(1)==AAA && LA(1)==BBB) && + ( p && ( q || r )) ) { + + This is incorrect because it expresses the idea that LA(1) + *must* be AAA in order to attempt r1, and *must* be BBB to + attempt r2. The result was that r1 became unreachable since + both condition can not be simultaneously true. + + The general philosophy of code generation for predicates + can be summarized as follows: + + a. If the context is true don't enter an alt + for which the corresponding predicate is false. + + If the context is false then it is okay to enter + the alt without evaluating the predicate at all. + + b. A predicate created by ORing of predicates has + context which is the OR of their individual contexts. + + c. A predicate created by ANDing of predicates has + (surprise) context which is the OR of their individual + contexts. + + d. Apply these rules recursively. + + e. Remember rule (a) + + The correct code should express the idea that *if* LA(1) is + AAA then p must be true to attempt r1, but if LA(1) is *not* + AAA then it is okay to attempt r1, provided that *if* LA(1) is + BBB then one of q or r must be true. + + if ( LA(1)==Q && + ( !(LA(1)==AAA || LA(1)==BBB) || + ( ! LA(1) == AAA || p) && + ( ! LA(1) == BBB || q || r ) ) ) { + + I believe this is fixed in MR12. + + Reported by Reinier van den Born (reinier@vnet.ibm.com) + +#151a. (Changed in MR12) ANTLRParser::getLexer() + + As a result of several requests, I have added public methods to + get a pointer to the lexer belonging to a parser. + + ANTLRTokenStream *ANTLRParser::getLexer() const + + Returns a pointer to the lexer being used by the + parser. ANTLRTokenStream is the base class of + DLGLexer + + ANTLRTokenStream *ANTLRTokenBuffer::getLexer() const + + Returns a pointer to the lexer being used by the + ANTLRTokenBuffer. ANTLRTokenStream is the base + class of DLGLexer + + You must manually cast the ANTLRTokenStream to your program's + lexer class. Because the name of the lexer's class is not fixed. + Thus it is impossible to incorporate it into the DLGLexerBase + class. + +#151b.(Changed in MR12) ParserBlackBox member getLexer() + + The template class ParserBlackBox now has a member getLexer() + which returns a pointer to the lexer. + +#150. (Changed in MR12) syntaxErrCount and lexErrCount now public + + See Item #127 for more information. + +#149. (Changed in MR12) antlr option -info o (letter o for orphan) + + If there is more than one rule which is not referenced by any + other rule then all such rules are listed. This is useful for + alerting one to rules which are not used, but which can still + contribute to ambiguity. For example: + + start : a Z ; + unused: a A ; + a : (A)+ ; + + will cause an ambiguity report for rule "a" which will be + difficult to understand if the user forgets about rule "unused" + simply because it is not used in the grammar. + +#148. (Changed in MR11) #token names appearing in zztokens,token_tbl + + In a #token statement like the following: + + #token Plus "\+" + + the string "Plus" appears in the zztokens array (C mode) and + token_tbl (C++ mode). This string is used in most error + messages. In MR11 one has the option of using some other string, + (e.g. "+") in those tables. + + In MR11 one can write: + + #token Plus ("+") "\+" + #token RP ("(") "\(" + #token COM ("comment begin") "/\*" + + A #token statement is allowed to appear in more than one #lexclass + with different regular expressions. However, the token name appears + only once in the zztokens/token_tbl array. This means that only + one substitute can be specified for a given #token name. The second + attempt to define a substitute name (different from the first) will + result in an error message. + +#147. (Changed in MR11) Bug in follow set computation + + There is a bug in 1.33 vanilla and all maintenance releases + prior to MR11 in the computation of the follow set. The bug is + different than that described in Item #82 and probably more + common. It was discovered in the ansi.g grammar while testing + the "ambiguity aid" (Item #119). The search for a bug started + when the ambiguity aid was unable to discover the actual source + of an ambiguity reported by antlr. + + The problem appears when an optimization of the follow set + computation is used inappropriately. The result is that the + follow set used is the "worst case". In other words, the error + can lead to false reports of ambiguity. The good news is that + if you have a grammar in which you have addressed all reported + ambiguities you are ok. The bad news is that you may have spent + time fixing ambiguities that were not real, or used k=2 when + ck=2 might have been sufficient, and so on. + + The following grammar demonstrates the problem: + + ------------------------------------------------------------ + expr : ID ; + + start : stmt SEMI ; + + stmt : CASE expr COLON + | expr SEMI + | plain_stmt + ; + + plain_stmt : ID COLON ; + ------------------------------------------------------------ + + When compiled with k=1 and ck=2 it will report: + + warning: alts 2 and 3 of the rule itself ambiguous upon + { IDENTIFIER }, { COLON } + + When antlr analyzes "stmt" it computes the first[1] set of all + alternatives. It finds an ambiguity between alts 2 and 3 for ID. + It then computes the first[2] set for alternatives 2 and 3 to resolve + the ambiguity. In computing the first[2] set of "expr" (which is + only one token long) it needs to determine what could follow "expr". + Under a certain combination of circumstances antlr forgets that it + is trying to analyze "stmt" which can only be followed by SEMI and + adds to the first[2] set of "expr" the "global" follow set (including + "COLON") which could follow "expr" (under other conditions) in the + phrase "CASE expr COLON". + +#146. (Changed in MR11) Option -treport for locating "difficult" alts + + It can be difficult to determine which alternatives are causing + pccts to work hard to resolve an ambiguity. In some cases the + ambiguity is successfully resolved after much CPU time so there + is no message at all. + + A rough measure of the amount of work being peformed which is + independent of the CPU speed and system load is the number of + tnodes created. Using "-info t" gives information about the + total number of tnodes created and the peak number of tnodes. + + Tree Nodes: peak 1300k created 1416k lost 0 + + It also puts in the generated C or C++ file the number of tnodes + created for a rule (at the end of the rule). However this + information is not sufficient to locate the alternatives within + a rule which are causing the creation of tnodes. + + Using: + + antlr -treport 100000 .... + + causes antlr to list on stdout any alternatives which require the + creation of more than 100,000 tnodes, along with the lookahead sets + for those alternatives. + + The following is a trivial case from the ansi.g grammar which shows + the format of the report. This report might be of more interest + in cases where 1,000,000 tuples were created to resolve the ambiguity. + + ------------------------------------------------------------------------- + There were 0 tuples whose ambiguity could not be resolved + by full lookahead + There were 157 tnodes created to resolve ambiguity between: + + Choice 1: statement/2 line 475 file ansi.g + Choice 2: statement/3 line 476 file ansi.g + + Intersection of lookahead[1] sets: + + IDENTIFIER + + Intersection of lookahead[2] sets: + + LPARENTHESIS COLON AMPERSAND MINUS + STAR PLUSPLUS MINUSMINUS ONESCOMPLEMENT + NOT SIZEOF OCTALINT DECIMALINT + HEXADECIMALINT FLOATONE FLOATTWO IDENTIFIER + STRING CHARACTER + ------------------------------------------------------------------------- + +#145. (Documentation) Generation of Expression Trees + + Item #99 was misleading because it implied that the optimization + for tree expressions was available only for trees created by + predicate expressions and neglected to mention that it required + the use of "-mrhoist on". The optimization applies to tree + expressions created for grammars with k>1 and for predicates with + lookahead depth >1. + + In MR11 the optimized version is always used so the -mrhoist on + option need not be specified. + +#144. (Changed in MR11) Incorrect test for exception group + + In testing for a rule's exception group the label a pointer + is compared against '\0'. The intention is "*pointer". + + Reported by Jeffrey C. Fried (Jeff@Fried.net). + +#143. (Changed in MR11) Optional ";" at end of #token statement + + Fixes problem of: + + #token X "x" + + << + parser action + >> + + Being confused with: + + #token X "x" <> + +#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream + + Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class + BufFileInput derived from DLGInputStream which provides a + function lookahead(char *string) to test characters in the + input stream more than one character ahead. + + The default amount of lookahead is specified by the constructor + and defaults to 8 characters. This does *not* include the one + character of lookahead maintained internally by DLG in member "ch" + and which is not available for testing via BufFileInput::lookahead(). + + This is a useful class for overcoming the one-character-lookahead + limitation of DLG without resorting to a lexer capable of + backtracking (like flex) which is not integrated with antlr as is + DLG. + + There are no restrictions on copying or using BufFileInput.* except + that the authorship and related information must be retained in the + source code. + + The class is located in pccts/h/BufFileInput.* of the kit. + +#141. (Changed in MR11) ZZDEBUG_CONSUME for ANTLRParser::consume() + + A debug aid has been added to file ANTLRParser::consume() in + file AParser.cpp: + + #ifdef ZZDEBUG_CONSUME_ACTION + zzdebug_consume_action(); + #endif + + Suggested by Sramji Ramanathan (ps@kumaran.com). + +#140. (Changed in MR11) #pred to define predicates + + +---------------------------------------------------+ + | Note: Assume "-prc on" for this entire discussion | + +---------------------------------------------------+ + + A problem with predicates is that each one is regarded as + unique and capable of disambiguating cases where two + alternatives have identical lookahead. For example: + + rule : <>? A + | <>? A + ; + + will not cause any error messages or warnings to be issued + by earlier versions of pccts. To compare the text of the + predicates is an incomplete solution. + + In 1.33MR11 I am introducing the #pred statement in order to + solve some problems with predicates. The #pred statement allows + one to give a symbolic name to a "predicate literal" or a + "predicate expression" in order to refer to it in other predicate + expressions or in the rules of the grammar. + + The predicate literal associated with a predicate symbol is C + or C++ code which can be used to test the condition. A + predicate expression defines a predicate symbol in terms of other + predicate symbols using "!", "&&", and "||". A predicate symbol + can be defined in terms of a predicate literal, a predicate + expression, or *both*. + + When a predicate symbol is defined with both a predicate literal + and a predicate expression, the predicate literal is used to generate + code, but the predicate expression is used to check for two + alternatives with identical predicates in both alternatives. + + Here are some examples of #pred statements: + + #pred IsLabel <>? + #pred IsLocalVar <>? + #pred IsGlobalVar <>? + #pred IsVar <>? IsLocalVar || IsGlobalVar + #pred IsScoped <>? IsLabel || IsLocalVar + + I hope that the use of EBNF notation to describe the syntax of the + #pred statement will not cause problems for my readers (joke). + + predStatement : "#pred" + CapitalizedName + ( + "<>?" + | "<>?" predOrExpr + | predOrExpr + ) + ; + + predOrExpr : predAndExpr ( "||" predAndExpr ) * ; + + predAndExpr : predPrimary ( "&&" predPrimary ) * ; + + predPrimary : CapitalizedName + | "!" predPrimary + | "(" predOrExpr ")" + ; + + What is the purpose of this nonsense ? + + To understand how predicate symbols help, you need to realize that + predicate symbols are used in two different ways with two different + goals. + + a. Allow simplification of predicates which have been combined + during predicate hoisting. + + b. Allow recognition of identical predicates which can't disambiguate + alternatives with common lookahead. + + First we will discuss goal (a). Consider the following rule: + + rule0: rule1 + | ID + | ... + ; + + rule1: rule2 + | rule3 + ; + + rule2: <>? ID ; + rule3: <>? ID ; + + When the predicates in rule2 and rule3 are combined by hoisting + to create a prediction expression for rule1 the result is: + + if ( LA(1)==ID + && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ... + + This is inefficient, but more importantly, can lead to false + assumptions that the predicate expression distinguishes the rule1 + alternative with some other alternative with lookahead ID. In + MR11 one can write: + + #pred IsX <>? + + ... + + rule2: <>? ID ; + rule3: <>? ID ; + + During hoisting MR11 recognizes this as a special case and + eliminates the predicates. The result is a prediction + expression like the following: + + if ( LA(1)==ID ) { rule1(); ... + + Please note that the following cases which appear to be equivalent + *cannot* be simplified by MR11 during hoisting because the hoisting + logic only checks for a "!" in the predicate action, not in the + predicate expression for a predicate symbol. + + *Not* equivalent and is not simplified during hoisting: + + #pred IsX <>? + #pred NotX <>? + ... + rule2: <>? ID ; + rule3: <>? ID ; + + *Not* equivalent and is not simplified during hoisting: + + #pred IsX <>? + #pred NotX !IsX + ... + rule2: <>? ID ; + rule3: <>? ID ; + + Now we will discuss goal (b). + + When antlr discovers that there is a lookahead ambiguity between + two alternatives it attempts to resolve the ambiguity by searching + for predicates in both alternatives. In the past any predicate + would do, even if the same one appeared in both alternatives: + + rule: <>? X + | <>? X + ; + + The #pred statement is a start towards solving this problem. + During ambiguity resolution (*not* predicate hoisting) the + predicates for the two alternatives are expanded and compared. + Consider the following example: + + #pred Upper <>? + #pred Lower <>? + #pred Alpha <>? Upper || Lower + + rule0: rule1 + | <>? ID + ; + + rule1: + | rule2 + | rule3 + ... + ; + + rule2: <>? ID; + rule3: <>? ID; + + The definition of #pred Alpha expresses: + + a. to test the predicate use the C code "isAlpha(LATEXT(1))" + + b. to analyze the predicate use the information that + Alpha is equivalent to the union of Upper and Lower, + + During ambiguity resolution the definition of Alpha is expanded + into "Upper || Lower" and compared with the predicate in the other + alternative, which is also "Upper || Lower". Because they are + identical MR11 will report a problem. + + ------------------------------------------------------------------------- + t10.g, line 5: warning: the predicates used to disambiguate rule rule0 + (file t10.g alt 1 line 5 and alt 2 line 6) + are identical when compared without context and may have no + resolving power for some lookahead sequences. + ------------------------------------------------------------------------- + + If you use the "-info p" option the output file will contain: + + +----------------------------------------------------------------------+ + |#if 0 | + | | + |The following predicates are identical when compared without | + | lookahead context information. For some ambiguous lookahead | + | sequences they may not have any power to resolve the ambiguity. | + | | + |Choice 1: rule0/1 alt 1 line 5 file t10.g | + | | + | The original predicate for choice 1 with available context | + | information: | + | | + | OR expr | + | | + | pred << Upper>>? | + | depth=k=1 rule rule2 line 14 t10.g | + | set context: | + | ID | + | | + | pred << Lower>>? | + | depth=k=1 rule rule3 line 15 t10.g | + | set context: | + | ID | + | | + | The predicate for choice 1 after expansion (but without context | + | information): | + | | + | OR expr | + | | + | pred << isUpper(LATEXT(1))>>? | + | depth=k=1 rule line 1 t10.g | + | | + | pred << isLower(LATEXT(1))>>? | + | depth=k=1 rule line 2 t10.g | + | | + | | + |Choice 2: rule0/2 alt 2 line 6 file t10.g | + | | + | The original predicate for choice 2 with available context | + | information: | + | | + | pred << Alpha>>? | + | depth=k=1 rule rule0 line 6 t10.g | + | set context: | + | ID | + | | + | The predicate for choice 2 after expansion (but without context | + | information): | + | | + | OR expr | + | | + | pred << isUpper(LATEXT(1))>>? | + | depth=k=1 rule line 1 t10.g | + | | + | pred << isLower(LATEXT(1))>>? | + | depth=k=1 rule line 2 t10.g | + | | + | | + |#endif | + +----------------------------------------------------------------------+ + + The comparison of the predicates for the two alternatives takes + place without context information, which means that in some cases + the predicates will be considered identical even though they operate + on disjoint lookahead sets. Consider: + + #pred Alpha + + rule1: <>? ID + | <>? Label + ; + + Because the comparison of predicates takes place without context + these will be considered identical. The reason for comparing + without context is that otherwise it would be necessary to re-evaluate + the entire predicate expression for each possible lookahead sequence. + This would require more code to be written and more CPU time during + grammar analysis, and it is not yet clear whether anyone will even make + use of the new #pred facility. + + A temporary workaround might be to use different #pred statements + for predicates you know have different context. This would avoid + extraneous warnings. + + The above example might be termed a "false positive". Comparison + without context will also lead to "false negatives". Consider the + following example: + + #pred Alpha + #pred Beta + + rule1: <>? A + | rule2 + ; + + rule2: <>? A + | <>? B + ; + + The predicate used for alt 2 of rule1 is (Alpha || Beta). This + appears to be different than the predicate Alpha used for alt1. + However, the context of Beta is B. Thus when the lookahead is A + Beta will have no resolving power and Alpha will be used for both + alternatives. Using the same predicate for both alternatives isn't + very helpful, but this will not be detected with 1.33MR11. + + To properly handle this the predicate expression would have to be + evaluated for each distinct lookahead context. + + To determine whether two predicate expressions are identical is + difficult. The routine may fail to identify identical predicates. + + The #pred feature also compares predicates to see if a choice between + alternatives which is resolved by a predicate which makes the second + choice unreachable. Consider the following example: + + #pred A <>? + #pred B <>? + #pred A_or_B A || B + + r : s + | t + ; + s : <>? ID + ; + t : <>? ID + ; + + ---------------------------------------------------------------------------- + t11.g, line 5: warning: the predicate used to disambiguate the + first choice of rule r + (file t11.g alt 1 line 5 and alt 2 line 6) + appears to "cover" the second predicate when compared without context. + The second predicate may have no resolving power for some lookahead + sequences. + ---------------------------------------------------------------------------- + +#139. (Changed in MR11) Problem with -gp in C++ mode + + The -gp option to add a prefix to rule names did not work in + C++ mode. This has been fixed. + + Reported by Alexey Demakov (demakov@kazbek.ispras.ru). + +#138. (Changed in MR11) Additional makefiles for non-MSVC++ MS systems + + Sramji Ramanathan (ps@kumaran.com) has supplied makefiles for + building antlr and dlg with Win95/NT development tools that + are not based on MSVC5. They are pccts/antlr/AntlrMS.mak and + pccts/dlg/DlgMS.mak. + + The first line of the makefiles require a definition of PCCTS_HOME. + + These are in additiion to the AntlrMSVC50.* and DlgMSVC50.* + supplied by Jeff Vincent (JVincent@novell.com). + +#137. (Changed in MR11) Token getType(), getText(), getLine() const members + + -------------------------------------------------------------------- + If you use ANTLRCommonToken this change probably does not affect you. + -------------------------------------------------------------------- + + For a long time it has bothered me that these accessor functions + in ANTLRAbstractToken were not const member functions. I have + refrained from changing them because it require users to modify + existing token class definitions which are derived directly + from ANTLRAbstractToken. I think it is now time. + + For those who are not used to C++, a "const member function" is a + member function which does not modify its own object - the thing + to which "this" points. This is quite different from a function + which does not modify its arguments + + Most token definitions based on ANTLRAbstractToken have something like + the following in order to create concrete definitions of the pure + virtual methods in ANTLRAbstractToken: + + class MyToken : public ANTLRAbstractToken { + ... + ANTLRTokenType getType() {return _type; } + int getLine() {return _line; } + ANTLRChar * getText() {return _text; } + ... + } + + The required change is simply to put "const" following the function + prototype in the header (.h file) and the definition file (.cpp if + it is not inline): + + class MyToken : public ANTLRAbstractToken { + ... + ANTLRTokenType getType() const {return _type; } + int getLine() const {return _line; } + ANTLRChar * getText() const {return _text; } + ... + } + + This was originally proposed a long time ago by Bruce + Guenter (bruceg@qcc.sk.ca). + +#136. (Changed in MR11) Added getLength() to ANTLRCommonToken + + Classes ANTLRCommonToken and ANTLRCommonTokenNoRefCountToken + now have a member function: + + int getLength() const { return strlen(getText()) } + + Suggested by Sramji Ramanathan (ps@kumaran.com). + +#135. (Changed in MR11) Raised antlr's own default ZZLEXBUFSIZE to 8k + +#134a. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible + + There is a typographical error in the definition of BITWISEOREQ: + + #token BITWISEOREQ "!=" should be "\|=" + + When this change is combined with the bugfix to the follow set cache + problem (Item #147) and a minor rearrangement of the grammar + (Item #134b) it becomes a k=1 ck=2 grammar. + +#134b. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible + + The following changes were made in the ansi.g grammar (along with + using -mrhoist on): + + ansi.g + ====== + void tracein(char *) ====> void tracein(const char *) + void traceout(char *) ====> void traceout(const char *) + + getType()==IDENTIFIER ? isTypeName(LT(1)->getText()) : 1>>? + ====> <getText())>>? + + <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \ + isTypeName(LT(2)->getText()) : 1>>? + ====> (LPARENTHESIS IDENTIFIER)? => <getText())>>? + + <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \ + isTypeName(LT(2)->getText()) : 1>>? + ====> (LPARENTHESIS IDENTIFIER)? => <getText())>>? + + added to init(): traceOptionValueDefault=0; + added to init(): traceOption(-1); + + change rule "statement": + + statement + : plain_label_statement + | case_label_statement + | <<;>> expression SEMICOLON + | compound_statement + | selection_statement + | iteration_statement + | jump_statement + | SEMICOLON + ; + + plain_label_statement + : IDENTIFIER COLON statement + ; + + case_label_statement + : CASE constant_expression COLON statement + | DEFAULT COLON statement + ; + + support.cpp + =========== + void tracein(char *) ====> void tracein(const char *) + void traceout(char *) ====> void traceout(const char *) + + added to tracein(): ANTLRParser::tracein(r); // call superclass method + added to traceout(): ANTLRParser::traceout(r); // call superclass method + + Makefile + ======== + added to AFLAGS: -mrhoist on -prc on + +#133. (Changed in 1.33MR11) Make trace options public in ANTLRParser + + In checking T.J. Parr's ANSI C grammar for compatibility with + 1.33MR11 discovered that it was inconvenient to have the + trace facilities with protected access. + +#132. (Changed in 1.33MR11) Recognition of identical predicates in alts + + Prior to 1.33MR11, there would be no ambiguity warning when the + very same predicate was used to disambiguate both alternatives: + + test: ref B + | ref C + ; + + ref : <>? A + + In 1.33MR11 this will cause the warning: + + warning: the predicates used to disambiguate rule test + (file v98.g alt 1 line 1 and alt 2 line 2) + are identical and have no resolving power + + ----------------- Note ----------------- + + This is different than the following case + + test: <>? A B + | <>? A C + ; + + In this case there are two distinct predicates + which have exactly the same text. In the first + example there are two references to the same + predicate. The problem represented by this + grammar will be addressed later. + +#131. (Changed in 1.33MR11) Case insensitive command line options + + Command line switches like "-CC" and keywords like "on", "off", + and "stdin" are no longer case sensitive in antlr, dlg, and sorcerer. + +#130. (Changed in 1.33MR11) Changed ANTLR_VERSION to int from string + + The ANTLR_VERSION was not an integer, making it difficult to + perform conditional compilation based on the antlr version. + + Henceforth, ANTLR_VERSION will be: + + (base_version * 10000) + release number + + thus 1.33MR11 will be: 133*100+11 = 13311 + + Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE). + +#129. (Changed in 1.33MR11) Addition of ANTLR_VERSION to .h + + The following code is now inserted into .h amd + stdpccts.h: + + #ifndef ANTLR_VERSION + #define ANTLR_VERSION 13311 + #endif + + Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE) + +#128. (Changed in 1.33MR11) Redundant predicate code in (<>? ...)+ + + Prior to 1.33MR11, the following grammar would generate + redundant tests for the "while" condition. + + rule2 : (<>? X)+ X + | B + ; + + The code would resemble: + + if (LA(1)==X) { + if (pred) { + do { + if (!pred) {zzfailed_pred(" pred");} + zzmatch(X); zzCONSUME; + } while (LA(1)==X && pred && pred); + } else {... + + With 1.33MR11 the redundant predicate test is omitted. + +#127. (Changed in 1.33MR11) + + Count Syntax Errors Count DLG Errors + ------------------- ---------------- + + C++ mode ANTLRParser:: DLGLexerBase:: + syntaxErrCount lexErrCount + C mode zzSyntaxErrCount zzLexErrCount + + The C mode variables are global and initialized to 0. + They are *not* reset to 0 automatically when antlr is + restarted. + + The C++ mode variables are public. They are initialized + to 0 by the constructors. They are *not* reset to 0 by the + ANTLRParser::init() method. + + Suggested by Reinier van den Born (reinier@vnet.ibm.com). + +#126. (Changed in 1.33MR11) Addition of #first <<...>> + + The #first <<...>> inserts the specified text in the output + files before any other #include statements required by pccts. + The only things before the #first text are comments and + a #define ANTLR_VERSION. + + Requested by and Esa Pulkkinen (esap@cs.tut.fi) and Alexin + Zoltan (alexin@inf.u-szeged.hu). + +#125. (Changed in 1.33MR11) Lookahead for (guard)? && <

>? predicates + + When implementing the new style of guard predicate (Item #113) + in 1.33MR10 I decided to temporarily ignore the problem of + computing the "narrowest" lookahead context. + + Consider the following k=1 grammar: + + start : a + | b + ; + + a : (A)? && <>? ab ; + b : (B)? && <>? ab ; + + ab : A | B ; + + In MR10 the context for both "a" and "b" was {A B} because this is + the first set of rule "ab". Normally, this is not a problem because + the predicate which follows the guard inhibits any ambiguity report + by antlr. + + In MR11 the first set for rule "a" is {A} and for rule "b" it is {B}. + +#124. A Note on the New "&&" Style Guarded Predicates + + I've been asked several times, "What is the difference between + the old "=>" style guard predicates and the new style "&&" guard + predicates, and how do you choose one over the other" ? + + The main difference is that the "=>" does not apply the + predicate if the context guard doesn't match, whereas + the && form always does. What is the significance ? + + If you have a predicate which is not on the "leading edge" + it is cannot be hoisted. Suppose you need a predicate that + looks at LA(2). You must introduce it manually. The + classic example is: + + castExpr : + LP typeName RP + | .... + ; + + typeName : <>? ID + | STRUCT ID + ; + + The problem is that isTypeName() isn't on the leading edge + of typeName, so it won't be hoisted into castExpr to help + make a decision on which production to choose. + + The *first* attempt to fix it is this: + + castExpr : + <>? + LP typeName RP + | .... + ; + + Unfortunately, this won't work because it ignores + the problem of STRUCT. The solution is to apply + isTypeName() in castExpr if LA(2) is an ID and + don't apply it when LA(2) is STRUCT: + + castExpr : + (LP ID)? => <>? + LP typeName RP + | .... + ; + + In conclusion, the "=>" style guarded predicate is + useful when: + + a. the tokens required for the predicate + are not on the leading edge + b. there are alternatives in the expression + selected by the predicate for which the + predicate is inappropriate + + If (b) were false, then one could use a simple + predicate (assuming "-prc on"): + + castExpr : + <>? + LP typeName RP + | .... + ; + + typeName : <>? ID + ; + + So, when do you use the "&&" style guarded predicate ? + + The new-style "&&" predicate should always be used with + predicate context. The context guard is in ADDITION to + the automatically computed context. Thus it useful for + predicates which depend on the token type for reasons + other than context. + + The following example is contributed by Reinier van den Born + (reinier@vnet.ibm.com). + + +-------------------------------------------------------------------------+ + | This grammar has two ways to call functions: | + | | + | - a "standard" call syntax with parens and comma separated args | + | - a shell command like syntax (no parens and spacing separated args) | + | | + | The former also allows a variable to hold the name of the function, | + | the latter can also be used to call external commands. | + | | + | The grammar (simplified) looks like this: | + | | + | fun_call : ID "(" { expr ("," expr)* } ")" | + | /* ID is function name */ | + | | "@" ID "(" { expr ("," expr)* } ")" | + | /* ID is var containing fun name */ | + | ; | + | | + | command : ID expr* /* ID is function name */ | + | | path expr* /* path is external command name */ | + | ; | + | | + | path : ID /* left out slashes and such */ | + | | "@" ID /* ID is environment var */ | + | ; | + | | + | expr : .... | + | | "(" expr ")"; | + | | + | call : fun_call | + | | command | + | ; | + | | + | Obviously the call is wildly ambiguous. This is more or less how this | + | is to be resolved: | + | | + | A call begins with an ID or an @ followed by an ID. | + | | + | If it is an ID and if it is an ext. command name -> command | + | if followed by a paren -> fun_call | + | otherwise -> command | + | | + | If it is an @ and if the ID is a var name -> fun_call | + | otherwise -> command | + | | + | One can implement these rules quite neatly using && predicates: | + | | + | call : ("@" ID)? && <>? fun_call | + | | (ID)? && <>? command | + | | (ID "(")? fun_call | + | | command | + | ; | + | | + | This can be done better, so it is not an ideal example, but it | + | conveys the principle. | + +-------------------------------------------------------------------------+ + +#123. (Changed in 1.33MR11) Correct definition of operators in ATokPtr.h + + The return value of operators in ANTLRTokenPtr: + + changed: unsigned ... operator !=(...) + to: int ... operator != (...) + changed: unsigned ... operator ==(...) + to: int ... operator == (...) + + Suggested by R.A. Nelson (cowboy@VNET.IBM.COM) + +#122. (Changed in 1.33MR11) Member functions to reset DLG in C++ mode + + void DLGFileReset(FILE *f) { input = f; found_eof = 0; } + void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; } + + Supplied by R.A. Nelson (cowboy@VNET.IBM.COM) + +#121. (Changed in 1.33MR11) Another attempt to fix -o (output dir) option + + Another attempt is made to improve the -o option of antlr, dlg, + and sorcerer. This one by JVincent (JVincent@novell.com). + + The current rule: + + a. If -o is not specified than any explicit directory + names are retained. + + b. If -o is specified than the -o directory name overrides any + explicit directory names. + + c. The directory name of the grammar file is *not* stripped + to create the main output file. However it is stil subject + to override by the -o directory name. + +#120. (Changed in 1.33MR11) "-info f" output to stdout rather than stderr + + Added option 0 (e.g. "-info 0") which is a noop. + +#119. (Changed in 1.33MR11) Ambiguity aid for grammars + + The user can ask for additional information on ambiguities reported + by antlr to stdout. At the moment, only one ambiguity report can + be created in an antlr run. + + This feature is enabled using the "-aa" (Ambiguity Aid) option. + + The following options control the reporting of ambiguities: + + -aa ruleName Selects reporting by name of rule + -aa lineNumber Selects reporting by line number + (file name not compared) + + -aam Selects "multiple" reporting for a token + in the intersection set of the + alternatives. + + For instance, the token ID may appear dozens + of times in various paths as the program + explores the rules which are reachable from + the point of an ambiguity. With option -aam + every possible path the search program + encounters is reported. + + Without -aam only the first encounter is + reported. This may result in incomplete + information, but the information may be + sufficient and much shorter. + + -aad depth Selects the depth of the search. + The default value is 1. + + The number of paths to be searched, and the + size of the report can grow geometrically + with the -ck value if a full search for all + contributions to the source of the ambiguity + is explored. + + The depth represents the number of tokens + in the lookahead set which are matched against + the set of ambiguous tokens. A depth of 1 + means that the search stops when a lookahead + sequence of just one token is matched. + + A k=1 ck=6 grammar might generate 5,000 items + in a report if a full depth 6 search is made + with the Ambiguity Aid. The source of the + problem may be in the first token and obscured + by the volume of data - I hesitate to call + it information. + + When the user selects a depth > 1, the search + is first performed at depth=1 for both + alternatives, then depth=2 for both alternatives, + etc. + + Sample output for rule grammar in antlr.g itself: + + +---------------------------------------------------------------------+ + | Ambiguity Aid | + | | + | Choice 1: grammar/70 line 632 file a.g | + | Choice 2: grammar/82 line 644 file a.g | + | | + | Intersection of lookahead[1] sets: | + | | + | "\}" "class" "#errclass" "#tokclass" | + | | + | Choice:1 Depth:1 Group:1 ("#errclass") | + | 1 in (...)* block grammar/70 line 632 a.g | + | 2 to error grammar/73 line 635 a.g | + | 3 error error/1 line 894 a.g | + | 4 #token "#errclass" error/2 line 895 a.g | + | | + | Choice:1 Depth:1 Group:2 ("#tokclass") | + | 2 to tclass grammar/74 line 636 a.g | + | 3 tclass tclass/1 line 937 a.g | + | 4 #token "#tokclass" tclass/2 line 938 a.g | + | | + | Choice:1 Depth:1 Group:3 ("class") | + | 2 to class_def grammar/75 line 637 a.g | + | 3 class_def class_def/1 line 669 a.g | + | 4 #token "class" class_def/3 line 671 a.g | + | | + | Choice:1 Depth:1 Group:4 ("\}") | + | 2 #token "\}" grammar/76 line 638 a.g | + | | + | Choice:2 Depth:1 Group:5 ("#errclass") | + | 1 in (...)* block grammar/83 line 645 a.g | + | 2 to error grammar/93 line 655 a.g | + | 3 error error/1 line 894 a.g | + | 4 #token "#errclass" error/2 line 895 a.g | + | | + | Choice:2 Depth:1 Group:6 ("#tokclass") | + | 2 to tclass grammar/94 line 656 a.g | + | 3 tclass tclass/1 line 937 a.g | + | 4 #token "#tokclass" tclass/2 line 938 a.g | + | | + | Choice:2 Depth:1 Group:7 ("class") | + | 2 to class_def grammar/95 line 657 a.g | + | 3 class_def class_def/1 line 669 a.g | + | 4 #token "class" class_def/3 line 671 a.g | + | | + | Choice:2 Depth:1 Group:8 ("\}") | + | 2 #token "\}" grammar/96 line 658 a.g | + +---------------------------------------------------------------------+ + + For a linear lookahead set ambiguity (where k=1 or for k>1 but + when all lookahead sets [i] with i>? A ; + c : A ; + + Prior to 1.33MR10 the code generated for "start" would resemble: + + while { + if (LA(1)==A && + (!LA(1)==A || isUpper())) { + a(); + } + }; + + This code is wrong because it makes rule "c" unreachable from + "start". The essence of the problem is that antlr fails to + recognize that there can be a valid alternative within "a" even + when the predicate <>? is false. + + In 1.33MR10 with -mrhoist the hoisting of the predicate into + "start" is suppressed because it recognizes that "c" can + cover all the cases where the predicate is false: + + while { + if (LA(1)==A) { + a(); + } + }; + + With the antlr "-info p" switch the user will receive information + about the predicate suppression in the generated file: + + -------------------------------------------------------------- + #if 0 + + Hoisting of predicate suppressed by alternative without predicate. + The alt without the predicate includes all cases where + the predicate is false. + + WITH predicate: line 7 v1.g + WITHOUT predicate: line 7 v1.g + + The context set for the predicate: + + A + + The lookahead set for the alt WITHOUT the semantic predicate: + + A + + The predicate: + + pred << isUpper(LATEXT(1))>>? + depth=k=1 rule b line 9 v1.g + set context: + A + tree context: null + + Chain of referenced rules: + + #0 in rule start (line 5 v1.g) to rule a + #1 in rule a (line 7 v1.g) + + #endif + -------------------------------------------------------------- + + A predicate can be suppressed by a combination of alternatives + which, taken together, cover a predicate: + + start : (a)* "@" ; + + a : b | ca | cb | cc ; + + b : <>? ( A | B | C ) ; + + ca : A ; + cb : B ; + cc : C ; + + Consider a more complex example in which "c" covers only part of + a predicate: + + start : (a)* "@" ; + + a : b + | c + ; + + b : <>? + ( A + | X + ); + + c : A + ; + + Prior to 1.33MR10 the code generated for "start" would resemble: + + while { + if ( (LA(1)==A || LA(1)==X) && + (! (LA(1)==A || LA(1)==X) || isUpper()) { + a(); + } + }; + + With 1.33MR10 and -mrhoist the predicate context is restricted to + the non-covered lookahead. The code resembles: + + while { + if ( (LA(1)==A || LA(1)==X) && + (! (LA(1)==X) || isUpper()) { + a(); + } + }; + + With the antlr "-info p" switch the user will receive information + about the predicate restriction in the generated file: + + -------------------------------------------------------------- + #if 0 + + Restricting the context of a predicate because of overlap + in the lookahead set between the alternative with the + semantic predicate and one without + Without this restriction the alternative without the predicate + could not be reached when input matched the context of the + predicate and the predicate was false. + + WITH predicate: line 11 v4.g + WITHOUT predicate: line 12 v4.g + + The original context set for the predicate: + + A X + + The lookahead set for the alt WITHOUT the semantic predicate: + + A + + The intersection of the two sets + + A + + The original predicate: + + pred << isUpper(LATEXT(1))>>? + depth=k=1 rule b line 15 v4.g + set context: + A X + tree context: null + + The new (modified) form of the predicate: + + pred << isUpper(LATEXT(1))>>? + depth=k=1 rule b line 15 v4.g + set context: + X + tree context: null + + #endif + -------------------------------------------------------------- + + The bad news about -mrhoist: + + (a) -mrhoist does not analyze predicates with lookahead + depth > 1. + + (b) -mrhoist does not look past a guarded predicate to + find context which might cover other predicates. + + For these cases you might want to use syntactic predicates. + When a semantic predicate fails during guess mode the guess + fails and the next alternative is tried. + + Limitation (a) is illustrated by the following example: + + start : (stmt)* EOF ; + + stmt : cast + | expr + ; + cast : <>? LP ID RP ; + + expr : LP ID RP ; + + This is not much different from the first example, except that + it requires two tokens of lookahead context to determine what + to do. This predicate is NOT suppressed because the current version + is unable to handle predicates with depth > 1. + + A predicate can be combined with other predicates during hoisting. + In those cases the depth=1 predicates are still handled. Thus, + in the following example the isUpper() predicate will be suppressed + by line #4 when hoisted from "bizarre" into "start", but will still + be present in "bizarre" in order to predict "stmt". + + start : (bizarre)* EOF ; // #1 + // #2 + bizarre : stmt // #3 + | A // #4 + ; + + stmt : cast + | expr + ; + + cast : <>? LP ID RP ; + + expr : LP ID RP ; + | <>? A + + Limitation (b) is illustrated by the following example of a + context guarded predicate: + + rule : (A)? <

>? // #1 + (A // #2 + |B // #3 + ) // #4 + | <> B // #5 + ; + + Recall that this means that when the lookahead is NOT A then + the predicate "p" is ignored and it attempts to match "A|B". + Ideally, the "B" at line #3 should suppress predicate "q". + However, the current version does not attempt to look past + the guard predicate to find context which might suppress other + predicates. + + In some cases -mrhoist will lead to the reporting of ambiguities + which were not visible before: + + start : (a)* "@"; + a : bc | d; + bc : b | c ; + + b : <>? A; + c : A ; + + d : A ; + + In this case there is a true ambiguity in "a" between "bc" and "d" + which can both match "A". Without -mrhoist the predicate in "b" + is hoisted into "a" and there is no ambiguity reported. However, + with -mrhoist, the predicate in "b" is suppressed by "c" (as it + should be) making the ambiguity in "a" apparent. + + The motivations for these changes were hoisting problems reported + by Reinier van den Born (reinier@vnet.ibm.com) and several others. + +#116. (Changed in 1.33MR10) C++ mode: tracein/traceout rule name is (const char *) + + The prototype for C++ mode routine tracein (and traceout) has changed from + "char *" to "const char *". + +#115. (Changed in 1.33MR10) Using guess mode with exception handlers in C mode + + The definition of the C mode macros zzmatch_wsig and zzsetmatch_wsig + neglected to consider guess mode. When control passed to the rule's + parse exception handler the routine would exit without ever closing the + guess block. This would lead to unpredictable behavior. + + In 1.33MR10 the behavior of exceptions in C mode and C++ mode should be + identical. + +#114. (Changed in 1.33MR10) difference in [zz]resynch() between C and C++ modes + + There was a slight difference in the way C and C++ mode resynchronized + following a parsing error. The C routine would sometimes skip an extra + token before attempting to resynchronize. + + The C routine was changed to match the C++ routine. + +#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <

>? expr + + The existing context guarded predicate: + + rule : (guard)? => <

>? expr + | next_alternative + ; + + generates code which resembles: + + if (lookahead(expr) && (!guard || pred)) { + expr() + } else .... + + This is not suitable for some applications because it allows + expr() to be invoked when the predicate is false. This is + intentional because it is meant to mimic automatically computed + predicate context. + + The new context guarded predicate uses the guard information + differently because it has a different goal. Consider: + + rule : (guard)? && <

>? expr + | next_alternative + ; + + The new style of context guarded predicate is equivalent to: + + rule : <>? expr + | next_alternative + ; + + It generates code which resembles: + + if (lookahead(expr) && guard && pred) { + expr(); + } else ... + + Both forms of guarded predicates severely restrict the form of + the context guard: it can contain no rule references, no + (...)*, no (...)+, and no {...}. It may contain token and + token class references, and alternation ("|"). + + Addition for 1.33MR11: in the token expression all tokens must + be at the same height of the token tree: + + (A ( B | C))? && ... is ok (all height 2) + (A ( B | ))? && ... is not ok (some 1, some 2) + (A B C D | E F G H)? && ... is ok (all height 4) + (A B C D | E )? && ... is not ok (some 4, some 1) + + This restriction is required in order to properly compute the lookahead + set for expressions like: + + rule1 : (A B C)? && <>? rule2 ; + rule2 : (A|X) (B|Y) (C|Z); + + This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com) + +#112. (Changed in 1.33MR10) failed validation predicate in C guess mode + + John Lilley (jlilley@empathy.com) suggested that failed validation + predicates abort a guess rather than reporting a failed error. + This was installed in C++ mode (Item #4). Only now was it noticed + that the fix was never installed for C mode. + +#111. (Changed in 1.33MR10) moved zzTRACEIN to before init action + + When the antlr -gd switch is present antlr generates calls to + zzTRACEIN at the start of a rule and zzTRACEOUT at the exit + from a rule. Prior to 1.33MR10 Tthe call to zzTRACEIN was + after the init-action, which could cause confusion because the + init-actions were reported with the name of the enclosing rule, + rather than the active rule. + +#110. (Changed in 1.33MR10) antlr command line copied to generated file + + The antlr command line is now copied to the generated file near + the start. + +#109. (Changed in 1.33MR10) improved trace information + + The quality of the trace information provided by the "-gd" + switch has been improved significantly. Here is an example + of the output from a test program. It shows the rule name, + the first token of lookahead, the call depth, and the guess + status: + + exit rule gusxx {"?"} depth 2 + enter rule gusxx {"?"} depth 2 + enter rule gus1 {"o"} depth 3 guessing + guess done - returning to rule gus1 {"o"} at depth 3 + (guess mode continues - an enclosing guess is still active) + guess done - returning to rule gus1 {"Z"} at depth 3 + (guess mode continues - an enclosing guess is still active) + exit rule gus1 {"Z"} depth 3 guessing + guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends) + enter rule gus1 {"o"} depth 3 + guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends) + guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends) + exit rule gus1 {"Z"} depth 3 + line 1: syntax error at "Z" missing SC + ... + + Rule trace reporting is controlled by the value of the integer + [zz]traceOptionValue: when it is positive tracing is enabled, + otherwise it is disabled. Tracing during guess mode is controlled + by the value of the integer [zz]traceGuessOptionValue. When + it is positive AND [zz]traceOptionValue is positive rule trace + is reported in guess mode. + + The values of [zz]traceOptionValue and [zz]traceGuessOptionValue + can be adjusted by subroutine calls listed below. + + Depending on the presence or absence of the antlr -gd switch + the variable [zz]traceOptionValueDefault is set to 0 or 1. When + the parser is initialized or [zz]traceReset() is called the + value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue. + The value of [zz]traceGuessOptionValue is always initialzed to 1, + but, as noted earlier, nothing will be reported unless + [zz]traceOptionValue is also positive. + + When the parser state is saved/restored the value of the trace + variables are also saved/restored. If a restore causes a change in + reporting behavior from on to off or vice versa this will be reported. + + When the -gd option is selected, the macro "#define zzTRACE_RULES" + is added to appropriate output files. + + C++ mode + -------- + int traceOption(int delta) + int traceGuessOption(int delta) + void traceReset() + int traceOptionValueDefault + + C mode + -------- + int zzTraceOption(int delta) + int zzTraceGuessOption(int delta) + void zzTraceReset() + int zzTraceOptionValueDefault + + The argument "delta" is added to the traceOptionValue. To + turn on trace when inside a particular rule one: + + rule : <> + ( + rest-of-rule + ) + <> + ; /* fail clause */ <> + + One can use the same idea to turn *off* tracing within a + rule by using a delta of (-1). + + An improvement in the rule trace was suggested by Sramji + Ramanathan (ps@kumaran.com). + +#108. A Note on Deallocation of Variables Allocated in Guess Mode + + NOTE + ------------------------------------------------------ + This mechanism only works for heap allocated variables + ------------------------------------------------------ + + The rewrite of the trace provides the machinery necessary + to properly free variables or undo actions following a + failed guess. + + The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded + as part of the zzGUESS macro. When a guess is opened + the value of zzrv is 0. When a longjmp() is executed to + undo the guess, the value of zzrv will be 1. + + The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded + as part of the zzGUESS_DONE macro. This is executed + whether the guess succeeds or fails as part of closing + the guess. + + The guessSeq is a sequence number which is assigned to each + guess and is incremented by 1 for each guess which becomes + active. It is needed by the user to associate the start of + a guess with the failure and/or completion (closing) of a + guess. + + Guesses are nested. They must be closed in the reverse + of the order that they are opened. + + In order to free memory used by a variable during a guess + a user must write a routine which can be called to + register the variable along with the current guess sequence + number provided by the zzUSER_GUESS_HOOK macro. If the guess + fails, all variables tagged with the corresponding guess + sequence number should be released. This is ugly, but + it would require a major rewrite of antlr 1.33 to use + some mechanism other than setjmp()/longjmp(). + + The order of calls for a *successful* guess would be: + + zzUSER_GUESS_HOOK(guessSeq,0); + zzUSER_GUESS_DONE_HOOK(guessSeq); + + The order of calls for a *failed* guess would be: + + zzUSER_GUESS_HOOK(guessSeq,0); + zzUSER_GUESS_HOOK(guessSeq,1); + zzUSER_GUESS_DONE_HOOK(guessSeq); + + The default definitions of these macros are empty strings. + + Here is an example in C++ mode. The zzUSER_GUESS_HOOK and + zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine + can be used without change in both C and C++ versions. + + ---------------------------------------------------------------------- + << + + #include "AToken.h" + + typedef ANTLRCommonToken ANTLRToken; + + #include "DLGLexer.h" + + int main() { + + { + DLGFileInput in(stdin); + DLGLexer lexer(&in,2000); + ANTLRTokenBuffer pipe(&lexer,1); + ANTLRCommonToken aToken; + P parser(&pipe); + + lexer.setToken(&aToken); + parser.init(); + parser.start(); + }; + + fclose(stdin); + fclose(stdout); + return 0; + } + + >> + + << + char *s=NULL; + + #undef zzUSER_GUESS_HOOK + #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv); + #undef zzUSER_GUESS_DONE_HOOK + #define zzUSER_GUESS_DONE_HOOK(guessSeq) myGuessHook(guessSeq,2); + + void myGuessHook(int guessSeq,int zzrv) { + if (zzrv == 0) { + fprintf(stderr,"User hook: starting guess #%d\n",guessSeq); + } else if (zzrv == 1) { + free (s); + s=NULL; + fprintf(stderr,"User hook: failed guess #%d\n",guessSeq); + } else if (zzrv == 2) { + free (s); + s=NULL; + fprintf(stderr,"User hook: ending guess #%d\n",guessSeq); + }; + } + + >> + + #token A "a" + #token "[\t \ \n]" <> + + class P { + + start : (top)+ + ; + + top : (which) ? <> + | other <> + ; <> + + which : which2 + ; + + which2 : which3 + ; + which3 + : (label)? <> + | (global)? <> + | (exclamation)? <> + ; + + label : <getText());>> A ":" ; + + global : <getText());>> A "::" ; + + exclamation : <getText());>> A "!" ; + + other : <getText());>> "other" ; + + } + ---------------------------------------------------------------------- + + This is a silly example, but illustrates the idea. For the input + "a ::" with tracing enabled the output begins: + + ---------------------------------------------------------------------- + enter rule "start" depth 1 + enter rule "top" depth 2 + User hook: starting guess #1 + enter rule "which" depth 3 guessing + enter rule "which2" depth 4 guessing + enter rule "which3" depth 5 guessing + User hook: starting guess #2 + enter rule "label" depth 6 guessing + guess failed + User hook: failed guess #2 + guess done - returning to rule "which3" at depth 5 (guess mode continues + - an enclosing guess is still active) + User hook: ending guess #2 + User hook: starting guess #3 + enter rule "global" depth 6 guessing + exit rule "global" depth 6 guessing + guess done - returning to rule "which3" at depth 5 (guess mode continues + - an enclosing guess is still active) + User hook: ending guess #3 + enter rule "global" depth 6 guessing + exit rule "global" depth 6 guessing + exit rule "which3" depth 5 guessing + exit rule "which2" depth 4 guessing + exit rule "which" depth 3 guessing + guess done - returning to rule "top" at depth 2 (guess mode ends) + User hook: ending guess #1 + enter rule "which" depth 3 + ..... + ---------------------------------------------------------------------- + + Remember: + + (a) Only init-actions are executed during guess mode. + (b) A rule can be invoked multiple times during guess mode. + (c) If the guess succeeds the rule will be called once more + without guess mode so that normal actions will be executed. + This means that the init-action might need to distinguish + between guess mode and non-guess mode using the variable + [zz]guessing. + +#107. (Changed in 1.33MR10) construction of ASTs in guess mode + + Prior to 1.33MR10, when using automatic AST construction in C++ + mode for a rule, an AST would be constructed for elements of the + rule even while in guess mode. In MR10 this no longer occurs. + +#106. (Changed in 1.33MR10) guess variable confusion + + In C++ mode a guess which failed always restored the parser state + using zzGUESS_DONE as part of zzGUESS_FAIL. Prior to 1.33MR10, + C mode required an explicit call to zzGUESS_DONE after the + call to zzGUESS_FAIL. + + Consider: + + rule : (alpha)? beta + | ... + ; + + The generated code resembles: + + zzGUESS + if (!zzrv && LA(1)==ID) { <==== line #1 + alpha + zzGUESS_DONE + beta + } else { + if (! zzrv) zzGUESS_DONE <==== line #2a + .... + + However, in some cases line #2 was rendered: + + if (guessing) zzGUESS_DONE <==== line #2b + + This would work for simple test cases, but would fail in + some cases where there was a guess while another guess was active. + One kind of failure would be to match up the zzGUESS_DONE at line + #2b with the "outer" guess which was still active. The outer + guess would "succeed" when only the inner guess should have + succeeded. + + In 1.33MR10 the behavior of zzGUESS and zzGUESS_FAIL in C and + and C++ mode should be identical. + + The same problem appears in 1.33 vanilla in some places. For + example: + + start : { (sub)? } ; + + or: + + start : ( + B + | ( sub )? + | C + )+ + ; + + generates incorrect code. + + The general principle is: + + (a) use [zz]guessing only when deciding between a call to zzFAIL + or zzGUESS_FAIL + + (b) use zzrv in all other cases + + This problem was discovered while testing changes to item #105. + I believe this is now fixed. My apologies. + +#105. (Changed in 1.33MR10) guess block as single alt of (...)+ + + Prior to 1.33MR10 the following constructs: + + rule_plus : ( + (sub)? + )+ + ; + + rule_star : ( + (sub)? + )* + ; + + generated incorrect code for the guess block (which could result + in runtime errors) because of an incorrect optimization of a + block with only a single alternative. + + The fix caused some changes to the fix described in Item #49 + because there are now three code generation sequences for (...)+ + blocks containing a guess block: + + a. single alternative which is a guess block + b. multiple alternatives in which the last is a guess block + c. all other cases + + Forms like "rule_star" can have unexpected behavior when there + is a syntax error: if the subrule "sub" is not matched *exactly* + then "rule_star" will consume no tokens. + + Reported by Esa Pulkkinen (esap@cs.tut.fi). + +#104. (Changed in 1.33MR10) -o option for dlg + + There was problem with the code added by item #74 to handle the + -o option of dlg. This should fix it. + +#103. (Changed in 1.33MR10) ANDed semantic predicates + + Rescinded. + + The optimization was a mistake. + The resulting problem is described in Item #150. + +#102. (Changed in 1.33MR10) allow "class parser : .... {" + + The syntax of the class statement ("class parser-name {") + has been extended to allow for the specification of base + classes. An arbirtrary number of tokens may now appear + between the class name and the "{". They are output + again when the class declaration is generated. For + example: + + class Parser : public MyBaseClassANTLRparser { + + This was suggested by a user, but I don't have a record + of who it was. + +#101. (Changed in 1.33MR10) antlr -info command line switch + + -info + + p - extra predicate information in generated file + + t - information about tnode use: + at the end of each rule in generated file + summary on stderr at end of program + + m - monitor progress + prints name of each rule as it is started + flushes output at start of each rule + + f - first/follow set information to stdout + + 0 - no operation (added in 1.33MR11) + + The options may be combined and may appear in any order. + For example: + + antlr -info ptm -CC -gt -mrhoist on mygrammar.g + +#100a. (Changed in 1.33MR10) Predicate tree simplification + + When the same predicates can be referenced in more than one + alternative of a block large predicate trees can be formed. + + The difference that these optimizations make is so dramatic + that I have decided to use it even when -mrhoist is not selected. + + Consider the following grammar: + + start : ( all )* ; + + all : a + | d + | e + | f + ; + + a : c A B + | c A C + ; + + c : <>? + ; + + d : <>? B C + ; + + e : <>? B C + ; + + f : e X Y + ; + + In rule "a" there is a reference to rule "c" in both alternatives. + The length of the predicate AAA is k=2 and it can be followed in + alternative 1 only by (A B) while in alternative 2 it can be + followed only by (A C). Thus they do not have identical context. + + In rule "all" the alternatives which refer to rules "e" and "f" allow + elimination of the duplicate reference to predicate CCC. + + The table below summarized the kind of simplification performed by + 1.33MR10. In the table, X and Y stand for single predicates + (not trees). + + (OR X (OR Y (OR Z))) => (OR X Y Z) + (AND X (AND Y (AND Z))) => (AND X Y Z) + + (OR X (... (OR X Y) ... )) => (OR X (... Y ... )) + (AND X (... (AND X Y) ... )) => (AND X (... Y ... )) + (OR X (... (AND X Y) ... )) => (OR X (... ... )) + (AND X (... (OR X Y) ... )) => (AND X (... ... )) + + (AND X) => X + (OR X) => X + + In a test with a complex grammar for a real application, a predicate + tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)". + + In 1.33MR10 there is a greater effort to release memory used + by predicates once they are no longer in use. + +#100b. (Changed in 1.33MR10) Suppression of extra predicate tests + + The following optimizations require that -mrhoist be selected. + + It is relatively easy to optimize the code generated for predicate + gates when they are of the form: + + (AND X Y Z ...) + or (OR X Y Z ...) + + where X, Y, Z, and "..." represent individual predicates (leaves) not + predicate trees. + + If the predicate is an AND the contexts of the X, Y, Z, etc. are + ANDed together to create a single Tree context for the group and + context tests for the individual predicates are suppressed: + + -------------------------------------------------- + Note: This was incorrect. The contexts should be + ORed together. This has been fixed. A more + complete description is available in item #152. + --------------------------------------------------- + + Optimization 1: (AND X Y Z ...) + + Suppose the context for Xtest is LA(1)==LP and the context for + Ytest is LA(1)==LP && LA(2)==ID. + + Without the optimization the code would resemble: + + if (lookaheadContext && + !(LA(1)==LP && LA(1)==LP && LA(2)==ID) || + ( (! LA(1)==LP || Xtest) && + (! (LA(1)==LP || LA(2)==ID) || Xtest) + )) {... + + With the -mrhoist optimization the code would resemble: + + if (lookaheadContext && + ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {... + + Optimization 2: (OR X Y Z ...) with identical contexts + + Suppose the context for Xtest is LA(1)==ID and for Ytest + the context is also LA(1)==ID. + + Without the optimization the code would resemble: + + if (lookaheadContext && + ! (LA(1)==ID || LA(1)==ID) || + (LA(1)==ID && Xtest) || + (LA(1)==ID && Ytest) {... + + With the -mrhoist optimization the code would resemble: + + if (lookaheadContext && + (! LA(1)==ID) || (Xtest || Ytest) {... + + Optimization 3: (OR X Y Z ...) with distinct contexts + + Suppose the context for Xtest is LA(1)==ID and for Ytest + the context is LA(1)==LP. + + Without the optimization the code would resemble: + + if (lookaheadContext && + ! (LA(1)==ID || LA(1)==LP) || + (LA(1)==ID && Xtest) || + (LA(1)==LP && Ytest) {... + + With the -mrhoist optimization the code would resemble: + + if (lookaheadContext && + (zzpf=0, + (LA(1)==ID && (zzpf=1) && Xtest) || + (LA(1)==LP && (zzpf=1) && Ytest) || + !zzpf) { + + These may appear to be of similar complexity at first, + but the non-optimized version contains two tests of each + context while the optimized version contains only one + such test, as well as eliminating some of the inverted + logic (" !(...) || "). + + Optimization 4: Computation of predicate gate trees + + When generating code for the gates of predicate expressions + antlr 1.33 vanilla uses a recursive procedure to generate + "&&" and "||" expressions for testing the lookahead. As each + layer of the predicate tree is exposed a new set of "&&" and + "||" expressions on the lookahead are generated. In many + cases the lookahead being tested has already been tested. + + With -mrhoist a lookahead tree is computed for the entire + lookahead expression. This means that predicates with identical + context or context which is a subset of another predicate's + context disappear. + + This is especially important for predicates formed by rules + like the following: + + uppperCaseVowel : <>? vowel; + vowel: : <>? LETTERS; + + These predicates are combined using AND since both must be + satisfied for rule upperCaseVowel. They have identical + context which makes this optimization very effective. + + The affect of Items #100a and #100b together can be dramatic. In + a very large (but real world) grammar one particular predicate + expression was reduced from an (unreadable) 50 predicate leaves, + 195 LA(1) terms, and 5500 characters to an (easily comprehensible) + 3 predicate leaves (all different) and a *single* LA(1) term. + +#99. (Changed in 1.33MR10) Code generation for expression trees + + Expression trees are used for k>1 grammars and predicates with + lookahead depth >1. This optimization must be enabled using + "-mrhoist on". (Clarification added for 1.33MR11). + + In the processing of expression trees, antlr can generate long chains + of token comparisons. Prior to 1.33MR10 there were many redundant + parenthesis which caused problems for compilers which could handle + expressions of only limited complexity. For example, to test an + expression tree (root R A B C D), antlr would generate something + resembling: + + (LA(1)==R && (LA(2)==A || (LA(2)==B || (LA(2)==C || LA(2)==D))))) + + If there were twenty tokens to test then there would be twenty + parenthesis at the end of the expression. + + In 1.33MR10 the generated code for tree expressions resembles: + + (LA(1)==R && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D)) + + For "complex" expressions the output is indented to reflect the LA + number being tested: + + (LA(1)==R + && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D + || LA(2)==E || LA(2)==F) + || LA(1)==S + && (LA(2)==G || LA(2)==H)) + + + Suggested by S. Bochnak (S.Bochnak@@microTool.com.pl), + +#98. (Changed in 1.33MR10) Option "-info p" + + When the user selects option "-info p" the program will generate + detailed information about predicates. If the user selects + "-mrhoist on" additional detail will be provided explaining + the promotion and suppression of predicates. The output is part + of the generated file and sandwiched between #if 0/#endif statements. + + Consider the following k=1 grammar: + + start : ( all ) * ; + + all : ( a + | b + ) + ; + + a : c B + ; + + c : <>? + | B + ; + + b : <>? X + ; + + Below is an excerpt of the output for rule "start" for the three + predicate options (off, on, and maintenance release style hoisting). + + For those who do not wish to use the "-mrhoist on" option for code + generation the option can be used in a "diagnostic" mode to provide + valuable information: + + a. where one should insert null actions to inhibit hoisting + b. a chain of rule references which shows where predicates are + being hoisted + + ====================================================================== + Example of "-info p" with "-mrhoist on" + ====================================================================== + #if 0 + + Hoisting of predicate suppressed by alternative without predicate. + The alt without the predicate includes all cases where the + predicate is false. + + WITH predicate: line 11 v36.g + WITHOUT predicate: line 12 v36.g + + The context set for the predicate: + + B + + The lookahead set for alt WITHOUT the semantic predicate: + + B + + The predicate: + + pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g + + set context: + B + tree context: null + + Chain of referenced rules: + + #0 in rule start (line 1 v36.g) to rule all + #1 in rule all (line 3 v36.g) to rule a + #2 in rule a (line 8 v36.g) to rule c + #3 in rule c (line 11 v36.g) + + #endif + && + #if 0 + + pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g + + set context: + X + tree context: null + + #endif + ====================================================================== + Example of "-info p" with the default -prc setting ( "-prc off") + ====================================================================== + #if 0 + + OR + pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g + + set context: + nil + tree context: null + + pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g + + set context: + nil + tree context: null + + #endif + ====================================================================== + Example of "-info p" with "-prc on" and "-mrhoist off" + ====================================================================== + #if 0 + + OR + pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g + + set context: + B + tree context: null + + pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g + + set context: + X + tree context: null + + #endif + ====================================================================== + +#97. (Fixed in 1.33MR10) "Predicate applied for more than one ... " + + In 1.33 vanilla, the grammar listed below produced this message for + the first alternative (only) of rule "b": + + warning: predicate applied for >1 lookahead 1-sequences + [you may only want one lookahead 1-sequence to apply. + Try using a context guard '(...)? =>' + + In 1.33MR10 the message is issued for both alternatives. + + top : (a)*; + a : b | c ; + + b : <>? ( AAA | BBB ) + | <>? ( XXX | YYY ) + ; + + c : AAA | XXX; + +#96. (Fixed in 1.33MR10) Guard predicates ignored when -prc off + + Prior to 1.33MR10, guard predicate code was not generated unless + "-prc on" was selected. + + This was incorrect, since "-prc off" (the default) is supposed to + disable only AUTOMATIC computation of predicate context, not the + programmer specified context supplied by guard predicates. + +#95. (Fixed in 1.33MR10) Predicate guard context length was k, not max(k,ck) + + Prior to 1.33MR10, predicate guards were computed to k tokens rather + than max(k,ck). Consider the following grammar: + + a : ( A B C)? => <>? (A|X) (B|Y) (C|Z) ; + + The code generated by 1.33 vanilla with "-k 1 -ck 3 -prc on" + for the predicate in "a" resembles: + + if ( (! LA(1)==A) || AAA(LATEXT(1))) {... + + With 1.33MR10 and the same options the code resembles: + + if ( (! (LA(1)==A && LA(2)==B && LA(3)==C) || AAA(LATEXT(1))) {... + +#94. (Fixed in 1.33MR10) Predicates followed by rule references + + Prior to 1.33MR10, a semantic predicate which referenced a token + which was off the end of the rule caused an incomplete context + to be computed (with "-prc on") for the predicate under some circum- + stances. In some cases this manifested itself as illegal C code + (e.g. "LA(2)==[Ep](1)" in the k=2 examples below: + + all : ( a ) *; + + a : <>? ID X + | <>? Y + | Z + ; + + This might also occur when the semantic predicate was followed + by a rule reference which was shorter than the length of the + semantic predicate: + + all : ( a ) *; + + a : <>? ID X + | <>? y + | Z + ; + + y : Y ; + + Depending on circumstance, the resulting context might be too + generous because it was too short, or too restrictive because + of missing alternatives. + +#93. (Changed in 1.33MR10) Definition of Purify macro + + Ofer Ben-Ami (gremlin@cs.huji.ac.il) has supplied a definition + for the Purify macro: + + #define PURIFY(r, s) memset((char *) &(r), '\0', (s)); + + Note: This may not be the right thing to do for C++ objects that + have constructors. Reported by Bonny Rais (bonny@werple.net.au). + + For those cases one should #define PURIFY to an empty macro in the + #header or #first actions. + +#92. (Fixed in 1.33MR10) Guarded predicates and hoisting + + When a guarded predicate participates in hoisting it is linked into + a predicate expression tree. Prior to 1.33MR10 this link was never + cleared and the next time the guard was used to construct a new + tree the link could contain a spurious reference to another element + which had previosly been joined to it in the semantic predicate tree. + + For example: + + start : ( all ) *; + all : ( a | b ) ; + + start2 : ( all2 ) *; + all2 : ( a ) ; + + a : (A)? => <>? A ; + b : (B)? => <>? B ; + + Prior to 1.33MR10 the code for "start2" would include a spurious + reference to the BBB predicate which was left from constructing + the predicate tree for rule "start" (i.e. or(AAA,BBB) ). + + In 1.33MR10 this problem is avoided by cloning the original guard + each time it is linked into a predicate tree. + +#91. (Changed in 1.33MR10) Extensive changes to semantic pred hoisting + + ============================================ + This has been rendered obsolete by Item #117 + ============================================ + +#90. (Fixed in 1.33MR10) Semantic pred with LT(i) and i>max(k,ck) + + There is a bug in antlr 1.33 vanilla and all maintenance releases + prior to 1.33MR10 which allows semantic predicates to reference + an LT(i) or LATEXT(i) where i is larger than max(k,ck). When + this occurs antlr will attempt to mark the ith element of an array + in which there are only max(k,ck) elements. The result cannot + be predicted. + + Using LT(i) or LATEXT(i) for i>max(k,ck) is reported as an error + in 1.33MR10. + +#89. Rescinded + +#88. (Fixed in 1.33MR10) Tokens used in semantic predicates in guess mode + + Consider the behavior of a semantic predicate during guess mode: + + rule : a:A ( + <>? b:B + | c:C + ); + + Prior to MR10 the assignment of the token or attribute to + $a did not occur during guess mode, which would cause the + semantic predicate to misbehave because $a would be null. + + In 1.33MR10 a semantic predicate with a reference to an + element label (such as $a) forces the assignment to take + place even in guess mode. + + In order to work, this fix REQUIRES use of the $label format + for token pointers and attributes referenced in semantic + predicates. + + The fix does not apply to semantic predicates using the + numeric form to refer to attributes (e.g. <>?). + The user will receive a warning for this case. + + Reported by Rob Trout (trout@mcs.cs.kent.edu). + +#87. (Fixed in 1.33MR10) Malformed guard predicates + + Context guard predicates may contain only references to + tokens. They may not contain references to (...)+ and + (...)* blocks. This is now checked. This replaces the + fatal error message in item #78 with an appropriate + (non-fatal) error messge. + + In theory, context guards should be allowed to reference + rules. However, I have not had time to fix this. + Evaluation of the guard takes place before all rules have + been read, making it difficult to resolve a forward reference + to rule "zzz" - it hasn't been read yet ! To postpone evaluation + of the guard until all rules have been read is too much + for the moment. + +#86. (Fixed in 1.33MR10) Unequal set size in set_sub + + Routine set_sub() in pccts/support/set/set.h did not work + correctly when the sets were of unequal sizes. Rewrote + set_equ to make it simpler and remove unnecessary and + expensive calls to set_deg(). This routine was not used + in 1.33 vanila. + +#85. (Changed in 1.33MR10) Allow redefinition of MaxNumFiles + + Raised the maximum number of input files to 99 from 20. + Put a #ifndef/#endif around the "#define MaxNumFiles 99". + +#84. (Fixed in 1.33MR10) Initialize zzBadTok in macro zzRULE + + Initialize zzBadTok to NULL in zzRULE macro of AParser.h. + in order to get rid of warning messages. + +#83. (Fixed in 1.33MR10) False warnings with -w2 for #tokclass + + When -w2 is selected antlr gives inappropriate warnings about + #tokclass names not having any associated regular expressions. + Since a #tokclass is not a "real" token it will never have an + associated regular expression and there should be no warning. + + Reported by Derek Pappas (derek.pappas@eng.sun.com) + +#82. (Fixed in 1.33MR10) Computation of follow sets with multiple cycles + + Reinier van den Born (reinier@vnet.ibm.com) reported a problem + in the computation of follow sets by antlr. The problem (bug) + exists in 1.33 vanilla and all maintenance releases prior to 1.33MR10. + + The problem involves the computation of follow sets when there are + cycles - rules which have mutual references. I believe the problem + is restricted to cases where there is more than one cycle AND + elements of those cycles have rules in common. Even when this + occurs it may not affect the code generated - but it might. It + might also lead to undetected ambiguities. + + There were no changes in antlr or dlg output from the revised version. + + The following fragment demonstates the problem by giving different + follow sets (option -pa) for var_access when built with k=1 and ck=2 on + 1.33 vanilla and 1.33MR10: + + echo_statement : ECHO ( echo_expr )* + ; + + echo_expr : ( command )? + | expression + ; + + command : IDENTIFIER + { concat } + ; + + expression : operand ( OPERATOR operand )* + ; + + operand : value + | START command END + ; + + value : concat + | TYPE operand + ; + + concat : var_access { CONCAT value } + ; + + var_access : IDENTIFIER { INDEX } + + ; +#81. (Changed in 1.33MR10) C mode use of attributes and ASTs + + Reported by Isaac Clark (irclark@mindspring.com). + + C mode code ignores attributes returned by rules which are + referenced using element labels when ASTs are enabled (-gt option). + + 1. start : r:rule t:Token <<$start=$r;>> + + The $r refrence will not work when combined with + the -gt option. + + 2. start : t:Token <<$start=$t;>> + + The $t reference works in all cases. + + 3. start : rule <<$0=$1;>> + + Numeric labels work in all cases. + + With MR10 the user will receive an error message for case 1 when + the -gt option is used. + +#80. (Fixed in 1.33MR10) (...)? as last alternative of block + + A construct like the following: + + rule : a + | (b)? + ; + + does not make sense because there is no alternative when + the guess block fails. This is now reported as a warning + to the user. + + Previously, there was a code generation error for this case: + the guess block was not "closed" when the guess failed. + This could cause an infinite loop or other problems. This + is now fixed. + + Example problem: + + #header<< + #include + #include "charptr.h" + >> + + << + #include "charptr.c" + main () + { + ANTLR(start(),stdin); + } + >> + + #token "[\ \t]+" << zzskip(); >> + #token "[\n]" << zzline++; zzskip(); >> + + #token Word "[a-z]+" + #token Number "[0-9]+" + + + start : (test1)? + | (test2)? + ; + test1 : (Word Word Word Word)? + | (Word Word Word Number)? + ; + test2 : (Word Word Number Word)? + | (Word Word Number Number)? + ; + + Test data which caused infinite loop: + + a 1 a a + +#79. (Changed in 1.33MR10) Use of -fh with multiple parsers + + Previously, antlr always used the pre-processor symbol + STDPCCTS_H as a gate for the file stdpccts.h. This + caused problems when there were multiple parsers defined + because they used the same gate symbol. + + In 1.33MR10, the -fh filename is used to generate the + gate file for stdpccts.h. For instance: + + antlr -fh std_parser1.h + + generates the pre-processor symbol "STDPCCTS_std_parser1_H". + + Reported by Ramanathan Santhanam (ps@kumaran.com). + +#78. (Changed in 1.33MR9) Guard predicates that refer to rules + + ------------------------ + Please refer to Item #87 + ------------------------ + + Guard predicates are processed during an early phase + of antlr (during parsing) before all data structures + are completed. + + There is an apparent bug in earlier versions of 1.33 + which caused guard predicates which contained references + to rules (rather than tokens) to reference a structure + which hadn't yet been initialized. + + In some cases (perhaps all cases) references to rules + in guard predicates resulted in the use of "garbage". + +#79. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com) + + Previously, the maximum length file name was set + arbitrarily to 300 characters in antlr, dlg, and sorcerer. + + The config.h file now attempts to define the maximum length + filename using _MAX_PATH from stdlib.h before falling back + to using the value 300. + +#78. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com) + + Put #ifndef/#endif around definition of ZZLEXBUFSIZE in + antlr. + +#77. (Changed in 1.33MR9) Arithmetic overflow for very large grammars + + In routine HandleAmbiguities() antlr attempts to compute the + number of possible elements in a set that is order of + number-of-tokens raised to the number-of-lookahead-tokens power. + For large grammars or large lookahead (e.g. -ck 7) this can + cause arithmetic overflow. + + With 1.33MR9, arithmetic overflow in this computation is reported + the first time it happens. The program continues to run and + the program branches based on the assumption that the computed + value is larger than any number computed by counting actual cases + because 2**31 is larger than the number of bits in most computers. + + Before 1.33MR9 overflow was not reported. The behavior following + overflow is not predictable by anyone but the original author. + + NOTE + + In 1.33MR10 the warning message is suppressed. + The code which detects the overflow allows the + computation to continue without an error. The + error message itself made made users worry. + +#76. (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com) + + Jeff Vincent has convinced me to make ANTLRCommonToken and + ANTLRCommonNoRefCountToken use variable length strings + allocated from the heap rather than fixed length strings. + By suitable definition of setText(), the copy constructor, + and operator =() it is possible to maintain "copy" semantics. + By "copy" semantics I mean that when a token is copied from + an existing token it receives its own, distinct, copy of the + text allocated from the heap rather than simply a pointer + to the original token's text. + + ============================================================ + W * A * R * N * I * N * G + ============================================================ + + It is possible that this may cause problems for some users. + For those users I have included the old version of AToken.h as + pccts/h/AToken_traditional.h. + +#75. (Changed in 1.33MR9) Bruce Guenter (bruceg@qcc.sk.ca) + + Make DLGStringInput const correct. Since this is infrequently + subclassed, it should affect few users, I hope. + +#74. (Changed in 1.33MR9) -o (output directory) option + + Antlr does not properly handle the -o output directory option + when the filename of the grammar contains a directory part. For + example: + + antlr -o outdir pccts_src/myfile.g + + causes antlr create a file called "outdir/pccts_src/myfile.cpp. + It SHOULD create outdir/myfile.cpp + + The suggested code fix has been installed in antlr, dlg, and + Sorcerer. + +#73. (Changed in 1.33MR9) Hoisting of semantic predicates and -mrhoist + + ============================================ + This has been rendered obsolete by Item #117 + ============================================ + +#72. (Changed in 1.33MR9) virtual saveState()/restoreState()/guess_XXX + + The following methods in ANTLRParser were made virtual at + the request of S. Bochnak (S.Bochnak@microTool.com.pl): + + saveState() and restoreState() + guess(), guess_fail(), and guess_done() + +#71. (Changed in 1.33MR9) Access to omitted command line argument + + If a switch requiring arguments is the last thing on the + command line, and the argument is omitted, antlr would core. + + antlr test.g -prc + + instead of + + antlr test.g -prc off + +#70. (Changed in 1.33MR9) Addition of MSVC .dsp and .mak build files + + The following MSVC .dsp and .mak files for pccts and sorcerer + were contributed by Stanislaw Bochnak (S.Bochnak@microTool.com.pl) + and Jeff Vincent (JVincent@novell.com) + + PCCTS Distribution Kit + ---------------------- + pccts/PCCTSMSVC50.dsw + + pccts/antlr/AntlrMSVC50.dsp + pccts/antlr/AntlrMSVC50.mak + + pccts/dlg/DlgMSVC50.dsp + pccts/dlg/DlgMSVC50.mak + + pccts/support/msvc.dsp + + Sorcerer Distribution Kit + ------------------------- + pccts/sorcerer/SorcererMSVC50.dsp + pccts/sorcerer/SorcererMSVC50.mak + + pccts/sorcerer/lib/msvc.dsp + +#69. (Changed in 1.33MR9) Change "unsigned int" to plain "int" + + Declaration of max_token_num in misc.c as "unsigned int" + caused comparison between signed and unsigned ints giving + warning message without any special benefit. + +#68. (Changed in 1.33MR9) Add void return for dlg internal_error() + + Get rid of "no return value" message in internal_error() + in file dlg/support.c and dlg/dlg.h. + +#67. (Changed in Sor) sor.g: lisp() has no return value + + Added a "void" for the return type. + +#66. (Added to Sor) sor.g: ZZLEXBUFSIZE enclosed in #ifndef/#endif + + A user needed to be able to change the ZZLEXBUFSIZE for + sor. Put the definition of ZZLEXBUFSIZE inside #ifndef/#endif + +#65. (Changed in 1.33MR9) PCCTSAST::deepCopy() and ast_dup() bug + + Jeff Vincent (JVincent@novell.com) found that deepCopy() + made new copies of only the direct descendents. No new + copies were made of sibling nodes, Sibling pointers are + set to zero by shallowCopy(). + + PCCTS_AST::deepCopy() has been changed to make a + deep copy in the traditional sense. + + The deepCopy() routine depends on the behavior of + shallowCopy(). In all sor examples I've found, + shallowCopy() zeroes the right and down pointers. + + Original Tree Original deepCopy() Revised deepCopy + ------------- ------------------- ---------------- + a->b->c A A + | | | + d->e->f D D->E->F + | | | + g->h->i G G->H->I + | | + j->k J->K + + While comparing deepCopy() for C++ mode with ast_dup for + C mode I found a problem with ast_dup(). + + Routine ast_dup() has been changed to make a deep copy + in the traditional sense. + + Original Tree Original ast_dup() Revised ast_dup() + ------------- ------------------- ---------------- + a->b->c A->B->C A + | | | + d->e->f D->E->F D->E->F + | | | + g->h->i G->H->I G->H->I + | | | + j->k J->K J->K + + + I believe this affects transform mode sorcerer programs only. + +#64. (Changed in 1.33MR9) anltr/hash.h prototype for killHashTable() + +#63. (Changed in 1.33MR8) h/charptr.h does not zero pointer after free + + The charptr.h routine now zeroes the pointer after free(). + + Reported by Jens Tingleff (jensting@imaginet.fr) + +#62. (Changed in 1.33MR8) ANTLRParser::resynch had static variable + + The static variable "consumed" in ANTLRParser::resynch was + changed into an instance variable of the class with the + name "resynchConsumed". + + Reported by S.Bochnak@microTool.com.pl + +#61. (Changed in 1.33MR8) Using rule>[i,j] when rule has no return values + + Previously, the following code would cause antlr to core when + it tried to generate code for rule1 because rule2 had no return + values ("upward inheritance"): + + rule1 : <> + rule2 > [i,j] + ; + + rule2 : Anything ; + + Reported by S.Bochnak@microTool.com.pl + + Verified correct operation of antlr MR8 when missing or extra + inheritance arguments for all combinations. When there are + missing or extra arguments code will still be generated even + though this might cause the invocation of a subroutine with + the wrong number of arguments. + +#60. (Changed in 1.33MR7) Major changes to exception handling + + There were significant problems in the handling of exceptions + in 1.33 vanilla. The general problem is that it can only + process one level of exception handler. For example, a named + exception handler, an exception handler for an alternative, or + an exception for a subrule always went to the rule's exception + handler if there was no "catch" which matched the exception. + + In 1.33MR7 the exception handlers properly "nest". If an + exception handler does not have a matching "catch" then the + nextmost outer exception handler is checked for an appropriate + "catch" clause, and so on until an exception handler with an + appropriate "catch" is found. + + There are still undesirable features in the way exception + handlers are implemented, but I do not have time to fix them + at the moment: + + The exception handlers for alternatives are outside the + block containing the alternative. This makes it impossible + to access variables declared in a block or to resume the + parse by "falling through". The parse can still be easily + resumed in other ways, but not in the most natural fashion. + + This results in an inconsistentcy between named exception + handlers and exception handlers for alternatives. When + an exception handler for an alternative "falls through" + it goes to the nextmost outer handler - not the "normal + action". + + A major difference between 1.33MR7 and 1.33 vanilla is + the default action after an exception is caught: + + 1.33 Vanilla + ------------ + In 1.33 vanilla the signal value is set to zero ("NoSignal") + and the code drops through to the code following the exception. + For named exception handlers this is the "normal action". + For alternative exception handlers this is the rule's handler. + + 1.33MR7 + ------- + In 1.33MR7 the signal value is NOT automatically set to zero. + + There are two cases: + + For named exception handlers: if the signal value has been + set to zero the code drops through to the "normal action". + + For all other cases the code branches to the nextmost outer + exception handler until it reaches the handler for the rule. + + The following macros have been defined for convenience: + + C/C++ Mode Name + -------------------- + (zz)suppressSignal + set signal & return signal arg to 0 ("NoSignal") + (zz)setSignal(intValue) + set signal & return signal arg to some value + (zz)exportSignal + copy the signal value to the return signal arg + + I'm not sure why PCCTS make a distinction between the local + signal value and the return signal argument, but I'm loathe + to change the code. The burden of copying the local signal + value to the return signal argument can be given to the + default signal handler, I suppose. + +#59. (Changed in 1.33MR7) Prototypes for some functions + + Added prototypes for the following functions to antlr.h + + zzconsumeUntil() + zzconsumeUntilToken() + +#58. (Changed in 1.33MR7) Added defintion of zzbufsize to dlgauto.h + +#57. (Changed in 1.33MR7) Format of #line directive + + Previously, the -gl directive for line 1234 would + resemble: "# 1234 filename.g". This caused problems + for some compilers/pre-processors. In MR7 it generates + "#line 1234 filename.g". + +#56. (Added in 1.33MR7) Jan Mikkelsen + + Move PURIFY macro invocaton to after rule's init action. + +#55. (Fixed in 1.33MR7) Unitialized variables in ANTLRParser + + Member variables inf_labase and inf_last were not initialized. + (See item #50.) + +#54. (Fixed in 1.33MR6) Brad Schick (schick@interacess.com) + + Previously, the following constructs generated the same + code: + + rule1 : (A B C)? + | something-else + ; + + rule2 : (A B C)? () + | something-else + ; + + In all versions of pccts rule1 guesses (A B C) and then + consume all three tokens if the guess succeeds. In MR6 + rule2 guesses (A B C) but consumes NONE of the tokens + when the guess succeeds because "()" matches epsilon. + +#53. (Explanation for 1.33MR6) What happens after an exception is caught ? + + The Book is silent about what happens after an exception + is caught. + + The following code fragment prints "Error Action" followed + by "Normal Action". + + test : Word ex:Number <> + exception[ex] + catch NoViableAlt: + <> + ; + + The reason for "Normal Action" is that the normal flow of the + program after a user-written exception handler is to "drop through". + In the case of an exception handler for a rule this results in + the exection of a "return" statement. In the case of an + exception handler attached to an alternative, rule, or token + this is the code that would have executed had there been no + exception. + + The user can achieve the desired result by using a "return" + statement. + + test : Word ex:Number <> + exception[ex] + catch NoViableAlt: + <> + ; + + The most powerful mechanism for recovery from parse errors + in pccts is syntactic predicates because they provide + backtracking. Exceptions allow "return", "break", + "consumeUntil(...)", "goto _handler", "goto _fail", and + changing the _signal value. + +#52. (Fixed in 1.33MR6) Exceptions without syntactic predicates + + The following generates bad code in 1.33 if no syntactic + predicates are present in the grammar. + + test : Word ex:Number <> + exception[ex] + catch NoViableAlt: + <> + + There is a reference to a guess variable. In C mode + this causes a compiler error. In C++ mode it generates + an extraneous check on member "guessing". + + In MR6 correct code is generated for both C and C++ mode. + +#51. (Added to 1.33MR6) Exception operator "@" used without exceptions + + In MR6 added a warning when the exception operator "@" is + used and no exception group is defined. This is probably + a case where "\@" or "@" is meant. + +#50. (Fixed in 1.33MR6) Gunnar Rxnning (gunnar@candleweb.no) + http://www.candleweb.no/~gunnar/ + + Routines zzsave_antlr_state and zzrestore_antlr_state don't + save and restore all the data needed when switching states. + + Suggested patch applied to antlr.h and err.h for MR6. + +#49. (Fixed in 1.33MR6) Sinan Karasu (sinan@boeing.com) + + Generated code failed to turn off guess mode when leaving a + (...)+ block which contained a guess block. The result was + an infinite loop. For example: + + rule : ( + (x)? + | y + )+ + + Suggested code fix implemented in MR6. Replaced + + ... else if (zzcnt>1) break; + + with: + + C++ mode: + ... else if (zzcnt>1) {if (!zzrv) zzGUESS_DONE; break;}; + C mode: + ... else if (zzcnt>1) {if (zzguessing) zzGUESS_DONE; break;}; + +#48. (Fixed in 1.33MR6) Invalid exception element causes core + + A label attached to an invalid construct can cause + pccts to crash while processing the exception associated + with the label. For example: + + rule : t:(B C) + exception[t] catch MismatchedToken: <> + + Version MR6 generates the message: + + reference in exception handler to undefined label 't' + +#47. (Fixed in 1.33MR6) Manuel Ornato + + Under some circumstances involving a k >1 or ck >1 + grammar and a loop block (i.e. (...)* ) pccts will + fail to detect a syntax error and loop indefinitely. + The problem did not exist in 1.20, but has existed + from 1.23 to the present. + + Fixed in MR6. + + --------------------------------------------------- + Complete test program + --------------------------------------------------- + #header<< + #include + #include "charptr.h" + >> + + << + #include "charptr.c" + main () + { + ANTLR(global(),stdin); + } + >> + + #token "[\ \t]+" << zzskip(); >> + #token "[\n]" << zzline++; zzskip(); >> + + #token B "b" + #token C "c" + #token D "d" + #token E "e" + #token LP "\(" + #token RP "\)" + + #token ANTLREOF "@" + + global : ( + (E liste) + | liste + | listed + ) ANTLREOF + ; + + listeb : LP ( B ( B | C )* ) RP ; + listec : LP ( C ( B | C )* ) RP ; + listed : LP ( D ( B | C )* ) RP ; + liste : ( listeb | listec )* ; + + --------------------------------------------------- + Sample data causing infinite loop + --------------------------------------------------- + e (d c) + --------------------------------------------------- + +#46. (Fixed in 1.33MR6) Robert Richter + (Robert.Richter@infotech.tu-chemnitz.de) + + This item from the list of known problems was + fixed by item #18 (below). + +#45. (Fixed in 1.33MR6) Brad Schick (schick@interaccess.com) + + The dependency scanner in VC++ mistakenly sees a + reference to an MPW #include file even though properly + #ifdef/#endif in config.h. The suggested workaround + has been implemented: + + #ifdef MPW + ..... + #define MPW_CursorCtl_Header + #include MPW_CursorCtl_Header + ..... + #endif + +#44. (Fixed in 1.33MR6) cast malloc() to (char *) in charptr.c + + Added (char *) cast for systems where malloc returns "void *". + +#43. (Added to 1.33MR6) Bruce Guenter (bruceg@qcc.sk.ca) + + Add setLeft() and setUp methods to ASTDoublyLinkedBase + for symmetry with setRight() and setDown() methods. + +#42. (Fixed in 1.33MR6) Jeff Katcher (jkatcher@nortel.ca) + + C++ style comment in antlr.c corrected. + +#41. (Added in 1.33MR6) antlr -stdout + + Using "antlr -stdout ..." forces the text that would + normally go to the grammar.c or grammar.cpp file to + stdout. + +#40. (Added in 1.33MR6) antlr -tab to change tab stops + + Using "antlr -tab number ..." changes the tab stops + for the grammar.c or grammar.cpp file. The number + must be between 0 and 8. Using 0 gives tab characters, + values between 1 and 8 give the appropriate number of + space characters. + +#39. (Fixed in 1.33MR5) Jan Mikkelsen + + Commas in function prototype still not correct under + some circumstances. Suggested code fix installed. + +#38. (Fixed in 1.33MR5) ANTLRTokenBuffer constructor + + Have ANTLRTokenBuffer ctor initialize member "parser" to null. + +#37. (Fixed in 1.33MR4) Bruce Guenter (bruceg@qcc.sk.ca) + + In ANTLRParser::FAIL(int k,...) released memory pointed to by + f[i] (as well as f itself. Should only free f itself. + +#36. (Fixed in 1.33MR3) Cortland D. Starrett (cort@shay.ecn.purdue.edu) + + Neglected to properly declare isDLGmaxToken() when fixing problem + reported by Andreas Magnusson. + + Undo "_retv=NULL;" change which caused problems for return values + from rules whose return values weren't pointers. + + Failed to create bin directory if it didn't exist. + +#35. (Fixed in 1.33MR2) Andreas Magnusson +(Andreas.Magnusson@mailbox.swipnet.se) + + Repair bug introduced by 1.33MR1 for #tokdefs. The original fix + placed "DLGmaxToken=9999" and "DLGminToken=0" in the TokenType enum + in order to fix a problem with an aggresive compiler assigning an 8 + bit enum which might be too narrow. This caused #tokdefs to assume + that there were 9999 real tokens. The repair to the fix causes antlr to + ignore TokenTypes "DLGmaxToken" and "DLGminToken" in a #tokdefs file. + +#34. (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue) + + Previously there was no public function for changing the line + number maintained by the lexer. + +#33. (Fixed in 1.33MR1) Franklin Chen (chen@adi.com) + + Accidental use of EXIT_FAILURE rather than PCCTS_EXIT_FAILURE + in pccts/h/AParser.cpp. + +#32. (Fixed in 1.33MR1) Franklin Chen (chen@adi.com) + + In PCCTSAST.cpp lines 405 and 466: Change + + free (t) + to + free ( (char *)t ); + + to match prototype. + +#31. (Added to 1.33MR1) Pointer to parser in ANTLRTokenBuffer + Pointer to parser in DLGLexerBase + + The ANTLRTokenBuffer class now contains a pointer to the + parser which is using it. This is established by the + ANTLRParser constructor calling ANTLRTokenBuffer:: + setParser(ANTLRParser *p). + + When ANTLRTokenBuffer::setParser(ANTLRParser *p) is + called it saves the pointer to the parser and then + calls ANTLRTokenStream::setParser(ANTLRParser *p) + so that the lexer can also save a pointer to the + parser. + + There is also a function getParser() in each class + with the obvious purpose. + + It is possible that these functions will return NULL + under some circumstances (e.g. a non-DLG lexer is used). + +#30. (Added to 1.33MR1) function tokenName(int token) standard + + The generated parser class now includes the + function: + + static const ANTLRChar * tokenName(int token) + + which returns a pointer to the "name" corresponding + to the token. + + The base class (ANTLRParser) always includes the + member function: + + const ANTLRChar * parserTokenName(int token) + + which can be accessed by objects which have a pointer + to an ANTLRParser, but do not know the name of the + parser class (e.g. ANTLRTokenBuffer and DLGLexerBase). + +#29. (Added to 1.33MR1) Debugging DLG lexers + + If the pre-processor symbol DEBUG_LEXER is defined + then DLexerBase will include code for printing out + key information about tokens which are recognized. + + The debug feature of the lexer is controlled by: + + int previousDebugValue=lexer.debugLexer(newValue); + + a value of 0 disables output + a value of 1 enables output + + Even if the lexer debug code is compiled into DLexerBase + it must be enabled before any output is generated. For + example: + + DLGFileInput in(stdin); + MyDLG lexer(&in,2000); + + lexer.setToken(&aToken); + + #if DEBUG_LEXER + lexer.debugLexer(1); // enable debug information + #endif + +#28. (Added to 1.33MR1) More control over DLG header + + Version 1.33MR1 adds the following directives to PCCTS + for C++ mode: + + #lexprefix <> + + Adds source code to the DLGLexer.h file + after the #include "DLexerBase.h" but + before the start of the class definition. + + #lexmember <> + + Adds source code to the DLGLexer.h file + as part of the DLGLexer class body. It + appears immediately after the start of + the class and a "public: statement. + +#27. (Fixed in 1.33MR1) Comments in DLG actions + + Previously, DLG would not recognize comments as a special case. + Thus, ">>" in the comments would cause errors. This is fixed. + +#26. (Fixed in 1.33MR1) Removed static variables from error routines + + Previously, the existence of statically allocated variables + in some of the parser's member functions posed a danger when + there was more than one parser active. + + Replaced with dynamically allocated/freed variables in 1.33MR1. + +#25. (Fixed in 1.33MR1) Use of string literals in semantic predicates + + Previously, it was not possible to place a string literal in + a semantic predicate because it was not properly "stringized" + for the report of a failed predicate. + +#24. (Fixed in 1.33MR1) Continuation lines for semantic predicates + + Previously, it was not possible to continue semantic + predicates across a line because it was not properly + "stringized" for the report of a failed predicate. + + rule : <>?[ a very + long statement ] + +#23. (Fixed in 1.33MR1) {...} envelope for failed semantic predicates + + Previously, there was a code generation error for failed + semantic predicates: + + rule : <>?[ stmt1; stmt2; ] + + which generated code which resembled: + + if (! xyz()) stmt1; stmt2; + + It now puts the statements in a {...} envelope: + + if (! xyz()) { stmt1; stmt2; }; + +#22. (Fixed in 1.33MR1) Continuation of #token across lines using "\" + + Previously, it was not possible to continue a #token regular + expression across a line. The trailing "\" and newline caused + a newline to be inserted into the regular expression by DLG. + + Fixed in 1.33MR1. + +#21. (Fixed in 1.33MR1) Use of ">>" (right shift operator in DLG actions + + It is now possible to use the C++ right shift operator ">>" + in DLG actions by using the normal escapes: + + #token "shift-right" << value=value \>\> 1;>> + +#20. (Version 1.33/19-Jan-97 Karl Eccleson + P.A. Keller (P.A.Keller@bath.ac.uk) + + There is a problem due to using exceptions with the -gh option. + + Suggested fix now in 1.33MR1. + +#19. (Fixed in 1.33MR1) Tom Piscotti and John Lilley + + There were problems suppressing messages to stdin and stdout + when running in a window environment because some functions + which uses fprint were not virtual. + + Suggested change now in 1.33MR1. + + I believe all functions containing error messages (excluding those + indicating internal inconsistency) have been placed in functions + which are virtual. + +#18. (Version 1.33/ 22-Nov-96) John Bair (jbair@iftime.com) + + Under some combination of options a required "return _retv" is + not generated. + + Suggested fix now in 1.33MR1. + +#17. (Version 1.33/3-Sep-96) Ron House (house@helios.usq.edu.au) + + The routine ASTBase::predorder_action omits two "tree->" + prefixes, which results in the preorder_action belonging + to the wrong node to be invoked. + + Suggested fix now in 1.33MR1. + +#16. (Version 1.33/7-Jun-96) Eli Sternheim + + Routine consumeUntilToken() does not check for end-of-file + condition. + + Suggested fix now in 1.33MR1. + +#15. (Version 1.33/8 Apr 96) Asgeir Olafsson + + Problem with tree duplication of doubly linked ASTs in ASTBase.cpp. + + Suggested fix now in 1.33MR1. + +#14. (Version 1.33/28-Feb-96) Andreas.Magnusson@mailbox.swipnet.se + + Problem with definition of operator = (const ANTLRTokenPtr rhs). + + Suggested fix now in 1.33MR1. + +#13. (Version 1.33/13-Feb-96) Franklin Chen (chen@adi.com) + + Sun C++ Compiler 3.0.1 can't compile testcpp/1 due to goto in + block with destructors. + + Apparently fixed. Can't locate "goto". + +#12. (Version 1.33/10-Nov-95) Minor problems with 1.33 code + + The following items have been fixed in 1.33MR1: + + 1. pccts/antlr/main.c line 142 + + "void" appears in classic C code + + 2. no makefile in support/genmk + + 3. EXIT_FAILURE/_SUCCESS instead of PCCTS_EXIT_FAILURE/_SUCCESS + + pccts/h/PCCTSAST.cpp + pccts/h/DLexerBase.cpp + pccts/testcpp/6/test.g + + 4. use of "signed int" isn't accepted by AT&T cfront + + pccts/h/PCCTSAST.h line 42 + + 5. in call to ANTLRParser::FAIL the var arg err_k is passed as + "int" but is declared "unsigned int". + + 6. I believe that a failed validation predicate still does not + get put in a "{...}" envelope, despite the release notes. + + 7. The #token ">>" appearing in the DLG grammar description + causes DLG to generate the string literal "\>\>" which + is non-conforming and will cause some compilers to + complain (scan.c function act10 line 143 of source code). + +#11. (Version 1.32b6) Dave Kuhlman (dkuhlman@netcom.com) + + Problem with file close in gen.c. Already fixed in 1.33. + +#10. (Version 1.32b6/29-Aug-95) + + pccts/antlr/main.c contains a C++ style comments on lines 149 + and 176 which causes problems for most C compilers. + + Already fixed in 1.33. + +#9. (Version 1.32b4/14-Mar-95) dlgauto.h #include "config.h" + + The file pccts/h/dlgauto.h should probably contain a #include + "config.h" as it uses the #define symbol __USE_PROTOS. + + Added to 1.33MR1. + +#8. (Version 1.32b4/6-Mar-95) Michael T. Richter (mtr@igs.net) + + In C++ output mode anonymous tokens from in-line regular expressions + can create enum values which are too wide for the datatype of the enum + assigned by the C++ compiler. + + Fixed in 1.33MR1. + +#7. (Version 1.32b4/6-Mar-95) C++ does not imply __STDC__ + + In err.h the combination of # directives assumes that a C++ + compiler has __STDC__ defined. This is not necessarily true. + + This problem also appears in the use of __USE_PROTOS which + is appropriate for both Standard C and C++ in antlr/gen.c + and antlr/lex.c + + Fixed in 1.33MR1. + +#6. (Version 1.32 ?/15-Feb-95) Name conflict for "TokenType" + + Already fixed in 1.33. + +#5. (23-Jan-95) Douglas_Cuthbertson.JTIDS@jtids_qmail.hanscom.af.mil + + The fail action following a semantic predicate is not enclosed in + "{...}". This can lead to problems when the fail action contains + more than one statement. + + Fixed in 1.33MR1. + +#4 . (Version 1.33/31-Mar-96) jlilley@empathy.com (John Lilley) + + Put briefly, a semantic predicate ought to abort a guess if it fails. + + Correction suggested by J. Lilley has been added to 1.33MR1. + +#3 . (Version 1.33) P.A.Keller@bath.ac.uk + + Extra commas are placed in the K&R style argument list for rules + when using both exceptions and ASTs. + + Fixed in 1.33MR1. + +#2. (Version 1.32b6/2-Oct-95) Brad Schick + + Construct #[] generates zzastnew() in C++ mode. + + Already fixed in 1.33. + +#1. (Version 1.33) Bob Bailey (robert@oakhill.sps.mot.com) + + Previously, config.h assumed that all PC systems required + "short" file names. The user can now override that + assumption with "#define LONGFILENAMES". + + Added to 1.33MR1. diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt new file mode 100644 index 0000000000..91defae169 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/CHANGES_SUMMARY.txt @@ -0,0 +1,2049 @@ +====================================================================== + + CHANGES_SUMMARY.TXT + + A QUICK overview of changes from 1.33 in reverse order + + A summary of additions rather than bug fixes and minor code changes. + + Numbers refer to items in CHANGES_FROM_133*.TXT + which may contain additional information. + + DISCLAIMER + + The software and these notes are provided "as is". They may include + typographical or technical errors and their authors disclaims all + liability of any kind or nature for damages due to error, fault, + defect, or deficiency regardless of cause. All warranties of any + kind, either express or implied, including, but not limited to, the + implied warranties of merchantability and fitness for a particular + purpose are disclaimed. + +====================================================================== + +#258. You can specify a user-defined base class for your parser + + The base class must constructor must have a signature similar to + that of ANTLRParser. + +#253. Generation of block preamble (-preamble and -preamble_first) + + The antlr option -preamble causes antlr to insert the code + BLOCK_PREAMBLE at the start of each rule and block. + + The antlr option -preamble_first is similar, but inserts the + code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol + PreambleFirst_123 is equivalent to the first set defined by + the #FirstSetSymbol described in Item #248. + +#248. Generate symbol for first set of an alternative + + rr : #FirstSetSymbol(rr_FirstSet) ( Foo | Bar ) ; + +#216. Defer token fetch for C++ mode + + When the ANTLRParser class is built with the pre-processor option + ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred + until LA(i) or LT(i) is called. + +#215. Use reset() to reset DLGLexerBase +#188. Added pccts/h/DLG_stream_input.h +#180. Added ANTLRParser::getEofToken() +#173. -glms for Microsoft style filenames with -gl +#170. Suppression for predicates with lookahead depth >1 + + Consider the following grammar with -ck 2 and the predicate in rule + "a" with depth 2: + + r1 : (ab)* "@" + ; + + ab : a + | b + ; + + a : (A B)? => <>? A B C + ; + + b : A B C + ; + + Normally, the predicate would be hoisted into rule r1 in order to + determine whether to call rule "ab". However it should *not* be + hoisted because, even if p is false, there is a valid alternative + in rule b. With "-mrhoistk on" the predicate will be suppressed. + + If "-info p" command line option is present the following information + will appear in the generated code: + + while ( (LA(1)==A) + #if 0 + + Part (or all) of predicate with depth > 1 suppressed by alternative + without predicate + + pred << p(LATEXT(2))>>? + depth=k=2 ("=>" guard) rule a line 8 t1.g + tree context: + (root = A + B + ) + + The token sequence which is suppressed: ( A B ) + The sequence of references which generate that sequence of tokens: + + 1 to ab r1/1 line 1 t1.g + 2 ab ab/1 line 4 t1.g + 3 to b ab/2 line 5 t1.g + 4 b b/1 line 11 t1.g + 5 #token A b/1 line 11 t1.g + 6 #token B b/1 line 11 t1.g + + #endif + + A slightly more complicated example: + + r1 : (ab)* "@" + ; + + ab : a + | b + ; + + a : (A B)? => <>? (A B | D E) + ; + + b : <>? D E + ; + + + In this case, the sequence (D E) in rule "a" which lies behind + the guard is used to suppress the predicate with context (D E) + in rule b. + + while ( (LA(1)==A || LA(1)==D) + #if 0 + + Part (or all) of predicate with depth > 1 suppressed by alternative + without predicate + + pred << q(LATEXT(2))>>? + depth=k=2 rule b line 11 t2.g + tree context: + (root = D + E + ) + + The token sequence which is suppressed: ( D E ) + The sequence of references which generate that sequence of tokens: + + 1 to ab r1/1 line 1 t2.g + 2 ab ab/1 line 4 t2.g + 3 to a ab/1 line 4 t2.g + 4 a a/1 line 8 t2.g + 5 #token D a/1 line 8 t2.g + 6 #token E a/1 line 8 t2.g + + #endif + && + #if 0 + + pred << p(LATEXT(2))>>? + depth=k=2 ("=>" guard) rule a line 8 t2.g + tree context: + (root = A + B + ) + + #endif + + (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) ) { + ab(); + ... + +#165. (Changed in MR13) option -newAST + + To create ASTs from an ANTLRTokenPtr antlr usually calls + "new AST(ANTLRTokenPtr)". This option generates a call + to "newAST(ANTLRTokenPtr)" instead. This allows a user + to define a parser member function to create an AST object. + +#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h + +#158. (Changed in MR13) #header causes problem for pre-processors + + A user who runs the C pre-processor on antlr source suggested + that another syntax be allowed. With MR13 such directives + such as #header, #pragma, etc. may be written as "\#header", + "\#pragma", etc. For escaping pre-processor directives inside + a #header use something like the following: + + \#header + << + \#include + >> + +#155. (Changed in MR13) Context behind predicates can suppress + + With -mrhoist enabled the context behind a guarded predicate can + be used to suppress other predicates. Consider the following grammar: + + r0 : (r1)+; + + r1 : rp + | rq + ; + rp : <

>? B ; + rq : (A)? => <>? (A|B); + + In earlier versions both predicates "p" and "q" would be hoisted into + rule r0. With MR12c predicate p is suppressed because the context which + follows predicate q includes "B" which can "cover" predicate "p". In + other words, in trying to decide in r0 whether to call r1, it doesn't + really matter whether p is false or true because, either way, there is + a valid choice within r1. + +#154. (Changed in MR13) Making hoist suppression explicit using <> + + A common error, even among experienced pccts users, is to code + an init-action to inhibit hoisting rather than a leading action. + An init-action does not inhibit hoisting. + + This was coded: + + rule1 : <<;>> rule2 + + This is what was meant: + + rule1 : <<;>> <<;>> rule2 + + With MR13, the user can code: + + rule1 : <<;>> <> rule2 + + The following will give an error message: + + rule1 : <> rule2 + + If the <> appears as an init-action rather than a leading + action an error message is issued. The meaning of an init-action + containing "nohoist" is unclear: does it apply to just one + alternative or to all alternatives ? + +#151a. Addition of ANTLRParser::getLexer(), ANTLRTokenStream::getLexer() + + You must manually cast the ANTLRTokenStream to your program's + lexer class. Because the name of the lexer's class is not fixed. + Thus it is impossible to incorporate it into the DLGLexerBase + class. + +#151b.(Changed in MR12) ParserBlackBox member getLexer() + +#150. (Changed in MR12) syntaxErrCount and lexErrCount now public + +#149. (Changed in MR12) antlr option -info o (letter o for orphan) + + If there is more than one rule which is not referenced by any + other rule then all such rules are listed. This is useful for + alerting one to rules which are not used, but which can still + contribute to ambiguity. + +#148. (Changed in MR11) #token names appearing in zztokens,token_tbl + + One can write: + + #token Plus ("+") "\+" + #token RP ("(") "\(" + #token COM ("comment begin") "/\*" + + The string in parenthesis will be used in syntax error messages. + +#146. (Changed in MR11) Option -treport for locating "difficult" alts + + It can be difficult to determine which alternatives are causing + pccts to work hard to resolve an ambiguity. In some cases the + ambiguity is successfully resolved after much CPU time so there + is no message at all. + + A rough measure of the amount of work being peformed which is + independent of the CPU speed and system load is the number of + tnodes created. Using "-info t" gives information about the + total number of tnodes created and the peak number of tnodes. + + Tree Nodes: peak 1300k created 1416k lost 0 + + It also puts in the generated C or C++ file the number of tnodes + created for a rule (at the end of the rule). However this + information is not sufficient to locate the alternatives within + a rule which are causing the creation of tnodes. + + Using: + + antlr -treport 100000 .... + + causes antlr to list on stdout any alternatives which require the + creation of more than 100,000 tnodes, along with the lookahead sets + for those alternatives. + + The following is a trivial case from the ansi.g grammar which shows + the format of the report. This report might be of more interest + in cases where 1,000,000 tuples were created to resolve the ambiguity. + + ------------------------------------------------------------------------- + There were 0 tuples whose ambiguity could not be resolved + by full lookahead + There were 157 tnodes created to resolve ambiguity between: + + Choice 1: statement/2 line 475 file ansi.g + Choice 2: statement/3 line 476 file ansi.g + + Intersection of lookahead[1] sets: + + IDENTIFIER + + Intersection of lookahead[2] sets: + + LPARENTHESIS COLON AMPERSAND MINUS + STAR PLUSPLUS MINUSMINUS ONESCOMPLEMENT + NOT SIZEOF OCTALINT DECIMALINT + HEXADECIMALINT FLOATONE FLOATTWO IDENTIFIER + STRING CHARACTER + ------------------------------------------------------------------------- + +#143. (Changed in MR11) Optional ";" at end of #token statement + + Fixes problem of: + + #token X "x" + + << + parser action + >> + + Being confused with: + + #token X "x" <> + +#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream + + Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class + BufFileInput derived from DLGInputStream which provides a + function lookahead(char *string) to test characters in the + input stream more than one character ahead. + The class is located in pccts/h/BufFileInput.* of the kit. + +#140. #pred to define predicates + + +---------------------------------------------------+ + | Note: Assume "-prc on" for this entire discussion | + +---------------------------------------------------+ + + A problem with predicates is that each one is regarded as + unique and capable of disambiguating cases where two + alternatives have identical lookahead. For example: + + rule : <>? A + | <>? A + ; + + will not cause any error messages or warnings to be issued + by earlier versions of pccts. To compare the text of the + predicates is an incomplete solution. + + In 1.33MR11 I am introducing the #pred statement in order to + solve some problems with predicates. The #pred statement allows + one to give a symbolic name to a "predicate literal" or a + "predicate expression" in order to refer to it in other predicate + expressions or in the rules of the grammar. + + The predicate literal associated with a predicate symbol is C + or C++ code which can be used to test the condition. A + predicate expression defines a predicate symbol in terms of other + predicate symbols using "!", "&&", and "||". A predicate symbol + can be defined in terms of a predicate literal, a predicate + expression, or *both*. + + When a predicate symbol is defined with both a predicate literal + and a predicate expression, the predicate literal is used to generate + code, but the predicate expression is used to check for two + alternatives with identical predicates in both alternatives. + + Here are some examples of #pred statements: + + #pred IsLabel <>? + #pred IsLocalVar <>? + #pred IsGlobalVar <>? + #pred IsVar <>? IsLocalVar || IsGlobalVar + #pred IsScoped <>? IsLabel || IsLocalVar + + I hope that the use of EBNF notation to describe the syntax of the + #pred statement will not cause problems for my readers (joke). + + predStatement : "#pred" + CapitalizedName + ( + "<>?" + | "<>?" predOrExpr + | predOrExpr + ) + ; + + predOrExpr : predAndExpr ( "||" predAndExpr ) * ; + + predAndExpr : predPrimary ( "&&" predPrimary ) * ; + + predPrimary : CapitalizedName + | "!" predPrimary + | "(" predOrExpr ")" + ; + + What is the purpose of this nonsense ? + + To understand how predicate symbols help, you need to realize that + predicate symbols are used in two different ways with two different + goals. + + a. Allow simplification of predicates which have been combined + during predicate hoisting. + + b. Allow recognition of identical predicates which can't disambiguate + alternatives with common lookahead. + + First we will discuss goal (a). Consider the following rule: + + rule0: rule1 + | ID + | ... + ; + + rule1: rule2 + | rule3 + ; + + rule2: <>? ID ; + rule3: <>? ID ; + + When the predicates in rule2 and rule3 are combined by hoisting + to create a prediction expression for rule1 the result is: + + if ( LA(1)==ID + && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ... + + This is inefficient, but more importantly, can lead to false + assumptions that the predicate expression distinguishes the rule1 + alternative with some other alternative with lookahead ID. In + MR11 one can write: + + #pred IsX <>? + + ... + + rule2: <>? ID ; + rule3: <>? ID ; + + During hoisting MR11 recognizes this as a special case and + eliminates the predicates. The result is a prediction + expression like the following: + + if ( LA(1)==ID ) { rule1(); ... + + Please note that the following cases which appear to be equivalent + *cannot* be simplified by MR11 during hoisting because the hoisting + logic only checks for a "!" in the predicate action, not in the + predicate expression for a predicate symbol. + + *Not* equivalent and is not simplified during hoisting: + + #pred IsX <>? + #pred NotX <>? + ... + rule2: <>? ID ; + rule3: <>? ID ; + + *Not* equivalent and is not simplified during hoisting: + + #pred IsX <>? + #pred NotX !IsX + ... + rule2: <>? ID ; + rule3: <>? ID ; + + Now we will discuss goal (b). + + When antlr discovers that there is a lookahead ambiguity between + two alternatives it attempts to resolve the ambiguity by searching + for predicates in both alternatives. In the past any predicate + would do, even if the same one appeared in both alternatives: + + rule: <>? X + | <>? X + ; + + The #pred statement is a start towards solving this problem. + During ambiguity resolution (*not* predicate hoisting) the + predicates for the two alternatives are expanded and compared. + Consider the following example: + + #pred Upper <>? + #pred Lower <>? + #pred Alpha <>? Upper || Lower + + rule0: rule1 + | <>? ID + ; + + rule1: + | rule2 + | rule3 + ... + ; + + rule2: <>? ID; + rule3: <>? ID; + + The definition of #pred Alpha expresses: + + a. to test the predicate use the C code "isAlpha(LATEXT(1))" + + b. to analyze the predicate use the information that + Alpha is equivalent to the union of Upper and Lower, + + During ambiguity resolution the definition of Alpha is expanded + into "Upper || Lower" and compared with the predicate in the other + alternative, which is also "Upper || Lower". Because they are + identical MR11 will report a problem. + + ------------------------------------------------------------------------- + t10.g, line 5: warning: the predicates used to disambiguate rule rule0 + (file t10.g alt 1 line 5 and alt 2 line 6) + are identical when compared without context and may have no + resolving power for some lookahead sequences. + ------------------------------------------------------------------------- + + If you use the "-info p" option the output file will contain: + + +----------------------------------------------------------------------+ + |#if 0 | + | | + |The following predicates are identical when compared without | + | lookahead context information. For some ambiguous lookahead | + | sequences they may not have any power to resolve the ambiguity. | + | | + |Choice 1: rule0/1 alt 1 line 5 file t10.g | + | | + | The original predicate for choice 1 with available context | + | information: | + | | + | OR expr | + | | + | pred << Upper>>? | + | depth=k=1 rule rule2 line 14 t10.g | + | set context: | + | ID | + | | + | pred << Lower>>? | + | depth=k=1 rule rule3 line 15 t10.g | + | set context: | + | ID | + | | + | The predicate for choice 1 after expansion (but without context | + | information): | + | | + | OR expr | + | | + | pred << isUpper(LATEXT(1))>>? | + | depth=k=1 rule line 1 t10.g | + | | + | pred << isLower(LATEXT(1))>>? | + | depth=k=1 rule line 2 t10.g | + | | + | | + |Choice 2: rule0/2 alt 2 line 6 file t10.g | + | | + | The original predicate for choice 2 with available context | + | information: | + | | + | pred << Alpha>>? | + | depth=k=1 rule rule0 line 6 t10.g | + | set context: | + | ID | + | | + | The predicate for choice 2 after expansion (but without context | + | information): | + | | + | OR expr | + | | + | pred << isUpper(LATEXT(1))>>? | + | depth=k=1 rule line 1 t10.g | + | | + | pred << isLower(LATEXT(1))>>? | + | depth=k=1 rule line 2 t10.g | + | | + | | + |#endif | + +----------------------------------------------------------------------+ + + The comparison of the predicates for the two alternatives takes + place without context information, which means that in some cases + the predicates will be considered identical even though they operate + on disjoint lookahead sets. Consider: + + #pred Alpha + + rule1: <>? ID + | <>? Label + ; + + Because the comparison of predicates takes place without context + these will be considered identical. The reason for comparing + without context is that otherwise it would be necessary to re-evaluate + the entire predicate expression for each possible lookahead sequence. + This would require more code to be written and more CPU time during + grammar analysis, and it is not yet clear whether anyone will even make + use of the new #pred facility. + + A temporary workaround might be to use different #pred statements + for predicates you know have different context. This would avoid + extraneous warnings. + + The above example might be termed a "false positive". Comparison + without context will also lead to "false negatives". Consider the + following example: + + #pred Alpha + #pred Beta + + rule1: <>? A + | rule2 + ; + + rule2: <>? A + | <>? B + ; + + The predicate used for alt 2 of rule1 is (Alpha || Beta). This + appears to be different than the predicate Alpha used for alt1. + However, the context of Beta is B. Thus when the lookahead is A + Beta will have no resolving power and Alpha will be used for both + alternatives. Using the same predicate for both alternatives isn't + very helpful, but this will not be detected with 1.33MR11. + + To properly handle this the predicate expression would have to be + evaluated for each distinct lookahead context. + + To determine whether two predicate expressions are identical is + difficult. The routine may fail to identify identical predicates. + + The #pred feature also compares predicates to see if a choice between + alternatives which is resolved by a predicate which makes the second + choice unreachable. Consider the following example: + + #pred A <>? + #pred B <>? + #pred A_or_B A || B + + r : s + | t + ; + s : <>? ID + ; + t : <>? ID + ; + + ---------------------------------------------------------------------------- + t11.g, line 5: warning: the predicate used to disambiguate the + first choice of rule r + (file t11.g alt 1 line 5 and alt 2 line 6) + appears to "cover" the second predicate when compared without context. + The second predicate may have no resolving power for some lookahead + sequences. + ---------------------------------------------------------------------------- + +#132. (Changed in 1.33MR11) Recognition of identical predicates in alts + + Prior to 1.33MR11, there would be no ambiguity warning when the + very same predicate was used to disambiguate both alternatives: + + test: ref B + | ref C + ; + + ref : <>? A + + In 1.33MR11 this will cause the warning: + + warning: the predicates used to disambiguate rule test + (file v98.g alt 1 line 1 and alt 2 line 2) + are identical and have no resolving power + + ----------------- Note ----------------- + + This is different than the following case + + test: <>? A B + | <>? A C + ; + + In this case there are two distinct predicates + which have exactly the same text. In the first + example there are two references to the same + predicate. The problem represented by this + grammar will be addressed later. + + +#127. (Changed in 1.33MR11) + + Count Syntax Errors Count DLG Errors + ------------------- ---------------- + + C++ mode ANTLRParser:: DLGLexerBase:: + syntaxErrCount lexErrCount + C mode zzSyntaxErrCount zzLexErrCount + + The C mode variables are global and initialized to 0. + They are *not* reset to 0 automatically when antlr is + restarted. + + The C++ mode variables are public. They are initialized + to 0 by the constructors. They are *not* reset to 0 by the + ANTLRParser::init() method. + + Suggested by Reinier van den Born (reinier@vnet.ibm.com). + +#126. (Changed in 1.33MR11) Addition of #first <<...>> + + The #first <<...>> inserts the specified text in the output + files before any other #include statements required by pccts. + The only things before the #first text are comments and + a #define ANTLR_VERSION. + + Requested by and Esa Pulkkinen (esap@cs.tut.fi) and Alexin + Zoltan (alexin@inf.u-szeged.hu). + +#124. A Note on the New "&&" Style Guarded Predicates + + I've been asked several times, "What is the difference between + the old "=>" style guard predicates and the new style "&&" guard + predicates, and how do you choose one over the other" ? + + The main difference is that the "=>" does not apply the + predicate if the context guard doesn't match, whereas + the && form always does. What is the significance ? + + If you have a predicate which is not on the "leading edge" + it is cannot be hoisted. Suppose you need a predicate that + looks at LA(2). You must introduce it manually. The + classic example is: + + castExpr : + LP typeName RP + | .... + ; + + typeName : <>? ID + | STRUCT ID + ; + + The problem is that isTypeName() isn't on the leading edge + of typeName, so it won't be hoisted into castExpr to help + make a decision on which production to choose. + + The *first* attempt to fix it is this: + + castExpr : + <>? + LP typeName RP + | .... + ; + + Unfortunately, this won't work because it ignores + the problem of STRUCT. The solution is to apply + isTypeName() in castExpr if LA(2) is an ID and + don't apply it when LA(2) is STRUCT: + + castExpr : + (LP ID)? => <>? + LP typeName RP + | .... + ; + + In conclusion, the "=>" style guarded predicate is + useful when: + + a. the tokens required for the predicate + are not on the leading edge + b. there are alternatives in the expression + selected by the predicate for which the + predicate is inappropriate + + If (b) were false, then one could use a simple + predicate (assuming "-prc on"): + + castExpr : + <>? + LP typeName RP + | .... + ; + + typeName : <>? ID + ; + + So, when do you use the "&&" style guarded predicate ? + + The new-style "&&" predicate should always be used with + predicate context. The context guard is in ADDITION to + the automatically computed context. Thus it useful for + predicates which depend on the token type for reasons + other than context. + + The following example is contributed by Reinier van den Born + (reinier@vnet.ibm.com). + + +-------------------------------------------------------------------------+ + | This grammar has two ways to call functions: | + | | + | - a "standard" call syntax with parens and comma separated args | + | - a shell command like syntax (no parens and spacing separated args) | + | | + | The former also allows a variable to hold the name of the function, | + | the latter can also be used to call external commands. | + | | + | The grammar (simplified) looks like this: | + | | + | fun_call : ID "(" { expr ("," expr)* } ")" | + | /* ID is function name */ | + | | "@" ID "(" { expr ("," expr)* } ")" | + | /* ID is var containing fun name */ | + | ; | + | | + | command : ID expr* /* ID is function name */ | + | | path expr* /* path is external command name */ | + | ; | + | | + | path : ID /* left out slashes and such */ | + | | "@" ID /* ID is environment var */ | + | ; | + | | + | expr : .... | + | | "(" expr ")"; | + | | + | call : fun_call | + | | command | + | ; | + | | + | Obviously the call is wildly ambiguous. This is more or less how this | + | is to be resolved: | + | | + | A call begins with an ID or an @ followed by an ID. | + | | + | If it is an ID and if it is an ext. command name -> command | + | if followed by a paren -> fun_call | + | otherwise -> command | + | | + | If it is an @ and if the ID is a var name -> fun_call | + | otherwise -> command | + | | + | One can implement these rules quite neatly using && predicates: | + | | + | call : ("@" ID)? && <>? fun_call | + | | (ID)? && <>? command | + | | (ID "(")? fun_call | + | | command | + | ; | + | | + | This can be done better, so it is not an ideal example, but it | + | conveys the principle. | + +-------------------------------------------------------------------------+ + +#122. (Changed in 1.33MR11) Member functions to reset DLG in C++ mode + + void DLGFileReset(FILE *f) { input = f; found_eof = 0; } + void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; } + + Supplied by R.A. Nelson (cowboy@VNET.IBM.COM) + +#119. (Changed in 1.33MR11) Ambiguity aid for grammars + + The user can ask for additional information on ambiguities reported + by antlr to stdout. At the moment, only one ambiguity report can + be created in an antlr run. + + This feature is enabled using the "-aa" (Ambiguity Aid) option. + + The following options control the reporting of ambiguities: + + -aa ruleName Selects reporting by name of rule + -aa lineNumber Selects reporting by line number + (file name not compared) + + -aam Selects "multiple" reporting for a token + in the intersection set of the + alternatives. + + For instance, the token ID may appear dozens + of times in various paths as the program + explores the rules which are reachable from + the point of an ambiguity. With option -aam + every possible path the search program + encounters is reported. + + Without -aam only the first encounter is + reported. This may result in incomplete + information, but the information may be + sufficient and much shorter. + + -aad depth Selects the depth of the search. + The default value is 1. + + The number of paths to be searched, and the + size of the report can grow geometrically + with the -ck value if a full search for all + contributions to the source of the ambiguity + is explored. + + The depth represents the number of tokens + in the lookahead set which are matched against + the set of ambiguous tokens. A depth of 1 + means that the search stops when a lookahead + sequence of just one token is matched. + + A k=1 ck=6 grammar might generate 5,000 items + in a report if a full depth 6 search is made + with the Ambiguity Aid. The source of the + problem may be in the first token and obscured + by the volume of data - I hesitate to call + it information. + + When the user selects a depth > 1, the search + is first performed at depth=1 for both + alternatives, then depth=2 for both alternatives, + etc. + + Sample output for rule grammar in antlr.g itself: + + +---------------------------------------------------------------------+ + | Ambiguity Aid | + | | + | Choice 1: grammar/70 line 632 file a.g | + | Choice 2: grammar/82 line 644 file a.g | + | | + | Intersection of lookahead[1] sets: | + | | + | "\}" "class" "#errclass" "#tokclass" | + | | + | Choice:1 Depth:1 Group:1 ("#errclass") | + | 1 in (...)* block grammar/70 line 632 a.g | + | 2 to error grammar/73 line 635 a.g | + | 3 error error/1 line 894 a.g | + | 4 #token "#errclass" error/2 line 895 a.g | + | | + | Choice:1 Depth:1 Group:2 ("#tokclass") | + | 2 to tclass grammar/74 line 636 a.g | + | 3 tclass tclass/1 line 937 a.g | + | 4 #token "#tokclass" tclass/2 line 938 a.g | + | | + | Choice:1 Depth:1 Group:3 ("class") | + | 2 to class_def grammar/75 line 637 a.g | + | 3 class_def class_def/1 line 669 a.g | + | 4 #token "class" class_def/3 line 671 a.g | + | | + | Choice:1 Depth:1 Group:4 ("\}") | + | 2 #token "\}" grammar/76 line 638 a.g | + | | + | Choice:2 Depth:1 Group:5 ("#errclass") | + | 1 in (...)* block grammar/83 line 645 a.g | + | 2 to error grammar/93 line 655 a.g | + | 3 error error/1 line 894 a.g | + | 4 #token "#errclass" error/2 line 895 a.g | + | | + | Choice:2 Depth:1 Group:6 ("#tokclass") | + | 2 to tclass grammar/94 line 656 a.g | + | 3 tclass tclass/1 line 937 a.g | + | 4 #token "#tokclass" tclass/2 line 938 a.g | + | | + | Choice:2 Depth:1 Group:7 ("class") | + | 2 to class_def grammar/95 line 657 a.g | + | 3 class_def class_def/1 line 669 a.g | + | 4 #token "class" class_def/3 line 671 a.g | + | | + | Choice:2 Depth:1 Group:8 ("\}") | + | 2 #token "\}" grammar/96 line 658 a.g | + +---------------------------------------------------------------------+ + + For a linear lookahead set ambiguity (where k=1 or for k>1 but + when all lookahead sets [i] with i>? A ; + c : A ; + + Prior to 1.33MR10 the code generated for "start" would resemble: + + while { + if (LA(1)==A && + (!LA(1)==A || isUpper())) { + a(); + } + }; + + This code is wrong because it makes rule "c" unreachable from + "start". The essence of the problem is that antlr fails to + recognize that there can be a valid alternative within "a" even + when the predicate <>? is false. + + In 1.33MR10 with -mrhoist the hoisting of the predicate into + "start" is suppressed because it recognizes that "c" can + cover all the cases where the predicate is false: + + while { + if (LA(1)==A) { + a(); + } + }; + + With the antlr "-info p" switch the user will receive information + about the predicate suppression in the generated file: + + -------------------------------------------------------------- + #if 0 + + Hoisting of predicate suppressed by alternative without predicate. + The alt without the predicate includes all cases where + the predicate is false. + + WITH predicate: line 7 v1.g + WITHOUT predicate: line 7 v1.g + + The context set for the predicate: + + A + + The lookahead set for the alt WITHOUT the semantic predicate: + + A + + The predicate: + + pred << isUpper(LATEXT(1))>>? + depth=k=1 rule b line 9 v1.g + set context: + A + tree context: null + + Chain of referenced rules: + + #0 in rule start (line 5 v1.g) to rule a + #1 in rule a (line 7 v1.g) + + #endif + -------------------------------------------------------------- + + A predicate can be suppressed by a combination of alternatives + which, taken together, cover a predicate: + + start : (a)* "@" ; + + a : b | ca | cb | cc ; + + b : <>? ( A | B | C ) ; + + ca : A ; + cb : B ; + cc : C ; + + Consider a more complex example in which "c" covers only part of + a predicate: + + start : (a)* "@" ; + + a : b + | c + ; + + b : <>? + ( A + | X + ); + + c : A + ; + + Prior to 1.33MR10 the code generated for "start" would resemble: + + while { + if ( (LA(1)==A || LA(1)==X) && + (! (LA(1)==A || LA(1)==X) || isUpper()) { + a(); + } + }; + + With 1.33MR10 and -mrhoist the predicate context is restricted to + the non-covered lookahead. The code resembles: + + while { + if ( (LA(1)==A || LA(1)==X) && + (! (LA(1)==X) || isUpper()) { + a(); + } + }; + + With the antlr "-info p" switch the user will receive information + about the predicate restriction in the generated file: + + -------------------------------------------------------------- + #if 0 + + Restricting the context of a predicate because of overlap + in the lookahead set between the alternative with the + semantic predicate and one without + Without this restriction the alternative without the predicate + could not be reached when input matched the context of the + predicate and the predicate was false. + + WITH predicate: line 11 v4.g + WITHOUT predicate: line 12 v4.g + + The original context set for the predicate: + + A X + + The lookahead set for the alt WITHOUT the semantic predicate: + + A + + The intersection of the two sets + + A + + The original predicate: + + pred << isUpper(LATEXT(1))>>? + depth=k=1 rule b line 15 v4.g + set context: + A X + tree context: null + + The new (modified) form of the predicate: + + pred << isUpper(LATEXT(1))>>? + depth=k=1 rule b line 15 v4.g + set context: + X + tree context: null + + #endif + -------------------------------------------------------------- + + The bad news about -mrhoist: + + (a) -mrhoist does not analyze predicates with lookahead + depth > 1. + + (b) -mrhoist does not look past a guarded predicate to + find context which might cover other predicates. + + For these cases you might want to use syntactic predicates. + When a semantic predicate fails during guess mode the guess + fails and the next alternative is tried. + + Limitation (a) is illustrated by the following example: + + start : (stmt)* EOF ; + + stmt : cast + | expr + ; + cast : <>? LP ID RP ; + + expr : LP ID RP ; + + This is not much different from the first example, except that + it requires two tokens of lookahead context to determine what + to do. This predicate is NOT suppressed because the current version + is unable to handle predicates with depth > 1. + + A predicate can be combined with other predicates during hoisting. + In those cases the depth=1 predicates are still handled. Thus, + in the following example the isUpper() predicate will be suppressed + by line #4 when hoisted from "bizarre" into "start", but will still + be present in "bizarre" in order to predict "stmt". + + start : (bizarre)* EOF ; // #1 + // #2 + bizarre : stmt // #3 + | A // #4 + ; + + stmt : cast + | expr + ; + + cast : <>? LP ID RP ; + + expr : LP ID RP ; + | <>? A + + Limitation (b) is illustrated by the following example of a + context guarded predicate: + + rule : (A)? <

>? // #1 + (A // #2 + |B // #3 + ) // #4 + | <> B // #5 + ; + + Recall that this means that when the lookahead is NOT A then + the predicate "p" is ignored and it attempts to match "A|B". + Ideally, the "B" at line #3 should suppress predicate "q". + However, the current version does not attempt to look past + the guard predicate to find context which might suppress other + predicates. + + In some cases -mrhoist will lead to the reporting of ambiguities + which were not visible before: + + start : (a)* "@"; + a : bc | d; + bc : b | c ; + + b : <>? A; + c : A ; + + d : A ; + + In this case there is a true ambiguity in "a" between "bc" and "d" + which can both match "A". Without -mrhoist the predicate in "b" + is hoisted into "a" and there is no ambiguity reported. However, + with -mrhoist, the predicate in "b" is suppressed by "c" (as it + should be) making the ambiguity in "a" apparent. + + The motivations for these changes were hoisting problems reported + by Reinier van den Born (reinier@vnet.ibm.com) and several others. + +#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <

>? expr + + The existing context guarded predicate: + + rule : (guard)? => <

>? expr + | next_alternative + ; + + generates code which resembles: + + if (lookahead(expr) && (!guard || pred)) { + expr() + } else .... + + This is not suitable for some applications because it allows + expr() to be invoked when the predicate is false. This is + intentional because it is meant to mimic automatically computed + predicate context. + + The new context guarded predicate uses the guard information + differently because it has a different goal. Consider: + + rule : (guard)? && <

>? expr + | next_alternative + ; + + The new style of context guarded predicate is equivalent to: + + rule : <>? expr + | next_alternative + ; + + It generates code which resembles: + + if (lookahead(expr) && guard && pred) { + expr(); + } else ... + + Both forms of guarded predicates severely restrict the form of + the context guard: it can contain no rule references, no + (...)*, no (...)+, and no {...}. It may contain token and + token class references, and alternation ("|"). + + Addition for 1.33MR11: in the token expression all tokens must + be at the same height of the token tree: + + (A ( B | C))? && ... is ok (all height 2) + (A ( B | ))? && ... is not ok (some 1, some 2) + (A B C D | E F G H)? && ... is ok (all height 4) + (A B C D | E )? && ... is not ok (some 4, some 1) + + This restriction is required in order to properly compute the lookahead + set for expressions like: + + rule1 : (A B C)? && <>? rule2 ; + rule2 : (A|X) (B|Y) (C|Z); + + This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com) + +#109. (Changed in 1.33MR10) improved trace information + + The quality of the trace information provided by the "-gd" + switch has been improved significantly. Here is an example + of the output from a test program. It shows the rule name, + the first token of lookahead, the call depth, and the guess + status: + + exit rule gusxx {"?"} depth 2 + enter rule gusxx {"?"} depth 2 + enter rule gus1 {"o"} depth 3 guessing + guess done - returning to rule gus1 {"o"} at depth 3 + (guess mode continues - an enclosing guess is still active) + guess done - returning to rule gus1 {"Z"} at depth 3 + (guess mode continues - an enclosing guess is still active) + exit rule gus1 {"Z"} depth 3 guessing + guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends) + enter rule gus1 {"o"} depth 3 + guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends) + guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends) + exit rule gus1 {"Z"} depth 3 + line 1: syntax error at "Z" missing SC + ... + + Rule trace reporting is controlled by the value of the integer + [zz]traceOptionValue: when it is positive tracing is enabled, + otherwise it is disabled. Tracing during guess mode is controlled + by the value of the integer [zz]traceGuessOptionValue. When + it is positive AND [zz]traceOptionValue is positive rule trace + is reported in guess mode. + + The values of [zz]traceOptionValue and [zz]traceGuessOptionValue + can be adjusted by subroutine calls listed below. + + Depending on the presence or absence of the antlr -gd switch + the variable [zz]traceOptionValueDefault is set to 0 or 1. When + the parser is initialized or [zz]traceReset() is called the + value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue. + The value of [zz]traceGuessOptionValue is always initialzed to 1, + but, as noted earlier, nothing will be reported unless + [zz]traceOptionValue is also positive. + + When the parser state is saved/restored the value of the trace + variables are also saved/restored. If a restore causes a change in + reporting behavior from on to off or vice versa this will be reported. + + When the -gd option is selected, the macro "#define zzTRACE_RULES" + is added to appropriate output files. + + C++ mode + -------- + int traceOption(int delta) + int traceGuessOption(int delta) + void traceReset() + int traceOptionValueDefault + + C mode + -------- + int zzTraceOption(int delta) + int zzTraceGuessOption(int delta) + void zzTraceReset() + int zzTraceOptionValueDefault + + The argument "delta" is added to the traceOptionValue. To + turn on trace when inside a particular rule one: + + rule : <> + ( + rest-of-rule + ) + <> + ; /* fail clause */ <> + + One can use the same idea to turn *off* tracing within a + rule by using a delta of (-1). + + An improvement in the rule trace was suggested by Sramji + Ramanathan (ps@kumaran.com). + +#108. A Note on Deallocation of Variables Allocated in Guess Mode + + NOTE + ------------------------------------------------------ + This mechanism only works for heap allocated variables + ------------------------------------------------------ + + The rewrite of the trace provides the machinery necessary + to properly free variables or undo actions following a + failed guess. + + The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded + as part of the zzGUESS macro. When a guess is opened + the value of zzrv is 0. When a longjmp() is executed to + undo the guess, the value of zzrv will be 1. + + The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded + as part of the zzGUESS_DONE macro. This is executed + whether the guess succeeds or fails as part of closing + the guess. + + The guessSeq is a sequence number which is assigned to each + guess and is incremented by 1 for each guess which becomes + active. It is needed by the user to associate the start of + a guess with the failure and/or completion (closing) of a + guess. + + Guesses are nested. They must be closed in the reverse + of the order that they are opened. + + In order to free memory used by a variable during a guess + a user must write a routine which can be called to + register the variable along with the current guess sequence + number provided by the zzUSER_GUESS_HOOK macro. If the guess + fails, all variables tagged with the corresponding guess + sequence number should be released. This is ugly, but + it would require a major rewrite of antlr 1.33 to use + some mechanism other than setjmp()/longjmp(). + + The order of calls for a *successful* guess would be: + + zzUSER_GUESS_HOOK(guessSeq,0); + zzUSER_GUESS_DONE_HOOK(guessSeq); + + The order of calls for a *failed* guess would be: + + zzUSER_GUESS_HOOK(guessSeq,0); + zzUSER_GUESS_HOOK(guessSeq,1); + zzUSER_GUESS_DONE_HOOK(guessSeq); + + The default definitions of these macros are empty strings. + + Here is an example in C++ mode. The zzUSER_GUESS_HOOK and + zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine + can be used without change in both C and C++ versions. + + ---------------------------------------------------------------------- + << + + #include "AToken.h" + + typedef ANTLRCommonToken ANTLRToken; + + #include "DLGLexer.h" + + int main() { + + { + DLGFileInput in(stdin); + DLGLexer lexer(&in,2000); + ANTLRTokenBuffer pipe(&lexer,1); + ANTLRCommonToken aToken; + P parser(&pipe); + + lexer.setToken(&aToken); + parser.init(); + parser.start(); + }; + + fclose(stdin); + fclose(stdout); + return 0; + } + + >> + + << + char *s=NULL; + + #undef zzUSER_GUESS_HOOK + #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv); + #undef zzUSER_GUESS_DONE_HOOK + #define zzUSER_GUESS_DONE_HOOK(guessSeq) myGuessHook(guessSeq,2); + + void myGuessHook(int guessSeq,int zzrv) { + if (zzrv == 0) { + fprintf(stderr,"User hook: starting guess #%d\n",guessSeq); + } else if (zzrv == 1) { + free (s); + s=NULL; + fprintf(stderr,"User hook: failed guess #%d\n",guessSeq); + } else if (zzrv == 2) { + free (s); + s=NULL; + fprintf(stderr,"User hook: ending guess #%d\n",guessSeq); + }; + } + + >> + + #token A "a" + #token "[\t \ \n]" <> + + class P { + + start : (top)+ + ; + + top : (which) ? <> + | other <> + ; <> + + which : which2 + ; + + which2 : which3 + ; + which3 + : (label)? <> + | (global)? <> + | (exclamation)? <> + ; + + label : <getText());>> A ":" ; + + global : <getText());>> A "::" ; + + exclamation : <getText());>> A "!" ; + + other : <getText());>> "other" ; + + } + ---------------------------------------------------------------------- + + This is a silly example, but illustrates the idea. For the input + "a ::" with tracing enabled the output begins: + + ---------------------------------------------------------------------- + enter rule "start" depth 1 + enter rule "top" depth 2 + User hook: starting guess #1 + enter rule "which" depth 3 guessing + enter rule "which2" depth 4 guessing + enter rule "which3" depth 5 guessing + User hook: starting guess #2 + enter rule "label" depth 6 guessing + guess failed + User hook: failed guess #2 + guess done - returning to rule "which3" at depth 5 (guess mode continues + - an enclosing guess is still active) + User hook: ending guess #2 + User hook: starting guess #3 + enter rule "global" depth 6 guessing + exit rule "global" depth 6 guessing + guess done - returning to rule "which3" at depth 5 (guess mode continues + - an enclosing guess is still active) + User hook: ending guess #3 + enter rule "global" depth 6 guessing + exit rule "global" depth 6 guessing + exit rule "which3" depth 5 guessing + exit rule "which2" depth 4 guessing + exit rule "which" depth 3 guessing + guess done - returning to rule "top" at depth 2 (guess mode ends) + User hook: ending guess #1 + enter rule "which" depth 3 + ..... + ---------------------------------------------------------------------- + + Remember: + + (a) Only init-actions are executed during guess mode. + (b) A rule can be invoked multiple times during guess mode. + (c) If the guess succeeds the rule will be called once more + without guess mode so that normal actions will be executed. + This means that the init-action might need to distinguish + between guess mode and non-guess mode using the variable + [zz]guessing. + +#101. (Changed in 1.33MR10) antlr -info command line switch + + -info + + p - extra predicate information in generated file + + t - information about tnode use: + at the end of each rule in generated file + summary on stderr at end of program + + m - monitor progress + prints name of each rule as it is started + flushes output at start of each rule + + f - first/follow set information to stdout + + 0 - no operation (added in 1.33MR11) + + The options may be combined and may appear in any order. + For example: + + antlr -info ptm -CC -gt -mrhoist on mygrammar.g + +#100a. (Changed in 1.33MR10) Predicate tree simplification + + When the same predicates can be referenced in more than one + alternative of a block large predicate trees can be formed. + + The difference that these optimizations make is so dramatic + that I have decided to use it even when -mrhoist is not selected. + + Consider the following grammar: + + start : ( all )* ; + + all : a + | d + | e + | f + ; + + a : c A B + | c A C + ; + + c : <>? + ; + + d : <>? B C + ; + + e : <>? B C + ; + + f : e X Y + ; + + In rule "a" there is a reference to rule "c" in both alternatives. + The length of the predicate AAA is k=2 and it can be followed in + alternative 1 only by (A B) while in alternative 2 it can be + followed only by (A C). Thus they do not have identical context. + + In rule "all" the alternatives which refer to rules "e" and "f" allow + elimination of the duplicate reference to predicate CCC. + + The table below summarized the kind of simplification performed by + 1.33MR10. In the table, X and Y stand for single predicates + (not trees). + + (OR X (OR Y (OR Z))) => (OR X Y Z) + (AND X (AND Y (AND Z))) => (AND X Y Z) + + (OR X (... (OR X Y) ... )) => (OR X (... Y ... )) + (AND X (... (AND X Y) ... )) => (AND X (... Y ... )) + (OR X (... (AND X Y) ... )) => (OR X (... ... )) + (AND X (... (OR X Y) ... )) => (AND X (... ... )) + + (AND X) => X + (OR X) => X + + In a test with a complex grammar for a real application, a predicate + tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)". + + In 1.33MR10 there is a greater effort to release memory used + by predicates once they are no longer in use. + +#100b. (Changed in 1.33MR10) Suppression of extra predicate tests + + The following optimizations require that -mrhoist be selected. + + It is relatively easy to optimize the code generated for predicate + gates when they are of the form: + + (AND X Y Z ...) + or (OR X Y Z ...) + + where X, Y, Z, and "..." represent individual predicates (leaves) not + predicate trees. + + If the predicate is an AND the contexts of the X, Y, Z, etc. are + ANDed together to create a single Tree context for the group and + context tests for the individual predicates are suppressed: + + -------------------------------------------------- + Note: This was incorrect. The contexts should be + ORed together. This has been fixed. A more + complete description is available in item #152. + --------------------------------------------------- + + Optimization 1: (AND X Y Z ...) + + Suppose the context for Xtest is LA(1)==LP and the context for + Ytest is LA(1)==LP && LA(2)==ID. + + Without the optimization the code would resemble: + + if (lookaheadContext && + !(LA(1)==LP && LA(1)==LP && LA(2)==ID) || + ( (! LA(1)==LP || Xtest) && + (! (LA(1)==LP || LA(2)==ID) || Xtest) + )) {... + + With the -mrhoist optimization the code would resemble: + + if (lookaheadContext && + ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {... + + Optimization 2: (OR X Y Z ...) with identical contexts + + Suppose the context for Xtest is LA(1)==ID and for Ytest + the context is also LA(1)==ID. + + Without the optimization the code would resemble: + + if (lookaheadContext && + ! (LA(1)==ID || LA(1)==ID) || + (LA(1)==ID && Xtest) || + (LA(1)==ID && Ytest) {... + + With the -mrhoist optimization the code would resemble: + + if (lookaheadContext && + (! LA(1)==ID) || (Xtest || Ytest) {... + + Optimization 3: (OR X Y Z ...) with distinct contexts + + Suppose the context for Xtest is LA(1)==ID and for Ytest + the context is LA(1)==LP. + + Without the optimization the code would resemble: + + if (lookaheadContext && + ! (LA(1)==ID || LA(1)==LP) || + (LA(1)==ID && Xtest) || + (LA(1)==LP && Ytest) {... + + With the -mrhoist optimization the code would resemble: + + if (lookaheadContext && + (zzpf=0, + (LA(1)==ID && (zzpf=1) && Xtest) || + (LA(1)==LP && (zzpf=1) && Ytest) || + !zzpf) { + + These may appear to be of similar complexity at first, + but the non-optimized version contains two tests of each + context while the optimized version contains only one + such test, as well as eliminating some of the inverted + logic (" !(...) || "). + + Optimization 4: Computation of predicate gate trees + + When generating code for the gates of predicate expressions + antlr 1.33 vanilla uses a recursive procedure to generate + "&&" and "||" expressions for testing the lookahead. As each + layer of the predicate tree is exposed a new set of "&&" and + "||" expressions on the lookahead are generated. In many + cases the lookahead being tested has already been tested. + + With -mrhoist a lookahead tree is computed for the entire + lookahead expression. This means that predicates with identical + context or context which is a subset of another predicate's + context disappear. + + This is especially important for predicates formed by rules + like the following: + + uppperCaseVowel : <>? vowel; + vowel: : <>? LETTERS; + + These predicates are combined using AND since both must be + satisfied for rule upperCaseVowel. They have identical + context which makes this optimization very effective. + + The affect of Items #100a and #100b together can be dramatic. In + a very large (but real world) grammar one particular predicate + expression was reduced from an (unreadable) 50 predicate leaves, + 195 LA(1) terms, and 5500 characters to an (easily comprehensible) + 3 predicate leaves (all different) and a *single* LA(1) term. + +#98. (Changed in 1.33MR10) Option "-info p" + + When the user selects option "-info p" the program will generate + detailed information about predicates. If the user selects + "-mrhoist on" additional detail will be provided explaining + the promotion and suppression of predicates. The output is part + of the generated file and sandwiched between #if 0/#endif statements. + + Consider the following k=1 grammar: + + start : ( all ) * ; + + all : ( a + | b + ) + ; + + a : c B + ; + + c : <>? + | B + ; + + b : <>? X + ; + + Below is an excerpt of the output for rule "start" for the three + predicate options (off, on, and maintenance release style hoisting). + + For those who do not wish to use the "-mrhoist on" option for code + generation the option can be used in a "diagnostic" mode to provide + valuable information: + + a. where one should insert null actions to inhibit hoisting + b. a chain of rule references which shows where predicates are + being hoisted + + ====================================================================== + Example of "-info p" with "-mrhoist on" + ====================================================================== + #if 0 + + Hoisting of predicate suppressed by alternative without predicate. + The alt without the predicate includes all cases where the + predicate is false. + + WITH predicate: line 11 v36.g + WITHOUT predicate: line 12 v36.g + + The context set for the predicate: + + B + + The lookahead set for alt WITHOUT the semantic predicate: + + B + + The predicate: + + pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g + + set context: + B + tree context: null + + Chain of referenced rules: + + #0 in rule start (line 1 v36.g) to rule all + #1 in rule all (line 3 v36.g) to rule a + #2 in rule a (line 8 v36.g) to rule c + #3 in rule c (line 11 v36.g) + + #endif + && + #if 0 + + pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g + + set context: + X + tree context: null + + #endif + ====================================================================== + Example of "-info p" with the default -prc setting ( "-prc off") + ====================================================================== + #if 0 + + OR + pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g + + set context: + nil + tree context: null + + pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g + + set context: + nil + tree context: null + + #endif + ====================================================================== + Example of "-info p" with "-prc on" and "-mrhoist off" + ====================================================================== + #if 0 + + OR + pred << LATEXT(1)>>? depth=k=1 rule c line 11 v36.g + + set context: + B + tree context: null + + pred << LATEXT(1)>>? depth=k=1 rule b line 15 v36.g + + set context: + X + tree context: null + + #endif + ====================================================================== + +#60. (Changed in 1.33MR7) Major changes to exception handling + + There were significant problems in the handling of exceptions + in 1.33 vanilla. The general problem is that it can only + process one level of exception handler. For example, a named + exception handler, an exception handler for an alternative, or + an exception for a subrule always went to the rule's exception + handler if there was no "catch" which matched the exception. + + In 1.33MR7 the exception handlers properly "nest". If an + exception handler does not have a matching "catch" then the + nextmost outer exception handler is checked for an appropriate + "catch" clause, and so on until an exception handler with an + appropriate "catch" is found. + + There are still undesirable features in the way exception + handlers are implemented, but I do not have time to fix them + at the moment: + + The exception handlers for alternatives are outside the + block containing the alternative. This makes it impossible + to access variables declared in a block or to resume the + parse by "falling through". The parse can still be easily + resumed in other ways, but not in the most natural fashion. + + This results in an inconsistentcy between named exception + handlers and exception handlers for alternatives. When + an exception handler for an alternative "falls through" + it goes to the nextmost outer handler - not the "normal + action". + + A major difference between 1.33MR7 and 1.33 vanilla is + the default action after an exception is caught: + + 1.33 Vanilla + ------------ + In 1.33 vanilla the signal value is set to zero ("NoSignal") + and the code drops through to the code following the exception. + For named exception handlers this is the "normal action". + For alternative exception handlers this is the rule's handler. + + 1.33MR7 + ------- + In 1.33MR7 the signal value is NOT automatically set to zero. + + There are two cases: + + For named exception handlers: if the signal value has been + set to zero the code drops through to the "normal action". + + For all other cases the code branches to the nextmost outer + exception handler until it reaches the handler for the rule. + + The following macros have been defined for convenience: + + C/C++ Mode Name + -------------------- + (zz)suppressSignal + set signal & return signal arg to 0 ("NoSignal") + (zz)setSignal(intValue) + set signal & return signal arg to some value + (zz)exportSignal + copy the signal value to the return signal arg + + I'm not sure why PCCTS make a distinction between the local + signal value and the return signal argument, but I'm loathe + to change the code. The burden of copying the local signal + value to the return signal argument can be given to the + default signal handler, I suppose. + +#53. (Explanation for 1.33MR6) What happens after an exception is caught ? + + The Book is silent about what happens after an exception + is caught. + + The following code fragment prints "Error Action" followed + by "Normal Action". + + test : Word ex:Number <> + exception[ex] + catch NoViableAlt: + <> + ; + + The reason for "Normal Action" is that the normal flow of the + program after a user-written exception handler is to "drop through". + In the case of an exception handler for a rule this results in + the exection of a "return" statement. In the case of an + exception handler attached to an alternative, rule, or token + this is the code that would have executed had there been no + exception. + + The user can achieve the desired result by using a "return" + statement. + + test : Word ex:Number <> + exception[ex] + catch NoViableAlt: + <> + ; + + The most powerful mechanism for recovery from parse errors + in pccts is syntactic predicates because they provide + backtracking. Exceptions allow "return", "break", + "consumeUntil(...)", "goto _handler", "goto _fail", and + changing the _signal value. + +#41. (Added in 1.33MR6) antlr -stdout + + Using "antlr -stdout ..." forces the text that would + normally go to the grammar.c or grammar.cpp file to + stdout. + +#40. (Added in 1.33MR6) antlr -tab to change tab stops + + Using "antlr -tab number ..." changes the tab stops + for the grammar.c or grammar.cpp file. The number + must be between 0 and 8. Using 0 gives tab characters, + values between 1 and 8 give the appropriate number of + space characters. + +#34. (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue) + + Previously there was no public function for changing the line + number maintained by the lexer. + +#28. (Added to 1.33MR1) More control over DLG header + + Version 1.33MR1 adds the following directives to PCCTS + for C++ mode: + + #lexprefix <> + + Adds source code to the DLGLexer.h file + after the #include "DLexerBase.h" but + before the start of the class definition. + + #lexmember <> + + Adds source code to the DLGLexer.h file + as part of the DLGLexer class body. It + appears immediately after the start of + the class and a "public: statement. + diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt new file mode 100644 index 0000000000..352428ed0c --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/KNOWN_PROBLEMS.txt @@ -0,0 +1,184 @@ + + ======================================================= + Known Problems In PCCTS - Last revised 14 November 1998 + ======================================================= + +#14. Parsing bug in dlg + + THM: I have been unable to reproduce this problem. + + Reported by Rick Howard Mijenix Corporation (rickh@mijenix.com). + + The regular expression parser (in rexpr.c) fails while + trying to parse the following regular expression: + + {[a-zA-Z]:}(\\\\[a-zA-Z0-9]*)+ + + See my comment in the following excerpt from rexpr.c: + + /* + * ::= ( '|' {} )* + * + * Return -1 if syntax error + * Return 0 if none found + * Return 1 if a regExrp was found + */ + static + regExpr(g) + GraphPtr g; + { + Graph g1, g2; + + if ( andExpr(&g1) == -1 ) + { + return -1; + } + + while ( token == '|' ) + { + int a; + next(); + a = andExpr(&g2); + if ( a == -1 ) return -1; /* syntax error below */ + else if ( !a ) return 1; /* empty alternative */ + g1 = BuildNFA_AorB(g1, g2); + } + + if ( token!='\0' ) return -1; + ***** + ***** It appears to fail here becuause token is 125 - the closing '}' + ***** If I change it to: + ***** if ( token!='\0' && token!='}' && token!= ')' ) return -1; + ***** + ***** It succeeds, but I'm not sure this is the corrrect approach. + ***** + *g = g1; + return 1; + } + +#13. dlg reports an invalid range for: [\0x00-\0xff] + + Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl): + + Fixed in MR16. + +#12. Strings containing comment actions + + Sequences that looked like C style comments appearing in string + literals are improperly parsed by antlr/dlg. + + << fprintf(out," /* obsolete */ "); + + For this case use: + + << fprintf(out," \/\* obsolete \*\/ "); + + Reported by K.J. Cummings (cummings@peritus.com). + +#11. User hook for deallocation of variables on guess fail + + The mechanism outlined in Item #108 works only for + heap allocated variables. + +#10. Label re-initialization in ( X {y:Y} )* + + If a label assignment is optional and appears in a + (...)* or (...)+ block it will not be reset to NULL + when it is skipped by a subsequent iteration. + + Consider the example: + + ( X { y:Y })* Z + + with input: + + X Y X Z + + The first time through the block Y will be matched and + y will be set to point to the token. On the second + iteration of the (...)* block there is no match for Y. + But y will not be reset to NULL, as the user might + expect, it will contain a reference to the Y that was + matched in the first iteration. + + The work-around is to manually reset y: + + ( X << y = NULL; >> { y:Y } )* Z + + or + + ( X ( y:Y | << y = NULL; >> /* epsilon */ ) )* Z + + Reported by Jeff Vincent (JVincent@novell.com). + +#9. PCCTAST.h PCCTSAST::setType() is a noop + +#8. #tokdefs with ~Token and . + + THM: I have been unable to reproduce this problem. + + When antlr uses #tokdefs to define tokens the fields of + #errclass and #tokclass do not get properly defined. + When it subsequently attempts to take the complement of + the set of tokens (using ~Token or .) it can refer to + tokens which don't have names, generating a fatal error. + +#7. DLG crashes on some invalid inputs + + THM: In MR20 have fixed the most common cases. + + The following token defintion will cause DLG to crash. + + #token "()" + + Reported by Mengue Olivier (dolmen@bigfoot.com). + +#6. On MS systems \n\r is treated as two new lines + + Fixed. + +#5. Token expressions in #tokclass + + #errclass does not support TOK1..TOK2 or ~TOK syntax. + #tokclass does not support ~TOKEN syntax + + A workaround for #errclass TOK1..TOK2 is to use a + #tokclass. + + Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov) + +#4. A #tokdef must appear "early" in the grammar file. + + The "early" section of the grammar file is the only + place where the following directives may appear: + + #header + #first + #tokdefs + #parser + + Any other kind of statement signifiies the end of the + "early" section. + +#3. Use of PURIFY macro for C++ mode + + Item #93 of the CHANGES_FROM_1.33 describes the use of + the PURIFY macro to zero arguments to be passed by + upward inheritance. + + #define PURIFY(r, s) memset((char *) &(r), '\0', (s)); + + This may not be the right thing to do for C++ objects that + have constructors. Reported by Bonny Rais (bonny@werple.net.au). + + For those cases one should #define PURIFY to be an empty macro + in the #header or #first actions. + +#2. Fixed in 1.33MR10 - See CHANGES_FROM_1.33 Item #80. + +#1. The quality of support for systems with 8.3 file names leaves + much to be desired. Since the kit is distributed using the + long file names and the make file uses long file names it requires + some effort to generate. This will probably not be changed due + to the large number of systems already written using the long + file names. diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README new file mode 100644 index 0000000000..84e0312686 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/README @@ -0,0 +1,171 @@ +--------------------------------------------------------------------------------- +README for pccts 1.33mr20 (Maintenance Release #20) release date 5 August 1999 +--------------------------------------------------------------------------------- + + Parr Research Corporation + with + Purdue University Electrical Engineering + and + University of Minnesota, AHPCRC + + Terence Parr + Russell Quong + Will Cohen + Hank Dietz + + +A central place for information about PCCTS 1.33 is: + + http://www.polhode.com/pccts.html + +The maintenance release is available from: + + http://www.polhode.com/pccts133mr.zip + +There is a ready-to-run version for win32 for Microsoft Visual Studio +at the same site. It is available from: + + http://www.polhode.com/win32.zip + +There is a newsgroup dedicated to pccts 1.33 and related topics: + + comp.compilers.tools.pccts + +You may also want to register for the antlr-interest mailing list +which is provided gratis by the following service: + + http://www.onesite.com + +New users should visit http://www.polhode.com/pccts.html in +order to get the following document: + + "Notes For New Users of PCCTS" + +This is a Postscript file of about 40 pages which is extremely +useful for someone starting out. It is a based on 1.33mr7 so is a +little bit out-of-date. The section on semantic predicates is +very out of date, but I have not had time to revise it. + +When you have a little more experience, be sure to review the +following documents in the distribution kit: + + CHANGES_FROM_133.txt + CHANGES_FROM_133_BEFORE_MR13.txt + KNOWN_PROBLEMS.txt + +------------------------------------------------------------------------- + INSTALLATION (Unix) +------------------------------------------------------------------------- +0. Download http://www.polhode.com/pccts133mr.zip + +1. Unzip the distribution kit to your preferred location. + +2. cd to the main pccts directory. + +3. make + + This will create: + + antlr.exe + dlg.exe + sorcerer.exe + genmk.exe + +4. Add pccts/bin to your path. + +5. To get an up-to-date list of program options execute the + program with no command line options. To get up-to-date + documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt + at: + + http://www.polhode.com/pccts.html. + +6. You need not create a library. The makefile created by genmk + assumes that the files are not part of a library. + + If you wish to create a library from elements of pccts/h: + + If the first letter of the filename is lowercase (uppercase) it is + related to the code generated using the pccts C mode (C++ mode). + Some of the .c and .cpp files in the h directory are not meant to + be placed in a library and will not compile because they are meant + to be #include in pccts generated files which are grammar specific. + + For C++ users place the following elements in the library: + + AParser.cpp + ASTBase.cpp + ATokenBuffer.cpp + BufFileInput.cpp (optional) + DLexerBase.cpp + PCCTSAST.cpp + SList.cpp + +------------------------------------------------------------------------- + INSTALLATION (Win32) +------------------------------------------------------------------------- + +I've tried to keep the win32 kit to the minimum necessary to get +up and running. The complete kit contains additional information +(some historical), source code, and DevStudio projects for +rebuilding pccts from the source code. + +The kit is now distributed with both MSVC 5 and MSVC6 style projects. + +0. Download http://www.polhode.com/win32.zip. + + You may also wish to download: + + http://www.polhode.com/CHANGES_FROM_133.txt + http://www.polhode.com/CHANGES_FROM_133_BEFORE_MR13.txt + http://www.polhode.com/KNOWN_PROBLEMS.txt + +1. Unzip the distribution kit to your preferred location. + + This will create: + + a pccts directory tree + pccts/bin/*.exe + pccts/lib/*.lib + pccts/h/* + sorcerer/lib/* + sorcerer/h/* + + an example directory tree + example\calcAST\* + example\simple\* + +2. Define the environment variable PCCTS to point to the main + pccts directory. + +3. Try building the simple project: example\simple\simple50.dsw + or simple60.dsw. + +4. Try building the complex project: example\calcAST\calcAST50.dsw + or calcAST60.dsw. + +------------------------------------------------------------------------- + INSTALLATION (DEC/VMS) +------------------------------------------------------------------------- + +DEC/VMS support added by Piéronne Jean-François (jfp@altavista.net) + +0. Download http://www.polhode.com/pccts133mr.zip + +1. Unzip the distribution kit to your preferred location. + +2. set default to the main pccts directory. + +3. @makefile.vms + + This will create in directory [.bin]: + + antlr.exe + dlg.exe + sorcerer.exe + genmk.exe + +5. To get an up-to-date list of program options execute the + program with no command line options. To get up-to-date + documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt + at http://www.polhode.com/pccts.html. diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Antlr.exe new file mode 100644 index 0000000000000000000000000000000000000000..a2bfa1f4f0ac38a4f7a23bb2abaa3f808b2504ee GIT binary patch literal 286720 zcmeFadwf*Y)i*u~6C7Z|3^0+10V9kyYS3tcf)g;15F!ScNyrRx3CKkc5fyPpP_A|| zm6Jm#w$$2IA5BGTTWe8ii#H4e5>QmY8-i7+Jnc>gD=NmIXx{Hy`5H0wJ&GV^bM9C7K_D-e;pkb%U1l-e?|Pa`#(qUy6<_<_qA;4_1gJc zQ_5dEf2y+Zj_k!tZo6s84Yy>^yW!SbZwqG6U68#bbZhp)TeC~1RA%3D+x!KWrl!7RdTdwvyk#WfQS9AQFLr&bE`ecayd)}d3-2d$OxrZ!V&UI)se)oLR^H6{M{%7BL zhf?udv2dP3FuG#w9dEIer}VJcFFrcbcz49&Na>T((_-0|YOyp@&n=cyKgG2Z7f0|* zy{BvZlW$|cmPgK#@9>)F#y3=!3iGe|Lk}%$j-^_1`0D@iAKh{bpq998_-C!EAKT&gyb@5Sx-;=F3;(k5+`T%xrbKalHqN3Hpq8RcDzS*q zmZVz3JDoKtVgRl@J02x~^-2fIUfZ>7vsw0Ex2IYf<_9NO)ZtXVZB3!G*plL??S(+| zg~qB9OSrw-5qTLjt1oe9)t9?7z4cSwZXfP4D{!0b_0?31V}G@v?aWA{qjn2IS#fNB zss+Wej8bl@lu4DcE4(#B#gf zwyX)HvkYw9)CKNQwy&aQw#bU%bsU)nkwyJT+V7#__+QL^zlib;<+2}2f_}VpTUKHtb{cha#JujhnJUs^<=;l)reXISVpp)gQbf&9(3^h_ ztu{PSRczT-fX8*tx>v3~JCs$sC+Mp4rr^e(66zanObs`u*6s-%$#0CNo!b~b*a5y5 zHxS#s;_tsn!QXqgfD-8^1I3m{2^v_xW|YNIJ00MalaNvI&f7#PDgfp-r&?OCp;vq9 z)eCq<93PG+;r1IGk+HZ)&cPeR#am1cew7ANTs*fs$xRhsJ!_VK1?9DL!rUi@0dok| zvPYeFO|Vpmf@iqZkzVnK*`(XD(6_%PH8XyL%c<$T+z~+J}qe*Z=V3^hRyidoK#Cd9ZZ15*=R%Degj}+kPesn>+kLm z`)?sc?Gx0|^sFT<4?F`ch!{byc=KtNkOH6hJu0JRaXIQIFa(j)Uw3pwK9<&@KGd;# zn9@M{)y4RPZZ(Y0{pd^GTCyVQ2(~EOQysM-X2;Ob^6ren!yuY&L~euiF{noU*D~6d z!7l8ys$Q#>z8BYOnN3UI4QmcF&c-bnjBxv{xZOJtx0Kimw+C_i+A!Qwcf;+=aJwxJw?E_C5N_Xa z<2KBMML3s;zQX*xLzpv@F4hUP<{ifqon-2 zzQ4>vV{;gYc0yNt^mrM9@)y)Rmy)Kt?%U&#N(1 z=2=_qt5RVdwPR2x-2NRpbMv1~Y&|G%=*$+N`JFnmn{?*x52Vh(3|f>N(iug6@>`}Z z>CEH(Kx2hcJ`K)7O-cnGW_cBI&U_UuX(Y(#kVOo>8;*!mA?X*l|AFvz&#s;|+p;r8ZS1O|J`%E7H~TGeuv@TIb*)xs{wVU+tmUn)FQ4k@sE7K9EjBh zJnJe}QN<7|JFcV?SmMqEEnJ;Fw;XtG^Tfq}G6m={m?m*CaAv#UX_B_!{se8@Yqs&k zO$PPZ_JrH#hdkhFCN#`NzE#Ze%YoxJU%c?7+1!eQ zCqa3ESQ>-z8H#EdGzbDli94^tD@H+?Fz$&Prl(pS*$WYudU$nHa8iBHox7DD8NSKY zub%0fT>WaCZ{leR4jeU@+?}99c_03^=nXdw!WVVduW;wGqZ)J2UMAS_KANlwtG$J) zzJcK!RSoLGGashF)j5NM7lEeIFigA=0+b%-o!>*EmhGsW3|p3z%!-TT@#r5-O7BJK zh8KaGrzzyBNl{YJs3=)Lt=Jx==L(6lvKdHv#U8XS*`j5b?|c>FX?iZ*^PQR7oeYVVdO>B>;6|_@G{+RC zniQXS93DAGJ)Sq!41PaYX(lGI-!&Dji0mC?4j)7Iu%!TvJCHxiO+8 z*?ZvNrlHvk$~aPjdxk{`?T*1b;;Rw7}PYdeh;a`C|x^V_<)aV!a?{5CP7k`7jyyB^P zNzk@+;B@-NB@--F!le$UVJ~`xZnCp{;tdYN z$oP622q28F9iTKDm1fp#Mn|-Rup!t}*gVx3 zd0J@X8LFhiY;_&o(m_V1=VfNNq7OVbg|4A7j^vo~3>?|>=#z!W{w6W*agz`$;hcIt z3|gCu?J44FYL#>%nl5u6YaF#BsKA%H|8^^x>GKkx@?&5i&Ge&)#p>1;^((e$Z?|nv zQ8UP|cGQl9Jb2!%UqS#bNC05031BV&gxeL_V(1E>??PWiDKN3$ zNpkTxR3V|w*^eZ}*Kz=Sg_9KOV3Ka}c7;yl{Eq0QKraWqbCNfbWwHu+B;|e9@>WVQ zv{BTk;llHY9(v9qGM1Q##8m7n4qz$obuL}CFH{FJ{Ufh+OOJ)(GByEB${MsJE(4ay zMaV5WKwv#GxEkdXQ0@fc0ZkC)K8AfL0OdGI!#4X7qTHevlTeP*JKw~+4(f2S2;w)s z808?KBx6=btv8J%SoX924k8SkoilXhXtg1rsdUwzs>|1P$vc@U2E{sAg;ungZZ~wL zpPry8tYeF$7CS`>FpH*#+iM(=hpn<;!zMUNvJp>gpTr!~Jr8{7zUmQ2x#y)`wEdXx}vG??;2QGZL?G8k$aM8vKs zENNu`QUuq^k4OpQRzVCVQy8QO+GG%r7g2-8T4bF078r(hHWji`21;B)F;W64kp{2UqScQzr(^QswH{Wn#@Q0pNrh%55oi!_Zj7 zd4Q;vW{QFQnXFKL#|rLy;lpE79HtK%-_Pj60_(}`)^?8l3Mzk z#k5CEvi}?+CdrQWEn+gwBS8GOxl01+lmz0@P`& zO=6yhio?iQ=r-bP08d~e_Fiw=2-t_;nHbnf5X-kFu@7Wfb^9PKD>Fe=%EVohbS!BA zBl}=;)V2ak5SG!dUrs&!o7qmRr`yp#+0%ajrxzlqB*S8a35DVYFR?Gu798qV$So0G zN>JZvCF|A}Oj|R?60*VVayO67Op#RL_!|+^PV&q0_jtC4(ji*8s{QRE2y-->c&oW2 zZ(Y0S8SY5jRoAW({Kzh)lUsn)9{$c&%T`EX%OIDC+`ejc!y4deIF{j^MNLqm9I(Vm z?oXB(;$ogb$ptlPQd+5Fc$b5MP8x66zhu_{Nq;4i3q>g>lw?@4$`WIfH*|sruIPEm zTggF*D)G{d9zUHIq3brwwv4O8AvAQVqdGlb$bgbVSa z?lQ;fOn4%T^r+z9P)Qc}V6ONNMmrG6bU@-04m9ht%_tk1fX>>{S0}paic7NOcmr@s zc_u2Z<9}7q@oa@V-WwVy{dRbnO>z2FNpU!ZPB&9{LGFv^11Q)>W*_Y*p3xe%@4I3B40^A+wtIR{Hp+fadY9hBaT3$}*RbL-dXE}GxscF#%1k2Wx9rVWMO#@a zbd|X#Nt1{zZ^6-yu_XCdcf;>WzRt=6Hz5yyS zF!qVe)fgv*I65B0{Kib`gtzzd`NbP>nzel|kNjesoaC0dLp9?`8s2z{7fBzQ{jU1# zDeaXh@u3vM(sPYpYNNTvew00t5 zbS7xVQ67_>Nr+LmW|(;Tev{@e!!GIp#^IG9UOG+oX(MQw4<5I65Ytm5#eInV4Cieb zjb67U!011~Lt^A0N@sAgi~W+iALsQiwmgv%93aT&f(SWVFbtEBMQu+Y*xZLJ_)J{b zQHx~0CGxSO_P6-0$*d9|?F3%vjnXMUqAE)lsCSD3j2_Q=hnG zAa%$Jw^?24)G~;*fvO6zX*nw+df-G!3Lc1m!_a8ZT|iOF;Z_aLb$^6M?rai!roS6r z&k;Bgt)tOQ+Zv(^V#@xw5lA#4Li2nLAHf+c_C$l%Q0Mwx(EQ0{@}a~T+danB@R+z7A1I6q<|_9rKY+i%t* z)-g~)nhr>y#5W5CA(9*s?-q;3fdmL=DD}u$m>J=nxlOWZqYTewWSja=Dan)U6^egvpw_e4mnnA_RLFd!c=miC0;C}`xp4k(um zI=_{G&aWW^k_z%4#0{*n`G-XsvHgS?GZ;uC(0r)ag6Yc%&S08)ReiObut3PfQ^Us+ z09|GR{gn}nNXCWR7l$SidC80tb>ruRDry#sCo!8Yc{f6AE=skC<>&{rC{68AKg}w` z3O&EKIQUnhq4bwqW>mb(Y#=Y4Y8O$Syvl4jb(d?Bdr>uel1%Q#_0)Dw zexnZS|2MtUF?4iwA7+6dlHRMz&!G3~=Q6$D?~dMs69BcDKraH&PE@+RJ9^(P3h#^2 zyXcy3>3#cm(0l)o|AOA9XR;^B^!CCMCZM-m@&=K$l1*j{pMSW@?`fim&rFE6G4bib zeYOl-N)r&}^Xm*syKu!s$#27aqV&rg5iBn0NAS=JD5Q7H$(Z=g=`;yR7Xpb3FaolPq_?L*9pXwZS)b2tLMa^h%br;s` zklJY{48`l54!=X>$EraMEFvG(v}V&oWaSFC-xMk*r3I)2x#*k3e^`Ua*PSFjD@41) zG3j1cHbFaa^{cZT8+WYrPLRD}iHAAq-kDrhZvV+?oZX(08bF z4z$^A&hWTNxpR#f9&!J4!yjfr`&S(cn$~0xG2Y*l@ml^Kzh^t#3i1K06ei=^j(;}X zyXamTySfB&rXlE(8vP_f4|K_HbjeN@jy**uyvv|8fnpDfy$lFm^RP#0M>$Sc*l9#z z@5sp>Ibr@l) z?pXaeNGZ-2SqyEW1c*ooT*f3&_;_|Fe?0$VC?%~#bs>&mciiuJEr8rM4evSlb>Uw& z-qZZorUcZQ1sZ``m0~pl5H{54dlG>P0cN52)jCt42d6qw zRyH`{vIo2(cL^1ysk*bPsshSeWMc#Xc*Tw<>5VHOPW>gtqEPnOtM(Ab$sbA=Kx2=I#ukEd0RB2mS|umcn@ce>Hs^V6E1FF$Euu23xTR@msZ#7?HK1uw zcXCSIC|+e2Slvx}-C%k2Y8D8Z#z|f`RUBi5<8CTOU8k;j zHjrIP#p_pr8?b@e>z-ZGPYe#Izs?HQoCK?-;(@#H?jn0M0T1qr1jOkBl1Sp@A|jIW z`K(xN_mJ)*l5s*+*)`iDt`~#k}bPrE0(L2MZ7KBD5 zuf0HgwAR$xo6Oq5Dbd34Dd6+?Juc9Zf|0+uW* zHdyj2=o<`Nl0KDb^L!zB;Qzxp~5PMis!=wNlzqa zn~7w7LOl}(fWxWheaf0S`qzEX(oP%G=Fw=NI`I$VJ@2>vvBoGMF z8xXgR{m${=PQWS@>Q79`Is)1Y6_e4)xw$}GA1l8ZgW@{WuE`3BQUn_` zQ)~D92e$BP6Vo+quyf7-L(+t)GBU}PYL!#ZPg-G$l}hnT45GS)#cCFnJg4y%Cudt-DWjr6qc)krzk*;+EjY?QD za{bM$x*+X2qejpo^orQTqv+kces-)HlrD zuB+??cD}`(JURgaVB!wL7&*7lm2v`K0d=$ z&GmdMsU0jH6?D5pj{5P|O0PKQ8EzwbL4C-o*uhx8=!r*_e$j!9GAwKX@}eg>xty8b zCI@>|uiHR<#_PPc9Zr3)TndpSQPlQ(-f{f&POMr}{0YRk6*?%zxHqnp8xs_1HjDfV zaZ7TGZ3hm~xg-b@1(Zy%%xbPUc8{)d!E1!Lj0X*s35{;Z=kb%Q5DO};Sv!1tF;)patW0M<`CF1ebX7}4^ zhx`ui&@8A``zLAUw=Oi*XO-l>x%0Y81H4&2tFotdb=VWFs zMXb4U-Jq}L4l$SkXOrJYJ8;Bcl;_US+5!@-B1i2JbS5sD`(XlND4>BSsOB_#?U9QQ>Z}I97fK%Ij26F>*=H<%nuPkmy%S^w)%{&~*w} z5-bELV?AuW6|g{+B#DXw6l$G_B5iBtxOk%^O&TI$&hrNKOKD=_>jWgJ0wE+x?nDF> zTZ=U@IYm;%de&p62t_l7aQ#S!Tfsn$*RacwB^AevDD6peeaF zj6|nvQg~TR5>;@^5){qQs_g{pZ=A9OMKeis?ljb?N<6-l$Vbsk5jsfAV%&@(9{d-} zVjd{P$mdjuOXB#Q1W6zH3YxH+d!-P)IM4Ut3`21+0hMkAZP0W;Y(UHrmz%ifR0Q%Lx?J?R znCEx;dgYq3)4yW{(c^aXN*2`p$o<+5jr+?4#!go1d;K!(7zUH>P0;)&Xcf)Fn{v|C zspa}~Zsagpk6MXWkW_Ofk*B11UYgccFBe0WnU;;5`M3p}t_xEwRh5F$DVpn>0)&N{ z^_x8U!OF)9FFe>Q7UID55mgU(S95axqGWV|^4LrDrglNGUgmUL;QCbfU<= zIqI=>Ef{=P%V5s)ID>ss%T>O2)c&ZWqXUZK1|~Gqm^WLs%e8fIo%MxvcwC^egrSg| zrbbz|(n(@twm=6$>gO`lFX1d&T+%tKn7vNcy~THQ(miEk0tQWn#7hRqh7+Fvt@xV#?lhu!xFqu;#*{h#$U(Djy_3!)l;$A<(GXKy|g(+IFnbb3SQ>7!<>jQvSROM`Qp^8VT2Bu*-8dsR62z zT=^>e60FzLb_{Xp;W5@AO{Nq;=%Fhgldd3LcQ-Csd+huK0Lr|+ib^s6Muv!` z3(m3HLG&Ikzz}!vTJ1_21;XE2gK0(JJFa?!T$*0pmx~@0`qXhb(ShM_Q$y!!E(v!c zslwC>b!-my&%;H6FT!NjUX%2ZgZdgrRPdvf+ zASdLgZ9*l#h_F&vTXD#OMLCv$*O`bYrPho>ECS9Y$uC;K9@xIXViGi&p92ab(KIQw zxzse5=93aEHC0E`4j)l=4RktHAzq6IZ;R9E!Y1k!AQqy&7gkUF9Uc-GZkz`(!FNKsDgf-kGj=X`FeU-4?8x3HI`f&WegrAzQopn!}BR5&nL-(;Bu%^K=kLHXSKcn z0Wqh?V6Wu-VI>lw9r`}?L3Dlw}a7~ViwOK@*4ANu=c&H?>zx=m1L+wK~9{} z=)B1GdbxyKL~b`t$62I%yyLY(JT;9*Pb;RUgP1^WSj)X!hrcL;EoQ-VCAS?U4*Z;p zal#EO5CI-@JuM;Z<)TE8-zVNOpAC_l!~7MZ(Rdbg1p)}lC6Ci%_LxJNeC{eqtNxw zKO@9k`EBv`sq-4*8gVxZHv}kD3@J>!hS-=Q9ZVyOSXKymwn};4yNKl(Gu^a)#MLA` zw2A@q-dt2Zi*cLACvWHRiPPV97^2Mjtk>vx1NcLp*J-Ij37p5+a)n@ACVZH(DuE0X zvl$>?Wj?e>Pg!EVm6t8mttIsX#G2O9Wd|*aMA~Sq5BiS z|A=*y;9Kdc{d(Q{JH=Htw>{&*qoy0oJCR#SYhKhF?fGyhw~;s}Ob&_L;5D1Meql0LkF<+i05;Ngv7ScDU| zz=(qT&B7SkgPd&Ifv63TL6=uslIs&`fXOQ~aGuIQWsBJvPP~hs5LkO%iF>{laIVFY zJkSEx#Ge6hGFS};k@x`!$uQGEXrI1I!HBc$kE4fNfIQU9gz#5h4GTy zdF94ZvH2F0D#b$(Zf-u;Y!V!3PSBpyZ0~ZkCl7mJCL+_FDg`Gr9)>N+^k}LW9cyym zVDd784w*LbizOf@MoDoou!!DGlcn82S|C1WMdH-NPr5+L(IFif1W0*6CrRv=0|{@v z29>2>k?p8O_pqrv(#D=z@FHz;HUbrgHaQPJwAW-l&JG#iS8Oy&?f6ZKWDunp$iW89 zL;{+B1OrQueC{Zp7rh|l&@RSU0 zv;+%g^aF?D9IVc4zezlIv&r^y3HB@iAlVjAos$~NZLFjo^{|~ec=R@Vbcxv`Rz&hZ zyO|xICdR~?-hZye!YN-d3XK}R-J0M$#7Kqkzocf@HjqzO;#Q!P=V<3vN>5o_xd6Tn z`OK7PE6qiLMdSi4LSdvpBJ=T^-$+(!ZD|=^7RYD$F%qNk^1!~|+lB|Q5 ziu9r)Nz)F6ROFw7KxUdHsRlOP>BL1m9FAYom>Pv<5c}@XI>a+Dm?;QaQun{9M5E@iA?z@w;{ti z$6;p%lAVcjAv#;%rJ@XxDZ5;b+Qa8S%F1F*qP>v`+Is@6NS)aO$3L;1xh}bBOBHX! zh1Q!?&?J<^she%T=yg54vx)6z>s^W7NY>`^fxSS2HO<7m89L?6JSf|WB?)@;0ri6uA{|(e3n% z91F5KaOy?8)#ItDLkaMC9#}{lad)e~QJHxn@r$;50F@#R=<@hEps;70C(U*2QLNta5KuCfA=vU7t2C7a4=e1lcC$ z0-~e`<%p8Fpc_amUhI#7VmlIVbkddVxYj4qrrniWKe+>0y7@>%Ey9R#Izi`GQJ2}i zK8%2Y&Ys|GrX%tysFu7Z3&pcHm;@+A`{G$gcaxoN5ssBV8|4#Bx&`65>t|0O=CSrN z9LJMiLB3DkMe?0s((R0MC&Mklarg zDz?uyIX)F&c<-0K(@h>=#)+~S_y}tzXE5;}?{06!)crA#(i8z|o5IN+GJl%-^*Gb30?)@D>Cj(x}}|$&C5IOuurF#N~^6Lc-RPMz85VBlPAB+E`PT zW1)8%f=j7*7b1RxpLy!=g$VRw+Eiv@u!v~( zI5vPJ)Fw(PoN-cvs<_2leE<$UCQX`|370fDhIlE{P8?j(vLEYfaa`RWARH+dnsBH~ zDyVA)LQq9IIlt5r)&o3c*IAyalo9&B#Lmz-r=A)aO=oOO@VtZ5sBj^ZN^{Ll$H=}O zWRYb5Gopxa`%Gz)9TBXq>?X>ZDVk=Q6!!x+(bOAUBYyE*o|2%cVP;b$Xeth0Bs*5= z$&S+GPR%OejWziZD4=B=MAwkk&lRQAIE|J0ZLQlOD&h9kp|Qz9trlr9P!9l93l`0w zzZUULFB4F7`RFxx6e>w-^%Z(Ao`+@BMQ@T03Zt||JQD}1o21D`;%;wLl-z|U{-@rc z{FDwXzTVBud<>`eC&2JB6GN{N1-(GnVxWJM81yN4=P_gPN3&x&q-}R$g=|7&amLUqo;nL~ zF#Zy4Wxv6d1nUj&5J5KioU}L#IEf%?N^hqd*?Ey<=XGEwWd}=ICc~wn0Y0)vZ|-&q zjdz$Gh$;RrKs_lte?@1pD@{5|j>tQhuSzaEOT;V4gy^y`3vk6NJy~|VsDp`fG2;XC zm{#6?%Zt%+<(y;%R-|cM9g(G@b_l9tjH8)EwFkx%nnzTxvucI>2+JRMVsQi+u*q;U zra{$bs(dS|(5TGg8w(g{3G{0T`uQj79XoWdBU)ikh3Pu_9#Za#q&-#Wz4$xZY-Y=1 zA}y^|Ew*ZXs%Wxo-$bH>Q$`9+X*jn0I8sxie=Gqf%NQ#3Uev|_50pI1)hex8k185@ zufoV{0syN902o)a2&rc5zj#_A8KHs?FB?GHZ7}_%Ml^I8|k~y$-d{^y5-!!t>|j^blUW z*8>#lp((jlqWaww3npH?>;+-^2?Kv-mGpor`C11LU0lPsDW6)1(**cw~qt0@R{iy&& z4icuy5Liq@&iNja6@-|5KzgVkMJ%Bl~AoFm@y{wiUF+77Z5?vWwJ}1$1CRsY|`Jh;p%|!F;c{e-|7g zzsp-8j^hel0;nu)l1&?L_ZkcBl&z-#d2dK|86pGbU95)k8n*JBRp|V#<(Egpd-AU{33Oy$rwVwkk9P*z_MeYI>y`l#fbhf@HS(YSTZ6^zECyg#imLESxMOvYH z2x)^Qoh{G@<8`5IN!x%d4AF)%Oil#O%|&xkfE}`Pq3e~CG;4f5V`Poe{{1BA*ulQm zmDCoynrj@jj}b`Plmxpxpo$cshTA0b1bc!XQNBmuD%26t4txg!IHFD&dcWdb zUS3k54_6qZX!v5nJY7u803&mWGSctXm*W)D%ArE?cM7~yd^K~WS1wj_TX{4V!gO-p zgVzocIm($dWlWkyAWb=)&DR4LUXHzkpu|)9GzuTb<<6iP zZj>|EVPZ}^(NdaPojEMK@JD0t7M~b%|dZ%irMNqs#Z(YE~nJhG%zfQ zgX$JLjB3H_l{ute{p7aLxW#mT{)Tx2i8YiY`@1I0%0PD{5*M(*(*oK8CDCf5R2d!FT!FiN4P#rA?H6YwgyEx0 z;aO&jwA1?JGxnq-MKM%4lmLyn1{$>#{_vKNScc-~Xg6NU^n-bTD4pBv7C)b4O4;AY zFmi@7zp>tzf+L@_uV~5qwQEcIb?AHPXuZuixPtZqb|bL882O)&zHhE-Y?V)$c^WeJ z5;li;#RT3?>k`*|jb0F5n8?Y&kep4^z$68TDu01S%@ZW~gxQk`y0{uWlgxeu0m$fk zO*V(l7xw@Hj$0js!!)=NfU9GsLsXF528%@)Q`3qPS2^c3r2 zX-mwNjGaiRP)RX~^@16>h^+IZuh=@9O3G`0*;vyd(KTXltUUHLVgC!2j|+@D$qo)Q z{Ft?c;UmXosj)#9kHdSG;U_{uI?9W9MduQ}i5DOimN$Nk1Z^L)vm=Q!mAt3J&KoA| z<|`My8Yy3$5z=0As>a6Irp_lW&$5bz+>#9o&oP`2RGcQf6ExQ$=1CuhmZb|ks8VfO z#&KNGv9U1uUU4H9cv231$SD{kT{d7>3Jm!`#_Lq!-RW85|?tni{lS z8?vd(O5i{(!)y@6c0B9n*&P}LGM1|oXq3{O3O%Eo(}Xuz+D6Nz=py!>(xj3u@+ur(eGSSXBau(_EJ;z$!33C>VC zjj_NlrpxA|wQRVPpXUL~nt#|h%maOPLz~DF8V7pN=S3Enf)lgv>kuSKmH!h0n=`Cy zr^N>f83eJr%rs?(4JB!zV8A>P<7TrR)`bZ-uz-q(+hSIh_bulFr^RO37*6fLMB;P~ zuB54D$&_iMq=Wf>N!pa+&{tW z_AwMaLw$W>2To5jKo3;bm>pv+9XCg6X)HBOb_5@Sqx`Zb{$N0{^b7VING#;SeaL5m zGw^G~m>5bvpd`ki;;7*ymLP1s*?x?$4|C^fs|&v0J9&^)E7mDv%h+En1}%!MFj*T-WY`3bnB5IAmRmbfW8q1rM$T-O&1$WQ{FrQ< z0Y@5@jX(h-W0!XzT#^W9BT)7O_&AQ@CWgg-or3r8lBYx;rl8fwyc`YJcKpkNCqRe6{neys zjJ=IabYkyO3JZ3}X^tcpB03dn;d!H;6N4`#fU&}a@ep8){wY}z9@ZU^VyPi^gLItW z z596~G=*SygWSjOgkaD6LaI-;4Gv&x%0%GHdlSW~EbG?4( zwkW}@Agvh(1o6Nas*eGfdeAu>!uoJsALS`_{NYwBG*0d??7F)U^Z?(|?Pt2VSAyn} zZvliB;a58_PojUp70xk@#RC%5vY55bM=d>t5A_F0bi#p-#{M=b#-6dJOb&xg!n?~8 zSAD`tXP$G*XT7nji&#V|oi$eNIB`}kxDdm0AS&&m?LQ2FzV;f^9Nt?_r?B6T3Zkiq znLxRVKgIz#jA12!{R>l()W%Qz4>F*vB{%u#^-MzSf7RWGIlu}`m($=Zz*0i*&?QFKG~99IfCxa6D3ej8!76f8 z-yK9!0wL*sTbyu!MKv}lH1i5|p`pnX?AE|viX=OyG9 z>xL>-3Fz`RLK&vZm+iU{mga5ruYgwQuH-n-dyy8yVJ2`8X@qt%w^9oHfzhU-T|{W> z8uM>9vsRoBy*-*D*ImQLV6E2Qk!T2iqld)maMl1T{PCQCc$bb|nMr31vmR6h#4dSm zi>U{daeDBcU)O`h)pUU!ygbcL8+WyR$beF$eR~25JqyA}6ZF=Xy68xy`86ouhx zHaV53jQEgcp5=kQ?I%9`x6T--()vp!%mjUsYy zg1E|f3dis*sJikb{o!w3e+yL6$K+DS1952#v4?<$D2+$#FVwz%U=T}#?hxFZytgb9 zpL$FNml4oUTfb8#w#BMsP?c?{(n@Iz=?-K&YOez_t>Bv+aG6f}j)J6m#XX!KgZu(O z=!9E8l&C{GG8HZ9Q+n9h>R6AgiXJENSZ-)R(nh$)9aoz@_M^V&5Zx&+oBh49D#K94 z;PWwLo(M4^UI2_}U)ld6M=chFTE>&nmfGnNoi*XLo46j02GD|+kAqZptqbzg#zDBW%JxO}MhoZF4B~LZ7SrKF4i@dd;rp zY}1UUZHqbsxTwo{9p{+eHOF}!`Fmi%Hg3nn)Akun=Qhs9H_r7({3PCmtn_15m_2}1 z@7EdIGp`*&9E2+rtg0)sqn*iQ-2F=MTR1tVF@fS0KY^=5bPCfHvZEG@8}RTNWJ{n^ z*x1+vm@aHDj!cK7DJ4{IDmzE=C3dOGjdmT5+ULN3w3H_|&tb#ntAq8{Ls_!f_rF2) z2si6sATDYl;1~BHV~0^Gn{YiGyZ}c&%wz-rZn_+fwouiHT=lJK^v(rdWZ~P->!*?q zTCw$1OSj;!*B1~6;BP=tBaHz^?b(F)GOAt3weRQJc51jXARgd$Y|&>TjeZi zi2erRjz}9i)jEcpnuj>mNuy>Tzc|7f6>Bt8c8s0IC#MiSuQaj4xh#%aKdQMP_S0iulDC1H3;pL^SYOFO)&W2p9}`{o)h0JvKsH+`-qtBsfTdb`j{| z4Ek>YCQfvxtQ*?t#oX`-@@dog{V(Nvg5wvx(R;6ArD=+n!2yNn7Z6saUM3ZZ7q1OI zzf#g+43_&(fMXC1aICIpVRq17*ehr&>>acgriXfzMx$%SEDvTVE|eE;ZqmBdj+^T1 zo9aqaN>QO56;7hUiNf^Y@xqnCSulE5bo5RTT#BsCubhUwMJWWa;#7<$%{Qa`%5l7r z!}bJ;i4zP@g2~Fzqg#)lJQ`QFkOcpX-5L`ky_ayzt#v7dV^>^VIDPe%bz@V;7T&PJ zT6p)WlXzw=oWAOKVIF=*tvXgXJ9q>ov(ej?Av-8-Q*B!zXO^b?#u&{=9c^pI3=LZI z8>?lvhX#k~G)h)F<#ks{S=AdE-&4DE%Yddzg;#*wu z%%L#S)hVH~lqXO)`Xh`l?h55Wv*J65h5X{%D~M0j!m9qt1Ln);@Dl9vix2ocgme|u z<`i{N|eVeyZ^pL>9&DL;> z?VfMj@oov9_#NXW<}3H%EN>A0iUt~LYf`*o5?pt5_EG)CIW=>XOiQsvq59&riExwX z4Ty`6*`Z30-Jb1toZU>W3q6+)i+a4`*}ml89cgdjQG9b7jFS-3T0bKrgq5y1_d=unUS&RT@rfTnoi+9j^tZ<`zc&%FbQ!<4nXfTm=C@6Z z99T6EL&$&zD#qmTies{$;SL*4#YpEDC0zMc`GPTsrc7XrWP$txb*{V$rI3qlLNSQ~ zXi+-R^Vy1rB>0hd?G?0U6lAQP-KqPM-m(7erT!5awRG-f#t9%;hC?uvO@LA%t^t%z z?@!WuyrvInW2qOFIoBwI!9BmN48l1deRXN+RF*sI6JH{h0yeU<8T^7eTOmG>FO1G= z>C8kfk>6Nnz1+*atq^}jIYxv!Tjn{j;z1og_0}hTDZzB@E#&JM#HJ|RZhMq2LN4(& zd`R&V{Ao#}C-h%Dg)l3Hre$w=LJWpQM+c()F|DU%Y@SkLacr~ISto{%qypJuJjGF<>rq+zOl$Yo z7u#@{`NQZ8k~(Ea(JCEIwKJ>7Zk`NAI9!0DesMDoYu45asp5Excg@J5p)vB%3ZKZ% z;3h${VVGO25Z+6X14AKpr11SCehr7hQA?wcR%B~kOTT%rDb?P(P|)qYw{5?>#wuZ!U4O)-)#;bx6!!g#9AA za0GM3z+Da4TXF1#g}>6#0cTX=txd720h>H(W`bQCOWJ`JIQ41PPG0C#nzm<)DeM# zS+p9QAV+5lLh-ba6`xAPY1?8T!EGnFblSzOo#B2}ENR$N3O?2$i+(76kc!jkjEg%L ze^oD@LEq(Upw9?sQ*5+)`HFuq90){VOfu-4+TIXRNCss{`$&MyP8TK39-(_%Yc+xt=(S6`wBZ;IC&#Hg_=}XH zQ>(IvciFr?*bqqj*7pJXEA3#QQq*%z65~iCPz_W9>1;G+5qC(K^yYDXBes7?C~8&T%lB&>M_rp>vgo%wBCIevBOp_{ap2 z0Vs0v0fk;$MU_~{nAo-PR&b9_-fPDL;JzRD00Xl3M#pi;X0L#_kjGXlK3%KRJ@PN& zlT_EpY+TE=ZcZ4-2I3U_m!MZ$W<~XD{n}M^rLNk>&{f^2bzQMUbi?DWe znbq@+qjnRXYF9zyvPMmIuDXUd0%()%6`CJBtq@!PPC#G+;rP+!1I>?B%%wKkDUfcw z3ii?_JGKAt=0Ha9&ykODFnblqYQx&y3T*&E>U)^it7ju?>;|zB?PWt2ANT-_DTc|T zF$~9VHN#rM{*j`9s4jJYT5N4Ch3rYP+TzC?_K%fC=qu_Drs8Zkrn-S*2|jcK9BEP) zd~D)jN5bR};MmCutw7i5rD5`^5(?6!o)s9^Sj4Zg2mYC_jf?Afhd`Y6G?OgA@WFfUD2Fe=JU6LO7)IvtTJ4MRxuhS&GAGKFMVP;zqDyRB`&&0jj&9d_Zjuk9{##V z=nB;B6rPONYsE(mgAYu zWjM6)a={`pp;&wx-kBSniv5XTLp%?tGI+oh@=(Dm98`hhQl`VT+gsD>UG>CxEuBIu zM2Jol^of5$M-eZ@I3|N4;#h^)!!N-xFv;7%(GtacUUBOQlVSO&+BwGhxn3(iyjm@v z#dA!;lR@Gfyza~}e(Mh?Q_rIIitt{Kvt%dn)F&>cr?Qn?Jg5-o5Ew=?ldJWj`_u5> zI3h$qc+tz0U(p=076cqIR)zQn)KM>HFAcX?5!Jmf!B9p5UrfS#y>)8GC!VGUvf+I_ zso_Tm0yn%F_g=9fR$~Po_{8d14KLTY)vU3s3Q2{LTE0?ENObXN-B1}ZFm7Hf;SH6Ks0!@+E@gsU$y ztIN7sT-P6~YvXF;sTySl!aEDLkr^%XG&|Nmg)7g9O<=8@3WB!?Dn$+ihimp{8l1TH z>|OzTNjyP{)JkZ54J~h-hl;d%;Y$zAy4i>hKk8}NhM`&! z4P;1?5L5&-?=#p|A$(r+vkqXgPBT2PpzIujqvabQt6|_tos1jf!>X zyaWNTj1|5|jD_0_3$_r@#u%sU!55cw+zO}_;@Lx(i5sGPV;D-m@&KNT=SMQ3yyEGr z*km%(C`IB}S3zzRx1wxdnk@zhT^dAN8vxFa0lqcgw~2H1-L(qp9v_g-=8Jwsv@Hy$9u!GnfJ04%%{yJbKi zsUauG=tld3q6ocOM~^vL8EDD zus+1SUPBtJ*Xe<*Ar00`W{o(5^+c?iG+4i+Ql`PGCW}Rw$62gOOuCT8ic#l%P{%7~ z#XvC!_cF~U&{K)V7CfjBS5gC9m#y6cT=)D~-E~~eNu}t(T^J4U6#~pvRxpUq-(|Kj z-|=#U1UH`{y^D7`9m*L}Gd+;COStx5xVDb}NIX(%+!88x*2AOW9sU_fodAkziV2J%+JRUxQ?w-*DcM(1JJJ=DL-B?5KsGET zJA)uFW>T`#Vl|{>pM2Y_kptW-#7B4_Ys5+R>r_fMBqjSLDrHJG2{ttnC)jsmuO3!~c0pT6hw7mi4Z* zxD}HcL<=&|DBzalwE!uv2%@r1*<-y(cIGiOr>T!RX-FX}L@8d%+N6(|fsNHBee{V7 zxOQd(4FWV@l_9HR&J4gSL{ENg*S&1wO`PNGQ?_!Uqlm5>XiSm1tH&RY;GI|O!aEpw z9piP3@zYdZnimQhU|v|@mNBr6vVt*q4q~UupdWiv;&v{A&&IJ&MRg6IDu6e7Q**ef zQhFf4moxYg^q{k>d|#f<2oBNB1k=MCP;$AgLkFm<&gi-Nj1s+_SfM!a(kou#mzeD0 zu99!&6TinZW9rAo&e=qKZ>y7Y_A_`zrgN4X=bW9*T$R3=SIh>a@AA#;@Xgk;Z)RqO zO1~jFBOaVDowGq+9W41~USVUTJNstR3zDgF@`B_QyddhB>D9fypJ~yW&^J5J1OAh% zCw(){UrA?*a__pA_H-xL?3L&w$wuj$Rft>AKqucUv41D~bFY*`p+ttg?yOqm znudX;yc(r&rX%t%IIANkq=Y7GrPeaF)Vj>B^=!7x)Or@FJ)?d6H8Vv63@|B>{=UD~ zw>gF0hg(wBo~^H+ri~b;{6CnNioSo!y)o4|{xP*bZuYr~x~= z#E+eKLruWZxrH-BSI1!Kco=w|g0YOlGrp}HUf=!}?7Cn+Fhi&Jeww%O{eOiF>!ig>yyq??+F65a-amm=Zm zi4r|w=F<_5v<1-oTv@!l4~ieSgwYbO&?zf|vc%$LT+*zDXhsB~9gM@wC;rBiv8u&z z=>bWRkg^HVS_vtxxZaWFF1b->H?lVF@X;QhZ$hpuQ=OHIWchVYwKy}lSX)jD3b2Ig zW7_TH!|MHq_JWv|v}Q$Xuj{RSi3L&aHK($J13h1coNG> zZeq%~+C8E7n|s3Iz6IUK*LB<4*`BDyBPpr+X9%Erb7AZ6@T=X-3mCr97ckTZFX}+r z$ncF=>gWajm-X zmfFT({wSU&B>?*fz$rFc03d5SwqXWZ2VkokpE4d<=GT-=kg!T@!5odWfY#>X%Tkbz zH{*_6e5iD`_BQXVigP7d z!YCgHff%T~X12YN+78OL2|c06_HW?!DX}Kr!2)SzEy`h~>c7z{DGnwY!hlhe1sV9& zD_H2n?@x$9z(oJ}YEO~A8^Y03|MaSbZshD3)`$RFg_=&YeBw*QCUiWLn>XIRZ(_!$ z!5_+Ds`%w+SjXcttRbgZa1Cp47FZC?=lNs?=oL>AD03d>qt2jyDnV&?I$;baxKq?A zE_Er6gr-9fwI(%?t1iz~Z)4hV@)8u|Ofs$G8K@xTqjT$hqS!bcSkUd{>B7_I>#g*9 zn0#H=(+`IA74AaGp9$G8@K~Q3cc*K<{E;gU{E?4o@*xufF6HAif!y~ari9o{%hlTj zp9phM(D#mY`KW?`v_LZOpO*eU=8}BkL5_Z;x8&4XR6ly0t5!oOwKvhnD$$4ILKd8* zxhP=1lKAj?D>6m{74TihCd*F!m)Kx@a?y+lmJJ52JYhMebGbo!Ib`qERe5SN)w|z!h9`OD_}4dYlw0}@CV}C!FusBQY-RIdlR|I*<;nRY^^#k za#(vElQOSr*W)tur8+hbm}RSX=hi{>TS{>tH;y{?E9y^Z_*7Trv`lbw+V@>GlsjA7 zC9~l=ezJpY0Uf)IW5H!@M0{pCeegulkLKI2<%-vi02>nd`=(oa0acODEiQ!GGRP!Z=^mv z4YCkhe@|R&7r(_14UY2IYlES6_^>9#$-R~770Odr=Bne}zy$l7ENdq#>is(Z)Cq3k zpe~hWinFLoprKldj{$_O6s2b6tpEz|;~; zn&@Yr)~xzFX#mXk?`47C(oehi4VNR*2Xg7FDqRKyd`t$D8c?S>{+jZd`QnY8Fs!=$ z%u((&aP)c`XgKpKPZF*JnbKIiKSm-gfz+?xjBiC~&7M!I@93|3o!Y)|V>y=Lom9CE zZ6c=W@u6U9FVKQsS}f1uaA16hK>OJ_LgzER6*O( zWjWghoF8D~KN9#mI^j>Ez!K6K{{W*6{8tTSqDvt4>yKn~#eby4pV~0+r)vX$Y(g~g zM^oM5&w6rZH~iWNK^^^616Z^SKxG>l^Qs_)C~~ zxKw=7;6xhj>q0j^Q@JH=a&A4oHJDDV8r`^1cH>*H0a{I$5<8 z@i>38cCx*t6sPl`xs3M_(bU++Rfvr{2o0NBIu%J|sOM1wZRITzn*I{YhGS^B=u!Gh z=X^DH5l94UcvDFyAG{d|Ro4{NTp>IF%+&CF9?D@6QNA!>S61pW8D{XH#vd@MaHvIq z>esKaqxYX`&8A2eNtV)EV(AiyBwas;BY$;XszYY0)3em+ZgqN&Iz6wtC6$Z?&ZUCx zG*EZ_MYK?L)AksXFjhl;r7>!!-qNZJ!lG;c8t8-!!wFPJ+x+7#kJ|A^>T~)@!YYHx z#T) zp-++fN3C({%==Dr4bQ$+`y~MFbX(rnVz=$n$BiZv)j*v)0DpGS;(u)zb`gv6gY#1Uf<6umPk4+`c;8CuoUZ zsNbk*Uaaw6YEu_`b?Bc4U85eTrI&VfEB(f``W&}PV9#uIL+AKOEJsyFP$!&gEv&9p z^8e`mIvYgcp{7woFTR$SB+4#HPPpn+?v$3!{bXjT*86lYOlJ(b z&}-r%)*BP{sqSob>MS5^hW&1p4OznFt)L=(7zo1HBxaEEJH?J|0vPBmyD zSSBKU-IrHA8NyivGw+QwM7w2k(%3E8_s=N6gjP4qzz}p=sLHL1mfAg zVlM_TC;T)Q%Ztj`V5q|Kkl(@Bgm+q*X!6M~^d|&IJ_*Yw>S$&?w~kM8(fe65IxX?z z{y$Gf#IwV{q7dJUH^j3!XeaSpZ1=nl**s~;W-un3Z>b|lAJh?~5Y4P6ODDVPWAK~zyJ^?i}?ql*PP}=Ck!K#RZm-hI#N~) zpbc=^8#qs}$*MZTjn->JpTES6`o^*De*lW!!(noUze!m&{N>G9!*8ZckRSL`+y64b z#k0?z(q5Sof22p;aUuE{D2Yo0xb})Xj8tY9u;xi%u8@We$XOz?P>ifqKaw5=@2gZ(D%@XqUsNBixUGJfT^ zlU3{o&!D%IeDALuKM(0E-f_F`MIMG}jNxq|sNmGT*|r8!7v7a!msvX`n4vl3#E+~o zoom>`E!NU|z9s2gau{TwbDNw+^%GepFlPQu+kx3avrQrj+7)KIF4?Z>sY;OqOJUF; z;@bA@qDTIL@X@odhoM^AfxQg(5l+K)bdq2$pWhgW?9o20zsnWs0h)Q5qOtd!Vk|!^^?bSHpPgM=qOat>XLs;QbOQq@^R_o2gI|2zj|Gha(iEwJl;ujz zZ)_oTur$Sv)}2dk#tG_T>`a#27l^)eCd(w)IW8+t*4;|AJ9P#mVE9A;8y0VWg8U?l zdT0bNKsK1LAu_9kk&B2f#aJR@;Fd+Wsh3yBA?74+qYGj`2Rah5EzjwQRiA-b_&5l1 z0;vJ?w!}@{rSIxm>+joy0Lb$SVmg~6{0yG5k8%<1D7X)IK+TCDA^j4ryZuxuDJQMG z$MWXywe)_~RZ#THwY=|DX=SRmOQUu3p>+nG$U?jVBwUUk({4biqV^`_Yn0q<@T+W6 ziACH4I#7NBG{-8@o`n|&hajitRdUP{vrz&&#Nerw7G50s2QEts7l!&P*=C8+D1rKG z#@vR-F7xq)@^PtOahlKiQ*#rLRkov#{gu-sH;l(Ahz4NDjaK~RUwEQTv17oik@<&YU@O z<~&@i4U)Se#CAU-7HFx$g$s_369TBcqwh2aT4Lrb4rR9TA9nh}^uMj<)=r{(HqkW(T)r+KQc-8Z=IPUN62Mb`ylyndik3LCIJ} zNx*3f;ggQbSo{G+k)_n4^^?zyq|aQ@NYClTUe9d;;F9xVW+N7QTnu1S+^}EyTVKzU zpf6Bxn1_G2uZK>TwgV2^g*mtwn|FZ-g7f-v5~Ujh`{wt5q_rh?vYB#0}w6#p* z=@7)bK0)ZUlr#61WR! z2w_Q?lES2M+9KzHn01*Y0kXG^teDxCEIU^;$#mWISEdWoAPD5qdNUu)aaDzTDo!hr z6~%e5Nt22?Hk4)Br1L@Ht~VKgB0k*p7k;`Bgu6EK;St5XnCN|?*dV=Fa!l8`aGn=6 z-PVlHX(CqF95|t=@A=g&oC9b3^7BfzdJ_CZ})Is|ATxyKYYPw|C`6zY1 z$_7;3Ym6WXQehDSLqrJh_SB&CAWO-D-_kaT0Rhxs-J?@uuM)iWkbDGoqSK#!M^mY# z24s&&MMLR$ACDn1m8(#Uv=MlmHqT%_bczwACCQ0Us1-LGkd@|mjCvrhW6A*BmaF}| zyCrXe&GY*A#N$p0fd7Ej(FmDg%zOc-sYOkN`d!a_p- zBKmCqO5K^T_AjRx_KA0%3m+Kg>Q$FeIYeEq-BTOlMp|%kjKtnb2!HqP*D$>_h-#~s zzBt>%CYnCX1FXb_3!;jNuWNFiz$TVV<`?gFxA!?HQ+j6%Ms=`D%q+d4t|Bir1EO=< z0^9?NCo804mhzl`Ga?r%&LibfCJ~W47D=Ol{_=w*aJ@6LqJ@k8kIk#zSYN%9+$s`L z1y<(w$I1o6Emlg{#uP&7BTvMko-6d`0(Kln5+wAF((H!u{j^&7VW!@M-92}A$PkabYKx> ztK?e7#{#v+oDlVcs(;o+!1987Y1Cd91xO|xz`S|5Xrc5j@Td+7f5;@L0&2l zu_HB>Xk@x-1+pb@bql4!T1wDUXbz-Q_hmay>Dn{XRoE-^-SJI7aOF~4D>HeNP!H((|aE3EA z<}QIC$TlAiezkpHnl5L6dke=T?G1}Fl^uhS(09>2rEqV-g=cjf`#ushKfRb5Wyx|d z7d6M)l56C6g5qa0&(5}lsSfd10@LYThL{;iv6i-k32EPv+3CM%Z>6+>UxBbD=SQM; z(--~)v@ZnN?4no!OzlmBWr_ndKucZ(Zea;6T&=XAc$m?#F^FyCY*ZJ99KJ?$e~$d< ztw{G5apTykr|3@HD*O1qGzOw($H~C4h0fWd1ccN&j?J6LfWz0^kIL;dE|8TMObvDB zEa-YF+ds)JYDm4kvQ)EASK1?Q>&g43XgyjapUT^5oKS zY%nV2pSKRhd(B>iC#F?dZo!8+D?7AT$=lP55$I z8wWE|$F!P{_`3wxk_>-a%_?Lv;=Rh5xgcuZMZQMOTc_HBo85wowcz(DC>_#7%=}R` zof^T~^Q`wm`5nE3Q#_gwP~?tCx65J!Bky9#LYs#hIMpqmIAtK?buM^&M7Vd0K@%a!L(L} zeWJ<5+Q4YPfnvV7!Kn=_AfEh^0p^;?UXA41gQUBEiuhO%nYARZh3xalW;`4RpJ1U* zQ7CGjmO{-7V&V}A%=a^eA^Df~JH|@;;76@lsOM-R|p`C>J+xMllYIk@t zoVdAMnwlA8Zjn1456mn_UuZMWvC3KG=y00oJ7$`tf<@5wh(LU-w!nCz>;oRF@v0>6 zBsXUECl{I}YZX~CmJiY=y7d=m{cmK678)L_gDGcj*#9|U;4isIzLnB{M0=Y;Zg<0W8mHcq2D|CXZJ*i z>bq1*^pW`yRPWeOmpx<8vTwNbAcmcC3?E6q2V_LKz5eU^g;}Y|Xl98ZER%lv==>@C zEpq9cAm1)o3zL2(tioggY?hik5J2?lO$P5zmkR$=G}{=xoQ_DLi#b& zDNVHnnG7L)7vF8N?zHj#p_G@ql_EQY@}p+1l(*z2lpizGwE@N>JKznIJcJ72N6o=x zTEf4J9FOpAbs_wi3E1j!bEppGKzArZ83TlWJD)O?x_L4bCH(Ku5bjB_4?M-$Yswm#?moJj?HMTtaXtbv#fvGW*@hjL3 z(}RA6-tklzl+yt!M?HE`ooK9iwd*;|DGjgO!f$w^xZ{Zc`;>ZT=3HmimO#uY-r_XQ zjeEc2=9d2kd+z~PT`TX~-pB_#V)ibamXg+f^us7em;d~WFKMfev+}{=d!D1cQo?Vc zY4wz28k|}Wl1inR*uhpwQkG(*(SjU-RMPU#Zq=4cTQh-IGIL)EP`f5(j_4tk_nSI4 z6!Fl;fYjhtvj7%=uE?)f>`fOl^%h#L4_|Y%?CZ{s)X-)_6LRXJaXTViogdZbJ@P&{ z$sX{?Tk>b$M_!OW`#iE){)8TRK>idy@(f3rD`q6YP7U_bYwi_+upMm6LjPk?gc}#2 z&#~!yJ!K)7>3%cMU?;pA6acWw2besKlji*GFua{!`NfSB1Ih>!Xg-|QA| z1Bg%#5Fh)+<_QozZZTPWS^}WjheT*;)t6x1#L5vmIeOi)66lql_S7~AhnkrgilUmKMxzXR2Xf-n$ z1cp*uuYxi0DHt85XrJQDnd`t% zaVPK!`t46aNAq0A^dB=K-W{sYMl4G$d!l=8-nVvKPlvlM7O&Vw9+_>~YfVIsoVE+V#sO(qd8f`92bUsnUwTJrWsd4@i(IM7N-1E+WD! zPaI|?RrmJ;&LCb(%_-m^W9uPO#x?uxx@&p;7KV7XB?2}%2g@es09MKx)gj7TP(vQ| z=lmWD3n7$9fm~wvsb)y14UZUN=2oHwAfU?HxF}IQ%@RbAt{SAWA`;nG58dhoE>1M& zf_?VSH%yeW@@Pf9FJvU{u`gsUf=5Nnc|zt)``ssG8d1#cYNPyJg6lM^jgzR1oB3z& zDh`_Z7dKzo;vzjNkJPSI$QZ*QbBnQOHQS`2pC^5isbOh~yjr6X%Tw6)?y1BS*j- z;uTcvj`GBa*!k+CB42)vM;rWrXAgA!ur8aM!}8#!Y#MMg^>**#_h;8+rC6($Qlg^m<+Kos6mS>mf&+zie@`#?A#W6FB911qX&4v;kq$dmZEEE68 zk}mQPRv0U+kRuQK*x*hrw39siu_lIk#D=p*A?+;)cRdWqlP8Gi314%!U}Qn0zQw$_ zHv}qrq7|j{sOs`{sP;+c8<2%PrTcrni0DxEvX<(Zna1sowV@BUm8_hUDsgiXC4CX` zr1Ke=LKt>mOaz*ksmsaqF$E&yW-K`^=9ZEDu_RM&G9&_Zu`A?T%;xt+$hVlqQ_uoL z=jzzN2_8^abzk5^{M^lUdWTt|*1X+~6*w{njKXBz$QS&B0azstUE2yGoq$g^iG^Ch00*?^kMAt^xCD*cS zg`q0>Z5U`Jp2t-RZCX|htrvAK^@(tnvLp^U|B48uPShOWvEXC5LZ(m6$oKMdg^a2h z|3L32(WAv45sTobK^&tv)eT|{+?|#3^q)z!qK>ac(0na|M$CHUJlLJH-X5og5Hzhh ziq|+z4AF4bmD@R#?{}ZeXrKq;G2drd&-p9T^hbmT{BPRzd0xYLf z5^NrWB|Axu$tvSf(TB~JgPB;-*=i6Zuz(ybMffbOefF|BgdHn)PT{G^)F_hBOU>ki z@EPJdhcjP}!7*NC$*3Tj0gq(Sa>Pl@;}Gq~d_^;j^UU`nBx@LQ?t#q1K6I%LXpNGL zNUg(jq}F~GYCRF$lbmfapWVgNhsw zBx+(TSL)md(~|BhH!JLSpVS$HqM4)I9HV#ct<-5hZCCkF-oN-zx41~1IfrUjDs>L< zi>cIk=ObahkeUH+Xxg>ah+kZ#&Vz1okvdN}WY+ zF_Aj^00c6=j;XYgM|V*-|D&Je*+t1YM=&e9sMGn8BYF0q%Sx|yM+IglG+}{-R(}_5`IZerbk*r zd2zGIcHqe&5Y-@y;+|EVzyC-e%9TL6_2cpB90{~W3+*I0?sW#u2u050j_8RiC$n|IX*XtN8D7_pkiEnExc* zGlIG2qv1|;g}fFe2o7Y4ta&re`0K)*Q%J5Ye4Vdw=aKw&8tYdyP3U|o+;zBoHC1r# z)fM6ATry5b5kZkUfW&auKq=T<;Upr6xyt2&hhXjc@KqlwiPq!LtFbV5 zJs11|i|0+q1)FFgs&^x4}fUlW8rUh^XsYFT?KD?QlTzK*8|Ki`( zZ*E6S6~{k#X}=b!4>>JHuW7&DVU_ zYtf3;_p!{218KPPDiO?_lge@8or1U&uG~cD!|Yei6&E#Il{#%0^%8T%m+nzni?+ZO ztSdt`JKQCv6;BJf<|@JRPHu&L=(_e=!Do3ZUMmwk9ABzw3pzHGGll!IknNp}`k4#K zY{~8ma>wMPHc1t6uGtIwkLpaJ9JU%qE_2>u{wde)XVP+D;%l^BCf1C^TukPOF?<%b z9h5s3(XnjXQwm?U0-;Kr+F^jvzg?5cB}j!8E88J%Rbv|2WMH!FiH&KdU^yL6&IvAd zf%L*QQxjEE0J@m7v_f6rF7p+G>!ry?+a%^TXEWx~an4>HUj@>I&hbUreLKG5LaY;u zkdh*KP%6~%)j)L0<14XEyrkE>H#UAJ9|sbFfcN$EyrMGE<{n0D@Vk0ex_Zqh^wvjA zciqrljTq-Kx?{5ES2=$pXn~z;RRUuIJXmb)ND+Je`wxDL>eq6-ZP6KuE?gRKYjGVy zyUPe_17-iApm}a4KNFL9xfRS`1mCKWR}1d#S;jMdYa0Z-Dw#ZIJFGzpkXKRN)a z9FduOMDBc@k<&}B-;DO+xXrNrvGaAO@)fbFu|yvsmgpmp{B_ZS^O5BN94n)y=1L~X z8lgdBW$onl0h!69=ZR!UMe2ns*+u-CWiUILg7sW05l49ESn=zkmm!-9<(HBdCs864 z;;q~VnS<`dQkT(kq`DA|bRjyY3Q{kY*8+;fvH!v<4Ub(D?)q4!3A%?uBbKepy*mTG z{&O3>bxgsHJ{dU7TM5s%%8Cu_h^U=fyDnXv+zuIAp%b(D1i~|Oncmz7WscIUBDT{# z68*FG+4M;9>`#8`S1#5Pyaf<57YQ8?6!w#Q5ZnABA1NCJHPCmsYaylj-E|OoAn_Z5 zi8ctJ?`wee(y@9#n zIe`f$_V3^*r0OV~niFj;=KFvp{J1v#R|Pcv-lByQ*LwHtdKx$(BxV(3s_$5LdhNPZ zlF(kbN>Y61yrE5tG+o{(vN4~)_O#k3V52*j7YpS)fpYuX7D`;#tY_XZ+`@jQAaIj9 zz{S1xT0N{8HiwLMH)9|(%cC0Yfy5>;wWG$%{z_p3>rL9XN?J`?XXXC5su#9 zWz}6$%u@vnvr1RsAVB}SF1q&A#l?OXr}|xV(5y2;hG55c{ThJ;4R? zrhv1#V{LKm6T~!7JUFZp>p0`hj1a7Bl9|ZcL`}pg_{%hLU49w9O3sLj`FCo@ehf>= z2e+5>2ls=ANv?}z*jl)T+se`+J+6|!JG7`2k$7O@N6zzCi*S>cTV-d7aKPncTc#Pm zlR(^Tfl8nqIgk3ICFaaPE~0Db1h@TBRt8L++!VwwG8*7+*HDLws^aGQT{?^gILO-kpXfciNHsUm`zbYIEjT0&h%7m`mKq_Y#n&zw5~*(gf=%PU`3v6?^`W=x}h43~V4Ro$VgggM=&9jW6XyehvW;xa%SYLTF%MYLxR}dg`#O3dX`h67 z1U~|bxfhZ$ja(Y4l3mh`2!S41^&cO|FKX^Hxjo|FmrEa}tCnqLf;OE#xTnUd3+yJd zhb6mwc#DKxe*A{Qn;pTTU+(bEhFoNtr-wfwXN&eEtF3h6dXV>MA9C?VF3vP^1*{^E z*gES4DPDQGel*aB>aP<#sE{({G&kG{w)q{Q+vxqResGRU{;WToS;BWQ)!DtABCYz9 zU0~ct`*eZau3g&OL9-RNX)b$#!E~jEjv<^<<5GbNTxqv9y2dL~+TG6f$%T{NMP+rz zEmz;hVZL6HhndWhKgPVNm>Q1wQfDq|Os`UmOD-6wluP6FNQGfunGITouvvmVQ8p$M ztm!CgrvA%BUC}yjeWQW=;MD;rHlW{ z+V$y!CXW_+;Gx4E*&~z3`d#S2yI!+cme+5D8stwrmm+#6j~3#CAZXvk^>y03;yR6K zORn3OZ43l?chw!bMyFhoH?1vhigmpBjQ`;aM98^S$V^_U5X7?Y3U}hbmA7I>vE1F{ zyo>7==~J8;@JIS6Z`OvwoTZtXt2&5ouz`UP*ljA~%-tBEQQ(RXJ!K9pN) ztI;iOoSe_nF=u8`?UU(>$rFT#(vy>q_D4m-D~bx|Nq}QNCc)Jzogz6Is*K6)C68;3 z#-EZBIXiHn0%0+|KPH=SdwSnKx^5ux=aj(p%&b`5%0OkT#Uz7EE?qHc0t3Wa{+ zTHAYLMT>vi%iT1|b&ZO+y(reG2PJZ?IY;<>fRKFJ?@uTAT-zT)a-iG}L7SvQ;JD=s%L%U$&%L;>fXG zX)KX5DWE>I(^wwVJ~Yxo5h1{?f@&m;Of!FhQ4aGE4`vQvcWhue40j$bngN0kqQ+)% zJL{(?PkK&kZ5CvfF|~3*O>7r(F{~2bS>wpiIqzdyZQZ0>SA>YriKTPzU*eJUL{Ra? z8jP;6N$eEzs$1%Oy#+=%Db(BAO?vGsRa(3Gd&6u*sqW%uYoETbI{6i7$&R$?TM!I3 zy)3!iM_08F+Ji44BjoCsP@7&PLtvGU|3mlO&A1;(AJ|Vw5e>qbQRB>(D_r$yofuiI z@mI`KIDxIKc2lacN9s7UYpfN;X{CJJ9DY7ym*)|A&sXb;=iuS;!0Rh;Zo-^`i#uqv z9FNwu-tVeaG0&Z0=VK~wQm0JW#mwMq6kpDk7Sn_8o)DE__NnwhVX*8V&|ZdK#>SNI z3iE5amHE{MWbz)DQCXYdUoW+j2!>ti2zNS+ix+`fl@jemNAu-Dkm}}h1XqBNnqiWY zi6c6F^06{c#0=MwvjHe_W)#cC!dEVkcA0JB*dobvT(fcR`RF5+Q3~fZ<}YIrwMy@Y z9?W>47`(YZkrM1Ty?TIxQp>=+1amgPP{f(B3u6>3V;qs3$_YY_40m3zj3K-iae^nt z`w4L<8mZ`wKXpi(IT09y(4%H5zbu4TYp0<;xLCg!H_XZ)_Y?RmX@?blQ2{Xk=(w>> zVY{OgJ`!y$<~Q~|9&a?ni2NkAcbjQrCfQhA$oY5xne}0tc~W0m3OM@yt+eFvha2y= zR3EIG_yN~w%o;bFrN5EFv6cxU-d?wHK6zul--T^kma;Uc?dsxcopn$1|%zT+~~p z5A)T!xr82zbH66OOV0W%keT(dgxS*x>ZEfbyO3(p}_(fYch{AYch0`LZ##aqw!nbgp^qWB( zQW4Gbf3#$Ao4F~c$`7T=Oo6`6W178p!x$g-AIp+I0}_ij5LqhU!+>n2J^z8j=VM49 zka4P|pLKXBW)2pkfOAy#Z7dQP3*?c;)M42dok74=DCU__oCsrI1vf&$YtwF-A=!Hu ziOGjZZfe`H63_2X3>VU0^MBIcp|(G_tA}^(>Y?3qr5&n08DlSt^8EF5{)rg%zva!T zCOK+6A&3Qhl9)VGCHf{P1Kg}Xuy_r~Obwtl49N_4rUl~c56mL`>@eCOKeB~9$Qc*& z&BNA6d?zhq`R)d^9LfLwB4>S$u?C2Ids3=Z7Ag=wyB`9IossOmUa}+13P z<_yxy&5z_{H8=~gd_4utJD=F4<{sBbl?c$vb#75HX^G89EM1%j?VQ>iAOid8JEeN- zlbXMnrZRnq0G!c6&Dl`zQA{=#bCx&k9fO878gB!^(mCoZ@?(zz=v2 z4_g-lkD7z@M~DESyaOSncLeTLGg-&`vR^`R>=8q(XrWV=1Y;}^<>sAp7{)fCS$XYM zj=289zR{{0FH|9U7qfTuBrl3%wH)#<>HP?KM{7J6 zCY|M)Dl&t_P<{P-h||mff0|WU0_5|DvaCv!&vk0VJvV8@aKTYqL~7-99T02;?I2xwnm`TF*ya0!yEr+ zi*%_GvNTg*;oNAHPB$q49mmR`@|WRX5pYJb8k86J8Sz+Uffe@9JFIDfBX;P_?^ zVl1q{RWbn9naetA^HLYP*kO{d0xd2nb3wj@{b=MXR~)B~1a$VN{;rW?K=b0i!ZZL~~!3YbmLM0b}59;e6{R^dYj*!+alZ~ZBhbS7q*{RN-mZ@@5 z`GL&RfHO(m($@xSUuu6>@?&P|dC=h`Jq>{ldai&Q8PoWWSy!)lhf&GP(Adoctg3i& zmQb=rMO(vFjYKl!fB%|qdS!A;9nM$W`{GR@(P4I!3)OQq+n_kv>g|59~7LUMNspgi(hD*v}unYmkhAo{Df;DS`QCeeA#&Cy8VyV z+e8P^%M3HQjICa*gU+nOP$G%`!}ZGH z;(>Jn?xXH&({sKfV3&%yvn09DZ#^KbPq(eJ2|DS&XC-N zIYvdD4K<@|Q;)nn0Se?)Equ*+tO#&!QH!}=;1r8Vufp%lT^Ddd>*8Xds?d+XI%e<| z0OZddX96;koapS%hsg0WeNf*KIex=NMTC7$)f@vj@NBOhPgWy#~7?X1IJSwjj2j z)AX=Ez?_EIxCwvgV#Mj$d;#C8|7`BWpnR=AfMtT~m!Gr)&|0cf)ovD)EjyK_E9kDW z(x(+mD#Svsk!i5IWEA@eddX=*+{BDqVDX#5< z5R?7>r>c(XMkq-$)zws-OKaDq4y!E`r&9uJ<3!qK3cS&zN6~egS??=9qAzFHp<%Dt zjS@@evacetx9H(PIipP#razjvcD-VFeV;zrEMzC5iik|<6PyCs{|(60I*oNy8OJ3E ztgtax020^>)=bVil4(0(gAf-tF#h%jOJx_zdnUhMv`{-hYlImB;u|&~%|Vq7Ugq6m z%##LALQQfKMJ;HY=jxycS1r1i6&pi2=&(ZReIb(2dfSPd{0&SUEoF|B_9yJ@(|Mhg z{uYopbdpdx`{Xw5G*@x^h1Yduhm;^c&O06-@qx4&`s67&2c$7qft9=PK_Ng!LVU}T zfcd3mxq;y_Mr$hf!4Aa5+M#U?rt;v*od)0=6NtLOwN zB2>@S)am+sQ=zD3^1n@mVz`o)i0eBXC98;#4Slu{XB#z(Z6PVnIM}4$kH~@hb9zk( z+tY2S8I1ZAHLLXBHEOrwaHO~``8s|-=6$tG>rwhi>!Fj9WYR~Zx@l$CT11YNIBYHO zp%?v0rTMFjhnN!beg%G(9b#UfiL?AB)J4m6v-^AnC}8NCl@%& zrr4he5CvP5Iv3R|ypG>l*+eGgQn#}Ut2Or;Klf9avQuoX#nT))^a!bDtd8Y;5oq5& z9Gp8N8GCS7hM7z!gjejn3DMb53-8*#DUk^otHQOP1wJ9>cQL)2i~cGzve#Sk?|7`P zw8DXpS^B0Bd{O42VhFwiqoR)BR(}LKAM+o#^C6TGinj>zA}i69Xs4smOo?$uc9*XWcQx7!*$^T@Z? z01~z9+5Rs(O(AgRZeyL?hVJm+jNBO}9rq;pr@QzgHmY&ry`I9_Ag%WmU8+STt$)!9 zDJmUxY$zAY)y>wTWzQ4fN1>XDpF4pEr59(Il(cwTrTai@#8ubUjB)go zam?C|`ZO?1&|vb)q!IJDpWtdK66VO#-Aemf#T*NyBIsY;`%u1 z6<{0g^mb3*0cZTTW`)og)$%nARb;s>E!yHvuPyohS*aTF%@PwA)*v>ksc<)bQtS_H z)oh{pM0Qkd0j}mhWz#l+Ka6ENJ#d3_^n^N4Ea6SeVZ%wQC1-Y#hJ?dv8r#n=RaLZO0Z3pAQH#or~C3{KvJZF`}oQuALJ? zs566WXNJOEZ?Mid6BaNVGcx)|H{8E{ZpV&QLWGV)@c3W(s^Uwz1h$5Jj&!Zv0p5u@ zTZt;TO4v;)tI40R)2o@Vt-sd^>)SqUDvVN8{%7ui)spp;vfHj(h4Y$#5whr7`&bPb z>B7e(Sc)^OK|t3nM(xuNmy*+7`0zUr1eC7`Wd~>*nNK6=4HI`frb8GwbC-?c9eXS3 z@?h(uG+=8TB(*kT3oO0zTd~_L+t>%N36g0cQ1uxc)NXcOSvJ7gqMNqbH)~3qSwaSPug$FforKn{lvAagvnOPdG#v6?JD7~RRV)pg>xB9{qtEsj}@E| zlC^U=n;Lko#@Xat5Li*P;^|{Xx+ECQ=OeKP66EHfk|2t=Je&KU)#@X`6D`m3-)dg0<{L%#f3H^s+1|f!*m7Sj8j=Y&kIjkZMi~mnFCViQOQc*Lbhs z&&Wp~wn(lsQ|9+0xWoB$2@bKgJA#w#1OykPBM9yV=x!H+dr!eDo%mF@_(KfpK0kjK ziknnqDK3#iaraZr`4a@kLk%5Y4p{bNzdg;uwj2w^aw+QH59qrWaAMBAfK%g?`8W~v zOc>AWosLSjG3=y%tUS?okaSxgTFiK9T-gf>6Hk`G3JCVYvB{@>Oh3xV&6wZ1W)ZJ^ zi1K~xj80x7ifee~M{OkDSCAU|FQzs@=NX>3Aa8#~P~j+4XpW zuEEEODOae4HMq*U6_`s=;#uUHgrIQHXQ6z@$AKzfuX1`OnWBJ|$HgN>6)>79*C1a} z=VQ~3He;bn@km*ZDDg0|kSL$ejPe%@+!uNJw6}n2jmKR{nv_{MRvZn5r3s?CSVt0CtRGnYr-F zdb`rsI3q+Li`z4!3ttl^IftfRZe!T8umQ`&weh|=*hxHP^Z?U*svM-}Tj*T5@@i9I z9nwJlXH#_zwr3XuiMmw~zWNzRjmTTiOqdE4OJQcOXezp^eh`0MNYRV(JGw+PQ)QTpz!{TU6K+Zm9D~=iXj^Y-vFGZXYS|px)N6UN(jY^rAl-XUM?1ktP zAFkvJRM=XspU_lqFno0xAHe%M@Tz}gxbuiTHB%}X&n4H=MtmzCF}v@K3+Q>yy5wp~ zMYpcrQzvxQHmsNuS*OOS98mjBIyjv!YhPLRPbpLTX1MbWro2a%aA%l^ zsQRhOFj3u(Ku)D}Zv{&lNs=t~KhNM(MF-MFL~HmOVl?HkOBtc#tGlb?ID+TkB#5nn zJ3JDM*|sx5B@%ZY*?=B?zg!Yh3-?HA&uU^J42d+@b(7G<9Ku+MAbVksObY2KqRt~l zomm4hI}fB8vBbX=mE2JFY|7hgDoK$zWvG4dEW|^v=E#h{>NE@#s~AGQIoDe-?Fd#TuC4uqlgIE) zYdzIb&VSsJA$EStUd|C|0a~%RxfN-Zlu0(t`F_hq+VTOmWm@Hiwvx{#&X_21zI<3!fPy=ZeAB{-K z?nQh@5fhpeA}MBik$fn;7(RkdS{w+X&J?cRilck67q=7&!()ts6w+SWnBifz;XG{^ z&pvJQdTz(Z%ck=1T1+ZlS?WXS4S380qZ&R0my`G9Mi>!noGoF)yVX@CRZ z)G;{#*xPu$J&nLOUlieIc3B56iT~N<;|SKcc_H(Zdvlm zu)fKGp`Ji+{P*BLn30BvghCY~V%Pr&Z{~P=imgeWizqU$QIhMT7>4*PH)U|1pqSU$ z>^Q4rD$F6uutA>w!*$r=t5RorI2mGtBxTBe1Mx)?;-wg&k!Yb8L^v3hK%+ zq#8HO(^gh!;|a53DAUBz0Av&HyckaH*WWFal{l*J49UX*bKxJzwsCN^Nprb2Ri;fT z4*^e*=|~-AN3&Q*a}uRwubwb#L|d`rS)k*YB3Yd8W2j7>kgc}0WT;VdpkM3izFPCN zRxqcQPvB5(+G;tm*D(o<4PpzFlal|im^bPc(%;E))ExO%mS@dE;jS< zV+*;lt#|O`UC3&rWheX{1j>BJ7ikkA2+kQ3!y*)Cn(D#V}L)zu{I zJenD9wZ?i?z9q`Em98sk)y%ldD)r6v&Q#gh@&u7z;B+YvaSL47Hx~(Bvf!phqL{g0 zO?zUAG{K7?9u{RfxUr`UCxHn(jM-^=(5B}cZ74mfe-m%lTu{^ITv~@DY((OhBnRVZ zV8MM~p!q3onQ$@0UkSl+fQoavaHbrm;u|WTKvZQRQsIR*%CH(mXw%^Eq|jWesj@&2 z9$#W?Cvbv|a+E}ngwM`$2a}qr%-m`UJ$NP9eIv(9N21lj#m+X`8@i%#CU-}!U$?w@ zrf~1)7{j2KF)C~NgeN2Hxn3Lv#9k~TEl=%*9nW19Dr$rcyhXvXz_lkLP;c-gzZ(7{ zseL;x5AFb+cFJvF^fM?3VZwOj@QXP2sczfEJKfwzgC06ADa}tW&6Sa!h;-_!h!YcY zqLH|{tVtX%@n`VaP;S~+m_anpH3uYN8HoL2h_~{T3(RKg3FKU+v{u`!SMnwIa!XBwDvT^HSWC>Amy!nheCknud61|0$f;tpvT zO7R$a^c(3M+*KDj8IT zybMr+G^J-@MAmK|B7 z?l+EKk)Y$a&Hi8NKvINi&vSWgIbcwWRDhbm_Jb> zPk?IlrW~yoi~7prH0Bs}1q)?EOY-@$_Sz!WDze?>^Wid?pBEafM3Q5M^ke-1`W;y` zDP9P&vC`?vS-;HBZB-9o>v%w1CSbLw6i}n)d(w;x>WMj^mU^IGt4?A9szlrW8$wxj zTMDYT7)59)W-4-FUDHo$49kTzeWdN*E^Qyr=!e(jS!kzrk=i1B`O$4kC*CNm$l?5! zk%tm(QK%K8sIp;5{+cVlWGc2L%wX`Ln88MNwcq6H5R19RHiKHHNPzb?koT4kbF%yHdzU0n zWi_zqD?SFm?(0$XF`}Zb9e9JC=4aQ4Q#Z8`g0WScOBDD+~Am~Xvm4zMGy15Hsgdpb-qvU^TG>-I0SUQu=;We>N7s zP9gE9wt1GyL*&U^E8Fbv;-`vg+?bk1+akolNVuzoin*xLA?e$g5P*O;+zBjqMiip} z;q06Z_Sj#`(MR{QR43|NFqWJ}<8gC6jjOa)Q6}nLFq*8_elKye=)vlX6F*4QzQK8- z+{6Qrqj%pj_fELL!zrm!=@Ej_c~ zrP{BS{ncVvC8e+O$%MtsO;WmmcDoaDziB@g@(v)WeKK`<5A(tJQ|*__-f{;uj{?MOmI6b&8--PGmkmg+OfDo7GMN0`K)Ca5fklya z**x2W<+8uk=kzdfhXta0?r?qyTDqRc3h3h{YVOM|K2yqpnKzRnlCw)Xjum_sv@hs4 z;LD|ohe~h2If(B!;CR3G3vvf6eZ;dvlS0P|5<07t))26@Z-l#kk9sDOJ6Bc-LCbs7 z2yX1B1V!YStF8Ou;2Nj}?Nrnce&lghP-Y&e6?6&JkFi63R_EaH)fm|V`?R48fkKQqymuKh54%{4;pOsie1@n@ye+Rwr(-veN7(3X41d~>qf zak%TxWO?v>!6Zp|Hg>t#vBlx_|NO=3Vuonmy;0Y)j#>_!d+D3L*pA|OXHjTv2&)iI zw2>`y;kEi$w@rn(^!RY6v5n4Qznr1Xvz2V~t;w?$&C^MAjulF9hBBdDJGukif(U4# zn&T{$#?|-vv`{T>lVJ->ESaQl+9V_pO`fhD{JoA2rUyFKvmy{g z03%4T$XUUkxN?Hi7BfT{SP4g#m$>=0RI;0oT9Z5dsik(>1^<^H?#;l08gJ@7G|AKp z@5#ARo>@q9An`v#(-F3?P{6)BQGhO9`~zsB*&fab3Gx5-mSBMUJ57;}F9+gy`DH;` zQ+W8f5`5INt53hQo_`APXYHuTPwC%_BlgFNrp2GXvfon&_K!b>ZuD@c2uJqme`5qI z_Ue2-+==5~-m#amzJxnuAAiMHL(=6N^A^-^%sZF=7SylUYk5)qR4JR@vb;zeSbxP= z3sP@i@zvP$3`(rntA2UWidcUA)XwKqFKbg5ER|-0HZ!{q#nXe`GTB1vrGDwxNdGCj z>WZ%pN#E$Fq<(DMs3bXcWxu+EsT=N;CDkvTetzp>zBlF_2DJL$M&{juxiQcEp(qyJ za78{5Xo~7;Q-Qkj^zao^^QZEN_%_|ft_P9cROnwRMQ=<7bw|^tsRj z{Ja|^?@XKLG?vMBW1DcU1knk1qDSzvf(fq1C3o>~NU_(9;#!PltLv!D3&BVm?x-J$ z!*kTkLRV)QT(lLArfL;cE6hK*UE;E`REe1_$O$J=g)`K44W~n-@T%;0&Eu4F8CF}q zmtuX^9qc;oYS*zs!K$G0;vV#j2d?-kYYvYXdq%f}c}7Cz`|K1o3$;9f@FPGr-33aH zf_VRntR017jWfEt2WTegDF{FIF%J=O%7rZ|2;+=pl_Xh(qfUFc z-f}uo`NWlagaE`QLO~`VWU;cR+_z5gf~l)C;5aCA=?c9 ziQQxH^fX@K`CM&iB&bd?=Xtm_T*OinczRxKo{n>?#fDLT_wbMNCZEwyRcpM6ygEx<+g3 zZF2hLQO}&CXgfJ#S6#jktjoEXtRjSv(xWMUl$tlWE@r7QM04CovTBM)0VgR3rg-oS zN0q4!RGHaF6Sq;o+GP5j9uRoOis$4UC9dNt9I0=~7gV$b_xGhorLf>dUu4=`p?A;1ohSr?MYD?scTqN0z$hl;hGr5Xm(SDQmev*{89FsRK zqd%PH>X-=+#PveY<4iSG+=gzTPTU-%5SM4?YD2Bbi?yY&riQXp{+}UFD&&8z7Ce-B zvwXar41xlbT%OWR-mL}hr2zgu<_^mE2gl-?KtyuQ zvIoaN>mCu@O0~Wtf}6CFvngp|hGmn>NQ;|!q$x5)a=;Le$~vbyXShqO9J#PpN_`~? z4?D+;^NUrOcKo!Y3{wh33v)+1 zg&cFVfNy6?7zX>Fl-D6Ik+7CBcAjL9n>QgUmthL1V;d5FiJH%j(7DSVXB)B%6EkmW zawv;V(Z|}hh~;f2zd;ab9?+7-R@979Q8P_MqH9F8M0>3k3W~tdr>r@_nj`Y)xTtv| z<)Suqq&pU=!ucmvoVEt4U_H1w&cxf13fP?gYlEfk8?*~pFp7o*J+lGRw{;vyMR zB;2DlLoVZnJNNPEDBKy8pEJQoxRWymZyJ_KE0*%|q;Yc&Ex6<>!j?g(@0*hENoKZo z3KcldrVD>>Ktom}TW;6d*eTj-6miok~`Z8yw zkU+@s)EA6&{nZy=4aikuyhPQf-FQ94Z4+Nhuy-vs-%Wt_UUUW4IznM`(I^$M{wDc4 zWON8YPc)f2PT>FWFy+~7twatC%KFK)<(U`X@CUMha&fbfa^`VTEf3X@7&Z55b$yRvqpfMz>~>^vWfB3t*)JIGaA~S_r1R#ZZIaO|S)* za@{&_7H#a;2YIPN9#SC7EsY)T3Wsw9-md5l`je|z4V)^Y?GoOF_%^TmLl0>K zf0*Fw-H(xH5g=_x&1%U~abs3VHOr|o^)YijdF(VK8j;Yy`9WX1+fZQQ<^l?6V}vCl zA!<(58h8duEFcs2`w}psra_9UWYbDaXuT;%(T+~pn7sHm`JY1`e5EgIiULE@{v7eNuJm8XH7z_-X7qo zXlhV$7L~Gv$p)$0DRu91>&l0#2&eZqkH~E#rNFjiHDzPwSL3vgt)B?@HzM%UO)DCk zFbN!BuAy+kY@RLn5#1QU6K_ifs21J&s4&Gjerv65$+xCSa|^V&qOG?}{%pxtf!dZ_ zOExbQknOG)vM*(Ded|TFr`+vrim7M`_jam@6W{>9t7NBk^vR(DchGFz;`NbCY8S7P z!9ZjNZsr8iW$-7YST2L#uk}TE=oCwQT>L+koC8}g;>%7|LS~wylk3=+05S(w-!1r46;hDi8M`{#$^bU79m|O;`j45KLHj z;$ZWA>hqr12~171>jQ*-@&FZy0B(g!w$98I7{rhuJcFhEdh&@7srg0OGE*)2iQ;&& zvkzfoH5YSBQOvwEllG0fBM1m-fdYsDy*7N+X!$wfCivPJb_4&);@L4)xft#p=I_JB zbm^;hjtqVc2XQWHtnT@ngC&CY@$eCY+uz(Q`Md7_=E~@@rQ&Qo3pe{ z-C{LYXzmHTd00giBp?O)G2Ijr*m7m}-*rz`q$nD#1$ZS=ZnEXKkM6lsjS8GJSb_)$ zDCUcUl=m$xR#kt;CYe`X07lOe@vTt4YyX<2`eLfq-MaoPhbe};Fj`|+$nDD7!B)EM z{(yGfstfw6hC79*Y|E$Sg40U1o&{>8k?rojW*YT<)Uv6DXiPoSR%$AC&Dl(jg(7Z- zDgdP>Uj`;3pXRD;kB8d*{8+zTTSvC+kJ1AE&k>aXS$9(-d)uh_y(Xg6N+g!_c(+ae zEXQtZf8rLhSieD9%TAD>4OL!ww@oQd1Y5Vb6|gCa$4uO&c`(ngFi){CAMGO9lHnn? zs2TkicH*A7!gFLioz|iz;I`(@<{`GVa@(5cf@W2>R}NI_Fn@j?l#B0cxbr&Xd2Wvr zcbNMr<&l24bDi*ti`~UNeY{0DU(wAX`%9B@b9t0YTtwD430hUmHDe3Oyk2g1HMOUCPtP}d|fwJF@nM<@p=PDgj+#ajRkS*6sJJF>XO#x>{DFRu@7Qdf76Qry=?<#e_Do3>VPN};+ zws@H$G~u*{oEbUC7OmD-xYdjhkuxJ=Et;;GE{~}}W1^;eN^#wvDKtA`aTwEM3OrOL z-)@wqyUJotACA1E3v===%%b$cdp=_hQFsk)o}+=Mp(u-x$9|U0+ZILIQ(D zpiEiJe4~u$k4!dH+zqfWMs0-QR&&+yuGqH&9A%#5CT_oZc*r)hX-1haiMz;HS2&jt zRI^K+1^<-WrGJ#UTw1X_^MVd%scpp~VY6=YP9aIF>I|m#vvoapw+D3hHrXA6ZAv9z zHYJOME$j+b>4Fyn+_Dx2w`=_`;lbVYVcU~F;^sx=Q)?C1TSTHmKgRnlE*hlQn7M~i z#7b6J*{EGVxSxIFyi2WpV@8o97jyAUh(@A4ay+x6_&V$p{(ei%8wAWia1)VYTm@Vth;th(byGYAH zXa89cY(~x1ZZ$g#iaXqfa^}zc7bP$gd6>MTKPC_Q{{L@Fkv)dR|3w!kiQ^!upPa|a zn{~x)HVn~bzu&d&(#!{XXcEFiKY+dVQ-0>{lKHI7w2_j$$agwIiQ6`|LENurA)i!| z*RN86_)|j zUXUR1y2~FIuB+X&>=0L!97M@nQBne1Qmz7YO5CYe66Q3*T39s)8p8}E(3mMS<6dI@ z2MwAxpZ4kddfnUpc|Tbq7t;)*wvs?JxkWM9y)Vom-0NyT=KC@cmh!EQ^t+S*!R}1Xmu6(sleCM%Y@6$O z5pe&?I~;^^MKg{h%uKNC_Q6&swYR(Q%O&z<(4Rot9toyP&9{OOZM?KW*mBz_yUgkR zrh`{B)^pOhzu7`5r`h#hk0pZ?jhiR6XefJtH{xT=YQMGZ3^i(Qv#ogrMwx4+A^eFQ@VBRU#vt z=A|B?EF}#i*T%5oO*D*=LgCFzoy6HKsJY*afCjfXUzzJSd6mU znIy~NE)h%C>8ypx)5@4Js6RS~Koikq6=h;3TOxfF`3HCvTJuFs4YuKUz8Ro_v_~OT zTTcVF0!v5sn&q9gaMzCcsljdLT_ssr-FV-wArc_2qSJJ-6Xp5RrloNwdUh<7Vy;>aV$9r)UJpxkkd5?!6U%6YL54DqFk=t=@Tc~ny))G%H z*5hW&f2hP{=(y}^a@}?2S5JC?3W=lt zQOLF0Sg!9o&qFZDx4?I#OOkuBEZ8HHKqC@+!39FQ zp^oG7S&#Pi^WL99UcJr3SuL^&Apu>^tP)By`cvYmU;?y^wv>4(!!0;Q>5#Hd|Ut;J~-s2sLPs=*wm$$wYs08MD-q3(J5i)WdTX>g*8f>m&=d zM}wm2NXsVR!*7?>&*6CQ%s72o!n}Yz(PAQDwyg8#FAtDo<|!$x?Rek`Nt@MD&Qkvt z<>DU7nHx#9<6TK25u;VMlM3s(K6bpmB0}-?^=wtBI8|SnyV0(R_ zIZPyjoeOd0kD0&jrSfnf^*#^j3Lg@?ojxF2mga+eJT*2>Z4<1I1HKc(NopXox2i zPoD|%%{1 z$+Wnx1Fo34fDBGwD`hTsqzc-yTvYl7^5}U>wMEf~N|K}f!Q3#O!JKlAj?|mTGkLch zh!(3l^h54c5tJjh_5uBC?{90BM&DW}Ggj{_)yT)S`D;VA&H(@3{sx`}*I7o$SF`@^u z@LN4lZ(*8ysp+zRG4SF4BkGKb39f0&w2BDU@6<)R09|U%m-_6AEKykLFI04rr0+~c zjTUHACz+OtLW-0LWVD(mzxH9tQ&>i7`C@im73{jI*kTqCQR)lJ)*MRX-ZYq40`__hvJ92h`WzsR>oXUDc&rjlnjS)H^HzK zS@eHt$pX88GU)%dC5lyeJJ<@hxzqZ3wcDb(eeLPfIo^_4Zfd0G-O$HaZQYyLy?1V~ zz&2=~S!7ZHRMmSsr`8tJKbR#VtmFOCUE~oLoZG}?fI4%ZPw(YTu;*iES$ZGnjt&OC z-!Bo65;xfrvI8RX0YCE{X3bpgR@e77OOg-zxoai&J8mxC#O!X|K>LbaF*n>lQTE$! zd?Xkb+`yQMBG2G(LA4qj8VGZODPhDF8fLHF4To4!yUBUA{XpKScVfkHUd1CK@gO_t zYttcEs1gYiOK{_esjEbOMmaJ}m^qvd>*|EqKrk<>b`pfL`AQ@gp@9CXBp6`fvbXj# zpF zwpe8*1l60NnvWW@_IDn|Kg@h^|7!@bRc1x1m#~!FE@lhMG}kKw{)9}|4!qp2cZJsb zK3V1h5(NY??EIE>*!9wEvaah+GbV{soT-)b!KG`G*e6%nfos_=x!&EriK29U$NOcL zUY*e*vUEF33_*F4KyK5^-JblR-r{-F@sQP!GnHno`D=imcZKAAc!tfxdH}T+_?f3m z=5scaX=4d0Ne2Afdda=t=DN%7RJQomP9`hwF2wse4`~o@;-BDff>15NO#2b-JLiajWIL_M`!Lq^L>EO}PY?B>)b(_j zg)(90zDy5W`YoR0`xpKDem~Snj%_MCxNk>fcbxD~`T(=H!l-Ce zh>nlxGRpd=oE;K_Ty#lLm|)N{8+20_DNzBw0$277O!b{j4>7EqbyU{ZIP2>@lAg1I ziNZsKUfaGa*BvQiQ4$f9m}O*hC?r~s*qEE^C0?%Uc2TORIoURlF#r4%oXJc=?G!!| z+#lvNFKCIG^kXs^v>@+$+j&5Ljhp?c$~-ip?aMf}Sd15Gvjyb2tx4BJ-oW1U{)2#L zXHu4(n0aHM$~{-2jOKbuLNow#-~)Dr)W;eEaImOFFqA0rxxytgLio-VF}SED%+D)) z5yOK%8l}6pRYXh`Ql;8FU7#YShL1XP3gB3nt%#WeG>DiQ5iwISiS!dON0RA^n1lR! zR>YK$Wr|1?FS%Ak%-nIi5i!UY5Ha@O?4=l}s}Y7fFM+pO%pi`{NVQ95*?MyaxXGpM zpBH+x&HerwS4CtPrEJQB2~!H6^BSu2o|!^(_K0bLIn{5ZmxYp;<6OYP&bE$F^U)-*0=lw*3rcp(S_i zNKNe^rbPbb_>#%ot~r>w?N!-b@4RQPa{QbYBv;V>26OL9_HrxPvnA$Y>4MdTotl*S z9c8RpzsOq)J+po@B`spDa#}BNLv)b7Yt~^m3W6 z?4WrJsmxoB?qNX#Ig*a8TBFbvWvunJYCkyj7`oY^DyCWR? z#g_fnezC>hoU48t>QNiFo`k6NL0?r6`NYd5ve|yoUyWWzj+$4wJtY>%cCLk%Bwz9~ zH%R6ho4JQGq41%y%ukj(Zlh%$r)Tt!bCn#55!T?(9({NZlVQOgKb}I3xTt%I6 zSK2Xuxs_}?X75m}Q6OlDcw@dgvd1x(Ny*$X4+B=J=8XBIUqj~Zklj(Evc719fp&R&+yMrU-PU5Q7 zh$IPg5;uFXBIOV59RF)mH-Ox5;AQakX2#8BZ3E*nLlx_JUFK(RTe&yMC1@ENINt{xCkB#W1d% zZ&7fp^tuBJStFGyM-WG8FipqI55vHl2m%{ZM3Kp(&&GF_<(t?n$#-bMhMF(?RwSNu zL7Wy{0gGUhcLtNHt0}N}HsZzx1~4ybj-IMRMtY1fuiXtP__qO{q1mW;N`qvDvJ=c2 z$<@Z4L<2ZHWeOI*J4v*1bFCJ?QHvMt;aq$O4BI1+Ln(Cc-q0sXm%^_^67j z{S9ow0vmSGg#-;6F=~_#qeKmC&;TI`imO3D9u&fI%<1J=I%^ZNmNXU?2CbLPyM zGiT1ss4qF#HVC#kz-C7m0Dg>`;?Q8M2Siw%BlUTvjHUS-pEG4FqZa|_C!ij;%K;cs zSpxu1kE#&}u(4fFz&+9`Iy9;(F(N1hcQvEyk%eyl)+3TMWh_IM;aGq2QM=jmh0t}n ze>E9!V|@$xdYEe>?7g0E2%LAy*at~w&>}leT}gPJab@4(su;GdH=r(MG9I&JYQ!j% zs>(D9#5RMpYeVX0*(Ilqe5yK$@adyzM=oQ_hv)*m)6{2Zh3>3(kP}kxeP)Y`?oqQG zJ^E({XpaDG0}w1Jt7&7@)5y2947Yx<{t*Clf$(OGx{m;w^;?C2yKDgV5nQNorv|-k zcD2rzEro4RfZ#n^Ge*rxBhvf9(=5QM2~&)s1THPW>~`p6w4o10f}h1prqt&r#+TKf zn>gK^=cOdm2&uC}(99T4+2N|P^`b%xQr8#g6=$uzVZBwo&0iElAh8*rM;dLxnb$Ea86taxL8je+G&r2%^o2jF( z{S45X&BYo){&QW{tf~Q*Pt(u3 zVYQ~0_EuaSr~a!(vkq$r#f#KUM1*-6w{C!@?2To>W)FS0RCb!0M;Pu6&Pc;pE9H%s za`2W&>ce*mEadoP-@q%nRP`~?Jh3P2WfC_Q1d&Vqs#r4~p)i@t%XAry|@Xkr=7 zJ?-SZUdniY*VobpGSwod>Sk%-T+%nUF{}=x0(4(M9O=0>wNY^N3DD+-qN!2x06IoGMb$$ZSXVNHG zQA9n0R2gXKrD!})DK_L@2chr~Yo(n`Ze(FS_BGe8Lt(VZ@|G-4_Qyx!-+Y&6$>>R%ZHVxvWi-e#tg3~Wh>jbE(1VZN16^GR|qorH01s6Ps2!N)d zY+uXLPjKh@MY*<7_7Sc54{-VxwC$}#-oNpWcW@Gerk*3>hacnA_tv9{l|?YP*hRR~ zEo`iUSrk!sek|y^)GfzD7y_}>f=I7$h$v>RaC2AgX)rKqUIe=c>l*8Dsyv6TZzKp= zI^K8yxWXy`TmZ$=9aQD={^K3bi}L9G3Rf0g_=qZOh_QvhhxZoOIijHtKJNMm$9DCF zBhMpGiwCZrnT$uI*d9KB=P_?ZHcp%8>C>X; zn^tH%f{nalR};BXr_*}GKz z<~XoIfp|zDaMOb3g*GNGE``XaP(t&LPKJ>BhK0+HbjnBhu=s)fk0#OWQ8<2lGuvzSUFkj)ig!#R95H>@Tg-^|sw>*J+Q9Im(T z3*Rkm^lH?y$&QzGphN&tg1)!Hqjz=UkBV z)PoM8`hK2u0GG%^a1`jrs5OMp+P+grxkDoqYaS5!>T7_|qVX62aD!1M6*y9g6~<@S z8c5_wjYi4jJ*;4ar7R)I-Q0j)FTK1p1H=bqfTunT(Tv*h;v z$(;>ZAO7Od&e`piL$gAv@qG}tpS1CHq~AL#{|2B}N9M4d-nQYBJ16%;6J6PScv@m? zx4Y!r3UROC*EtpVr?72!#VT(}#mwF_n-5P&@M5)*OlF<{oLe!uzwN|Tfs)?A0@pSi zhku^}nC}=ce7bn=s=lgFx=Q<<`W(tOkg_jp$}n5yz(PFiWUgW6ES(AK8+~RuwEyik z2~;08t(K%AM-JFfL3TRQHyz2M`J3t6V2VgD6uL2g2nF~@dERhpA~kPudt zOqljCN?^xebLjzGvG7t`7ADOdQ@b!}?!u%wT_#O_k4SEjXBT%Rc2C}pXBW38|I!b& zSEw=KM`CxBY?c0~e>(_YsBHsUfGOmXtL8o`D1!)>TE`}76zXjA7OfXxmRlWTx z61Q^(1;8r3Vdn*_&hPLe*c?ABhe*iS034Ct6FMF^4(}9=x1)y2oLm-e+FV92egba~ zxGdaCSwEjUXKFKL8qi*kReZ7g(e$6DpoSrp2W>NI?86am#qn6V*4Rw9^sxg_)~` z-#1F8r+1Qtq6{cRaw00`;1O%3R0y9j5ZS_x5^Z~fJ(L}d1xKkVH)@ms8Cf4$$9P_bR!sNNBhTT>Q)u82PoWleqJEGb|2vkt+YGeh6t-~53J~P z8|g{rsP&*qFh(qFS8Hq*5)Y8z{43Hd*6e_i$N5hp%;4^MQYb%DC)2*hX<7!RXp@Lm z?j&2d}7HSrLFA^f^EhKONSmI;JrVDu?^}OVHI*Ksn_+ZT>^9DCU#m_Qx z;LoV>m?5|0V)FB?2X$i(u=8^1e9W_du?Cf|Ux_AmSUC? zJCUGEX!C4Kx&*~Lte$X6B)3)=n!pE;1_{#6=8jT`=nUM)C9dcAa@>HZW^Y92Fg>K+ z|Bx#(O5s=4m%roKlU#n`#b+S0mS0uO)08b2$}VD_UVoi~JWZtDBQ22n^RbEOPh(`M zu*$MXyMQi1jc=~8VKA7Jk|ed~U7xB-oo;U87k5EZ90k%j@)pJP?OGz~pPD&|CkeMrnTK6uN8afKSQ zJ%OBP$c#aKh4x!{mLe}QsKT+s_zv1b%Wdgqe1<+_X_;t`9j(%&x)b)dl)LG4m4Eiv*cS0m7YP^u^nKjoK%-KQKD)# zs?zA7oixVhVWONm&|d(Ij=umHw*#a7;`CyMkp;v;u{+`8zp;g0$Li4b1|k-$bj!BL z6a=a+S{2rr@iAgYMAf4xVbFqzst2X8-<~XO9;XPQdECUGn#VT@Fy=;fr0zx93Q_eX z$#86i5k`r0?o3H`mSBYj4HI}QkqqCa3?JGgkbeOT*pvSV<3T|?SeG|P@oxP~xBN4^ z-F=^%{t%hzqv~&OqeCejS_W<6e}`m?_$~aYiGLbDDIlE5qv~N6)$cSQ^#qx!d zNnNnUS^FI;^{`Mon2cSGb#x22Z2EJ=f~LBqjd0; zJQ{Q=rqx2+hzQ_1e#GaKnQ7#9^h7H~r*@gE-817I$E^#6n7C=13@X5RIB*fb15R{c) zKFrtpd&o&`!!UKDg`zsE8ZGWC9~%Ft{Px6Gq@kCirDvg~mAa+X8Wb({Z5~n^s#X{3 zguTB3F1zXZZ2DMa2nMtQ8C-TDbY02}vdY|zGHf7c{eQ#RSHv*z9M9R!Vi`D`{e4yN z067b~M_R2NivRP`>a5Glzj1uxEZ^oGwGnlT#$Vkwgy$$$9L0=`Fm4FPa5Cl!ol7rq zra87oq!D*Hz|-(uTilFh%G$TF(MS<1hSmp`Vr@^ImbRx%SW$RtDx`}4g}Q7@>dlzC zO6o%R8EUf5mjL~*9Q3ae{bY?^?nQ3Q#%20VdB)QY$VP(rH3+;7iLo1Vz}YEPMTv3x zWZ22(&3t-WLSU3RVsdBlu-kWEXU*x|OK_)m+CTsgJW)gtdDV~GK_!mlHec-WwR8Ym za@wYFC9dG{`!%g+*Tbx8~Db=1Wt-SMuvU#?|_3_b_F9EH*&GR>W|c!9&8HAQ{0fo z0-SP!$}vAg!_NK-i3nhHg>^vd1|ytH zE{FJStt;(pm?AvH-3Fk<9nReSBvGhL0<%%EA1n8A39ZzP^*D&OPDEp`v=Bk!bYq*| z)Q#2Q>k?TiH{4z7>7h3U1RF4>P)Tkirk z3JZk>eb)qtPZxiC{HaWVTg<^|-M^LkH> zRQv{p2f3whT8Dl%XJB7Z{T+tVW=yVZU+}1jH<}+|+eIbFc%a|8xUFss{BXla6=bQf zHxHQdYw?P}cW^ujxFiF}g}4TEL_=1bOehMeWrxx%s30Z1qZtJV?>J?~P|tIA2C zu!bH+u;!NC!kUa>S;dNihe(6(o@+3w7g~L}A4(&vKE)UV2K`Rr;`oL5?YCcM)d729 z<9@0aAIu^3!rhMeRU$E>exrvdMM1}3n$tlE{7BP937Iu`2{xYBJH(vLA0y1^o}TG) z(*S_)I9#+{*L?c zJ5dN&dKoDl0L#JL}xG8Clb3;OdBdc73+Cl>1CGI)+r^5g&Aq zXiO}E4Qa8jWxF0qP+f9<^{_23@UcKET|h%vO@0M>mP&^zJ|8}p2A7)l z@lgm`p@lYnGt_*6@}Q(1c~PTWSlK5{_Vz|QZb1DN7$A3Z--TXX)5<2ZIq$Rf&Kqdy^SBL9L@uJq^O>}_B5d`1_ zee0~8(uT;fXn#nwyNNN4w#`BND9W!p0_K=7qeMv9eE1R}u6n0M_OC>^CwInLUxT3W zP2uyQbMZ27{G7HC*ptfjZQeek-95c+7#6t)C+|9R0UK?)?@d*^Q|0%Xc(86^SHstj zC2cTCs~Onh52QhCu^+!ckytTe67dnjPh#eu;!p z6n@_}vMs0WuTytmU*a{rFA>dZdv)q_&c4KJ1DE?F^k)86n9tm|V+$-h+RP=p^r>)? zvn6qnu?v(O+qg49zVX<=#+~3aZt@>t0FH)kKF6HKzB9+NN81~NM}sfja?Yxex|Zox zDXEQ+i9dHEZdg92*DulO3%d*qx#OyS6v&OG1FQZn(zGOP1hr{(u%_dF2!B-KWJ9X| zLXr58`t#1Ttm05RVHz$p{7W&+G5Ne|ff*mwLmQoQ9t&ZO8ZO}vFV?R6ksej2qfT=a z%SMcCk}{H%X(w6^f98un?K4o+aRkaPxwVKd-!+~78(Gp0#-0WO6r$>{X#j6EUV{qu zHNGud`BC*OvMh`n_*1*(e#W2LE%!tI)NZ+Z`Ev!xkuAHZO7dH~5b0JycK(1>kJsP*u=TN%s zZ2FEQdpeHsHm)Q_?FozXr*yB}bf)AU<4hWfM9Z0!!=IaE zRDAXlesVuIs`m3I<8Pws@BGP~1IRyrJ}j^=@h7(n;Qz!=ZY|$08Ba4qQ~xM`()SPl zAAha_fDsp{HT+&CKU?{8f&9FUKWSD+)%Ez9+*)pgB;!habxaU1Fqb%G689B9&nTDN znaDMVWC*4IJ%p_3l4mh*CFagzxEfxvtZzuT_-hNLxLd07c9d#=gM-{Fx$ph~2z(B5 zoTuLBAb){*Y2+oxAn1eYi>ikRl;7@>19eoQd@T>R;!v;Kch7sU%enRrMENv!pg9ir9R4@) z66r>0&^k4Y)sJGWz+~QrxHAUw;(>4!gf|VpO+cYSnB+hnYF>Rl?5)?fXw$ z49)A}z3>^HVU9L>I0b0c95L3Q0(Jj*(g=^VZLITLY2>!DzIbb^+zIU=n7HjWz4Lb&c1r&9D}Ol3+0Prs%kZpU$XJ0Y zdPm}MKkH`>9{-bC2cuRpU?$CUTjdU_3#o1Y)T3W-`{5N@{m9^dRk;_HB{9N zDle1D@A{ooZj{K^3Vea@MX;r?Zt~0QFMZPbHTu=yRgq4fncU(HzKUKJM~iRu8OYRe zn2w3)+nl|X;zG|8PEh?^Of3$c!4-J>%eJ!86Rm;A_1JGqfO*M^8`?L5o7p0%6oqEVR&%^6s;B zUe0&Vr|3nyo)M;Zqji6~x6OH!!TW2z@7M*n;53eGU(5gEcXFC*0WKN$-Ln}w0af8? z&5hR6n!h%46(WnEKOT`K3PjS^@@;^%)p%RB`&#MH78#e$sEn#VqQiv-h#OFiFasOS z+HQYT&_6*&BG=5N2BaH%Tdyy80Y4fq>CH~J08}_{4WMX%SlqwH(h_1+0ye03 z&!hk@okU&){!_V7hqOe!br8bn#LZn|OTOVD#;s>aH?&pZu{K}peQcejPOysM)!@;oRi zztriMLOS53I(XQ(dN?$SP3WxS2;B)?PZg!*dp8MEzeSps@2!IP=K|xzOd!I=MRrRO zEKv7B9NAWBeyE6~d_!Z^5q}-rB(04~+|_>-bwzoaNV#R$m8Gp7KZlh;Tix|MMy1tN zP*nnQt=(ZHGmJiX~zZV?X*Us$S@ZlGDqGXZcevBR1ft zr78+OcNuYS8sOMv#ELY=>-bYIBfiX^dKnSpPe)(ihEIM|Q^049pPI?Ifn^#54MqaR zO&j(V@Ziw1y#YyJMO1wz5G7*#c&s4H^mJhD&lojeLrlFzwqY{>9fn2sX%b+~{=sGY zMyWtNONg6GFlw-W_9k{<^!|>~EV&)X?RX3Yh@f*be*sJGKopHcQRPl{!&;-Cn^@8W zS@=2yUzqp`We1e_`0IFl6TT3iyxSZV*CqEwy}|CrLXo*>C~6d5#a8!jMJ+rV1A4Ic z*0iVNReVShKwI=j!%@R6;F}0e2n&25{k0M=qIEBhEZhj86K{s8UjjRT-a!2H5a}FI zbJdl#n798VDPCg@s=y7qsKT6A8CE~k$p9Q#YcxvUG~_`BdYm=^PC-O4u+Ctds zN~{OJV%3FLzDF@89S>G4mAZaN%z9mLuawU3U1qf^DW%iI&6fh#Ar-{UPZPJ0C^T^) z7K!PwcLcnbONk&78E&L&nJ8Z#b7jd)?%}M3LR(Uw-hqPIs>9Er z1|`Vem!IMn_#1v=jVni#>1#4)R)QHPhg5zJGu+Z$Gb`)RU1v&)*IZaarTJ&Q%-ALf ze;`=Ajs&blk4xvr!L~nS+n5S#jg7kffVZ0nUZa)lwB9Mk2Faew?0JMmq9bW zC#M*>okx$s40`A2hjZiZltK*RnpBm0h1bmKc1W^)8 zmD!a_xU>gQ`Uj3b?0x>u>6!|5O=K+F?xj-W;V9U*h=X8^Kr?<}qc?*7sZMuL(CMI{ z8m((jci@QbtYJ?6F!c#kD%dJf9UjCuxXXtn&Z_SHz%Gz$j&2*WYLG4gZ>$gE`J65z z;Q@(e8`5iz?jDp`_5WxvJ3rUVsqc2_x-pp`kl;2AV9Sa4gX^NLuaN`F;lL_#AcP%n zazLMPka4SzImE~GPnpQg_e@!N3|jF2A}hxgyy*)IIVbpJQ(TF1!G7!U*#8LSCLQ~^+>rj6nJ#6k4y~vEo$AoNTGiWwV2Swfy{A)Qnq4rT z^l`hiy@Iv6e*b;=bSSQ&diG_@9;2v&d-vnI@p9>@xEcCTJ zDFZhne##yjUK7J|s52~ws(Rf}49f{|yiSe)eM-grFU0%oMrgv8F~OC}_y+wjMY z%4`js&WA?NR0x0HA}p>Z!L9Sa45L%p^2Bc>-5#u93pS?Q%~QuEM#s!gon6M+^{XmJ z_P5W->N1}jsQ$IQ$@J_OX+N6`FGB1~NPX{F#1U*B5ymBI_uwbGIQVKJpF&HSc%?0` z4PiM`ch)cQt;L>+)iE8L3^_$H!q{{ZWcBt!7Ib$dr*Z9nRb!xGq45ARj7H}AFf*YW z#ES39-iVTzI9xqC#BDb`q!sH}ER$sE%jSzGCQjm5j~Wx=!1G<;38|4%R{%%1hzYZu z1+t%2#RcU3Q&}NE()3)PLC?y(OnTT7(vvEckULGwG1KRoJNEIxQjFRSMTPi551_vj z1%KmmyIiDmTn3#V0DnkbtBJt+>yE7~?9gk03cXte^x|VdjcxnsH$HPCWVjDKBCbSl zqA&z&dKp=;*t8W@0As?}f*l!GJ60QYa~a&H!}{7eFnD536uG%K z*o&~O?*mYCsghM(Fm;QGcq<3|o+5eJt>j9o8uItFeaA%Qr7*SwKL6k_+VnLk_=)7UGGs(wjNw%xmSCs-;4 z)#BEdkAEu|*6{-9*3OlAMl&1!gv|Kvo@^$g<0zOK{&@?2w++9E@XaGNoVF*OT43T#IH%U1njb1T-NvJr`K1&2R+_EHBGc*k;3x zf&^-thS~-kv19qDxxcy06*PkWlMUp`76zro@}~KE#^u-cYHFx)iLlbR=&cK-u}Ih;UBB())8jiD*U5x zGh_c=M4;F}J=t96XX0OT%=g-3z8S(x_?~P=m!v7zwd(o^vyRza67$WdxtW&6gV?#Dj>e)2 zvzvvsx4@{B+&i7zVLF#gl$d!&uHZgbK&fd!3{`e4m(voPSzn2R5%q1d>lXp z7_yF;m?!xk>Y8hm-hwGv!cvy}61v{&e9q(NR#2jIEBM*ye4fY8InL)ed}0T1z!aHD z-x|68+Tus&vGm<&=Yl?FfpO5o%mGk)^KH);hpn&}qQfFYk z1RK}wk6HS>UEoY4@T{2?b>KY~ zlIgYEJt8%hQj;3Xe(D`>byo+|;y{!bqw{-50#~l#B8FVuB)OOwVMAzFaLetdAjaY( zW5eype-BfvP6s>8E$cWl;aovti1oX@rhgsJgS2jopMV>IUTn(Q`BrdSX*EdY#_9RSID1qaNl_(qBhFdwduRJMaxClDJ zC;DH{`>C;n5JsUvBSPx>r**GYAQ_V`ZjW1ZA)h+nt57%Kmpau0_N|7pQ}@BVLyOd6 z^npHLk{ad5WTSp}GDuvFU$hY}2fJ-=dtt}#*iMeLzdOCKqY=2KXV-$?kk_jDB`q8JfPk|6;2EC5oj!P6t%Z(07TR;An9NZqK!ejWuPX` z42ASrJM~Q~+gM6gz2#-+FAT6qp!Z4~*dnIQ9&p{{@v0Z5j!qOH+AF}zSYDVK#WOL< zPB~S+J+a3*T7_}o4aL;UJ)&!S{dH=}iNG6E&q<0mrZ)Vq5Vcs{0C7>@=sMcp!7Y-I z3YDUroUTDK8i(t7m>yO&7wIn6Ebz5V#`GvfP}j*uIca|gbx_{^l{w}u(ekyTU%(g6 z+7@5F1GWlZu0yw@x7O{01_8D_V?1zc4NyqD{~E@8ulo2|bcX*Gi&Q`s80R^Vaw+w_ zfE1ztZhC?*;&!2bb1OCJ9MuVYJGL{%msR6wOFg#s#vuE!(w}9Z#^g@pvBgy`%ZA@+ z9)j8a?0T@|;6q}zA6!q!0??T@^O-`Bw3%;#3P!R2Wks;XJoGG)%Syo9hOmRT1|MAi zYyim8KwLHuNK))&gN08$r+FwGHCUypfSd|f^T2R&b-&HkX%4UUeFI$OV}@XpF3Jj2 zwq0~LWSB)ivWw1eif(1m<+`X^zYBe_6-nZ&NOpsos-9`I$|Px76Z3$JC-8$ zd6~beXMT^O%s1A+&mB^qX=>HT&6(X>>(ndVy8*KLfA8K4fy&_4=3%cnW!3-Wu* z-ctwfj2wEODbH|sg`QFSQ%gM%BfuMGhBD*#|est0rUN`y>aj=_rw%x#7|W=+Ne zV4bvlCTrWtGSeOSsA|B@);dNIsHOZxMye=(?dPvK{8fa>P|e^kFMpNcSA*Bsvl8ph zms#+;Fd{-7%#%dK%L0P?+uViCGhTFt?p730Q?g0E7Z^6+v!}`f73)&9z=8Q0IB?Pz z>9|jJ0FoU8k$eP4g+{VoBjFNGjUbXy8VS=QLVuc)KMh3kxJCjJkdAXdIFqH1j5N3# zmaU_ikrI(sj3Bps7hUx z7@iI8ijew_Rl)%D z16!t6i87%IME%VvQN$9D>k=6aUq^{cxq!{jITavGW3D!ZI9Sv%l<`DICS|gXP&98-dx(H4wsxCN98-Zeoov znve7JWLE&y6R%Hqsjow(T07VEfjXEcXFJrbCUqY{UOSkDRzyQR*=xTJ{~P=eJ=sL= zhhkPE5v4L5x@>dJJ=lUA*={)S;w#2ueT0G z8*~|m)Y*HjWq0BV-Fk7F+KpHL{IRee&AkMMsi3nD9c?7#mx8Y$wRI?nO4o&+wX19V z7Pl9QF(puf?B&FXR7?iV8SGc1rI4X6?oAl40%urdTS?A&+;}$kZ}N;44%_-z`M(6t z3j;{IV8v>2RO*Y`p4iBb^sGe?$_@DEUxq>QkU)7i@`F&w z&p4SDF}z;}P_qE}H}WHmiq#L`r>g&fE&40?dTTTM?^cwS`37Y1pd$+Jlt2`|j!+Ja zUW$TIIF6Az)6sq$=-%q#RRo10bqUy_4{gNM8O*c7itrd!e`1fJPGuo4GHO+1J*)N} z7k_}+3}aoNI%?e&YcBvh)boe51>0iK=*dWF5kVoSSwZ;y1`kt%NG3Sd#8$b#g~BsNHKTRwC)lzzj+1xd$Q4vii~13N6&0ugB^_C!r=ZU zBoE_xH|J|qHbyVR83V8^z`Tsx?fUNrI@ezV{X~rdP4K@uK0BQ3e(y85Uhs4MbRw5LxyGFfg`A@ z6mxVcTDG^C#cDjMxupPS0$y1Lo9e{dT)`Z&Er>?a|2;Dl+D4xWVBFNQCXDlRCPJ3!UgZR*dn<#ATQFRqS61p zqEu5UE`IGraE>FYD=4Z7eSp=xj-AnZGc*}S@?x|%bL>d}(U*_-*8sdu|7H9uoTimU zUTU8biaX-Ce49Op3H{kaXu}TF1>G}v2A){|bIhE^YBDEO`a?Wd9p?{W62LIWP9xGo zJKKh|rE-usbz8hRv-~0RFH&9uzo>Uu%@@Ts$k_R}rtUOaYcCcHVM)_dcRF0pia(kB z8XjcrE;|M0MNL-4)E5(dW^O6yX&YMRiRT8pS*F-mSix;kxkb2@1j(&I#@7`R_KBl5!;?@idu#&~zc zfL#cg=gIA~y>bPBw7v4GQ*f3PEN}{1`a8o$3~p&0&Q}<7YQ!uxb7^#&0SO*Jd}bQ` zryPA48F(?kLH{n&;4|U=A6^qtPWm4t{XfwAGa?lG>LaJ%eHKECPW!+AA9^n(dZ9Os z{z3~qbX)_q=TBk8^OTYY@tAoASMGXlbS2SEXGy1d&1tm#MT+%>xM6hziy_Dld|F%lJ*6}_Y4kvbTA7XFh@;5Qo9!`&q%7YooCb35$f1n4S;#8 z-8&m`7A?p@$H7XoP?ZwZ*W~O7-Z$7nzY~iz6c{DQS;xa^D7odWL8&`dp{)5WVo1p` z5p@kLu$~G$ut>KFA*Bp%=LH)1sm@@QQHZ%yJwkI$PMTnkqi4FC=+jedlrJQz*(4eM z7G9YgXt+%`HopZF{tkyi*iLj~3TNg>Vrs5Ceeg<5JmEi%66G0OZRpZvEPanI-R{0Q zbpeZR*)wQ~xr!|@*RWM7p$l6{XoJI7WrKieJrL(?Gh zfTSeej~dN)*>>JtYhA9Y2Asz@`fZBaR!+w}{;-bAk5n%A3R4#_6^tJT!PP=CALZ4x z7Cll(;x&TXU{J{lBjvtRBZGIKai0(;mBaG#_*%w-y4t!J&xV?}BaGZ_=3yeJaELlU zHVko2YPp^T=b%G*J6xVI$)O@ZD*h(t(!J(QI1WUbP4`pi>V2(t10NzT9zBrEz#Uj- zZgVnMG4pnPz6-(bruT_d;0Z$OMtJYU?-Wms>cUS(qQ-is@MXtiZgw&!*_oQ7V1uvy zZuF;&I|jqyw+kcX=HJMu0t-&WK~416ybvN}L(01uZB`uF@1f0APMhbW2K9lQdguJ? zPbEC0_rz#8B&SUC9SR;phk|F&0C0VCbXFw0yumHBeH*`dEEy{_8N*HYlb~TfRuG|x zTE#cL9UA5jq~WU;4X7M)oSNlfHx3D#!z1vgJsC0fKxFk&;`A>dq@DApEg1n{>t1O4 z`o*{wNAEb&zW|+&Tb+(IP(^j&D!dj%Fu+QpePLaucAZ0KC*`9{j?m*QKuxl5@GUp@ z7qymsI30_Rv2YHpG^+yLRb#X4{-tm{=1AdJzXi-yI3mZ+hjniT?!ag@Z}vmkwlC?D z7lae#xc7YsuIj0pz}J~@Ul5j4xT!6y7UBoU=1Y)Ex{SLVqV6YAlQdBn`5zvb?%IpL zk6ZuS3W#AAyp9!7hECBvEP4=!%b`MK{)GB@M;=J$P8JSgdg>9XUJz6L@bBVoEu3z? zfZUObC8Mb*DdFR}RY3CmGw_&F!VlTizWs_zx*5hdB_7wDZJ1v_0gQrRuc`DZCqv zIn!zk#S?P}#=}(|tg_Y;N6b60ZQmE0%99$5MQ@;CnJ({Q`FC-aoy=evbGW%<{GXFY zv)aqQ)i~Vz!{p9`kLnDO{#lg%y^W79#DPo!m*bb?yHQ|qd-IaUcycOmsU3}`F9 z0QdP}pt;*dHh(%!ANP#s=oY8EcRDjhy1#xou)k(nByy(({Z;yF5sQKSHILd_`l}Ty zGK{AJ_Lkknci=_t<2oo^-wRHC6=caDdo@cqHKV?*C`>IfKtA3?5nbOX);Bt$evWm5 zWp|tpVx;NO6rLIs+0ke2XT-uO`BWclv?wZaM8+DAkk>s9JqGESsp)CUiQ*bdkId2` z+(9L$aPc~TP2Q3Og0L&nqg|r6z&|8ak6}b#S<3xAGcTfUf(>tRt`7y0TZ_b-0u*Wm5%fuuW3Wt~Vfo8&;3kDv z@M;|_-y)WYX)I3(mO={)?q?&G{n}nehu%ai*Llnln5I)-LkDr|2{++*9~p4NWrqDy zf)3SV#=Q!Se@eCiXc_u>$6Jm`^c0a#5~moY4(x6+>MjinuoS>zDo1$ghDC{oF&x>a z&Z1ApzTTDLM7lzQ6;8L1&|tm4EnQol5pn=42$*kC#(M=WHaXf$#mc>kg)EaU&!}?> z<+IS=u%AzpDww*(ow|rCA=6c#y1{J@Po0MkTc7eG3e2U^_(gC%Vf(0ri)@Hj6OWAf z%p435cvQCDBlAsE{YL*V4?zXLR=-e=Jvq3DQ<{tCbs&{@I|SWNf+CtA@E5UYxR_S1 zV@D04{#PXUfueli818|8AjhBl?5a9!Xg%a0e3=Nh{6kvE5r!Rr^c`ul&ArKgEo&NQ z{M3erZrsEYF9`{V@4HJE%_s!N2VE>%5q*~4Hc5Uq?BMz~+~(EY%8YaBSG7Nn|CijJ z-`rKQkx8q5(2ak)TYK=Y3xc-snyatA`WdWHT!(tMd^*UA7BIV-pDS5)A3?u&=&%%& z1eWS<-DZ`QF46L$8Q5jhZ>SWgA88Sd)q`xC;^=FhvDJauM40#96`siUKL*7c8!#xW zRrcw|HXD{k`27UGM^M7(|CLpayRXUeCvbX)TfQo56(lTI60y>DKiT2r7Z|^{u^BfI z)lI;lv$49$<(@3eoz`86JTve_eJb!|ha_Qmd!JacFg3EP&YbYX9nY_Z<_iAl#)-yj zHa7HC1@WCOq@l0=`gaSl#tNARViXSkY4J_tjW?WfSRls?4~uS;#-LSiqG-C5`^oxb zr<<)fh7@}&@PFZ~wf+Np583FAiZ=2K2sy6`f>C4!nqvl@3chgTusfcU#=LNIf$^zR z%EM9%*a8+I?RKe{S^iY;rTWCs9`_Rv7Z^jyEk{yd&Vb=$pYIYiUjXw(>yHW(XtOji zR4-Z{`atkl2L>0XxYX--08hXQdl)+02xj_(-BUaN{s@$&uvyZk!YP zFj)HQoAAW0jn7z1RHtN;5iEVi*K#5Rroj)5d37s9Q;Rk)T!Frs;*?#^vTw`Y02oep zb6xvad4fGvr!SdJ&BE)yM^eKP8-Q*>)xNv2DGz&D?~cbBu7^>}n>1D9XA~iZe!$@R zCf*2VodGPk!sh4>?xe%6G`(w3AncB)xqwDnahV_d$r=|f#^nwe@YND6aTYr`2^&@$ z@$NN#^~}si;}9-Thu1*vgs~wa!(;cJVChERT}x;}Lpj4yhH)sV zjkQhy>#g%l9NJ}@jazJ1hp@V8lP3e0Q`{~Vo`I&H~V}ov_8yJEnXrT)eL+uWbtv2 zFxl#xgO7ty%-0ODIoBdHl}YCJ(`0^Er~{ds-^wJjeJYvS+>w4ThRos^6kWF5K zbLzK}`6LNE!~KU?vSQp}Z^Laaw7J^)7>!2oo1w$s;O|lF0o-Jw=emo)z9nv4FRJI% z8-Ro5M@zU#G&KWjao*URy40iQTX_c|Xxkk$@b0l*>3)>#anllmjk9X-UMUX@3zd?ji8k%c3d*gMF9*}M^%U%bKNsdLF+H#h(W?0p?kZqzUAEfpE`K|J`f^_Pp>cd6J0c(uydEI%7h7qW&ys5aaiVkq>Hv zBTzD5b5zI!%$>NK2=R3EgpldM_3&1RZg0MR=`Z&<+?b#tt= zHGk@#?mFU{;rhX#8Lk?rqMpGsTps)%#NW4&wkvB!=Jlnre(+#XGPAh5VssX@bFy!! zueAuQGiPEi9Zh)Bo+XTe)u`~1*K`wRf+5I#%E^@m&T(?n4K%+|!hv6{3v3uz;AE>n zH8|qOE81+MB~x%iV=9JB8-7-NNeVPo&zFmABwjV-iKyMTvNydTW5OAJ%t#(L8#+381$qy6X;eODE`=4<&C*!5cw3i{AUM95^uUrTG)l*b7WD~uR!Hs=Pe9gb~IuGEEq zfX{1AGg$S7&3Or)11)$~bG)C^oJVY+_z%o#_V9=#HVg+Ph8X)GPtbw9mPzfhW>`Y# z+pODa0=($#1vG+5PqQ&KB?$W&F6DhK>yaYE&AMtRalQm8tGj`!gOeE;8&q*maAIG^ z%yzA=Xuv?Pv(gj=yoSZ~D0TCRn=TW(;oglK})7BB9eF*+TWl=es6<&4}AyX%*)ir6PF z9t6YSZYQsldEeD}aQf=#EwvUk;eiBO3A8!jGDeCm@SAZj^N6$((EB;u+LYDIcbr1a ztYflW|6tVrT_?|AUY^d=kukZ(GNz5R8Vj1#KmI~r6E6c+pK@71$~a{5jQ?>E31#=Z zqQ~~a4?B5lnRknYwu*wCXFTHMN~L2mD$VH+v|3tD zFZ8VYJLs{mzyK55%*+XPX|Mfh#%>!|$f#^bRbF8Qmc@fDtm41--MtSZ6h8d;a9C#& z+tYf0DvoY?ISLR~yVgS-EN@W>{HA8q8!_Rxw}M$?v50a1X{g~gK@1~zw+DSI9=iktbuL7Dxg$YNWEF@&{ zPzFPCq6shjT*Ty$$iew#_4HXsA4u(}^@>3dvSyhbYxANt7BNVT6vX>Kioz7O5KZS5@ZqKclkgB1rTyI{AUnTgpBsF6~ zmz<~N8cVh`B?3{_C$4*d#IKPU`-pMmolu)x+JhljE4t)!~LF(=-H z?>R*ikX8(A@1Puf=8(pxjE70cX@p-$L! zJdNWo891Ixe3kW2Lg`y|=}{;>$S$3jsY~|ilCPsAA1w$zmndbW=c3qYx>yj!UWDq= zVk{)@)rHv?Ygc`orgeNo<%5ZG9cABNnH07B} zme958I$hxM#0MBeSSMm04PYMiTJtDKMZ|v0SP$&AszQJZs)PS({CQOQPlMF#=Lr5J z9t3;v2z%2=3+-r)b{^2mAIQHkkxyqiCCgAWO!0`Sx?q`8SSWf`yqEn=(pY+VPY9>KpRfvrCo3f(nV@`Ou zjXe^rQ)fd8GN_*Xi8_1(>E1~g{nS)3JUw{-8p+A6CB3I5j}C4suxKG-+*mCoek8K& zo%{)exQZI53UCezOz&-@%S)`(71n@Lm2&c3if;cKtq^JuT@(CihSOR zojmGpd<_&9wtI89Tb3-pr$5dasxZ05oqV1#--W$c{DF0~YBkD5)h>}oFPSyqj0&X- z^9is7VpNx#ID;$)!8x_y$}MUF+TT`H4IxJm`y5!}&a@D)UxivjX*yG=gQEZdRDhgs zWV_#bR;vI|Vdc_LdoN%uQNQ$0#PAD-cfd|qJbT9=PyOmM$i`fl{kSax$L<19JD{Sa zbE5~a)+)bpki?24UM%1R z&^5)dS}|lq{Cib1pocjfE zr~rCl3YyUg0KDjUz(xVwbDi)&S9vB6mj~nqEVvIMc;VWTXJeTF|5AXlAP}1M0Q`}p zVFTFLvKf*lcZI-$Ih9__sv?YpMY?LVXgExKE{qY4?@Bi1XC*F*sf)2wVBwpOI>Krm z@aeKT8LANb8;}X`Gr6?@;Yjf-VrmGBY1UPuSVZNsSQSnca@96U5B_o?`ludpy*|8@ zcNv3TE(0>a4H)fz(LlN!8x~UCI!QLLN7S`nmW84fS{=x27%%j-*5JEV-Ns!6O^jcN zF{LO>X$B5p)L7@MaI&~x*PYfL&=0l(!N%?6PeNh7eTw_d0;;wFP15^Q@hK**Fzbg* z9K>nnGZ34V9h`= zo7q+~2?5IGEQ9gP-K0mZ5vc+r&orYI-7_X-nKxJ1D;g~x5hH|Qp-OP!ELfSL4fXji zTDC*P>_RYRdIZNywaFHrU{;lxb4yXz#ZFy=02;-zasp(gctGl0H$>ne=yYr_^+nYG z=sEs$JekC1fpE_4d8TJ}^6=nWeAr>A%*PtGVgkZm{CK*v%j~}h3BioNX>REF0K|~T z5`MBEqzc~EOC;F1jaWtW<0)C?anhi;4(ebpOx)99tKz0Ms1L1!UnNf->(SyRhU&{W zMX4vnDw!1Xj1~v_2|_mwfR^Z>3Y_PBM`*xOBw#9eup^&OY|O*nR{~1<@ZYco@|h=w zBj$cp4t5}7H9=L@{x!F@wsy*EdMsg&fC+Lfd|oA8u{U|Hk zeG9U>Ypa%QxaL*WYv7``L@@-ebO7Z6)N3t3gs(~+Bd|QRUV5e64U_Jrfc5jNb&G>Hiu~JkJC0TFcAT8IoBMoT?vf~ z0}Ft#LGI?d6*3ItzhgiC3GM(RA9eUsK}M$JR0hrt!OIKPH69L;?8HzAc=N5LS@8nn zaR1*1xEz$XbAuKMAw7 zB@OJw8uVD7m$`g9t+hE&^ojX^LFdE!4k91ZO-Bi z8h>AkkNxOg`b2{JSH{iD-DVx`fr+ZNFCzG~IW0xieu!uw64g5a z%eip)FdC{=k4c637_-=3YB#jN+PwBT)U@2loPUY;v)gCo)qP!+9Q&rU|~)U&ijFyok_c zY1I|AqYcRKoCx0^E>hQ{v6i&lk4iC#n4_VxH!i_%1^#i@FQ{%=X)&ixEm?}3nUoct z&`XT#D1(gR$0TDo{nny<{O4j2jKXOUK;gn1h79C~>+p8;eG9COt3Hm%2{CkHM0wvl z+8;~JLcH!9P*GMVyaED}IOYKB)1cfqPx#_>4fcDwqA^ysb?6q5k4E9G8p#Bhz|1 z%d(zMZLcbApNn}Qrmn}zqdhvIy(+-@`3^Bp^P%Tr>Q`*0JqJCLp}#~w>P^#gU~MJK zvf@SR&;#JrT=-EZP&tMW=HN+TEfDplaN@UW0@Nc^B&mbFR3{Od`8cup9%hvWG$X*L zf?h{|>)7^~ry{rm&#KE2>OA9Wrz78?He0<}kN-=0e>-KmCo$EWPV?<#fVjT;;^_Y=)28EC{J z+tIq+JP<#(LkdMbGePOeM%*bBXQ92nP1h}jb_QRM53&4HXmcq{GSFfkKsW8B+rG*Z z+y)CJkK;gLX5^#+Ar}AFYuY0F1BzRYNX#&BR%V$ACWQ0Oc!HlOFf&`Z7b_i|~rfeCt@6GB2nt2XI4Pdv)mrWJuKk614W(>&vZZURYfssUGa0 zy0a1!tm+>?RzwwP)B*GbtVZnt|bnkq}nn(j{7u5K$wUP+3&-MLqH!l~rZY zBD|=Af%io{(gn!ld*tVm>H!KjeK~&WUVjt|^H}0^i~RXQObY;o{MtG)`=FfHu$&?W z`z5TdBrS35Su_?E>#{iAi!ST|EVU?fHV`L*nhPbug^4H=jn&qvadjvx-9gKNuNAM6 zDvGu35XRI(V^?!DAS4}FByBGPJ?P)B92YL8~x(B zN=$*S$Vb3@)V4eCpQK5r-H8n!c%(){FV{mcTM#`t(6)&9J?^vs^s}gE8vIQ#!ffZ+ zFS8P7nHPaEr{T3vl2la#-oV2)tgUJ`{+qsP$t=Arc+;Hc?~wJ!Hh2YC>G4Gp zW70*qX}GGsrn`E!#0lW%s`}ZolelJ$xca=}>cg2@y880b+X2kXbuhT!Ag2)C%DH!# zxgS>iyWnq^sIzP3{35m!Yq6^fR}x;^t_6ZV7@&|!-qnD2(=9hsZA{fd9FUIGAw9EP z7;G*iz7b_2lyThMT{SC9_9i*WmtvrR0jZ{<)RJPjC>J}U)>=Qr&*f!{5O1pH{1`3^ zKxC?{ifi#cF@DC9-E$C+_b;iSsD7b6KPLAr&<2w1Env2UAyA6HbMUtue;48JeEhBK zSdR0)vhu}4kO53_<@h@ve=G5K8U8N9-#Lkq>V;z5rApwQ3jaIbft?<K-$i0yu49 zcH`QRnhD7%S&8f^*A~UIs?7?-qa=EX5?jN#E@2*j*2UB<3xpG>nLFrt#&g`J6#Hr; zaH@}=mU*PX6H}K1G94IQ2-xQx*j0qxu3@qHaI)EDzGQ8lK(1vsCFD+adS)l~qRzoi zo!Ey2p6w2vMZ|N5#sk2=#%$t9y>+>U5I2E<3#P6f+@+kEY^<0i(9gpj&@Eq_9(sOtX&&XOUpbi(SR({z>Yb0HiB*qy+kTQhKO zM2&~mPYs69q-x!J5j*C><+n8${Rm2j}t9A5R-4=~Gfn8_PC!GHN$=3vp#+VAl1o^pJn zXbFhRhd>pL=lRtM=9cl@_`lTjmb4cjbjjD^0$lQ9Fq{V&P~1=UncJg2V8F+%%5!X)#z%NJu%tVL*7owoO42&wD+>fzS41N|Tr@G?P zgN;SY<3Z58Af)zT9GkLM1>qIEu(*P%W!5|wmbEA!NBI@%ClPiQ_U?SG>)2pm0(hW0 z`5d-8Ji$Hy6*v9}{3sB9;Go~j=KyT9sZdKHM4^(w8!m1P$Ta4sh4l(Cf#~gU7~|5? zVffPFG}hW0kaZ0%vwU#!rL0u>V4S;TpF{dcWlef$=}&RKv5i$vnkW5MTr_dE?8nLK*pY``4D zquunL+dRUY1yX+2NB*2X6u_E4iD`tux%R-|m7r66dL7(x}I4SM3-8uv&{GF)Z0TqAtVt8NT|WWwW?6_ zdX7w!99Wd_O*WI#5xyhhYK{(?rp=@I_I0zIsPg1~R$`5>NpSOEX9#1qDsq-T5ZloLMA zc))>RnNU#A2#!6^T7sW#BAh)+Z}jbR*>hA@KH1(%czU2Q`MkH@kTEZWP4kPid7$k@ z@k?OM_~qJI`yyAM!Ck9f34ugQ+;P^|QIbbELBt-{igYf#nz(%UM6Ay%%=vd5NzK3e z2%Idq3gSI1LN$x75IYE_jVHClUB3`Vk`NC7Z*U3+lK5nwxxc-t-?mn){TgU^ygBoU zQ)$6>QR&;i(3KKF`@p{1$g(wu@G2E6Ul4vArgZw#P%TgrhF7~zXS_ZQk zGVW_x$e&-Yn7lpM-4?6Hg52Co6m7Gs2k$iJmgAqAawwD2gCUlbX@!!I0S{3_*#Y%BV0+5nEFg+I7vMSCZRormR_mw!=*7|O07RJw7Ys% z*4~$yZ3jt>m~xq&z6t4o%tlIlD7J{KA~R8>16jsb!RX$&UG+W00_x!;YPPG6H-eZ# za|T!;rvGyZAFCbKJ+mgOd*ei5etGv|s?E37R+oCXh)25||j6Awq)Q3v`-Vi*OELo8aI{G-r+@^j_QA zUaq%!@wT?Lt!=%QT8asQBq&w>Sf$lhLre9H2Q>&LgGA2vTYI0G3{mfQU%&Uu^Gwb; z`|sLo@4fcgYpuOD_A^9b0#N1Np?#NLZ$w56b+wkZd_{`a9kFtAwvQYpUZtra))cGq1`RP_(X}bRhp&_C5s5^ zVyfdjoCo^)JiL6W#G>W#5_JKT0>-mAWc|K+NP3#@IMu!;R1`-Id$Rt)c9Jfl{4ELy zZC`AaGX2`CQyF9=%Q8hE;*xOH67=4p-l`>5zOm+#rq#7Hu9;E6(~px_Ub;4^b*f$!SXp=eK;`$@f3Nd|XmKx*wP;^kFGR+zvD5m|jUxSv0 z=ntlS12!b^f5~L&h{VS zMXg$cLwh(|T6PWV8l`CsO6K|Gdsp3^~%r53Y{)|LfrA^rqYFo@3>DP*I zevoMu-RGR`l?XLu2#LW9Yq=730M#&@!D`%~H z;MYMy01XAn?yj1q={<=%2$SJs;ul;3Lj3^+S+%|SW?!%cLsC1il#mK1H?31yKyVNP zH0YtIA_z7B#a{Zrz^d}|1X?12lO=G)6C_p0#w&>thT;+^=6we20L&90Vlr**g8LKg zj?uhGHQSAy%kv!l9(NyHS;aUVd^e%<g5=`L zib%kKBpN$h;F(yINvsBOg7jM~iRfXFvK}V#UTa#6BsGrrCln%(ABpQRtxVZbLaPgM z|3RYerBwGUUN@#+Jyw|g)C+M73}6_RiQ+ifux`&-&N#DYX@mh+B;To|J`lzZIbs=@ z#@FF@>j5dr2AXW1p2xf*h1qXtezjtUE!``-Ez)|`>rpp*!YiwZXCQ{*0_>pw51EC# zQ5p^P2FN;JdpC~0+rhY+iUiUy)s-$N(V)s83*LOS7|1Gsv0+6V=UfwETH+3j z7JxT0lKv@HGj~7ruM^$y4c%$WJ z`LJNd&J%=}WPEiR96%(b5NUl?<>+3BTM1FH-$;`0fd{a3(zSzZn*%vh78pB|0ulLv zVK1HL1={E?RxnXeykp<|@O>yg!R+^7r^^}PT{ME5!O3!x1X%~2eP6tgjZ995eu>qc zIrqlqqi7zBfQa1r(1SDrA@K=rLm9A;tHLLCQp5|O!q+M&C3;I*PJ02wP{H{KHIL&A zl1~iy7GQ^<0$M+|lgOG+JSyq*p92WUGz(!f2!2-F450ki>~KLq`#v(DFObHu7WXyK zB675bf{39>9$|^|O1Pm5%OuT~smZeMyl%E^Fb6SzGuJyCqs`I;^@<2iWI&(H1_*H| zRd&qWpPHXQFj>1L*S2ey$^VO9ka+5A7jmTma7P6F4EYlB(zVL_KzTch@DFHdpw3@T zfP+2U#|t+l?qpAd{i0uMhXo?tu7EoOh=5ax_s7DD@9b735KL}Ur)h1U!dv7xO z9-GDzcr?K1w)pD7nEm+;v_PpUfUMI$L#sXoXsUAoGsfa-ETPas249e5AJwlLs!^C$yiS*iRN$oA)0^YKhRUGjDzF|gNd_f4CSkT zQZh@BNez&n<+*T;&c0Ucgv)p7ESTwQgS!$%Ev2G5<3+)jF#!b;!k^TSTS_6SrE|DA zhKsShdjYg$RG&II;-G-l^J!921``Zsf$cuK{Uvo?9;^k_DP%Lih3$JNK*`Lf04AG( z=v|rJkG#t4rMSvRnH_>Xg)*CRkcCDz@oO4G__ zlMRMc68uG?HOvCzU!P$8reCenNhTMZX;ZcEhMpaX+hJflHvSRgn52)W41}VIQ7CA4 zuu%UxQQi!~j?Bv|n@vz)82&a9eV&HlIv$O(vfYP>oa|uhv%Ql#RbiM|dwCCa`VB8rPJj+x#`%ag8E zds!A*yz!@I(s(OA4tKf`q;;Oehgu}hw@KE8sChB`2<6b+!+>0r5hvloZea5S1O=GF zos_-4_zfWB(fvRG{F1OTN*+fc&h~#NoS63ca-X0z-p2X}ZM?OU&EBPHnD}YH2ia#B zWfV)(BN$wssP5>$(fH@p>B~_X&k2)%6}chCPXn1KxCIqK@2y>AWk9J1kn0m=JVs^Y z^D@8=!j`Ur5k5PEf06s7^AXx$v28dzj?NBmU^%1dr5(n!HFxBXpdeV_Qvlbb^Ybx3 zL4di3M*^Sr{m~pnEXPAE2aN!D_#4K79-dlYslPUw+CGQMUq!_c-eHyC?p@t7hj%cn z6@A*0-I%6KJixh=I_-wh)GpjZx&62anjMA10*qprG+`fRflnI&_Xgfa`zP4>veuI) z-|aAvq<&)w!Ta1nduU%g1^R^Uw|vvY0YB>SEXpw}B7*?fzwm;Sm`RK;#vg#1#8OBK z(!`uJ+SNfFM;CA~ou>0v+7EYK!j^dJJvec_w0a@=&AWS4F#5ejFP754yYmNp8Yl6O z)nFiKqf7?IlY>7_1w`m*uyI0Yn+kB1S!JK-KM;XZBaXpR{OsM9u#<`@9f zcW5gUId1Luw;fmd&B)Z2LaK-CMIaEiaq0uddRvJ=?jz$_Uyp zl6=|}FghqypXA)X414ltmRDLfsP-k-Q7qb@7pb!OwD*bm!P)_MVNmZ-`@yt0n7N%p z?zKs(UXH0!9z4UUCXT?YTFjSw)BM^mFUvlTXU80QnHPbTr#4(Y3o=Mg$J$xuOr{J?br-4=FeKl9vcFwnR67t&5-Un$n)x3 z3Uo~0D1wUN7mz?)rQV7$h^!NE8kh}bwlQM|WU<4iCs7*yhg!hOR55;wlsEJZla@NI zI1v<2%ASnA0z53CMW_OoDbrYV{0HVvj8Hu5F*dFI+BrUl6N)Oc6!7%43oL#k03jng z=MN9o;=~$f+YeBXtfe^HkK;wZhe<7MqLZYS>2gdE;RZWRnp4)4hf1q4XnCdE@=@vU zaJU4$s8;3S!Uu8!vlB)1daN)wDu8=zVQU%)eW(r>Qi_R;Z9hWB?L1?+>P8I8#N#)u7bE`UsDaUc!8 zfXyv``3^OZhuhpx^WW9#8R41|+8S+ z9=Ap(IdJ@-0-ZQem(K{-mEgL9yx^roE`f4wP0Hm94q_UpnsyutSln2F53LWc*iZ&= z=E17Wqq4LTbT2g9)iC?W4sFA^33#Ie=6I(JVmN5ma>!9DE2Oug1ov6O`h%6P+3`k5 zJj4$}hbu@p_#i-qso1|j zF^tC>b~=lk%8u%0b3JsAU-NQan01j~d-t-h=w)A5<4awJ<0d%Z*VtQO#Vt2}?HvmA z#{=PTg`}D|r<3*RXA`81tgx3J?Y=g3OVYH?q5wjD)A46rnk17p+# z?@e@AkXqZji;W6%OqDg|I@@+rRaG<4>65X4g3gPaJ8R!yx(rA3+sLn3fHKmAY`cJs zMRl&S6~_ue{p`weXxaCoqunn#+v<>#BwCOD5pxJaiaWHK>?{}U6Q*Ii#+=2(k0H(? zV1D{I1BTs8#rJ<)zfk5rhwbc?QWPxR8T_|I3)pt{;7*oFuTTRxzYtlDW3o7;)J|Jj zeFpT4XuQ+Rdrj~^kXJu|jc)*iJ&=3ZrWa$dNL@Y)=J?9mZ0+B%a|9)bssP^E-cC*6 zwhDm)u0er`_A*zUwvzerqc&X=pTqG>Az7RL%((--s;r4zlm0FNJUc{_#(@Wzk#Cm3 zx|VxCV~1#JAwnroy>=x4L0v%0WbouNJX$ZJhd6b2woS*N)V@jZF^#fPs?@m1({r_; zVBHM}xIjaop8vDZ{hQd@sP$ieEB;X7t&weHT(52)eS)GIS&n zVSn=qh>xN-qGEu;8Q7}CRN76{;A@YvOiawGROQ9JG~}C@^qZKhn!#lr$}-r6Gt)zV zk(s9?o~JaPXDP>im2Xs1#-WC&h}KGMPjT-$uuSs)Y<~a@!#$AsjCv(;whaMUapQpZ z@SY?Fj!0zU$*(>Gn@;C`*3Dw<4(*#|B$f}sE*~;l|6e^DpL7I< zcDj>;Ur*qI_4Jeo!vzvBp-Uj?xYQ>BTwvGAs>#Kwi}QU=#Z;#qi!TG=6e=PVcZqGR zF?7xeP?EElDrCcZK87lyAzhhnX1(0P#|3#&ww?)#Tb#^-gpw$xN>`jga*^+B{|iDO z;kfLYvt)eUO!$OCEE$VN5*E*m#p0|47EN4T6K{gEJ%YpxZD3NrdIR3GK>lHE4ZEgX zYR!s*BH*ytfE5D}nRJrqi3CR3#D7U;7{y5pDAAVYeNK3GCoh-#Jhq`em?dfG(+>U^$9p#$K~qUD@iDIw!iv0 z=p5BIup!QP7aaAgEU=?%1aU*MB}B1l2~h|#42x+p6eW)SPJ#`}jo$#~JHX}VVsuuq zrsV09>5c;I7onnKCY{=B7UAMr!2g9N(JdrGk`&hDznpESsXxfto%BO=wi0VJ?8UxvL>NuhSm-$t8&5vf&(2t%kQJ?ID&j zPw~TT*bFs5mS~$Ie8X;j2Rqg-vKTpZDKkioHhUUep>CVP@6sjwu za3lU{J3BZv+aiRk@-Rx^s4tPAh7#P%6ZBRswwieN_oc3bl_V$$JVHK13mEouj?qAv zm(Z=xK5c#pm}t9Ye9ct}Or^R*OK_SggS%~lSNk5c}MwbLF=OMttpc|4D= zqxhX>{Ofp{AO@cWWIPFMoZ+v4u@d&^vu2WJ92zBr*Hh$jGe6x&Z|3h@fk>VN2Iv;K zD;44rtmX`F+IA#_G7U_Wnn?-k;?DRqaJ?8X4mO@>4mrps?=S+1oOa_`d_3&9Ep#DW zoD{l{DQ1N(Tq}-Wi2J0`^DY12PiNcXNXU~p+aAF?lERD+FOelye#3O@v~YG==o2dD z6DsBt6k}dKjbhj()Z$7rNi8L*@kj16!b{5xsu5R8-Y7al7uMil%+mSBGK5KI!Yk%m zBg?E*)TDa#FNJSabgZx$tc+`=4_6ny+|*lXH7wk4EonT#5HmiWHe3})VDQxh{$YxW z{VHR2?9mc41xIZFQG8G_)fNxLX$s4p#~?1+^Em#QV~$6yNu=lBjbpx>#(b|G^L^Kt z@4Lr*|I?W7e;)I_Va)ee$9xCJe1C1sck`Ijv$VYjbpy= z8}q$s%=hLo-{P2WY0USQG2dIqd~X}`egBy6Z;ko>_L%RMG2g9YzPFG0eqhXZXw3JH zG2ai4`KBqAjK8)q-?Xtwj(=#(_rqhp*WtT!6$pYH%O^p~cqvW$2qRv9PmbLtP3qis zA9ICZ(%ObZ?p?ch|E>R={J;4hrbcpe@%h>JA=ME={pXO10mXt2%+*HPGpb6Q!@%rCQ_R4EHL4z9!<~7 z&!X}xD3pIY>H8-7j@Rd+`d-N9^-Ug|A1Xgf)JmaA_@0PBvwiO%BS!!)e-foXMuE*4 zJOu9+ZLL}U?-I#Pcu+FhPoYWWqZ8ugKa|M8OPfsT@1sCIUYaw^!IFyz6B!=?2twX% ziM#|M&wnN5pO%zA-OP_MAJ6|AGk^N$DU)-(=>0o{}a0c>Q4L z&|Zp&&xdOeqAf79JUp6(r=Lpc@1xKp{Ny7rKHd`1X1xhlq+R`dYP=$T+bsv%Q@sDY~KO|gur<}s?~@OG+ZIK1{Sjf8HHoLc9_gdsp+b`S`zr`E`+Lin@@G)`yD5<8$1cPYtz-E~>A?fB z^(0Nu#NY_Ea}i>x4TX3H2Pov%?S?Ui8iT%$=7+3+=Res19N5hKIw(ibUW5GieO~_N zMqc?WWY%^9x2!-^3`iV759RwkO3>4T`Sd;;We`-~MHoXMu3Bd(quZo;NwZNB=jN?= zqZ^wSuaz&X+%h>h4rHG1hIUg~72jrk$WR^(VX%5|JQ3p(<@>Z1nCT`ckl?^sCYu0i zP8WFViY0Y-1UpcKp3O3=nH1_-3^h{-p+U>N*k!zlKEf`Ne++@3qFC)MJUbsjReh-) z_)h?02xbI*1W#St=irymgn)U)J8$8f&$f^nI3<{uXyB_<;9cLsevQo}3{|rP)=-9& z-pUC^K7$|aK9Bj&+Pwy(Z?xTOKd0gQKDXh|Qp5YH;eW?qriQbRPqDI4!~cQj7dCvA zJlb%GtHyTdji29KTsD@cWfrD=SN$vBQX;@;PT4l3ir zZ483&6&;gV8Q5aK$dHM0$kTI>$_f%_Qd%%ZcuWlr65?ik6Nvj6s1zZNeH_HHO^ACM z&o4yWRIpHEW+dxSK1_;$H-7+hm7msNXvJt-RUg@E4ZFhEgkQYvgmev*DOZGj)^L-R zeP_YAN$yR-sg*a2yY$qnyX2FglB*%mW7<)OQ%MueNkqO0qkt!@Fgo{v6w`L{-%xQi zqCCE5R=cfca6Qd{hc7V_zC6U2+KTYW*n!T_Fo^l*W6kJE7YsNG- zhV<-(cLYZO7Z07tLLK~LmI+@ro_st8H-eH^)M>v4(}tG9gB2J;jEv}xyMVo<`8XF~ zGI`CzNXg|jFJli7r%BXn37Vv>_<#-ho}~5t7UVbA_wOMe?-7#kvzg8Nb;fnp8s-rFM?j|w|_a9>2|37C%;_1baZvU4+G~* z;F*jU_MiE3^=44s(_b#{D>OE0z8uW|N_oq_OkQ#I{*o`1Z+dkgI14$0`!-@~Mlfgi z+t08$CqjQMRu?UTkIT*+#QDim0IV&*DKIwSF)uHtR4phNlxibAQiH4T(C%R6+O^y8 zj2^&HSH$`b68~`FZZ!kUM$`5hnlbrqU_^ z9iU3n`VpbeX5VsbCPXu@qaHm^D?$P})+$ZZdJzzOl4^MxY0;YKV^kRanp=1c)N#`7d~ zm&yASir+!;N$m+E&}`3!M1jrYcnK;ZH3O8E;0+|AcQvQ-_(v%IZ8QEWN%3a>2*tl( z#;1KY{!xnm4>SHVD$`rnPFkH>$9;>n>r!TbHs#{Ub&-)P2f z{cJoDEX`@g2S($0Yrl)wWclg$$9z9N=KBX@zJEC8n>gO&@^+8;{@$4H#}eP9;>97w zZgE;)D(y z5Y?Jo+{MXqKIJvxgu|;7^V@TEUwWV)hWeRC~Js1QZ_*FLhZJ)|wt)@J&qQU_PR?2@of;x47Ol zNh#QuN{CLLpY)CKW{w9YR)X>yf&PeSC2vUr;|bdj?;-rb$#n15tHKjHT%Gh8c6lmT zIL!2Lo7|RnYS@>%w`uEya2>Rignar#Jf!vXMRoUL147wr_E2~6k;o???oaUt7?I$e z%lmOpIojJv-9K7lWKFu^q3eZ}Oe$&*jS?Mqw9rQ<8#_z{0t%m@J%wmmib7x`tVh_GKgv_UOdxZ~2ZfY;e}1qxsa3HM9t2b(8Du*mA+ zrQvKBRjMa7P|cwl!YS~TH^I5TYvCR?s#%~e$o&TUR8Ne#bz##U;Aznvmsa6KDv%|^|?qS`N z3@IxQR^p54ek?u>$i-?)hB~3RE1a@WnV^ra(+*)sfwJ-T79Z!}I~e%k6|h@GzVHFPB2nn4?yjrmh!Gr=dlhk#9NHlIX&i8@^G`KzsvF;r@l_g z&xRc*<~UMa8HQ~z8}1b>7bl@f!<|u5oP|=eS#dPnlM0(cgMKxvH8OFKeLU>iQ?=y) z^77*{&`;#ypdwN2g)q)xA5!YxmJnGGFiOkT1{{_Oju1Tz)`GRW0lQB~5*V2Y<}Zy0 zPh!C|8BPv~&jyuJYAk z#0YR?g)^@>4HZRSA$b8n!I4=ZlD*e`U~?WB9?n=6CprVkod zBej6VEMk8?lKmSb&cczkF1vCQ61op;`Uuft(ZS-S9JoAWf=wcTdj|DQL6*GwK;fWTK2FV@evv9K9DNL=qHt22nRUcOAYt=E>Yy@Rml5qKuUdXwu99!ZR{UtpWnNfE%c{LWNmN(Z?w zbNm;L9L2G>lYQn;0_OG0JbwxlWUJS}%gYk7d+DU+#_uG1iVa(Pvpt|42Op2-!*&d{ zUKI$ABx=2tZSEY+hPDc@Df4O1*-69G9or1A9qzY9A8bIEf}%w1e?;jxr>e}?GNGmT z{PNyqEu``Uyy0NIu zTYlkLb*6h(mUQz%%6xRwS&DXF+&t6Wv)PSzTpYDSF0)7zXB)V=@nVxK^|GM(letj;&p-@KbJa z>@a?t`&Gc8xS5J{1R~`RsTuD6Eh%a@%DYJC3s4w}%u-z$$3RUL7XdiD>4PM{c<~ac zEo{!f96FNskT{!q+lBj8czFTs=Tsi^leLx#oIYCMxlJF8_5Q%|?3)y!3s>;ei=puP;9AhwbC>NZu}S4w1Eh zI)5(#-d-xED(U2yw98&GuOA_s&d`c=Zqr+9`%=K98J8i2%^n!v#k~dfbq}N=C+^Sz z88S}?umuqV%jL%j0w^gl9&kH2U;nfb&=gQ7IOsFP0$2Q}Nlqd)uAXKOf*kbIaFUR6 znl7mV&R>aW_@x2$t*x2h3T(~RCb`!szcW~DAav^u?kT5nW^ij}y|x#{sZ>Mvj07ywp4R0Rm;-n@G|zC6@APpPu2nOa;td9eBksXXlbBOW zz$JfRch99Ho8NB=<`Yo41k??vvY{b3g8~XD0Gd$*w7&rd8&tKzz%X*`sM+*O;s)9` zXC}(+wd?OU^{iCS_ydL{Fl$jb^6GTkk&6t5r zAWO8F)W^AdThr9uJrqN}2WDJ?=5J2{ItJL6rZvNz&s>VroR>ui%~xp?p`B|eKD>7Z zST|fyf-H)Cg4~r45<2fGoC0lmulV@yODXbz`cZc*mB^00-O@q(;z3YGkrqRnJl>GI z^B3;8@HkSoyxP>G-JJ&e&v}Gli9O2wT8c3;mC40Cvwf~Vu30J|VHf`6E#VU~K)8BT-0BC(8rOJ~)z=Z#C3 zw%d-%gGTWIIPv(Y#cJIlYHIZel1*(pEne|c;L{?e;{m+BvRu!UKTH9?{Gm;^$sgK5 zfU<{ssc_u(^Ox>uinL763tv%%t#on6NGiQn?W6n3;lM5LuOYSTCMY2k5I9cgIKb->Ha%iB~Z z|D9UI5+L@*+of~yYB-+7iImmZM#4lB^B-_@+=GbQrBC9`Hyiz{|F+Sy(CBN-Mmt6u zt>^B*X$A06ll3gTp(?!Di;uH1i@O$!>BU`28X;AR0br>;4x@Sc0q(W5yJ%RqclpJ1 zpY{N~H#C7<#EF#)lafunI(eRJGlnSiWN=sS735fj^O2vSMmct;b0;x^mVCVa^}4dT>&-D*g zF0qDSzPvu&(wx%a6*?NnuhPed){nPzG=iu0;|j#uk!Bl~BCp^J7;_0QZR52x^YgKM z{}S#>$2p(#j_8^A|Ecr2+L7)7A)_0l^e|D8L{rR$-0ghiSF9o5a_;;wy=eK-C-6i= zc3h;Ew9b&{Q6sF|9nC5A+SR-n8S!Sw11V-ZzW#ab$f9=eRy3z1n$c`sMUAk6GMfzv z5`i)svu9eoF+U|&3!m2-v?b0%#-VdMpG#}T!Rl`Tc;J~n)l81-3VDFk-L`7|xbwMN ztL00x)eoRtzf>sM>AU!ico`0mK#i0%C?MX#jq(7geKI5Ve~YZCI!YPzSL9D;t36W6 z@JW&i^nj4twR^BoHZTlhfJACw$xhhY3Lz>1;ryMwLcc@phva}hyDy-tj}2A&t)V8^ zx39ls>8Ks)@P5j1^eHd~>;OmU3`Z8~>=E))KY2Q#CJz`-Io#v?oi}~D*TK3K+?Ir+ z%MLhudg?)E+c~u1DUY*Vr>9lCLdFF?Pr00JZ{QopFAFXyxY>fzQ-r+UVJY~~k+R{Z z4l6>XYj<3#0eu#Q9hYdQE@jkfo3Cdpw1ngN1$b@PFkIyjtO0Qy3<=cvg)y{O$x@f) zF2<|;PGgHptHN40e6peG z>Mphk;9E?bXs1r>$C44ckRsi>;irOCyval|?rOL`;G?|f*mQTe`=l%+e<~zq6?}@8 z>uH1#IL$-`>R4qQ_jiebgV_ZmXwa|XAzb=ol(BVwdu=DJMT2ql84&Q( z!!O>Tg8N%$-Mpt6zK+0kKAyLwTd>DRtb+X>>~amCQ0ks5dJrWCc;hbviL!l*`u zr6>zBJV-;@Ln!ONn;gXSixrob(#}g6$4k+tUY;LYf%xpo#_VFdhAHt~L$+UYLgs;q z>$;neNL`lb7QB0&C^NkW5f`v%$$1>|0o3N z{ox730fEi>TKGOIn2zPR`4z4`!f92dN5vd)IvL=3@R|;jypNk!!{KQU1q@1hWV;c* zI|bb1j4=Gzr<4vz2g4OM4m2jMT`5%ctkCeZnr@lZ$IK14xHgxL2(1i!3aiN#< z6~AN0_FP(*B{)I`Z4gAq&>=f+=BdghZd}c(K|Or@HuVgjgq7a_WCE`7=Bh&E4ilx> z2tI@E3$EI~(6X)*&9L~^DL?=KJ>vpFQr2rmP99R=?AWVH&NCp|YX6Q?jGxPV8eiR~ z1lx-cThpuN+VdoynDVng)WNw)LUW!*iqr;q{fI?d4~>YClZ(>!O?-r0q)JqPj6XUyG;hcWkAN>%J(yIsY58kfZ&o$5V-l$M=DqU+*`R^p|>Ohr3C z#x~Sp37A_BeFaF11Nx@Mn9?{BPAk7#ysCVY=q%srY`+#${P$M0Tz3>7mS48&!tcom zz5H@Yv-Qq!wYB=T9%tL%QMvmBU+bael4C0#*d*R1YlWg$)~*z9k+m!_ug2N_G}4td zj_}J-`n)43$RZ!k*MG+XAH`Q9(53&cp>B`VDj)Xfk7EgtHp{0j$?uHFhf{XE970O{ z!M$vQ)-N?=^hY<*>Y)9TSW_d;k+lqQqO6URJVS@NBzNdfo@hOy%Nk?SoIY=iD&6sp z@d9RWxfwh;9{jS!0|SNY5R9y1TJiDdm3R;RDa0mwknRF7Bv&16f&)M(R?UMh_e-rr zX0O5#a3l3JI!D>)P*&NMTxFG@tjdEfn=!&_4()TnLXscF;x6}}1KS(nlaUs~ix5-& zNz56laL8gh-N@rU&~ip!pq9vbff{Sh?|wH$`_V9ntD4ET!A`!2mZ!Nth4gON{W03R z%w;I|+Le19%DsXzN4YnTBro6;&2(C2{#38)w3Pwbm!5C4UBi$dWs z+CWL4Kz=wN*t+TA!sA8xZ#Hbt#Bt|-j;!O5W(m@;jU@itdpggf#US6bEZB{s#CF)h zN0L|V;;v>3@j5~3C%9{dw4(qc5BGwSU`EW*Fmv#Q6~&a)Y?mG4^TZyjfvMm zzFg#k1WCRQu7oghuFIxJvvrRH&%RVU{-Y+#s-8}Yh&V!>lmXH=2sN{T0DGa&vEvg9 z5^aL)DqGi38Dj@-OVTD5ir_em(VXPoUnLJ@^4M-ajwR940o-|2o4 zU~WlO(B>CyjU(zs6hPVCpFs5biTf4t>uPOGt+Tu9lAwPc1%*z$$6z}?ZN(_`6BzVn zbR7EQ(;mAF`Z`>Cj3NbGAD}GZ@3=}pP?iYl%9z}G29gc1*UmNtwWzg&5yypiN_s~! z1tl!8D=1-!-MvJR{y7YnhO&|0QR}?a-GTSb*M(Z07Aflw1gHAS2^~lqe`Vq;Qu$2f z_*{J^OXP|yA7C*&Rf8Sh@!n};aE~ulfmH9Ha+R`X(ug5A+c9h`oiyx7WBoRPnJM5) zoi_tRv-_0OR^#}CB?LlD6r{cmDpVHFvY5yj?-SUknbYHvpX{J6=HBfY;=vz4-y-&L9gbpA#V?L52UF5EMZ}PWa)%6 zb&;BE_$^*P3y?#aaL{37(j;-GQk%BeWDSNklvT;3$)wwmXb(jxbE%o}t-O3DJE@v_ zf5aYw*#1EzrnylwSw1z0d4Zv}7(>1_OMcln@qt_$GZg8(?!q9)hNO7tgoaPW8|$Q+ z)RXSFl}2InmFn$w)jhp7HvLk@D^iBslkILCLByta@s#dY|LQ(T$#O1BmWpKhJMNQG z0}^eXAb(qcA5?@PrT#wUyFQ*Tlf|+0A0T~}R*DI&o@~dOCy3eg+F$Y6px*AnB}(wA zQVO*S7+EsIQl>B{7r9iI{E4Bg9051;$S&$OwPjaj9Nt@19<;G?`pVdJ={#`;k($bk z*Hq~|j-q_04e1T<2qGc9R4+|0%Xl4Ez+zs$SZr|O5+^LR=hdYs_hnpCz^iG_M$vy0B%LI8cC&}HIAgzUoIRGLM zX(_c2pHLdlOkdMcso;0XDPgD!YVDb68Tw7h^Ma*~Ji~9GmNX|C06C+4l&e|i6v&y$H>pwGv*M*mkv&)w-g)>@bUg{3D zW>`89B4x0tsJ?vS!}0FKD_|er(ow13n3OOxvMfGr$A23{WhAnXL5tx1s6TY#gYmb5 z>_Eenp`e){Z6-WMo|TK)VQcpLn;-7bmuWnYk%l z@L&bjF9EZNXNZ*S;Q9*q-m7wnH#FOWmVBZqSh4~}&Ma0M$xE`qc_%8N$qxo(vb;<% zl=;ebyOBy$8@^Ly!C?9qEOK>heG91fxzq}Q+|Xh?4J^WV>SSyNKePIMUrj&HajD;>Psiy8$Lb__XX2F zi*Ja}(BcknLUiT;EA#7-jgt%O99Zk2MCyLeslND`DY$$Du054nm%645^PmibXvF#G zT0k|_gIiIS~vl9TDw9ocJ%?8WNNLe@MSAj`qmMP^HGuvtF2h)9kh~1 zmfkdyUbSrUf5F2$x)=8^=Lje54br``E%Q_s1T3s}khke*=*S^pWS`HqETs}8Gl zhg{x10(KrZ;70h{A82k$`Ssc~I3xyducS$naBF;Xib6twRd7&*{Wu(bEl`?r>E^ik zxI1pcj%ALN2?Pl)wb5tCfsoFC&33k(hbRXuWASkvQ({n+jusy; zTY1L$$eRccUCeKp6uP+Wfh_0#o^WV42&FvWq)XMD``dc=;j=qthkH)Nd(`>x50L@x zHlsgAqS`?$^+%MICzX{0%F5GN_LY@yMz2=i?<*I}(b{;@$k2o=O5qta}QF!gALiGDA?}#h;dOWt zN@HJj?#x3k%dz#&2w9!Wu~p8Uq)TwNZKH5)k+bbT@Cj^h#P1$ib2!_hkV|YB_Kp+@ zlARiWwVh0~Qukxi{s6WW6Zzv_2tTojYK=J~uOPh7I|%&4F9iN2 zL&NJOFhsXj1VDU|cFOA0eptX-uXxWx5`1%?_aqgs&y=-0aod$PUOWT?Pz_;G0S(kn z+QFN4u&jOF^OTgA0~R_;Cl**ke~U!4`7UM`T!^!Vyq^l z{!MB*VxxQT*{KmGyfI&tL@<&gbn&Zn8TKGmg=N!_j?n!O^fIW{#FW~-s%J#;?xP+y zTNLr`#qPeS9?E!W1mf8p?}U(7%$8dRLE_9rMou{rG*IaiNn)G`E@8n8t+S;}bfh)% z$KL}{z;J*m9vY$~Dw4IYIok-yvX<&>BaI=@)J6}njwWE+r^r)-uwSz@n30E(tIzxD zSMaTu7j_?uMahbr_daVg7HZz@q7Z`7lg*=_E$oi&WZ4Fxo1xrkcwn&!0rw=l-DpCJK9}{&)#yRQC+G{nIWR^K4Kd53d$``!+#GON)D}`!ksU4{XoA?+sEF2*QI}yNFZoG zVHpS5v6hD7;}j!a-G2Om$t_STZk{lFQa%ooo#DR{rqxg2vT{)U1mh(HYl(L))Mc&X z&ED7T*vSm5y%~KH-cDnv{SM;<8)Kt(u)XVnaTFuERqy#9+~EsAq0*(SJg9YE3qmR# z#9iP$MTXP`q4-pU$QR3~p6xbUMk!p1*TzC+MRbFe zl!-(heD_*$so{CK^`ynwejYed8%KtEJmU33eO7TCx?;AT4Ze)M7V6`NdQ!v;gyy4r z(2*FC1BKG*Lh1Zak3*Vh5+Q$czBU=Lkl#^A#QPpdmLWj~OU@?|I@E*dGt^^G%2A~K z1H~auZhaHCL(8q_E!(N>YGW+2&DfyY7NMMe-y-b~`RE`_#_cypYR{0ckcDd}d2Y3D zIoftq&oMzUr1ORp(}-Q7dc7ldF&WDH%v`MwzVczsYo7#73*^LXssC!{Ld(1#Ewrq{ z?@9dL!0+$)LelII)nrA%jMiZE>MMB zxF?;={wdo6%GPr`vcWJK-i9GVlr47E0+M2W2oQf)Kv)$2M&t&HmCsa?0zODeC+$0c zTODiw84;SV*51|73S}I5a-(akD94M8t2spSti+Q7=B`}nq3 zsWxmn}=5E>1t06Q=fEwjDky0Fzy>L3~@4cc4jpWrr=iQ(~T74 zLd)zP9WKpnQaWA*-H!jEMe;>k%fA^6a1ehKLIP*`U?ql6v#r=@GF85nNh;qPhddB+ z!%Ymi=0+C-Jl(pvZTM6A#-UHY0rj5;lnZX>@7k5S0_k-tNr(^Z0~W$sh)De!BPwiVlBdi6Lgvx{h0~&n^b7IERlWDYcLk7wUnyYJ_P>kcA9#T^arO z?*MylAvV z`4K4jV7}^SBhqi=Som1PH3#|>iu3c4Sa0O`%#rvq5Zj!xY7dn`qYW;)^H5T1C)r>n zk2y?Z$`d6XnGHG;!Id@UCI($@Jy48c>`=Y=NrNtz4?1i$;DP<0A?Jvc!#4o$Jnc2! zdDv^c30<|e_aBUg>lyJre4}`X`p|t&oC*D;pO;TV&MXy0(!}v02E&b7OM9=#`XggT z4I#VU%_yfouz9oEuR?}Q2Az@e2odb=cWkP2sPZPeRm4$~J+P!9(n0QAAIEkT76TT2 zIW15Sh|^+Y+?ho8{Q;+ZKga+$$Ftn*G?LdIhtd{CflpbTZ2_bJA!>DjiB(z$ znLL@op2`AvHd`-DkwV;=sY+%>E(H>}R>AquyJ%RX{S4WD*NzlIwN&fc zJQJ^wB!|bt<*Afrcn5nenVt>|@czhmDP`e{umS_TEk|I5!1BUW%6lF@RrnWt2HT91 zA|vN6U-jV3ewV14DBI| zMMFqnu5Qyr-kj2ks@8uoT5E|VEFgfv@HaK`%r_J7toqbc!C_B zbPkWIVN$-2LqzBa)z(1M!qWb}IDVy83k7Y1o&%B57t9Z+mq+bL#3@e+;+3!p(X#$* z7#ntMa1388hD>7|$%?A%V=S65u>#D15JJ{g0dwh?t=D~Ni{OqqAKZp{V%qR#L-z~~ zw0uF>H1phl8U^3geuJ6a_dIr07CCC)d#KK!1=?`iy=#BVo#YUQJ+mCBu`@zn6t@H~U(89WE^9K`cHp6Bt5 z;TgjdlG2^v1R`j*#WrY*#W7(}gDt;ZXmQ||k00dWO|S#oMXgPK=Pfrw0OMuY04m~X zBjQa=;%(x;U=;tEpPu{A5!4%c7PT0|e*u<@@QSkH{c(Z!M0f z1U4xL$}Ryg<@i_^rWj9e!K!1D^AM=R7=d&~axjo;Z-R6Sp5c3K#r4U3fb1 z#F@=U1w6rKJZi@iN9U6Jh2v)z%6lBYr|{cHWykxa%7)e_^#l7xYm@o_Z9^I!c3HnA z*#t%w8moIEPZrRCh^#As0G(_)>eZ95-XIoe_yA22aZ)&aVd-DQV{M1UIvymwpK&q( z%kRIt{23?J^cU!C0;b<^@kDg+Y1%|v=7U_xx|`Qytdx3&pvbj%PjHZ^7)dzdCdvMf#_q12y85uqPEpjaL}8F3bg6WVzKe^XaWDN=@gBA{Ilk=b;7h9!?c+ z<5aOZwE=p)oKgA=mkzYv&8G@u-(c(cT)g|VufS<$L-cxr7mAJZ)|Jrm6xkUcfK@#P zWWjJ|d}u+sWOvy0l!A*mLhgk|3PL%Tt>4{Ef;jmlB*PXwY$?au_e*?~XNnmxwlTb} z=y&kBxD0E5E>d_xrRlhM%j-(fn|jkSt5Jx)nYRULBVGee_stdFY>-LjA#27sM8KG7qT}tguOV@K@3~taeediEk{U`>P{h(gJ z50IP>R%4dwE?`$go5wxnK_gQ-#uc_Y!1sWM_@b4AYv#a_3L0S%TW4omKA~`xKvy5- z;8nhuiW7-<30TKgMMktB3v4`3V20(QPwlbj2 zMNXLhdP585iPx^w{)!7d-96w5Sn?uD9x!gvoD)z!P8~JaJ}sRp9d0xj5L)jM66;K% z;*@LFHua@e0#XbF3nLkIb(cfG9f$As7XeX0JJMi7nIi&Eo%!ITl(|PyhI*+q7nb5+ zhhq@Pjri(eRa}eGFigQzN9-N&@d)_nFk>#RfD)Po?NRK28sh0mIc%oxfOyRs6#@f*GiS}VCkU? z0%pPl_&Vov$A=y~^-#6NE;1zD_g9qoN`vHRX;y%y(Y zaq8%R4zoA`$RPb(uJf@2%F5hhx_aVvP{*uA1W50=HC2WcC%eLA5WPfh&9y+>1W*Rj`P2knqZ+CXVCy;kdy8oCE@Gz?xz8L|1`6u~q_MhBZ2wJ`K?(e+Au+YrYT}O{pZ2TDlhI1mQ1ErwW>NAX-5K`gr{6%NmdkEoi zw2g>juJhgZ4!mFtIe30&+W~xUD7!}O6|+2^4Q08~1^)P`uveYuL2<`o_4S_mdY`|( z9%q0{U_Yk0b@Aqv+D~xf8%-HVD#hvb^()D&ya1_;*Fn*<@ByLJVVWmvaNHR`h!t80 zydJ%t1O`jp7l~xVAr{L^r>cFhGA+%OF4DiD!ak3xt<*fI1_D*UY%d9ZB3tChbMG!JqcD}F2JJ?nO+Qc(~$(-ywCYn=)z1f$>k?NkxO zZZQ71!%+tF##9DdPkr4VIzSlpbn^w9eNy2svMXPAG^{>gw;Va*UvzWPszpUbj8}oB zXaL4rFb?nv!yeX1XFHL5rW~RDJ7|WoXhhxYP`@ou3+|3Mw#Y3z?H1ANUm5wj%fS8b zjZG*aqf0E_R*qEl+E20Nl@Hnxi?e%gu@3>+u#E$+sllbFq1tyUiyX)+AOoV*lAU_z zUTT}3$6BK2P~pu+z4ipp&%GtYJ7pz$MNns|6?s0jBG;$gZze(uJISmZf+H~#!|Dck z-m6dvTBT{h5frXrXK3jx#RPy>L!=YY28GgyXXj~loOzNuVWoi6x{uQW;}SC<=dPGH z1B$(tvwp})-m$sAM^Vo9JS2@*1}!JbK!urRh0eCu5wPPEs@2(c7XKsdYXBr8={R=7 zX*x1YGQ($`CI{-TKy%j6z=Hz5$R8<-_B_U(2da(oEi-wHPx}diNGw9}vgU5K*fY6Kmu)ca8?4}hnUmc&O;V6k6EfbraJw27zjX$=Soy1>Plr40O? zV6(x*Nj^Aht$sa@ltowu2xGA5T?Jqu9k`|WJeR;jP(U&n94KOAEDy{L7C8SoF zVUIYwMx0h7nhY%#dRR6xhW0viBXo}l=+bc#ie5ZAw7>Kc0>dfCT;la~{YI`FE20}s zJ<=Z(X;9CBijYQtjssInQw;jvIQYB;>e9U=fSUdyJC*A0e_$@=?@QthFf5(|*%b1K z<#>VyINR?9w!xIMa&E;7u@?FqMT+S&kp#0?yb4bsN*wQgQOt_Y=jmyB6O1uxJecYI zAw1jr#7S@#hhYqd47J(78}k)_6ItmyNQ?@63|WT`g7L{1h7?XUcS zm%t#PzE=C9ub~*OP^mRM`gl^PP&Wyf@MN#j0FJx?zP?^^Sh@VO!<&&T0u8Otr~#jD zm$u;mo;c)nq=@(81S6*V^Y1ZQ4M`9TJ*2E1OkPIJtXQir2(6z4%`LPAIM2B2BbE>_ zUI7EHt4LBeSg*Z{;YC`&25}-$^m?s1QJ&XP}446HX$U<6pS@@OUSB_sLez*hp|B`%%DpQS(_`eOm4*YggNW5SEFUfZp|I|&4 zl9(N~RzR5I8D^i-S;pL`*2}y~bSJz@RE!|)%@Dd2{1gimBtUpTEs~=DDN;dR9PNeO zJ&}q_iMLM^ZzJX#rY>z&aNxTUC&`!>0%;wNHxLc%hoM1|H0#I_NPlooWML=xrjMUA)qIN@`Ze3S`xha__8q0LFwqRvkG4BNuJLnCkjT z8TcLibD4EHP*)b}61E71U}~?1qa8d2JRQS-g~82VEmS!n7~Ue7Bx$b?%#mBb4fI{Y z!g+gF5T_(xn6zn%e4$`#E=Luytv#y!&nu9052?C(c3jwpuuT(pTzC;ro=U*m7Dy8) z0WIvrS>r@D?rBfDt(LLTFwZX!)Vm!O}8Swf+;I|dyT*Oslo@q}u* zHy?{Gw#_Yv^hI26u1)La_6^0ReM7{-Pja$C6)TF(PBwFZpBBOPnyz)fo2tIePlN-D zc0bpw1UADh!RM*?4x`c5tGD(n|si$!6v zG|5Lb`>1B$Xw9;t$oOL2NV1M7Z;Tpg2x=s2#NI91R0~eC5g&HB>aphtxvvuRW>dne zvY8v;6aXG(7(sBy3BrF*3#Nk>T*YZY)+jBw-@sA!`!DH2nSkNKz1f^X`VyR9{>tzHMs-Y2F(5mA%pnZ?&T!8# zLT_~n+zy!^rZ*bIGM<+-=CqOQz(}Rd=-jS$2yb9Z+SZH^=+MtO+x+x)d~ZJ{Oj(h* zN$x7b>{&^(C*swhY0h~J!-8qR3y`we0~OQ@1CXi6t(q00DinC`=RZ@XoPHPzwue5% zbP2V7fV~FUfk$dT3{Pl-2`C9*ozGPmkSDkgI3K3-4WSMuQ}O5@j23zB=aG^-pfc}% z$Nsa(6DI*t$Zb(y5@&_$tiT84IdDJliMwwr&KLea?41o@+{abmXC1q>)ueUXv~iQP z`TIk$WLviEq>UrTj$}!WO=MeGa^lu9@>;u+HeT&+cUS((M-2&FXbbg0?+9GEGuM_2 zw1AKEapA59F6}`I1q}2c2Zg$&1#{_vfdZzqQF|CClGXyz=w^KVR?7yqS6P zX6DWOzwzE5I7NiH#{^9$w>|z%SJzQ)w)-5Lxley;E>`@r%b!H-{>q%slSOiF`adk0 zJ^Ra&v7h@aX@BuF?vH--ogbFGfAr;@AUOOAO7v!wV%A7)4(E2Rm&sZAFCRJkex5dR zg!JWCeeYX^z&)oF+s8ikv6pYT|E--eUwG|V7DCP0pXEPV^-YLq)#;?)KHV%a;Oak4 z&i|D;@-7*CrTIh3>Tf1JpHt6oOukO7U83mPA=*B|kXBvv^x4_f+nzpqOZDc>RoP~J zVK$oor(Sr2{y!Um_NfV4;5zwYOnxH4khCl9`r zb90~2s9i4v{PZ%Rzy6rst@PJFxpCurH@?D|{L{m`xgF=bzxs9R;O$Z`mb7fPgZ2@* zK;?J;km`{*Sf|?1N5bGoY@)M^|G>rJR*Bj;?w%S!e)b>O)qeWZL)cJ!pO74V-|N{0 zslM4({rvZSaE=gp_ShLp|MHz|gjDC-pg@Aa{qi3lJuZQ!v#SdR{Nl@799OtrsQebL z7CLyV$MxdTPX^CEtC;S3`h2?l#;4C8Irv(S?!}{j7QB4MBLmehFmHW&y(}fODD&7i z&#r*lJAY-4ct~5ZE6qK$99Eh)j#s}dbEA)l0B0GE8w1{cocHl@ydQn#cRA@RF{}OK zyR64}k32uT8P8XK_rrZWeoWpO*53TeX*tDLeeI8lFCKFS#7B%lJg^Wf*z8i!%jXd^ zdT{(~)5%v}k$W;8x#w@!z18lw%eF(^l`((Y^Wtna9{!$EJeFdjww?MEOGcS$A(_NR z{jpj2-xvD7?ircq$-?h)uAq3Ts1^y|_ub~4w1~6iUt)#99OXoVyFcz$E|<|PtvmlD z*Lcu4BqnpU_k&$MB>>kK?FB$@;EZG(qIQwqixkae+N#?2Q@lj0a z2F_M77G-IJ<%Q>k-{=1BkM8)}zxyN348G#Gw*-lusj5waq-Hs4jMS8q17t5d&263# zldEn%^C?UW%D+erYo~U@dgWa;!`$}`escDE`#w2atQa@E_mjUMg>DAS{Z&k?<{bUv zdtScfJLT@XP8!YYkACK;*d;yNG}>%V-NZ$ekwzo;R7+`n22dSeX?~W{cx_JCBOm2z zG0dBuocn!q=AwOaX4XuuJMqf<->|uKiT? z_w|!gT!HqPPm%1#?*<2MaNq_9ZgAiR2X1iS1_y3%;06b7aNq_9ZgAilap0%_WR}T% zWtJ%e-vj&z@Z-Qq;Fp2V0bc^n0sjcRmiPhC4r~DWfl=TI;QhddfL+8p#q%`qCE(A2 zS${gq%m?lS)&kprap1dv9|2ARr-0u8{s{QLz}EmVpLheXNX;mifAjnKV;jw{1MCF9 zN>)wg8}^M~HEaIt-rn9h@_T!`=@uf6@z{#WA;WDmg1-8;UQpE0G< zA%1g-!FK%Ixjg3bCr;C13TD#e`D>LV;ZNv)M?GU;lX?B3Fp-d8A=CtyISTpTN>CxU9WJdrCT`P{DM zX;?qm0vs$BCbESp_{eL!mZxFdba`x2B33+q+t&!6M)O6;6~=;6F;}Q+Gr%X4%~*bJ z&5e|cmEveMcqCVms_I_8JlNqHXkTt$IbA+1jk}3P>AicU-7aiu>bHgJpb49mD_5Ea zd?^cQTK8mOf1!A=uz_!ZXRCebO0|n7a3I@XEKQcw&$=JY6*9$xW^1-mNsnbW77ulq z$x60-&zhB)e4cY&U#5?{-x}%TXCk-vm*+n>Idw9%nLgT;r+u0Cn_gNu+#G=k=GSHo zx<-=qUS?hj9(GTb%ha#;{O^ikQ#qS8=6~w@j;zJ^`@-?=;>1L{km<`6vR&r;CH*7W za)mx9hJ-@9CtInOi-*n6sjHjTUIo+FW<6s2tRg<=T^6zVp;-gj>Soa9v)x4+35HsN zd7zrHp2$UUZ_4GfgNI95GipQANP*Ip!f3I}y!xg`bD3=Sc)C1T+$#NS<6+3oniake z7JUTs`BY!`)^us0TBiMW8S{s6_oK$-EOrSMYQ)GVeTdU0KGOQM(HiqXDS_m#U%ErK zY|O1UJzCCHv*Krd-fYTGR>tLhWijYUmTLe>m5_3mmf6DyG ztR2<-&cZ=@mbuT^nw1=PaVs&UkJZ+1YD?*tsxhCD_pWXR#!Z5Gd+%0xACPxxa$T8B zS(>N$LaGn>;Y0&vdY|CzEo8QjTCP0YyJK5#pYOl%K6>N*1_y3%;06b7aNq_9ZgAkA z9|x*WZ#324+!$v3Ezd;n-t$0`dSBI9aQ`gcMf+I&P_L<>o>+W6` zC64EDG*_-v8)UJJQW?l}aw1*sU`nl}XJTC(p)kQ>n=Gvp?nIec7066g=IL>|ln!T4 z$53fxq*@tferMl?(uHciZ2w<5BIS0u8c!d{1_fpsOue-#vuKdh)7qD=WL>q(JQ7?T zzzV>vCYVyWSk>7)ex-8mfJ|IUll$^HCbBZ`NIJ# z4W5^ds&MikX>x_2I-aWpHO{=gBH(`hiS4*}@+Op+sSDY?So|cVSzBFQ#Z7~Qk2r%jW2Xe*93VBvW z;oBB-b&0qvzi4Yr6tS9xAjtaMln zfs4r?By4Yu1T58S+moW2x-~uUK%qEZ%vGuzHU#NXDa%k2q$@PfT(!-%ZkhsOCwSli zV#H#DU&IZ?o?xsAmgJ;K+Y~L8Rs;GjmaS%Parf2f$ec60$9IONrlMD{~ zWSuSd?#XOWBB|};I^@;H*IqN8b(O5hLs1h$>v}pXDK+$x=^M)jS636cL$)auvIpBL z)x!){ip|k3<}=QBNsc4vEFA6$L^RXjsWTRQtHDymzah}TrDo}dr83IdK5H2sq(@n1 z3DUwUUSv%*Z!*Qg(rR$HI2jydJR)#uD*{zKtjm`^c)>W!h|@xzS|5}Kldyv#&tE9-JNIJDLsck6p!Sd3s4?ay@^^HeaEcYE5A;!VMd_7N?x%un+qVt&?%29zTUXySNS_KG z-O|_7-L<1<>PSJ0N>|#;QX0%S3hq+fTvEA^EwE=prDgp}V_=saRbWK?wEfm9d@mDZ>@pD3JES?Nyz*mto0Yq6)Qof%pDW*!_Z`-eRYrU}^>PT%nQTtW*>_Lo&?#U6 zB9JBdcn%?5SYjwGs>Ko(Z%>tMezeWSl^u4+*r-XyB4>)d>faG;+u7F_ zWXY@9(c9I%*?AQAJ;u~Eo*x};E+#wLpS%Xl!bO3Rz$^T;*|PQy8{S-@t*l(hgNW=~hnaPRLgCsYN+FF=9aF9A|=h9ZgFm36{a!I%n_Z?vh{63B} zFP@SaPX~barrcKgK zrcSqdigeqAmNcK?>b^XM91b1Y?;Zy$G6xN&(jNkwb66`k7P2VH6SN}8dNcq^Lbty&f|x39?r%T~=>#O%7( zuhwmaWKBA!`Ytkpt-W1wZL#X`BGV)yy&7mXWk)+$CYg*FuzSyXDL(qf<4AR7b}W$0 z?pYT+NrZ-Iv@F|D#Nm#Pl&yi3VKIx5`AHT-$nMJVMPinb@LPmO7)J&z33pvtGdj%G zNB!G(3=Vg1@9Axd;x4jFdTQAth!c1x>S(w`QY0pi-oZj z!J|3eyNl!5!U`rTnP79eus`U@WvfRzg4Or0y}xbs{rBGwBIrDnEy&yjHDI({oS<TWYtm<}>pkwQ4u*^eAi zR_gGg9X%EX%DUiKUt?5ooj2^Oi!%8!^5?oXBJ+&v4)N?GGpT zbL2?aI+{gq^YQ!oh95>!+PI-iaWWuVeQcs+iTe2OdRKSXw&90%_6|smMR-)hzz5zv zDl08B?AKiZ15c2*y#wn-y2`4c7bh#T;<+iv5t-32rJa84SLH?mL|(P(uFbh zE3||bA68%RN$^Y^$L=mDogM6V?8uHrWK>_(MV;-e?)ze}9aWOPE^AO|9d!ZXzcIhR zp?_boSgH*`Ijjz+(O1?>*4G8hy#m(dT9-Q-{n%;Mrg5u?Y$p`Uhl7LTvj3-LkaiKO z*$vjJM9D*qW1IbPvX2EcoulZ`5kKDmh^cS9)H%R%MfP>=m!E|HXvyY@Qt^1oAbaq;H$uw zftP?6ffK;TfsX(m0zL@z0qwv7;8tKha5FF$m<<@<8*c?CAo!(BQr55GJ_iU7zRdFs z@OeP;`V!Ai04D*-m*Dw0?~*Pa$J71@Vb8t>KJt7{-hn58Dv$wo0ewIxa4*mfv;cPk z^MRXzxxj2d^7zbOu`ka1xjV@ha2ohD@Co1rK*}WLd!F~_fMx*;2ZE&;LE@n;3eR5 zz-Iv|htPkP{7V_74DnyPb8sbr|NZqZ+PAxA6E@$4AAPlZ=|3J!|9dRBP>jau8E=Ax z{0eAjCOCflc<|U`kFik|1fvC(QsRmB#T~JCmqnjvBOQ!iyc`()hko{r|2b43KZzIq zoMRRq-v7>XrBomh&btKi-tc$clWrJ#VbAmD&l4#%>s5v~d6lQp7oYg7f2n`Q^ZbeP z)l}f3%yrM>u0-*8cb<1;b8+P1}UH{`EO>rJ?x}Z(l!kbj}$b zNwU+B@bx430{M?$+^^kwUC?idIjS+^X#Sw<4`!2;)kFQJ> zFhl?U_mw}rU8A1*3O{+1$5%Sl&;Bg ze95N#qI;SzoeA)fNZ!XrnCkzFE^iFc&GH_^Jb0b`%skg#aA+k+cuM|D{ASON#d9IE zeOrroder!O!=62Xpx*I?FT7Ikc_E)K+yvS$DC#fp{6eaohfQRCdB<1(zi<|8!mu3H z8UBB&h7IkVq4Wvk#L64`1&!hv!#TV#ioP_Wi(k`%h=)h|m(-rW zC}{uqPX#ltU*v8w^}#v+FFZlp-1&dL_i2!kS@_-R{O>$}Xx zO#kxs`Ti5I4nHN(MzfLAk0amGud3@-}#k;%O-j!}U z(%yFe@SbJF!*p;&)&Ro2f8N(~{_jDaLrmQJ`i5H847KWWHBU@=%0+evzeB=lq(e_& z4+OS7#9fb{(9kuD=v|itacUT=XbCr_grWQHy9J+Mv~k6H#J>{{C$_sTEHpuk+-_Bd zi$3uidcc^4@_d|gy0S#W3bHVATT$QC_Q(?+dNRy6e5z}SJmCFq!df>hS-i&#EyleBpnisi za3j!%b_48|6J!?Su^5lVyN9WI8o(a^A{DpHESBx`z*63`ENB@jJTX+}-%z2|hV32- zhN^_viVhz4?nO`SUbJU9W=`HiBP?rO7Cf26LLOWrAup0G$qzZ@iSS+Gvs06=B{t1U zmy~$g&{mSnzndkL3s783-~s>Ot=*sT#sfnwQn=PV%L65?dpEH#pZTH3iS^{3GiLwrm;eVq*NBXT?;Urn$1m1e=Ot zB2B9xjyB%irg?EztkFt2kl5nn|CltiEZ?uZBz{sQ?ww1kO_>4nwOS^hlmUycs_gDt)1T;of5!MEl5xAOfuE$+wOaAj z7>GISX+r;~NF2Y_wPuNF*M)6Ky?+#w^tLV}YA6@g@K9u(v;lTEIed?$zZeguC-&vW zCfU$iDHR=1g~k185p`4yhN|qmRjiSrH9d&T`X~GkK7mK?#wMT1aW5>{F9!)RoC$J}E2^Lwbo~NsVAJJc8}-sQTG62TIPXMWxoc}9h((*-p`Z`nt6yG~J2JIPTo&ZU}LWiKxXE*6)!ux-$A zS~~=#!&xln*kNX;d5Vncc6RyzHmQ0MM+0<%t=m@r8nJhvqBtGWoS|>XU@0$pR*5Zg zAv;}JR$oEBOo8jl@MX2#=AS8Fu(p{AU&6+uT@ZukDI~_!0x2$!8dOz7kr7FmCM!F1 zoY7W~EK(D3j2cB)XRr!Zs{|DjwLMHKw+RJ0Xm|B|FkLQyM$1m`hXagOPO>)z@@sJo z!?zgUV8k@RH6rKLiiM2W1;%k+9xB=)zZsNE>=sn^O0Ht!!S*3=T%?#tl;KM71-^?Q z4m+?8yY<3)DxsXn&t>pb`t}U+VTA29d>776A#|}h3F|!BB-DVV#!K0$O-0T1EGj=l;jr==IRMeW9GRPhmcA&Rz4RFmPW z>%#kyJWj2X15BK*74wDdK z4y^kmPMtsMulRdA0Kajq`lEAbyBMU-tof+aq?H%;@X1nl-e&!VrLGP6`qvYI+6d&> zRHRchbArg}lA>V4_Ppq0N+)8Rh@=j+eI~3$Htm^#MSUfTDCu)q%(!St8&)@_BMmA# z?c@3h#;sAN5Zw_nWyeWtb|&kR*+5B4!x0f#FPcOsK3T{VnI+tV0W=&Pdd)3XYLLSN7RcB9uwOMj~MsLKTA}Sn` z9+r6|#lr4`PYbI(k+o`?z=)@U+>*A{5$q2husl}vV2hl6L$Zn%9MG%7#;6w0AgriC zUl1ga$8nliqc{u`C^^i@RA;S9y;Xt{WUtsjHfpRg**?gj6{}8*?i5eY zX=BnK9OrVSXwrymkR#HECDi)9s5SzBoDHhucOaM1!EV!?meX_A zJS@5!Pa1V8BOe3svQ27;VoEy@5vF#lGI)q>lkFWc#TP4f`UD1c`@=Ju8?;{}vx~go z{Kcqin4!Q3Wk{u7)*@-UYJ{g(fkmX!8)^RBgP`p}yMKo}>w;v1btUOK&R>PZG8sJe zjU^?sGr9t=pa;kCYedh}Qt_;9ozBM5RXewDbEh8us&=p5<3vQvuRZkBhFL8Z zgUYxp=j(XrdVVvqqq%L(+nIaT_w1Io{leCuEuEG*h{A6C5LTF7D@!>*l7>?pRM6Qr zV?={AE{ewBUH2M-fRfquprDI0q_sb)*4PT!Qox2@TCjFX#L&g@Eznao3BJ()vtvx$ zK}05?-oqVjY*4hcp)S=I7|*Fo+%Qe7z%dyj>pmR4v_qv-o0L(we~+|JneeyW3nQGp ze9+7hh32+<+AGKz*B9N;O&r2xXeaSIDn{PoV>?H?!ZgcV8gSUtZEp1UIGs8mNoW^> z7fA-%`{X>Cx}#G)c$1sBKWko^e`Dli2Gdf2pKV+n!b)YWzCBbfPL_D%J_%uWu)*=) zHtzwo%I}jQS=ge#&WF3qnMbaRYySvQM4|bUoPxJnR_B}Y=2i0kYxpxM^j2-1BD}cS!w(FWx>Lg>?f@maic4HWuQ#Cgw7g(JeF^s30 zyqD?H3vHYYxXL|7ed0dBE|Vw3YJ_0ntn=8&s_% zTu350Ttrziy@jewY}z(hA=0*iB5?Ty;!H(_&IvS*j}e4o#>lB~!5cjBgncfQe1r%@ zlnH6cqM0hl=fkNVcC9zcg=t+eTse?#MMt#MTA<`!O^XDrZ!z>W7C=#XN2=R*I03m` z?17m$FvyNEgjy{?)=}+zfFzQ=0lTP&eeFUn&>0n7J!oyEJTla4`C7z({puBvH7%^& ztFwKD4Yyox=d6aM9&FzcvR_8TiQExgEfg-0LMZCWjUCPzIu0V4MGIzM%vB)wC*}_1 zGIA>_w)Mdn9lH`#CfT)QOoE@f$b-0w^nSYx#NpNhS?O20G#D)k`SF4yGLA+&H5Aey z!xv2=Rt~|A{N&7uyE7u#$02gJ42R^XS=XbS5f6OMoSqsDJ%;Yl%Wml)UCU{o?MXi! zbVw%?K5$ZBwyxxzHXihK$#jA-n6;_!J!5FD+7^)_Mphz3Uie^=dKyWadXcPKHU+YM z8=#uWyhGx)@YDmP7Qvpo<=`pphXd8%Z8aS5ws|0K(C+%@J$AAzI2573>qKrAb{i^o z2K^v)6x-WD)$w~f54z6GfW2*?W>O&Mx{e&-ZUB2`Vt6a3t>mZ-3SUdGaBNb@p}w?= zAO9UWB9|IuGujiZezZ&$(jIs zkyF6@CnwG!61wjmma7fY`7i{-5tuK=~{UoTF zQ@-k_^jgu3qCYUG%m_%T@SZy7EZi`5l@B;n|h9MQUan0B5A+mRzG zr{#2zo(=RQ$x(~kI<~A;d^D?;@0!p~)8M?vNOX;7OR8}Yu-WPkx&NX?g6t6~%ljio zeC1JX$vg{Bw0@?HfvKTmOHCf5I*>YXcwB9?24h7TtU0wrE#|Xj31{m~X@zkf7v3wM zSJbliaaM@RTvHMZmk%&jGgUdTPX8wppdp=oxmz-aTORmGk6tGcI72kJqsCv#D(g?O zJLxYQLJCxv4$9qGlOJF}6s*i3eh-6MEwn$5qZfB(d=W-hOYc_YY`|b)#KkVMVZD8lt-gPGSt~~Jg zA|@dB5b<&YLJO@++o*3il#5YzN&zHcf>hhcu9TCTl7Jha%-xW1hX zPX^1hm8xC7oZQiGM5=+NVPP&5?&@b+9C6la{3Azn1}I~g^2fP{57KP#ToFlzn()jh z>(IoBWmPUMkdcd)GwGp>Nom4v>jjNGlO_7A$ho`Asbaj~vl+n8Q8Ww{e17WhW{&Garix zZ8uu`1z$WYv~f9dq<7brK{V=Wx>Ayc1tO1EZ)#HaR#vv!mB(~Z>7QC4p(%&bj~p2( zRM)T8a6d^}FT*pVj1<&%6?v-13X<9LvsywiaxrF^?|2S@jN20L$Pvv&B7DI>6mA~`R}(gEwC@^uAFQCRNNDX^>xY1?p4H%`>x3Yc@0572fz4}`Z;uvolM z5h9w*QHXCRUE0RTvu$gQ5y`@(c3^PIAzlBjNJ;DF^=tu5Taro6$IDj&^s5XBdXG2x z`jhI3;nP*RsW_9sM_UOSQP@zx<^AI=QfNr=MJH_=<8D{G=xA4ON7Axm$JYfoEp89z zKJWm05^`TzIOjm;*Rs2jQThB1Mk#liSL|X$L6%j^V38~pR`{UEA|3slPI?I`wLS-; z863NqTX(zzq%cA8KXRs zyvFHfv0;hM%L=*RA$Md~>R0L8I5M4x=Pt^76dvU;nKs@+5>pQ55uO{X0}(c%+s#4f zcr}a^8GwAzQP=TaJy=izMN}(MA8lz}E=;6$$ z0(8Wpt$Wu5gtzYWudVmA+X50#FQseaOcxe$Uh5^qJvHYwo;_h~vw-Sk8y(a1kOla#dX&W!Ij`e_+; z<>VdM!oP2GcG^~&;USkUgw_nutBVukv%k;8we9i>#5fm5FbQaB!48SR6S3Y>Ze6i- zsD0@QEPia0^=DuLn~wW!kR)iZdcRFiU-nS8EKOIP#7*AOBs}nRq1cFU8?Hn`=5 zuz%a-9N}5bIO1cj(7x`MQi#~(8fk6(nEY80)O4BvnWpI&B|7L-_70&f+cs?%Sw|I& z9pE&NtB0_jrS3-Tomt8HLgp|X8PV03Dl5y9JC?`f_8oSmDVww-e<_+&xOLlh1P|FS zE@b2`;r{OK!2vRBFaJ`jP~BZ<8yzR7L0cPFPIdD)$Zb=>7MME%t0(2+BCY!iMG4#I zz+jJ(8b-8ihKKZjy_>1d-<31;Cvsg}{A5qbFH}1jx@k*auRqP9HZHRMACITDV|Mq+ z`paF<775x!OcJwaV>ccYjT)Y_&Q=kd3|8zjTPC=p(-V&?NVK84a3yN@3Z?O}M!Hh^ zOSe5+f?80Nn*lq5m@!pdSVOBS`kYlf{f+}Fx=d%-cMvT}FE1AxFt_nwN22LB9mtnj z`niiJJt~U@E46*tQ_6L*b{@t|xMoWOvQzA7m=$+Nnvr`|^@(?<0J%5OsdyEAiEC@4 z1sSF&EBt~7`CLJ1Wi7xe&_|AlzQf$txxK3d-ma}1 z`&fNRx`)+%pH3<4tkam)EAP2y>y9;Rh-y~fbC13Z z40i1p#QoVl-R2Z<68Jdq5#Zjx+-N??^Zme4pbCrwyMP{G1rPwY0yhH&_}UP6!2oA~ z&jFtWJ`KD8JP&*bct3Cy$OA(_KhO!R1(pCe1G9niyTJvV0X_%32)qD14}1`K1}FhT zKo4*)&;r~E+zQMEzVR;Z%mKa(yaap}_%!ed-~{jy;5pzJa1_V`yMTURGtdd#3$y@t z0`q~{!1;G_M-K23@LAv#@Co1~@NwWd;3zN->;n3LwLlASD`0@H?xJkKY2eeqNkD$* z-$5C9{}Av&;91}apaf)qT|ht313Un%0Q_%$s>>XE6}ArZy3F32yVU#iuXdU&C;Rwi_liH$Q>T~eyRPyJF4D7d4+`Eb0rgXhDi=OnDcNwfwc4SV z?`nK?Z=WOs=+V)|s8QG!h72F}kZjJfXo^u~(r**9ju?K8*MnuU^+O3n7`o45f@?r8 zVUBs>r%48~7!|sFIE$pv%_gdR<5Q*|a`$KGAIsAtVwL67+iY4dV~5NNPx%;S#bid) z#H*^go6RG_*o~`*Xt5O^mX9>qFxeogmc56H@L|0k8XTmf0oZuy%z-qA_;9c!pRI!4 z`j@k%JP6cZ-bI_1IP$3rc~oGD3y)8TqQPqb+_eeBb0~@c^eDC9cl{?L}!~K{X;LtR-w;b}V|I9F=*m`V&VC z41ApMom1jsC1~T6ZMfhUyHs1AbY5D%w)faN2lFfn7VbZ|4Fu4LzuT0EJQH!z7L)O; z2j#Mxd3v3>Dv(mvm>;+q;K3DEkf-JF`TUTMkIu-dD*>8KG2{;4vyNA+fT*9ZGrfP( z)taUg3+9BU9qARwk>IyScs}p7cbiK zm-)WzWOPhz^DmLf758yQ%g=IErxmZVCKJ*OKM>cnr66YIECmfz%Y&lY4air`(a#jy zxGXJ;9S*v=-0^5hG?|IRU}LCprZ^Tg`5ywB`AK0g%B#O%pR?Ki_I-EHf_dNpNfF)* zp?nDa7_PWIBIakgtam`bv<(~V{4k7fWv<5eVe_m&WILXFe5qI~RMlzbwJcMS+nQK2 z(=isSO{R;KLnBzcEuv7y-7@VJKiOyM+T7dK!#h(DI|r06Xz}Uik#f%N*f2Y&NJEed zQTaXaK$EPWFqmzEwW0Zyu7SxsZAv>zSS5{bo-5$Id91I=_2Turq`D3jhVw-VAv|y1 zw!SVVUOFj`yKOM-tZ819H!T2jF|`DvT(ZFCT8C@CO;UX%65QPB9sAtJdMX1! z9LX`jxo=CzaZhY{xw=^w7Y3z9^}7geR;9QDkH ze8dIIG21dQK%{F_s))~MJxIE-pPS1&^~(}lV-ikMRZOZ)Yb6j6GHC2XlHa4em!OSFmorJmM` zWvnK>4Y3%ePS08nAIgv$R~qFZjw7lQBrH=w3Z*YnE+58#Dkg{$=3bkOC=B!f>5lj# zDcxFPTX(o5Zf?7SG#dD4Fpsc=IjYHrC(_@x8d^cS~M zwvOJ_!}^XimF=Tc;Dl5kOEkKcf=onTlkn~N%z%6bOkyNM!?{CrE%PcTHxPG|$RGJI z2E|c4(n+F0L{6yC(%ogoy!a0eDs>;Q&V4YTDb5eOMJH&@8vWmxLlrwOJM$Y|W{~%O z=MH|o%PiqN0AxNi|JSlO_pAme#k2`lK`Dx*OiF2PL{A`i@0`hCe{c+wu;@thX zckw<5Ncql@KH&XM7k&bIpD%QqmjL|{|2Xd-a_*yq@8x}$b05RKg7+3c@SXWp_%{Ln z0CAh&gkQYB0LbqY@t@`W8RtHOyNCBq=blge`Ml2sBz=JUvw7Al0CAr<4ZnGRKOnzT zm@Ao?QG2G|J zseeFz$Aup6$DR8G?jhcHId||P>3M&^xsT$O^?};o?%vWK@motg0nxdZ0XyX47pGL& z8*uDbhuR3+!k6mGRr_JMa7oQAq4}k;R!*$Y%Tek>iyqO|%5o-L<_B$;O*Vj-@9YW*4}M{U42|iV$YTr?eUvsI>_2%bIETlA^OpgtT6^d1bF(( zMUD_~z%lyvFzUU(p+-xxsOD}W5>h?{X(c_D1)bY#6n;hDMim2_MXZM~ifKj`1$>G^ z_T^=NT|?ByQBDFc0)=U_aj6fv>dk5{x@Qj~Arr_Zdp5%rM0(~cGpSlROm#=Mm}nLA zoMe_I5!1$8TQ7{`z4uVHoJRK=E%I@Q^4B`yKp%Sg8c+h@Mk#km@oRV`La^R2QPrqcdI%wgH-+F&+ zs}(+_b&Z0hDR<+L)yCwEq^#$%yEnlnaB`eG4LA^zt%%MT!wq@EK`~e4G^4gOw6s-N zT2yUO1qM%<=ezGEDP1!tx^A(ssyI3t?B@`9qWx^;Tt*e;N4`3;gX0-8v#}q>)X#{@ zB$YO!@3NSZz_osLFoWb_`gj>~l<;sai)QLBLV&LaICjJOxKxz8xP;Qg50!zS?cf?S zAZJ~Z`U9E{Hf3EEb_aYosoi1G{TIFzWIG#~%hK zZ8@LdtIQoIWpB=&oM!PvX6Tw{tq0n1#3P~2XE-Gf=<{;!l#WIZ2WYrG^5t4N z-q9Aar_I(TUE6JEOTTIx8;@`>g4sdPuBb?r$SpCnF20NGzV_RoQ9&ZYq3r=0(iZ$( zD1`$>du3RC;w zd>1ioqgC(cm+9~;dq2O#hu?(v^IgSevkfUB6>69Ih?n>AVl`rK9Oc96j8b|RNIz7$m%S$(kHNP}+l0qL8`h6#XSmOiZJD<0nrY+8 z#gH~?Soc;AWml`5lUkGBj`)r;qH<2YBP+J$dRc9b1$&Ofdr3&Uy~ZP6fucE!T?Fk`zeb6r3fnW>nZ)OaLqyKrxK%ALYEyd?3u_A=&D|L@ zwW`?G<2&>Pt^|dKt}k_=xW{SQL&7ZQ$a}Zu?RZvnk zqjW79B}MCYCTZL3)s%IKb$L(q8vku#+iB+L=HVUvI{}sCfi!UF_+@&xRi?VsXNWQ`r{8s6#|I ztw!X*I*{(yZ#aSmy;F1zd(#YD300J!WqK6_wq*t{*cK|O~By(e|wxynId@t>l7P_SZ>5>uc8-D z*!Ci;Fm2g;Br|feg;i?e>pKV-yNDuJ4O(pn`%;;bAWN9BayWu@340rjze%f^>r}9L zkQ-vBh`T=suia|S;0R;O{h~~!nSkm(&M?iLa~GlxB#hauTHUYuBD;2~5x}1d#2feV zR*sZp$;QYIb6pyww~t3t@k%2_4R;))!4DjE#J5GKtr@!!D=j2C_JK0Me3F`4+PReV z9~lHd9fh+{#Cdb6Jxxtt4i-C2*UoriVeTXJ;d(=0c|mpB#6gQYc_u4o7~ze=3R~lgi5&%j$-wcqa86Sv}9L~tqhi6kzVHim5-q+W2c^- zz?y|*Qf4dJ7`^nnk8WvHtxHr5i}e9%MS6XeOcJ^ekI1Madal%o?}Ldrn~I#Lm@>>8 zel$)yD2o&Wn35RI(8Nq&(La)BsHKmER0C;dTs45UQs$~1(uS6?DrcM9?q{bGHrj1l zGdw(O)UYSmZPiz9AQ)X8jIPlO;73L6FmmM>{5ovM*#{q#?|sB+3O9Bz1j~tE_X$n* zPuxO}YI}MEa*M9ONjH}H2L=p%@hF;C-xs92g!06SjGBI{^B4*u+M--M1S+lq@zWq= z7qeWZUNXDwPpgm*07?D)sP&Y9doAnY|!8yuY*_7n6z|dPpTI*k(!ru`I#cR4eM$aQ}BFb#b zk?x5SRYkYs%vrf8=a}V;4?`2eLVCZhTM5IXePQ_q3Z+(~7b~h|_uEaHwUQA=qkNN^ z^*NoEIPnmRq4pNxRlu%Y`w55VOPon@j@7o~oh-3*>8dR@cI-VhXXGojRX&;)B=(Y0E3e`q@I;4i5`bU;fThoW=58YVK$rmGN3aY8( zMp#}I)~Uo*YbaUe?baqOYlBnT>!8h!&FUDr93BfCK)M&e2T;vCv7|Xs6%1C5gYDjd_L>#}QAaM=K*X9`{uZfpHA^lpI zZod&seys3_vLek@%{7F@c`dhGrn=7U0orTxXuq}TSS)3eQj|c{x9O9zt|rDaMee4x zmt4>TGy@`}Nh;=Sp%Gq}oPFsCRM>ARWOiF3a;4=S5ie?|R2!$5=N_qIB@t<(eokb1 zM0If*A%bTO@~cElHyrQW^4Kb5Ti$-Oesn{hB+Cji$bVX5V&t9CYA9Jw=8PrjPZM=*&bK8v@ zhimR_1i>$r8_};fKP2mB5P=ZI@r&Ftw#rt74oa_R$sA@Z)$MY$C_ zGq@i?N}lUWBnadhFzrr8`mm@0dZsGs6)LiQ4rI_Ep0nxkzH&F0e4ks4I^$I*BO7aQ zNC_1JlxvE3phVg;iq*$MH-}XmEXuHn@i4m;~&mo;SS4Dqv zDRh*Uh*~xpfnQm1jX)k1w=M^kVGksyrR_=S@D#N3Q_a@*Kdvz4o_DLLp)>B|YYHRda$705WHCW+6qh)> zZ|8y`UX6UmK9Vvme5%dfD^U_V^vibjC@dl$tOS?JOq;^VJXILHe-xXz zUW3qCjlKQcmm>^|CGdU4S{8~v|tQorE$LB)+GB% z-LeCvthcc#Ec1}4Ti84Mnz`RMni1>m>W@>Onm8b}J@Bo!wkL4Pfl0x4nD2AQM*~FW z$+xxa%-F3{JZQGKdzZrngSHJi;Kco%*EIU6wTF>;+G6e=R;9{UWQ$G|807Vs<@Dh) z9=LQOH~o682;An?_lSzjIfu5@T(4|6KWbX!>{+m0bV#}VoxMM%ekk^QJwcM|8cbL& zk^OejvV}o4oj;g9%&1bH%-Tz`l`W)E0~NPs(t%r6IK4B#9o{~{N}g=^Q!q+~|CaC) z@IaRgQ8M?V`2`D;VFTcc1%a<+(cO11vUir##>KsUL)@(c(R#rJdBWpA`j;$vAV)aA zz*&X|wcLU3xX5`ARUVqellN_0TC2Oa+jq2v0pc$g=4t>hQ3y6{BF0#`ovg^Uy82PC zBDN)>c4HwCUv_b~^D@Jh*{>|i1R39?p{L4`A<7_4W|&W$aC2nahF&WK6D3H*smve_icaiv8Tx0GPs%hP}E)DG8p7Ez0XfPb&QU*30k+u6@`daA!Pi8ad!DYG`KJhi-WYK zeWF~ea@H76tjkhT7bil(H!Pz*ZNDETg_E@kAtr?l38Jy<{SKnr=Nb5Arf*HRYN9cz zN^>pmO3T~LMXEvd&zNCfxXDRhmX9?>B@JnZblDz}>JbgAg?YM~bZDQPkS>;>Ej6cn zum3EbR;q^S(o^iaB!Z!O5K}&OPvB89{e>$qui38b6)J+`9rk8MAy9mE;CFDHT z+WhMjDp8^)>=%7qAev-tjRj+!07$$>j7y}qdMe^Uwh^g+zy9AS@f2-YGbLsXu2q0& zhtCE>tYC_jCmm}ru{$1Q>5lV@vVtH968)-4`nX(q!9mR7w7>LA>c7X`(cdlKDTxj(!ho!g=1TOL#Fs2;^cmpR71D0IH8B(1 zkNJG`L&T0Y(ba&B^4DL~hOHu7!YQ9#i`^2-vq zT_xcFWI8VvAmLbqW+gf4)7#^%CailUTsF}&+_!}f67ZYI)?fZF`5@sYj3trAa##H- zhGn!+cXnP{mMADGpS}843 zfvv_pv0YEe=Y?rr1W7SaL0I|=xTYdHNVAVD0E8vBR-OTdSV9PE`nThR|-q#KZ3JY@ASdjeefKP+RoOVc?v2Q;}UbCz{TCKrJ3RzZZ?AaA#P140+Hd>95t&vU>}ehlfWnz>$pr5>9>7S;I7SAF=^OJzmY2)uJ6g>*IJI zvZ_O4aYX9J`#zi~sVtVb!b*DxzY`Z%O}s6L-|RJ-%LE^;T7;Ii}5Fq*X| zkyVHALeUP>Xt)SlB4cO2RH&UTr(zFv zh{&)4R^~kNITwThL#~VnzWU>QyI|UQIxGG+gt_XL_SBaxjPXGo5pT9lifFTY@Z#4< z*onVqzgz^O;=~Qo(Zn_~vhh6@OB4EQ7(<3ycx@Lz_wk7_TX3)I$cMj0**+-s%4}Us ztYsHfH-Ew7GzIh?H(8(sP?0gReqiNvF9A|6-8YM2B-0G_Y0>z}jor6~V^f(atqknc zM^J?yFV|_0?rO_dt_RgrIoVJVEZA?N1F))T7e?hZ%C(nxTG2%g{qjQx)%l~VgWY>H z|A)0D#D*Pn_D4C#2W;QL+;>}#rc0_0_8JDAl}Ib<)(vlANV6=k)4t@Bm@QUo)m+j` zMDjl-_Fj>l2XoMuTRCN($jirgEp5)Ze_K=ycsNz$z2N7~h z>dbWbUusrI$4%Z5JyR{On%B|M*0FNc+>`#WyC>+VIjEMBniHTNxPddtnho9=t_9e2LtzWbKH?Y^Zenpa1J zuG5?FU{3g(HD}IEp(FN^ioIXl>+Fk*eqCbU;K7_ZGvk3)&m}d6e}3(NjxcSel?`;5 zZ>?Xl9sJAX!A;>Wb<<6=LdU$U~{Cvj4<7T(_A_Zszk^ILCPcst>DP=W6)t7cPqET(38g2Y2{iYStZh+~gh6Gj+!uud=Q=cf9$IJ7&Kn{N1tOjyDma z#cBATB)eV0=QUC2SKog7&98gS>*wG8hFjkFT8)3}9k*G`*Ykf^km9z~o6Kx8$GpnC z+RQccOp|$y{@rYD(ZAQ4*O~d|_3HNq{r`=z|0V9N>VA`Xv$@SIFmExpSXHr{>?Jim;SY<-uy4F#KPmd{{@zMscE?`rEa}0RDDlcW|s4} zLjPYL=A_NJmvevfaXy4KHoYw~{W=)e8CQN9*se8+Vw zU9zqEvfdZ#Tge#K6>ra%){oYj_@Ad6_iOZiGPO43RP<(3TenZ;G1fk9{_l6?^P!E( z827vU@_I_w`q`1FNl#tMwk{D8FRj#QRIAaOO>NyizQ=gud4mHN%Yg^NzI?GMFE{@B z>qhx&MhtC^4pcy`|Q(mCh1%6nogg*m~|E3sy$urZuIQCBIQkDj?>*b4X-bs z&r{QlLblcA;PUDE65e=TT@EDsh^LkGt#{S;qwS%*o>@PV(XBrm2|eBTnAhn2^2fm> z)=Q!L?O{o6>Y451OhtD`$b)1I>$+0q9dK0Q2WfZ4Y?CZOq*-#_PO*WseSrz z`}Cnn-+I@{)aW&)JEk1CT70%89G`;AS3*7~dDw{0xdzm)Zh38<9=nQk_dDE;%A4d! zUSpn2Oi`Ovs;B`js+dttghuE$vW^x^jDLzBLds~VOfo=2a`J}++kO{TpR*JQ}8 zOG$m{X%0+7_n`s_ktuSMl!Csr%gvJw zq(v0>T8s-3wdn0+>Z!0Cmm??N<4PBmH=@z#?efceG{MhnNB29g6Wt^iuU&bkr~6$A zZbWe}zkV&Qr>}Xtipn5wjrsgcU8%23dA~cv+n8=LZ#IANJo;4jc`DInq54!)3vR_TQAFAPPyv$dR?vGAG_3D;4UcTD*%P;R5^Y3FCw3m}f?Y7?a zt*t-*hZsj}*)O)d_2a(RFupbQ$q$5jo!4`Gd9U8nx7F+OJbqpD=N~iw(R|qa7=K6f ze|fvwe~tN@lteyG(l_b)$Q2qFJ{pt6GodTFxO_R8EX#Cse>{;tp>6-7x47Hm^|5N7 zKHNTiXx#Td#prqeYf;|kuM=Hg#`yDEls8V#zh5c3KjC=UsD3@I`14B9^*9^R{mJW8 zzaP6!bUiQP&&%g?Qg`xvPWpP+$3wm2V)YG=H+p)U_UZkTzV)ulr|T(Q-Dflo{?t_; z|NQtWCHiUO|9&QX^FCMWY3ZJD^sX)4`dVCW{&TE<`tW$4Y4m>i{V0ibdb&Rw=I~0< z{VxvV^mL;HFR)&tEX| z7x%f6@7Jrm^<{|qhP?Ukq;I_|-j9AUOl4DBEIy6LSo@UlQ(;f>p+41A&p6#Ew--w{ z!XDB6WSEyIG(?g=_!( zRE;#fHaYmG!{?+F^rcVw*1P`s%8g`M{^^zX(+LTE`F!>zyw=a@`TV~UrHtZUet9EY z^5#pO^tG;Ej^*K6(p_$TC8T`$bYBc{U8uZq9$Y@%IJW8e9FKW%bbrpVz)~2o1nYmAgsU-eyncp_QV}6UjB)&_>|G5Ny-`?bD%>OPZa+71pYrXe`LO3{*b?9{7c7wCV@YmBV)c~{@8rke8v2U`O_MDQU0P7jqBrV z0{@>G|Ch}F%<#W#zH0uT`E&CZ{GUu8<>y?2-pQ22wEs8G-^tWpx)f7|`w|-S*XC>H zZ_MACzvKU@=%25lFELN1rjCCy_4hNT{}1LH=9}gpYiP&wE$^??;H!_HO3g~$l$xz= z)R!(<9>Ft*aQXB2>*K#VH8(Xc)f9^pkMG}KQ-h~I{w=B3re2qtpL#w2NAxUp?|y^B z;@uMS_cZa3DTwJ$-slH6&WBnuiK31(yV!Rf2MRYISN2K5Yr#E1jQvQun6b4ov;` zj?{grwW<4KF*;)JlI}|9=~D5nOFa9*A*|{^!bzizHwTb-Kj=@wOA$2Nrl=F@2Vhcn~H#npRXSZlS|r?0Pgxo%5sjg{7bGzt?x$&U@2s$4eIK&z7UM-fv6o zb~S(H>OGmCh|i7kb7i>eYq;^#=Et|6D9+W(&rC`+G=qBIle+NVccg}EVr@&fll8tg z?B{;Qd@=PtlXA@@&V@_0CskjrbX~djr7q=fB#}z;I})sigqN0|p1bnQD$g&5 z&rus~^fsF4?_;U4L_hZ_W?HWLvNtN%bhSFJEjgEZOrQHx`}NrvG?w%Fk`7;zi`Al$!4E-KjF=nl6TfNl7jgrd1`h>vD5*FlF=O`PBINIC*|T z^W8W+@}0gN&b(X^#;f@@^KxC8Ts)O}PwHsuJ5%2UFP~05qkrG+p4Mgm|DM#pN=@=J`!W#4?N z57woRVm3+_h2D6(SPs0et`;s9!}W~+ZxXrxw+YvU^7TU(6+4dYxzrC|QraK6$W*>R z)IX!#H0lq@`2Q}}o2E}Ep&tT%^dj>aVfAnSeufzS!wlnjywUUcC8xAFe(WOC|Hq4r zFI1BC@Pnxjhdxm`8r7c-{m3OyJem6FC8dh;3 z_p>v?_FrZc>(co5t)A-K$Ggq=Pj#C!z^|Mzb5 zEMWdew>boy1I9lAePGxBgg&tO7oZQU{YB^lEvKLlEchh!fw{i~ec(J$`V{nmy`P3Y z(Eq=n4|M)A^nvzYfj$tt2z_AwXP^(5Uxhw!4jBJ6=mWbx3w>bouR|YL`y0>)T7DDy zz=G4z2j>13^nvq0>9?T|?EM|+1O1}U z4}Dr^nuPVLmz1W z3iN^CPoNLX|5NA#<}CDqbHMnYK_A%lf1wX-ei{0}+OI+%X!(E82NwJ}^ntm50e#>+ zP&x;FVDDc-AL#!p=mVX94Sk^fYtRRRzkxn5|8JoWn7@NQa1Izh4}DM<_@owIt(3qbo#J?42JnB8NZ z1Ln`^G0y_#RXyeqa1I!Mb&oj%?3&wSP6M0g^_Ww@+NK_J0%&;+@4#kY7cdSS0-gn) z1D*$70A2)M0?q>Gfw?#Lm<2!!uol=1>;lGtL%_4ZbHMY!3&4xOOTby+JTUhb(gQ8P zT3|D<3m69u0nY-@0nY<3051YB0cU~pz}(l89%up90zE)KFa(SPRp2P_e&9LaBftsZ z6TpkW=YTW7SAp}u?AO6RAOPBdPM{yy3zUGPz%k$@Aeavg-~@0U=zKl-1x^DC-as1Q zdEgwd_KlQcoCR?H}rwyz*(SuDfEF; zz}yz-1J40xfR&2Ij5?FK`Gr0h|SbHRK;S2D}KEdng}J0-guX01NJg zKJYAX3OEn6za9F(ao{Cj{yU%#90gtg&H*j=K_7SyI1S8Q3w_`aZ~{0B7?U!y%uW2w zHg7Sn!o9|il0X02&AtI73i z_)DhoIcRlh-#`vl0TS1kCjR2_UuWLv;=P_Y_i3o$^jPG1Dl0rqb`;SZSgW&?l5bn$Zd; zeI{c@_)7!EWKG_Dz>EXmY2IV@^EY9Rny1Y75cb{XefW<8`%TppOv$`kzvc5J-|?B` zUdd<7d(C&5r_J~B_pi*e=KIb2xsiR0_*GLhWsQ5#93b=qrh@AO3WooU-ZLUT@@DvA z&|&`nfc`Hxj)=efqPHl94>RU5VhGq@j)#EU>-_`#$?qfl{d@Bt%yI6blKUBd!2F>3 zpoaL+e;c|acJlY5G3Rr<{~PE2VQvxrA@lFdhtz%S(T&FJ+GzTLy}(i61Tg=d8%;aV z50rpoz=?NlG^c@cfZ4s#1VB5`3G@Sdff8^OI0hUCP5`HX)4&FfOCNOn_+MQ{XhvgDuDkno+p4az&Yn<_7WFp2l@etw^yFPG2n#rJH_*ydpBv~ z0}{8BXUV-E<#`-90i1SzXL$DSBagt|5pV*>fm6U~;0zFC2m_7-N3-A?1;-d+Ir#G! zVZbqe|R1T zP61~CQw9&v3G@Rc;23ZMI1QWu&H<(ZJ|FyLMv&;KX%&*!_%mwy6X@+Z5^S3lOx zC?X??F=q}#fus0 zShzkYkRn?!rl(`5G%`}H3>S(A?b}egP|cTzDkJH_$`P|QSE=L*W5KFr>w?kZWFZq| z{(n1G(i=w+g)1SEKtf`ZPzWHsgc)Tf84ruZWpFGnNPrXtvI(LnOv>&WyX~ItQFpb+ z_QA4E4j=&v%7qgsPFVf`ix7u!;{-w+Kt6!kBz{7W5aIiJ8OHXQBnK{Ns`cip<-J$0 zUe$ZkUD}`Y*mdwx*p!bC4sIDAVwR2l8EE#UX{;UyS~V#~$^@RDDRX^^YzS>&?b$CS zuwa#;=n3lvet8Su#FP%jbFB%rx0O4UlJU6FfR13+gbgofKP8d7V5I0^PmSYFXlu4- zQDscp(xJv0pkrHAs!*V%;`+1Na~+_J9XcdU>4%|;$M#9O`!h+RN ztLRjUQCUHZTHSF8O+#!D$hgZ*NoA_NWU3g3T(#jE&*>!%*=Xy0Q8M4O1P$0)o$e(F zz3vUhw-YTC830x~`&Ge$Y#jQ6O^HoKN{(r`zH!Q8JkvD3&4LAUipVMKU)*ZzklQz9 zLf2}4!boX<7{j+iXGT&V>9bN3#@*mxK_5nCXlQ>~oepBbo+JSn_>(v*JPxT_V{4+! z6647Dyij2z?J47n_M!l+jH!_mCnI$d6GIM!P_~RyY1uGB$b^X)w+I|CEUL)?toQ)- zVPIB=t{$gS9K7_{M-s#~a*-F{>~z9ZtHqoM1LLSVyfcfnCs^ffK^OZFOuY_7>0mt! z0?RPunTRaTSqZHYkk)g6^{lFno;q@*!^>00!-i6aXnGp)w(C-IdB^t9nBeX<3#5M@g=%r6GA1oiB<61rk*iL9TSi0$kb|CS4C)X z8E>KVRV28BljVgA z-Bjp@ZkA2MiJ!>RFMSW(ss}!M{%J*GbZvf0_~uTZ%_F_q&muRnS>dfgZZ+6x3z1``*&{cn{tB$Yj4$sA|I!wad z5${_R?go^S-4`DKbPDt1r@xFQ|0S;j??C$;koFHPoM+54m=6WOZ}Ts)r<0R?#2Be z+E3y-iS#RNg1>RghU;|@*F+!O38H_A>?3lW9OK^PW7JDo;$0x>r61TwKhOsx_U{9+ z|H-U9lC{UO_6tDD9MAesWcVVG`cH#6w+Eu0CP+Xn5PcVdXe-x2{v{A?Ue0g@$njS| z96t}D9-IwT2ECKDF9B)q6%gn907Sk|K(y~G5XZj*aeNP)LjUAt$Ie~J(YyjjpIez< z*_REx|6^LY^j?a~@2+!8)$rm{f**qai_2@5B^}=KyZl$$HJsr`H_1Pe@qY~duUCIv z-K&0E{e6{pZ5vBR|Kg=Y;usFbv9*`iMAg@(*PhtOjMnnE-~X`whf5A;3I_dwqReGlBw1AhZoX~%~E literal 0 HcmV?d00001 diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Dlg.exe new file mode 100644 index 0000000000000000000000000000000000000000..166f8b705f3018bb8ff912d79400da819c895698 GIT binary patch literal 73728 zcmeFae|%KM)d#$r+$5W@$u6>is6iKr76mOepy2W&foup$aFf7>2npB%-KIVk;a;F^ z0*g1>=4M>Px4-OD+s8ER^XT(vAKOO}TMG%n1pEnTTdcH=mfBetH3$tsV)p%>nY%v{ z!P?K~{p0<^e6oA*ojG&n%$ak}oS8Xyw(^c$mUN57qTmyYSuA^SrN0vK{mEa4k)3zt zuk$QVX1_FPk9EmQla>X(vdO(+s9f9cM<@BW(V{^C0KM(u9*SMGL~-CpDV zx38^TcSCM&PLYZFuf?*&nrwr5v2-G3SDHxv!#8ko z;zNy~*3vyb#0UC|UoC6E9m>NW@ku<0XMCCI=0)VTzGksZ5qJL|e;u}1p7;cmH>m5j zs>pBr4Zet=PVC%=T6(b<5R0)~x-UMeA5c6W7*$F;JsLinOgF0R@}|8tAIYUo^XWeE z?NS z-dWN?d0l;JKK=yetso_OS-8xSCX&Oh5b?IUirYZBe!$j21>28jmRf53wPAaRnpMTO zprE9J9eXB=h&q4z=PZ}NfUmeSbZFaz@NEUXRzk+|DZNDRQat;cPO`Eh7h6)~Wcfsz zugVz5e^_s^7z>?7jY}rBQ=O>WDBQ)mS2wIoZQic-2gjn4lXlQTGw#|d{>~cIF$lZ` zs5{iDWvtc@*t?mtX1Twbzf=d9YM)V7RAekGn!>}VD~yL)AFswl9F$CF%ZjE|Rr6vH z%lh>L?$Cg0V>cLg6}hAK-m)S$YOydpv2qt%>hx9hmfNXa{Qn`cQLEq%$Sr;&)VXbY z`0fHAbk^2X^E(M+7KqUYW9o7uFx07L`}j+D3bu=0X1Ub6;bldx+G-#xG?o;(`5r2W znn7KmuZsT=wdn_(D6B9`G_APP@LGDyZA65qd!hcE;yKpTDu_hg)%>fd!Q`UirIxT6 zj|jo=aL3LW5X4$u0T9$tD0tRTzmf=>fiygel7fj4tJ-H?MLorx`-0^QEvNry^@z?u zehphyWLxg9Wlco|0RpY9;d@pAH%G(SjK`@MIC?cJS6GFsius(?fLM=i5lzx;?55Cw z_GVPU_ce_+Ubvc2uzp_rQ7mSlkRnhRnLuYqbU?Kl6iZ6b2BoI>joMHr8&toh&x)xl zmxB=newM{@AA+o~89Tto0_HD32Udffe-w4w!OjA<+5Q`1BM4O3O@a_cr}pjB!WH zKGa0)vV&V*=%`7Zs63PUwZ_LE2XSnhU1A{}@GGI1dJ8KrU`t&fzFrV-1M%0eTBV)p z@*Gw#V_7JB50%ZOq?)Q){w36=A8@hFPE>G%Nme;@P@OcQMh{8}JT*Q)zrifzRlo(b z-w~=Nvz5+j!19&#-Qc9Ho>^Iy5|;zfAmX@7$bgG&u^X$=ndPu!w-A}vQhpI`oGf#>k3TF6vf=2X#hrNGm3aPPLI48O z&y-kV`BU%>(dF;vSS*o)FiCNX*uDZXfT}NRpWatuXOhgN#q-I7=WPvD%+2b6&+a<*Z|(}>(CyIT}UHac<9$_kf>$+dKoS( z_q#w?TIFjed8iJQAkAlpM1BX190V6_%0^u%8mYo{PZJ76_b2;IR&7Vssr=3z^_(~A z*)i&w7NAqhj~(@V$*AXXqn=%(p7TdNk013sA@N+ra;fVvW?Fou0Tm3Wl1(ZA2>8yWJde<&Nouv43 zl<2W!kEAdqpM0AhOU^~}CyM;si{@V;@@=E?llpii@=blb2D)kL4{=Y@=SF^8g|&4A z2AMSpSrTuGev_d40zt5Zm;0ez7QP*JV3f%a^6xJmka$Q1JU!|-ArtlkHstu(*A?mhfS}Z$$m?3qX71 z<`jHMdAJVHvN@s>fx6N}oe?jQQvcL={ZmY!J|x8JpN4zB9bbY`DQHbrtTjn_3?OD# zh)W9o>yaghI5;TV7eoU2SH*`sUFxLX3?dzLSvoe5P~=X-qmiqM`@8Th1eDuW_DrD0Tas6$;B052cuBHH~3oi#yxW78qlr*;PEvFGfMhy#%R}e!HN*ZJE`|o(I`N z0@_@8CW8bEL!00TMt(?qA-SRkbbV3-s5?Xh;vJgc{KXp*%O}+T5`{#Y_7h2H@lkXh zSV5iF_C1md&mXm0JebUGa>sky?B^bP@jfu>536nQnIQ_e6O}rZu&EKFKE&CL(l5 zEo-wv*vCT5OGPPZJ5t14Ajf2mxdghlRU?R*NXS-VnwT4kY1vrJ$l&nYEUQN>f9zuU z&yHOntk!~1ry(A+j6HqS@4}H``DDf5Uk9GWHL%MD`*VLavBf0}OrSrJyj3KV7E042 z?4^FPkmVNqqeOaoAQq-YA@dS0jrlz<)EcXbT(oLHLV|lIK846G+U{m3JKp}mJ zdMAhqoNysq&@ml^l@HwnJHF)$7LZHN#zgX8Jud(|8w8F8qj9`iMYI!+65s%@0WL5N z>~NlixpuUCAEbD?!y96boo+I6J^DGDfY5G+SLX~bDRTL+0O78}le-#^1->dw#3y68 z(GOtB!qKt_-U`=g5GInM8})Np+C&s_qJ)b|xDyBps(p=F(f#_l96&%bXk{aTSb!B& zRX65DAJ)%hYwnBJpB?!oO$^VCafBGr-_yJ>>`?Qn__utp07MYH0+vrp zW?_4<#Bhc00|?8fbrnyKXeiRCSkrGWUf&pAjN#a9Z!Orwzk>l&p!f8CyzZP&QFrgi zx@FhIdnMF39E)8D^AnKif7Yr|m}gI<$%~r7EhIZX0`XF6xbJ2>dypvGK{BxY-x}{8 zEke6cr4*r$AWV&mM(1xxcRai$Tst(Xx6bluL;fpt>1;`xmdidS?fg&vCpo_X^Po()d zBxmytV0HU|$?61sqcqNyO5dl`IJ2Up$ElwzNU@)A1~9S2$6f;qx7_o*AFH%U`w70{ zxsdVglLKLJZ?t6oehIaPjNd}YXt*Ng*)PP5y^aD8T%f?u69q0IJtI*tgq_s~Gqm{^ zm&*+95>hS9;TOp~sQ-w?`1`mMJsMd7Vb=#U9ifRxy0|=K@)t3yG3EO*!ZVHV{8t=L zsFQSba^S}opgnS1ys>_WXi~E>P0b?ly12>BnRU?czj>A2N-&Jq3xF?Lk_*`K2R=SJ2KpA8+~4dI}1&n`z=dLkoQ2#3T11%)VI zH;MYWP#V4GKHl`5i&Hpwk*1HT`qNm6$ylCfRHT)-*-a!AnG`3L7k7dze_T#G!J5%Z zSql23QvL$+Q)|o=evJyd-kU+r3}ny3e}}L37cp#w=j`?|`)@a3e6HfJcu24xf!U&^ zZzcS25jLL)3d?qmD*gn7JoV+jeDW`NtdV#(^SYzZSlMN$O?yNgzrKN$wEDc{g^_d zsmKX0(M7z#a{->+!f5>!38NX>kLiMBXg#D3b44&wTCKKw$*4c#bhH$cMz0~;qx=Ya zd#sfhN^^l-D&6>PrZ|PSl6iUO0=2XyYB`GzG|h|jG^EqwcC?Uggs1J}XQ{TUuwKUe zis7>}`{Saz3MV#furmcH$?%a5j^ynt<^PSkVtg+UN*+-(!<3cf%9P9rX|#ogyAWCn_025iy{OvZAfS%2Y33n=UUwl|S~QR6(SZZSoM)WJI_AZNi% z&cc-CRoEcqMPNc8h&D(TA7`_S1ujaryL|vuqPU^w!aXqNDu^=ggT-Y}%Y*C*+h&jejsl+EBAD=}29{|M` z>>|ZjgnfH4nG6I;VD^^~0XBZeyYaE3#}Ph5h(`^9FC``G(@tDgH;ADFY=*elsO4f- zRcKDv0wq#r-p8VNV(1v*FH7C4`PXZPgwUo{A;hJC#KlRzr71na!NfKe$6f#&OzJ5< zgjIbZI7BeSW~4nV9`N+kh6{ygJVTOV%7z=3(NJL*RoFrm5*mS^%)Wr2oLE5U$>Xbn z$Ve;5E6DDZJx)OlY?rV^HHz$KW1(sIdZgi-e*u&aBv1~QB@Lf`F5mR44pA4P&2e!n zAf``|(pTM>&p(9bn1VM0==mK{_*GBQon->>_49M%ak)(~mfFKh_6>BsnZ_Py5k}d` zYHY>=Co@{{h#pEu%!jc_Nf1pF&xFO1J@`QBKi7KGddB@8>5}C;T5cwnY{X<%;+&g` z^CF|&D2wd5fM0^yU)*3_)F6%WOX9}R9GpHr5dSn4=S4^}amMHPB%=^fS6pD-jaCxb zX^H93E$9w7Izn2PqKAaECd`~5MZ~%U;p9jo2H_NgGcB5qwp=x!Pzq!x_1YWA!5!W26k7!}hK@T76oZHgZstXnvK7=F<+S zBLalt<5S%KIy&0_+K(9}`CH_F6@h&gnsMUeMp~h;JGA>Vx|{C;VX~WFCy`9LU~+(h zZ?prY_!a4+Es;Oo^W}-2UqLR|&I?qMm8e8TC1%fe>*vOa&e!gQ-EqMRiB*>(vO-01 zD>RO)LXyP{#sYK5%57K;HY)7=o0s5ekgIfox3)Y{on8=0DIicxOk|NXW(UPYJc z=UiF|4K5f}g_#o-6qys0Miz{(>+!T&4yy}23FSA9_3MB)9lj_2fo0A4`k>1Z z`Vm!hQ9ir4J&EAKB!Y*4fOpLz+%{f^S%+!SECZjr~x)$q85hwH|2xdr|`r%lj0831AzMFI%#a&!K zKiPlW8Z&217w{jCTtIVPx`pZ_x8Rn!(CE2h%DKaV+j50}U0iKKY4yRej?m-O#~1bX z#_}mH!X|X-8&GK8`d5tT>532xI|@3bLO@J}6Y9c>_9gr@VlK==UKFBux23l5vV8+k zLZ*myYfN;-Dq(|cP$<$*y*RA|D-l6qRoZ85L86Ig)Y_y9gYw! z`dz%I9DJLQcF|LZQHKBdO|-$llG?=^?&OP;g?=QAm=Z37Uq;TO@XHW}8x$T{rB3K=5JM0POhC>LGtME73jneX@6&&=b|@m#x$z{Hhy2sXx>&2pN=i ztoOnb8Rg~_J9ZIYVwB_f&n7ah(u!S^N41-4U>9&%+iv=oYyLD7nJevLB13HC#koWR z%ovn9W&f{Aa0D?37}em#CDwIV1nW3<4D8oHEk=6}H-KDeo_>TeLOO}8oFaM=b-Q;a zWyZaxZFXZqyNLK+q=>5GuHw`S;QhTQD%QV&ca*D0txy~-K@!$!yZJa0D%ayA1Bj_5 z5vcan@-UQARD-ag3oQXpLJemAMV)%nU5w8+ey`p~Y+XxN4Am(0}z<&|5n01Vr zOb1iZTto&(%@8m$B|{MPlSP7xxW5>KTR07@vW%Lgx-e6vS*oX(ogz;WAMzrnW41a4 zy}sxIy)z4>$zK0C`rn)y+?N5=Gjn=zd)lG z3Oi0B`2~eGkgO3?^pNGZM3DH-^#i{4uDYIgB;|l-rNPcGhC-6?~xG z==;$*h&xGV{q4kxrTU=BjsFoXwt*YDvN8978_=;aettl@RJSjXe(KM%`X;nmV1im}l#?j0k5>nKrgbC*@hc_3_i6Ow;Tp&8| z4_K7;8^93EM9~+;N6`Xwy8vb%dIlZ$|B_^GODw!<{_yfz{&NU|Xfc4%gyv+Yq1*Qh zGEy2kMmChX{g1*VP_KOvC{Wtun|ezU1^Rt^0);6#Bn+{5DDVIh1M1RHa$hdFQS^Gh6n6CPVr#bj9zXSJ#F}YD!PkI8%CKT z>4O$^59}agnj24$2h6i~+S1(b0& zth=;8lQG!)jfui9&L-y0_z_-1>W!PAYW}lpV0p5zuvx2^)(HAV27?UG$0V>sh)9YA znyTii_45_N0+9IhiM{-bNZ>~Tj8G(Pmykf9xE0h&+x24;1rgqGp%sH5luGaf@E6;o z9JLIN_c)T1k`eO}Cv=eH4r72=+D`Bn3GoGP*e9{jU0`103*P90|G7XH6oWq51rL+N zh=l{OvaJtJLIBJ~XCad!zeff7V1bB|xrjer5IG}&E(Op+(pesH^ak>MD$M2%w4Dyo)z&BJUNFEga-Zq3OHZTw+alcz^4J$kPJF z6`BW1dXa`-!CR6jatMWMcboD(8cl~gTeG5D^g%buUz8_qUY0EXJnF-CL7P1!%6GLo zqBkRi)r?iSXb&melEm>X;ONOhe8unLbAMQ|vxIom0`6fl>?F;fAg>>@V&sB?pM_wE zjmAq6uqF0B5N{QDP+F}IAboMGbs<;I|F72!BV~h)Dul%nOa4x>SOsLU+==DXC>kke z|H5buk*uY-&EkDMmirji`ssbd2XUqM5g)=e{yrk*VfN+Y?rW)R{Cz}9PQH)0Rpi+^ zsGz^Lv5=pJWnj64kL6S1-abs7*`T4ci8m5~hh9mf{MCjnzB{{Xmwe%_xU=H~z&kj7 zousdRe2F*mdNT+ShKX3m8QdTS65mOK(SAT|M^Q-}<_Tvk@3_-lOuB>{Fhfi)FPp;#OE-Uw;5g$5ig6acGZGuWzS1qLA{(a)g| z5Xy5B_Y(hGV1%F35`(N^+a&>>$b3$6$DMmdzN4{N zLvIG9Kq@RNyM_5fi|uWzikvNl)3s~BB6SjdIrvq8768alPmU;OJ^%-hByBg{=_hSH z8Bd^>Efg3IjuwVj6}k18wP_rU@$3~gPVZI>C%rDKo&GJ+;rYmM-%oI*e2U!EKeBGS zeqZ6a5(_vW+duUjJIjvjBfLoa;1}%q+q)uZ5UA(%H`7o5jLj9VL;X`|AZO3Z`H(DU z!#W5BX~QqWm|6fua*}>|>E&2Xdtr{9cSG{187v)iH65Z*{a8=fd*d2rPjy+C{4z~8hKhC`5~(tjO%Ez z4$vURm=!Ne{H;QgjozPC_z~0xwIYA}l0XsIB?YqTbD}-Oej!~b;A9`|oq=B0pL4er zv|OR)Ge=d5%v~u;*zt;G`Ho?dj*V}Ci~=fH628?&ed6ib_%z$^LQ&Tf2rq|Ae8_#MQ3&q4JjGy}5_(FZxeY%}{~ ztmtUkXRt~YfIT(v!l!&ex?79~w9*M5f`ZEeQ>c;2IN|rNrk2v2Y84qh(Z>~HKGk+f zSP8;*w(g=?hYWf(TE!|>D=lG3kH~1f5BJ8dUHGPVi&MEmv3&F8yBw0MjwNVlccUc`7{dJM$RyFBNnD~o z39N#^MEC9z#eB)<-i)8&h1XPi4}+f6XL4fcFWx?SPR&0y>X`^k=8OJ4SP?ozD&W}p z2oT9vUZt_o=Udcf_W8XPA7U_guFcu@{4L|P!j?m-tIcP{gWsy<;k8M)>qsa z&A7Z%KL*ELg@XH*oAM1~pxN0Xr{0S-A?=CiRJ?!;kjt@a%*It!$FRc(#e{;w2vmR& zS2P=?kqmW2j*HBMNu$eg|5{iO(iYL+8d3%)8AfMY7Q*kZ4bHQuMTo)o@&APyI`-yO zv19yaQinaqw1T!p)VF`Lwm5%+733d~~jaxCRjID^Lm}UU1fRj+V#4=)G%^z?Ke%4n5NcNG;=; z@=skGJ(1o(vOOXvI3`w&G1ja6<0xzdlBCNWdB!I?La4`O^ z=Orm)*TX;sUb1|W;c9-%74)cdv>@1w))y!~C0^{-z(G*Jv-0t#9lr;F9rPk-`$16w znQ#Y$_dx=2T`7LtDHWPyD4W{{QX#Jdi>?s@UL7Jn00mQTKAcw>y$ykdHy z3K$?UHsuyvX{VnMF;Pz`9JqONtLd2&694 zcgiUU{tnvxFmeyzyJH1P8o8_R-LXd8uEqCWbd4oI&wj3pSQi^c5GzufBK#_ZFZ0TM zu~;&+4{l#OVUr{*cZ-frsWGL($T*ZFdL+q?mYKjR0$h0ZIO@$}Jo`j$AUIrtggT&; z02~_%K7I)RSS}U!1yn#(@tXm`@+l>-0SVRo8YD;*a|DX<1R#n8W{DCRi4yvOl0cCt zbPAFsyv{gsa^7%^0g_GR*D($Dt4f+$rTC=kUqC!y@+a92G2 zO@Cs!6n9$1YqH`zLF6u=t9b>WWh?%Gg#@z|C#+Qe^~w4VBB6>GQbIl%Dzn0$3Al_T z+`|Iy459!{&Od~NYW`Owh$8xdvcPNTcppDZFtVdtMWKDkLTf~!U&IRq%JA&tKS`FD zB}#+|;JYv_Lc{a}ScGfB8=S;;f1ps{XpDovvX*=Lx4qd;aka&<3OM`QZeufkOX0Ve zV6@=k>2JOv+(2=-6u~R;lvdRQECQ38YL|fUYRVUatG^S-7FBo#o1QXJ$@5D3x8D#h z6j;LBVr)ztRjrBYcZHyv`hyTH0#(Q3Y`0K5cO%>6%mE}+@t;$I6y%4HP|d#^Mc9$tajn2eoYD`>D6KN}AG=i&E5;FDV2Z$e3t^U_%ubT9mD?r@ zQ~@$q{(vIT<);9FsZD0WQihCqBU7U5hb=HN(>EC9bZnC7(_x9_alL<1V!@k zx5S1S+Ap47!&3@R4genZZxq7uqI^P^$#BRw)5%==_*s~EjFn_RpA=gAHYJF&IfT8e z=D$ONEJ3!?$Db1=Xk3?Ia@JAJA5XxM{qpf23pjyU8s7UTL1HFjSYA$wWHtCJ2~E$Mqm7?i7%dE`AzG+P%Gt+S2D#Cak4 zs06Ab(71s{sE&A2@Knt^2vqhCdEJ)@6_xP5z)8^$L0P3)<7-H(=68uSFgfn+lnJvF zFW5&l@kIcVuO(D-3I#P=co3OBeqFL+h=uufv!K&2d{Z2`C5lUvVUz1?Je(sKZDM*% zVCtJdJ!)D#(*&&poFrJ7p!-Byp9Y{g$O#j)Z4OhOdgKx)hy5uU?eNZ?(A6m;3#+2= zH2WSS17GQ1v{aBUlS*kVDv3fjs$;2rY!uu;b^#mLAH;4A*>Mh3^ys71KtV0m_2 zq%tD&ZSiRtslNEb3|eU~gdAc%e0cL^{ylWhHYixXDfRq*%Rdmla2HYiMwgxlzN=#PA$Bm}TLZB(y$0 z>`=jN?CZ z0q+CFTYH?`BJ9ixWlU);$%AO^UJ^NROwI_@enjyJ%F=+`9MWCI1JsL?WMlk+5&%^3 zH!-=AT1KA8t)35>{vz7o56lvc=%RdS0H%uqPapx4M!5#8pL7c1YL<(Wzo?_kSGL9G zPrMoV7iq>vnV;B<(kis$5z&rYP;0y$h=jcFQ7B2u)Pv zMuo4Ig|UBtHGJ0&w!r4&fdHZQw4^f$t+@IsZOoWBXLv_-r2!Aps&KqGjX@;9zH=;Q2xd^7R~}p50!I zLe3I>FbBC#$9-F|LSTvq34IlRK%lWEq?Q1rE3g&-)qH~lkgK98N0SJ9g(-)y zp(kMZMriq!!k?BkmH29F10@+$+hl>v6}_D0lNTu@7v5zNGJQN#WZH#*LZv3e+29mK zWmuU#ienPRfM!8zH9v|O6FM>Jy?c7L%@Y_%E60lpY6JafiI4xMfOP_c)Q=N_0lP%1 zU0@(HxIa-E2a`}uwSm_JBfe}FH;)f`QQ)kWrA>@dcOzfJa+|Pcky6~5eG?FUbCU#0EXF}%61+7>hsQ8%UdUcj zNM?$?q|w1|js{N(R{W8Sg!!%{M)$=ybMyMzePR+eK{Vmk>cC?H@`)5kF^yg9Io0&X z)y(x2LC0Yq7O*XVh5jY?%RV-~l4XZreN*<~yI|Qx`p_h|D$p-5Uzb9KNv~Tn%O5xa zh-z*FggIlfmsda#`y|Kxf!B~<#W@U&piLgK_U}Uf1V7Qwg|gco!%?FMsRN|QfMS5w z>m;qEpcO3j$){pLIf=JO3!-3Ev>@)jX=h_GlikY%%C8bi)93PwSu&=`Q{#j0FD0d9 zTLsgrxF-oOrpv!G1;Y(&)qEo53MDQO*mLm=yB60M(0sFS+-M=)UlpDag3?%c3BI5i zPUBnTy_ue!Qeu3ce7X)=&461}hFu47$RMr8!NWTsDtrtU9Ti~x7CwfpmJKJix^O-t zoN;#8Oae1#0}vZvUDyKqQ0{siWc$Vb6%-oyvEM=K_Q3rba0mJz5d2pX{~mf6Au?hw z1}8c$Y^Sw6G%VZ4UlcK3O3G*`p!_L|e!K{6_47ZYlg#r~A(MMZK^r>gIN3xUVttS0 z(#j#W05mtQfg7^}N2mwSHFRWUAsXZMV_2)*UckSE$Qw)y zVUr+ZG*r-gA<@hEc@)HLp%_1xBg4%f1OhNq5Eh_?N+16RN+*XX5eAD5FWS-z&UmYp^PD!v9-g+x1A z7Qoch<1ie8ZBsfr!E#QCEn1q*P%u1Me*o~Ud$w&`d?AcXUR?!l%&fjIgT!N%CV zx)Vo?(uu1$YqVDJu`D`-vYE8xkBrwW=WhW8Y%g?eg4~`!Po~MLjnCuE&uDJw4K=%l zzX$&mQpA?paX4?7OyXv&*<*KG`%bDM6xxgR!8pC3)g%?RJ9$PVb*d!T(efY2NYX18 z$w6?69HD!#9*sW71OR>&27qm|YknhmFV25uW9S6fW3rPWjCmBLQeDe$5^b}IqKjy! zb+GB>m0$!`Vn|>wH=9JV@3(`oHUnqL8cPd!J+-gg>EjewhE|F`Fq?ojy zdR~TH+P0(t?SQ%fyV;80$Cprt!3{zo;(FNiglGSzi6~N7Q#-Yv&BL7=a zwy9W8*!2_72b(6L_>|>S|IDVPqsp_tn;aMtwHjX;+89Niv)*%l^8~g(?Ai+|^VoDE z>BBKCH-*fG?i!f1My2chjPPn}4Zlm6Q(H$1&H#eE z7We~e!CC3G{uI-$cFF)!{p~A_i9y_BLQFkj*!Q%H$9w`CpjV|nu!B&B z8N1Z^`YelPr)po`RE#>*GZ>3zQg3v#cOQ|JRgM)E7FXIoU=<->;N} zPO1NB=*IC}NpD5&H^8LFv@Ag%1}tcJ=%_l09qfu^gzvF>KG>3vG^gHoCC()zq-;jp zn@Lx&(K^h= zkQgqqdb&2}z!m)s&TAu;Sg1hSOgUq&Jz-_fm?NuK8Z_po{!!i1;B~4uik;@#@SJb4 zF`k2)(^wbqeHHi!8Bpdi=a?g~79zR@CgVLJv8mW(d;BuvPiOb9VBVhd>-{NE3BLnT=R? zb|Wb>bvxD!kd@kEGXrOMAM&$)h(zHooK_9BuVwT05MiNNYKD=6{syMfxxzx8Bnx?Z z05kG&K)E_P` z&l*{gf?R3-I^@`AR5d=`mMN=ZA#der#$`mpT$FD*C20%xHk?PO@51)oX$>2y;+&xV7+4pS!_ zRnr&Xoq*rhvbj`E!Y7vA@4j6a1WX6GxKlX5B1uMs%_XE~kF;gA89M=Y%RzNYYWcJ5 z^%US2%xKAx(38I#o1{S>?9Kt zTdZu&V`JN3X$tn?kY6e#vd3jI(0ca>90jhDE~gznpuC?>-5DmJ0;wXMPFPo zz2RB7rPUCkq8lajlWyj<^?FY(25)?ZmmA(b{>F9mO3?|z5cc)~iI0zWQ#t3MWEsB% z1`tXwpwbey*NfwnV%vTEb&vsnBUX8W^>4K?Z(q=DiRJ>xhvmXQVac|xj`cJglB{6m z_D6I_%K_kdq{I<=mab`Pj@@mP+atfglij-hQM(mS8m2G)8&Eo$f%iy_%-H6F*k)U7 zvy=j@{N$ zBd?+R>@kFB^&w!?nO$zz*DDs`VYIKQ$6k1&3tO{rEeKaM6M;2Ztfzx=8eww>ppbPP zE1)=}Q)lHmBVuX}Ah22e|Wx?-}y+Zyd)mq4}Uo ze^2quB#=$-HU!*6Q~?nM!G%}_rcgo=C18&b386PuYGm1Lh9D!BZ%56mP16S2H{~Yq z_9)SJ8%WBl^trAHP-7hIp-qI2=!2z>`~I7nGgu97=9_XWCikEZ6xJPGC*NRU-Cct=$L@mzWw%;`sw0RkxyH0s zudTH{dqp%mxGvk$T926#tZTS(s4*Q5lh@{}jm;#&_=iH=-QdSBJUv>bW4CuGnv3s` z9J?!ry83Kmy5P3S^ zZ9!LrE37-t5uIDi_x2o5E2YtDb`U2UlPYwb15=L-l=-be1Vseb4O?0(hg!WKNoqa< zZJ-0xpT<1z?)mcJE8w#oYSWI8*TC7fks;~>Rc5cbuRVu{|0Md zPgGa*84OUh{5FsWvdHMK#GEBM$gN)>2+i8S}Z(=zOFit2*-m+ z>v$1gzSzu8Tw*hyC8*_i4+ky9z~|$i103_7WHy#pVagd#K4-97|75EJr~l-ObFI0fQ~ zj>3PVh1{|L4LJy@h0QENkx*v``C4ke*i{B29C2}QBNyeUc%TGQkn|%+P*83b%Awo! ztEc0}qF+6OE{)cXX}I=g6yX~+SyptnQwCl{YNrC2(qb-4$0I3IefAw6(l1tT#1zRD z<)}<}5iYje&MIw?YWxP-2UG8{vpa_L{X?}~?>X@6W8WD1${_{Hew)!e6u!?|2Fi^3 zGe%`UvyU6-vKp0x+V-w!jJyBE756%m%ax@$3`iPXH*BfWEE(qm4Cb3(Rym}<3A#=?LJtGQ)a64+5fmEB2N&Prc^+hL&M?sC z=hN$l*m)qJ;+_vNHcz|7#!$zWR=!?dYUsN$ST6>dovp^+zXt zcLeoSia=>&ixuNmd9Sd=Hse+sTRx~apR{P%vzzUX76Y}g%KotZTpW__0fyg>W4Geq z9UHzqx7xHXwJpg~^q9M~(lOlCiu+Ah2b&!hE$=r(Cwt}9D43RgY2qnd_C#5BLG)Sy z@F6tg)(5F1N7i5=}c|AolRoq{JecM3$a z>rF>`h5a{{AT-EQf>E~$C&!C?QN(0UwhuqVL}g^j5~u#NR_bDjmz6k&D;7$C3TN=^ zko0VQjWR4!^sTm-b{F~U8|<+^h@{vCXHq}N&lW<@@`cDN^o|5OC;+D(3@;gbvMP)p zBlGbFm=$sd;MwMql6W$RqRr_##}+9S#jjl8JDLul4$3lSQZwUYF&%D4#bh-#{;(3n zYR$a>Cf%r*pugDZ;*?gnrkt+nji_XrU87s;1%1 z;D`f>#zaBoLML9c>XpheuL+%qa_#S$yAa%p&-pu6FLAR5N?{KoPE`( zKRJ0-Yng%1utS5W+gRnvNn@g4NYx7g8@^9S=-F2%T{`SQF$7{r;M)|42yUUk-%#}C zK?_+WX!bX3Fi4J;?-GANY11hsY(Hgu16uzv6<*u6Bva9cp~7RDuO03RVppdXDcTsJ zitOcA-_Q0WZb5r?Q)^lD^C^J2;iYl4&Hg5g%24=OK`oN^qW<8k?`7W%vx9}rF-DHD zWb6<~hGEnC(~ltDh>~s`LjSP5(4p|xt;RgM5@(3l>vdpmtDTXb)KoN={ zRUntf8w$MgbZOJWWrmMl>5R=JC4!SHmlJ4OjngIW)aBqL1~9WU!37SKV*J9dX9i_~ z@QfXD3BuEBlsnby8kK;>O*REXRxN(aLtvv>qznF9q7qVmI4%?PrM8$c4~Lw^GK7wn zJ9S%3Ec4NXK#Xs->>ej86~EjFdFopTdFpPQ|CLS}-tGvuOc!IDcgQHQ86{YMwA~8! zoX0l9-yP{+w~KK+Kt|4_1!Fh;SVZJI;CA>2mJL|z_;AadFkb7a7>wzyCmj&_aO)5* zy(L5axPXPNL+|5f4l9)2AV&fvX3(G=uITqXzqyxrhr+kpGbp|e(=LD+rMB>`cAQ&k zlq&k#pOjgQXMaM<*H*r;?ci`%OD9ZE>(YfiZhQ&oml(nddI<@|CkEiK7^0~qteM%&4wP#h9Meq>|7112D+_| z5dDf$`s<$4j{Cj1gJ?*DHy_%#IkRzo9jDlTy`T=$XH?}HC%2Fms^bmLq^$+gONpGBCPE~TpVFKKZ@1c zuLWl4=xsycRmD(Jr%`VwLx%*|I&yLv2E0S)3Yy$8ZOAl&A_E-q+-}nr!L)3;LK?r9 zUyX*Yvi#1p$ z!n&{iRyuwvW#hG{e;zCP9&atNu-;!&rXEo?+V#Hl^nNfZC!-d0n_zff&9e;^6=s$tbnrOr9r(njY#;<1k^5x zuN)AIDCfRJ4$A)p^}UGC0eqgt=Sh4X!{=xCJcJJ`+j+t$yZ;2P99NF(NnG)pygU1G z?Z@>Du4ix^#1+4(yAvXL|4>*7quG}9{`A2(Ct}oKi&0{+9_^1cz>Le{V|pLqZPCO zf`E5Di2FVG^x@N1o<8|V>!S3fKzuuKZg&b=qRY%r_R)K3`ul?W_oYDYN`V9QXr0+t z@1^VSQ;$0Cy#tf%loG%_1H{b1rwpGZ_$ z4YvDnSj{$x5#E`v}`iQY}%J#f?^pDVNrluWVdS7 z`katOEJb3bAntxc1HR_2;gfKND)1Ot+PHAJt1%6Svl^KzjPe33PDgXue50Yj*k*%E z)1a*1vDBV6mdqPs6lkB5Hi0aD^(xxs8Ys_os@P0kBM+{Ze0VvtT!Z z_QVEC0FmY6zXAl3(7iiO(jnT?BPbqdyK+&>8#F7?PGauvXgPy81k6K=k47=h_A~8p z@zL4KPde^9j`ZMpchk7w`K{aY9DBRlf)By_()%3rbH((oyj%L~;5FT~WN>5q=dpM1SOY+=LZ_N}`zI z?T_pcg%+zf1kVRlckujO>LtPRTO6T>DZTO|TjU3#?2t3EQ{K2EA zy+hM&nnDf0gn`0uGWOEOkl@Tiz)uiPTOB(HXV1|xjDZxVyJWLm1-gf%Uhi=vSuouG zekr}s{2HFtBb>s~@;vTJN}_-7^}a|D!EQIYw5A~UpPcXef;XFqV6$DjY2wX%QP5 z$d4(|gjP|s*L#LQB_7PnBYy{PL__}%K&0r!_%TFGqoxgbKeDM49Q!OsINFGs%w|TO zB5tlbPAx}ngkFtlw-6`1gTBa4AlK}{^IyjPleeF$f-fG^Uc~&upqqYHF=$loVI@O` z_gU&;vqfR=9xNHI$-}0QHiS*k9d8FwR(0vk{qUPipjiH00H`DEm(ad!B6+Py7Hqv< z%SA_8!@qq7i~@&i`O|r5eMB7H!@nX!v~`~0XrX-su&ISEY85G9%SR|vfwW&DO=#pH zw4m4f+UM{boinxT$YA72q{!YEZHD(RyIr*f5kQk(5oIj-Z`iP% zSb5UGR;cLp$Ykmdh!xQ1h?+hMs!$aeg?Eut7cHgI>Lh%Z2vM^0gOu*r*ZITf)%;m; z|8!^cg9Lz0{A5#Iw2%J>WfmW$9QE?h(d`qOur;@7?Ac@bQS95E{UdRjeHc|(Kl>2! z62z|E-!0T-&Dmz}M-?oOoMk;@dNtggfT%qUIl*dMtg=7UxjmC|R1fo>`5_MM#71qW zvHSqP`dS!L?EpKbcTbOLoj5bCV+z`Mem2#!Ej_*dHRc_RRSvcmM4tk}sd(@XqW&~U zsd_2q{lVGOHQGeX1yBi|d#uxur8gh5I6`N@BUV2&&|RWlGtg^QGtm{-M_rigiQB2s z?1AnybqrG7=pG@#THjRd#8mCfK(}4H#56+wMmL{;Tx={-O4$1jOjb<8iu{c-b)XyS zGtjN1l$b8|15iS5K5kJ<_2x4cyv5}`!|Dfd?&Nxwz7Tj0`WEtX2pqNz>bBh&t~^-< z#3G#^1L-KudT&SD4oCA%QexVfn1-z#nTyU+)Kn_(F-tYu<;aIIFEkFn|A$=zF@LDp zSz@_13Uag`R5}ScItW zj#=P8h(kF9rFg{&aTI>+85H2-;*ZIF8hu_&%@P3H|4O?|2*a?m?%U{{rES-UGlHVbAD|_{O3G@e7T3t>{`r3t(^2AxA7E zwkf50pUu;a-wv%Ds>RM6Vnwfp3f9%(Wfxo>yUVTRKK@;FCPpgko8*}(_fq#p-wV#W z+7Wsk3Ljke0zMp{2tFU+a|)k#5NQ%zcOLr>Cye?&tlRf^Pg{-p!;akz*76kMx@mj< zKAfhVN?f-f4mzM-0s)J8`^4bC5Tp2+=sNxU((Uuq2L1eX7%k41tIPEBi`5+c{1WZv zVejdvH@MAulQu25Ep0})JWZP%^B&gM9TPU6^+!K9?EN5ml@14Bf({1&#kQ!nVehGE z9?A}T&qp(dD^Cwso)0#k!U%XfdM()efyL0EIuH?9eFUswC=esSYoevi=P@O1%bZiA z=FC~BW(F(I$D&G)_q-Kr1CHIr`pa&8_-;cxfEc9VFJVX+{w8*yG#hP&@~6N)?DvxH zd58FBdNRBxi#um~`_$~&-ZPFC5llM#HOKu8FlLUH9P%56zvO6{hDUvPt)pcS1D|7O zqj>!Cwpse{SJcZt;Nw|ffbKT!dK(k23CJkKYzU=v<(0~-iTEkV~)h| zQ*-co6|%Iv)*sVt_^G-0j%MiRr($Ke*%qrrR}9timw|^JtHUBI)<>FcdUKye&EC;` zrXIq%4FjjRiFdKRQK{jN;gs!>8{5>klc;Yi;RC1>V%`(2SCk9v8ug%ZZU2 z)Q4U|;q#VlkkWUo`lmuvfl7ks|e^I!MX|(fGA#)A&h0G ztkJQiHUxlNN|}Csx+CNT6=u#-nS+T9SgL+Lcz%U?oj$zP9Pdrug?0u+_UNm!nAqPO>fp2Pg z!TI%C_OI#}^?3iw9Zhdr{z6;UoO*TjqB+-Vr7cI*xowW%xq9`cMYkN;q_lNKmA3tD zM{YU1Ws+m}QOEB7sUMW%&^f%Yll6aA9D#Q9ui>(chinB4mTLUQqtPc3q0)Akb&bxB z{wO#ff@uX;1rcJ?77JwBYa|&lOa!&Vyau@#$%v16aUpcHJOq9V8N7@N55~y6sN2}V zMk^}0!?CxXzxo!Uug|4B_AbeNsQ87@5p@l9r&b+oeg}iR94%VC2QgsC`Ax1s_X6Cy zx>oO@n25olVL$A}k#PUv#uR{g_k&&Qjm+}$XgV~*&|ZtsxmPg6kyUgB(LPSWu61>@ zwZo2O^Alnf6pWaAn?OZ29p< zrH;St2C(79RQWh>24SXUtcjx&Ch319u9V0gGJy5^@Yl3_{rs%v8WUf79sfS?MR9gj zV@^yv9@CC-FA^kv7=-Y`!#}iokBwb^Ty%8?v_~y6Mf#>h?UAX(XH)!VBe||F*c?H# zkDH`d9)}lvgwURS-KabsIe>J@j$h#p>_F`Q@P_2U)S?k@zi}ahwV4`$adcMmU0r`q zkIoOz*>~jc(OL24$GQ2aEIgW4Ff;e9*r0TFmbwZk0Jnb#iNYQ0-4WBqNJEuD^#AFgK<69lqR(BUW=OJ<%Cmb&N!sU^*LlIfdpCwy;U z9Lu~f()?hSH!8NZFbsQN6yC7Ob^kUeyjB~+9QhaiC_2qS&&h-2X?l^Vzx@~eJw!>0 z7crFBt;*JHmLozfbGobfO9<1E5zH|WGGl`yYvU8HAoAn_TP;$Yu}r=fvc@n~{mMk- z!SC1pE<)H}r1v$>c0utl6K=DX;)J^r`KX?(iU#xI{+tzqFe~bjtm`MSfy%}z7ZMuOx{4Ij?^l!Q>NKvJEv7YjboOXi2%gGs( z7k!J~r^2W@2g_#bv8J~G>hv77qO7Qltim&NKRp~!_E_M@dHTbJH#DWO{@F9Bj^^rp zML;I$c@42%v{o@om-QQ2;Z{+7*QSEt8dPtK^^|1fFb9?$c65o#PvC?riK*!~(M%?A z7RPYXL^;kPMa=0%jR4t+3P%fYQJs^B}gP(PpE^rM&{JeEHlNGLp8KTsyan(Q>8vDJD+ zzC(Ww42L`N_LU&L>+SS#p&4H*F6ljOK4oA(eoW;j0MpkE!o|ht?6j~~)GrV0Pt(3Q zu)ji`*jAD;Cr2G0t8`-5BRzb(wbwfccuP;&^o*Ra_Y8)1mJaQ#ip`iF%P$lB(r$_6 zm*B23qYhi;`MntrV|5tQDvOc(Gu%byQH6v5CPFUg5IQ&qmqX?w*WjLEukeg@IW|tG zD{W=dl}Cbb&QTO^GGqtm=V*#uiKZ2uZ?(b_U{Vi1Dg7XRfD_A5`U@mFUT2$S&Sj34 zU*KU*t~#bQYf%io)B|{2JiF4lsQ?fq!C5)bTdy-M+R&4gy9h|4n`B!68}`N;t<6}o9Jq;zSwT-EfwM4(Xn_?!uTzwQcA)|WGWZaO>QdDX~Hza2$cpXOGo2 zTuwoR@n};_%xOF3AYKs(o=ekiUjL}gs(!)TE(yi9T~q6$vbW*I39!}Ei=%!K@)}h0 ziax^5Of-wOHuM(|2Wz7(8Y6Qx>&99E0%xiHbqHy#EgrzB4KcIjl_@Qs#VQa)udCBx zp`2FD;o~=;j|2-QE{tAAsTK{ffN5%;kB>96w6rmUaTffaD9E~1M3>SE1(qEUT{`Q? zMWRa!WppWMnQOz=iB?{VDD;&zff*>UmrNI4mB_aU;tSa%ULUy`61%R*=bL+yW2pY)@W6Qf82!4H9++FDJit&L_%V*E7$ zH#$YMs)D%HPtjZV(5T-Nxr;8#g~)NV zkki+gwxWY@khByrFMg$2%V?)){#2R4Xhvls|A7KRXebtJc6~uYXbNh;B8Z`#dEF^O zQy_%~+f!IQ`w|x5!gDaGmCT=lcZ7)f*q=LITZ8l6(KXQV=$LpPyiq(rec(B*UW*84 zzr;@>V`2qL5_}(WATHEe+OG?*dvR2+n@6gI|n2MzXF)lI= zV*cOuz6LJJ>&*8I3^?E@qXI#r$?FFVf*&ZF2qWo?FbWAMG6)(`9GOAJj5FMs_f<(W z88Xl-OlaIT+xB;VyfrkIm~bpN(OVCgJQP5-auDT+wY*K7vC=E1t;De)^+?~+<1x+V^_`gEfzO#chF5o@fb#ri*t6LX*XrWoaGX z;8p8JTE}5%lolH}Erh>Q2zjlJ&&OLD!cPzMnxy@K)28rO&{Ipkz=cl(@7)NTPH218 z56bXk$LU*wV%+L6{-o}aEx}oQ zwEj4lhM!E&7%*eFPBqapt|#_g3V$}ZED)X-9Na1NzMl|!_9RUYCJ}w7HccMuR!%T} zf=l4njDJ9W*BT<7Zu~~P9zPS`xv0}UlOzdI-%!qIzq%03)G&6ZwF}S$H|jcmp4Og0 zCHZj@cAmEBQ2RGtBw^IR$Cy+OfWyH_`7~-k6t7a>$@Mr^Bngs^e(rh%dqlyEZ{Tm@ z*;?aE`!l+imFJ!9UiR%3u%h$)lluFlYuMFa{yZ#-QM`CW{8SPd0#tx4#Ruc8+Q@24 zG3FXks&=xvulS2`Rvlz@PjPpg)njBeuNVVE)FX8R;VH#mAgfe4#x7VzctUWU<#jB5 zC>fi!hIN$n^{{~q#bL@XrZ(Xe8cs9pX!Q`Ipo<8>Nk>6mn30dawa4kNNV!E`NgwFJ z56Jnng$C&l-TLya-TH2_#U%zBMaE8!qoa7UgXO*%5}@KV?yhl%gUqUU|?-3`zY_%=Ny%42){lf(FB9Ml<;I6kUSpTz(E=1V3Go zg?ZCpH_no2f8UDRv6To7Q(=<%)gGt{o$I4a;by4u3R0*G-9af-=}D$k`?;#xI)2{- zCLAS~b@ID24OTOiaAm# zUj8)sKbj-X$L?e{b|D8I)7)Rew4y$u!P6wkU4{dht4&=06Rr=x$_-lVD6ggfR-3{l z+$M=TcNt7+$KDzU#0Qepm4$t3#3G0(h$Y4UQHu0R`)g8SSr|{th+2PB1k1E6hM7QG z`+4xA%RsbAL`O%?+@2a%eBy%}(jy6{EIKNUf}i_W)Js|ugn%hY3vk*gWn;>@KMQk> zy_z|AH37HePK2>Bs-x~45-?e5PoC)9kaad3eEoh50+UN9At#gTS4TAWOINxKNauZl z{aFlaR3zoIND4N)_Uo9q2!zw)vY0IMN9GL<)1nMa1lJ-O)5VSGCV4Kwu!!d3ZDfpy ziGjON?CI$L=sa=#`lnW4tij7h3-_YRVE&G20K~ETq=Lv#FrB(0qIVz)%569&k|BZ$ zPmg?@*8UsV$Zj+*zDScmK38dj26ad;`%h~>0drH~9l?|0WRt0>FiW~FE5FY>87!t* z+u1>@)nv6+)mp81Az~S>eT0l*ap{JTrB`k;*xnH5TCE%Cs@gnIMSj}RBTc3~p3t!q z)K2h*2EC(!NmvUduP{72u)(Ptr_>dTwkmQQuu#w*lLr5Iz4V6YbiE4x#;R0Y`(s zM%P4pOJ!>Nh}(y=6WTcYiJP`_#O2`zi& zmD-Y}`5Q~}^O0{n>p@w+f%8K&=xZjP$+QmY?78p(P9blg$LK7%5%lSU57Ub~qODuM zJFxEwEfX!Z8@eAfL~5SUZox^PeqxVUuy-Y>tf9Zh@em%MfGcjyzQYYVc*E2Wa*H7w z>TOW_L}!T}es%Bwr{J2^ zqS;4qgATW{`)PPFh!e3jW-i`{1Fn4^)&@VsJlFUoa!Tu%2~ssOND(0*L^w%_Fs=Qk zuxR^;VohuR5P!Qn>XAs^q2s!|+@r(8G{t_|8zziIiD?);Hpy0XRo(weUP5<-BM}os z2UhN$FS}HQCc+B6KMyhxGVV-F9Bj@<2z8;^e5r5f?$`!4H>dMZ|6wvkPZl^1IT|%I z8@TJ=z#?+&734{#sS0(&rrCfwj1o%dbxPYk)6gNjxS%2Y83;;ta}U_r!jSjKZ_s9; z*?Cpow8LcHk5-0<0927{u=f8--g@IPG}ck%ty{j0b~>-S8O|hceF?^ce*F0ca0a*~ zd20$Ba=B4jMTU2nyfsmcE^n>)Uk8Gfz%pO~Fb|jsqyu^Ya=PzAPWRs_Z_POop$xYG z`+$QKwkp^AXOp+S{2jz1%Ud6Ub_{vzL8JxcK*R@i_>%)v0jiwz2zhIwyft}i9;O;j zR4Vyq^43b&&mf9#0M7$2051Zs0B->A11OjO0C{VQEEr+OO-u)50Ska=x%_+Ntubf@V_&?Amtjzsz^H$?k|C;#mT`6sSWVh0!jU zn0OMx+Su3bMbC+CZ1RFDSo?KppL?J8rI$WN2UvL{4|j{PV?7^QoQ!p)_^+o*6C#$& zC)p&^0c;HQcmFj}=Dmd11(4o-uTZDSZ7_AFjd|Hrr|xA_zXgtz;9Of{88n{SHxYB= zJd56FF?hT1)GXPhbX+VJ1Sh`&nnk50@hHie7j9Tk&^(HT>0?AZSZ!+{*vOvKPxOp%2% z^DLLgEUVLeBSNl4-b5^uu$(@BC+ZPi{Gv+KRobf!oHx-di01ToCt(Y&xbtT+q^Xdj z)Hk(VkFY(3J2eM%8@KdzSLy-|tmWvIExn0>#fKgz0rIZha@qimWY824*-Pe=+(~kB zbCFyu`nD(|0=7g-=VeXAqkI_0>F00_cvI`c;5q2@P+t$5QQPrsGtIKd?(D_0KR^4M zv*#wBmabmA0*OjHekiUVF6r0aOFZkHYy{mNop*u}w7WHH3tq!fYna%Nzj)t=Xs=xWPpsE2@KV+hOB1QQb=NK=z8+szRAT|1L!y)Sx-v(|wTEjCi4QCVFPt)a}uQKg0oYo~CyY-L*Wh z)ZlC#uWSo#*J)7L_rq|Bd^8if?_2Uobb)db-L02jYvO@+Y7lIC{DCx{LDD6@84mTn zpA`Isd?-bAs8(iBoewX=j5ZnuRxXK1cPmqHl9WxC?g)e+i%}-(%A{%5omay;>&`!f z6RkT3A{mc^hrtP*GxPCuwW%sIua? zv!ExhUo@19x^ih+6~$adF;~T64(RhEV{c=}b=8W@$Nj!sDnGU}37xC~$P-@$&a0fpI zGy^YU!*Sv@%vp5YQWs7=Vi1$L-Vo}!fr-gEycJ~pg*0tQ(a_p6eD6+%^A=1#-bJr_ znM*pTvz;3WM}88L-ZNcw?_Nr$EO z&k*+}oVITYUJ1Ue*T}QQ1D1*Sefa2v(eId8hBJ7rv={xQIAGByh;H17!$SMvv4Uodldo;(pxo?{Gp)7BX?)c?QjEE?Yz21dB<&eUmtq z_EM~&mC^7dy)|^~*GL;Wr0{fl)Bx4YqSs*xG{Fxc20@;1Vvj>vGLlfdF1)k*nR$pF z^K0sY>l6W>G+DsMs0#SpT()N}WP4`FvOSYyvOTR4JX_cLX;|0Y`bjvkyOo4_^h)^C zyQYwQrTxHdYm_KH2q$&khK)`xLlo2~QbfTiQ8}UupkLNLAl`ND1m=BAoJuMeBRbW2 z8;x-deND3F0UcNh=HdtU-Slg@-YhG_sRBs*lh{nBroGh)EK^NHxHCMO*rcM0mCkAV1G!{$pgId z+}As2Y0;~veeQQiq<{Yh*q@*a-`$nJ>zdMzYgzvYL)tNO1Urz%6KVhRi$ryR@4}kG zAH;&Z@?7__Y8++tzNh_q_t$htgx|=5FN+Jh)@#5I>;U6I!;g%o_TV9*8(m+xj3nz0 zQZOdtsoj4toBeo6_zg_j1AUO|zM=K@Vp?=6=@Rmcl(VYCl>5+0O4zX*@cV=FFhBe3 zro)u>XTuv1Kx+iezYNV8QzbctI#V%i=y*S@4LuH3CXNLfPR0&Af+^_Xp*{E9bKyya zvr4I_n;iN)JcRxkf6yf-qN4KJNP|uwn<&85PbCBP?V+axMzX)kS^ddS%dc?D8&VpV z28faK-hAOR=&{5(fsht=0z#8SeVIs8^5a_cS$)T+^1oV44El~wA${FW6W-F~<%d#J z63zK?m~z26fjl%&XOHz5dNf>gsl{^}#JaeukV%!MhY!RD+LJC}4PnBYnpe9lzdzYQ zCIK>V_gL$?H(W_O2C2LrWAC0>cp&EmPHH|b;0yi?EAA`L1^LsZUthJVYgGil4tu6y zGv2Z5xP+(BBFm{<TZg%DL4hPSz@MK^oFh{lP)2W0|(iCSQO2Kc$R38odj}1*x_IK50N7? znayCp55naNSMU&^cRC&c+>@?`)$i{W4jkYi-5D6Pd8Y*iAKEin4X)pRQ3#(`14B^X z$6i;Um=2$?k-PJg&;sg+PbHBB)fMGz3N;63Q>&WyVcRW|@eFDTZM@@2%jJilZ*GBg zUF1zX=~YHGvZ{HTY|&gn>fs7lM&3MJ1?4HyV@{SCIYZC&h?AcpTUaDn$%YpFDsXf} zp~>6F;X!#hMDmh){MfblP^~riGfbh=ubo8Aq@SWUNE1-fk|#X7D|t1Yd5hVo9rI;( zDa`AEv_9~wL~)W#0N2Gh=RiX-Y~I??C*Rx`r;^vS_AUgf+~xm3_UeMe{nAI9x60ij z?^nykZ^~V3vf8y~;s8w+(R>G8$pUn(cPL$}UhZ0@lbyGPv)XqzOofDuhmj;nwsY6X8BoU_kGYW{>4L{!wy?r$jvEu2T+JXV&ELqBdj%`O= zB_Am5*J2yvI^x2D$r{@9L2SrGKOH9f1lXIS_G#^J!jcZo^6--EBOWe?*4@D_Q~L=Lk5KKqeC?gv2d=$?r;;M72qFa{&p7y6 zf_!5`|9`+YZOfc&2rCPEWqCm(HuaIp#N7A5u!(ASO|Q1AqE|~2qxW|8exLH14X{EH z>%t`eg-64a+UUJd6I#v`|7kx7zZ^(y%4R)@kQR%|M4vceP zoCE*0IB*o5zUwE9Jp_CXcoH}Qya2okybb&Y7zC0*n+fCqD}dF&MxYrGfiB<>unn|5 zP+tSy1%3}q{wZVgfO~5iU zUdb&wcR2)y*X!{Lj7>^qtfpd})hgSNky*>vu8A|U(sh;Q^0hIW>bvuou9%d%P>|fV z?JkEPdIYE2DLQQ~=R*#m*e9gbC= zy|}~db9f7uF0#8^j2(T0Vwb-nYU^iI(@^y?6IHFl z>q8qPAs~vo)Zr7oo>q2@n@UjIMZ|bDp;m6QJOP(glbkg6y&TrLR4SlQ3=@Fnu?N2TZ>inqHdcR`?q*=9b-;8W^$#JfWkG@1~hlD z5|_v4P?G+3!UlIU&zjw`x6#o;{T0%M7K>4h{8oDGlFLC!U5omS5PKOh$r5X$a%y~L zc47>dIyRj`8tH}IKDs?pS({KTx;D7?pq;Sv#5%82Uwn)K!p43MiSE$b|mq_>iuDwf%9_fjQf zztB{m|4_OHa3M%BSlsq?O%x{H)3#KvwN$9>cW5geH;r>(oCD(=80Ww^2gW(@m%@Q_ zl8IeCWr`+u|L&MRYPniIC}272r%A}k(Wr))%B{3HId|MSXKqe*PR?yv@;7~YPR@*+ z+j9~#_?J2SOV7*{?wXyGnKLm(pOHK*GjnogW|Gd3HYGE4>Ld_P$jqEMZ`NmG5&b{X z5kr!rUt&}@x+aONwL{%BLyf~s3B%0)6^+CLZS+gjYVm*UPeV=#W4r%lx)2W%qMs%q z0ssHIePDqmAyLaK`G|TtL6?#`Q9o&NnqkV+Y3a#Z@ssGc{DC&(R*C<_aBnqOCB2!q zME@U^hTDe4cGGaPh7#YDb|~qeS{B26k8K=JgUp*hBOj*En9jf3XHK6!Yx?v%WYe93 zAZwz3sf_>BHZ*(0H%d{2Oac^LAIj5Ds9Y0(fz0AZR`BFG~~wVhiKLG z{waCO8xq3k1~pvnx?pq~)iz4IP_-FbjnaZ-(b#0%B}Th=>(+d3wPY+WG1?f#(wKIL zPNgjvVmrD)rIlTmjZUQ4#?vmpDP^pl-Tg=C$T=47J%5xsM$1W8+{}YYTX-`f#Z9Fp zW6>X>kE1pI5z@H4$&@Q^;vp{F7*%mh8?PHmdvCnc2)#=C*%2-yEmYd5iz%ubp&3qV z9zhYaP-s`hY{u5bhg&i>8Fz`Nl}Ss-^bw`Cj7bu8h|-eH>ZtXonjy5KQp7C(Gilev zq8*|eEe&NuC}M`uXk)HJb&TD2e?{fmb?ai*Rf=|f%u3Z&TUFg3SMhk_#=2-*qBL!S zCpB#&)y?%=h6Gynu8E1jA>b8Y5SaIC+&=~O0Y`v00QMg4W&#_5cHk)RHlTYScXxqp zz~jJi;9bBF!o6Og8F&)t0WJYq7x4r<&;ooF=m)L>!f)`qKEPh!8Q=_X1IP*Ew|)RW z@D1P`puJ>b`9M8z0C*la59ohuVk-bUa1eL_2m$FIn3xH00bc=L1TF(Je`jK4fCwA{ zUI7Myd6$uYU>|S90&o1BMX%vym3S>D~>|6FcNk9(1^2pPKCxvVFEjG25Oq zKlNb&R?H_t5}{Gp?QzmqGy*)gjmTgkKG{@3)yxa52AKEY>;lj**DqcK#D{Z_Sk&FUD>|7=A*ATvkVBf*_3MmNyE0ZnR9iHunw(Jf`eVWt1l56iI}NKhQIyFelqL zheShQx66qnxOaez3BFdhXxl6E2-)Riu(zyRjdGwY3Me%yS35#MeMr#i41&o|^&L8#67%(`9`URW^-T?Z67l5O{5#X!9lfdIZJFpKB0T-|hr~#^gGN2S#0W1InU?z|S zqyq+k0XMFpj{q(Mmw*sJ>3A3FdEjl}9B@X_tExW@iO08%|7EP@$p3mYk@V;b^85QW z_?EML`CmS)ln)xkgQ6G|e}>TaxPQYTB^n&PO2wz=M2@7=;!eePoR$mT6<@nXgn*XOc& z5Y*S-%kZC7Th^46nX6evc?~OBx3;Ey?FMsA`MR|f#wsggCDmvr6_8akuVST^l7?Dy z#Rd!9$}AhB`gJ8W<_g8Mc3lmtHm_YnH0$7Z-C9dS<+^GzvIi{H>r_K^!>Vd?$^EQC zQL7uOkP5U>MU~wxio1oaskWGF8u(vkE|F7MVcA$!ZCPEu5&q!YYN;-%Fk7t*_9_YK zD=n3)EEM)ybET!B%7Uo4k*V5>2CCiQ2`cpFdT+g0FKo$!*#s#44ilgk@Y=NSFv&gD zH`hauZ&5QW@u6X}C5s9QDyx?+CG)l$sJlQFKwpKT_N+r4hJKl1KDril82WV89cBjo zjgO(?I|FkF`gav`3;e$UeZOKp3iA=@p8=@-Rl(d2yQYZ16d#hjiO*Uc2C2 zj2_P>Haon62yq*si3^S3HZS^0rx!wc9&f9#2hI)wvVwv~5~)`vDxctM_DC+fu)`zd z*d0wahzJ$WSu|%p#kUY+N2TpShu~5=cAMMgYJCW?G}pPxxBc=wsCm zF02M$MC!8nd_qoX#TpC`4)1)U;BmWJ1<0e>c^AB}q=d)S=(<^4PIojmio?lPNlv7i z3+YfNjzstxZEiOr%pplWdEg{*Op?8$p^VbzM0<>;jSp3Pkc;C7Teu7NGHhPA;B1N; zEPR4(*LLR)$s?hQXAA3OlT&Pkd=KJ;l$T%wGlUYhaEFaSOiUehz`ETIm#~yAELl2= z{Sw$Op>eV?&Wl+hDArp#fuWS@O;7~pFigV7lEM{*3zrlY7N)XC5ncp;Al~~ZK>|B>xKT$M zA-V>)s2TOui!n87Mirp6M9nS_A7~eRg1Hq?0n`I?o$f}Lgc%JD%ScNpuZ^ovkL6xQ z$X!h0m`unOz|y#6Qr>cfD#>e?9Kr@SY8oW|#8$!LLc8+vN@Q{Gz^urjPG^WdnloX0 zt02@l(dtS(%?|eh0pf-ZccVk7vU$A=P;2Z0WaSQ;*}h80 zuI&!*YDg!~&zWzefcN9?T!-84Y@#$M<)DUKE}KctjcAcZ3Vu{ql3`sa=LhwIrl+W+ zR9bSnA)sw{coE3r#ljLAEtUwS4m89@G*9pnvX~@34WVxIftXP8gwV`T@H7eVlgd&^ znD>DPtYzh^YjQ~6IA3@eQ%U%93rq4EjRGcn_-;zKy@96&bJNYyx%8IJ@V$k5Pf;f9 z(fUgD8=bJT3A6gm+4e2ql}a-zkL4+=k4RPis`Ow533?)bnCFu~^lk^Iqe6(%G})|J zGN8X|Y=k`K2=}4s%8knnrEHXN>`k_Y?Px}u$8gUD!LWRls%h}W<#||Ukxg3V@Hkt% z9+69$qnf7BN(WtsAlU4?ZD>e2WFga~3=0F&=VEj@6i-K9QUpFMP&t$D6vD$mN>Q}( zQSSiv1;Tcz$%iWd3$XB^l}<`ZluL?B@lwoL`639tA&qtAwC;iEDwaJ$E`pHjjoNt7 z!c-m@(d(#XL-O|2@rr1nl<|@FsxR(5ihHGbBPM{Q7V=GPDZbB(YkPC#X|0q_)bz>QdRkk{r8D*Ue>iFIXP==*zf}8 z@tA3GPd$u6h4d?oLok+p&%|mKmAfNRL`jln*eFm>=L)+d^Z?B^OlR}?>=<=EzB5;g9dj$pSCBllt{|$hNb{Dc z5vk(?$}~RESQdRTTD3hr@Id+68Vi<^HRZJyR7cew5%M~j?aQVqF@87)fJ&=yEuaGo zfB={PKk(-!p!j_bvBB-wQzVpNHGqWxjrBAEz-k5CRk(p9?85E~Mtq)nnI6LgHeQ51 z9ISwss4pqW!V46bkw)degvuN_v76rZl>;N5F5TZXR#j#2q_CEVcV1u;yfPEYg zlD;?{O7x?CvImbJQ#emTO@Z1BmFP>MQhu|bPJtSF&BUfceG%$3s9%Aa1$7%#3Ume3 z8BiJ2+oAM>KlF;{A*g$y9)#Ko)erR{s4Y-$Ky^WlK&^+WeqTFnVxvKIr?SZeDE$P= zC#l3&N)!0ap9{gZJkJyHKo3wpNu_*}O8F!=DjU^}!kq+=O56Put^puB;sf!3K=!i% zvR|&4&5D^uGjgv2$WJvubXG;JgG%9V0w``5K<>K$0cZh;cV2+fO8FpqKR{`2Q`ERDNB`n5>-Z_7ru_ceFDH}mD pZZXb*aSn`gV4MTv92n=oI0wc#FwTK-4vcePoCD(=_;163{{x_KCoBK} literal 0 HcmV?d00001 diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/bin/Sorcerer.exe new file mode 100644 index 0000000000000000000000000000000000000000..9b343359b2faff066e9cca33722570661bce1136 GIT binary patch literal 135168 zcmeFaeSB2K^*_EzHn6}ZyT}4jf{n6jEU3{$4Q{{yAp`{6O~?l2(dTQ5inyz^1q3&1 zv$?KfeW+DGtufTn)(2Fq_y8mX6Y!y;wHAe1v{olwR1}4P$o}5v%)NK-ZWe;RzJL7w z(3fHN&YU@O<~+@rGjnIBUAoeeWwBVS_>0FamUZ}~|H}E_qyMuV)ww@;G1s!T-y0{b z%b5DcNi&pdZz@>0=!R<+U3Oi;6_;Iq{SASF%daX}6uiFR+UpA{F0LuK?uIL`Ix{Dy zzgt87zw3Yf;**X;UHacY2JPv33eT0!{o3cgu21lM#-Ojdni=l9t`I(Nc7DEY-_)SsWPyGWu973o|U1Jv3sAWw0CHo%pgG zpEPRvjz3wO__QoUJF3Hf#4mo}XZ)j;Yad*Ds3F5r$lv}S{{uSL9tGu@fvXk=Q2+Y% z+PG+}X2MWcV6n_UbJ3NT1unB#-m#&8#!fKI1AJ=#m4hK?N-)djcfpaBfLo4A`ZWDl zZn3nQ9)JA$BL{xuz>ggGkpn++;71Pp$bla@@FNF)lwuKjgrQ-8L-dLR;g- ztISOryk@-^|gy7{&U^;ujx-IQhJbpWnf=Uld}^s%%4n(#oY9P};mFrvj}D!>xhi>NDys z_3?U(-z%n_ML6@6ml^Or1Kk7s9H!?x`0FnSM=5#^ZO#XdpQwwi;dmfVb@-G92Dk(O z>aA7~7>)-;vkjntyIxt$wI0HBC4Vg8n;|GmM>JCIOif zIQl9xQ5ehCh}_dx>&S+VIutKA*nvXuOzZ6pJV~}xaqW6~mP337U+Xjc;++zUrFl2= z#Em{qljA99-hv|4p>Zg~>k}i-w8(Mgp}Sp51tVNwbWp_4v+?W~7W@ll&YL@H#byk^ z(!O%#%A@L!p*r>y)p_7pRL8EV&VgE1o#<4zofXn2>in8A4FN?7Wx7c!(_&Jll4@2a zzxXyA%EBsjCCdHc?mjy2xNs&HE{{8p8bCGSR)6pe;av(Dl^kDTnOoJF zP34qU3GK?5)k1}ByPVmN_$n+dFZ(Jj?P?B{sR6gWX*L;EhH8zjMnyw@QE*zQJ0nm< z|C}cdErB=(6Kr&R9Jm;jx&`0bK6I+qFtu6HMtCDRgc$7uugpz!KdW7PAYV1BePw93 zvm<+D&UlNZrq*AlE^)h~3*3dFc*YVJtUFJAQ?0dxUa>};p;qhU;8!ov5Io;H?)WP{ z2_Ql);M7!KpDjf7bGj8`?E@hbZk<_apJOY-2DLZ41D_5Nfk}wny;fxYHkx$7y`( zL>dtOSEn74gTr^vzt!L&^*T#rf!n=oY$q|t(oFn|WJt**BofIqO2BfB*SV3UmU(mM z%!0PGs|y}>MG8AJXz)DH=+wM;&-T$7$Hzk-Wwd?dT(OBp4K7B81apaOV2b2PTvOfd z$Y>oi=~u~N=vS?}z-{-}MJ8I-(cq)gY$^#TG7#e(vj!zgzIc&vM&~%$X&1My*kpnF zX`CgG|Lux)D$xuV%v^Es5j5PpYRMaNeDfkvrzI20RtjZ{+~>k~43K<+`9GZ$a1~Uv z5OqwFN~EyXq|);(mX?n37;O z%Z^jFKs%MH%<&enFq16TM(V!)aTp~UIMweqJc6&GR|=Z)8cqxhrfFfb(PAvOu!lOW zl`9UD9WUAe17p?O}!S=`!5&VXGPq#oXS>j>p?n4t1H4Y?FWlHV2{x3fM&T$BZU+vS|hZm)j0 zH)@>>nF28CS{}95F3+#9c*VB>XC;Ssjatj2_T}rSn-1%=|3f{`Nv7efB;MJS?f*xv z|9FdM%bvb>V$zOx?)y`k*>FXg->KF6ywYl{#<1Aj~V=kCZbvya%1bhu` zu1K(uCs;Wtdd02eQgU8KQ*|&+ygnuGcjGM8B8M;@;>no;fE;e5974z5m|e{wP-Q2c zeBwXYl96p`_BUdlYVj&6n%x{^*vX?w6s@pO4vM_uPXGXm^ni|yN}3ZwIcSp>)TPeM z<)r4l1$ElYtWioqm`{wB{iRNL&4nB&Il{vrdM45y3Kg@iq!-odHFaBeBw9U=p9G{LCo?CERKdoD2{BhfSUxl2|?)cDr3}h2sIZo zKCfbDgp~$DMpCWpgmk^)tR7g_vebvBVrfLNPgqb472*Jv=O$JaJ%+9Jiin#4@;E*L zKn-{1R|4GGrtfH!GH|u2H(JB{0>jlI8a)dbP=w6JjtztO_NEh-Z&4zWU)zXp%|pe(wsVnwHJhth_3L}t5P!J*0s_m6i$Y?chf(9bKrIKV@YUCG6=oqO)zK+tbW<7K83tv*sFb42Cyr+{HZ{B%M8RSkULk?Zw1#&$8lI-F#p>;i*jXoI zz8}xcL^BV-)49aM#HwEFl!(_VzgJnqTbJaj&W_A}ToAX!26*fHiT)d~5|`m*k;h?$vsbamN?@s<;1xST2-A)+cskYnM;W@U zBO`g}4$V&x=PEsWmc63&^D+1Hz&=%g-Nh)@_Lzh z$~JO$;0x=8R->#%p-+qlR>Nzp)kk=R8g6AV2QT5lsQbU45GP7=;kG;yNk=2mA>Q1_ z5{ABl(YGSHb}`)d<<^H%ArpOQ+*;1usz)c>Dbf!4NRxa#3EY#@#}WpZ%v5M`*J2{9 zGn*Js|A|qOL0Qrpp@^uS9Mrt5fHipC`N5hGzt_oZm5}A(h z-|?NtzX4w?o{lA>dB|ov8$HtsE9;?Zt2B+)RjpIw&31HIEzbCcCDe7(vEsLMSdvw_ zq6dB%$!!6CpLpYIGu>n6|Ke*qPSWN z`yLecV8;19P)lY!&dg}ttC0*ol(&#Tus$nLr&!fCOv-&#%Op>G@Bl3J6cUORshi-1 zsPL#Od4gO z7y)ul#0Xk+W1-`!_KOz~KPNgQZ8_S6(xcB8q%!yD)5U#`r#@>f9TW32(AD8#n5ZYZ zBDHxa&?aj;;Jo4lg3BT4_{T-~Q#{?*5L|wh#tfF<_wo6|dQc~w6nUg-vFc0odY*b6 zf`8=O9pO4!c_C$_wuMAxU|3b4Ulry+c%WE57+0V+vLCs`87p8Nx{V)aT0;ja1G%9C z01q9Qq4-*u0?1(m=2?nlSS`NV1B#cp^SBydlX^klLtOoP zpqIuX#dQy%54a0!>MiR1G`f!Q`59u;2`Igj9u<;SWSlGF%QNbw9KE8B+E%#B5Lkt} zD+51c64h_YJ+FLksa?f()RPAm=E3J*7>Z%5V%%C+o>z{-=pLM~^yox#f>gsNBIpGC zjr9Y!oh-;>>7<7@eF%D;Bu(i}Ntj-7ifJI_>Nh`tQDr^QYwJTj`rL)M-w0;c;lV4O z`aHqDUbLsjy!JW_CV4noe~8&AyynqWD-Tmg6cACFbo4%DF_9w9PV{cCI+ii_kXuzM z4Vsgaa(nADj7}y=C|K9xEAaLxs?kGg|Ai_i50e%q%9YH&8_)wP!|`QvjzuMU@USrz zxi%9@mo!jfzc|>!$@WeTO18oDsvHf2@WFw}FDO~WQ`yl6)`NHU9(_xlpNWzA#C^Mu zSu=XD>=|h;?`JF#1{7E|BjjJ9{kuXwJ#yXBz^>e8Qh|| zudZ6WC9_s?bH%R3@tjXaQm0R7nX@7=R5=5hDg&Jv6p*h!moV5liQ{Nc!3Mw$3-;}} zodPB7%RY`GwGZMj*se|8qxL~Ipj)lPV{pEDvomzKCXgLEJULjyBI*?ojz&!2h-lNdb!?xdr9VF2qxwM+OG#_M`9In2ye*l#}F+tL( z=_j$STAW1E}N_O(LaU9ZX3v^)_M&6zGQu;XSGJOtFl|q{|HO z053`9~Pn z{BwvFyE@Sst@>~1K&j(b$M?5bXd`UYm~u7?%E53Yo$RO3nR& zoRpry8QB!x!lW4q#O-Kg#9V9f;1!-E41sHwUx@9Mtw3`uW9aGsrB#_E!Hb%@I;D}i z7H@nkdH%Cx-UVhIOK&~ozTKqaCIhHb0?eHG+!?fvoZgIM>7j=q+??7&jrh7R4Z%v2 zOM7Uk1>CwGCC7rj2mN_Hu@5=OX2#eV=dl<>4>4?H4eq&0QCJ97|4G*6$Bt3jJ?NjA z+KsNUxtjBvN^*e8%9U*i_x|cfx{AU(!S^M!RMT@8z!G}C=MSXk_n{HMlf3l`l(9)l z3uJ6feFIlFzz$yip+gF5=0LN6S*4@``-GhdamMC0v<8mJYxhv85ve_}`;j{96_0;N z1N}Za+e7%9SnW;1uMy?hsXF_j_1JW_2l-d_#D4kyAE2{6lxaXJ;uII5W&G=uovaa| zUCgMa@DtL-l{SSR$2Yas3dy)s9Oa>fQK;4BRkl-un1lHo+5|UG1zs^uVo(Ru{;-?_ zrnzv?ZyVQ+K&|HRvD3e9GYW&*>(9bO*}J^UznBc(Lz7%MaAW-$=7! zN0V3@)hSnk2(KuR{d0FTx!jJv^vT5$UW}(>@p?V<^W@Y{HLIqurCR*u17ezu9bi+K zla$~x&9A@UT^hLZ8;_;i9{Tl{4;is(tVTjYhD}}!I^nE}STMsSHL^nnQ}0_1dXR;x zw|KE{`S&lj54;*adH~jg*u$)wCL2zQCV%y>1dpKb^;OtE z{*-J`vJDen{Uoor$XqndT3_iCrKY0#3ALio^sG+Az8XTe|3R*DU1S3b#2*T&FS}Z6 zSI1jDuLSys7Gqg7d~{*(c=UsZ3Beodr+CG`J~0sx;qztwEp_v z4yLtTTW^A+R&0(+j;=;)QF9t|6wAvAScYaBmCLE}JXy)h(161)hCuh#^JoFJFZgBR zuoCD>;2&b3c!yBzJypj~%iN(x*(Xmg&-!q&sY-bh{@-o_0 z4nYp^|EPxPNX4PON3VDTMSf*9W)X46DOBskAwIAgJ7aQvMUOb~gVaNypI@v?6#A{z z;!nmSbpN9Z%PpVd?^XQ0Ikw#L9zJ9Evt(yyWRe!k|FW_)9o9|(yKvxnsIt^x;lsqj zRyR|M{5l;!8KErGtNnfiCIm5^A)H=up9F2{TUHRTmh}r}O^WSZe&L9~C~QXLxr2en0zawlV zB{dJXzcJkY;sOodq>M>r{ey)GxZI8mGu&}zxWM)#&f;Nd@Cvw^d^#nLt+D(ir>ol& zsD|JWh0$d{(fK~fkvL3e9CR=zjxkBbL~^_C2a`2!{#HVFHK2$X`ZPYvMg-2G?$Fy& zdzzEf6O(BNdvE|KXpLjzz3i94#53^ewB%^CuvX+aHVpMwi-8i?Bo=G zsFFkNGq1xUnMUg_e|>+kgRM)>c%lN=0 zfHu6Zike#SRIM!U4)4PO_`JvrcYdH8JOD|fUl<02qpO@j8<80NCUzPP6*K9S;Bd9d z8u~e=RQ;fd7oAj#-~5Bc+WZduMoq0(WXxdfXjZDl1r>nvi5mciaF(H}MGR0N#l^sQ zHO3LX105^n0FB+E<`m$_3l1NNwKdd;gJrxS)2ftEmw~b3WZ5Y)retAW@i2BEX&y4p z-guQl?)AVsk{TQb>I;+XIsnFrk5P!ue*@%jav0_y#SLgJvhCm|IH@geW&p}!!nzy{ z9cbG{PFovS0r&75iEN6F%n_!*3auZg24r_lZJjtwqkt4bn_a-wpX5h!i|LHar%{RN zvfmIk&N3Z$+ztTgocUN5+T>9iQ3xn@`JBXsJ>ihTk@L7c;@k26l+sEpAp>r=XAJQ> zn6JgUP9|sL-x)G?Qygj*+u6*iD(gCM>s);$Jw#)~*F53esWlj{q1leoYOz==9VJ&L z-tboaVDc8!CzjId7{?Tb##t6|(8t|VXupQGm!YT{-nERkK;ktt;6WT|ORE9<-zG$` z_dvfI;d+-ItVqS@tDO|6LH=ZGe)Zh1p_#yTO%1%0y|xagUopK$D_uCHlZzaRD!^+# zgiveMBc?mRC~?w>jGqXk_g4lgjVP@V%eh!D_!xJR;}v*l`4;YzH#G_z0m0#zWJhTtV#!z|hyVqEcH(dZDm+yh2^YE!J=g zXY8lRVA%F|d1+lKUxsR6*an7mskatjK#n?PIhS6~rFMnn=NI!O1rSTFvhG1DnJ!DT zH_poC6V5ud6Ww%xvmpE#fEP2elVo-Cb~;r(8=Qlld^hDkoUvSuUC(M*WF~XnRG>E2+q6LUMkhc|lzi^;b^xoB3Z$_+yxQm& zG75e4mrH~^AUS%kEYU_k9#2d&DP3z|m^Lg&LmvoNp_9daaiVNtR3XQ&X~fZn_UjSE zki^iozsU>&CBykFdZ^u1<5iqIl9##8*>yKDRvWuDb?j*1t??zgciowbCuaF z*r4n}tt-HMdRqYoAQ*TK%9U;WwHjZw%mGBXZZisXJyg~(M3KadmoK-SL=?N2J#)aE zp$VDO0cyX|Hz_j?kW-A}N#ff@C*-add2hYZ#M1twecH&z(i+Eoj3`c^cr z6W0+8otP&d@KK%U%cyWvxm{l`8T)_R4CAjNBG!WlTIcc{eSzwAZkPZHLkB5#pcAWs zes${4ou0$<0zU~I92U&u@Zvb0we1ohd-RRYKxT2P=5{y&1$cook~jQYanHQ@(7a>rSw39%W5#xz}DNL@dW-1SJK>zmOvdp7w`bNLC#C-0Uj0q-(E9bAEuxiGKx zrs)Xm=&4~V)@W9Q`!+|o5mum9+Bz!p@uulcgg$kiwp(#f{MkwzHH1N`m2SjIfJM~p zXgHOim*Lc0x8tr8@Exz<+Prn*_9{XGK&n~xzpglj;mM|0($Vk{f2VNY(SV=}rxOU# zzwoVT`tSy9xZg=%t4^e^A$$#$TJYlje5L#e7(pTa5nB)>lhez^OPv=`V0*B}2BMx@TdAIEc{Or9p*cuzme(PATr-I< zIHCLf>cl;=C43&82eE_y@I_#tF;hu-Chb@M9_*1rUru~kGl=;T{!INQaM806Um{Sw zir(wcX0)NoDx=+%)NZkCrw)w_ei>pBlwyla%4?i?BB#rq7ym>-__LN(q{-jOV+jI9#D_hpJHHhX5YQQU`BG&ygCNT1m%gBYEm{MD<+e zqj|uE=SXF~T4z-=BJ!9hZ|Mh-*5mP3%B)*-I`%@uE#I0)yFQtqrsJ4PIMShBOegIx z$Ob`(zv+UA7db_1GM|+`xw>}o>3LojI}w5-C8RO_VPfF<5~X;mA5h(FRRvt`Wulp$ zy6L5KuU}kA!|aRKgD^}Q;Kg{KD3BZZB{pE>$n7yJ*4*@#c%J(2NFl;!69Xt~`4p;< zXhv0q+csy`CG7y=wMyi4deVp{$3-Iu!CB#)onLvQC0g*m(K#}P-nsFdjxa2A3b2?+_ z9*=6D_yeb3sqx52pJpC$rA^#w0}1FJFSP@V69tj+HY!oiju1k~IJg|WIm8SC1+|!( zBAM-^5%VHNYP%_tlMLYHlD&8z8s;mr4HgtV2^Oq$G7E}ZDP1|qSrcmgZ*8a>$2wY( z0HDNfV;v`U=i`H41&h|<+=V#(0JLd44SfgLdWC`0N;u0TPO+9&f_uah_yAWfvJ*>w z!zlrJIoa=?GYf<4ppH2^9KFSbkoV1QLr((}nr~>bK zN08a>bmE2RN)pSr4i<~rF=rOA(*}=U*$sgwe4eNRh}p#*Zl@;sxL<>5KF~+Q3u%($ zn*-V-nX@FdP)8u{gzN!?AVa)H&{$VN*flquyAPujx`l?kS?k6N!QZFXhB0sYx3 z*1F<2{N-8VMk_`+B%;Xxb83|h9&(cIA?xh1OeB%vUXh**z7?5+bujSEi%hgpa79GHJ{B;UN>MaCz!r~2)C;H152AK z^Rb6~GXk>4xk!dCJJ*v3XvP^E$!&U4sdcvU47c zw(_NbA0U8d%m9=D2b@JM!kis&yRcn@$Cwp%N}+`6r!Zm77^winnxzIZg^*pPAp;t9 znYA3sh{+d!d5(ss2<^piUD&C}^QqG@Mfk)i9u$71Zbv@vQpSp8MR1n(PVjw{eydis zS9MK0%E1k2HN#CadI6FFqtLU|l-a28*U0bx%T3a^Uw90mR^@UixUJ5?y5$p)%FNQ9RS_56U1ffSW1;$X(NM!-d zg1BS@&uT|xdVyx=IzkM{*0K$YJ&d*&fk*wILMJKt_-Z1$LN@QrCP+Hf)XwxG zUlkakyhE@?KF$>X z`8#Q2F>w0wv6g__v7r?UO1N6bhFl*)j$5SH^=uF3HDRN+5_7~qn}#;!7PnsT*1Wln zdyxv6HW;fmkI;D!fpf!5Spt6ONfF5YCbceT*2 z8c%cQqrGI44V{SBvY76~4H2RX05G`M(Ew{6j{&|D0~QYhyqT&%k5_!|p~kcuirXZ7 zFZ0G&Gv&3J0jr2ZJcymo6P%5;+Tc)sap9BkxcJ2yy!b#j0fD-{;$?w*BMNjb4^^&A z=JGv^NM7AS_og)5PC}<^9%sC?crh4=#JCxD8a74i~piw=3!kV&iXhW_lrOMl{qNU7&u6o@E>mB zQW|t&t|xhkHv!+wlH=%Sp}G`j7k?U1)QQ%P?CnF~JkaCdI%Nqpqi3;-WoVBTm~KI$ z8;~|qZQ@3;y{pt|c1&|9R2JxciuvdcuN;J4feKOFyb{w^Lg||~Ls`@ua_{Aywxz$& zq6&o!#MeTV;sq=a*o_6}se`FR*#hMH8`q+mhYuGWoT%ndwKs9tZ8ZSJ@z5YM&)<9w z<4<%8#-ryYw?n7b*)qqQodfvS>;=oht+$@3JY*>1>x7lwwc|>f+@XwBEd&{{hj$(a z2ZJccs+G882}=X#8^#dWIZK8rj~VzrCVW`Kl1{5RRFBIE2@T$Krl$nA$Ukss2nzLfat)|Yyb3>OEmQ!>j%riVe=^FzdIT%?LVy}~ z^!;IZJjz9J3r7f7zJLKVbI!$HZ$q1(lULe9T0yCyp$1?X0WOw+2=JVdv1%4Hql6n( zP$MI0m~S+4QKJd6QN$Cu#Tq%Eb_`Uk#THuC0gpSGQrs%LE|dK&V5<$GM86UbMyytU#PBv)v_xK4*MQk`T=Yhoj@ zih;QfQ!lcrgM8KTI?68Q11{8#^Iu3S;RWR^FN!IQ#3PDz@?4I)t_0D^DMFcV;?rq! zi~;VX0iKKyn-mlZ(jc@gW=bKB(+4`ihyt~JTztd!$tKlkFc!Ny&geBGPb(>+3! zh-Yj~<1@x1Ts6My`|&(>PgkO`*R)lL6-{~T;_P1G7_!J zE@R#GZ=iF)YM&afaI(r`!n$Q}2C*1jovG$3>vf8};Qnrwx)swGQTI1?#W;UBSR<4C z_M}jU)ziJ?ab74l(^{d%zhNgnpyMavUZ}rg^J^&^T)HRf@1|>_cABq=>PyZ8 zw$@xoCW6@3vBBo^i{H{5xsB+1JCHRVNt1W$)G^eJnIkkCtwtoH$wEn+Z1^Wg%@lI6q?)P`ekk}fsGrODtr;+63>pO!D5y-pKR8GW^9h zy5me%W$^iOI_BY27K5p^Vl0;6sQvN`swJ~N7g=jD9*zvx6pjqR@hk~qNv zZ0sZsj*c>pHI5Q{o@T_f+vE2Y#|0AbQfmTR40Y4;Xa3?HYS7Zu2L@s<8wDe&%%GV5 z>!v<+4XsQ}FjM{a=rJ$%8E;uO$g!c1LYviI@efSRpgndR)&=U|HP-Q#t5xfiQ>YSb zu`M4vFOW4o*4eY+!$)nHjfO#LNZZDhA?`NA-0z&;o1X?pTZQc1;#}NnoQngleakB& zePho!HVnbh=y%pI;gzvRoBGU49d)JJ9tmofyRtm65sO)i4^Z>;_ArTJ6Z>~NNW=}< zjs|R>S>y@Z<@i=MDp(D{OiD<`V@Sp${Id6iYZTL87aJdd?S8>+W-1QFVAta{P<6vpxh$tTreNh7F8p8YeoIC>u zE;E$zW8y$7zrkcz&ab9-FT8Xt?mG4GmrK?7gKNc2R(6 z2HR?;Xy&fJSgiRu^k#p7PnD-;V+9ojsKr&aY^&j*w(#L=}0(4Gm_#X0IA zKJ=Vb9?6Q~;DVzD7i&t3o#Z(j#JOW=&t-|xZez=+7B4-cjaJPev%mrxmN8DZjKbv? z&civ~qx4ZM`=He|4Dt8Iq%Thf)TxIJ7v~e3(HCtH;i@(WX}KXJ>q{8!FbtPw+C&4) zM>IWttGQmaot-8{P?+E8ygM7batH9#iB`~&IAOTX!0jg78FO!H$U|F#%d_R({XDdeEMx~6x>}nPX#C%q zK|~3R7O^JH8(^dai{5tzNR?N|>dbmYW0s!rXZt`9B5i=xKfHqs0Fu~YaBBu}>+Y{5 zw@jb_+Gzll5zqn&^b$I@j2@n9Lsv;7Pw#I7hABjsW%O)&`qA136KyLq)cqs(_`S;G z1F>FM@+Z<`d&lkcWLZc5YMLUWLT!6mddPjoSeDRO9@%SFJ(GV}a<<7o^ws8)h;%$O zHit=DjJX6BlXWrX62m{}4ZTNgm<>}4QbW(-TZSs%85Axc3J-rJDa2{hNuK=ybWL$q zf#ei!iw=GcZ{qURh>QNn=B#z@#3WL0s}}D{BaJ!GPTF~sbzEo{0<%C?W$bO9PX{|T zY^$jjuY*X;s&KtDvBnI0Ua@-{BweFE?B0&gTJ>@FE`0iNbSi+&2Zp<&Y2H?A6#8fme@e)VM2M8sH=)%RAk6G+*~fdP$KO%pRF zOvH;D-{8ztm)b92;saY~R)5pHE01hk$@~)ieVicZxLdpaaOuPL`)% z8?$16B{TeP^tr6lW;830iYAaXG4^US7^hPJBlk!B8FcpLlgD6}aw8kw-dEjGQF032 zcYB|tNr#kA^?Lc-gK{siWy>D&_=(K+vOf^r`LU_^kqVp-SnN|)0<2nGhnXPyvbzBS z&>Vr?v|PIIFFXmXgFvMKuqRFrZoVU$vAWl zerST!!L;I1l!Le+b?|)r3%?|W{{$!fm0^hmcr)E@?+ zGLRUhtM4pTl zQlRT<1fUL8?%`?G_@)r8HYmNz&n=pKRzXZk$h`>*d$3No$D;9hnkJrx;{{Y3X zMQuDX52X$!lxSJs57)3G7pe^rIZNC|TSUpx-w~bz^pBhHj1^HGPZGWL8HxU}A7v3& zqY1>?xr2Lfh_D#T#A^7t&_+{zgWm-+m(dhLh_8K&j#{!9-a5F_h;YZ<18Zby@ zG5y1-)*DdG`G^^sGvz=R=ecJt5gu ziu}g`QIZO!)Q|6_eqt~6mA%wY>ZQJ_m-@-Q)KBT9{-R#$y}i`?da0k$OMPuG_5NP! z>w2l5*-QN;z0_aYOZ}`~>Z^OHuSr|qL;t03oDJYKRv7;siut!Y>Mi&YiF%9ivnfax zz!*f{|B_cIe?tSTP`VZlhVvtTiFSqqM)YeDeNZEh;Bme5XMoY(BG|+|T{ycXhiGR-a;Th(9b{;>h*bdbD)Wd0E|SNcv6w8Kf+ zO@}@GlX*VE!48Y?0|SlsNfV~t$2$N`<>c2>et&)#3XYbl_Cf61%-fqg?r6k<0RRwLfQ)~weQ7F~*J9P5$vCG?#=d>lYmUCk0%1YOTY(c=%oJFuma)L6G%l~O9?H$y%8#eI+^vX+Z_x!N7F0|F&JPp>G%{Yzm=H3V6-Hd)rbMwJ_(Vpz1 z9KRz(RbCu860rx#atphVbhD`E(iuN&0*y&>YH3{Alfb3in~eWKl)=NsE{{&i_?`wA zJhQoxn38h`{=Hfqyb>QRMBXF6#EQ28!v9l(zej`rWg7VUtOW9r1iTMR10rU6GO$iheP#lF6v20B@F%8+ zR}MX79xwKAaehRjCx)h}<4s^c6QEsNOdu)pKa1*Dr`Fe76Bvr9vr{$tmYE=Br;N|+ zAkfkj_-M25*+7!UaRgVwaXbKCn*yK9P)3V}L9#1p57`NN&LMj4$EuC^`#C;MgE#nV zOTZTs{MCRHZTLrqf1TW%UoA}GM+recfNIT21P3Usr0w^ih!?mFUjy|14X>j@8{fHT zrnO+F8kq1seO_Qf{pq6hJ+=~&ht9AY_B~Mq*NYoy;m!nj#Rwcs#Qknq0Au?^yn;{O zU`rYAc_6%NH7a#3rqrKL^^K|Z_4WjR=McyGa5vVjxh6=Hek7ph624LsR7!vIP@fe4 znLrs~3jBP+Cy)h5qTjUsvL~&VE(5r@1mL7R&D1Of-{pj_F%@5e{wt_nIdc7#s5jF; z#sr$6zkWah<5ffwlJ!i|iK*b)e9%7ue>K71ufczgPkrR_Gi5y206I-Rz|_A&_$oDg zcc#Z@ruSNcr@QNjg>%!xC#bFOwf~YuX7%qzZ5CRxnJynp4Fk1=1WN zUR>+VKjB)WPN4szlA9wREJaR2{q)!Ck~#2F&!Os+xwXmYE@o@NmRZ05hf8Y!AF=x)$5jCLai#4 zztXLGM@4w?tX368m_*fE5@8b6s?rFPsCvsHOrly|-a-@_{0nvGEXA)f5@TAJ7;D%K zUgHhhsm=@#L9o~lq0zKh^pn3(9BzR$)tFG+ju%qB*Y)T9~9XPArj%s+~)<`DDz z(Le_M+K`QBfbiB9;$Oh+>A2;Drh$#lW_oOLmXG6d+|6M1blm(&6+d}8=H4=}$rta; zCg#(BsP8YIsP7JVHELefLgJE?Nc!mg@H+N*Qn*r%EweG+W)gn_V{~@^csc*_S`MLV zAuWkv+nOGlS$8;tWn1h2b)Q_#h+cRj#_F1W;#f}3S_CSC$@Zrj)s|?#;-X15y~A6Lx6yHA3d+BpWigJ5tji_KN1^`Nz+5jG(dGQ_0W`wE!2THD>J@@ zwVDfKw$PS1KdY|wBuBO6IqJ1|N7L-g4E68DJ0gRLfUDJfzq*$W5lbS14PBRlcg>`! zMDSW7*vbT}+<+J(o|u+%G4>}W(z2}sLXJZ4H6AFi&M9I4U_6~8DNZe21!9a!Aj zlsP^!Fox?sGdPN}%JCMzEy=et`Asu2GVqJ-E;)#OQXj#)DUwARJz=_8pbJSTOEWnE z8o;Kb51@r$X#l!Vdl^Vvnl8)t7%9{k`-r5pc;Abpn;@N)0#X2{J)Z|lJg?nUpi5kn zH7*wsmjO6-f+VpWrVCQ3cnTF~;Tto&c@K>LNa;wOSH29f%~J?S1+s)HX!7Jc>FLbKj8kV{O@Re zPm_V18|Wp1Zt{n`B|Nu**y3V0ql^NmES|*0WQ`^Vgx`1MD_+zby2yo3V;A5UJHOIS zZ$5fDZ>BRAcy*kvcZu0?8nr;(j~W}Urof4A+(IxJyaj=7xXwK6$wyu5JezLHr-N06 zwIjEyqq6YE(tyHHtJSk9a_yl-pW{vQ3N-gxqt+Lru4e$8s}`X;ay9@xn-+bAYI;8c zm&79UHqlBf!BsTqN28f9pP>_;c_7*9`5TdVOQ!lIPBM(g`4KDL-gz7>1wQ%-K%}2R z+#2*Z98L0T>PGHS%lfE!Bfh21N6XGXn@7~qJ$^R6J%x|ThYrVsIg(BC_M3LR@qM`7 z+V(|ubY4b{nDr}SxUHoOEQJ5f^DEm8uD^8~%$h1Nme40Zi3~5rch&yf3_wKe>zes- zFagY?tNZlxfj9!Eo`~~+Q|N4JGYx{T=)!APe-5+K*IVnve{Sb~aqTR6J)usq9oA(% z3%#Pl`nY%uQjd(Kj85}A=+e`DQ>NPO`FFsJH(sa0!lKsoz>ZtJBV)y~#v|byVBqru zpE@LJe;{gI*-2JKFQj?4EZQrRMl4#qjN@0ggx`*qtPEU8_wU#V=5IF@helfhU#r{H zb7}N#9}OS5E$c0{U)x7n>ZTW|$h|B4C2k&DWDRY?OVeKlzQNn8TjJ(JCnOvkm%&dC zucOZKP9~HP2h~qfx3qO-M{msVe09rUQl8MRpWv+9r)ntm&OD|G@dA&^TFsSRFuOpOoQgyScv?C(HQ2z71zV zAze+bs%u@;x^BQ*^JYbyX5yj0)HmUz7wXR;l=ix4+3o58&z74r)i&V!77me+;fybS zEqK6NIP4$64boQ6{zad&hG>pK`=IgoLkHqG@rr}zYFnGgj(RgZ@7|KfO!yEaMI{q% z+yB;xFC!(lB@>k1p6D%a+{Hrn6gZ;}reyPZqh)uBxkOwA-fAK0h%%d`j7*lV9qMuA z5RDaAB4e~AWK(K?I67-2GuGF$C6E;vN3Whcp%u6frVlPSq5GHu1Jn%F63HOFf&7z) zyV9?`4(Z@Umrp~`L+yQ-9Vn`eE`T2%qW%qaHbhVZVS3$gaaQ$% zSSFYew1!@>hWDulg71@7;0DII=<&6AY8$XbW?JPJU69%*+b6J}20HBY+OsQCNvGre z_@RQxGP^(`G_H2&*J}JHnYqA0P5Af1zJblN^L5ELymA$~h1V|zE@hwCG|3g6$M<%_ z{o>FQ1nL*xEWx4ByXfxr=&$Hsm<8Uv!OfhHaP_;WhPv>5MwLrW$2AGd@Z)1sfXO@{=uA4!`v{-bBJ}nGZ0YJGsKCfi2g-j#n>sVzYuEtCh`+;VOv_ z1HjC8GL2lnawAu{mr+fSjpgrI4FW{+Z5!J95JJS#lueK2>#y^6g1s0x)+72V7?%dX zOlSwTGn*n2G8FL!j%tQBTRXGKgy_EwnfONx!AWAdry3m>N4BAbs<9!QO^v3vP;&@< za0zHs$B?m*%Sj;dMi<4!abPgNYYhCA5r&GKOD*O>Q3BTD)=S!(>0NH9Y>~1Xw^@et%qKo6|S7`K9nnpW*t~WXrjo8;l#xR*%aAXQ|61m%bD^}fujEcOm4^v?| zPgw`X1y4ojP~mn5GSyAsXMdO%yeUcwt1&_T`2eYyb7Ji5(1GzmzZvufs3-zd7r+aB z)ivT)fP!221zcx2MmZ{pj>x&}&U;W3z8PkLYd@G=34}qmrWxeE#rhz}k&?}Dmrs}Q znB_i;*q|}%3dr613N!!6J7b?4tgfR?1Oo(RBW=5;xBqA4! zsNq2pk)r{-kz|v3;BLMb>>cG}anNeO>#H9of?yi#h?cq4*jPz3g^EnvY3o%!h6RXU zwG*^m#Bm5$%7hKMN?JAigStiCW}K=6jWVmmUc(@_p@!rXm*bEvG4!|741M}7x}1Is zwIoH0UL23)u%Ed;t`1TUK-{hIM3-t~PzOQV zB>C!>7{I4#T3=+ez8|eI0M>2{AXLV3hV*x!*|WCw!|)OH#=&&e&Wh3STd4vsQ3Y0l z7+!ug1V4)Oppf(ccMsKyn*xRgcrm6&%AoXE9v4WrkDd&9`o#WMNfmZO6=El*QHmNG_?ABFX3mrLVgI5{DNrk6sVqu%_G+ zN5m43xSr7T1a5r>ePtRMTY7Ow)UbrFJpE+n(92v^{hH4ZIr6> zTkPsdFQcgr%k$`7W^}%$IwMJSKGP-xZU{CHOv9uuY;8!=HY=!k+v3sGx%dH5#G&96i9ek6AeC5Ejzno@Mxd3D+c{JfH zM&eQiQFbORUrg`9gvv*sWgMq&laZXhP{JLpm`Zf_R^Vv(4&#J+vAZ#bbM;O`MBTrv7;`tj4rritd z>0DAp2kD)l*=y^|Qm@8|6upuG1-T^2l@FaO+9<#!dN^4(I$zS$03r1ZF-p=5?4E@> zTRwmYqLpzhr^|VXMl&&PJ9P1)5>7a;=d_$5KDgc(7}=n>6Zb;M(M8Aih{HJyhifX~ z2oGOM5wVi%1Jg^>(6;{uowo6yt!f^_s=0IL;8GUyk@yLWQSESQMWD__Ge&_iW4Mv8 zycdB*>_ik7k>iu|2%ZWF$c@{T8&Hp+b7VaYA^!+;dD74|&!CHxid0E1z}12HUZimh z_*^j3Lb`(`--il!H6BNK`GAA3I&qj&T#7xx`f`OPLGigl#JDM8O@qVwF|^y&OtAp+ z*2F6O5&*($CwNUiq9a#K=t+CF(cxK?=g}v^XE1hZngRR{yR_04x*&dV&k4S`h%Ziq zO}P5Few@^D(Y-*Ea$vf69Ord42~!|EK8{v&+8}Ag#gZnx-Xwg(#FIKENBAz#+#?G1 zr=fNa_EaUc9#9J=7C=pr1i?4SABThu`R7Ub7aU3c zc+cL9FH=0JW0Las#8TpmHBeTkvv5A@qvAZKy4xS+T zg8B?ngnVyZlC6D?(-id?%949wYqwox*xHKC#N~E%3@7Hc#zUWG6t}j0>Ri!D?iE~h zC*Jei*oqlQd)r&Tm81MS5K^3$dfX+bCtAb@AOd#}8tIm~|0W*UBEyL>GS%{z4-EzA>EiWN3+t+u zX@TpL?S0XOaWQo|b&Ujz3@l|bW`=uVwfN|2umY(AuUIF0?aZcI+@KLS?@yg_TmYdK zMh0_=K!(jd^F5xJZhTAAs8cfz$VheCP0YQ6)hRkrdK9w1Ihq0DU0c=)EfJ`Fgm&ZH z1a;4e5G?vF__Nng8bo^N@K*YnGu=bygL?AFx`%etaL}Rvrg?W7>aq;#rh_`3D8UoM zKNlGOG!OpSC+4#I;$`t`h{obMG)D*?1LmCE$c(w)xqm%<^Y+ANto%(tM=C8q6>&sTe;JX$C?xe6I}@LIXiBw z+@{DMW5Ua{G>ns&7j`ik>Y%xt@$uM=q3#+-_&E@IWX9BpiHTmH0jSCtxw9z}yF{3j zgy$cE5`W?0+C}>ZTJ%+A44LP+2(whrErxgKy7tF3tUDLSyCmzDV=Tx7kBUyvrY?sz zZRzJ2D~{Q^cU_IiYkPA1{5r}I#2i@;m7#Ph(!;Um~FW0KGQyOIyc;!VL5ixyaS^I>tTvm$txV zW(D6s+|XvO$hq`hllelP!&jhkf=wM%&$m+34g`Lp%rf30PJAkPB6|mrn8?6SckJq> z3G@R6werLQ@3BHK?iRw%eW$zO`W_&VcN|*?|Ar@%@dqUSSbrW+Eq(yRCH{j^&P3nTBfm4H30(lg-gU#scdGx^keea903n zcN(PYFVm^AktxM%*@l9&(VU)@b;8ANhuvcyFpACF^+^X_qdZNB&wd{auZZ;v#q%BE z7opKO)5nnsPs5-s6EaCncAaFBEWkt$cJ_@)`TuRdQaVBbWs zctDeO+6?D6i1-j@MJ5!8ga7PZ@{8ak3ek~MdJ}TeGSa|3fzmBoXA#1DawzDxl*frL zW!e(naaThY#>#hSrtI$&&DVwTOUQcPCgkgEfW@$@WZnkn0Ca{q(=cog&YVjX^PoN4 zw|BCZTMts&>wuA*2EzxZX}`v3|1Gf|@r%?hJ$~^!!flY<5p|>9FZRzd%F(8w+h{5 zgsJ-$Bhql@ew_A~oc$0oB0Y>w(!!J8RdJ&DaJIpf|6&(X-2D%OD?L{Ry19(fb})+2 zT?ww4rbq%`XF}ylz@}3Av4TQ`UYbIVB84m^LntLKViK#b6WGy$E&`LIVF5Zu%F0_D z_k0n=uUjLmgS(I1y%}h+M#pz?@SP(u&hrIR70AS`vQTA^QR?Z8jG@=+WXPdsr_N5p zyi4$6g=F3;D43p|8j@H(gf^G8gXBUCz)1thH`D-ITFPvgRoALR#z50p-c$lvK_JLl z0Rbmxcx!|wb^3*{QPMcCsUwEucU=x(7>HBLM_~e%krzf+h|v{rZiMW&fR@gM)mrdl zN=ChL3FgBB83tYEC#+gBs!WT6Lc4J|JQ4pC)4jN~5uC3jCSVMH&s%kH(FOR+$DbR2 zPW;iCpHZ;U$~4Th&(@h)2c5(a%H=DQ>}L4%G8&V9IIF!tRVuCm63D#*tf8nEzw+Q0 zU+y45BLI^VGsP*b(V3hCOVj0VXX#yj3`xrT{cvgx^9q&m+GeIB`~Z0dO3)Y{5l=XVo1Lp=aKgS(?-(gdE9MG2ws-M}f1`xc|w zCTa#xhoPbQm>LU8P3IZP^xmNRQ4Grr7CQP!>PAuiCtY;hg8>3 z5CKG4Uh%ho5wy)Kz9Ftmb(cl@L>f729Re*bM@eaDvpsSfMXneP2j<3R6n*kOGsYz}uUeE6fmm*`IJQv<*`=2E@x3@zk4;0-s*PCO0L2VJk2luTYw6?%Gy(4%5lqWn&?A*}7i-PldZ}#Y^XlA(6TJb0a zITdaNqNd+}FNYe>z;luG$&?V3((F2nAO;6XW@Ie87zSA+OCfQ6)y_9!r}&m(eqBgc zL+bDXNRE_CQ^YDuZaT$0q?I5kk(y>5EyVO`1v8YdY4*z$*LulG6m*>eR&sdx4p<6T zRAEq}d$}jl$n@@7osyl9uE`%IX3ttnb$x~S2;q%alwlpk9_b2%)fny!{9u^ol4@!F zH4|m!(jnogg1i&+A+go9HVqMWgNQm1p$8MSxMNsPMus+*Q#5e|cDTR}>~+bNKIiY{ zx}WSChnkcHGETVgVj`aQx=KN2364`TZF-pVd>YCY&CuDi9wI}lQCe_ehzZzeVkk4k z6?iO4GY>5Ead1J3EUeRs6fL+YPdMDr?ozYA#oJ5la&hB1^pB2`<-_B8-qdzE3h+tU z73pu6Al6ud^e|=y%9Fr|X^T45h##rZM-&6s6WR=42ERTVaiG33s0oh5fVIh9d^Ma+ zeg;@t1f?A1#Z~6Z{!XKCb^Q)Iaj@^H$c7>Y$KqLLSY+fvJCri~nF_U8N)GBt-G8KE!b8l8R?hHm?A!AqhpFkgJQ^_j69jRW2;VPZ_@**LAj&h0xM75+`ln(f0Tw~ z0qv1~y%;3pj7jtc{eaRC^ISq8dU^ayOL6;H4QGTSl-fL(KNoJ7v3l3i&QcKt#J zkzRP7d>Uwx>1U*!DJH>4_opFjgIDKNKM;nLGt|zN9AtsUgqz^CK2oqqFXSZXySzWz z%9RJU%l+cyw?JwisA9)*TC`<|=1vs!eprLH=gDoQSp=1U-CcY7!EN6*^?p97*$=~k z&6W1Z3|J|>kTQw9d$B&wlc3IUI;GJ$I7}0rV(5i_Z0!Iz)h`W(dkqZ#CSf8sz!A0K z0gxMb5sW{wMEzpNG{ba@FcP757!v&fxdEuP?g&1zp<|hr!Epw^c$9*#T;l(VCz$^y zC3-r-dK($N<;2)bM?)0DfHw2+j3_KG4NF$=1|8)jUxymO3X&BE=j-ABBDZl6o{R5Z z@O>&~lDjDe4-Q2Maza6eir@N*tf16m*NVOnPOePI%90yUqD@w5*1fNjR=iIj@Uj3) zv+jMFK%OU%BkGo$K<))ds2hh5-v%KvF{}=!+&4)SbHr41k%%sgG}|zdJ=KuIrIJ`m zkFgw1_?xcwSe+SLS3YsuqbNtz0Uw3*?Q9%SiL6+SZpF_x>l&f$h#rgQzLwUlr=^k4 zhf{T>A4SRwl|6%(C;Fr{B{-kV9n_{V@F`-{MaIBZ^kEiLYJm;>OB|r3nPw|a&mJw) z)K4mvH82MX#hn`pb#@wpiwuH)3DrucP+00j9%O~W>Wo3|=|WGZJa`KUd-1x?H=oPR zYEn^}rGu{-nVd8!t4qamlc`fqS@ow*uQEE-bOL!`j>Tw2m2&7UdTksjQa*lf)BM2JnFSy^ai1n|nj+>T@I3>@V3bDSbh5;U z7le@ogi=|=o>tuuG1+#VhZKs`WLx0;WKDM5Rg1i$;!nfs%O~rse&V8|>F93K(ZN7~ zpAL0|x6>qY#9>s5`zIM}i9wys!ok+#RK$H3Q6_hd&nhmDYbgpCiVzyPV!qxjg# zqPfx-^giG*tKDBgCk=Wm`j=`ak3G?L$q~)u=Vmie(#Y1qCsyZ=;fba5D#xK>C}k!o>I~0U~GGAp*cA9tZy(4q2E>NgjRvjX?n6Pk!tf| zilv`>$6HCUY@S*1yWKpurp(Wn;^fQ>A6CvWBfenar!Vv`^6J#&a) z0Kwxiq`5yC&nr=ijl?f5Bto>6XlY_4Di8dGcF&jjZtcw{?Uav^_om$+neV1ahjQMD z^(dShp5442MXnmoo9+cljbfd~ux3F&J#8!{v@1dG8XMbmNZ_F~&EBifx#31LJ=+%` ztxk?%Yl5{$c0Dy>*aSnXug`@QT4%k0fX9NLFYqRg0POw4)qfCAzoZ)@%rG{a*SdqK z$q~biYO#L2f!!&wGh#c=7EGhF1>6^7uOaN5Ta+syIf|b41clKz9l@E$({N_v1f4Ve zp~+PsPupKLGCF)@0kilQx1dk$9pBTzByasFpLlg8@;nTIma_ph8Bn3kuFi5BBxQ+R z5n5)O7?^YH2j0&DJ*wXZ{PXd~9!|v5fd;PS>ichDLf2a2KV|&SHfWej6$_6&!pi4F{LPJmgY)3$#od>A7@BgwV1B zR^JEufU!`j3El$1(BT8x+bD!_E(Yf|f<8RbaEiRXT5&N&JqVGZ16SfOWN|AN-V`W< zyDK))3$BS{mg+(M7j-J!0X{-W=ShCcQ6f@Lobm5^0ZUX?!wrb35YCq#nQzsRwK(Yq zc8z4e!@QZLhu6Uaysl-rDMIy>DB@`jxPlgpVR0R#B*; zQakHJje^MnA@ly9Gdr6P5^8(j7k-nOJ##*u^PJ~A=lMEkOz;W;-fcs{bB+og15Nw4 z9oE$N2IAbkgV(7)je!1skA?pEL^_?O?Ht-hbYG)soEdf2Ez#yNmd5%>yBj;e@_}5N z_Qi`9n3%yB%Hfjc!1fB_j4;m3g^UK#XsGS}y%9iO5Ci$&Ks&JA2RB(t_@Gb_kQ}kI z4@RgUIaWaxDu8vScevHwv=P8Mb2kYK*s1U?ivgj)k`p6T_|hB;i5yY$H?qzMH^!#c zcangw*S7;-gLu;U+z7!RWS!Xo?1KJFhg)a97y+>C7+~Kkve}rlY!)K|cm40PVl>qA;Pjs{^9;pj zV1+F-&1QoFH~L2C=*%0f5qJ=Ti+NudTmh%$fO&>Y$ZW$B+g4}?tqorrPtCTfm_zh& z-r5HH%*#MM@HL9m=F{ATF`R9|!lvm6sfdp0KVhHw%pI%EgW7<7ie`j~y-JHCNwAEK zK-54J7-;GO1{y*w3^YGMKS0o?frdq3g0O`VaB{rR!bvVDDHiM)Tig(P1yY<9HPIm0 zuQ+D|kT1q;G?_?&2#9k~%JAXusFCJwa8UdnY^7O-By?~TG4CxRj_XVl!YGp7F3KWM zmQk%VQz=Uq8e&=msR4|QkILKTTWoyg4Y7fEk>DIO74CZl0|6-^%EmDz)bu7=X7XGA z4jX@yw#}Pi=4N2}h1889Y<%Jf12xla4b+1~#voqCM`LT|-%&RnEQs~+v0H>MGU z7DpOU-5ApoAc{f|UlS+_&b#U7G4QD)0NZkd1?- zlCnXsqnN&yh7SWDa-R}tqqb$& z?}z>BLJie~pJULJNO_|-RHD_)j1kK7;LqW|utK*=6{EL(tCllRXgvy{w=prO;3cZh zskQxf5UquuVYQY^i$+Hb;x%AYiTbf7QLTg6Z%^}P|O>Y zZ8?lVg$Y_byr%m`sOdjrHGMW~K)Ej?Pjf6v|Mm-L_opyp^&2q)qwstVya(F~ z<)QumA&;nmwEtr2&2Y#!jsUqf!@@y6AV(=n{U3~jZ>s-a2mRkwM~qUt|JwvgRR6#I zeEmOq{>d=?{}8l#>i`t@o@%UGWb4YtH8|RT7Jg4xHPXbu$+nEptFf_O)q+4w3(ah1 zN1H(U7ELzPL348iKSiZhn~&Lqz>?^sTZk4gk*1>w@?=gF{ z@N$fHVVu#i$4BT`!E|f58bNZb zV{Cqs+F|)BmI+N1uQocLTBdEhF2+%QfTcm3Y5`A$NVm^Kg%zw9w^*|ruX0$p9niqG z`;wErQoDAbsvN57!(Us9GuzU`f^CNFtR88P)KepLc45BN*`LvPVyT}!#3{2xq5#)X zR;DG|&#sMivIY2nzQ*>6X>$N!j8~%8^9PHpi$ulQLgOc3&`n3phE0V6BlDXPfc*sq z)YR@j#TdnQBw2gCx6-aVto3DszgjVfZKVh4gY$zv5T-3cg>}1zvb!6IYDkYpSn9ig z3^N^qq~{FTl$_oGOg|M`AP?yggsJ0z%JFqC#z1|REF*F~;RN5OR_D<-v=LK7vT2z7 zm>Azt;$hQ)itudYlOu%kQJ3%~S`K4COhq1#{4td8dlo3S1gs099P05Oq8+mWjTn^! z>z%Q#3>zFEV#<0D*a6lg!^{EfxDlXr~QGHAmNp zcC1jMA=X>AYkrh){~TZt{5d0+uuuFsFY1bqnT+2Yq0xo0Mt?@*KERs?nPx8(fvi2Iw37Ug{8O_YKN!A=I|S1!CmD4vIxoCgsJMVYl5=O2xFXYHEXzS&i#(bZlEBm zUt-B92Y{c90N@ALSO8uP01>-mdPH!bjv2-xpTP#nG8DuK0NBZ_7QV`YTYj|gF{Z=k z)03|sDEM32Jo(^np>gmCHXD=znOmUM zIOalCKewtfm&b3gjIjM+kr6r@AM0#65#b0L;{}(I@&U+h0%YK6d0=feEwb&KEF(l7 zutOY2iSsnZc&OOJZ8J+Tl;+5613_ZWZ?Lq+xTw--tt2;pb6dFsl@4D@zR0D9vchiz zvS9JDGbTOJ5^{?+`)V`|3qHz9!^2i?!)E;X2Qf+ zM+O!U4P7U+fT~nIix@B?jz0plLRI)=?&~k{i)j-{GEJ_%&hyMHEm44-#?T_JBE(epsr3 z7!AG7EI(B1YGnBYs%=g@)^X^PNo8*now@h zY6t3Gd|ut0wS$?}{ne9$MwJM~6s1@o`zU+*Zy5mvcYMo2!SfhRVtX+OIvJFEv(CQ!;;}UW)-YE`pG2RYG*(bNs@ci>G#(h@+6y{=Fd7g{$(|d=y7@tC3dDjJ9 zjEQXCvk{|@muWBlhc#cB{8DO4G{E6-5oSPu3B$p77jrP)F#-~^7z`9-cqdU52E&vI zEX5E4%>5*$jH)wLYTwO?v6?Et2uXDit0~uVehIv%{|8MJ(An+Gop)jDuj*vE;iK|s z?N6Ze1+@UCC4<16Y>Rw__WQ|z!R!PROu?z4x0hO4GP%9JHv%HYO|htHIp}Is@n+fI z5pR5Kdb0s5g}+8i0Q^kb{>R0el!2EIR7Zh>2%oQPj0+q}P)5pw6#JPaAc!}1N9Yeha08G?xecWQ!7s5N#WVS{E z@914Ac@Lq+vYBG3u|JRXX+YXJgI=5H_kwB&{j^+0_nstU1WjwDl!2|&WAJ)9JXsI2 zaO1PIL?Xd-WtnMzLmHN-QKX$d6C;zdOpLIPrBP5DSs_PfLG!ia6JuC8gsj6^&{oKQ z!&wl<>cU(|Tkx1g&`~$Yg?vy$Lf(Ek0vdmpZK1LMay*SF9*wFCF46igi}kSEVU7E* zem00XUTEk8LZcI<*pwSC9{qj~vI9!sRjQgJR#JoZIw8QOFxx z&tVK>%N1Df%OkY**hC98AJYsYHPKjo#bblP3Yg~1~Ahox1gwkg(vw$lh;Mh_Wbsz4;C`P|0(9*y?USxX~ z`xsxxlz%o(oEE&FRDRi1`MuJ`=)pix4kl1_xpp;nu<75X+4L+Y=HEYE#W_%vuYdV1HypI8)3 zWpBZsY!EQWCI>v?d?E&wm?tvQUaz~fNdt90Gf?N=A6s=s50CrC>yHDH#PIo=e~E>@ zO++8(tv`OD>DNT*qpm@I?f%SI*CWUp?RpM@X-eq-a2U^B+7$zJK0Q$90YrXYSnAjD zeT}=Nh3C0h(njd|EKsm1!N?eOOru%W`hqWZSu2db23;TJh>%_8BySnVI06{2)1Wh5ZHpg?0op!&)4;*d|O9oapiUcZ&xA=1_~u z3xInOwxizbA(H_HoD$C|`tAA>> zw*EVoy$9mdnNss@Ix|^U#k%dW!(<)2oqFK()j88}l5+`P3DVPcAW>c9tjk0i;?w_? zvbgl}!3XLwjm$bwZ`$w!_5M2@Bai>pby?KNkrhKNLR;_}79s6``p+Zk``RHkff%Cx z2&hd&&8JgY=ukxIdYJBe$=t_PkzQM_JwakZno{D#KBe|M(6WyX#>hkO-3K-$KxPDq z3dI%!M4xh~PagJ>A?o4q-mMv-VkuT} zD@eqWX_E%W3JvBRtN3xeBky}yaa~@eP5~h zA3{@RknuFuxeEx`P+J%;Gl}lMV;vb_K!?af$-bU7ft>Xt>=n63XxdE-a8&K$9&LPT zY)tdvMTwGLTayJSmHo%Gi|=b8#>m)=`ye?wrq*b#8)D%6S0*fS>Je=*T8ss8j_g~| zg`S3eP`6<7@SxiKqgY@}nrFxa&A&PVmYxTtnpo<^NPzz?3|1M@gP@ZX=TBLPGbAZ| zMeADmtg(p$)0m2nC9ZJdD_>U;ZJ1M;nfA>vwp~0J44fCh>>`80{NMou`v(AfMgSl; z2EaNZ1zNmVB#3#?+`U4Rh(e64M#iDF z{VPw{G84@Xjvz5V$t0g%1Bk$pM~7&Q_EB;SqJH=sq7ZGCV-PVW1ZdFPk>S8Bz~p8h z6%)1`Af;g7t6{Mda6!JmAtaB==&1YGPNJf!pc8aGg9_CTG#dC=qL4H-#1QpQApb`Lb#5D|^V)$rFF;fl^05J8 zDta{>`Cr3E6W&BR-s!u9rk|79WmL+#OY2XJb?y=XVlGT`c9pElm$Eq2`7yO@Bn9y4aHb_hF%> zrD@4Gm;QeX`ZdqEX43zAl|$F2NATKOoAy6o4O?`-{RI#`WcHo_B1a*h{eNfn{yZUu z}?(nne%O>gTfXtC*yb%$1%8Ez~t(IqAkOANj_*^V(DzN}b;j6jXC zgk2~-=Awb8Vr%Q2u;p;Hxu_ya%+_Kj$T$m-Opg{b4-zz2J^A##LgVJs=r3&*W9Vr* z#3X9r;SSVTH!DV&1G2_yOaXHh{U6Xw-2wa@ZuFQN%d&;Cygfpe>{yoXQI?NJ$Z`%G z(rk#l*_fad|31R`QJcYJ!?b;+P9LEb+81Wl5=Ra7jF9EgSe6gaUx+yr<~YKc22W5! zY1EKw1ia8`HD*JP)7$J3vgF3HtfPj^n5YpBHhP{KB5Q12{s^`F6|`(Nlt;CUikDZY zmK8)8BQ=@IUX6m-k78r17h2dfw(j=WOFBIU3#Lz7#NKmFt(#JO+8qYs*pgB3 zJBw(wVJd5Ng?3^(wH&qhscb?hFo>~-o6HHKCcp@Y06_w)BZ@h&=rHNU>!$b%pqWQs%#|ZxaUN98?@6td=n_waN?EC1|@|y-C zY@hXr@p7l3-|(y~PWNeK9`LCV?Qy8|#yXcq!G%OKt@ZK9ua8wrvhW#$lyYqr&4|@m zwi>lVUhT92`YN@{R}I?Ieu_HO?x5FIZb(i_SVYzve6~H}(-N5Ko2ho-b9o`{w=lPZ z!0n-OL(Fkmmv*ITeGd6ONOIDp9fVN`aD=wDt}e0p{OR-^_{1If0GLfraJSbds_on8 zjh`#mJ_2Ml+jjV9?$k(={G3mjLGQHPLtgOyOSBiEjn?Gv-oeM+1bKssDBKviHCt}u zW;f#qf{mZ%A9^X1UhY)CYKz3npG<^h=&7m_#B+Ab5kmykOAa~7klV6vYB;?CIXAww zJfuwk_5!n?zogh^6XU~O(3L~`2K@uia8@_%7Vq~}s_$Y}ruVi3G@7F>DG^6#NI%dg zwIq}@C(fHMPQm9)gX3@LwVu5sK*>V)%SA>-DatAkG{Ouo&{{BsBg5!YPZRGD%FOu82U)k*T2J!vI zL*mrN9`Ul?oftx!=%hQwvRxUkXEuCf7_k41*VFKXWIS>ChghBYt@FiXME4|8{Za$~ zOHCGxTOR{vK}2!Jfx7fZz#Mq|(MaN~aL`O97=$X2nkI`mq|ptyu!dR zGM1v{6(Kgu+#ueysj+(7IsLQc=9{J-F$V`kVg}SSwfe;5a;=S?YnG#n#*6@H%*b$} zA~vxqeJUcvOPuO**Ru}_jVICWvmT*Ir@LLeNM6m^o`uYL6u;F)d``bYHhScz7xF5n zE$0ho-0ELB?MRg_Z|J`ggevk4{iV1|DV5r@IW!Mzq(q-qgU6cHy(LcGUM;Q!dr@!9 zjRZ^WN}9STb3Qb)McgJ=HN;=}a)y7!>(ujMei1KHL+W0dBOh9GB*=B*psV8vH`#hT zT(+3%kMr9qwf~vK%Aw|#GQOGD)BX0KmtR3u=EbTksCTXq6XZqCY+X>j{1hTDop)vf zelV-$%W6Zw2vA!s{1($k?mw=+zdjYd8HeA#Ty7WSPrCCBq^`f(J)sNjuTQPiwvae#GgWwtLGNkwsqs7BR+z^`|z_Pz7J1M_GC-E$@Y87 z!r_5fXN5dFLhV;d6VPEfa)+?_w`fF;+%G)*U-Y15ho8hqie($RSJSIVj(Akeg9-y$?*V~YHWw#g?5+r52y zD*m1mwwLv_9p_WpmhGm#$X(g!gHQ2liuX9yfevriO#mGg9>pgXlN~` zu4J{m%luF2`oy8-L24FNrdw1w!J^7^pSEQZo1{Y11fVYr=d!_8(Pg21KzX%V&*RIM zyN$1YQ`GzJ;uf#-+*iMuH!D%3h`Ttoqi+QpnF@>xCUe7SLf(2OxF0A(c#$j8Z&5oD zi$g!#PJ>Ji_7wZ60F3cmRDktJBqqvf|CMc~y`SG2 z<)P+~LAu<7Re<&YQF2(tM-GBp8T(t5+i^2 z4fBlkoXE|e-+NGP!{WI+gmsxW=5rg;)G;lPqMPFkyRf}ARKcKMcZLYkgoxxOS!mn^ z=!p%#Liac^nenIaZ}7`$x43N*WS)uWw;m6Urz9BbGL3aSNmi>Ex|~W0WC-yt5+?41 zRM@lgL20_W$W<+$HpF!Gbeq8#YT>ISbOa0E)Z+4BY`C3ci#+Tc1;(@N2fu-#syq%9Bi9=WttKJJoRT}jau0xWf~ zfKoA=3PEk;*Q7Uu>3JIcX|l8QwOzTL>aHfc`k~6J9^ zgsapb_wT{mN)Au~{Z0AYG&Ll}^&X+`FNYWb-G!-9Lwv|@)a?L4)bZ6twv}5kEVlBM z3Ta_Bxyx1Qt5#NNMn)EL>)Lh#(;11R# z!W)1!TjFu{_RmpSjl8PQrY(ciYh+}iwrx*Ca?reaSRGnXLi>Cg7K=RkWABBw{3z14 zJ%&H!#*EFl88ezGS0apz;D(C#M7frLe5$t#_)SvEjzfL88^i+QQvtAaT#NJ|>+DXH ziWB3t_pd|4G;z}MAwm)GM#cfq2u-zErkAWtVLa4CbCH}98$I{zrvSDfKZFX@4z<@5 zcY|3>+->{Bp*nhs^EkWsFV)?l{qed*04LgRs0pmh<8aERm{g@bflk!u8Q@y!@|1hf zMJ$_l;RgSS4NE^8WhPm%IVetemKQI^jMAP3PF6RpcJ`jlZ>_->XE51HxR|IVVH*CJ zh6*VfR&(MaOz&A9>M2R}hyu;X1pub^NX_y~Td~M5k4hN%N2^Kh!pA}!fzxr)%+m*DE||L! zUk8+v6zH@|w;(8E9}Prhb|6P79^nZUiCs?JfC zXDXX`C6+2cWuM0k0T14)?N4PB)`A@HZxJM(*5CeCX-sz|34sY|JM3XP}8gjCj@e@N$X zQ>6p>hYG5?gw4m09ypu5aa`c+h6mDw*Fr6Ur$LYMaRCI`D!kU%z6(FwBAgsaRJ;d- zAN?E!jGU%%-$tggZbPZsr&JwLs*WpFCzPr_rRrFC19G4u2xy{P)*RwASwlQ_X{k6C zzl5e5yq3%Q_;9)Tz=h|T5BBhlcnFmB1;R7Tl(_IzN;!MAG?}z#?Q8rZ^m>mA!Leo* zuJ;IjhB^F#z$Co3H^>Eo#YG47uu|0>{w&@sei3{ zn>P>n0>FFtF1%2x4w&p7$Pu=OdWwr6Z(bbqcEKFL15xD~ZQW^^i0Lv9Wd^@kO%3dF zhNs|8D2?1HJe-A5mLsc#;J;zQ;M6F@PU1mm+(7BtT%qw7_z7&^gX=C?a|%si2pX$< zy?uGS#8C%Ssax(hr1;k`MIK<7c>?uQ4i{eo?|WH9XzYhP1T%kLnhpt#Z{gQ!c@`R`(~LYG{cjy!`Vf&V5X#2zdV;U+z-on0$ks=M;G0PA@OA_L zw(vpx84QitE`cGswLAb)9&Dnb<=Ru%vfeA+Q!uw&*Wo=v)$3Qu+O6VsvX&&iQHt$Q zNDK4mpmu}<|7d1KJG`eTt67iYjfCk_8myzgLnfN&`D!T#gTvGw?>Sx^FT8F$sG*N& zDca5O9|)VPj#1C?HoOf#w;mx(cq8TEEvQ^_2F~6Ifx_EOO{rd&A?=e}d4(Rj)zXMk zwnO#wDc)CTgrhwQdUt^HlM?&*Gr>0sEp`F7vl68Y+NqI2;yCKjhM7r zE$dpX@Q@G7x)eS->fy;W9v~}J4;vNoo(qVWDqsrqRg)UMh)Ro-@Ylmg$*FZxy6}4I zXLGPzvS%w6O>^d{G zCxq$K6XFJy$kYCc>QF+iKV}n)Ojltr?!BE~CEmiL{S3azHP2TIRHr9oPX(T}MwLz_ganNY{a+fq5>) z%e+w=GHkUWCg!^sq?;y@>g|KvnTac1d!EFPT~7H%Lri2D9{3n0Vba{4YG{G48s32` zpd)0VluLLmp}GX6vdT3nT5Jv#3oQWgd_*=DtoWR4<5U}1O7sU0VYn!wR#?CBay7k0 zM=B~{44RRH097Un993!~N^M_DV&NU)C53B5p%9DN?d->&m7CDD-X zkMrAaZJB4EcSA^M{1`}eA2!Ws!fUPAVfnxs@pf6u6}_@{v3R|#rHNUkLeuleS5Vt0 zG;PB}hnKjJP2QcYzsM4aTgDPy`hWJcd8B%Iw?}^rqMEc;{;*&Eq)*-**RVf;oce=1 zm~Pc6)ueQW*APCm?}%8-u93AA5+M>KPtO~zk~{DxPZ&`EMnP>vx~9V$p+*}%F87rZtT+MsMBRVM~(Qi+x`}(ef9+?OHDOR?Sd)n7ACsSiJ5Az`)l-fk;_o- z=9Igg%H6zjjdFJuc}Aew$z8>yXV#J7Li;6ZQM+rfT=4!&wJ*OyoyrW-kUQc@iOB|P zf)7znclX*$0%QYCGulhylebbHxt))vclt-ZPefL`qQY)gl9b9p=EZKY__i?2Af&)ZEG_Fx1)L9 zX!pb?s{&TchBnst3E;=9Y2(X!g39X5H=24jm8cF(Jn{OLGFwlZUAzX$yp#ec^8h83 zg3F+ry*b>>s-`HgrrMfIxp`hW#JT%7{xSck+1bJ)MsWHOsjTT}dkNPd#ru1f>d9)T zloj}awHBGhDDr57vzXTO2#9vbNCyWE1z|2{C9%^ zZe(1EN@$$qUBzG%en-BsJgU(Y57KD9-Qxjmq?T*<|23+}*kJ=m-#DJ-F{ZzueW*c0 zChDk>b6&7nip(pdzd&p7+sIB-M-xVPv=y)yGNf!HYq^-A!FmT2!AKZ2pU=Wu7?GfK zgz7vP@u7Aic%wI>9K28R6cGc z`-wwWk!QDNbl}c8Flo18t`{|D5?NlrpFL&2Z0gQUK&EOWx#+-Ey|C|+SSs!-JDP>(y3Q$FERUc9q zgi2Lp{;d#t%be@t74&(Jqqa{yiwdZ?`^>sH^^E&X@q1XU)e6pCF$j8E*aC+?Ww0HZ zv}6GKF%0_XYYX~AlO7!ceFev=jt| zI@iol>I&R97dVk`=lWTSya8g(U1V{-$7#I7l8k#?1M`C%PmJi*3`X)?pzU~^+Q~BJ zb_N%Y>8c2prehO`9foo8SHO&)N|VGLPkmbFkhOF*m5M5~HR*ztlVJ$DFS8DI!XN|hR zrP$TEE_s$ACBio$AW@mXpq%ScUGf>26Z&A~-TVj*o4WClVhi4xs+n|8@#Lz=Wa$)H z7=xw7DQ~ONDSWT($BoEuc>C}Yu4=V^azV;FVpzqz+>>vZ%*A3XWvA4IsCU1V8g0g( zjYd{9?cNxF@WXj}uZj#yPIGEgih;Ko^8?_s63Yw~T)#R{%|K?146=F&AOMZb3NykL2Qn;C`n9-ee@zkp&=N;LBV z4kUtdn85dQa(%=`TnRJ#ejW@-Xnd6L14uW1$pxKXD)(d7pEre9wk%BGW8_N0x?#rn4gWlRk&vZig)55ZLWg0C=Wk^CCk4;=nH zX(reX^ym~NSy?!y4o7qo&bEJnhPj(k1Q*MDo&D)a7Q=TS|rS%5pK*QaJv!jcZa!fgxh-ng4TPqqlhTI+E9kRJNu>~wzn)21{ zD#H53V-}eOg3}v}4DyM%JCqWac(tFavt<)c!IFiwzBu~EDW$_I7;A(kKP18N@*>`V z?QRoi#M9JPOI(m+SfC0C-E4iUR_}GGMLZ({yG2BO3T}=!Nxqcwt4#$ z53hJQ2tPLiJ!kz~+usDoeNMKH*AbJ8!h*G%$BYjDE3h5>ne843U1!!82Islt(ug59 zcL^Z+U~?aC9iF~!+$>fXbj_8yv4&a0sT zrbUZ8R3p>)sJ;`tXMApj6Kg&E&TXFx>Ynqa;NrgdZcHwhdRqbJK>-+1pRk33{h*-= zO^fm1c-MVWc-V_4kcP?d=3q9iOYqOB!ChU!xmRHMq?LbSY^{l~<@4~Q+a8H6{ui_5 z^Sm5SFn(e!{xzJsm`9ZgJ#gv+G|AvD%iV9sN?+e+6Sn*sI8p1d&O2!(4=%j6FD4As zo(g7RiFc{XSovC)Qo}1?wl$oxfX82V4KLjmTTaJCm(xjs`f=wir@`V!icKuPsbjrG zhVz%wMg}=JiM8svm~hn>EWQp?NLgs7X;|e9me`e>`jq19BH?*JBDn2b+=So_gwa~( zRj3(rbU|P6wtP%dms0B_Mu!COIudf0L&e5WG*Q2$z9+{fF>mt4Vx9OZUQU`gQC0>dP*3}SJ7Qo#U*_Y;PZ0eG;u9Emjdalt5t z7Y)L&*QGd=;!JY%npz(e@=7;TZhX~i*Q%W=7G(;D3Kj-Qry~E5&{KRZ{6mPBf8$aJ z)9??$*B|rU=!?l#011Qiej}q4JO-wqvt(ak9w9QnL%m5V*M1IHN{ybaCX!d^To6tt z1Tl=_3|eM-0@68}HhiT!l~gldwIJU|!``NTdA=8`1r^fiE7e3LMnSy`_C%$=n=R0k z_H4F@fC@zSVLt0Ru zpM?X+V4_&@@_I+G>{K-re^_mu#y}&e`V@KuAxi({K;|dN7LHhPGPGBG~ z>k^^yPw>Q;ZIKgSnN5x97v*}pM;$8!12Df5B|6)5f zVT0M#H5THSJx{LZ$v`Du8ie~n`{@)m?+^_Hmj%|TKCI)rL(CZd%Yj!eg=Zlyf!W6~ zDsT*n-%@K`TaV#K{%*Cq>8S9FwhGw(W=#_wZF7`4D>U+w01LCQ-e59FT)Sd8cqM6U%T^B$PXQdKQ)NrR`Z-tf%u;u!6w61oFj&{2jKI0-nQ=z(?TX0`|@6mSq zv?BTJ%8g?nPpy1>d2heXu7)1(?N{GJaxzO!9+GUUu>%;2jI$6>g`=-rzH0I6ttZen zEU{VY48n#xB+UaJs9OZipVYQ?TVCLHyG^IV-qI~pd`_sv(I14163!8dp~CS-xppgc zz{J2gDY4yan-;9MBO463I3TiG+YClp)1H`DGf$6mM1Y(kN?nK4r-*=RniJJ^+&mcY z>aUD~D{{T>>j}N@yWfY6?R|t?%}3@+e_pkABO<%d)(Z6vvIBxXnAk-_mPkWZ0#LS5 zzu@AUkFirysk>~T%PY;HR=@PI5JyG~sETqHux!E;ZOy3~74~qYa-?q?mEAbW9jc!I zN=`OeU2op3+} zrZB2RR?6la$YzE&my+Y#%Hm{3qn+0}?br|ML1jv4C2d&&(d+sL>LdpO$zOdc-PC z-KBVs!SiP5Z4R8sNFw3tNQ3PJ9A z6XweIOqh=;wZ|FEV`DHQlnR|t(fSAC?|o?G#4ykR@DqTix?19@tMvpE7++;wHU@?D z%0}4gCKJHDSXb2cFvV42DdlPHYdYk^j%4t9_(vhzd^sPs_>=gtT#C=7rBU5EXbA>k zRkHwQC_sqDYf}$8+TH!@cy~m2a07-s8l#?$wH7O`e41Z#)yZd!oS$kp1A>k}!fRub z!`vFDeB9yaL@aF5^)E#_g+Wsrv5(d~#>m@ufr zwgp8tC$4NmcN#-I|YdpdwA#8r%IA+9C3Zo{<_ z*LqyQGY&y|7@NShWa5tR>upKLJso$PK=-fGcu2a+b03IBp-BJo_Z#}(9O#&~XKB{&T6XVsfMi05XSJQop5?vVIh7(If8ARv=> z{p`;s??TAdvFb{nR(*;sYI=&r!j9(m5DRmk6t6W$3 z3zam2ae!))6qu7NaZXN;%Q@Rjav({{UYDcO-3Hr{An!#s*sEG>g;3mngCB*dVhYq5 z!|MwF7(eG1Kyl4P4o_fKvXmfuU2*#I_QceAs6=0D_62$I-2%VeQct5DiUxE-b(lw? z4+wc@aiXQ-xE8Mg{ESC6YRbIk;%npetK9WYDJ4*EBunw_iOG5jw2j^j4>n>ndM4uC$^`Mh+%?Y{nPAKhAfG?nG4%%+D4+|C#{m+%siN8(+ zd0~a>{cxwtR@wWZdW7EguFOeym`@)%4llziPz^|$*Ju==*a?l1CR3A zc*!Z>&cm*_G)y*f`78*ghY+2bPI3q=gk?^JJwx6kF4fe@-Zo>$hnle&e;o&X?mhJx z!RhmJ4+f|IArnay_1NybS?WdX!;D9fFdN|ntz<}{A2KS?@0tC`pri&$s-2BdjOA*i zq?>2MiW*C5qNJI#v82S39;Bq4*$_2iNe@xdnAty}q-3+j79<%A5bT*b3@OVO??E}3o=~z>)SzpMd~g3O3!ku)7`$7D{x6) z2c7em2c1Dmg>Mx}BBpYvGXH47gy)$>M~c^q>Flu?t(YeHMoYpCA#rTsY|%c?r+tRl z;2PND?79}@UWI7|)28W779oK12xm~dHR1%4wB3iu;xLsH)a}hmzPE;tkB1 zEnZ%wm7|b5gy>I%(9curqOa$t}78F5XP+xf^ zbf7ZS1~P}r8|0eHwHNkNr*K%F`y?RbwFq`a)>!$;)XhCq?yF{QaQuRzQ>w5C^A*dt zQHZ&@IY%wSL{G2u$&+B{bWy}i2ZI^|2?c>yW+E^F{^r1}%cbI$a=RyR=5p~WYy+Gk zY(LcV;2ld!@bMF;VaN8hgceuxMI|2g{Ac#8?`J=_z!kO~)LFBW!=K zM;=^Bd`o8YWhH1OTTDVLNr5v-(!Rz+lA~0|E@hDmtTw=cGi{J9&F|c_xF~Nt<)gqn zmQE9EFz{+sx)Imm2-ts@?g0g+oX2taI*6h zN{l$+OySX;N>%1TT|K-2+%;`30n(muTZv)EUdt92;JjI`&$J;N0-($RDB=xdvJkI9 z#)}7aF~P)-i5u*Lh#}ActQmGscq#ZB>m?9o*uyx%7av;|9rCv@?CDS{De9`CVrv#+ zn<}f+Y0V%Rc!;nv!b=pA@{K=3KtCyhJ5Ublt$wAE(TH4X#C=w1{1hqXJJPhmq*k!y zy8#cNA*WehXxxe4s|zku+r>1GXLUiQblSXqmD{e)COzO_q_WaeSy}F@ti+jc)8UQQ z+`4#Ol{R6YIb{$@BTlZYtSX0gn}b}&J6I9YNDbD~I%uBUhI1})K`sdpcp<%#B#wnR z>H1A65~s<53F ze~LgcO>K~ls%YTj-Xe;jHou)L3T%Z~g0qL?c96C~ zVfjdMmHYea@=(D_16u=Zw&>;&yvfE&px)y|Sh08wws_`XbJk z@KzdIXUCAJ#lPb<4@w(Le#h&fl@G^LRaor+3`~0~Ri@rG+{aNvP+H+gy2V+5P>J{* zG@zl%ikBY)Thx=I53qBSJ76xSe9u|4Y$s>ix6e2Cy1b=x^YWOagQ$~gID+A5@bbML z)=8m>m^};8B-1rGhBCKLUF%eT$WssQ2s+ov8z1IuqSsdy{GQ8L@-SDs95tl0iuoG~ zk*iYs6*D<-c$Q!+wm+dFD@|!j>w|fvv_RQ{?Z2*!6y#) zztJn9DGOPx#>`JopuyB=gF@pwsI=h>wJJ1ziNC?7+W;hE=-9Goa�J7fo+&gpF34 zGX{{b_1x)g8<9Ibyt~h%C&DHi97=IUe?@xha*zgh#IQ3KeZ91yMj$P zQq-ucW3`6K$H@|K0zy~pM_t{M)aFqn7~7vmpUgbv+HR!Oxgf(tYw@sJQn9k(WPla= z71-+;WCh@dz>-I2EMeEq_5M?4d>9k}az|h@Ce0me@@C@d4#J_E7qfxTn`S?iLmYJa25kOk6A-&* z@)6zf5}EZ?I|g@V@Dbv1?wxD1;EN3Fd6C4ADk_O=MTG^Rgk2_hoq$?e$c!XG2qLP)D z-@0rxVV0rXXS%kk*H#VkY8A%zW+gHom0g^PP!m`Uqcdb;ers;0=$bF`^QCd+)N(ns zTt3jU?94Mp-)c3;*RnQin4_f!juv~6YZD!+4FPoL@6;Mxcs6i#fExfF8`l3^cW<4|%U^JR#=%3KPU8j>8Qe$vFK_<^il+Zd)i=)KB%Zr*pBV zzUUKJED1{3<64W|b)+YQ&m)B2xw_%BVOw9|hxvbLZ75jA%c~$DQ$!VQ(uPFmgz97( z*JhBN(#W876;z$TB!^V9lUD;Cbh37k@eKWi?ut`hQd*@0;CHBP%O|(zhQw*5;-peBs%H~p zLHHHMEIbAL4O=Ua(5hp5Iz4!FY;K{40Q6uv;u5crBiUl69LW=t<%mamS&_Q+4D5iQ zrA5ascD4})VqXO_*<{jXp$KJCG`cz6UJli}=1XiV#!hFC<8?dcX z?D0C|#Jh2n1muX-A21ORp$6E;CZ#nnAG8dh#WHDX<2yi;QB`PZK@o0&{*E6&2*T3 zn{th8-;S1l9T}d-^)#+0a6O7^Gp=_i+x~TXYYZ@xbZkTBBk4>{Q=2v2Rdus{l1eO1wzXWwzc#cq-XNl4sb^3d+dOa z{MIU{_SK@p?^=o-T4J1&r`=j{POc{e_UDZ231#DEr;T9okV<)+d$HH29(>J)Rpxc# z%#+`Kl`-mxi0KDU7SnNuU@G$Nx22Sn4m~mD4c!sgXP^A$axumIC&`Ig;5Dbp;%qBw zdpcapSj`;7S1iXkkHbezJ76J44v@HLcUqh?yEjC@5QOU9KQcJ>yvE?5g#)}^ z9P8dsD*^UE?sMvVU>{FVaO&QM4=Kn*bRrw_NeL;?fm3!ar}{YCG7*_v9^Oh1t=ZwnX#{F{wtV^R?hlsNPbpxc3r=;b)Y@JqMC-}c=`xes z!AmJFYt=}H%LsJ1j6cpiUS?_RbQ!fBXQa^iGSRbT5O7KYl-Bqmap!EvLcejhk9e#M zZrL+>c z6;Z*CjbC9H%$?^{0!p$!n`9=cj#ZY9%7TTztM*T^-c z0AU7v-bmgSO_sml5X0~{QsoKLI9>&g1_Xf^{%m$CL~w;2&4iYtZou4WhHzl^_-U61 zY3PgVisFDiTKna_a zT0~enZDNVym(UwHP0a3~2lf0i#NI!y?u7>$GsV_>8e1>%7X6~*rPMu#KgoTs_iZ&% z?VP-y!d3Si)>6Dq1#ZcRx)&D3!^aK8?I2p_m|B0zAGb{H_474tpTxO8*eIX}Y8xy~ zoC~L~>Ey|jbL_SSa+tgCIO`4r23AWNHQ~k5Wc6K;egMK;8LyTmD2S9SjT2skm&Vob zvGD+OblsRkZzBlfYB+0eg`>%f*nRjh@_TT&1`tXX{icKH2-3N*+y#gLidpe=H!Ox;5!ZCKGN4A z9S;bI{LP@M-a<48PObNtc^+jIXXp2XH=;H7#En<7qCQr@87S)wu;1UuZ*_e-DA6&~ zZx7#syatZ%S)U$Q)r&3dr^+2CwfV?XgCmeYz`2W^>I1IBpTJhs`|hQ?iBZ@BDPN{w zBZ1+;PJl8{O#~sR${0NvG5r$u9y^t58LsO{ji(S5y0ixwc+ODWj=`ySMN>^8$!{&k zKbZcZ(}|ta)f2)XWZLJTadYq1EO? z`#dZh){hmT=IC4CRjqPW!U9K5OZ8@Fb#RltJt42@sM@hhOV|S93S`@wj&2+qD44M^6`^+paJAX;^soDEfg7)t;*Fa)eQdS%$8N*$ zU~jfo^fe=F41H~M&ih~rf}M&8crmbD6O>Nj$UEp(kdem_Pw0E*nbpr|^`?Z^4Jb}(=MYlc6M%(d}lul$wL16tyDYOZ|)wCZ=q06ybeXmWQnDTDW zIToShOSuM^hyc)D{R2#hls8vnp8%T_INWA4WDP5b6VQ`Mx!I1q-8JqRh4_Spg0n3e z{YU{!Cxu2IJssL{1kAGnouz#2%n1Jpo0D+2X?8t$F=+_*Ue4 z4WA&P3Qs=wYh}Vp*uI2^zQ8yH>OY6o@nt*(%f6t|Hyydc_96p*1@}(jN3?4q(9C=* z9{uxyDo;KaoPG;%(e?@V>)?|bAPTtAM{#OPg&jl$zYb2hI^*tGk6nv>Ek8Mc4E!Th zjmO=w?(3qWK!Htq3lYt7h{xUlZcQ6d*%7}GAOdn*`8EPpYbU_AA4A#KJ^201Gd0@? z_Gk1eRB)dGt+y0&8w;xmA@7+DMBCONFmE&NX6AuP^#o-CHIU!RYQtisrxr|D3KA02 zG&n?U8U<0oaOHr0#zqL!ij${M4q&xka&^ShGXZE!d77d6+|b0QSYn?fu&A+t>}*k- z_B0kb@p4(?#PPD0DmqI=2NuO090$|njhZ2T~4QJ@)Kwoxw_ zCfI@t>Tl>uha!(n{yyyOA=C{bg^P%2TA8`BxiP*AT-Jjl=uWkGziMxyU)iu;&BQ4@ zRVRh*$vBzJ-L`%L*8W#m)}kHR_{Wax;einT52Y??m$;tZ;aq=s|&0x%NBclXu;QV2mI& zxmq2AXbSNnbLd?ykH&YQk>*EkNALA41XPGF^HnyzLf!hufv4!D%~Mna1iY@#k77lR z6s@@!Vk_1?M(D1V&Olpsb2F=HA`VSlGY$tPu1~Y7>kNdm_2X7$sOmMaAbB>qlwr2> zpVOwIwVIB2N+4P>Jp@k@_@ zQrNiw+CBfrFt8HvzWg5d1hQxgGKC+Uci3i6aVLiW1gHXtNPxtCGknDm7np4XoJptj zIHX?}OBWj7Mj|b)n3L54QDcVGXu#TsmFOz zAP&k2=j4Y+gm1OfYKN2tCn4Af}2i%NQ8%Ah+u!O_BF!Hn)V`&bf zgr{Vj8;JB@3`^&c&LjOtW;!;k6H|gCF;CsVsrwy0N?vgKoVM`9lrPm%UVTTohim(E z;=vD7_F!WgAIpuMW~H3^6^{P4Rjx$b&_1oKndtmHfJjY6S17Cxi9f&pcE4jCK#8s?-o}1Cg{FqlWX{@%vW% z1v{5lonmoL!fWsncAFVKWI|q+;pGwGByG<>w4$Jr$4)2g^lHOlc*23{RjHjqRd`ElYmKh2hL*B?wK6x^j7N~WZo_&C z**)le8fp<_^wwJyFOJyKXqOGPOnZ+h-s6h*EgZ*%!|~w7RJ=Ij%he(TPG^hwlO!f% ztBn{RIGrltV8Ornx#c($MUJEhKcdeJAU<)~h9aD*b?rtRVN~!yqTdmofb<(CP$asP z=#LMV;HN+*c;$+h;pB}pc5c^ONMs&!KOzZ^P;Zv%zm!)Up@=#CNmPdew>HM3#!bI5 zs}dT?uN63(D_$EoJ58J#IGZQl5;!|o*rK4Sz*+AmoU8R+VapHMuT{dsYw+Mt2zO#S zFZQQ|TX82SlTfFy1>YYrta@wkjM{{zKhVtI8J>XOXuTkVTnn4V;E*j$*vlYk*Fbf> zRZlbbbRZcAE|R7$UWSGH;e0f{8xR`FfB~m}b#QS%jYXNu9E;-UIMN9!E7>>-z?q-dSK-Vy>P$R=(1Rkv=C9ar z6$lT9@t`LY?$d}ulKe?a7l-LgE-Fy0x5@R{Ht}lIjIaNINYI#=juWMtevfi;nP&JC zmxdK&r+Wk4lNT?QBgsPJPmv+~1Ehew!_D~7;XMv;Y=~@(p52R}kPz+2x&7CKOdNJ> zp2*6E&OGiiiyiW|Jt!6(Xy`9bx7i+GU3l%a3Op;)iQzR}G-^$(+=0b74)!z{2c77o z%n};k1w8&t>>cY{ml3FcIew#~-}^GA9>%T|1cJ?#bjT9+gg*2Pazdj(Fcoxpdi7P% z+X_wLX;|>eH9z*QsooQ?C+u<-lxg)ilGEWu6yI^l;qYb_lpT{Cx!$bV)PqfVI6#Z= zKwE7nP9Ix3aeUHSHu3iSqdQ2nXTpE}A$WQ)M{N4?*)QmZLFZ2$pkjIl#eGua+8-cH zsa36N?M_u{SG{}Cxc-OyL;0YT))QkD6ZRaF}|FI9)T}s z`P9zWm_347D<-$EZrWYl?me-u-TQyr`xd~cinHy>1zcj3V6k#D41|~jlMpUeNPz4T zHjvNUOah1mH_PtXWXooE-3tNbvN39dh>aFozt&p3fc~wmX+P_&R)Qji7L}^4)FMVi z#iBO$^RIYo{^y-JXZP$Tfe`5D?^jOp?A+dYXXc$bbLMv5^EU7f@Gfu!cn|n1a1?kS z_yG9u^WEmZ6{<)6H|>K?tD^Xvqlx&%dQ7t8hL?h=&|5tQFaHJ4ceJE23fNtg5VyN1 zG4DOnXXn7W!E=fX}b|vzBKsXIM<6}`c6=bY~)I8k&34PVvxA4?zmEu=*1m5_)sP(Q}$fhrSU5 z<`JPiAv)aMn&e1l9SOUydPa`!XkYcHI?~eyUvhvlNn68kY`P4e1Hg#neeH36*s-ZN zY15}q(ETy}SlZKRziWP%9x6$MEmmBdt3M zn@C?(zT<|DCs2CrI>%*SG zB`xa?_5`zAl!I7#IMfrouthlpk*|9PWA(EkFvoM|cUb7?xsD$5J4X#Y=0h}SIEZ_d zs>weV2Okce{hR~e1}N*=SRTKr?C{3&p^lBkNk_*zK6zto52?IGwW0@VevXBDHsEwK z^udY=yXYvBtA9g_B6wyTt(#Sr9I&mUA?ZQIsU_75yv(W?PRe0ct1U33qk2c-^& zp7fhB$B3*jA}^#b9B(hIGi)BxjR_0%ex?UIV--W5LW_fxl;)W{(-O zC-f$d-hL_2exqy(mYCyu>yLmc}IIQPalHU_u|m;n?6HGm!P0oMat zfO~+4fv16ez(L?cfPq&skP7SvzlAWb0^GoQpbfYO_yzDgpbPj6K$p(4fnuNvSOKg8 zt_RwH9|GHfM*!_Yx7G8_yL+H9Bk5y6xo;kDfin9#t z(!9JSl~^|AoE~J%P}fk0i!rZvH7)}va2my6fMLKNIawxivmkTfFN>nEOn1=bl2*97 z@oZ!r>*Fd-Fhe~(3rr>cN}tE3`28MVv0@DbeM+TI@hk2C2re^Mm77baPlGjlDHrGE z<%M0Ca^YIC5N`nhWIwya#D)W8f1%98UIKhUcfi@GaK-2I_&8(dV9%hYw4%CN`jC@V zmy|EiIobS*GE+%;#HZ?8dDCW|la#}QZtDt{!UG=ebUOo1tIK(f!W$H;SFmA3cPY`i zJprz`J;C}0?)O@43U?rFm#4|8i)alvJ?==nZ}l6`AFv-M-X#>z3(@gaPG2Bsb#X_~ zZ6n^?W_7tl0+g>A{qnbX+{$WaV2U+B1`kjX!}*#zi{eGf?eQvL>~Z@&kb_-W<+SN& zRT(L(y^1ZM*o9;wQe-5bsX{(Mq^Qy~23-MXpuwkD?U0adWh{OFa#17MtpO{tdrp#d zh1=t6gaEugPrc9D$ODS6(dmwsbDk(qpY@}-AwiG35$zBBkk>p>o<3=RjQo`qohM z*1XKrW+x;i;Vz*9<)its+}vC?TPva4ik2O8uXKBw+;bUQpae>-m_?xaS1FYqZ_q3J zq>GTd&~dS#vmYZXDi;+sA#*Y0vLHZ|??a#J~(CFNMP6y|(kRtx`0=%ci2 zH}x%etoL<&9s9_enHeo#?Tgs&<7?E0gYHOlPmB$VgKUd}J|F5_^L!$1A@2NQpQ14K zu&|q4Xu<5a!d|6F*K1TOMV`h+tJ_}cbSoxy3-Ma4`24s>@x=>rQLTx}W-OHzxjcSl zA;?_{`$2rQ5|H*H4;l*QKtx|1u&V?tlibBlmr}FFt1yQQwW25Rmbe`rydx`eGhgus ze4aJz5#cJr-4;NuKaO84`wUTtZp|e#&bCn6#JQ3hv*KfHWWo}kGoX+ktEQAl6ehbJ zowgqfUF1{du?Jmh?$OVmm9WHVSBe^}z8X&%-RbkzAmRAM&8uySm-5+F?Tl1kOm{j0Da|;EV+NmcY@`CYI~P<5j)d#zgFzUs9Ul zwmThs%4DAIw>0p{Qq16=fz=5*U!LA$~y zru!$tLr0a{K;d@9fg!5MtfY6i;T3kDE< zJPA;KAA|WY(2Y39fOgoo0+iprWJh_WI-s&p9`68c8_)`bfYm?%@B$5h9jF6pfl6RL zK>49`u}?=!O}MZ&g)8EY6K?iTY4q_+n|&v~nwz6&?z)c7ft}2SWB&Rpl%ly*3)kGz z3`ILRZGp&3l+(EIR$0(A&AXR*Z%m542!ux*BoF zde|qQpr@xL-dLhow_3j`Sn?K^<~}#Zt%a-J;ri3)wQ$XS{P^*LOyvc`7`BRlx`ioP z{BS^wg^uA4@B-=I@FytM>sgva$!u# zW5acBD5<&7Fq%9@vGL=vi;yzv!cqF@ToS8>bm)G+p|g|qB;6^g*w=_*@h^2EvGL*` zdg2x|T33tVov=II(w>d<=K!_WGDbr{%1%jn4J$z%$YEr7d_yz|&fA|U-H3P0qX zvY^S!SBrG2%&WZ+8#8+xti-(v+f;VZ+&StPgL%f$#&UCO8)~sBMq_g7OvU5`ark6j zT~SqJt}<6~b&(oTlE{DRtXb1?@H2zP$LM4#n#~VxIFc1viTx6wk5Fa9azIX4qoPTyA{7DU=_T>Y0g(xDK1Pg?0m%<#KwX< zw$CV~Y;Lk*dxlqAo9qg>UBnk)yMz~Gw`(Ob#3xHWynXM3b%+*L# zx;c$DCCatY{3|lo3HxKlgSi?&^E_S~$(KdmfYo|GEtbV=bz{<(P8+FW#w9&u+PKST zPUrSmRyk>F&ti22KpN$yyr^`IPQM>3?3N~{%Wkv!>>!QxisFmFMr**tXAKE>r+ zF$GgW(Uiloo$Xfw-){8gHq4dz(B{Ci#lEWW4%1E)Q&^j$o@Sn?18>e;nw8Uxn`Y6n zA5PNGoB3of0&!V#7c^23F_#AHWiHr?HTcBkC zDhc`et*aD^I`Kvui}hmQ;KA-SC<8LSjwK~Rp2I8)7MZK7Eut@n#~fW66s}F|Wn!SO zsWO`_MHS`MHC2|%nyP9L4a1FQs;)tf(Nj<{=4jkOFT>_pQK@}}Uz?HP}wJuHY+t)MhE2=c# z$D10kJc7!aV6kJDoztQZE>(Q(3jy_PoT zMPcUTp(yNHOSNgSxq$c4O!eh)dqh$E0jn>-@r$(STnDvcSu|bQ#r>$G)bkNxnlLC1 z3Kx+U9F%`cRmp;dH3iJlxYCA3WY4_F;>*6s;s=y$t&OPdDW=UJuG*f!N2>&NAcsQ- zZpexUu(SyA+gU{DbkM;X;474RJejF|;2|9)c4s{fSSWVLRySL<7q}0rDmkDC(fv6Sh=|q54PC96wLe(NhR&(%V*4*d-GP9(I zE__k>d~ptU-Z z;{!S9$>x)_5l!?sPVJ`X2BR?DD{#oqAs%xyXabEkPr%SIoyMkObgn+gF`}Y}NE00r!XZf--HWDmErUMK+8b zfM5GL^7ZXpxTj8^K5ZJzEG%*w?-ct^;-N^#y69<-GgS0k6elD>MzR+Dn_6z__XJ&o z)!(2|$uUX(amR~9PXk7)-5%-8;1F^{I`xWfd>~TiIM*})F?9WO_TVRYQ|-&n8b!%S_hSJjI-PJQFIzj&L%?cB z)E{jhxzhMLJoN0exSZ~l=+OEiq<)^nqXknw{gFo{j%#ziHi>?5wvev59x|`uoXm8; z@Id)I1UO*m#^aC&ZfnsrJmSC{#)~+X>c;vGMuVtk+^2R0y%7%9Lhe{}2zqgAgNGQy zPsUgpV|gqyMf0S-LNJ8^K7zJ?RxE(iigI#kp`*q~2&+JAB8`dKifCUPb9TBq_`M+>;;OeL|vemG=RJV7zkOW(zY=qas6U~7ItShP05z}kxFSNOJ4#H~Cvi!JRv4BJmh(-vj0R4;AK1F+ka2%h& zDM+k9YfYS z$L_?F1~S9EpW@JY3OSGnKkdRN>1pu60}U92$kPrvf;dMw@Wz6}xmvKOcX?KT)f$|{ z_dDr50rUeaJT5;2JrU9K6_Z&I$g!DU+!ESxeK1Ees>cM^EqYQEG{@;iPoS_$Ja%yI zf^y1NV7*h^jN(kL8}}z2fR8j)A)oqSfJ{m+1521C8QDDJvMT%{g^U%RKtl#1tU(U7 z#JODcr!>h6=6o^7Lv1)R?DARe=S@?BZs*lOs?UH@ulRT-RV!pel7L`yAm<#>6Z)la zkcWZsp@Zh8HZ<>gjC&&bK(nWFXL1Pry;EG%RA@qUM5b2^;JfEd*< ztsjsy+EXJ+He4=?h_#KVf{Vscpe0Ic7_>sQ#uG$JXaJNgu_7vB1{yF~*GWl8yigZA zDoqheFK#$+JSc#wq=gl=eH}jzJ=6Njur6jyUgfw!CL?ny?}4Zcs`o`~wxVRBOG1?g zz3spo01P?mwU!}jE4oc%sTg}NK|HDIIo$+!#-im@n?bMRBy%Nt0NLKvDn%n&i7o@r z4ZMYfkrSFWWkz;P;pLBk)Jvp?(3M!%Zy=2UiIqi~T^6laQnVF#=Y!V3dp97Ru=MeC zt(e*nYM*+_*p>@f$o^))_0bQ#u2DuZR1{fl4R^JoMT;9PLMOWq8A65CYS<2vKy1!v z)gO0!8X}?Vq1&CI?&N}ZBqq0`%R*xze`*Y3%7WHGuRFnw0SiX)-N}qc!O;g@>kBWJqU8|4@5-F=)vd3YX<0XG0F~D@z#|#YhYfFSLcnw%h?1A^y5#%Z;P0?=x0H6 z|Il`gTy3O0^+ShY5~m>C543`-r?UnEN+W84W?UYQB;YF2@0B7 zvuhE5KF0l}5LAVu(&}rZ7gn?x03zYE0EJh$?A7#GCyMCM$T~2n5f>$&qV6W4Zx15N za&{y6(7DsdXq#47XncW+KtANqMNANJt3^h$v>xt+3?RoU#j)7xt5R%Y{Xivg+G(NK zuGn1poT_yVZZjKXtoIjVY3Ut)j;hYETb~;&U*l{j25;0p&VIo^$0iraj8R-$Teny;ezz^QD;pG zU+0e>l0Iy7dRo6%BBD)7KWE~&bCbU@@$88c&%1Eq#1RuG4j-8^QC#2TV1eg@STzJBchH^Olej7SVSbe405z>z#G zX*l_vdsg@&XWWRCq5WQlv*Sk$9no*_P-5_vUuW(GIX;Ly0RDZS3*)sbE`I#@1kDjK z zr;U@8`}ot$kFyEt-^8#jQp0ITjlwk_NvpYH%}K2HUo;JcYd(@zbDc5u5=akAN$>mb zZtvZ?BCScvW)iz7EV(o7>vXo447@uO`xnihLNy;rskzRW|2rixfn|oD8QN1Mx}*bt zc4+bS=IP*-rRH$3yrScsnrk5aSENV#pX9BjTMuPLX6m%en;o_7jm zoEnuUeXX5*Jx)7qyn2^0(#i){j}zE*UG7e;9%XIP?+oB{@j5lxNAe_Xm;4Xs>ryt8 z&0_g@AAL4bW-+M`%snR@i|FTu|DyQ~jK7hY*gRIm<}>r4^HUs^p9M_&i_Xu$_?NK% zV3)B{R>sN)ou7)R{8U1xv;2$B&%pRsv1(Ss7O}9nsh&~?KuZrQF;CP*mib5djORGhy7Ij`&robAp1G{1$!v$ zmK5#mm+V*Yi(jvH5y9h8_ShhKJ3+hJWeitEWfXtJ62AbgdS(V=_QrEdE_tpNQsX9O-s~`Cdu@b zs5+3G^zzr_u9^C@V(GLRiuV7bC}Uso53xUerRCSk^6FQVi)cATBqaU!hiiuN841;L zE&ZZ-$S~>m=M%<{aQbR&(RnAAKL3xi*VGb_ZzMF5*AvD6%PGcxoE-?KJDBtzXRi+^ z{y{aLvE|pwccSvYaSHLf!f_)d)Y8?=j8{x71ndPy{Sn^)0NQ~s zfQ5g;_ZxsNAp2E(F96sDr0j>D3E%02 zUATc(pc610fg5NAIswCba09JCCt&z1+(0YP2^fyT4YUHCfZ=_(fmWasFnj2Be;Q9pc63s9d4i%&`w6v+2{*!Hkv+_Fp6<} z15loWrc=;kaSA#WXP`&3F>D-^h$r9_^)PXYIti5Y_YH(!2#go5RNe3S!hSY>lfioe zo5<4e2mOKgodokDmVq-sq`q@9e(BBji&-|y!5?&E_)ea)+w1v{G+*x$rE^4KX{0(UL; zU(MJxrJc{^tO~o8i?QQ)IrjdpU`w(8w}35VP~E`lu!CpE9-fU^0qFf;4*b;v_$H#* zllwMo&_9GfxeIo!x(D`cwi0`6@}f|Bn>yms?9lk63-PFQZUkQ~?2XuIld&Vew9iIY zdjNWNf=1Q`v;$p0$|@tP1KNNNfHy&x4$uzl1G<5f)kc;FR03Y04QL1U0o_2#8iWIt zfEQ>3+JSvQH;{4-!huS{TBHNB3ou@bv;p!9!E6UoV9x`{&kJk?*gE73AU`8aFVF^b zsD52AQ`XDyJeYN=Jp{8I*axr;GMuYs8_c{A;x&UOPzQK#06owJ@EhR=gn%v}Q+z*b-%khc+jKpW5jgl<9@K>6>0*$t#@0zZKK>R`61_I8;20CqF@ z0ChkJXa~9gwi*6FCEx|xfOcRX&<&*Af^eV`U}*h?XqT6xg<8-O8_`B?XFq25A|&xi z+~dE+bMPtjr91H4>_Gpx6VKVFO^iQdVv}~EAAJ_jvEAsKpTl#nQ|exdL)`8yNaJ>6 z2N|33YBCP<)n16tLEg2^oKjE--^*FK?v0V)QdoTwMIj0H7D z4!ocrRy$DuEg4WwNBU?r{RI7!u!!nw(w%J&YXnz$Lw$lDUmYc752PI}qWA(ujiQG# zv#=&9Rmn?QMEeeCg{BaSBfp!4qOvrhk%{~oq3%Aw(nv)HeS^X4v(`6S;qPFii$Lf& zkV;ZXM5Gr%)%XZqBdQKjq7!OVqrx*qe9}ad3IEEXqMB+8w2|fKYhKVDNgT4!Uoz3x zYIWXcn;<1NQZOv6i5Kz0`VwF-Q57{?gZStJKKvk6aX|rfx}77KbdR{98~v%{*Ugc2&*#*#os?LHnz1PlOu zEQkX}AO!rY2`GJNk+TT>A4O8Z4pd603Lg~|lQbofaw#+?q484ELjq7X&6_+vyFW|l z1tD!U`j|nxf_sn@S5F{$sQMx`T|Z%l6pPvl(THz1 zpaMzf2uJHm_b*HLqcK1=DB}~UK5_GrYOpE=T9=@TMe0{W0T!q#Zo(QGxk;;Yd`E7X z*-K4Ij1BtdQA4_URYvlgbWr#&6zha_oQSWZlgdx%rokQN6x~zCx(x7!+vAdeXe^Xd zDzc_c3A*=4wH_4Gq3F=>F6yZtuJmmJT^`ZWq^zNHSJ$DUywFBOntY&?MN^Uq-qb}= z-wcx#2(|X49t&=@@+p1Ly92lj<<}sf`ixZE!{1y{%)<4mwYvexh?FupZS=kSSUt7K zywE15-Oo*ms%lFU4C`22Oj#0U9CaYtrGDv5bCOAYo1R1;riByDnd^)MPF4cJJMb(5 zu1>{#QiYz!6N&Q}0e4TYKbrT+zusZJeHP-me7wKwS?|AS`eqjSi(>=(({s2Erx&%q zc-&P3`P1Tay-@y5?bHY50{Xt_{jqZHk=Km52|&8B=|i#9jU7wC7|~_w6PgHzpbI=( zbzBHLjp69}zRtcGb{f~wb&JmaU7fv6XTMcvzfEWVp3aV}v9kag3*8LxA>SJfBYaVR zI_i4N!(hJOV#0a}BEuy5J7H4!yf8<=G{QU&<~W$&fZ2T==4&t?gGo%=V2*)#1CZJT6Ga^t`T zAP(OPhQaOwP2F{CuA4v(T-)D}=H1(*+5D3(s#0cL9}?yRpx=4#Yxi;)-0QdbpVG^y zn!g?(y-B5i1oSW7bNHSy?CpDw+_S8I{_F1+F)l{~y8N}PUgOO2+P7bu)|>w2{Rg`~ zg?{_>TFz9Gt?@?HhK4&NV*kt#wj1wE4%;iA86LJz`uIG}9{TT$C|u z^C#Y}wey~Q{g#8D{`m8w>wkKA(cSN?dTa0Bv!-0%e9`>OlnZ`(>=!9-J-h3(`A6@6 z<-b2U`sROJbNh>CW$$yhp1b`QTSvcjZ}B=>1$A0xe zb=m!IFQ4=5@`6ow-F9Wq^6lMs^NyNrH(zS~!>lch&@Zhuee^_YT{)p4{(2(C=dgIZ;>2sc(cg@>>+_K|O z?-oA&<(Ds5uOHF0_h*L-r<5*xvuxK>TW)`6PvLF5stbbipC9?u4<9N#SpUS9S>~Uo z{_@2wg_F{DAA0hMf~nR`*A!Y8E#0~Pm(^>}`;DdW)eom^9{SX6H=O_Z{K83v+uobC zE#t2n9++IX?!mhcKWSfEyzlizb8XiS-J4d^)Y5Zn^PF2h%O8D>Exl-J$AhycZ2ZH_ z>lXarG4|!F1qWKMFpT}>k+*K#o=~v+dh@)q9{JDUrGLrIpMLeYm(u<+?Zc9`D`##0 z&Ql#rUfXuv_IrLk?NGz7M%-WZlle;@P03C#Ih^yY85PyPcwuGwcb6vK*KzRab)O&E zoqE^1tyeC&b@q E52#`Rg#Z8m literal 0 HcmV?d00001 diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp new file mode 100644 index 0000000000..13b91e5f57 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.cpp @@ -0,0 +1,815 @@ +/* ANTLRParser.C + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#include "pcctscfg.h" + +#include "pccts_stdlib.h" +#include "pccts_stdarg.h" +#include "pccts_string.h" +#include "pccts_stdio.h" + +PCCTS_NAMESPACE_STD + +/* I have to put this here due to C++ limitation + * that you can't have a 'forward' decl for enums. + * I hate C++!!!!!!!!!!!!!!! + * Of course, if I could use real templates, this would go away. + */ +// MR1 +// MR1 10-Apr-97 133MR1 Prevent use of varying sizes for the +// MR1 ANTLRTokenType enum +// MR1 + +enum ANTLRTokenType { TER_HATES_CPP=0, ITS_TOO_COMPLICATED=9999}; // MR1 + +#define ANTLR_SUPPORT_CODE + +#include ATOKEN_H +#include ATOKENBUFFER_H +#include APARSER_H + +static const int zzINF_DEF_TOKEN_BUFFER_SIZE = 2000; /* MR14 */ +static const int zzINF_BUFFER_TOKEN_CHUNK_SIZE = 1000; /* MR14 */ + + /* L o o k a h e a d M a c r o s */ + +/* maximum of 32 bits/unsigned int and must be 8 bits/byte; + * we only use 8 bits of it. + */ +SetWordType ANTLRParser::bitmask[sizeof(SetWordType)*8] = { + 0x00000001, 0x00000002, 0x00000004, 0x00000008, + 0x00000010, 0x00000020, 0x00000040, 0x00000080 +}; + +char ANTLRParser::eMsgBuffer[500] = ""; + +ANTLRParser:: +~ANTLRParser() +{ + delete [] token_type; + delete [] zzFAILtext; // MR16 Manfred Kogler +} + +ANTLRParser:: +ANTLRParser(ANTLRTokenBuffer *_inputTokens, + int k, + int use_inf_look, + int dlook, + int ssize) +{ + LLk = k; + can_use_inf_look = use_inf_look; +/* MR14 */ if (dlook != 0) { +/* MR14 */ panic("ANTLRParser::ANTLRParser - Demand lookahead not supported in C++ mode"); +/* MR14 */ +/* MR14 */ }; + demand_look = 0; /* demand_look = dlook; */ + bsetsize = ssize; + guessing = 0; + token_tbl = NULL; + eofToken = (ANTLRTokenType)1; + + // allocate lookahead buffer + token_type = new ANTLRTokenType[LLk]; + lap = 0; + labase = 0; +#ifdef ZZDEFER_FETCH + stillToFetch = 0; // MR19 +#endif + dirty = 0; + inf_labase = 0; // MR7 + inf_last = 0; // MR7 + /* prime lookahead buffer, point to inputTokens */ + this->inputTokens = _inputTokens; + this->inputTokens->setMinTokens(k); + _inputTokens->setParser(this); // MR1 + resynchConsumed=1; // MR8 + zzFAILtext=NULL; // MR9 + traceOptionValueDefault=0; // MR10 + traceReset(); // MR10 + zzGuessSeq=0; // MR10 + syntaxErrCount=0; // MR11 +} + +void ANTLRParser::init() +{ + prime_lookahead(); + resynchConsumed=1; // MR8 + traceReset(); // MR10 +} + +void ANTLRParser::traceReset() +{ + traceOptionValue=traceOptionValueDefault; + traceGuessOptionValue=1; + traceCurrentRuleName=NULL; + traceDepth=0; +} + +int ANTLRParser:: +guess(ANTLRParserState *st) +{ + saveState(st); + guessing = 1; + return setjmp(guess_start.state); +} + +void ANTLRParser:: +saveState(ANTLRParserState *buf) +{ + buf->guess_start = guess_start; + buf->guessing = guessing; + buf->inf_labase = inf_labase; + buf->inf_last = inf_last; + buf->dirty = dirty; + buf->traceOptionValue=traceOptionValue; /* MR10 */ + buf->traceGuessOptionValue=traceGuessOptionValue; /* MR10 */ + buf->traceCurrentRuleName=traceCurrentRuleName; /* MR10 */ + buf->traceDepth=traceDepth; /* MR10 */ +} + +void ANTLRParser:: +restoreState(ANTLRParserState *buf) +{ + int i; + int prevTraceOptionValue; + + guess_start = buf->guess_start; + guessing = buf->guessing; + inf_labase = buf->inf_labase; + inf_last = buf->inf_last; + dirty = buf->dirty; + + // restore lookahead buffer from k tokens before restored TokenBuffer position + // if demand_look, then I guess we don't look backwards for these tokens. + for (i=1; i<=LLk; i++) token_type[i-1] = + inputTokens->bufferedToken(i-LLk)->getType(); + lap = 0; + labase = 0; + + /* MR10 */ + + prevTraceOptionValue=traceOptionValue; + traceOptionValue=buf->traceOptionValue; + if ( (prevTraceOptionValue > 0) != + (traceOptionValue > 0)) { + if (traceCurrentRuleName != NULL) { /* MR21 */ + if (traceOptionValue > 0) { + fprintf(stderr, + "trace enable restored in rule %s depth %d\n", + traceCurrentRuleName, + traceDepth); + }; + if (traceOptionValue <= 0) { + fprintf(stderr, + "trace disable restored in rule %s depth %d\n", + traceCurrentRuleName, /* MR21 */ + traceDepth); + }; + } + }; + traceGuessOptionValue=buf->traceGuessOptionValue; + traceCurrentRuleName=buf->traceCurrentRuleName; + traceDepth=buf->traceDepth; + traceGuessDone(buf); +} + +/* Get the next symbol from the input stream; put it into lookahead buffer; + * fill token_type[] fast reference cache also. NLA is the next place where + * a lookahead ANTLRAbstractToken should go. + */ +void ANTLRParser:: +consume() +{ + +#ifdef ZZDEBUG_CONSUME_ACTION + zzdebug_consume_action(); +#endif + +// MR19 V.H. Simonis +// Defer Fetch feature +// Moves action of consume() into LA() function + +#ifdef ZZDEFER_FETCH + stillToFetch++; +#else + NLA = inputTokens->getToken()->getType(); + dirty--; + lap = (lap+1)&(LLk-1); +#endif + +} + +_ANTLRTokenPtr ANTLRParser:: +LT(int i) +{ + +// MR19 V.H. Simonis +// Defer Fetch feature +// Moves action of consume() into LA() function + +#ifdef ZZDEFER_FETCH + undeferFetch(); +#endif + +#ifdef DEBUG_TOKENBUFFER + if ( i >= inputTokens->bufferSize() || inputTokens->minTokens() < LLk ) /* MR20 Was "<=" */ + { + char buf[2000]; /* MR20 Was "static" */ + sprintf(buf, "The minimum number of tokens you requested that the\nANTLRTokenBuffer buffer is not enough to satisfy your\nLT(%d) request; increase 'k' argument to constructor for ANTLRTokenBuffer\n", i); + panic(buf); + } +#endif + return inputTokens->bufferedToken(i-LLk); +} + +void +ANTLRParser:: +look(int k) +{ + int i, c = k - (LLk-dirty); + for (i=1; i<=c; i++) consume(); +} + +/* fill the lookahead buffer up with k symbols (even if DEMAND_LOOK); + */ +void +ANTLRParser:: +prime_lookahead() +{ + int i; + for(i=1;i<=LLk; i++) consume(); + dirty=0; + // lap = 0; // MR14 Sinan Karasu (sinan.karasu@boeing.com) + // labase = 0; // MR14 + labase=lap; // MR14 +} + +/* check to see if the current input symbol matches '_t'. + * During NON demand lookahead mode, dirty will always be 0 and + * hence the extra code for consuming tokens in _match is never + * executed; the same routine can be used for both modes. + */ +int ANTLRParser:: +_match(ANTLRTokenType _t, ANTLRChar **MissText, + ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok, + SetWordType **MissSet) +{ + if ( dirty==LLk ) { + consume(); + } + if ( LA(1)!=_t ) { + *MissText=NULL; + *MissTok= _t; *BadTok = LT(1); + *MissSet=NULL; + return 0; + } + dirty++; + labase = (labase+1)&(LLk-1); // labase maintained even if !demand look + return 1; +} + +/* check to see if the current input symbol matches '_t'. + * Used during exception handling. + */ +int ANTLRParser:: +_match_wsig(ANTLRTokenType _t) +{ + if ( dirty==LLk ) { + consume(); + } + if ( LA(1)!=_t ) return 0; + dirty++; + labase = (labase+1)&(LLk-1); // labase maintained even if !demand look + return 1; +} + +/* check to see if the current input symbol matches any token in a set. + * During NON demand lookahead mode, dirty will always be 0 and + * hence the extra code for consuming tokens in _match is never + * executed; the same routine can be used for both modes. + */ +int ANTLRParser:: +_setmatch(SetWordType *tset, ANTLRChar **MissText, + ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok, + SetWordType **MissSet) +{ + if ( dirty==LLk ) { + consume(); + } + if ( !set_el(LA(1), tset) ) { + *MissText=NULL; + *MissTok= (ANTLRTokenType)0; *BadTok=LT(1); + *MissSet=tset; + return 0; + } + dirty++; + labase = (labase+1)&(LLk-1); // labase maintained even if !demand look + return 1; +} + +int ANTLRParser:: +_setmatch_wsig(SetWordType *tset) +{ + if ( dirty==LLk ) { + consume(); + } + if ( !set_el(LA(1), tset) ) return 0; + dirty++; + labase = (labase+1)&(LLk-1); // labase maintained even if !demand look + return 1; +} + + /* Exception handling routines */ +// +// 7-Apr-97 133MR1 +// Change suggested by Eli Sternheim (eli@interhdl.com) +// +void ANTLRParser:: +consumeUntil(SetWordType *st) +{ + ANTLRTokenType tmp; // MR1 + const int Eof=1; // MR1 + while ( !set_el( (tmp=LA(1)), st) && tmp!=Eof) { consume(); } // MR1 +} + +// +// 7-Apr-97 133MR1 +// Change suggested by Eli Sternheim (eli@interhdl.com) +// +void ANTLRParser:: +consumeUntilToken(int t) +{ + int tmp; // MR1 + const int Eof=1; // MR1 + while ( (tmp=LA(1)) !=t && tmp!=Eof) { consume(); } // MR1 +} + + + /* Old error stuff */ + +void ANTLRParser:: +resynch(SetWordType *wd,SetWordType mask) +{ + +/* MR8 S.Bochnak@microtool.com.pl */ +/* MR8 Change file scope static "consumed" to instance var */ + + /* if you enter here without having consumed a token from last resynch + * force a token consumption. + */ +/* MR8 */ if ( !resynchConsumed ) {consume(); resynchConsumed=1; return;} + + /* if current token is in resynch set, we've got what we wanted */ + +/* MR8 */ if ( wd[LA(1)]&mask || LA(1) == eofToken ) {resynchConsumed=0; return;} + + /* scan until we find something in the resynch set */ + + while ( !(wd[LA(1)]&mask) && LA(1) != eofToken ) {consume();} + +/* MR8 */ resynchConsumed=1; +} + +/* standard error reporting function that assumes DLG-based scanners; + * you should redefine in subclass to change it or if you use your + * own scanner. + */ +void ANTLRParser:: +syn(_ANTLRTokenPtr tok, ANTLRChar *egroup, SetWordType *eset, + ANTLRTokenType etok, int k) +{ + int line; + + line = LT(1)->getLine(); + + syntaxErrCount++; /* MR11 */ + fprintf(stderr, "line %d: syntax error at \"%s\"", + line, + (LA(1)==eofToken && LT(1)->getText()[0] == '@')? + "":LT(1)->getText() /* MR21a */); + if ( !etok && !eset ) {fprintf(stderr, "\n"); return;} + if ( k==1 ) fprintf(stderr, " missing"); + else + { + fprintf(stderr, "; \"%s\" not", LT(1)->getText()); + if ( set_deg(eset)>1 ) fprintf(stderr, " in"); + } + if ( set_deg(eset)>0 ) edecode(eset); + else fprintf(stderr, " %s", token_tbl[etok]); + if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup); + fprintf(stderr, "\n"); +} + +/* is b an element of set p? */ +int ANTLRParser:: +set_el(ANTLRTokenType b, SetWordType *p) +{ + return( p[DIVWORD(b)] & bitmask[MODWORD(b)] ); +} + +int ANTLRParser:: +set_deg(SetWordType *a) +{ + /* Fast compute degree of a set... the number + of elements present in the set. Assumes + that all word bits are used in the set + */ + register SetWordType *p = a; + register SetWordType *endp = &(a[bsetsize]); + register int degree = 0; + + if ( a == NULL ) return 0; + while ( p < endp ) + { + register SetWordType t = *p; + register SetWordType *b = &(bitmask[0]); + do { + if (t & *b) ++degree; + } while (++b < &(bitmask[sizeof(SetWordType)*8])); + p++; + } + + return(degree); +} + +void ANTLRParser:: +edecode(SetWordType *a) +{ + register SetWordType *p = a; + register SetWordType *endp = &(p[bsetsize]); + register unsigned e = 0; + + if ( set_deg(a)>1 ) fprintf(stderr, " {"); + do { + register SetWordType t = *p; + register SetWordType *b = &(bitmask[0]); + do { + if ( t & *b ) fprintf(stderr, " %s", token_tbl[e]); + e++; + } while (++b < &(bitmask[sizeof(SetWordType)*8])); + } while (++p < endp); + if ( set_deg(a)>1 ) fprintf(stderr, " }"); +} + +/* input looks like: + * zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk) + * where the zzMiss stuff is set here to the token that did not match + * (and which set wasn't it a member of). + */ + +// MR9 29-Sep-97 Stan Bochnak (S.Bochnak@microTool.com.pl) +// MR9 Original fix to static allocated text didn't +// MR9 work because a pointer to it was passed back +// MR9 to caller. Replace with instance variable. + +const int SETWORDCOUNT=20; + +void +ANTLRParser::FAIL(int k, ...) +{ +// +// MR1 10-Apr-97 +// + + if (zzFAILtext == NULL) zzFAILtext=new char [1000]; // MR9 + SetWordType **f=new SetWordType *[SETWORDCOUNT]; // MR1 // MR9 + SetWordType **miss_set; + ANTLRChar **miss_text; + _ANTLRTokenPtr *bad_tok; + ANTLRChar **bad_text; +// +// 7-Apr-97 133MR1 +// err_k is passed as a "int *", not "unsigned *" +// + int *err_k; // MR1 + int i; + va_list ap; + + va_start(ap, k); + + zzFAILtext[0] = '\0'; + if ( k > SETWORDCOUNT ) panic("FAIL: overflowed buffer"); + for (i=1; i<=k; i++) /* collect all lookahead sets */ + { + f[i-1] = va_arg(ap, SetWordType *); + } + for (i=1; i<=k; i++) /* look for offending token */ + { + if ( i>1 ) strcat(zzFAILtext, " "); + strcat(zzFAILtext, LT(i)->getText()); + if ( !set_el(LA(i), f[i-1]) ) break; + } + miss_set = va_arg(ap, SetWordType **); + miss_text = va_arg(ap, ANTLRChar **); + bad_tok = va_arg(ap, _ANTLRTokenPtr *); + bad_text = va_arg(ap, ANTLRChar **); + err_k = va_arg(ap, int *); // MR1 + if ( i>k ) + { + /* bad; lookahead is permutation that cannot be matched, + * but, the ith token of lookahead is valid at the ith position + * (The old LL sub 1 (k) versus LL(k) parsing technique) + */ + *miss_set = NULL; + *miss_text = LT(1)->getText(); + *bad_tok = LT(1); + *bad_text = (*bad_tok)->getText(); + *err_k = k; +// +// MR4 20-May-97 erroneously deleted contents of f[] +// MR4 reported by Bruce Guenter (bruceg@qcc.sk.ca) +// MR1 10-Apr-97 release temporary storage +// + delete [] f; // MR1 + return; // MR1 + } +/* fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/ + *miss_set = f[i-1]; + *miss_text = zzFAILtext; + *bad_tok = LT(i); + *bad_text = (*bad_tok)->getText(); + if ( i==1 ) *err_k = 1; + else *err_k = k; +// +// MR4 20-May-97 erroneously deleted contents of f[] +// MR4 reported by Bruce Guenter (bruceg@qcc.sk.ca) +// MR1 10-Apr-97 release temporary storage +// + delete [] f; // MR1 + return; // MR1 +} + +int ANTLRParser:: +_match_wdfltsig(ANTLRTokenType tokenWanted, SetWordType *whatFollows) +{ + if ( dirty==LLk ) consume(); + + if ( LA(1)!=tokenWanted ) + { + syntaxErrCount++; /* MR11 */ + fprintf(stderr, + "line %d: syntax error at \"%s\" missing %s\n", + LT(1)->getLine(), + (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"":LT(1)->getText(), /* MR21a */ + token_tbl[tokenWanted]); + consumeUntil( whatFollows ); + return 0; + } + else { + dirty++; + labase = (labase+1)&(LLk-1); // labase maintained even if !demand look +/* if ( !demand_look ) consume(); */ + return 1; + } +} + + +int ANTLRParser:: +_setmatch_wdfltsig(SetWordType *tokensWanted, + ANTLRTokenType tokenTypeOfSet, + SetWordType *whatFollows) +{ + if ( dirty==LLk ) consume(); + if ( !set_el(LA(1), tokensWanted) ) + { + syntaxErrCount++; /* MR11 */ + fprintf(stderr, + "line %d: syntax error at \"%s\" missing %s\n", + LT(1)->getLine(), + (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"":LT(1)->getText(), /* MR21a */ + token_tbl[tokenTypeOfSet]); + consumeUntil( whatFollows ); + return 0; + } + else { + dirty++; + labase = (labase+1)&(LLk-1); // labase maintained even if !demand look +/* if ( !demand_look ) consume(); */ + return 1; + } +} + +char *ANTLRParser:: +eMsgd(char *err,int d) +{ + sprintf(eMsgBuffer, err, d); // dangerous, but I don't care + return eMsgBuffer; +} + +char *ANTLRParser:: +eMsg(char *err, char *s) +{ + sprintf(eMsgBuffer, err, s); + return eMsgBuffer; +} + +char *ANTLRParser:: +eMsg2(char *err,char *s, char *t) +{ + sprintf(eMsgBuffer, err, s, t); + return eMsgBuffer; +} + +void ANTLRParser:: +panic(const char *msg) // MR20 const +{ + fprintf(stderr, "ANTLR panic: %s\n", msg); + exit(PCCTS_EXIT_FAILURE); // MR1 +} + +const ANTLRChar *ANTLRParser:: // MR1 +parserTokenName(int tok) { // MR1 + return token_tbl[tok]; // MR1 +} // MR1 + +void ANTLRParser::traceGuessDone(const ANTLRParserState *state) { + + int doIt=0; + + if (traceCurrentRuleName == NULL) return; + + if (traceOptionValue <= 0) { + doIt=0; + } else if (traceGuessOptionValue <= 0) { + doIt=0; + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d", + state->traceCurrentRuleName, + LT(1)->getType() == eofToken ? "@" : LT(1)->getText(), + state->traceDepth); + if (state->guessing != 0) { + fprintf(stderr," (guess mode continues - an enclosing guess is still active)"); + } else { + fprintf(stderr," (guess mode ends)"); + }; + fprintf(stderr,"\n"); + }; +} + +void ANTLRParser::traceGuessFail() { + + int doIt=0; + + if (traceCurrentRuleName == NULL) return; /* MR21 */ + + if (traceOptionValue <= 0) { + doIt=0; + } else if (guessing && traceGuessOptionValue <= 0) { + doIt=0; + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"guess failed\n"); + }; +} + +/* traceOption: + zero value turns off trace +*/ + +void ANTLRParser::tracein(const ANTLRChar * rule) { + + int doIt=0; + + traceDepth++; + traceCurrentRuleName=rule; + + if (traceOptionValue <= 0) { + doIt=0; + } else if (guessing && traceGuessOptionValue <= 0) { + doIt=0; + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"enter rule %s {\"%s\"} depth %d", + rule, + LT(1)->getType() == eofToken ? "@" : LT(1)->getText(), + traceDepth); + if (guessing) fprintf(stderr," guessing"); + fprintf(stderr,"\n"); + }; + return; +} + +void ANTLRParser::traceout(const ANTLRChar * rule) { + + int doIt=0; + + traceDepth--; + + if (traceOptionValue <= 0) { + doIt=0; + } else if (guessing && traceGuessOptionValue <= 0) { + doIt=0; + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"exit rule %s {\"%s\"} depth %d", + rule, + LT(1)->getType() == eofToken ? "@" : LT(1)->getText(), + traceDepth+1); + if (guessing) fprintf(stderr," guessing"); + fprintf(stderr,"\n"); + }; +} + +int ANTLRParser::traceOption(int delta) { + + int prevValue=traceOptionValue; + + traceOptionValue=traceOptionValue+delta; + + if (traceCurrentRuleName != NULL) { + if (prevValue <= 0 && traceOptionValue > 0) { + fprintf(stderr,"trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth); + }; + if (prevValue > 0 && traceOptionValue <= 0) { + fprintf(stderr,"trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth); + }; + }; + + return prevValue; +} + +int ANTLRParser::traceGuessOption(int delta) { + + int prevValue=traceGuessOptionValue; + + traceGuessOptionValue=traceGuessOptionValue+delta; + + if (traceCurrentRuleName != NULL) { + if (prevValue <= 0 && traceGuessOptionValue > 0) { + fprintf(stderr,"guess trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth); + }; + if (prevValue > 0 && traceGuessOptionValue <= 0) { + fprintf(stderr,"guess trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth); + }; + }; + return prevValue; +} + +// MR19 V.H. Simonis Defer Fetch feature + +void ANTLRParser::undeferFetch() +{ + +#ifdef ZZDEFER_FETCH + if (stillToFetch) { + for (int stillToFetch_x = 0; stillToFetch_x < stillToFetch; ++stillToFetch_x) { + NLA = inputTokens->getToken()->getType(); + dirty--; + lap = (lap+1)&(LLk-1); + } + stillToFetch = 0; + } +#else + return; +#endif + +} + +int ANTLRParser::isDeferFetchEnabled() +{ +#ifdef ZZDEFER_FETCH + return 1; +#else + return 0; +#endif +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h new file mode 100644 index 0000000000..85fe921ebb --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AParser.h @@ -0,0 +1,358 @@ +/* ANTLRParser.h + * + * Define the generic ANTLRParser superclass, which is subclassed to + * define an actual parser. + * + * Before entry into this file: ANTLRTokenType must be set. + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef APARSER_H_GATE +#define APARSER_H_GATE + +#include "pcctscfg.h" + +#include "pccts_stdio.h" +#include "pccts_setjmp.h" + +PCCTS_NAMESPACE_STD + +#include ATOKEN_H +#include ATOKENBUFFER_H + +#ifdef ZZCAN_GUESS +#ifndef ZZINF_LOOK +#define ZZINF_LOOK +#endif +#endif + + +#define NLA (token_type[lap&(LLk-1)])/* --> next LA */ + +typedef unsigned char SetWordType; + +/* Define external bit set stuff (for SetWordType) */ +#define EXT_WORDSIZE (sizeof(char)*8) +#define EXT_LOGWORDSIZE 3 + + /* s y n t a c t i c p r e d i c a t e s t u f f */ + +#ifndef zzUSER_GUESS_HOOK +#define zzUSER_GUESS_HOOK(seqFrozen,zzrv) +#endif + +#ifndef zzUSER_GUESS_DONE_HOOK +#define zzUSER_GUESS_DONE_HOOK(seqFrozen) +#endif + +/* MR14 Add zzUSER_GUESS_FAIL_HOOK and related code */ + +#define zzUSER_GUESS_FAIL_HOOK_INTERNAL zzUSER_GUESS_FAIL_HOOK(SeqFrozen) +#ifndef zzUSER_GUESS_FAIL_HOOK +#define zzUSER_GUESS_FAIL_HOOK(zzGuessSeq) +#endif + + +typedef struct _zzjmp_buf { + jmp_buf state; + } zzjmp_buf; + +/* these need to be macros not member functions */ +#define zzGUESS_BLOCK ANTLRParserState zzst; int zzrv; int _marker; int zzGuessSeqFrozen; +#define zzNON_GUESS_MODE if ( !guessing ) +#define zzGUESS_FAIL guess_fail(); + +/* Note: zzGUESS_DONE does not execute longjmp() */ + +#define zzGUESS_DONE {zzrv=1; inputTokens->rewind(_marker); guess_done(&zzst);zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) } +#define zzGUESS saveState(&zzst); \ + guessing = 1; \ + zzGuessSeqFrozen = ++zzGuessSeq; \ + _marker = inputTokens->mark(); \ + zzrv = setjmp(guess_start.state); \ + zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \ + if ( zzrv ) zzGUESS_DONE + +#define zzTRACEdata const ANTLRChar *zzTracePrevRuleName = NULL; + +#ifndef zzTRACEIN +#define zzTRACEIN(r) zzTracePrevRuleName=traceCurrentRuleName;tracein(r); +#endif +#ifndef zzTRACEOUT +#define zzTRACEOUT(r) traceout(r);traceCurrentRuleName=zzTracePrevRuleName; +#endif + + /* a n t l r p a r s e r d e f */ + +struct ANTLRParserState { + /* class variables */ + zzjmp_buf guess_start; + int guessing; + + int inf_labase; + int inf_last; + + int dirty; + + int traceOptionValue; // MR10 + int traceGuessOptionValue; // MR10 + const ANTLRChar *traceCurrentRuleName; // MR10 + int traceDepth; // MR10 + +}; + +/* notes: + * + * multiple inheritance is a cool way to include what stuff is needed + * in this structure (like guess stuff). however, i'm not convinced that + * multiple inheritance works correctly on all platforms. not that + * much space is used--just include all possibly useful members. + * + * the class should also be a template with arguments for the lookahead + * depth and so on. that way, more than one parser can be defined (as + * each will probably have different lookahead requirements). however, + * am i sure that templates work? no, i'm not sure. + * + * no attributes are maintained and, hence, the 'asp' variable is not + * needed. $i can still be referenced, but it refers to the token + * associated with that rule element. question: where are the token's + * stored if not on the software stack? in local variables created + * and assigned to by antlr. + */ +class ANTLRParser { +protected: + /* class variables */ + static SetWordType bitmask[sizeof(SetWordType)*8]; + static char eMsgBuffer[500]; + +protected: + int LLk; // number of lookahead symbols (old LL_K) + int demand_look; + ANTLRTokenType eofToken; // when do I stop during resynch()s + int bsetsize; // size of bitsets created by ANTLR in + // units of SetWordType + + ANTLRTokenBuffer *inputTokens; //place to get input tokens + + zzjmp_buf guess_start; // where to jump back to upon failure + int guessing; // if guessing (using (...)? predicate) + + // infinite lookahead stuff + int can_use_inf_look; // set by subclass (generated by ANTLR) + int inf_lap; + int inf_labase; + int inf_last; + int *_inf_line; + + const ANTLRChar **token_tbl; // pointer to table of token type strings MR20 const + + int dirty; // used during demand lookahead + + ANTLRTokenType *token_type; // fast reference cache of token.getType() +// ANTLRLightweightToken **token; // the token with all its attributes + int lap; + int labase; +#ifdef ZZDEFER_FETCH + int stillToFetch; // MR19 V.H. Simonis +#endif + +private: + void fill_inf_look(); + +protected: + virtual void guess_fail() { // MR9 27-Sep-97 make virtual + traceGuessFail(); // MR10 + longjmp(guess_start.state, 1); } // MR9 + virtual void guess_done(ANTLRParserState *st) { // MR9 27-Sep-97 make virtual + restoreState(st); } // MR9 + virtual int guess(ANTLRParserState *); // MR9 27-Sep-97 make virtual + void look(int); + int _match(ANTLRTokenType, ANTLRChar **, ANTLRTokenType *, + _ANTLRTokenPtr *, SetWordType **); + int _setmatch(SetWordType *, ANTLRChar **, ANTLRTokenType *, + _ANTLRTokenPtr *, SetWordType **); + int _match_wsig(ANTLRTokenType); + int _setmatch_wsig(SetWordType *); + virtual void consume(); + virtual void resynch(SetWordType *wd,SetWordType mask); // MR21 + void prime_lookahead(); + virtual void tracein(const ANTLRChar *r); // MR10 + virtual void traceout(const ANTLRChar *r); // MR10 + static unsigned MODWORD(unsigned x) {return x & (EXT_WORDSIZE-1);} // x % EXT_WORDSIZE // MR9 + static unsigned DIVWORD(unsigned x) {return x >> EXT_LOGWORDSIZE;} // x / EXT_WORDSIZE // MR9 + int set_deg(SetWordType *); + int set_el(ANTLRTokenType, SetWordType *); + virtual void edecode(SetWordType *); // MR1 + virtual void FAIL(int k, ...); // MR1 + int traceOptionValue; // MR10 + int traceGuessOptionValue; // MR10 + const ANTLRChar *traceCurrentRuleName; // MR10 + int traceDepth; // MR10 + void traceReset(); // MR10 + virtual void traceGuessFail(); // MR10 + virtual void traceGuessDone(const ANTLRParserState *); // MR10 + int zzGuessSeq; // MR10 + +public: + ANTLRParser(ANTLRTokenBuffer *, + int k=1, + int use_inf_look=0, + int demand_look=0, + int bsetsize=1); + virtual ~ANTLRParser(); + + virtual void init(); + + ANTLRTokenType LA(int i) + { +// +// MR14 demand look will always be 0 for C++ mode +// +//// return demand_look ? token_type[(labase+(i)-1)&(LLk-1)] : +//// token_type[(lap+(i)-1)&(LLk-1)]; + +// MR19 V.H. Simonis Defer fetch feature + +#ifdef ZZDEFER_FETCH + undeferFetch(); +#endif + return token_type[(lap+(i)-1)&(LLk-1)]; + } + _ANTLRTokenPtr LT(int i); + + void setEofToken(ANTLRTokenType t) { eofToken = t; } + ANTLRTokenType getEofToken() const { return eofToken; } // MR14 + + void noGarbageCollectTokens() { inputTokens->noGarbageCollectTokens(); } + void garbageCollectTokens() { inputTokens->garbageCollectTokens(); } + + virtual void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup, + SetWordType *eset, ANTLRTokenType etok, int k); + virtual void saveState(ANTLRParserState *); // MR9 27-Sep-97 make virtual + virtual void restoreState(ANTLRParserState *); // MR9 27-Sep-97 make virtual + + virtual void panic(const char *msg); // MR20 const + static char *eMsgd(char *,int); + static char *eMsg(char *,char *); + static char *eMsg2(char *,char *,char *); + + void consumeUntil(SetWordType *st); + void consumeUntilToken(int t); + + virtual int _setmatch_wdfltsig(SetWordType *tokensWanted, + ANTLRTokenType tokenTypeOfSet, + SetWordType *whatFollows); + virtual int _match_wdfltsig(ANTLRTokenType tokenWanted, + SetWordType *whatFollows); + + const ANTLRChar * parserTokenName(int tok); // MR1 + + int traceOptionValueDefault; // MR11 + int traceOption(int delta); // MR11 + int traceGuessOption(int delta); // MR11 + +// MR8 5-Aug-97 S.Bochnak@microtool.com.pl +// MR8 Move resynch static local variable +// MR8 to class instance + + int syntaxErrCount; // MR12 + ANTLRTokenStream *getLexer() const { // MR12 + return inputTokens ? inputTokens->getLexer() : 0; } // MR12 +protected: // MR8 + int resynchConsumed; // MR8 + char *zzFAILtext; // workarea required by zzFAIL // MR9 + void undeferFetch(); // MR19 V.H. Simonis + int isDeferFetchEnabled(); // MR19 V.H. Simonis +}; + +#define zzmatch(_t) \ + if ( !_match((ANTLRTokenType)_t, &zzMissText, &zzMissTok, \ + (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail; + +#define zzmatch_wsig(_t,handler) \ + if ( !_match_wsig((ANTLRTokenType)_t) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;} + +#define zzsetmatch(_ts) \ + if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \ + (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail; + +#define zzsetmatch_wsig(_ts, handler) \ + if ( !_setmatch_wsig(_ts) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;} + +/* For the dflt signal matchers, a FALSE indicates that an error occurred + * just like the other matchers, but in this case, the routine has already + * recovered--we do NOT want to consume another token. However, when + * the match was successful, we do want to consume hence _signal=0 so that + * a token is consumed by the "if (!_signal) consume(); _signal=NoSignal;" + * preamble. + */ +#define zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) \ + if ( !_setmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) ) \ + _signal = MismatchedToken; + +#define zzmatch_wdfltsig(tokenWanted, whatFollows) \ + if ( !_match_wdfltsig(tokenWanted, whatFollows) ) _signal = MismatchedToken; + + +// MR1 10-Apr-97 zzfailed_pred() macro does not backtrack +// MR1 in guess mode. +// MR1 Identification and correction due to J. Lilley + +#ifndef zzfailed_pred +#define zzfailed_pred(_p) \ + if (guessing) { \ + zzGUESS_FAIL; \ + } else { \ + fprintf(stdout,"line %d: semantic error; failed predicate: '%s'\n", \ + LT(1)->getLine(), _p); \ + } +#endif + +#define zzRULE \ + SetWordType *zzMissSet=NULL; ANTLRTokenType zzMissTok=(ANTLRTokenType)0; \ + _ANTLRTokenPtr zzBadTok=NULL; ANTLRChar *zzBadText=(ANTLRChar *)""; \ + int zzErrk=1,zzpf=0; \ + zzTRACEdata \ + ANTLRChar *zzMissText=(ANTLRChar *)""; + +#endif + + /* S t a n d a r d E x c e p t i o n S i g n a l s */ + +#define NoSignal 0 +#define MismatchedToken 1 +#define NoViableAlt 2 +#define NoSemViableAlt 3 + +/* MR7 Allow more control over signalling */ +/* by adding "Unwind" and "SetSignal" */ + +#define Unwind 4 +#define setSignal(newValue) *_retsignal=_signal=(newValue) +#define suppressSignal *_retsignal=_signal=0 +#define exportSignal *_retsignal=_signal diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp new file mode 100644 index 0000000000..433a26075e --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.cpp @@ -0,0 +1,244 @@ +/* Abstract syntax tree manipulation functions + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#include "pcctscfg.h" + +#include "pccts_stdio.h" +#include "pccts_stdarg.h" + +PCCTS_NAMESPACE_STD + +#define ANTLR_SUPPORT_CODE + +#include "ASTBase.h" + +/* ensure that tree manipulation variables are current after a rule + * reference + */ +void +ASTBase::link(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail) +{ + if ( *_sibling == NULL ) return; + if ( *_root == NULL ) *_root = *_sibling; + else if ( *_root != *_sibling ) (*_root)->_down = *_sibling; + if ( *_tail==NULL ) *_tail = *_sibling; + while ( (*_tail)->_right != NULL ) *_tail = (*_tail)->_right; +} + +/* add a child node to the current sibling list */ +void +ASTBase::subchild(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail) +{ + if ( *_tail != NULL ) (*_tail)->_right = this; + else { + *_sibling = this; + if ( *_root != NULL ) (*_root)->_down = *_sibling; + } + *_tail = this; + if ( *_root == NULL ) *_root = *_sibling; +} + +/* make a new AST node. Make the newly-created + * node the root for the current sibling list. If a root node already + * exists, make the newly-created node the root of the current root. + */ +void +ASTBase::subroot(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail) +{ + if ( *_root != NULL ) + if ( (*_root)->_down == *_sibling ) *_sibling = *_tail = *_root; + *_root = this; + (*_root)->_down = *_sibling; +} + +/* Apply preorder_action(), etc.. to root then each sibling */ +// +// 7-Apr-97 133MR1 +// Fix suggested by Ron House (house@helios.usq.edu.au) +// +void +ASTBase::preorder() +{ + ASTBase *tree = this; + + while ( tree!= NULL ) + { + if ( tree->_down != NULL ) { + tree->preorder_before_action(); // MR1 + }; + tree->preorder_action(); + if ( tree->_down!=NULL ) + { + tree->_down->preorder(); + tree->preorder_after_action(); // MR1 + } + tree = tree->_right; + } +} + +/* free all AST nodes in tree; apply func to each before freeing */ +void +ASTBase::destroy() +{ + ASTBase* tree = this; + while (tree) { + if (tree->_down) tree->_down->destroy(); + + ASTBase* cur = tree; + tree = tree->_right; + delete cur; + } +} + +/* build a tree (root child1 child2 ... NULL) + * If root is NULL, simply make the children siblings and return ptr + * to 1st sibling (child1). If root is not single node, return NULL. + * + * Siblings that are actually siblins lists themselves are handled + * correctly. For example #( NULL, #( NULL, A, B, C), D) results + * in the tree ( NULL A B C D ). + * + * Requires at least two parameters with the last one being NULL. If + * both are NULL, return NULL. + */ +ASTBase * +ASTBase::tmake(ASTBase *root, ...) +{ + va_list ap; + register ASTBase *child, *sibling=NULL, *tail, *w; + + va_start(ap, root); + + if ( root != NULL ) + if ( root->_down != NULL ) { + root->reportOverwriteOfDownPointer(); /* MR21 Report problem which almost always an error */ + return NULL; + } + child = va_arg(ap, ASTBase *); + while ( child != NULL ) + { + for (w=child; w->_right!=NULL; w=w->_right) {;} /* find end of child */ + if ( sibling == NULL ) {sibling = child; tail = w;} + else {tail->_right = child; tail = w;} + child = va_arg(ap, ASTBase *); + } + if ( root==NULL ) root = sibling; + else root->_down = sibling; + va_end(ap); + return root; +} + +#ifndef PCCTS_NOT_USING_SOR + +/* tree duplicate */ +// forgot to check for NULL this (TJP July 23,1995) +ASTBase * +ASTBase::dup() +{ + ASTBase *u, *t=this; + + if ( t == NULL ) return NULL; +/* + u = new ASTBase; + *u = *t; +*/ + u = (ASTBase *)this->shallowCopy(); + if ( t->_right!=NULL ) u->_right = t->_right->dup(); + else u->_right = NULL; + if ( t->_down!=NULL ) u->_down = t->_down->dup(); + else u->_down = NULL; + return u; +} +#endif + +// +// 7-Apr-97 133MR1 +// Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com) +// +/* tree duplicate */ + +#ifndef PCCTS_NOT_USING_SOR + +ASTBase * +ASTDoublyLinkedBase::dup() +{ + ASTDoublyLinkedBase *u, *t=this; + + if ( t == NULL ) return NULL; + u = (ASTDoublyLinkedBase *)this->shallowCopy(); + u->_up = NULL; /* set by calling invocation */ + u->_left = NULL; + if (t->_right!=NULL) { // MR1 + u->_right=t->_right->dup(); // MR1 + ((ASTDoublyLinkedBase *)u->_right)->_left = u; // MR1 + } else { // MR1 + u->_right = NULL; // MR1 + }; // MR1 + if (t->_down!=NULL) { // MR1 + u->_down = t->_down->dup(); // MR1 + ((ASTDoublyLinkedBase *)u->_down)->_up = u; // MR1 + } else { // MR1 + u->_down = NULL; // MR1 + }; // MR1 + return u; +} + +#endif + +/* + * Set the 'up', and 'left' pointers of all nodes in 't'. + * Initial call is double_link(your_tree, NULL, NULL). + */ +void +ASTDoublyLinkedBase::double_link(ASTBase *left, ASTBase *up) +{ + ASTDoublyLinkedBase *t = this; + + t->_left = (ASTDoublyLinkedBase *) left; + t->_up = (ASTDoublyLinkedBase *) up; + if (t->_down != NULL) + ((ASTDoublyLinkedBase *)t->_down)->double_link(NULL, t); + if (t->_right != NULL) + ((ASTDoublyLinkedBase *)t->_right)->double_link(t, up); +} + +// MR21 ASTBase::reportOverwriteOfDownPointer + +void ASTBase::reportOverwriteOfDownPointer() +{ + panic("Attempt to overwrite down pointer in ASTBase::tmake"); +} + +// MR21 ASTBase::panic + +void ASTBase::panic(const char *msg) +{ + fprintf(stderr,"ASTBase panic: %s\n", msg); + exit(PCCTS_EXIT_FAILURE); +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h new file mode 100644 index 0000000000..a5b3116a54 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ASTBase.h @@ -0,0 +1,119 @@ +/* Abstract syntax tree + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ASTBase_H +#define ASTBase_H + +#include "pcctscfg.h" + +#include "pccts_stdio.h" +#include "pccts_stdlib.h" + +PCCTS_NAMESPACE_STD + +#ifndef PCCTS_NOT_USING_SOR +#include "PCCTSAST.h" +#endif + +/* + * Notes: + * + * To specify a copy constructor, subclass one of these classes and + * give the copy constructor. To use dup(), you must define shallowCopy(). + * shallowCopy() can use either a copy constructor or just copy the node + * itself. + */ + +#ifdef PCCTS_NOT_USING_SOR +class DllExportPCCTS ASTBase { +#else +class DllExportPCCTS ASTBase : public PCCTS_AST { +#endif + +protected: + ASTBase *_right, *_down; + +public: + +#ifdef PCCTS_NOT_USING_SOR + ASTBase *right() { return _right; } + ASTBase *down() { return _down; } + void setRight(ASTBase *t) { _right = (ASTBase *)t; } + void setDown(ASTBase *t) { _down = (ASTBase *)t; } +#else + PCCTS_AST *right() { return _right; } // define the SORCERER interface + PCCTS_AST *down() { return _down; } + void setRight(PCCTS_AST *t) { _right = (ASTBase *)t; } + void setDown(PCCTS_AST *t) { _down = (ASTBase *)t; } +#endif + ASTBase() { _right = _down = NULL; } + virtual ~ASTBase() { ; } +#ifndef PCCTS_NOT_USING_SOR + virtual ASTBase *dup(); +#endif + void destroy(); + void preorder(); + static ASTBase *tmake(ASTBase *, ...); + static void link(ASTBase **, ASTBase **, ASTBase **); + void subchild(ASTBase **, ASTBase **, ASTBase **); + void subroot(ASTBase **, ASTBase **, ASTBase **); + virtual void preorder_action() { ; } + virtual void preorder_before_action() { printf(" ("); } + virtual void preorder_after_action() { printf(" )"); } + virtual void panic(const char *msg); /* MR21 */ + virtual void reportOverwriteOfDownPointer(); /* MR21 */ +}; + +class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase { +protected: + ASTDoublyLinkedBase *_left, *_up; + +public: + void double_link(ASTBase *left, ASTBase *up); + +#ifndef PCCTS_NOT_USING_SOR + virtual ASTBase *dup(); +#endif + +#ifdef PCCTS_NOT_USING_SOR + ASTBase *left() { return _left; } + ASTBase *up() { return _up; } + void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6 + void setUp(ASTBase *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6 +#else + PCCTS_AST *left() { return _left; } + PCCTS_AST *up() { return _up; } + void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; } // MR6 + void setUp(PCCTS_AST *t) { _up = (ASTDoublyLinkedBase *)t; } // MR6 +#endif + +}; + +class AST; // announce that this class will be coming along shortly +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp new file mode 100644 index 0000000000..88df14ba00 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp @@ -0,0 +1,82 @@ +/* ATokPtr.C + * + * ANTLRToken MUST be defined before entry to this file. + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Written by Russell Quong June 30, 1995 + * Adapted by Terence Parr to ANTLR stuff + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#include "pcctscfg.h" + +PCCTS_NAMESPACE_STD + +#include "ATokPtr.h" + +void ANTLRTokenPtr::ref() const +{ + if (ptr_ != NULL) { + ptr_->ref(); + } +} + +void ANTLRTokenPtr::deref() +{ + if (ptr_ != NULL) + { + ptr_->deref(); + if ( ptr_->nref()==0 ) + { + delete ptr_; + ptr_ = NULL; + } + } +} + +ANTLRTokenPtr::~ANTLRTokenPtr() +{ + deref(); +} + +// +// 8-Apr-97 MR1 Make operator -> a const member function +// as weall as some other member functions +// +void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs) // MR1 +{ + lhs.ref(); // protect against "xp = xp"; ie same underlying object + deref(); + ptr_ = lhs.ptr_; +} + +void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr) +{ + if (addr != NULL) { + addr->ref(); + } + deref(); + ptr_ = addr; +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h new file mode 100644 index 0000000000..3e825f6be0 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.h @@ -0,0 +1,88 @@ +/* ATokPtr.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Written by Russell Quong June 30, 1995 + * Adapted by Terence Parr to ANTLR stuff + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ATokPtr_h +#define ATokPtr_h + +#include "pcctscfg.h" + +#include "pccts_stdio.h" + +PCCTS_NAMESPACE_STD + +// pointer to a reference counted object +// robust in that an unused ANTLRTokenPtr can point to NULL. + +class ANTLRAbstractToken; + +class DllExportPCCTS ANTLRTokenPtr { +public: + ANTLRTokenPtr(ANTLRAbstractToken *addr=NULL){ptr_ = addr; ref();} + ANTLRTokenPtr(const ANTLRTokenPtr &lhs) {ptr_ = lhs.ptr_; lhs.ref();} + ~ANTLRTokenPtr(); + + // use ANTLRTokenPtr as a pointer to ANTLRToken +// +// 8-Apr-97 MR1 Make operator -> a const member function +// as well as some other member functions +// + ANTLRAbstractToken *operator-> () const { return ptr_; } // MR1 +// +// 7-Apr-97 133MR1 +// Fix suggested by Andreas Magnusson +// (Andreas.Magnusson@mailbox.swipnet.se) + void operator = (const ANTLRTokenPtr & lhs); // MR1 + void operator = (ANTLRAbstractToken *addr); + int operator != (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int + { return this->ptr_ != q.ptr_; } + int operator == (const ANTLRTokenPtr &q) const // MR1 // MR11 unsigned -> int + { return this->ptr_ == q.ptr_; } + int operator == (const ANTLRAbstractToken *addr) const // MR11 + { return this->ptr_ == addr; } + int operator != (const ANTLRAbstractToken *addr) const // MR11 + { return this->ptr_ != addr; } + + void ref() const; + void deref(); + +protected: + ANTLRAbstractToken *ptr_; +}; + +//typedef ANTLRTokenPtr _ANTLRTokenPtr; + +/* + * Since you cannot redefine operator->() to return one of the user's + * token object types, we must down cast. This is a drag. Here's + * a macro that helps. template: "mytoken(a-smart-ptr)->myfield". + */ +#define mytoken(tk) ((ANTLRToken *)(tk.operator->())) + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h new file mode 100644 index 0000000000..ef14516ee6 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken.h @@ -0,0 +1,305 @@ +/* ANTLRToken.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ATOKEN_H_GATE +#define ATOKEN_H_GATE + +#include "pcctscfg.h" + +#include "pccts_string.h" +#include "pccts_stdio.h" +#include "pccts_stdlib.h" + +PCCTS_NAMESPACE_STD + +// MR9 RJV (JVincent@novell.com) Not needed for variable length strings + +//// MR9 #ifndef ANTLRCommonTokenTEXTSIZE +//// MR9 #define ANTLRCommonTokenTEXTSIZE 100 +//// MR9 #endif + + +/* must define what a char looks like; can make this a class too */ +typedef char ANTLRChar; + +/* D E F I N E S M A R T P O I N T E R S */ + +//#include ATOKPTR_H not tested yet, leave out +class ANTLRAbstractToken; +typedef ANTLRAbstractToken *_ANTLRTokenPtr; + +class ANTLRAbstractToken { +public: + virtual ~ANTLRAbstractToken() {;} + virtual ANTLRTokenType getType() const = 0; + virtual void setType(ANTLRTokenType t) = 0; + virtual int getLine() const = 0; + virtual void setLine(int line) = 0; + virtual ANTLRChar *getText() const = 0; + virtual void setText(const ANTLRChar *) = 0; + + /* This function will disappear when I can use templates */ + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *text, + int line) = 0; + + /* define to satisfy ANTLRTokenBuffer's need to determine whether or + not a token object can be destroyed. If nref()==0, no one has + a reference, and the object may be destroyed. This function defaults + to 1, hence, if you use deleteTokens() message with a token object + not derived from ANTLRCommonRefCountToken, the parser will compile + but will not delete objects after they leave the token buffer. + */ + + virtual unsigned nref() const { return 1; } // MR11 + virtual void ref() {;} + virtual void deref() {;} + + virtual void panic(const char *msg) // MR20 const + { + fprintf(stderr, "ANTLRAbstractToken panic: %s\n", msg); + exit(PCCTS_EXIT_FAILURE); + } +}; + +/* This class should be subclassed. It cannot store token type or text */ + +class ANTLRRefCountToken : public ANTLRAbstractToken { +public: +#ifdef DBG_REFCOUNTTOKEN + static int ctor; + static int dtor; +#endif +protected: + unsigned refcnt_; +#ifdef DBG_REFCOUNTTOKEN + char object[200]; +#endif + +public: + ANTLRRefCountToken(ANTLRTokenType t, const ANTLRChar *s) +#ifndef DBG_REFCOUNTTOKEN + { + refcnt_ = 0; + } +#else + { + ctor++; + refcnt_ = 0; + if ( t==1 ) sprintf(object,"tok_EOF"); + else sprintf(object,"tok_%s",s); + fprintf(stderr, "ctor %s #%d\n",object,ctor); + } +#endif + ANTLRRefCountToken() +#ifndef DBG_REFCOUNTTOKEN + { refcnt_ = 0; } +#else + { + ctor++; + refcnt_ = 0; + sprintf(object,"tok_blank"); + fprintf(stderr, "ctor %s #%d\n",object,ctor); + } + virtual ~ANTLRRefCountToken() + { + dtor++; + if ( dtor>ctor ) fprintf(stderr, "WARNING: dtor>ctor\n"); + fprintf(stderr, "dtor %s #%d\n", object, dtor); + object[0]='\0'; + } +#endif + + // reference counting stuff needed by ANTLRTokenPtr. + // User should not access these; for C++ language reasons, we had + // to make these public. Yuck. + + void ref() { refcnt_++; } + void deref() { refcnt_--; } + unsigned nref() const { return refcnt_; } // MR11 + + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *txt, + int line) + { + panic("call to ANTLRRefCountToken::makeToken()\n"); + return NULL; + } +}; + +class ANTLRCommonNoRefCountToken : public ANTLRAbstractToken { +protected: + ANTLRTokenType _type; + int _line; + ANTLRChar *_text; // MR9 RJV + +public: + ANTLRCommonNoRefCountToken(ANTLRTokenType t, const ANTLRChar *s) + { setType(t); _line = 0; _text = NULL; setText(s); } + ANTLRCommonNoRefCountToken() + { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); } + + ~ANTLRCommonNoRefCountToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string + + ANTLRTokenType getType() const { return _type; } + void setType(ANTLRTokenType t) { _type = t; } + virtual int getLine() const { return _line; } + void setLine(int line) { _line = line; } + ANTLRChar *getText() const { return _text; } + int getLength() const { return strlen(getText()); } // MR11 + +// MR9 RJV: Added code for variable length strings to setText() + + void setText(const ANTLRChar *s) + { if (s != _text) { + if (_text) delete [] _text; + if (s != NULL) { + _text = new ANTLRChar[strlen(s)+1]; + if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed"); + strcpy(_text,s); + } else { + _text = new ANTLRChar[1]; + if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed"); + strcpy(_text,""); + }; + }; + } + + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *txt, + int line) + { + ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken; + t->setType(tt); t->setText(txt); t->setLine(line); + return t; + } + +// MR9 THM Copy constructor required when heap allocated string is used with copy semantics + + ANTLRCommonNoRefCountToken (const ANTLRCommonNoRefCountToken& from) : + ANTLRAbstractToken(from) { + setType(from._type); + setLine(from._line); + _text=NULL; + setText(from._text); + }; + +// MR9 THM operator =() required when heap allocated string is used with copy semantics + + virtual ANTLRCommonNoRefCountToken& operator =(const ANTLRCommonNoRefCountToken& rhs) { + +////// MR15 WatCom can't hack use of operator =() +////// Use this: *( (ANTRLAbstractToken *) this)=rhs; + + *( (ANTLRAbstractToken *) this ) = rhs; + + setType(rhs._type); + setLine(rhs._line); + setText(rhs._text); + return *this; + }; +}; + +class ANTLRCommonToken : public ANTLRRefCountToken { +protected: + ANTLRTokenType _type; + int _line; + ANTLRChar *_text; // MR9 RJV:Added + +public: + ANTLRCommonToken(ANTLRTokenType t, const ANTLRChar *s) : ANTLRRefCountToken(t,s) + { setType(t); _line = 0; _text = NULL; setText(s); } // MR9 + ANTLRCommonToken() + { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); } // MR9 + + virtual ~ANTLRCommonToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string + + ANTLRTokenType getType() const { return _type; } + void setType(ANTLRTokenType t) { _type = t; } + virtual int getLine() const { return _line; } + void setLine(int line) { _line = line; } + ANTLRChar *getText() const { return _text; } + int getLength() const { return strlen(getText()); } // MR11 + +// MR9 RJV: Added code for variable length strings to setText() + + void setText(const ANTLRChar *s) + { if (s != _text) { + if (_text) delete [] _text; + if (s != NULL) { + _text = new ANTLRChar[strlen(s)+1]; + if (_text == NULL) panic("ANTLRCommonToken::setText new failed"); + strcpy(_text,s); + } else { + _text = new ANTLRChar[1]; + if (_text == NULL) panic("ANTLRCommonToken::setText new failed"); + strcpy(_text,""); + }; + }; + } + + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *txt, + int line) + { + ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt); + t->setLine(line); + return t; + } + +// MR9 THM Copy constructor required when heap allocated string is used with copy semantics + + ANTLRCommonToken (const ANTLRCommonToken& from) : + ANTLRRefCountToken(from) { + setType(from._type); + setLine(from._line); + _text=NULL; + setText(from._text); + }; + +// MR9 THM operator =() required when heap allocated string is used with copy semantics + + virtual ANTLRCommonToken& operator =(const ANTLRCommonToken& rhs) { + +////// MR15 WatCom can't hack use of operator =() +////// Use this instead: *( (ANTRLRRefCountToken *) this)=rhs; + + *( (ANTLRRefCountToken *) this) = rhs; + + setType(rhs._type); + setLine(rhs._line); + setText(rhs._text); + return *this; + }; +}; + +// used for backward compatibility +typedef ANTLRCommonToken ANTLRCommonBacktrackingToken; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp new file mode 100644 index 0000000000..a7b10c72d0 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.cpp @@ -0,0 +1,345 @@ +/* ANTLRTokenBuffer.C + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +typedef int ANTLRTokenType; // fool AToken.h into compiling + +class ANTLRParser; /* MR1 */ + +#define ANTLR_SUPPORT_CODE + +#include "pcctscfg.h" + +#include ATOKENBUFFER_H +typedef ANTLRAbstractToken *_ANTLRTokenPtr; + +#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW) +static unsigned char test[1000]; +#endif + +#ifdef DBG_REFCOUNTTOKEN +int ANTLRCommonToken::ctor = 0; +int ANTLRCommonToken::dtor = 0; +#endif + +ANTLRTokenBuffer:: +ANTLRTokenBuffer(ANTLRTokenStream *_input, int _k, int _chunk_size_formal) /* MR14 */ +{ + this->input = _input; + this->k = _k; + buffer_size = chunk_size = _chunk_size_formal; + buffer = (_ANTLRTokenPtr *) + calloc(chunk_size+1,sizeof(_ANTLRTokenPtr )); + if ( buffer == NULL ) { + panic("cannot alloc token buffer"); + } + buffer++; // leave the first elem empty so tp-1 is valid ptr + + tp = &buffer[0]; + last = tp-1; + next = &buffer[0]; + num_markers = 0; + end_of_buffer = &buffer[buffer_size-1]; + // BUGBUG -- threshold = &buffer[(int)(buffer_size*(1.0/2.0))]; + threshold = &buffer[(int)(buffer_size / 2)]; + _deleteTokens = 1; // assume we delete tokens + parser=NULL; // MR5 - uninitialized reference +} + +static void f() {;} +ANTLRTokenBuffer:: +~ANTLRTokenBuffer() +{ + f(); + // Delete all remaining tokens (from 0..last inclusive) + if ( _deleteTokens ) + { + _ANTLRTokenPtr *z; + for (z=buffer; z<=last; z++) + { + (*z)->deref(); +// z->deref(); +#ifdef DBG_REFCOUNTTOKEN + fprintf(stderr, "##########dtor: deleting token '%s' (ref %d)\n", + ((ANTLRCommonToken *)*z)->getText(), (*z)->nref()); +#endif + if ( (*z)->nref()==0 ) + { + delete (*z); + } + } + } + + if ( buffer!=NULL ) free((char *)(buffer-1)); +} + +#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW) +#include "pccts_stdio.h" +PCCTS_NAMESPACE_STD +#endif + +_ANTLRTokenPtr ANTLRTokenBuffer:: +getToken() +{ + if ( tp <= last ) // is there any buffered lookahead still to be read? + { + return *tp++; // read buffered lookahead + } + // out of buffered lookahead, get some more "real" + // input from getANTLRToken() + if ( num_markers==0 ) + { + if( next > threshold ) + { +#ifdef DBG_TBUF +fprintf(stderr,"getToken: next > threshold (high water is %d)\n", threshold-buffer); +#endif + makeRoom(); + } + } + else { + if ( next > end_of_buffer ) + { +#ifdef DBG_TBUF +fprintf(stderr,"getToken: next > end_of_buffer (size is %d)\n", buffer_size); +#endif + extendBuffer(); + } + } + *next = getANTLRToken(); + (*next)->ref(); // say we have a copy of this pointer in buffer + last = next; + next++; + tp = last; + return *tp++; +} + +void ANTLRTokenBuffer:: +rewind(int pos) +{ +#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW) + fprintf(stderr, "rewind(%d)[nm=%d,from=%d,%d.n=%d]\n", pos, num_markers, tp-buffer,pos,test[pos]); + test[pos]--; +#endif + tp = &buffer[pos]; + num_markers--; +} + +/* + * This function is used to specify that the token pointers read + * by the ANTLRTokenBuffer should be buffered up (to be reused later). + */ +int ANTLRTokenBuffer:: +mark() +{ +#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW) + test[tp-buffer]++; + fprintf(stderr,"mark(%d)[nm=%d,%d.n=%d]\n",tp-buffer,num_markers+1,tp-buffer,test[tp-buffer]); +#endif + num_markers++; + return tp - buffer; +} + +/* + * returns the token pointer n positions ahead. + * This implies that bufferedToken(1) gets the NEXT symbol of lookahead. + * This is used in conjunction with the ANTLRParser lookahead buffer. + * + * No markers are set or anything. A bunch of input is buffered--that's all. + * The tp pointer is left alone as the lookahead has not been advanced + * with getToken(). The next call to getToken() will find a token + * in the buffer and won't have to call getANTLRToken(). + * + * If this is called before a consume() is done, how_many_more_i_need is + * set to 'n'. + */ +_ANTLRTokenPtr ANTLRTokenBuffer:: +bufferedToken(int n) +{ +// int how_many_more_i_need = (last-tp < 0) ? n : n-(last-tp)-1; + int how_many_more_i_need = (tp > last) ? n : n-(last-tp)-1; + // Make sure that at least n tokens are available in the buffer +#ifdef DBG_TBUF + fprintf(stderr, "bufferedToken(%d)\n", n); +#endif + for (int i=1; i<=how_many_more_i_need; i++) + { + if ( next > end_of_buffer ) // buffer overflow? + { + extendBuffer(); + } + *next = getANTLRToken(); + (*next)->ref(); // say we have a copy of this pointer in buffer + last = next; + next++; + } + return tp[n - 1]; +} + +/* If no markers are set, the none of the input needs to be saved (except + * for the lookahead Token pointers). We save only k-1 token pointers as + * we are guaranteed to do a getANTLRToken() right after this because otherwise + * we wouldn't have needed to extend the buffer. + * + * If there are markers in the buffer, we need to save things and so + * extendBuffer() is called. + */ +void ANTLRTokenBuffer:: +makeRoom() +{ +#ifdef DBG_TBUF + fprintf(stderr, "in makeRoom.................\n"); + fprintf(stderr, "num_markers==%d\n", num_markers); +#endif +/* + if ( num_markers == 0 ) + { +*/ +#ifdef DBG_TBUF + fprintf(stderr, "moving lookahead and resetting next\n"); + + _ANTLRTokenPtr *r; + fprintf(stderr, "tbuf = ["); + for (r=buffer; r<=last; r++) + { + if ( *r==NULL ) fprintf(stderr, " xxx"); + else fprintf(stderr, " '%s'", ((ANTLRCommonToken *)*r)->getText()); + } + fprintf(stderr, " ]\n"); + + fprintf(stderr, + "before: tp=%d, last=%d, next=%d, threshold=%d\n",tp-buffer,last-buffer,next-buffer,threshold-buffer); +#endif + + // Delete all tokens from 0..last-(k-1) inclusive + if ( _deleteTokens ) + { + _ANTLRTokenPtr *z; + for (z=buffer; z<=last-(k-1); z++) + { + (*z)->deref(); +// z->deref(); +#ifdef DBG_REFCOUNTTOKEN + fprintf(stderr, "##########makeRoom: deleting token '%s' (ref %d)\n", + ((ANTLRCommonToken *)*z)->getText(), (*z)->nref()); +#endif + if ( (*z)->nref()==0 ) + { + delete (*z); + } + } + } + + // reset the buffer to initial conditions, but move k-1 symbols + // to the beginning of buffer and put new input symbol at k + _ANTLRTokenPtr *p = buffer, *q = last-(k-1)+1; +// ANTLRAbstractToken **p = buffer, **q = end_of_buffer-(k-1)+1; +#ifdef DBG_TBUF + fprintf(stderr, "lookahead buffer = ["); +#endif + for (int i=1; i<=(k-1); i++) + { + *p++ = *q++; +#ifdef DBG_TBUF + fprintf(stderr, + " '%s'", ((ANTLRCommonToken *)buffer[i-1])->getText()); +#endif + } +#ifdef DBG_TBUF + fprintf(stderr, " ]\n"); +#endif + next = &buffer[k-1]; + tp = &buffer[k-1]; // tp points to what will be filled in next + last = tp-1; +#ifdef DBG_TBUF + fprintf(stderr, + "after: tp=%d, last=%d, next=%d\n", + tp-buffer, last-buffer, next-buffer); +#endif +/* + } + else { + extendBuffer(); + } +*/ +} + +/* This function extends 'buffer' by chunk_size and returns with all + * pointers at the same relative positions in the buffer (the buffer base + * address could have changed in realloc()) except that 'next' comes + * back set to where the next token should be stored. All other pointers + * are untouched. + */ +void +ANTLRTokenBuffer:: +extendBuffer() +{ + int save_last = last-buffer, save_tp = tp-buffer, save_next = next-buffer; +#ifdef DBG_TBUF + fprintf(stderr, "extending physical buffer\n"); +#endif + buffer_size += chunk_size; + buffer = (_ANTLRTokenPtr *) + realloc((char *)(buffer-1), + (buffer_size+1)*sizeof(_ANTLRTokenPtr )); + if ( buffer == NULL ) { + panic("cannot alloc token buffer"); + } + buffer++; // leave the first elem empty so tp-1 is valid ptr + + tp = buffer + save_tp; // put the pointers back to same relative position + last = buffer + save_last; + next = buffer + save_next; + end_of_buffer = &buffer[buffer_size-1]; + // BUGBUG -- threshold = &buffer[(int)(buffer_size*(1.0/2.0))]; + threshold = &buffer[(int)(buffer_size / 2)]; + +/* + // zero out new token ptrs so we'll know if something to delete in buffer + ANTLRAbstractToken **p = end_of_buffer-chunk_size+1; + for (; p<=end_of_buffer; p++) *p = NULL; +*/ +} + +ANTLRParser * ANTLRTokenBuffer:: // MR1 +setParser(ANTLRParser *p) { // MR1 + ANTLRParser *old=parser; // MR1 + parser=p; // MR1 + input->setParser(p); // MR1 + return old; // MR1 +} // MR1 + // MR1 +ANTLRParser * ANTLRTokenBuffer:: // MR1 +getParser() { // MR1 + return parser; // MR1 +} // MR1 + +/* to avoid having to link in another file just for the smart token ptr + * stuff, we include it here. Ugh. + */ +#include ATOKPTR_C diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h new file mode 100644 index 0000000000..719e05944e --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenBuffer.h @@ -0,0 +1,106 @@ +/* ANTLRTokenBuffer.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ATOKENBUFFER_H_GATE +#define ATOKENBUFFER_H_GATE + +#include "pcctscfg.h" + +#include "pccts_stdlib.h" + +PCCTS_NAMESPACE_STD + +#include ATOKEN_H +#include ATOKENSTREAM_H + +/* + * The parser is "attached" to an ANTLRTokenBuffer via interface + * functions: getToken() and bufferedToken(). The object that actually + * consumes characters and constructs tokens is connected to the + * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken(); + * where ANTLRTokenStream is really just a behavior (class with no data). + * C++ does not have this abstraction and hence we simply have come up + * with a fancy name for "void *". See the note in ANTLRTokenStream.h on + * the "behavior" of ANTLRTokenStream. + */ + +class ANTLRParser; // MR1 + +class DllExportPCCTS ANTLRTokenBuffer { +protected: + ANTLRTokenStream *input; // where do I get tokens + int buffer_size; + int chunk_size; + int num_markers; + int k; // Need at least this many tokens in buffer + _ANTLRTokenPtr *buffer; // buffer used for arbitrary lookahead + _ANTLRTokenPtr *tp; // pts into buffer; current token ptr + _ANTLRTokenPtr *last; // pts to last valid token in buffer + _ANTLRTokenPtr *next; // place to put token from getANTLRToken() + _ANTLRTokenPtr *end_of_buffer; + /* when you try to write a token past this and there are no markers + set, then move k-1 tokens back to the beginning of the buffer. + We want to stay away from the end of the buffer because we have + to extend it if a marker is set and we reach the end (we cannot + move tokens to the beginning of the buffer in this case). + */ + _ANTLRTokenPtr *threshold; + unsigned char _deleteTokens; + + // This function is filled in by the subclass; it initiates fetch of input + virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); } + void makeRoom(); + void extendBuffer(); + +public: + ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50); + virtual ~ANTLRTokenBuffer(); + virtual _ANTLRTokenPtr getToken(); + virtual void rewind(int pos); + virtual int mark(); + virtual _ANTLRTokenPtr bufferedToken(int i); + + void noGarbageCollectTokens() { _deleteTokens=0; } + void garbageCollectTokens() { _deleteTokens=1; } + + virtual int bufferSize() { return buffer_size; } + virtual int minTokens() { return k; } + virtual void setMinTokens(int k_new) { k = k_new; } + + virtual void panic(const char *msg) { exit(PCCTS_EXIT_FAILURE); } /* MR20 const */ +protected: // MR1 + ANTLRParser *parser; // MR1 +public: // MR1 + ANTLRParser *setParser(ANTLRParser *p); // MR1 + ANTLRParser *getParser(); // MR1 + ANTLRTokenStream *getLexer() const { // MR12 + return input;} // MR12 +}; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h new file mode 100644 index 0000000000..a603707bfd --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokenStream.h @@ -0,0 +1,51 @@ +/* ANTLRTokenStream.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ATOKENSTREAM_H_GATE +#define ATOKENSTREAM_H_GATE + +#include "pcctscfg.h" + +/* This is really a behavior or protocol; it merely indicates the behavior + * required of the input and output of an ANTLRTokenBuffer. You could + * subclass it, but you can also just pass any old pointer to ANTLRTokenBuffer + * with a type cast (in which case, your getANTLRToken() would have to + * explicitly cast the input pointer to your REAL type (typically your lexer)). + */ + +class ANTLRParser; // MR1 + +class DllExportPCCTS ANTLRTokenStream { +public: + virtual _ANTLRTokenPtr getToken() = 0; + virtual ANTLRParser * setParser(ANTLRParser *p) {return 0; }; // MR12 + virtual ANTLRParser * getParser() { return 0; }; // MR12 +}; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h new file mode 100644 index 0000000000..b4d69477bd --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/AToken_traditional.h @@ -0,0 +1,215 @@ +/* ANTLRToken.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ATOKEN_H_GATE +#define ATOKEN_H_GATE + +#include "pcctscfg.h" + +#include "pccts_string.h" +#include "pccts_stdio.h" +#include "pccts_stdlib.h" + +PCCTS_NAMESPACE_STD + +#ifndef ANTLRCommonTokenTEXTSIZE +#define ANTLRCommonTokenTEXTSIZE 100 +#endif + +/* must define what a char looks like; can make this a class too */ +typedef char ANTLRChar; + +/* D E F I N E S M A R T P O I N T E R S */ + +#include "pcctscfg.h" + +//#include ATOKPTR_H not tested yet, leave out +class ANTLRAbstractToken; +typedef ANTLRAbstractToken *_ANTLRTokenPtr; + +class DllExportPCCTS ANTLRAbstractToken { +public: + virtual ~ANTLRAbstractToken() {;} + virtual ANTLRTokenType getType() = 0; + virtual void setType(ANTLRTokenType t) = 0; + virtual int getLine() = 0; + virtual void setLine(int line) = 0; + virtual ANTLRChar *getText() = 0; + virtual void setText(ANTLRChar *) = 0; + + /* This function will disappear when I can use templates */ + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *text, + int line) = 0; + + /* define to satisfy ANTLRTokenBuffer's need to determine whether or + not a token object can be destroyed. If nref()==0, no one has + a reference, and the object may be destroyed. This function defaults + to 1, hence, if you use deleteTokens() message with a token object + not derived from ANTLRCommonRefCountToken, the parser will compile + but will not delete objects after they leave the token buffer. + */ + virtual unsigned nref() { return 1; } + virtual void ref() {;} + virtual void deref() {;} + + virtual void panic(char *msg) + { + fprintf(stderr, "ANTLRAbstractToken panic: %s\n", msg); + exit(PCCTS_EXIT_FAILURE); + } +}; + +/* This class should be subclassed. It cannot store token type or text */ + +class DllExportPCCTS ANTLRRefCountToken : public ANTLRAbstractToken { +public: +#ifdef DBG_REFCOUNTTOKEN + static int ctor; + static int dtor; +#endif +protected: + unsigned refcnt_; +#ifdef DBG_REFCOUNTTOKEN + char object[200]; +#endif + +public: + ANTLRRefCountToken(ANTLRTokenType t, ANTLRChar *s) +#ifndef DBG_REFCOUNTTOKEN + { + refcnt_ = 0; + } +#else + { + ctor++; + refcnt_ = 0; + if ( t==1 ) sprintf(object,"tok_EOF"); + else sprintf(object,"tok_%s",s); + fprintf(stderr, "ctor %s #%d\n",object,ctor); + } +#endif + ANTLRRefCountToken() +#ifndef DBG_REFCOUNTTOKEN + { refcnt_ = 0; } +#else + { + ctor++; + refcnt_ = 0; + sprintf(object,"tok_blank"); + fprintf(stderr, "ctor %s #%d\n",object,ctor); + } + virtual ~ANTLRRefCountToken() + { + dtor++; + if ( dtor>ctor ) fprintf(stderr, "WARNING: dtor>ctor\n"); + fprintf(stderr, "dtor %s #%d\n", object, dtor); + object[0]='\0'; + } +#endif + + // reference counting stuff needed by ANTLRTokenPtr. + // User should not access these; for C++ language reasons, we had + // to make these public. Yuck. + void ref() { refcnt_++; } + void deref() { refcnt_--; } + unsigned nref() { return refcnt_; } + + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *txt, + int line) + { + panic("call to ANTLRRefCountToken::makeToken()\n"); + return NULL; + } +}; + +class DllExportPCCTS ANTLRCommonNoRefCountToken : public ANTLRAbstractToken { +protected: + ANTLRTokenType _type; + int _line; + ANTLRChar _text[ANTLRCommonTokenTEXTSIZE+1]; + +public: + ANTLRCommonNoRefCountToken(ANTLRTokenType t, ANTLRChar *s) + { setType(t); _line = 0; setText(s); } + ANTLRCommonNoRefCountToken() + { setType((ANTLRTokenType)0); _line = 0; setText(""); } + + ANTLRTokenType getType() { return _type; } + void setType(ANTLRTokenType t) { _type = t; } + virtual int getLine() { return _line; } + void setLine(int line) { _line = line; } + ANTLRChar *getText() { return _text; } + void setText(ANTLRChar *s) + { strncpy((char *)_text, (char *)s, ANTLRCommonTokenTEXTSIZE); } + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *txt, + int line) + { + ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken; + t->setType(tt); t->setText(txt); t->setLine(line); + return t; + } +}; + +class DllExportPCCTS ANTLRCommonToken : public ANTLRRefCountToken { +protected: + ANTLRTokenType _type; + int _line; + ANTLRChar _text[ANTLRCommonTokenTEXTSIZE+1]; + +public: + ANTLRCommonToken(ANTLRTokenType t, ANTLRChar *s) : ANTLRRefCountToken(t,s) + { setType(t); _line = 0; setText(s); } + ANTLRCommonToken() + { setType((ANTLRTokenType)0); _line = 0; setText(""); } + virtual ~ANTLRCommonToken() {;} + + ANTLRTokenType getType() { return _type; } + void setType(ANTLRTokenType t) { _type = t; } + virtual int getLine() { return _line; } + void setLine(int line) { _line = line; } + ANTLRChar *getText() { return _text; } + void setText(ANTLRChar *s) + { strncpy((char *)_text, (char *)s, ANTLRCommonTokenTEXTSIZE); } + virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt, + ANTLRChar *txt, + int line) + { + ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt); + t->setLine(line); + return t; + } +}; + +// used for backward compatibility +typedef ANTLRCommonToken ANTLRCommonBacktrackingToken; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp new file mode 100644 index 0000000000..99d08a42a4 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.cpp @@ -0,0 +1,100 @@ +// FILE: BufFileInput.cpp +// AUTHOR: Alexey Demakov (AVD) demakov@kazbek.ispras.ru +// CREATION: 26-JAN-1998 +// DESCRIPTION: File Input Stream with lookahead for Scanner. +// See file BufFileInput.h for details + +// Change History: +// +// 22-Jun-1998 assert.h -> PCCTS_ASSERT_H +// string.h -> PCCTS_STRING_H +// +// 28-May-1998 Add virtual destructor to release buffer. +// +// Add dummy definition for ANTLRTokenType +// to allow compilation without knowing +// token type codes. +// +// Manfred Kogler (km@cast.uni-linz.ac.at) +// (1.33MR14) +// +// 20-Jul-1998 MR14a - Reorder initialization list for ctor. +// + +enum ANTLRTokenType {TER_HATES_CPP=0, SO_DO_OTHERS=9999 }; + +#include "pcctscfg.h" +#include "pccts_assert.h" +#include "pccts_string.h" + +PCCTS_NAMESPACE_STD + +#include "BufFileInput.h" + +BufFileInput::BufFileInput( FILE *f, int buf_size ) +: input( f ), + buf( new int[buf_size] ), + size( buf_size ), + start( 0 ), + len( 0 ) +{ +} + +BufFileInput::~BufFileInput() +{ + delete [] buf; +} + +int BufFileInput::nextChar( void ) +{ + if( len > 0 ) + { + // get char from buffer + int c = buf[start]; + + if( c != EOF ) + { + start++; start %= size; + len--; + } + return c; + } else { + // get char from file + int c = getc( input ); + + if( c == EOF ) + { + // if EOF - put it in the buffer as indicator + buf[start] = EOF; + len++; + } + return c; + } +} + +int BufFileInput::lookahead( char* s ) +{ + int l = strlen( s ); + + assert( 0 < l && l <= size ); + + while( len < l ) + { + int c = getc( input ); + + buf[ (start+len) % size ] = c; + + len++; + + if( c == EOF ) return 0; + } + + for( int i = 0; i < l; i++ ) + { + if( s[i] != buf[ (start+i) % size ] ) return 0; + } + return 1; +} + +// End of file BufFileInput.cpp + diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h new file mode 100644 index 0000000000..ea54c0ee26 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/BufFileInput.h @@ -0,0 +1,53 @@ +// FILE: BufFileInput.h +// AUTHOR: Alexey Demakov (AVD) demakov@kazbek.ispras.ru +// CREATION: 26-JAN-1998 +// DESCRIPTION: File Input Stream with lookahead for Scanner +// Tested under Win32 with ANTLR 1.33 MR10 and MSVC 5.0 + +// Change History: +// +// 28-May-1998 Add virtual destructor to release buffer +// Manfred Kogler (km@cast.uni-linz.ac.at) +// (1.33MR14) + +#ifndef BufFileInput_h +#define BufFileInput_h + +#include "pcctscfg.h" + +#include "pccts_stdio.h" + +PCCTS_NAMESPACE_STD + +#include "DLexerBase.h" + +class DllExportPCCTS BufFileInput : public DLGInputStream +{ +public: + // constructor + // f - input stream + // buf_size - size of buffer (maximal length for string in is_in) + + BufFileInput(FILE *f, int buf_size = 8 ); + + virtual ~BufFileInput(); + + // gets next char from stream + + virtual int nextChar( void ); + + // looks in stream and compares next l characters with s + // returns the result of comparision + + int lookahead( char* s ); + +private: + FILE *input; // input stream; + int* buf; // buffer + int size; // size of buffer + int start; // position of the first symbol in buffer + int len; // count of characters in buffers +}; + +#endif +// end of file BufFileInput.h diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h new file mode 100644 index 0000000000..39892bb899 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLG_stream_input.h @@ -0,0 +1,98 @@ + +/************************************************************/ +/* */ +/* Predefined char stream: Input from (c++) stream. */ +/* */ +/* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998. */ +/* */ +/* This is completely free stuff, do whatever you want with */ +/* it (but then, I will take no responsability for whatever */ +/* may happen if you do either... caveat emptor!). */ +/* */ +/************************************************************/ + +#ifndef _DLG_STREAM_INPUT_H +#define _DLG_STREAM_INPUT_H + +#include "pccts_istream.h" + +PCCTS_NAMESPACE_STD + +#ifndef DLGX_H +#include "DLexerBase.h" +#endif + + +// NOTES: The semantics of the copy constructor +// and the affectation operator may be unwaranted... +// and the stream may not be reset. +// +// It would have been so much nicer for nextChar() +// to throw (of for the DLGInputStream to change status) +// upon hiting EOF than to return an "int"... + +template < + class E, + class T = ::std::char_traits + > +class DLG_stream_input : public DLGInputStream +{ +public: + + DLG_stream_input(::std::basic_istream * p_input_stream) + : input(p_input_stream) + { + // nothing to do! + }; + + DLG_stream_input(const DLG_stream_input & a_recopier) + : input(a_recopier.input) + { + // nothing to do! + }; + + virtual ~DLG_stream_input() + { + this->purge(); // bloody templarized lookup... + }; + + DLG_stream_input operator = (const DLG_stream_input & a_affecter) + { + if (this != &a_affecter) + { + input = a_affecter.input; + } + + return(*this); + }; + + virtual int nextChar() + { + E extracted_stuff; + + input->get(extracted_stuff); + + if (*input) + { + return(int(extracted_stuff)); + } + else + { + return(EOF); + } + }; + +protected: + + ::std::basic_istream * input; + +private: + + void purge() + { + // nothing to do! + }; +}; + +#endif /* _DLG_STREAM_INPUT_H */ + diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp new file mode 100644 index 0000000000..003253bd3e --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp @@ -0,0 +1,188 @@ +/* DLexer.c + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#define ZZINC {if ( track_columns ) (++_endcol);} + +#define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);} + +#define ZZNEWSTATE (newstate = dfa[state][cl]) + +#ifndef ZZCOPY +#define ZZCOPY \ + /* Truncate matching buffer to size (not an error) */ \ + if (nextpos < lastpos){ \ + *(nextpos++) = ch; \ + }else{ \ + bufovf = 1; \ + } +#endif + +void DLGLexer:: +mode( int m ) +{ + /* points to base of dfa table */ + if (m*actions[accepts[state]])(); + +// MR1 +// MR1 11-Apr-97 Help for tracking DLG results +// MR1 + +#ifdef DEBUG_LEXER + +/* MR1 */ if (debugLexerFlag) { +/* MR1 */ if (parser != NULL) { +/* MR1 */ printf("\ntoken name=%s",parser->parserTokenName(tk)); +/* MR1 */ } else { +/* MR1 */ printf("\ntoken nnumber=%d",tk); +/* MR1 */ }; +/* MR1 */ printf(" lextext=(%s) mode=%d", +/* MR1 */ (_lextext[0]=='\n' && _lextext[1]==0) ? +/* MR1 */ "newline" : _lextext, +/* MR1 */ automaton); +/* MR1 */ if (interactive && !charfull) { +/* MR1 */ printf(" char=empty"); +/* MR1 */ } else { +/* MR1 */ if (ch=='\n') { +/* MR1 */ printf(" char=newline"); +/* MR1 */ } else { +/* MR1 */ printf(" char=(%c)",ch); +/* MR1 */ }; +/* MR1 */ }; +/* MR1 */ printf(" %s\n", +/* MR1 */ (add_erase==1 ? "skip()" : +/* MR1 */ add_erase==2 ? "more()" : +/* MR1 */ "")); +/* MR1 */ }; + +#endif + + switch (add_erase) { + case 1: goto skip; + case 2: goto more; + } + return tk; +} + +void DLGLexer:: +advance() +{ + if ( input==NULL ) err_in(); + ZZGETC; charfull = 1; ZZINC; +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp new file mode 100644 index 0000000000..220a846a7c --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.cpp @@ -0,0 +1,268 @@ +/* DLGLexerBase.c + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#include "pcctscfg.h" + +#include "pccts_stdio.h" +#include "pccts_stdlib.h" + +PCCTS_NAMESPACE_STD + +/* I have to put this here due to C++ limitation + * that you can't have a 'forward' decl for enums. + * I hate C++!!!!!!!!!!!!!!! + */ + +// MR1 +// MR1 10-Apr-97 133MR1 Prevent use of varying sizes for the +// MR1 ANTLRTokenType enum +// MR1 + +enum ANTLRTokenType { TER_HATES_CPP=0, ITS_UTTER_GARBAGE, // MR1 + WITH_SOME_GOOD_IDEAS=9999}; // MR1 + +#define ANTLR_SUPPORT_CODE + +#include "pcctscfg.h" +#include DLEXERBASE_H + +DLGLexerBase:: +DLGLexerBase(DLGInputStream *in, + unsigned bufsize, + int _interactive, + int _track_columns) +{ + this->_bufsize = bufsize; + this->_lextext = new DLGChar[_bufsize]; + if ( this->_lextext==NULL ) { + panic("text buffer is NULL"); + } + this->_begexpr = this->_endexpr = NULL; + this->ch = this->bufovf = 0; + this->nextpos = NULL; + this->cl = 0; + this->add_erase = 0; + this->input = in; + this->_begcol = 0; + this->_endcol = 0; + this->_line = 1; + this->charfull = 0; + this->automaton = 0; + this->token_to_fill = NULL; + this->interactive = _interactive; + this->track_columns = _track_columns; + this->debugLexerFlag = 0; // MR1 + this->parser = NULL; // MR1 + this->lexErrCount=0; // MR11 +} + +// MR19 THM + +void DLGLexerBase::reset() +{ + this->charfull = 0; + this->_begcol = 0; + this->_endcol = 0; + this->automaton = 0; + this->_line=1; + this->lexErrCount=0; +} + +void DLGLexerBase:: +setInputStream( DLGInputStream *in ) +{ + this->input = in; + _line = 1; + charfull = 0; +} + +/* saves dlg state, but not what feeds dlg (such as file position) */ +void DLGLexerBase:: +saveState(DLGState *state) +{ + state->input = input; + state->interactive = interactive; + state->track_columns = track_columns; + state->auto_num = automaton; + state->add_erase = add_erase; + state->lookc = ch; + state->char_full = charfull; + state->begcol = _begcol; + state->endcol = _endcol; + state->line = _line; + state->lextext = _lextext; + state->begexpr = _begexpr; + state->endexpr = _endexpr; + state->bufsize = _bufsize; + state->bufovf = bufovf; + state->nextpos = nextpos; + state->class_num = cl; + state->debugLexerFlag = debugLexerFlag; // MR1 + state->parser = parser; // MR1 +} + +void DLGLexerBase:: +restoreState(DLGState *state) +{ + input = state->input; + interactive = state->interactive; + track_columns = state->track_columns; + automaton = state->auto_num; + add_erase = state->add_erase; + ch = state->lookc; + charfull = state->char_full; + _begcol = state->begcol; + _endcol = state->endcol; + _line = state->line; + _lextext = state->lextext; + _begexpr = state->begexpr; + _endexpr = state->endexpr; + _bufsize = state->bufsize; + bufovf = state->bufovf; + nextpos = state->nextpos; + cl = state->class_num; + debugLexerFlag = state->debugLexerFlag; // MR1 + parser = state->parser; // MR1 +} + +/* erase what is currently in the buffer, and get a new reg. expr */ +void DLGLexerBase:: +skip() +{ + add_erase = 1; +} + +/* don't erase what is in the lextext buffer, add on to it */ +void DLGLexerBase:: +more() +{ + add_erase = 2; +} + +/* substitute c for the reg. expr last matched and is in the buffer */ +void DLGLexerBase:: +replchar(DLGChar c) +{ + /* can't allow overwriting null at end of string */ + if (_begexpr < &_lextext[_bufsize-1]){ + *_begexpr = c; + *(_begexpr+1) = '\0'; + } + _endexpr = _begexpr; + nextpos = _begexpr + 1; +} + +/* replace the string s for the reg. expr last matched and in the buffer */ + +void DLGLexerBase:: +replstr(const DLGChar *s) /* MR20 const */ +{ + register DLGChar *l= &_lextext[_bufsize -1]; + + nextpos = _begexpr; + if (s){ + while ((nextpos <= l) && (*(nextpos++) = *(s++))){ + /* empty */ + } + /* correct for NULL at end of string */ + nextpos--; + } + if ((nextpos <= l) && (*(--s) == 0)){ + bufovf = 0; + }else{ + bufovf = 1; + } + *(nextpos) = '\0'; + _endexpr = nextpos - 1; +} + +void DLGLexerBase:: +errstd(const char *s) /* MR20 const */ +{ + lexErrCount++; /* MR11 */ + fprintf(stderr, + "%s near line %d (text was '%s')\n", + ((s == NULL) ? "Lexical error" : s), + _line,_lextext); +} + +int DLGLexerBase:: +err_in() +{ + fprintf(stderr,"No input stream, function, or string\n"); + /* return eof to get out gracefully */ + return EOF; +} + +ANTLRTokenType DLGLexerBase:: +erraction() +{ + errstd("invalid token"); + advance(); + skip(); + return (ANTLRTokenType) 0; // bogus, but satisfies compiler +} + +_ANTLRTokenPtr DLGLexerBase:: +getToken() +{ + if ( token_to_fill==NULL ) panic("NULL token_to_fill"); + ANTLRTokenType tt = nextTokenType(); + _ANTLRTokenPtr tk = token_to_fill->makeToken(tt, _lextext,_line); + return tk; +} + +void DLGLexerBase:: +panic(const char *msg) /* MR20 const */ +{ + fprintf(stderr, "DLG panic: %s\n", msg); +// +// 7-Apr-97 133MR1 +// + exit(PCCTS_EXIT_FAILURE); // MR1 +} + +ANTLRParser * DLGLexerBase:: // MR1 +setParser(ANTLRParser *p) { // MR1 + ANTLRParser *oldValue=parser; // MR1 + parser=p; // MR1 + return oldValue; // MR1 +} // MR1 + // MR1 +ANTLRParser * DLGLexerBase:: // MR1 +getParser() { // MR1 + return parser; // MR1 +} // MR1 + // MR1 +int DLGLexerBase:: // MR1 +debugLexer(int newValue) { // MR1 + int oldValue=debugLexerFlag; // MR1 + debugLexerFlag=newValue; // MR1 + return oldValue; // MR1 +} // MR1 diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h new file mode 100644 index 0000000000..d3f696fec3 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexerBase.h @@ -0,0 +1,197 @@ +/* DLGLexerBase.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef DLGX_H +#define DLGX_H + +#include "pcctscfg.h" +#include "pccts_stdio.h" + +PCCTS_NAMESPACE_STD + +#include ATOKEN_H +#include ATOKENSTREAM_H + +class ANTLRParser; // MR1 + +/* must define what a char looks like; can make this a class too */ +typedef char DLGChar; + +/* Can have it as a class too: (ack this looks weird; is it right?) +class DllExportPCCTS DLGChar { +private: + int c; +public: + DLGChar(int ch) { c = ch; } + int atom() { return c; } +}; +*/ + +/* user must subclass this */ +class DllExportPCCTS DLGInputStream { +public: + virtual int nextChar() = 0; +}; + +/* Predefined char stream: Input from FILE */ +class DllExportPCCTS DLGFileInput : public DLGInputStream { +private: + int found_eof; + FILE *input; +public: + DLGFileInput(FILE *f) { input = f; found_eof = 0; } + int nextChar() { + int c; + if ( found_eof ) return EOF; + else { + c=getc(input); + if ( c==EOF ) found_eof = 1; + return c; + } + } + void DLGFileReset(FILE *f) {input=f; found_eof = 0; }; // MR11 +}; + +// MR9 Suggested by Bruce Guenter (bruceg@qcc.sk.ca) +// MR9 Make DLGStringInput const correct + +/* Predefined char stream: Input from string */ +class DllExportPCCTS DLGStringInput : public DLGInputStream { +private: + const DLGChar *input; // MR9 + const DLGChar *p; // MR9 +public: + DLGStringInput(const DLGChar *s) { input = s; p = &input[0];} // MR9 + int nextChar() + { + if (*p) return (int) (unsigned char) *p++; // MR14 + else return EOF; + } + + void DLGStringReset(const DLGChar *s) {input=s; p= &input[0]; }; // MR11 // MR16 +}; + +class DllExportPCCTS DLGState { +public: + DLGInputStream *input; + int interactive; + int track_columns; + int auto_num; + int add_erase; + int lookc; + int char_full; + int begcol, endcol; + int line; + DLGChar *lextext, *begexpr, *endexpr; + int bufsize; + int bufovf; + DLGChar *nextpos; + int class_num; + int debugLexerFlag; // MR1 + ANTLRParser *parser; // MR1 +}; + +/* user must subclass this */ +class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream { +public: + virtual ANTLRTokenType erraction(); + +protected: + DLGInputStream *input; + int interactive; + int track_columns; + DLGChar *_lextext; /* text of most recently matched token */ + DLGChar *_begexpr; /* beginning of last reg expr recogn. */ + DLGChar *_endexpr; /* beginning of last reg expr recogn. */ + int _bufsize; /* number of characters in lextext */ + int _begcol; /* column that first character of token is in*/ + int _endcol; /* column that last character of token is in */ + int _line; /* line current token is on */ + int ch; /* character to determine next state */ + int bufovf; /* indicates that buffer too small for text */ + int charfull; + DLGChar *nextpos; /* points to next available position in lextext*/ + int cl; + int automaton; + int add_erase; + DLGChar ebuf[70]; + _ANTLRTokenPtr token_to_fill; + + int debugLexerFlag; // MR1 + ANTLRParser *parser; // MR1 +public: + virtual _ANTLRTokenPtr getToken(); // MR12 public + virtual void advance(void) = 0; + void skip(void); /* erase lextext, look for antoher token */ + void more(void); /* keep lextext, look for another token */ + void mode(int k); /* switch to automaton 'k' */ + void saveState(DLGState *); + void restoreState(DLGState *); + virtual ANTLRTokenType nextTokenType(void)=0;/* get next token */ + void replchar(DLGChar c); /* replace last recognized reg. expr. with + a character */ + void replstr(const DLGChar *s); /* replace last recognized reg. expr. with + a string */ /* MR20 const */ + virtual int err_in(); // MR1 + virtual void errstd(const char *); // MR1 MR20 const + int line() { return _line; } + void set_line(int newValue) { _line=newValue; }; // MR1 + virtual void newline() { _line++; } + DLGChar *lextext() { return _lextext; } + + int begcol() { return _begcol; } + int endcol() { return _endcol; } + void set_begcol(int a) { _begcol=a; } + void set_endcol(int a) { _endcol=a; } + DLGChar *begexpr() { return _begexpr; } + DLGChar *endexpr() { return _endexpr; } + int bufsize() { return _bufsize; } + + void setToken(ANTLRAbstractToken *t) { token_to_fill = t; } + + void setInputStream(DLGInputStream *); + DLGLexerBase(DLGInputStream *in, + unsigned bufsize=2000, + int interactive=0, + int track_columns=0); + void reset(); // MR19 + virtual ~DLGLexerBase() { delete [] _lextext; } + virtual void panic(const char *msg); // MR1 MR20 const + void trackColumns() { + track_columns = 1; + this->_begcol = 0; + this->_endcol = 0; + }; + virtual ANTLRParser *setParser(ANTLRParser *p); // MR1 + virtual ANTLRParser *getParser(); // MR1 + virtual int debugLexer(int value); // MR1 + int lexErrCount; // MR12 +}; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h new file mode 100644 index 0000000000..47cc50b604 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PBlackBox.h @@ -0,0 +1,104 @@ +#ifndef PBLACKBOX_H +#define PBLACKBOX_H + +/* + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#include "pcctscfg.h" + +#include "pccts_iostream.h" + +PCCTS_NAMESPACE_STD + +// MR20 Added #include for "DLexerBase.h" + +#include "DLexerBase.h" + +// +// The default buffer size of the lexer is given by the +// second argument of the lexer's ctor. It is optional +// and defaults to 2000 +// + +template +class DllExportPCCTS ParserBlackBox { +protected: + DLGFileInput *in; + Lexer *scan; + _ANTLRTokenPtr tok; + ANTLRTokenBuffer *pipe; + Parser *_parser; + FILE *file; + int openByBlackBox; /* MR21 Don't close what we haven't opened */ +public: + + ParserBlackBox(FILE *f) + { + openByBlackBox = 0; /* MR21a */ + file = f; + in = new DLGFileInput(f); + scan = new Lexer(in); + pipe = new ANTLRTokenBuffer(scan); + tok = new Token; + scan->setToken(tok); + _parser = new Parser(pipe); + _parser->init(); + } + ParserBlackBox(char *fname) + { + FILE *f = fopen(fname, "r"); + if ( f==NULL ) { + openByBlackBox = 0; + cerr << "cannot open " << fname << "\n"; return; + } + else { + openByBlackBox = 1; + file = f; + in = new DLGFileInput(f); + scan = new Lexer(in); + pipe = new ANTLRTokenBuffer(scan); + tok = new Token; + scan->setToken(tok); + _parser = new Parser(pipe); + _parser->init(); + } + } + + ~ParserBlackBox() + { + delete in; delete scan; delete pipe; delete _parser; delete tok; + if (1 == openByBlackBox) { + fclose(file); + } + } + + Parser *parser() { return _parser; } + Lexer *getLexer() { return scan; } +}; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp new file mode 100644 index 0000000000..84a3a092ca --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.cpp @@ -0,0 +1,662 @@ +/* + * PCCTSAST.C + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B14 and ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * AHPCRC, University of Minnesota + * 1992-1998 + */ + +#define ANTLR_SUPPORT_CODE + +#include "pcctscfg.h" + +#include "PCCTSAST.h" +#include "pccts_stdarg.h" + +PCCTS_NAMESPACE_STD + +#include + +//#include "SList.h" + + /* String Scanning/Parsing Stuff */ + +const char *PCCTS_AST::scan_token_tbl[] = { /* MR20 const */ + "invalid", /* 0 */ + "LPAREN", /* 1 */ + "RPAREN", /* 2 */ + "PERCENT", /* 3 */ + "INT", /* 4 */ + "COLON", /* 5 */ + "POUND", /* 6 */ + "PERIOD", /* 7 */ +}; + +void PCCTS_AST:: +addChild(PCCTS_AST *t) +{ + if ( t==NULL ) return; + PCCTS_AST *s = down(); + if ( s!=NULL ) + { + while ( s->right()!=NULL ) s = s->right(); + s->setRight(t); + } + else + this->setDown(t); +} + +void PCCTS_AST:: +lisp(FILE *f) +{ + if ( down() != NULL ) fprintf(f," ("); + lisp_action(f); + if ( down()!=NULL ) down()->lisp(f); + if ( down() != NULL ) fprintf(f," )"); + if ( right()!=NULL ) right()->lisp(f); +} + +/* build a tree (root child1 child2 ... NULL) + * If root is NULL, simply make the children siblings and return ptr + * to 1st sibling (child1). If root is not single node, return NULL. + * + * Siblings that are actually sibling lists themselves are handled + * correctly. For example #( NULL, #( NULL, A, B, C), D) results + * in the tree ( NULL A B C D ). + * + * Requires at least two parameters with the last one being NULL. If + * both are NULL, return NULL. + * + * The down() and right() down/right pointers are used to make the tree. + */ +PCCTS_AST *PCCTS_AST:: +make(PCCTS_AST *rt, ...) +{ + va_list ap; + register PCCTS_AST *child, *sibling=NULL, *tail, *w; + PCCTS_AST *root; + + va_start(ap, rt); + root = rt; + + if ( root != NULL ) + if ( root->down() != NULL ) return NULL; + child = va_arg(ap, PCCTS_AST *); + while ( child != NULL ) + { + /* find end of child */ + for (w=child; w->right()!=NULL; w=w->right()) {;} + if ( sibling == NULL ) {sibling = child; tail = w;} + else {tail->setRight(child); tail = w;} + child = va_arg(ap, PCCTS_AST *); + } + if ( root==NULL ) root = sibling; + else root->setDown(sibling); + va_end(ap); + return root; +} + +/* The following push and pop routines are only used by ast_find_all() */ + +void PCCTS_AST:: +_push(PCCTS_AST **st, int *sp, PCCTS_AST *e) +{ + (*sp)--; + require((*sp)>=0, "stack overflow"); + st[(*sp)] = e; +} + +PCCTS_AST *PCCTS_AST:: +_pop(PCCTS_AST **st, int *sp) +{ + PCCTS_AST *e = st[*sp]; + (*sp)++; + require((*sp)<=MaxTreeStackDepth, "stack underflow"); + return e; +} + +/* Find all occurrences of u in t. + * 'cursor' must be initialized to 't'. It eventually + * returns NULL when no more occurrences of 'u' are found. + */ +PCCTS_AST *PCCTS_AST:: +ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor) +{ + PCCTS_AST *sib; + static PCCTS_AST *template_stack[MaxTreeStackDepth]; + static int tsp = MaxTreeStackDepth; + static int nesting = 0; + + if ( *cursor == NULL ) return NULL; + if ( *cursor!=this ) sib = *cursor; + else { + /* else, first time--start at top of template 't' */ + tsp = MaxTreeStackDepth; + sib = this; + /* bottom of stack is always a NULL--"cookie" indicates "done" */ + _push(template_stack, &tsp, NULL); + } + +keep_looking: + if ( sib==NULL ) /* hit end of sibling list */ + { + sib = _pop(template_stack, &tsp); + if ( sib == NULL ) { *cursor = NULL; return NULL; } + } + + if ( sib->type() != u->type() ) + { + /* look for another match */ + if ( sib->down()!=NULL ) + { + if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right()); + sib=sib->down(); + goto keep_looking; + } + /* nothing below to try, try next sibling */ + sib=sib->right(); + goto keep_looking; + } + + /* found a matching root node, try to match what's below */ + if ( match_partial(sib, u) ) + { + /* record sibling cursor so we can pick up next from there */ + if ( sib->down()!=NULL ) + { + if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right()); + *cursor = sib->down(); + } + else if ( sib->right()!=NULL ) *cursor = sib->right(); + else *cursor = _pop(template_stack, &tsp); + return sib; + } + + /* no match, keep searching */ + if ( sib->down()!=NULL ) + { + if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right()); + sib=sib->down(); + } + else sib = sib->right(); /* else, try to right if zip below */ + goto keep_looking; +} + +/* are two trees exactly alike? */ +int PCCTS_AST:: +match(PCCTS_AST *u) +{ + PCCTS_AST *t = this; + PCCTS_AST *sib; + + if ( u==NULL ) return 0; + + for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right()) + { + if ( sib->type() != u->type() ) return 0; + if ( sib->down()!=NULL ) + if ( !sib->down()->match(u->down()) ) return 0; + } + return 1; +} + +/* Is 'u' a subtree of 't' beginning at the root? */ +int PCCTS_AST:: +match_partial(PCCTS_AST *t, PCCTS_AST *u) +{ + PCCTS_AST *sib; + + if ( u==NULL ) return 1; + if ( t==NULL ) if ( u!=NULL ) return 0; else return 1; + + for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right()) + { + if ( sib->type() != u->type() ) return 0; + if ( sib->down()!=NULL ) + if ( !match_partial(sib->down(), u->down()) ) return 0; + } + return 1; +} + +/* Walk the template tree 't' (matching against 'this'), filling in the + * 'labels' array, and setting 'n' according to how many labels were matched. + */ +int PCCTS_AST:: +scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n) +{ + ScanAST *sib; + PCCTS_AST *u = this; + + if ( u==NULL ) return 0; + + for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right()) + { + /* make sure tokens match; token of '0' means wildcard match */ + if ( sib->type() != u->type() && sib->type()!=0 ) return 0; + /* we have a matched token here; set label pointers if exists */ + if ( sib->label_num>0 ) + { + require(labels!=NULL, "label found in template, but no array of labels"); + (*n)++; + *(labels[sib->label_num-1]) = u; + } + /* match what's below if something there and current node is not wildcard */ + if ( sib->down()!=NULL && sib->type()!=0 ) + { + if ( sib->down()==NULL ) if ( u->down()!=NULL ) return 0; else return 1; + if ( !u->down()->scanmatch(sib->down(), labels, n) ) return 0; + } + } + return 1; +} + +void PCCTS_AST:: +insert_after(PCCTS_AST *b) +{ + PCCTS_AST *end; + if ( b==NULL ) return; + /* find end of b's child list */ + for (end=b; end->right()!=NULL; end=end->right()) {;} + end->setRight(this->right()); + this->setRight(b); +} + +void PCCTS_AST:: +append(PCCTS_AST *b) +{ + PCCTS_AST *end; + require(b!=NULL, "append: NULL input tree"); + /* find end of child list */ + for (end=this; end->right()!=NULL; end=end->right()) {;} + end->setRight(b); +} + +PCCTS_AST *PCCTS_AST:: +tail() +{ + PCCTS_AST *end; + /* find end of child list */ + for (end=this; end->right()!=NULL; end=end->right()) {;} + return end; +} + +PCCTS_AST *PCCTS_AST:: +bottom() +{ + PCCTS_AST *end; + /* find end of child list */ + for (end=this; end->down()!=NULL; end=end->down()) {;} + return end; +} + +PCCTS_AST *PCCTS_AST:: +cut_between(PCCTS_AST *a, PCCTS_AST *b) +{ + PCCTS_AST *end, *ret; + if (a==NULL||b==NULL) return NULL; + /* find node pointing to b */ + for (end=a; end->right()!=NULL&&end->right()!=b; end=end->right()) + {;} + if (end->right()==NULL) return NULL; //ast_cut_between: a,b not connected + end->setRight(NULL); /* don't want it point to 'b' anymore */ + ret = a->right(); + a->setRight(b); + return ret; +} + +#ifdef NOT_YET +SList *PCCTS_AST:: +to_slist() +{ + SList *list = new SList; + PCCTS_AST *p; + + for (p=this; p!=NULL; p=p->right()) + { + list->add(p); + } + return list; +} +#endif + +void PCCTS_AST:: +tfree() +{ + PCCTS_AST *t = this; + if ( t->down()!=NULL ) t->down()->tfree(); + if ( t->right()!=NULL ) t->right()->tfree(); + delete t; +} + +int PCCTS_AST:: +nsiblings() +{ + PCCTS_AST *t = this; + int n=0; + + while ( t!=NULL ) + { + n++; + t = t->right(); + } + return n; +} + +PCCTS_AST *PCCTS_AST:: +sibling_index(int i) +{ + PCCTS_AST *t = this; + int j=1; + require(i>0, "sibling_index: i<=0"); + + while ( t!=NULL ) + { + if ( j==i ) return t; + j++; + t = t->right(); + } + return NULL; +} + +/* Assume this is a root node of a tree-- + * duplicate that node and what's below; ignore siblings of root node. + */ + +// MR9 23-Sep-97 RJV +// MR9 +// MR9 RJV: Original version only duplicated the node and down elements. +// MR9 Made copies of the pointers to sibling. +// MR9 Changed call "down()->deepCopy()" to "down()->deepCopyBushy()" +// MR9 + +PCCTS_AST *PCCTS_AST:: +deepCopy() +{ + PCCTS_AST *u = this->shallowCopy(); + if ( down()!=NULL ) u->setDown(down()->deepCopyBushy()); + u->setRight(NULL); + return u; +} + +/* Copy all nodes including siblings of root. */ +PCCTS_AST *PCCTS_AST:: +deepCopyBushy() +{ + PCCTS_AST *u = this->shallowCopy(); + /* copy the rest of the tree */ + if ( down()!=NULL ) u->setDown(down()->deepCopyBushy()); + if ( right()!=NULL ) u->setRight(right()->deepCopyBushy()); + return u; +} + +void PCCTS_AST:: +scanast_free(ScanAST *t) +{ + if ( t == NULL ) return; + scanast_free( t->down() ); + scanast_free( t->right() ); + free( (char *) t ); // MR1 +} + +/* + * scan + * + * This function is like scanf(): it attempts to match a template + * against an input tree. A variable number of tree pointers + * may be set according to the '%i' labels in the template string. + * For example: + * + * t->ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )", + * &w, &x, &y, &z); + * + * Naturally, you'd want this converted from + * + * t->ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )", + * &w, &x, &y, &z); + * + * by SORCERER. + * + * This function call must be done withing a SORCERER file because SORCERER + * must convert the token references to the associated token number. + * + * This functions parses the template and creates trees which are then + * matched against the input tree. The labels are set as they are + * encountered; hence, partial matches may leave some pointers set + * and some NULL. This routines initializes all argument pointers to NULL + * at the beginning. + * + * This function returns the number of labels matched. + */ +int PCCTS_AST:: +ast_scan(char *templ, ...) +{ + va_list ap; + ScanAST *tmpl; + int n, i, found=0; + PCCTS_AST ***label_ptrs=NULL; + + va_start(ap, templ); + + /* make a ScanAST tree out of the template */ + tmpl = stringparser_parse_scanast(templ, &n); + + /* make an array out of the labels */ + if ( n>0 ) + { + label_ptrs = (PCCTS_AST ***) calloc(n, sizeof(PCCTS_AST **)); + require(label_ptrs!=NULL, "scan: out of memory"); + for (i=1; i<=n; i++) + { + label_ptrs[i-1] = va_arg(ap, PCCTS_AST **); + *(label_ptrs[i-1]) = NULL; + } + } + + /* match the input tree against the template */ + scanmatch(tmpl, label_ptrs, &found); + + scanast_free(tmpl); + free( (char *) label_ptrs); // MR1 + + return found; +} + +ScanAST *PCCTS_AST:: +new_scanast(int tok) +{ + ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST)); +// +// 7-Apr-97 133MR1 +// + if ( p == NULL ) { // MR1 + fprintf(stderr, "out of mem\n"); // MR1 + exit(PCCTS_EXIT_FAILURE); // MR1 + }; // MR1 + p->_token = tok; + return p; +} + +ScanAST *PCCTS_AST:: +stringparser_parse_scanast(char *templ, int *num_labels) +{ + StringLexer lex; + StringParser parser; + ScanAST *t; + + stringlexer_init(&lex, templ); + stringparser_init(&parser, &lex); + t = stringparser_parse_tree(&parser); + *num_labels = parser.num_labels; + return t; +} + +void PCCTS_AST:: +stringparser_match(StringParser *parser, int token) +{ + if ( parser->token != token ) panic("bad tree in scan()"); +} + +/* + * Match a tree of the form: + * (root child1 child2 ... childn) + * or, + * node + * + * where the elements are integers or labeled integers. + */ +ScanAST *PCCTS_AST:: +stringparser_parse_tree(StringParser *parser) +{ + ScanAST *t=NULL, *root, *child, *last; + + if ( parser->token != __POUND ) + { + return stringparser_parse_element(parser); + } + stringparser_match(parser,__POUND); + parser->token = stringscan_gettok(parser->lexer); + stringparser_match(parser,__LPAREN); + parser->token = stringscan_gettok(parser->lexer); + root = stringparser_parse_element(parser); + while ( parser->token != __RPAREN ) + { + child = stringparser_parse_element(parser); + if ( t==NULL ) { t = child; last = t; } + else { last->_right = child; last = child; } + } + stringparser_match(parser,__RPAREN); + parser->token = stringscan_gettok(parser->lexer); + root->_down = t; + return root; +} + +ScanAST *PCCTS_AST:: +stringparser_parse_element(StringParser *parser) +{ + static char ebuf[100]; + int label = 0; + + if ( parser->token == __POUND ) + { + return stringparser_parse_tree(parser); + } + if ( parser->token == __PERCENT ) + { + parser->token = stringscan_gettok(parser->lexer); + stringparser_match(parser,__INT); + label = atoi(parser->lexer->text); + parser->num_labels++; + if ( label==0 ) panic("%%0 is an invalid label"); + parser->token = stringscan_gettok(parser->lexer); + stringparser_match(parser,__COLON); + parser->token = stringscan_gettok(parser->lexer); + /* can label tokens and wildcards */ + if ( parser->token != __INT && parser->token != __PERIOD ) + panic("can only label tokens"); + } + if ( parser->token == __INT ) + { + ScanAST *p = new_scanast(atoi(parser->lexer->text)); + parser->token = stringscan_gettok(parser->lexer); + p->label_num = label; + return p; + } + if ( parser->token == __PERIOD ) + { + ScanAST *p = new_scanast(0); /* token of 0 is wildcard */ + parser->token = stringscan_gettok(parser->lexer); + p->label_num = label; + return p; + } + sprintf(ebuf, "mismatch token in scan(): %s", scan_token_str(parser->token)); + panic(ebuf); + return NULL; +} + +void PCCTS_AST:: +stringparser_init(StringParser *parser, StringLexer *input) +{ + parser->lexer = input; + parser->token = stringscan_gettok(parser->lexer); + parser->num_labels = 0; +} + +void PCCTS_AST:: +stringlexer_init(StringLexer *scanner, char *input) +{ + scanner->text[0]='\0'; + scanner->input = input; + scanner->p = input; + stringscan_advance(scanner); +} + +void PCCTS_AST:: +stringscan_advance(StringLexer *scanner) +{ + if ( *(scanner->p) == '\0' ) scanner->c = __StringScanEOF; + scanner->c = *(scanner->p)++; +} + +int PCCTS_AST:: +stringscan_gettok(StringLexer *scanner) +{ + char *index = &scanner->text[0]; + static char ebuf[100]; + + while ( isspace(scanner->c) ) { stringscan_advance(scanner); } + if ( isdigit(scanner->c) ) + { + int tok = __INT; + while ( isdigit(scanner->c) ) { + *index++ = scanner->c; + stringscan_advance(scanner); + } + *index = '\0'; + return tok; + } + switch ( scanner->c ) + { + case '#' : stringscan_advance(scanner); return __POUND; + case '(' : stringscan_advance(scanner); return __LPAREN; + case ')' : stringscan_advance(scanner); return __RPAREN; + case '%' : stringscan_advance(scanner); return __PERCENT; + case ':' : stringscan_advance(scanner); return __COLON; + case '.' : stringscan_advance(scanner); return __PERIOD; + case '\0' : return __StringScanEOF; + case __StringScanEOF : return __StringScanEOF; + default : + sprintf(ebuf, "invalid char in scan: '%c'", scanner->c); + panic(ebuf); + } + return __StringScanEOF; // never reached +} + +const char *PCCTS_AST:: /* MR20 const */ +scan_token_str(int t) +{ + if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t]; + else if ( t==__StringScanEOF ) return ""; + else return ""; +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h new file mode 100644 index 0000000000..c9fb597bef --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/PCCTSAST.h @@ -0,0 +1,142 @@ +/* Abstract syntax tree + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef PCCTSAST_H +#define PCCTSAST_H + +#include "pcctscfg.h" + +#include "pccts_stdio.h" +#include "pccts_stdlib.h" + +PCCTS_NAMESPACE_STD + +//class SList; + +#define StringScanMaxText 50 +#define MaxTreeStackDepth 400 + +// +// 7-Apr-97 133MR1 signed int not accepted by AT&T cfront +// +typedef struct stringlexer { + int c; // MR1 + char *input; + char *p; + char text[StringScanMaxText]; + } StringLexer; + +/* Define the structures needed for ast_scan() */ +typedef struct stringparser { + int token; + StringLexer *lexer; + int num_labels; + } StringParser; + +typedef struct _scanast { + struct _scanast *_right, *_down; + int _token; + int label_num; + int type() { return _token; } + struct _scanast *right() { return _right; } + struct _scanast *down() { return _down; } + } ScanAST; + +#define VALID_SCAN_TOKEN(t) (t>=__LPAREN && t<=__PERIOD) + +class DllExportPCCTS PCCTS_AST { +protected: + static const char *scan_token_tbl[]; /* MR20 const */ + enum { + __LPAREN=1, + __RPAREN=2, + __PERCENT=3, + __INT=4, + __COLON=5, + __POUND=6, + __PERIOD=7, + __StringScanEOF=-1}; + +protected: + const char *scan_token_str(int t); /* MR20 const */ + void stringlexer_init(StringLexer *scanner, char *input); + void stringparser_init(StringParser *, StringLexer *); + ScanAST *stringparser_parse_scanast(char *templ, int *n); + ScanAST *stringparser_parse_tree(StringParser *parser); + ScanAST *stringparser_parse_element(StringParser *parser); + void stringscan_advance(StringLexer *scanner); + int stringscan_gettok(StringLexer *scanner); + void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e); + PCCTS_AST *_pop(PCCTS_AST **st, int *sp); + int match_partial(PCCTS_AST *t, PCCTS_AST *u); + int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n); + void scanast_free(ScanAST *t); + ScanAST *new_scanast(int tok); + void stringparser_match(StringParser *parser, int type); + virtual PCCTS_AST *deepCopyBushy(); + +public: + PCCTS_AST() {;} + virtual ~PCCTS_AST() {;} + + /* This group must be defined for SORCERER to work correctly */ + virtual PCCTS_AST *right() = 0; + virtual PCCTS_AST *down() = 0; + virtual void setRight(PCCTS_AST *t) = 0; + virtual void setDown(PCCTS_AST *t) = 0; +// we define these so ANTLR doesn't have to + virtual int type() { return 0; } + virtual void setType(int t) {;} + virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;} + + /* These are not needed by ANTLR, but are support functions */ + virtual PCCTS_AST *deepCopy(); // used by SORCERER in transform mode + virtual void addChild(PCCTS_AST *t); + virtual void lisp_action(FILE *f) {;} + virtual void lisp(FILE *f); + static PCCTS_AST *make(PCCTS_AST *rt, ...); + virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor); + virtual int match(PCCTS_AST *u); + virtual void insert_after(PCCTS_AST *b); + virtual void append(PCCTS_AST *b); + virtual PCCTS_AST *tail(); + virtual PCCTS_AST *bottom(); + static PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b); +// virtual SList *to_slist(); + virtual void tfree(); + int ast_scan(char *templ, ...); + virtual int nsiblings(); + virtual PCCTS_AST *sibling_index(int i); + + void require(int e,const char *err){ if ( !e ) panic(err); } /* MR20 const */ + virtual void panic(const char *err) // MR20 const + { fprintf(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); } +}; + +#endif /* PCCTSAST_H */ diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h new file mode 100644 index 0000000000..83578788c4 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/SList.h @@ -0,0 +1,71 @@ +#ifndef SList_h +#define SList_h + +/* + * SList.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * PCCTS 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1992-1998 + */ + +#include "pcctscfg.h" + +#include "pccts_stdio.h" +#include "pccts_stdlib.h" + +PCCTS_NAMESPACE_STD + +#include "PCCTSAST.h" + +class PCCTS_AST; + +class SListNode { +protected: + void *_elem; /* pointer to any kind of element */ + SListNode *_next; +public: + SListNode() {_elem=_next=NULL;} + virtual ~SListNode() {_elem=_next=NULL;} + void *elem() { return _elem; } + void setElem(void *e) { _elem = e; } + void setNext(SListNode *t) { _next = t; } + SListNode *next() { return _next; } +}; + +class SList { + SListNode *head, *tail; +public: + SList() {head=tail=NULL;} + virtual ~SList() {head=tail=NULL;} + virtual void *iterate(SListNode **); + virtual void add(void *e); + virtual void lfree(); + virtual PCCTS_AST *to_ast(SList list); + virtual void require(int e,char *err){ if ( !e ) panic(err); } + virtual void panic(char *err){ fprintf(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); } +}; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h new file mode 100644 index 0000000000..01bda69abd --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/antlr.h @@ -0,0 +1,788 @@ +/* antlr.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ANTLR_H +#define ANTLR_H + +#include "pcctscfg.h" + +#include "pccts_stdio.h" + +/* turn off warnings for unreferenced labels */ + +#ifdef _MSC_VER +#pragma warning(disable:4102) +#endif + +/* + * Define all of the stack setup and manipulation of $i, #i variables. + * + * Notes: + * The type 'Attrib' must be defined before entry into this .h file. + */ + + +#ifdef __USE_PROTOS +#include "pccts_stdlib.h" +#else +#ifdef VAXC +#include +#else +#include +#endif +#endif +#include "pccts_string.h" + +#if 0 +#include "set.h" +#endif + + +typedef int ANTLRTokenType; +typedef unsigned char SetWordType; + +typedef char ANTLRChar; + + /* G u e s s S t u f f */ + +#ifdef ZZCAN_GUESS +#ifndef ZZINF_LOOK +#define ZZINF_LOOK +#endif +#endif + +#ifdef ZZCAN_GUESS +typedef struct _zzjmp_buf { + jmp_buf state; + } zzjmp_buf; +#endif + + +/* can make this a power of 2 for more efficient lookup */ + +#ifndef ZZLEXBUFSIZE +#define ZZLEXBUFSIZE 8000 /* MR22 raise from 2k to 8k */ +#endif + +#define zzOvfChk \ + if ( zzasp <= 0 ) \ + { \ + fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__); \ + exit(PCCTS_EXIT_FAILURE); \ + } + +#ifndef ZZA_STACKSIZE +#define ZZA_STACKSIZE 400 +#endif +#ifndef ZZAST_STACKSIZE +#define ZZAST_STACKSIZE 400 +#endif + +#ifndef zzfailed_pred +#ifdef ZZCAN_GUESS +#define zzfailed_pred(_p) \ + if (zzguessing) { \ + zzGUESS_FAIL; \ + } else { \ + fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p); \ + } +#else +#define zzfailed_pred(_p) \ + fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p) +#endif +#endif + +/* MR19 zzchar_t additions */ + +#ifdef LL_K +#define LOOKAHEAD \ + int zztokenLA[LL_K]; \ + zzchar_t zztextLA[LL_K][ZZLEXBUFSIZE]; \ + int zzlap = 0, zzlabase=0; /* labase only used for DEMAND_LOOK */ +#else +#define LOOKAHEAD \ + int zztoken; +#endif + +#ifndef zzcr_ast +#define zzcr_ast(ast,attr,tok,text) +#endif + +#ifdef DEMAND_LOOK +#define DemandLookData int zzdirty=1; +#else +#define DemandLookData +#endif + +#ifndef zzUSER_GUESS_HOOK +#define zzUSER_GUESS_HOOK(seqFrozen,zzrv) +#endif + +#ifndef zzUSER_GUESS_DONE_HOOK +#define zzUSER_GUESS_DONE_HOOK(seqFrozen) +#endif + + /* S t a t e S t u f f */ + +#ifdef ZZCAN_GUESS +#define zzGUESS_BLOCK zzantlr_state zzst; int zzrv; int zzGuessSeqFrozen; + +/* MR10 change zzGUESS: do zzGUESS_DONE when zzrv==1 after longjmp as in C++ mode */ + +#define zzGUESS zzsave_antlr_state(&zzst); \ + zzguessing = 1; \ + zzGuessSeqFrozen=++zzGuessSeq; \ + zzrv = setjmp(zzguess_start.state); \ + zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \ + if (zzrv) zzGUESS_DONE; +#ifdef zzTRACE_RULES +#define zzGUESS_FAIL { zzTraceGuessFail(); longjmp(zzguess_start.state, 1); } +#else +#define zzGUESS_FAIL longjmp(zzguess_start.state, 1) +#endif + +/* MR10 change zzGUESS_DONE: zzrv=1 to simulate longjmp() return value as in C++ mode */ + +#define zzGUESS_DONE { zzrestore_antlr_state(&zzst); zzrv=1; zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) } +#define zzNON_GUESS_MODE if ( !zzguessing ) +#define zzGuessData \ + zzjmp_buf zzguess_start; \ + int zzguessing; +#else +#define zzGUESS_BLOCK +#define zzGUESS +#define zzGUESS_FAIL +#define zzGUESS_DONE +#define zzNON_GUESS_MODE +#define zzGuessData +#endif + +typedef struct _zzantlr_state { +#ifdef ZZCAN_GUESS + zzjmp_buf guess_start; + int guessing; +#endif + int asp; + int ast_sp; +#ifdef ZZINF_LOOK + int inf_lap; /* not sure we need to save this one */ + int inf_labase; + int inf_last; + +/* MR6 Gunnar Rxnning (gunnar@candleweb.no) */ +/* MR6 Additional state needs to be saved/restored */ +/* MR6 Matching changes in err.h */ + + int *inf_tokens; /* MR6 */ + char **inf_text; /* MR6 */ + char *inf_text_buffer; /* MR6 */ + int *inf_line; /* MR6 */ +#endif +#ifdef DEMAND_LOOK + int dirty; +#endif + +#ifdef LL_K + int tokenLA[LL_K]; + char textLA[LL_K][ZZLEXBUFSIZE]; + int lap; + int labase; +#else + int token; + char text[ZZLEXBUFSIZE]; +#endif +#ifdef zzTRACE_RULES + int traceOptionValue; /* MR10 */ + int traceGuessOptionValue; /* MR10 */ + char *traceCurrentRuleName; /* MR10 */ + int traceDepth; /* MR10 */ +#endif + + } zzantlr_state; + +#ifdef zzTRACE_RULES +extern int zzTraceOptionValueDefault; +extern int zzTraceOptionValue; +extern int zzTraceGuessOptionValue; +extern char *zzTraceCurrentRuleName; +extern int zzTraceDepth; +#endif + +extern int zzGuessSeq; /* MR10 */ +extern int zzSyntaxErrCount; /* MR11 */ +extern int zzLexErrCount; /* MR11 */ + + /* I n f i n i t e L o o k a h e a d */ + + +#ifdef ZZINF_LOOK +#define InfLookData \ + int *zzinf_tokens; \ + char **zzinf_text; \ + char *zzinf_text_buffer; \ + int *zzinf_line; \ + int zzinf_labase; \ + int zzinf_last; +#else +#define InfLookData +#endif + +#ifdef ZZINF_LOOK + +#ifndef ZZINF_DEF_TEXT_BUFFER_SIZE +#define ZZINF_DEF_TEXT_BUFFER_SIZE 20000 +#endif +#ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE +#define ZZINF_DEF_TOKEN_BUFFER_SIZE 2000 +#endif +/* WARNING!!!!!! + * ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token. + */ +#ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE +#define ZZINF_BUFFER_TEXT_CHUNK_SIZE 5000 +#endif +#ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE +#define ZZINF_BUFFER_TOKEN_CHUNK_SIZE 1000 +#endif + +#if ZZLEXBUFSIZE > ZZINF_BUFFER_TEXT_CHUNK_SIZE +#define ZZINF_BUFFER_TEXT_CHUNK_SIZE ZZLEXBUFSIZE+5 +#endif + +/* make inf_look user-access macros */ +#ifdef LL_K +#define ZZINF_LA_VALID(i) (((zzinf_labase+i-1)-LL_K+1) <= zzinf_last) +#define ZZINF_LA(i) zzinf_tokens[(zzinf_labase+i-1)-LL_K+1] +#define ZZINF_LATEXT(i) zzinf_text[(zzinf_labase+i-1)-LL_K+1] +/* MR6 In 1.33 vanilla the #define ZZINF_LINE(i) is was commented out */ +#define ZZINF_LINE(i) zzinf_line[(zzinf_labase+i-1)-LL_K+1] +#else +#define ZZINF_LA_VALID(i) (((zzinf_labase+i-1)) <= zzinf_last) +#define ZZINF_LA(i) zzinf_tokens[(zzinf_labase+i-1)] +#define ZZINF_LATEXT(i) zzinf_text[(zzinf_labase+i-1)] +#endif + +#define inf_zzgettok _inf_zzgettok() +extern void _inf_zzgettok(); + +#endif /* ZZINF_LOOK */ + + +#ifdef LL_K + +#ifdef __USE_PROTOS +#define ANTLR_INFO \ + Attrib zzempty_attr(void) {static Attrib a; return a;} \ + Attrib zzconstr_attr(int _tok, char *_text) \ + {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \ + int zzasp=ZZA_STACKSIZE; \ + char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \ + Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \ + InfLookData \ + zzGuessData +#else +#define ANTLR_INFO \ + Attrib zzempty_attr() {static Attrib a; return a;} \ + Attrib zzconstr_attr(_tok, _text) int _tok; char *_text; \ + {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \ + int zzasp=ZZA_STACKSIZE; \ + char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \ + Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \ + InfLookData \ + zzGuessData +#endif + +#else + +#ifdef __USE_PROTOS +#define ANTLR_INFO \ + Attrib zzempty_attr(void) {static Attrib a; return a;} \ + Attrib zzconstr_attr(int _tok, char *_text) \ + {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \ + int zzasp=ZZA_STACKSIZE; \ + char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \ + Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \ + InfLookData \ + zzGuessData +#else +#define ANTLR_INFO \ + Attrib zzempty_attr() {static Attrib a; return a;} \ + Attrib zzconstr_attr(_tok, _text) int _tok; char *_text; \ + {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \ + int zzasp=ZZA_STACKSIZE; \ + char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \ + Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \ + InfLookData \ + zzGuessData +#endif + +#endif /* LL_k */ + + +#ifdef ZZINF_LOOK + +#ifdef LL_K +#ifdef DEMAND_LOOK +#define zzPrimeLookAhead {zzdirty=LL_K; zzlap = zzlabase = 0;} +#else +#define zzPrimeLookAhead {zzlap = zzlabase = 0; zzfill_inf_look();\ + {int _i; for(_i=1;_i<=LL_K; _i++) \ + {zzCONSUME;} zzlap = zzlabase = 0;}} +#endif + +#else /* LL_K */ + +#ifdef DEMAND_LOOK +#define zzPrimeLookAhead zzfill_inf_look(); zzdirty=1 +#else +#define zzPrimeLookAhead zzfill_inf_look(); inf_zzgettok + +#endif +#endif /* LL_K */ + +#else /* ZZINF_LOOK */ + +#ifdef LL_K +#ifdef DEMAND_LOOK +#define zzPrimeLookAhead {zzdirty=LL_K; zzlap = zzlabase = 0;} +#else +#define zzPrimeLookAhead {int _i; zzlap = 0; for(_i=1;_i<=LL_K; _i++) \ + {zzCONSUME;} zzlap = 0;} +#endif + +#else + +#ifdef DEMAND_LOOK +#define zzPrimeLookAhead zzdirty=1 +#else +#define zzPrimeLookAhead zzgettok() +#endif +#endif /* LL_K */ + +#endif /* ZZINF_LOOK */ + + +#ifdef LL_K +#define zzenterANTLRs(s) \ + zzlextext = &(zztextLA[0][0]); zzrdstr( s ); zzPrimeLookAhead; +#define zzenterANTLRf(f) \ + zzlextext = &(zztextLA[0][0]); zzrdfunc( f ); zzPrimeLookAhead; +#define zzenterANTLR(f) \ + zzlextext = &(zztextLA[0][0]); zzrdstream( f ); zzPrimeLookAhead; +#ifdef ZZINF_LOOK +#define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line); +#define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line); +#define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line); +#else +#define zzleaveANTLR(f) +#define zzleaveANTLRf(f) +#define zzleaveANTLRs(f) +#endif + +#else + +#define zzenterANTLRs(s) \ + {static char zztoktext[ZZLEXBUFSIZE]; \ + zzlextext = zztoktext; zzrdstr( s ); zzPrimeLookAhead;} +#define zzenterANTLRf(f) \ + {static char zztoktext[ZZLEXBUFSIZE]; \ + zzlextext = zztoktext; zzrdfunc( f ); zzPrimeLookAhead;} +#define zzenterANTLR(f) \ + {static char zztoktext[ZZLEXBUFSIZE]; \ + zzlextext = zztoktext; zzrdstream( f ); zzPrimeLookAhead;} +#ifdef ZZINF_LOOK +#define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line); +#define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line); +#define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line); +#else +#define zzleaveANTLR(f) +#define zzleaveANTLRf(f) +#define zzleaveANTLRs(f) +#endif + +#endif + +/* MR19 Paul D. Smith (psmith@baynetworks.com) + Need to adjust AST stack pointer at exit. + Referenced in ANTLRx macros. +*/ + +#ifdef GENAST +#define ZZAST_ADJUST ++zzast_sp; +#else +#define ZZAST_ADJUST +#endif + +#define ANTLR(st, f) zzbufsize = ZZLEXBUFSIZE; \ + zzenterANTLR(f); \ + { \ + zzBLOCK(zztasp1); \ + st; /* ++zzasp; Removed MR20 G. Hobbelt */ \ + /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \ + /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \ + zzEXIT_ANTLR(zztasp1 + 1); \ + } \ + zzleaveANTLR(f); + +#define ANTLRm(st, f, _m) zzbufsize = ZZLEXBUFSIZE; \ + zzmode(_m); \ + zzenterANTLR(f); \ + { \ + zzBLOCK(zztasp1); \ + st; /* ++zzasp; Removed MR20 G. Hobbelt */ \ + /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \ + /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \ + zzEXIT_ANTLR(zztasp1 + 1); \ + } \ + zzleaveANTLR(f); + +#define ANTLRf(st, f) zzbufsize = ZZLEXBUFSIZE; \ + zzenterANTLRf(f); \ + { \ + zzBLOCK(zztasp1); \ + st; /* ++zzasp; Removed MR20 G. Hobbelt */ \ + /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \ + /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \ + zzEXIT_ANTLR(zztasp1 + 1); \ + } \ + zzleaveANTLRf(f); + +#define ANTLRs(st, s) zzbufsize = ZZLEXBUFSIZE; \ + zzenterANTLRs(s); \ + { \ + zzBLOCK(zztasp1); \ + st; /* ++zzasp; Removed MR20 G. Hobbelt */ \ + /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \ + /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \ + zzEXIT_ANTLR(zztasp1 + 1); \ + } \ + zzleaveANTLRs(s); + +#ifdef LL_K +#define zztext (&(zztextLA[zzlap][0])) +#else +#define zztext zzlextext +#endif + + + /* A r g u m e n t A c c e s s */ + +#define zzaCur (zzaStack[zzasp]) +#define zzaRet (*zzaRetPtr) +#define zzaArg(v,n) zzaStack[v-n] +#define zzMakeAttr { zzNON_GUESS_MODE {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}} +#ifdef zzdef0 +#define zzMake0 { zzOvfChk; --zzasp; zzdef0(&(zzaStack[zzasp]));} +#else +#define zzMake0 { zzOvfChk; --zzasp;} +#endif +#define zzaPush(_v) { zzOvfChk; zzaStack[--zzasp] = _v;} +#ifndef zzd_attr +#define zzREL(t) zzasp=(t); /* Restore state of stack */ +#else +#define zzREL(t) for (; zzasp<(t); zzasp++) \ + { zzd_attr(&(zzaStack[zzasp])); } +#endif + + +#define zzsetmatch(_es) \ + if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail; + +#ifdef ZZCAN_GUESS +#define zzsetmatch_wsig(_es, handler) \ + if ( !_zzsetmatch_wsig(_es) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;} +#else +#define zzsetmatch_wsig(_es, handler) \ + if ( !_zzsetmatch_wsig(_es) ) {_signal=MismatchedToken; goto handler;} +#endif + +#ifdef __USE_PROTOS +extern int _zzsetmatch(SetWordType *, char **, char **, int *, int *, SetWordType **); +extern int _zzsetmatch_wsig(SetWordType *); +#else +extern int _zzsetmatch(); +extern int _zzsetmatch_wsig(); +#endif + +#define zzmatch(_t) \ + if ( !_zzmatch(_t, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail; + +#ifdef ZZCAN_GUESS +#define zzmatch_wsig(_t,handler) \ + if ( !_zzmatch_wsig(_t) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;} +#else +#define zzmatch_wsig(_t,handler) \ + if ( !_zzmatch_wsig(_t) ) {_signal=MismatchedToken; goto handler;} +#endif + +#ifdef __USE_PROTOS +extern int _zzmatch(int, char **, char **, int *, int *, SetWordType **); +extern int _zzmatch_wsig(int); +#else +extern int _zzmatch(); +extern int _zzmatch_wsig(); +#endif + +#define zzmatch_wdfltsig(_t,_f) \ + if ( !_zzmatch_wdfltsig(_t,_f) ) _signal=MismatchedToken; +#define zzsetmatch_wdfltsig(tw,tt,wf) \ + if ( !_zzsetmatch_wdfltsig(tw,tt,wf) ) _signal=MismatchedToken; + +#ifdef __USE_PROTOS +extern int _zzmatch_wdfltsig(int, SetWordType *); +extern int _zzsetmatch_wdfltsig(SetWordType *tokensWanted, + int tokenTypeOfSet, + SetWordType *whatFollows); +#else +extern int _zzmatch_wdfltsig(); +extern int _zzsetmatch_wdfltsig(); +#endif + +#ifdef GENAST +#define zzRULE Attrib *zzaRetPtr = &(zzaStack[zzasp-1]); \ + SetWordType *zzMissSet=NULL; int zzMissTok=0; \ + int zzBadTok=0; char *zzBadText=""; \ + int zzErrk=1,zzpf=0; \ + zzTRACEdata \ + char *zzMissText=""; zzASTVars +#else +#define zzRULE Attrib *zzaRetPtr = &(zzaStack[zzasp-1]); \ + int zzBadTok=0; char *zzBadText=""; \ + int zzErrk=1,zzpf=0; \ + zzTRACEdata \ + SetWordType *zzMissSet=NULL; int zzMissTok=0; char *zzMissText="" +#endif + +#ifdef GENAST +#define zzBLOCK(i) int i = zzasp - 1; int zztsp = zzast_sp +#define zzEXIT(i) zzREL(i); zzastREL; zzNON_GUESS_MODE { zzastPush(*_root); } +#define zzEXIT_ANTLR(i) zzREL(i); zzastREL /* [i_a] added as we want this for the ANTLRx() macros */ +#define zzLOOP(i) zzREL(i); zzastREL +#else +#define zzBLOCK(i) int i = zzasp - 1 +#define zzEXIT(i) zzREL(i) +#define zzEXIT_ANTLR(i) zzREL(i) /* [i_a] added as we want this for the ANTLRx() macros */ +#define zzLOOP(i) zzREL(i) +#endif + +#ifdef LL_K + +#ifdef DEMAND_LOOK +#define LOOK(_k) {int i,stop=_k-(LL_K-zzdirty); for (i=1; i<=stop; i++) \ + zzCONSUME;} +#define zzCONSUME {zzgettok(); zzdirty--; \ + zzlap = (zzlap+1)&(LL_K-1); \ + zzlextext = &(zztextLA[zzlap][0]);} +#else +#ifdef ZZINF_LOOK +#define zzCONSUME {inf_zzgettok; \ + zzlap = (zzlap+1)&(LL_K-1); \ + zzlextext = &(zztextLA[zzlap][0]); \ + } +#else +#define zzCONSUME {zzgettok(); \ + zzlap = (zzlap+1)&(LL_K-1); \ + zzlextext = &(zztextLA[zzlap][0]);} +#endif /* ZZINF_LOOK */ +#endif /* DEMAND_LOOK */ + +#else /* LL_K */ + +#ifdef DEMAND_LOOK +#define LOOK(_k) if ( zzdirty) zzCONSUME; +#ifdef ZZINF_LOOK +#define zzCONSUME inf_zzgettok; zzdirty=0; +#else +#define zzCONSUME zzgettok(); zzdirty=0; +#endif /* ZZINF_LOOK */ + +#else /* DEMAND_LOOK */ + +#ifdef ZZINF_LOOK +#define zzCONSUME inf_zzgettok +#else +#define zzCONSUME zzgettok(); +#endif + +#endif /* DEMAND_LOOK */ + +#endif /* LL_K */ + +#ifdef LL_K +#define NLA zztokenLA[zzlap&(LL_K-1)] /* --> next LA */ +#define NLATEXT zztextLA[zzlap&(LL_K-1)] /* --> next text of LA */ +#ifdef DEMAND_LOOK +#define LA(i) zztokenLA[(zzlabase+(i)-1)&(LL_K-1)] +#define LATEXT(i) (&(zztextLA[(zzlabase+(i)-1)&(LL_K-1)][0])) +#else +#define LA(i) zztokenLA[(zzlap+(i)-1)&(LL_K-1)] +#define LATEXT(i) (&(zztextLA[(zzlap+(i)-1)&(LL_K-1)][0])) +#endif +#else +#define NLA zztoken +#define NLATEXT zztext +#define LA(i) zztoken +#define LATEXT(i) zztext +#endif + + + /* S t a n d a r d S i g n a l s */ + +#define NoSignal 0 +#define MismatchedToken 1 +#define NoViableAlt 2 +#define NoSemViableAlt 3 + +/* MR7 Allow more control over signalling */ +/* by adding "Unwind" and "zzsetSignal" */ + +#define Unwind 4 +#define zzsetSignal(newValue) *_retsignal=_signal=(newValue) +#define zzsuppressSignal *_retsignal=_signal=0 +#define zzexportSignal *_retsignal=_signal + + /* F u n c t i o n T r a c i n g */ + +#ifndef zzTRACE_RULES +#define zzTRACEdata +#else +#ifndef zzTRACEdata +#define zzTRACEdata ANTLRChar *zzTracePrevRuleName = NULL; +#endif +#endif + +#ifndef zzTRACEIN +#define zzTRACEIN(r) zzTracePrevRuleName=zzTraceCurrentRuleName;zzTraceIn(r); +#endif +#ifndef zzTRACEOUT +#define zzTRACEOUT(r) zzTraceOut(r);zzTraceCurrentRuleName=zzTracePrevRuleName; +#endif + +/* MR19 zzchar_t additions */ + +#ifndef zzchar_t +#ifdef ZZWCHAR_T +#define zzchar_t wchar_t +#else +#define zzchar_t char +#endif +#endif + + /* E x t e r n D e f s */ + +#ifdef __USE_PROTOS +extern Attrib zzempty_attr(void); +extern Attrib zzconstr_attr(int, char *); +extern void zzsyn(char *, int, char *, SetWordType *, int, int, char *); +extern int zzset_el(unsigned, SetWordType *); +extern int zzset_deg(SetWordType *); +extern void zzedecode(SetWordType *); +extern void zzFAIL(int k, ...); +extern void zzresynch(SetWordType *, SetWordType); +extern void zzsave_antlr_state(zzantlr_state *); +extern void zzrestore_antlr_state(zzantlr_state *); +extern void zzfill_inf_look(void); +extern void zzconsumeUntil(SetWordType *st); /* MR7 */ +extern void zzconsumeUntilToken(int t); /* MR7 */ +extern void zzTraceIn(char * ruleName); /* MR10 */ +extern void zzTraceOut(char * ruleName); /* MR10 */ +extern int zzTraceOption(int delta); /* MR10 */ +extern int zzTraceGuessOption(int delta); /* MR10 */ +extern void zzTraceReset(void); /* MR10 */ +extern void zzTraceGuessFail(void); /* MR10 */ +#ifdef EXCEPTION_HANDLING +extern void zzdflthandlers(int, int *); +#endif +#else +extern Attrib zzempty_attr(); +extern Attrib zzconstr_attr(); +extern void zzsyn(); +extern int zzset_el(); +extern int zzset_deg(); +extern void zzedecode(); +extern void zzFAIL(); +extern void zzresynch(); +extern void zzsave_antlr_state(); +extern void zzrestore_antlr_state(); +extern void zzfill_inf_look(); +extern void zzconsumeUntil(); /* MR7 */ +extern void zzconsumeUntilToken(); /* MR7 */ +extern void zzTraceIn(); /* MR10 */ +extern void zzTraceOut(); /* MR10 */ +extern int zzTraceOption(); /* MR10 */ +extern int zzTraceGuessOption(); /* MR10 */ +extern void zzTraceReset(); /* MR10 */ +extern void zzTraceGuessFail(); /* MR10 */ +#ifdef EXCEPTION_HANDLING +extern void zzdflthandlers(); +#endif +#endif + + /* G l o b a l V a r i a b l e s */ + +/* Define a parser; user should do a "#parser myname" in their grammar file */ +/*extern struct pccts_parser zzparser;*/ + +extern char *zztokens[]; +#ifdef LL_K +extern int zztokenLA[]; +extern zzchar_t zztextLA[][ZZLEXBUFSIZE]; +extern int zzlap; +extern int zzlabase; +#else +extern int zztoken; +#endif + +extern char zzStackOvfMsg[]; +extern int zzasp; +extern Attrib zzaStack[]; +#ifdef ZZINF_LOOK +extern int *zzinf_tokens; +extern char **zzinf_text; +extern char *zzinf_text_buffer; +extern int *zzinf_line; +extern int zzinf_labase; +extern int zzinf_last; +#endif +#ifdef DEMAND_LOOK +extern int zzdirty; +#endif +#ifdef ZZCAN_GUESS +extern int zzguessing; +extern zzjmp_buf zzguess_start; +#endif + +/* Define global veriables that refer to values exported by the scanner. + * These declarations duplicate those in dlgdef.h, but are needed + * if ANTLR is not to generate a .dlg file (-gx); PS, this is a hack. + */ +extern zzchar_t *zzlextext; /* text of most recently matched token */ +extern int zzbufsize; /* how long zzlextext is */ + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c new file mode 100644 index 0000000000..58db285d89 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.c @@ -0,0 +1,345 @@ +/* Abstract syntax tree manipulation functions + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#include "pcctscfg.h" + +#ifdef PCCTS_USE_STDARG +#include "pccts_stdarg.h" +#else +#include +#endif + +/* ensure that tree manipulation variables are current after a rule + * reference + */ + +void +#ifdef __USE_PROTOS +zzlink(AST **_root, AST **_sibling, AST **_tail) +#else +zzlink(_root, _sibling, _tail) +AST **_root, **_sibling, **_tail; +#endif +{ + if ( *_sibling == NULL ) return; + if ( *_root == NULL ) *_root = *_sibling; + else if ( *_root != *_sibling ) (*_root)->down = *_sibling; + if ( *_tail==NULL ) *_tail = *_sibling; + while ( (*_tail)->right != NULL ) *_tail = (*_tail)->right; +} + +AST * +#ifdef __USE_PROTOS +zzastnew(void) +#else +zzastnew() +#endif +{ + AST *p = (AST *) calloc(1, sizeof(AST)); + if ( p == NULL ) fprintf(stderr,"%s(%d): cannot allocate AST node\n",__FILE__,__LINE__); + return p; +} + +/* add a child node to the current sibling list */ +void +#ifdef __USE_PROTOS +zzsubchild(AST **_root, AST **_sibling, AST **_tail) +#else +zzsubchild(_root, _sibling, _tail) +AST **_root, **_sibling, **_tail; +#endif +{ + AST *n; + zzNON_GUESS_MODE { + n = zzastnew(); +#ifdef DEMAND_LOOK + zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0)); +#else + zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1)); +#endif + zzastPush( n ); + if ( *_tail != NULL ) (*_tail)->right = n; + else { + *_sibling = n; + if ( *_root != NULL ) (*_root)->down = *_sibling; + } + *_tail = n; + if ( *_root == NULL ) *_root = *_sibling; + } +} + +/* make a new AST node. Make the newly-created + * node the root for the current sibling list. If a root node already + * exists, make the newly-created node the root of the current root. + */ +void +#ifdef __USE_PROTOS +zzsubroot(AST **_root, AST **_sibling, AST **_tail) +#else +zzsubroot(_root, _sibling, _tail) +AST **_root, **_sibling, **_tail; +#endif +{ + AST *n; + zzNON_GUESS_MODE { + n = zzastnew(); +#ifdef DEMAND_LOOK + zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0)); +#else + zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1)); +#endif + zzastPush( n ); + if ( *_root != NULL ) + if ( (*_root)->down == *_sibling ) *_sibling = *_tail = *_root; + *_root = n; + (*_root)->down = *_sibling; + } +} + +/* Apply function to root then each sibling + * example: print tree in child-sibling LISP-format (AST has token field) + * + * void show(tree) + * AST *tree; + * { + * if ( tree == NULL ) return; + * printf(" %s", zztokens[tree->token]); + * } + * + * void before() { printf(" ("); } + * void after() { printf(" )"); } + * + * LISPdump() { zzpre_ast(tree, show, before, after); } + * + */ +void +#ifdef __USE_PROTOS +zzpre_ast( + AST *tree, + void (*func)(AST *), /* apply this to each tree node */ + void (*before)(AST *), /* apply this to root of subtree before preordering it */ + void (*after)(AST *)) /* apply this to root of subtree after preordering it */ +#else +zzpre_ast(tree, func, before, after) +AST *tree; +void (*func)(), /* apply this to each tree node */ + (*before)(), /* apply this to root of subtree before preordering it */ + (*after)(); /* apply this to root of subtree after preordering it */ +#endif +{ + while ( tree!= NULL ) + { + if ( tree->down != NULL ) (*before)(tree); + (*func)(tree); + zzpre_ast(tree->down, func, before, after); + if ( tree->down != NULL ) (*after)(tree); + tree = tree->right; + } +} + +/* free all AST nodes in tree; apply func to each before freeing */ + +#if 0 +////void +////#ifdef __USE_PROTOS +////zzfree_ast(AST *tree) +////#else +////zzfree_ast(tree) +////AST *tree; +////#endif +////{ +//// if ( tree == NULL ) return; +//// zzfree_ast( tree->down ); +//// zzfree_ast( tree->right ); +//// zztfree( tree ); +////} +#endif + +/* + MR19 Optimize freeing of the following structure to limit recursion + SAKAI Kiyotaka (ksakai@isr.co.jp) +*/ + +/* + NULL o + / \ + NULL o + / \ + NULL NULL +*/ + +/* + MR21 Another refinement to replace recursion with iteration + NAKAJIMA Mutsuki (muc@isr.co.jp). +*/ + +void +#ifdef __USE_PROTOS +zzfree_ast(AST *tree) +#else +zzfree_ast(tree) +AST *tree; +#endif +{ + + AST *otree; + + if (tree == NULL) return; + + while (tree->down == NULL || tree->right == NULL) { + + if (tree->down == NULL && tree->right == NULL) { + zztfree(tree); + return; + } + + otree = tree; + if (tree->down == NULL) { + tree = tree->right; + } else { + tree = tree->down; + } + zztfree( otree ); + } + + while (tree != NULL) { + zzfree_ast(tree->down); + otree = tree; + tree = otree->right; + zztfree(otree); + } +} + +/* build a tree (root child1 child2 ... NULL) + * If root is NULL, simply make the children siblings and return ptr + * to 1st sibling (child1). If root is not single node, return NULL. + * + * Siblings that are actually siblins lists themselves are handled + * correctly. For example #( NULL, #( NULL, A, B, C), D) results + * in the tree ( NULL A B C D ). + * + * Requires at least two parameters with the last one being NULL. If + * both are NULL, return NULL. + */ +#ifdef PCCTS_USE_STDARG +AST *zztmake(AST *rt, ...) +#else +AST *zztmake(va_alist) +va_dcl +#endif +{ + va_list ap; + register AST *child, *sibling=NULL, *tail=NULL /* MR20 */, *w; + AST *root; + +#ifdef PCCTS_USE_STDARG + va_start(ap, rt); + root = rt; +#else + va_start(ap); + root = va_arg(ap, AST *); +#endif + + if ( root != NULL ) + if ( root->down != NULL ) return NULL; + child = va_arg(ap, AST *); + while ( child != NULL ) + { + for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */ + if ( sibling == NULL ) {sibling = child; tail = w;} + else {tail->right = child; tail = w;} + child = va_arg(ap, AST *); + } + if ( root==NULL ) root = sibling; + else root->down = sibling; + va_end(ap); + return root; +} + +/* tree duplicate */ +AST * +#ifdef __USE_PROTOS +zzdup_ast(AST *t) +#else +zzdup_ast(t) +AST *t; +#endif +{ + AST *u; + + if ( t == NULL ) return NULL; + u = zzastnew(); + *u = *t; +#ifdef zzAST_DOUBLE + u->up = NULL; /* set by calling invocation */ + u->left = NULL; +#endif + u->right = zzdup_ast(t->right); + u->down = zzdup_ast(t->down); +#ifdef zzAST_DOUBLE + if ( u->right!=NULL ) u->right->left = u; + if ( u->down!=NULL ) u->down->up = u; +#endif + return u; +} + +void +#ifdef __USE_PROTOS +zztfree(AST *t) +#else +zztfree(t) +AST *t; +#endif +{ +#ifdef zzd_ast + zzd_ast( t ); +#endif + free( t ); +} + +#ifdef zzAST_DOUBLE +/* + * Set the 'up', and 'left' pointers of all nodes in 't'. + * Initial call is double_link(your_tree, NULL, NULL). + */ +void +#ifdef __USE_PROTOS +zzdouble_link(AST *t, AST *left, AST *up) +#else +zzdouble_link(t, left, up) +AST *t, *left, *up; +#endif +{ + if ( t==NULL ) return; + t->left = left; + t->up = up; + zzdouble_link(t->down, NULL, t); + zzdouble_link(t->right, t, up); +} +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h new file mode 100644 index 0000000000..dba8be25c5 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ast.h @@ -0,0 +1,115 @@ +/* Abstract syntax tree + * + * Macros, definitions + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ZZAST_H +#define ZZAST_H + +#define zzastOvfChk \ + if ( zzast_sp <= 0 ) \ + { \ + fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__); \ + exit(PCCTS_EXIT_FAILURE); \ + } + +#ifndef USER_DEFINED_AST +#ifndef AST_FIELDS +#define AST_FIELDS +#endif + +typedef struct _ast { + struct _ast *right, *down; +#ifdef zzAST_DOUBLE + struct _ast *left, *up; +#endif + AST_FIELDS +} AST; + +#else + +#ifdef zzAST_DOUBLE +#define AST_REQUIRED_FIELDS struct _ast *right, *down, *left, *up; +#else +#define AST_REQUIRED_FIELDS struct _ast *right, *down; +#endif + +#endif + + +/* N o d e a c c e s s m a c r o s */ +#define zzchild(t) (((t)==NULL)? (AST *) NULL:(t->down)) /* MR19 */ +#define zzsibling(t) (((t)==NULL)? (AST *) NULL:(t->right)) /* MR19 */ + + +/* define global variables needed by #i stack */ +#define zzASTgvars \ + AST *zzastStack[ZZAST_STACKSIZE]; \ + int zzast_sp = ZZAST_STACKSIZE; + +#define zzASTVars AST *_ast = NULL, *_sibling = NULL, *_tail = NULL +#define zzSTR ( (_tail==NULL)?(&_sibling):(&(_tail->right)) ) +#define zzastCur (zzastStack[zzast_sp]) +#define zzastArg(i) (zzastStack[zztsp-i]) +#define zzastPush(p) zzastOvfChk; zzastStack[--zzast_sp] = p; +#define zzastDPush --zzast_sp +#define zzastMARK zztsp=zzast_sp; /* Save state of stack */ +#define zzastREL zzast_sp=zztsp; /* Return state of stack */ +#define zzrm_ast {zzfree_ast(*_root); _tail = _sibling = (*_root)=NULL;} + +extern int zzast_sp; +extern AST *zzastStack[]; + +#ifdef __USE_PROTOS +void zzlink(AST **, AST **, AST **); +void zzsubchild(AST **, AST **, AST **); +void zzsubroot(AST **, AST **, AST **); +void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *)); +void zzfree_ast(AST *); +AST *zztmake(AST *, ...); +AST *zzdup_ast(AST *); +void zztfree(AST *); +void zzdouble_link(AST *, AST *, AST *); +AST *zzastnew(void); + +#else + +void zzlink(); +AST *zzastnew(); +void zzsubchild(); +void zzsubroot(); +void zzpre_ast(); +void zzfree_ast(); +AST *zztmake(); +AST *zzdup_ast(); +void zztfree(); +void zzdouble_link(); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h new file mode 100644 index 0000000000..874e37a297 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charbuf.h @@ -0,0 +1,46 @@ +/* ANTLR attribute definition -- constant width text + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ZZCHARBUF_H +#define ZZCHARBUF_H + +#include "pcctscfg.h" + +#include "pccts_string.h" + +#ifndef D_TextSize +#define D_TextSize 30 +#endif + +typedef struct { char text[D_TextSize]; } Attrib; + +#define zzcr_attr(a,tok,t) strncpy((a)->text, t, D_TextSize-1); \ + (a)->text[D_TextSize-1] = '\0'; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c new file mode 100644 index 0000000000..930c5df667 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.c @@ -0,0 +1,58 @@ +/* + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#include "pcctscfg.h" + +#ifdef __STDC__ +#include "pccts_stdlib.h" +#else +#include +#endif +#include "pccts_string.h" + +/* 133MR1 include stdio.h for fprintf in charptr.c */ + +#include "pccts_stdio.h" + +/* 133MR1 include charptr.h for Attrib in charptr.c */ + +#include "charptr.h" + +#ifdef __USE_PROTOS +zzcr_attr(Attrib *a,int token,char *text) +#else +zzcr_attr(a,token,text) +Attrib *a; +int token; +char *text; +#endif +{ + *a = (char *) malloc(strlen(text)+1); /* MR6 */ + if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);} + strcpy(*a, text); +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h new file mode 100644 index 0000000000..3e92b05c0e --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/charptr.h @@ -0,0 +1,48 @@ +/* + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +/* + * WARNING!!!!: charptr.h does NOT make copies and the + * memory is freed after the attribute scope exits. + */ + +#ifndef ZZCHARPTR_H +#define ZZCHARPTR_H + +typedef char *Attrib; +#define zzdef0(a) {*(a)=NULL;} +/* MR8 Jens Tingleff (jensting@imaginet.fr) */ +/* Set memory pointer to null after free() */ +#define zzd_attr(a) {if ( *(a)!=NULL ) {free(*(a)); *(a)=NULL; }; } + +#ifdef __STDC__ +extern zzcr_attr(Attrib *,int,char *); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h new file mode 100644 index 0000000000..8aa50ad618 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/config.h @@ -0,0 +1 @@ +#include "pcctscfg.h" diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h new file mode 100644 index 0000000000..41881e929d --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/dlgauto.h @@ -0,0 +1,499 @@ +/* dlgauto.h automaton + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Will Cohen and Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ZZDEFAUTO_H +#define ZZDEFAUTO_H + +/* 10-Apr-97 133MR1 Uses __USE_PROTOS show should #include pcctscfg.h */ + +#include "pcctscfg.h" + +zzchar_t *zzlextext; /* text of most recently matched token */ +zzchar_t *zzbegexpr; /* beginning of last reg expr recogn. */ +zzchar_t *zzendexpr; /* beginning of last reg expr recogn. */ +int zzbufsize = 0; /* number of characters in zzlextext */ /* MR7 */ +int zzbegcol = 0; /* column that first character of token is in*/ +int zzendcol = 0; /* column that last character of token is in */ +int zzline = 1; /* line current token is on */ +int zzreal_line=1; /* line of 1st portion of token that is not skipped */ +int zzchar; /* character to determine next state */ +int zzbufovf; /* indicates that buffer too small for text */ +int zzcharfull = 0; +static zzchar_t *zznextpos;/* points to next available position in zzlextext*/ +static int zzclass; + +#ifdef __USE_PROTOS +void zzerrstd(const char *); +void (*zzerr)(const char *)=zzerrstd;/* pointer to error reporting function */ +extern int zzerr_in(void); +static int (*zzfunc_in)(void) = zzerr_in; /* MR20 */ +#else +void zzerrstd(); +void (*zzerr)()=zzerrstd; /* pointer to error reporting function */ +extern int zzerr_in(); +static int (*zzfunc_in)() = zzerr_in; /* MR20 */ +#endif + +static FILE *zzstream_in=0; +static zzchar_t *zzstr_in=0; + +#ifdef USER_ZZMODE_STACK +int zzauto = 0; +#else +static int zzauto = 0; +#endif +static int zzadd_erase; +static char zzebuf[70]; + +#ifdef ZZCOL +#define ZZINC (++zzendcol) +#else +#define ZZINC +#endif + + +#define ZZGETC_STREAM {zzchar = getc(zzstream_in); zzclass = ZZSHIFT(zzchar);} +#define ZZGETC_FUNC {zzchar = (*zzfunc_in)(); zzclass = ZZSHIFT(zzchar);} +#define ZZGETC_STR { \ + if (*zzstr_in){ \ + zzchar = *zzstr_in; \ + ++zzstr_in; \ + }else{ \ + zzchar = EOF; \ + } \ + zzclass = ZZSHIFT(zzchar); \ +} + +#define ZZNEWSTATE (newstate = dfa[state][zzclass]) + +#ifndef ZZCOPY +#define ZZCOPY \ + /* Truncate matching buffer to size (not an error) */ \ + if (zznextpos < lastpos){ \ + *(zznextpos++) = zzchar; \ + }else{ \ + zzbufovf = 1; \ + } +#endif + +void +#ifdef __USE_PROTOS +zzrdstream( FILE *f ) +#else +zzrdstream( f ) +FILE *f; +#endif +{ + /* make sure that it is really set to something, otherwise just + leave it be. + */ + if (f){ + /* make sure that there is always someplace to get input + before closing zzstream_in + */ +#if 0 + if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in ); +#endif + zzline = 1; + zzstream_in = f; + zzfunc_in = NULL; + zzstr_in = 0; + zzcharfull = 0; + } +} + +void +#ifdef __USE_PROTOS +zzrdfunc( int (*f)(void) ) +#else +zzrdfunc( f ) +int (*f)(); +#endif +{ + /* make sure that it is really set to something, otherwise just + leave it be. + */ + if (f){ + /* make sure that there is always someplace to get input + before closing zzstream_in + */ +#if 0 + if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in ); +#endif + zzline = 1; + zzstream_in = NULL; + zzfunc_in = f; + zzstr_in = 0; + zzcharfull = 0; + } +} + + +void +#ifdef __USE_PROTOS +zzrdstr( zzchar_t *s ) +#else +zzrdstr( s ) +zzchar_t *s; +#endif +{ + /* make sure that it is really set to something, otherwise just + leave it be. + */ + if (s){ + /* make sure that there is always someplace to get input + before closing zzstream_in + */ +#if 0 + if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in ); +#endif + zzline = 1; + zzstream_in = NULL; + zzfunc_in = 0; + zzstr_in = s; + zzcharfull = 0; + } +} + + +#ifdef __USE_PROTOS +void zzclose_stream(void) +#else +void zzclose_stream() +#endif +{ +#if 0 + fclose( zzstream_in ); + zzstream_in = NULL; + zzfunc_in = NULL; +#endif +} + +/* saves dlg state, but not what feeds dlg (such as file position) */ +void +#ifdef __USE_PROTOS +zzsave_dlg_state(struct zzdlg_state *state) +#else +zzsave_dlg_state(state) +struct zzdlg_state *state; +#endif +{ + state->stream = zzstream_in; + state->func_ptr = zzfunc_in; + state->str = zzstr_in; + state->auto_num = zzauto; + state->add_erase = zzadd_erase; + state->lookc = zzchar; + state->char_full = zzcharfull; + state->begcol = zzbegcol; + state->endcol = zzendcol; + state->line = zzline; + state->lextext = zzlextext; + state->begexpr = zzbegexpr; + state->endexpr = zzendexpr; + state->bufsize = zzbufsize; + state->bufovf = zzbufovf; + state->nextpos = zznextpos; + state->class_num = zzclass; +} + +void +#ifdef __USE_PROTOS +zzrestore_dlg_state(struct zzdlg_state *state) +#else +zzrestore_dlg_state(state) +struct zzdlg_state *state; +#endif +{ + zzstream_in = state->stream; + zzfunc_in = state->func_ptr; + zzstr_in = state->str; + zzauto = state->auto_num; + zzadd_erase = state->add_erase; + zzchar = state->lookc; + zzcharfull = state->char_full; + zzbegcol = state->begcol; + zzendcol = state->endcol; + zzline = state->line; + zzlextext = state->lextext; + zzbegexpr = state->begexpr; + zzendexpr = state->endexpr; + zzbufsize = state->bufsize; + zzbufovf = state->bufovf; + zznextpos = state->nextpos; + zzclass = state->class_num; +} + +void +#ifdef __USE_PROTOS +zzmode( int m ) +#else +zzmode( m ) +int m; +#endif +{ + /* points to base of dfa table */ + if (m +#include + +/* */ +/* 7-Apr-97 133MR1 */ +/* Proper choice of STDC and cplusplus pre-processor symbols (?) */ +/* */ +#include "pccts_string.h" + +#ifdef PCCTS_USE_STDARG +#include "pccts_stdarg.h" +#else +#include +#endif + +#ifdef DUM +/* Define usable bits per unsigned int word (used for set stuff) */ +#ifdef PC +#define BSETWORDSIZE 16 +#define BSETLOGWORDSIZE 4 +#else +#define BSETWORDSIZE 32 +#define BSETLOGWORDSIZE 5 +#endif +#endif + +#define BSETWORDSIZE 8 +#define BSETLOGWORDSIZE 3 /* SetWordType is 8bits */ + +#define BSETMODWORD(x) ((x) & (BSETWORDSIZE-1)) /* x % BSETWORDSIZE */ +#define BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE) /* x / BSETWORDSIZE */ + +/* This is not put into the global pccts_parser structure because it is + * hidden and does not need to be saved during a "save state" operation + */ +/* maximum of 32 bits/unsigned int and must be 8 bits/byte */ +static SetWordType bitmask[] = { + 0x00000001, 0x00000002, 0x00000004, 0x00000008, + 0x00000010, 0x00000020, 0x00000040, 0x00000080 +}; + +#ifdef zzTRACE_RULES +int zzTraceOptionValueDefault=1; +int zzTraceOptionValue=1; +int zzTraceGuessOptionValue=1; +char *zzTraceCurrentRuleName=NULL; +int zzTraceDepth=0; +#endif + +int zzGuessSeq=0; /* MR10 */ +int zzSyntaxErrCount=0; /* MR11 */ +int zzLexErrCount=0; /* MR11 */ + +void +#ifdef __USE_PROTOS +zzresynch(SetWordType *wd,SetWordType mask) +#else +zzresynch(wd,mask) +SetWordType *wd, mask; +#endif +{ + static int consumed = 1; + + /* if you enter here without having consumed a token from last resynch + * force a token consumption. + */ + if ( !consumed ) {zzCONSUME; consumed=1; return;} /* MR10 */ + + /* if current token is in resynch set, we've got what we wanted */ + if ( wd[LA(1)]&mask || LA(1) == zzEOF_TOKEN ) {consumed=0; return;} + + /* scan until we find something in the resynch set */ + while ( !(wd[LA(1)]&mask) && LA(1) != zzEOF_TOKEN ) {zzCONSUME;} + consumed=1; +} + +/* */ +/* 7-Apr-97 133MR1 for C++ and MR7 for C */ +/* Change suggested by Eli Sternheim (eli@interhdl.com) */ +/* */ + +void +#ifdef __USE_PROTOS +zzconsumeUntil(SetWordType *st) +#else +zzconsumeUntil(st) +SetWordType *st; +#endif +{ + int tmp; /* MR7 */ + while ( !zzset_el( (tmp=LA(1)), st) && tmp!=1 /* Eof */) { /* MR7 */ + zzCONSUME; } /* MR7 */ +} + +/* */ +/* 7-Apr-97 133MR1 for C++ and MR7 for C */ +/* Change suggested by Eli Sternheim (eli@interhdl.com) */ +/* */ + +void +#ifdef __USE_PROTOS +zzconsumeUntilToken(int t) +#else +zzconsumeUntilToken(t) +int t; +#endif +{ + int tmp; /* MR7 */ + while ( (tmp=LA(1)) !=t && tmp!=1 /* Eof */) { zzCONSUME; } /* MR7 */ +} + +/* input looks like: + * zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText) + * where the zzMiss stuff is set here to the token that did not match + * (and which set wasn't it a member of). + */ + +#ifdef PCCTS_USE_STDARG +void zzFAIL(int k, ...) +#else +void zzFAIL(va_alist) +va_dcl +#endif +{ +#ifdef LL_K + static char text[LL_K*ZZLEXBUFSIZE+1]; + SetWordType *f[LL_K]; +#else + static char text[ZZLEXBUFSIZE+1]; + SetWordType *f[1]; +#endif + SetWordType **miss_set; + char **miss_text; + int *bad_tok; + char **bad_text; + int *err_k; + int i; + va_list ap; +#ifndef PCCTS_USE_STDARG /* MR20 */ + int k; +#endif +#ifdef PCCTS_USE_STDARG /* MR20 */ + va_start(ap, k); +#else + va_start(ap); + k = va_arg(ap, int); /* how many lookahead sets? */ +#endif + assert(k <= sizeof(f)/sizeof(f[0])); /* MR20 G. Hobbelt */ + text[0] = '\0'; + for (i=1; i<=k; i++) /* collect all lookahead sets */ + { + f[i-1] = va_arg(ap, SetWordType *); + } + for (i=1; i<=k; i++) /* look for offending token */ + { + if ( i>1 ) strcat(text, " "); + strcat(text, LATEXT(i)); + if ( !zzset_el((unsigned)LA(i), f[i-1]) ) break; + } + miss_set = va_arg(ap, SetWordType **); + miss_text = va_arg(ap, char **); + bad_tok = va_arg(ap, int *); + bad_text = va_arg(ap, char **); + err_k = va_arg(ap, int *); + if ( i>k ) + { + /* bad; lookahead is permutation that cannot be matched, + * but, the ith token of lookahead is valid at the ith position + * (The old LL sub 1 (k) versus LL(k) parsing technique) + */ + *miss_set = NULL; + *miss_text = zzlextext; + *bad_tok = LA(1); + *bad_text = LATEXT(1); + *err_k = k; + return; + } +/* fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/ + *miss_set = f[i-1]; + *miss_text = text; + *bad_tok = LA(i); + *bad_text = LATEXT(i); + if ( i==1 ) *err_k = 1; + else *err_k = k; +} + +#ifdef __USE_PROTOS +void zzTraceGuessDone(zzantlr_state *state) +#else +void zzTraceGuessDone(state) + zzantlr_state *state; +#endif +{ +#ifdef zzTRACE_RULES +#ifdef ZZCAN_GUESS + + int doIt=0; + + if (zzTraceCurrentRuleName == NULL) return; + + if (zzTraceOptionValue <= 0) { + doIt=0; + } else if (zzTraceGuessOptionValue <= 0) { + doIt=0; + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d", + state->traceCurrentRuleName, + LATEXT(1), + state->traceDepth); + if (state->guessing != 0) { + fprintf(stderr," (guess mode continues - an enclosing guess is still active)"); + } else { + fprintf(stderr," (guess mode ends)"); + }; + fprintf(stderr,"\n"); + }; +#endif +#endif +} + +void +#ifdef __USE_PROTOS +zzsave_antlr_state(zzantlr_state *buf) +#else +zzsave_antlr_state(buf) +zzantlr_state *buf; +#endif +{ +#ifdef LL_K + int i; +#endif + +#ifdef ZZCAN_GUESS + buf->guess_start = zzguess_start; + buf->guessing = zzguessing; +#endif + buf->asp = zzasp; +#ifdef GENAST + buf->ast_sp = zzast_sp; +#endif +#ifdef ZZINF_LOOK + buf->inf_labase = zzinf_labase; + buf->inf_last = zzinf_last; + +/* MR6 Gunnar Rxnning (gunnar@candleweb.no) */ +/* MR6 Additional state needs to be saved/restored */ + + buf->inf_tokens = zzinf_tokens; /* MR6 */ + buf->inf_text = zzinf_text; /* MR6 */ + buf->inf_text_buffer = zzinf_text_buffer; /* MR6 */ + buf->inf_line = zzinf_line; /* MR6 */ + +#endif +#ifdef DEMAND_LOOK + buf->dirty = zzdirty; +#endif +#ifdef LL_K + for (i=0; itokenLA[i] = zztokenLA[i]; + for (i=0; itextLA[i], zztextLA[i]); + buf->lap = zzlap; + buf->labase = zzlabase; +#else + buf->token = zztoken; + strcpy(buf->text, zzlextext); +#endif +#ifdef zzTRACE_RULES + + /* MR10 */ + + buf->traceOptionValue=zzTraceOptionValue; + buf->traceGuessOptionValue=zzTraceGuessOptionValue; + buf->traceCurrentRuleName=zzTraceCurrentRuleName; + buf->traceDepth=zzTraceDepth; +#endif +} + +void +#ifdef __USE_PROTOS +zzrestore_antlr_state(zzantlr_state *buf) +#else +zzrestore_antlr_state(buf) +zzantlr_state *buf; +#endif +{ + +#ifdef zzTRACE_RULES + int prevTraceOptionValue; +#endif + +#ifdef LL_K + int i; +#endif + +#ifdef ZZCAN_GUESS + zzguess_start = buf->guess_start; + zzguessing = buf->guessing; +#endif + zzasp = buf->asp; +#ifdef GENAST + zzast_sp = buf->ast_sp; +#endif +#ifdef ZZINF_LOOK + zzinf_labase = buf->inf_labase; + zzinf_last = buf->inf_last; + +/* MR6 Gunnar Rxnning (gunnar@candleweb.no) */ +/* MR6 Additional state needs to be saved/restored */ + + zzinf_tokens = buf->inf_tokens; /* MR6 */ + zzinf_text = buf->inf_text; /* MR6 */ + zzinf_text_buffer = buf->inf_text_buffer; /* MR6 */ + zzinf_line = buf->inf_line; /* MR6 */ +#endif +#ifdef DEMAND_LOOK + zzdirty = buf->dirty; +#endif +#ifdef LL_K + for (i=0; itokenLA[i]; + for (i=0; itextLA[i]); + zzlap = buf->lap; + zzlabase = buf->labase; +#else + zztoken = buf->token; + strcpy(zzlextext, buf->text); +#endif +#ifdef zzTRACE_RULES + + prevTraceOptionValue=zzTraceOptionValue; + zzTraceOptionValue=buf->traceOptionValue; + if ( (prevTraceOptionValue > 0) != + (zzTraceOptionValue > 0)) { + if (zzTraceOptionValue > 0) { + fprintf(stderr,"trace enable restored in rule %s depth %d\n", + zzTraceCurrentRuleName,zzTraceDepth); + }; + if (zzTraceOptionValue <= 0) { + fprintf(stderr,"trace disable restored in rule %s depth %d\n", + zzTraceCurrentRuleName,zzTraceDepth); + }; + }; + + zzTraceOptionValue=buf->traceOptionValue; /* MR10 */ + zzTraceGuessOptionValue=buf->traceGuessOptionValue; /* MR10 */ + zzTraceCurrentRuleName=buf->traceCurrentRuleName; /* MR10 */ + zzTraceDepth=buf->traceDepth; /* MR10 */ + zzTraceGuessDone(buf); /* MR10 */ +#endif +} + +void +#ifdef __USE_PROTOS +zzedecode(SetWordType *a) +#else +zzedecode(a) +SetWordType *a; +#endif +{ + register SetWordType *p = a; + register SetWordType *endp = &(p[zzSET_SIZE]); + register unsigned e = 0; + + if ( zzset_deg(a)>1 ) fprintf(stderr, " {"); + do { + register SetWordType t = *p; + register SetWordType *b = &(bitmask[0]); + do { + if ( t & *b ) fprintf(stderr, " %s", zztokens[e]); + e++; + } while (++b < &(bitmask[sizeof(SetWordType)*8])); + } while (++p < endp); + if ( zzset_deg(a)>1 ) fprintf(stderr, " }"); +} + +#ifndef USER_ZZSYN +/* standard error reporting function */ +void +#ifdef __USE_PROTOS +zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text) +#else +zzsyn(text, tok, egroup, eset, etok, k, bad_text) +char *text, *egroup, *bad_text; +int tok; +int etok; +int k; +SetWordType *eset; +#endif +{ + + zzSyntaxErrCount++; /* MR11 */ + fprintf(stderr, "line %d: syntax error at \"%s\"", zzline, (tok==zzEOF_TOKEN)?"EOF":bad_text); + if ( !etok && !eset ) {fprintf(stderr, "\n"); return;} + if ( k==1 ) fprintf(stderr, " missing"); + else + { + fprintf(stderr, "; \"%s\" not", bad_text); + if ( zzset_deg(eset)>1 ) fprintf(stderr, " in"); + } + if ( zzset_deg(eset)>0 ) zzedecode(eset); + else fprintf(stderr, " %s", zztokens[etok]); + if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup); + fprintf(stderr, "\n"); +} +#endif + +/* is b an element of set p? */ +int +#ifdef __USE_PROTOS +zzset_el(unsigned b, SetWordType *p) +#else +zzset_el(b,p) +unsigned b; +SetWordType *p; +#endif +{ + return( p[BSETDIVWORD(b)] & bitmask[BSETMODWORD(b)] ); +} + +int +#ifdef __USE_PROTOS +zzset_deg(SetWordType *a) +#else +zzset_deg(a) +SetWordType *a; +#endif +{ + /* Fast compute degree of a set... the number + of elements present in the set. Assumes + that all word bits are used in the set + */ + register SetWordType *p = a; + register SetWordType *endp = &(a[zzSET_SIZE]); + register int degree = 0; + + if ( a == NULL ) return 0; + while ( p < endp ) + { + register SetWordType t = *p; + register SetWordType *b = &(bitmask[0]); + do { + if (t & *b) ++degree; + } while (++b < &(bitmask[sizeof(SetWordType)*8])); + p++; + } + + return(degree); +} + +#ifdef DEMAND_LOOK + +#ifdef LL_K +int +#ifdef __USE_PROTOS +_zzmatch(int _t, char **zzBadText, char **zzMissText, + int *zzMissTok, int *zzBadTok, + SetWordType **zzMissSet) +#else +_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet) +int _t; +char **zzBadText; +char **zzMissText; +int *zzMissTok, *zzBadTok; +SetWordType **zzMissSet; +#endif +{ + if ( zzdirty==LL_K ) { + zzCONSUME; + } + if ( LA(1)!=_t ) { + *zzBadText = *zzMissText=LATEXT(1); + *zzMissTok= _t; *zzBadTok=LA(1); + *zzMissSet=NULL; + return 0; + } + zzMakeAttr + zzdirty++; + zzlabase++; + return 1; +} + +int +#ifdef __USE_PROTOS +_zzmatch_wsig(int _t) +#else +_zzmatch_wsig(_t) +int _t; +#endif +{ + if ( zzdirty==LL_K ) { + zzCONSUME; + } + if ( LA(1)!=_t ) { + return 0; + } + zzMakeAttr + zzdirty++; + zzlabase++; + return 1; +} + +#else + +int +#ifdef __USE_PROTOS +_zzmatch(int _t, char **zzBadText, char **zzMissText, + int *zzMissTok, int *zzBadTok, SetWordType **zzMissSet) +#else +_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet) +int _t; +char **zzBadText; +char **zzMissText; +int *zzMissTok, *zzBadTok; +SetWordType **zzMissSet; +#endif +{ + if ( zzdirty ) {zzCONSUME;} + if ( LA(1)!=_t ) { + *zzBadText = *zzMissText=LATEXT(1); + *zzMissTok= _t; *zzBadTok=LA(1); + *zzMissSet=NULL; + return 0; + } + zzdirty = 1; + zzMakeAttr + return 1; +} + +int +#ifdef __USE_PROTOS +_zzmatch_wsig(int _t) +#else +_zzmatch_wsig(_t) +int _t; +#endif +{ + if ( zzdirty ) {zzCONSUME;} + if ( LA(1)!=_t ) { + return 0; + } + zzdirty = 1; + zzMakeAttr + return 1; +} + +#endif /*LL_K*/ + +#else + +int +#ifdef __USE_PROTOS +_zzmatch(int _t, char **zzBadText, char **zzMissText, + int *zzMissTok, int *zzBadTok, + SetWordType **zzMissSet) +#else +_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet) +int _t; +char **zzBadText; +char **zzMissText; +int *zzMissTok, *zzBadTok; +SetWordType **zzMissSet; +#endif +{ + if ( LA(1)!=_t ) { + *zzBadText = *zzMissText=LATEXT(1); + *zzMissTok= _t; *zzBadTok=LA(1); + *zzMissSet=NULL; + return 0; + } + zzMakeAttr + return 1; +} + +int +#ifdef __USE_PROTOS +_zzmatch_wsig(int _t) +#else +_zzmatch_wsig(_t) +int _t; +#endif +{ + if ( LA(1)!=_t ) return 0; + zzMakeAttr + return 1; +} + +#endif /*DEMAND_LOOK*/ + +#ifdef ZZINF_LOOK +void +#ifdef __USE_PROTOS +_inf_zzgettok(void) +#else +_inf_zzgettok() +#endif +{ + if ( zzinf_labase >= zzinf_last ) + {NLA = zzEOF_TOKEN; strcpy(NLATEXT, "");} + else { + NLA = zzinf_tokens[zzinf_labase]; + zzline = zzinf_line[zzinf_labase]; /* wrong in 1.21 */ + strcpy(NLATEXT, zzinf_text[zzinf_labase]); + zzinf_labase++; + } +} +#endif + +#ifdef ZZINF_LOOK +/* allocate default size text,token and line arrays; + * then, read all of the input reallocing the arrays as needed. + * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text) + * is allocated and it's pointers are set to the tokens in zzinf_text_buffer. + */ +void +#ifdef __USE_PROTOS +zzfill_inf_look(void) +#else +zzfill_inf_look() +#endif +{ + int tok, line; + int zzinf_token_buffer_size = ZZINF_DEF_TOKEN_BUFFER_SIZE; + int zzinf_text_buffer_size = ZZINF_DEF_TEXT_BUFFER_SIZE; + int zzinf_text_buffer_index = 0; + int zzinf_lap = 0; + + /* allocate text/token buffers */ + zzinf_text_buffer = (char *) malloc(zzinf_text_buffer_size); + if ( zzinf_text_buffer == NULL ) + { + fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n", + zzinf_text_buffer_size); + exit(PCCTS_EXIT_FAILURE); + } + zzinf_tokens = (int *) calloc(zzinf_token_buffer_size,sizeof(int)); + if ( zzinf_tokens == NULL ) + { + fprintf(stderr, "cannot allocate token buffer (%d tokens)\n", + zzinf_token_buffer_size); + exit(PCCTS_EXIT_FAILURE); + } + zzinf_line = (int *) calloc(zzinf_token_buffer_size,sizeof(int)); + if ( zzinf_line == NULL ) + { + fprintf(stderr, "cannot allocate line buffer (%d ints)\n", + zzinf_token_buffer_size); + exit(PCCTS_EXIT_FAILURE); + } + + /* get tokens, copying text to text buffer */ + zzinf_text_buffer_index = 0; + do { + zzgettok(); + line = zzreal_line; + while ( zzinf_lap>=zzinf_token_buffer_size ) + { + zzinf_token_buffer_size += ZZINF_BUFFER_TOKEN_CHUNK_SIZE; + zzinf_tokens = (int *) realloc(zzinf_tokens, + zzinf_token_buffer_size*sizeof(int)); + if ( zzinf_tokens == NULL ) + { + fprintf(stderr, "cannot allocate lookahead token buffer (%d tokens)\n", + zzinf_token_buffer_size); + exit(PCCTS_EXIT_FAILURE); + } + zzinf_line = (int *) realloc(zzinf_line, + zzinf_token_buffer_size*sizeof(int)); + if ( zzinf_line == NULL ) + { + fprintf(stderr, "cannot allocate lookahead line buffer (%d ints)\n", + zzinf_token_buffer_size); + exit(PCCTS_EXIT_FAILURE); + } + + } + while ( (zzinf_text_buffer_index+strlen(NLATEXT)+1) >= zzinf_text_buffer_size ) + { + zzinf_text_buffer_size += ZZINF_BUFFER_TEXT_CHUNK_SIZE; + zzinf_text_buffer = (char *) realloc(zzinf_text_buffer, + zzinf_text_buffer_size); + if ( zzinf_text_buffer == NULL ) + { + fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n", + zzinf_text_buffer_size); + exit(PCCTS_EXIT_FAILURE); + } + } + /* record token and text and line of input symbol */ + tok = zzinf_tokens[zzinf_lap] = NLA; + strcpy(&zzinf_text_buffer[zzinf_text_buffer_index], NLATEXT); + zzinf_text_buffer_index += strlen(NLATEXT)+1; + zzinf_line[zzinf_lap] = line; + zzinf_lap++; + } while (tok!=zzEOF_TOKEN); + zzinf_labase = 0; + zzinf_last = zzinf_lap-1; + + /* allocate ptrs to text of ith token */ + zzinf_text = (char **) calloc(zzinf_last+1,sizeof(char *)); + if ( zzinf_text == NULL ) + { + fprintf(stderr, "cannot allocate lookahead text buffer (%d)\n", + zzinf_text_buffer_size); + exit(PCCTS_EXIT_FAILURE); + } + zzinf_text_buffer_index = 0; + zzinf_lap = 0; + /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */ + while (zzinf_lap<=zzinf_last) + { + zzinf_text[zzinf_lap++] = &zzinf_text_buffer[zzinf_text_buffer_index]; + zzinf_text_buffer_index += strlen(&zzinf_text_buffer[zzinf_text_buffer_index])+1; + } +} +#endif + +int +#ifdef __USE_PROTOS +_zzsetmatch(SetWordType *e, char **zzBadText, char **zzMissText, + int *zzMissTok, int *zzBadTok, + SetWordType **zzMissSet) +#else +_zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet) +SetWordType *e; +char **zzBadText; +char **zzMissText; +int *zzMissTok, *zzBadTok; +SetWordType **zzMissSet; +#endif +{ +#ifdef DEMAND_LOOK +#ifdef LL_K + if ( zzdirty==LL_K ) {zzCONSUME;} +#else + if ( zzdirty ) {zzCONSUME;} +#endif +#endif + if ( !zzset_el((unsigned)LA(1), e) ) { + *zzBadText = LATEXT(1); *zzMissText=NULL; + *zzMissTok= 0; *zzBadTok=LA(1); + *zzMissSet=e; + return 0; + } + zzMakeAttr /* MR14 Ger Hobbelt (hobbelt@axa.nl) */ +#ifdef DEMAND_LOOK +#ifdef LL_K + zzdirty++; + zzlabase++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */ +#else + zzdirty = 1; +#endif +#endif + return 1; +} + +int +#ifdef __USE_PROTOS +_zzmatch_wdfltsig(int tokenWanted, SetWordType *whatFollows) +#else +_zzmatch_wdfltsig(tokenWanted, whatFollows) +int tokenWanted; +SetWordType *whatFollows; +#endif +{ +#ifdef DEMAND_LOOK +#ifdef LL_K + if ( zzdirty==LL_K ) { + zzCONSUME; + } +#else + if ( zzdirty ) {zzCONSUME;} +#endif +#endif + + if ( LA(1)!=tokenWanted ) + { + zzSyntaxErrCount++; /* MR11 */ + fprintf(stderr, + "line %d: syntax error at \"%s\" missing %s\n", + zzline, + (LA(1)==zzEOF_TOKEN)?"":(char *)LATEXT(1), + zztokens[tokenWanted]); + zzconsumeUntil( whatFollows ); + return 0; + } + else { + zzMakeAttr +#ifdef DEMAND_LOOK +#ifdef LL_K + zzdirty++; + zzlabase++; +#else + zzdirty = 1; +#endif +#else +/* zzCONSUME; consume if not demand lookahead */ +#endif + return 1; + } +} + +int +#ifdef __USE_PROTOS +_zzsetmatch_wdfltsig(SetWordType *tokensWanted, + int tokenTypeOfSet, + SetWordType *whatFollows) +#else +_zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) +SetWordType *tokensWanted; +int tokenTypeOfSet; +SetWordType *whatFollows; +#endif +{ +#ifdef DEMAND_LOOK +#ifdef LL_K + if ( zzdirty==LL_K ) {zzCONSUME;} +#else + if ( zzdirty ) {zzCONSUME;} +#endif +#endif + if ( !zzset_el((unsigned)LA(1), tokensWanted) ) + { + zzSyntaxErrCount++; /* MR11 */ + fprintf(stderr, + "line %d: syntax error at \"%s\" missing %s\n", + zzline, + (LA(1)==zzEOF_TOKEN)?"":(char *)LATEXT(1), + zztokens[tokenTypeOfSet]); + zzconsumeUntil( whatFollows ); + return 0; + } + else { + zzMakeAttr +#ifdef DEMAND_LOOK +#ifdef LL_K + zzdirty++; + zzlabase++; +#else + zzdirty = 1; +#endif +#else +/* zzCONSUME; consume if not demand lookahead */ +#endif + return 1; + } +} + +int +#ifdef __USE_PROTOS +_zzsetmatch_wsig(SetWordType *e) +#else +_zzsetmatch_wsig(e) +SetWordType *e; +#endif +{ +#ifdef DEMAND_LOOK +#ifdef LL_K + if ( zzdirty==LL_K ) {zzCONSUME;} +#else + if ( zzdirty ) {zzCONSUME;} +#endif +#endif + if ( !zzset_el((unsigned)LA(1), e) ) return 0; + zzMakeAttr /* MR14 Ger Hobbelt (hobbelt@axa.nl) */ +#ifdef DEMAND_LOOK +#ifdef LL_K + zzdirty++; + zzlabase++; /* MR14 Ger Hobbelt (hobbelt@axa.nl) */ +#else + zzdirty = 1; +#endif +#endif + return 1; +} + +#ifdef USER_ZZMODE_STACK +static int zzmstk[ZZMAXSTK] = { -1 }; +static int zzmdep = 0; +static char zzmbuf[70]; + +void +#ifdef __USE_PROTOS +zzmpush( int m ) +#else +zzmpush( m ) +int m; +#endif +{ + if(zzmdep == ZZMAXSTK - 1) { + sprintf(zzmbuf, "Mode stack overflow "); + zzerr(zzmbuf); + } else { + zzmstk[zzmdep++] = zzauto; + zzmode(m); + } +} + +void +#ifdef __USE_PROTOS +zzmpop( void ) +#else +zzmpop( ) +#endif +{ + if(zzmdep == 0) + { sprintf(zzmbuf, "Mode stack underflow "); + zzerr(zzmbuf); + } + else + { zzmdep--; + zzmode(zzmstk[zzmdep]); + } +} + +void +#ifdef __USE_PROTOS +zzsave_mode_stack( int modeStack[], int *modeLevel ) +#else +zzsave_mode_stack( modeStack, modeLevel ) +int modeStack[]; +int *modeLevel; +#endif +{ + int i; + memcpy(modeStack, zzmstk, sizeof(zzmstk)); + *modeLevel = zzmdep; + zzmdep = 0; + + return; +} + +void +#ifdef __USE_PROTOS +zzrestore_mode_stack( int modeStack[], int *modeLevel ) +#else +zzrestore_mode_stack( modeStack, modeLevel ) +int modeStack[]; +int *modeLevel; +#endif +{ + int i; + + memcpy(zzmstk, modeStack, sizeof(zzmstk)); + zzmdep = *modeLevel; + + return; +} +#endif /* USER_ZZMODE_STACK */ + +#ifdef __USE_PROTOS +void zzTraceReset(void) +#else +void zzTraceReset() +#endif +{ +#ifdef zzTRACE_RULES + zzTraceOptionValue=zzTraceOptionValueDefault; + zzTraceGuessOptionValue=1; + zzTraceCurrentRuleName=NULL; + zzTraceDepth=0; +#endif +} + +#ifdef __USE_PROTOS +void zzTraceGuessFail(void) +#else +void zzTraceGuessFail() +#endif +{ + +#ifdef zzTRACE_RULES +#ifdef ZZCAN_GUESS + + int doIt=0; + + if (zzTraceOptionValue <= 0) { + doIt=0; + } else if (zzguessing && zzTraceGuessOptionValue <= 0) { + doIt=0; + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"guess failed\n"); + }; +#endif +#endif +} + +/* zzTraceOption: + zero value turns off trace +*/ + +#ifdef __USE_PROTOS +void zzTraceIn(char * rule) +#else +void zzTraceIn(rule) + char *rule; +#endif +{ +#ifdef zzTRACE_RULES + + int doIt=0; + + zzTraceDepth++; + zzTraceCurrentRuleName=rule; + + if (zzTraceOptionValue <= 0) { + doIt=0; +#ifdef ZZCAN_GUESS + } else if (zzguessing && zzTraceGuessOptionValue <= 0) { + doIt=0; +#endif + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"enter rule %s {\"%s\"} depth %d", + rule, + LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */ + zzTraceDepth); +#ifdef ZZCAN_GUESS + if (zzguessing) fprintf(stderr," guessing"); +#endif + fprintf(stderr,"\n"); + }; +#endif + return; +} + +#ifdef __USE_PROTOS +void zzTraceOut(char * rule) +#else +void zzTraceOut(rule) + char *rule; +#endif +{ +#ifdef zzTRACE_RULES + int doIt=0; + + zzTraceDepth--; + + if (zzTraceOptionValue <= 0) { + doIt=0; +#ifdef ZZCAN_GUESS + } else if (zzguessing && zzTraceGuessOptionValue <= 0) { + doIt=0; +#endif + } else { + doIt=1; + }; + + if (doIt) { + fprintf(stderr,"exit rule %s {\"%s\"} depth %d", + rule, + LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */ + zzTraceDepth+1); +#ifdef ZZCAN_GUESS + if (zzguessing) fprintf(stderr," guessing"); +#endif + fprintf(stderr,"\n"); + }; +#endif +} + +#ifdef __USE_PROTOS +int zzTraceOption(int delta) +#else +int zzTraceOption(delta) + int delta; +#endif +{ +#ifdef zzTRACE_RULES + int prevValue=zzTraceOptionValue; + + zzTraceOptionValue=zzTraceOptionValue+delta; + + if (zzTraceCurrentRuleName != NULL) { + if (prevValue <= 0 && zzTraceOptionValue > 0) { + fprintf(stderr,"trace enabled in rule %s depth %d\n", + zzTraceCurrentRuleName,zzTraceDepth); + }; + if (prevValue > 0 && zzTraceOptionValue <= 0) { + fprintf(stderr,"trace disabled in rule %s depth %d\n", + zzTraceCurrentRuleName,zzTraceDepth); + }; + }; + return prevValue; +#else + return 0; +#endif +} + +#ifdef __USE_PROTOS +int zzTraceGuessOption(int delta) +#else +int zzTraceGuessOption(delta) + int delta; +#endif +{ +#ifdef zzTRACE_RULES +#ifdef ZZCAN_GUESS + int prevValue=zzTraceGuessOptionValue; + + zzTraceGuessOptionValue=zzTraceGuessOptionValue+delta; + + if (zzTraceCurrentRuleName != NULL) { + if (prevValue <= 0 && zzTraceGuessOptionValue > 0) { + fprintf(stderr,"guess trace enabled in rule %s depth %d\n", + zzTraceCurrentRuleName,zzTraceDepth); + }; + if (prevValue > 0 && zzTraceGuessOptionValue <= 0) { + fprintf(stderr,"guess trace disabled in rule %s depth %d\n", + zzTraceCurrentRuleName,zzTraceDepth); + }; + }; + return prevValue; +#else + return 0; +#endif +#else + return 0; +#endif +} + +#endif /* ERR_H */ diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h new file mode 100644 index 0000000000..d6d51a41b6 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/int.h @@ -0,0 +1,37 @@ +/* ANTLR attribute definition -- long integers + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * ANTLR 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +#ifndef ZZINT_H +#define ZZINT_H + +typedef long Attrib; + +#define zzcr_attr(a,tok,t) *(a) = atol(t); + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h new file mode 100644 index 0000000000..ff0dfb5126 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_assert.h @@ -0,0 +1,10 @@ +#ifndef __PCCTS_ASSERT_H__ +#define __PCCTS_ASSERT_H__ + +#ifdef PCCTS_USE_NAMESPACE_STD +#include +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_debug.lib new file mode 100644 index 0000000000000000000000000000000000000000..8d8601849dbc324ea4bdfbf1b3ca61b9a1600e02 GIT binary patch literal 158702 zcmeEv3w&I~b@!}xwOXxYTefBVgsh1H1IEa2SvJwimOuu{mLDPx0Tx+WVHsIcq?HXM z5I`hBC=dtstf z$tL0JFW>LuN_Ted%$f6=GmkrW?zs!scMNv!ena~FOz>E{YUT3Un&q`Cg2|a0bG>@) zYLj(US}FA>O09nPt8>2PQKf#L&L4h4ssGDo?A+Vbq~}$iQ?dVB=O-7a*vX!Mw^GIa z-#qK7x_cjdF$tqo1totLTl`el-s&9(;&kWX_J(j6uE4fojeJ4C+)!snp9{OSp@9m#4B5N-3x)o@ zZYG!!M6B!1;X-a#zOX-^50u}|+9nkQH6+rN&kt{a7oy=SuD53>P)}N`?YW-*UBlg3sqnoW*W}&ut{~LL z-i|_Npb~)tnlgqUxw(Ok!9q_*K=-f+4JFFx%kTH32%Am2my;E%=^N_V)!Wl|^^nUI ziBkL4?j0mh%FgDt4Z2zMT)n$6fx=khxkCRn`M%sxA)qo^?}kPp?f?~b1q50K1KQBo zpy~-i3zDYn@Bu7Pydw>*fWQ$AYTY=HTVXuLd^8tY13B1q{@Rcl1WrR02BD_j{I&T( zK=u?|K*J0KwIEs8rszngp~_%Clb6#lEZ81EB!UTMgQb{+)P+kbt83RyqTLMTbL?01 zePQ+ks*K=@u%JHX{c~WCZ7+noQ|%29etf)6uv5?vUI!C z)TPwbd2~3}gy^F6M73V%=m{95+c6cw2Fb?GHdDB6ARlZK(v<3J8aD4}*|vi%Vmk!y z*y{|@HH|G7wa~IQbPSoH8-|C(O??By1q;5ZSq!m$Sr8h8^+2Cn6D46s^I#E^dQmV{ z#M5JSSAN&<)xuFW0;9Re57L~AdaH*Xr4;H#%7t9EPX)vL&w;$7jAbR$YR04Wo zbgbcAYbJWC5iH3(+qLEgdOLS_3>Lv{W+Vf>V5Ug6hX8YrBH6lIA1Z+F?FG)Ff-I1E zZF)La2CboveXjsGUvRBzObh^ zFAVB7%1+6Q;kpH~y#@q;+H@OS7Ay@Wbb4-0FvDq=0YtWC2BAe3-7*NPo$u(% z20_39XH@JVIm6vZ+X+GdNu(zNL^mcha}=R@X^m7{eX(52La3opDBO|wbSw{6ThSaxW4lDg?LF7$ovy=Tuu9QD`7YhGC%~us zj1Y5T5ncJge7A$%lUI7fYYUi98;ViXoIDT=-Ibr|;IgdhnW}(D~b`9kaDYlJ}_hxIeE6~JhYk~)FSkQg1;PQ z)wshF5~e;ZS*IEX2J`)cXaYV597c$7Fh9^gSlF^JKe&Gox9wZH8*z)(*5A{|+bEAV zQ4xA*cvq*~nR+?IVrypf7d-dH`DB!YlKR9DiDa(?Ne z!WdQU>H+gZrW3UmgWKXJ+!S~A_YDp2HRGAh!}uVr$Yi$n6>#?ws6gFTM4c{>GYD8* zgcKvmw+>ysJcxxY3Kia{8zccH$Y&ie+a38V0SLmoduE$X+U8jFntWHjldG8lF({}} z($&NHAv1>9^2p`QoKwP?$qIa~s~^*H2Oyi(C?_q{&6~kUA$D7`8W6~_9a_&&V;=LX z3-egiY3l1hzaA2n#w$H9W_3a297sh4&M;_2BziN=ACP+@slm-1VT(X50!(8W?AeP! z#hW|^*d;C9TRZm!0SKWukx~cqL)Z0T)hbZJRFW8*fBz5wnG`7+NvBPW`v|mvrZvpcc(eN6J+tG#z?8q;8;e@v2!)zIl8|Z+> zP@#HM60j3PY|BGUL8)zB3kKZ42k=X!>9sw{?;j48b^wO4T4rrKh{ce2<uU6{Oww&QgKXybuF(N)c+RE~i=w9g=6tK)%D$Yr44i z4Oj!L?F4fpXHCoA07MGeMH(}ma*Eg-7Gd}EJKlP~vPHDwkIDk_ql3_VId`~L%wl== zrq2`tsI!jX7luiX#? zruF|jHw3Thb5w609~u2PNBMofy(s?B{rBzJ@Fe#@lRr1!^}n#__rG@+cJfcbPxRQv zJ_mOne@Xvlmy67E^vR!-Pqy0mYA&FlC426y6JF#p>R;P6o4 z_jMK9%wPOb-A+!lQ3NIeoM`^G4+eb#c3$KV2raQ0I(luT$ef|*eWw)qJzvr|nT;?f zz3%b5ZRMJLz4|0}<8VDBGJ5M}7k{ZFI2q(EIF<*vwsqpYJiqf}l2>Cl(8)Y&nfx)f zw`FLOy&AGKGWjF#$#&kI;F;y5yOd6}LWV7hx{?F8G-$g1BAS2{d$Pg(jiD#Sk%IoL zAIp+r87IFgH_?NWfs1bT6)gGtsSU(xo4 z6RuyL_*vrMWIN%!-4iD-g1=%K96HeZ6xp8f|Ik*u6YZ9DH$zM$x(j2sfSl};+(~!i z!V)7>2|Ln5^Y-DET`s|OcngX@LzrX=Qlwl^RA*LEjMl5XE`D;mA1B^1Gvx1joP2|$ z*^X!WNL@_#l#`d!Ft2Tl^oC)7i>Or%rz2XS|0^3KUzG>-cxV)yd+AQS=)`#P2Qt6a zHqFVm37p)E(^w!g{&P z&6f7>+M{fW%we%TB#_wXtwslu-Kl>dqrsU<1~c>|GMJ`2aY;MhzFcNFwK7@GO>$;g zP0i}nt23Ept7>X>k*m@zv5dOx?4Q=2e~wb$!1FI2OS=a1orQgQeWlb{h*X!_EAyMK z0vy$`XuHih7*}c?;9g&@Q>yXPtg1FFE#N-i0^xT>iBjW$IjvHuU*kMQy z>45#_6kYHq@*7i`D!_&4wgBXxkbnME4GZ+DxhhJR_%<4t9r8OdzRQsRiDLK`U8{*8 zT#WMx!2Ha>C2=isbafOuJSe5w5I=32lYnSe)jYNIS_1kA3D*a>FB#Z`z-6;xy_}2m ze*w(&Dy8P*OgnhwN_~;68`^^Y{1!q)5904w*|nl4f%aIdGNV)v3k20>7N74 zZw%Z-dOjU+GuRk$td!s4dhS7f9r7PEuoK}!SE2qKFh9jvK1<;lv&9#*dsf3V=4w*a{30JD(>i^IdG>urZlRqF4dw>KIXo5ud? zJZwVf8160f_Ux)_*|cF}W5!L{($cuOp|xpyhG@@Ky02T*SayQ6qUQW^{E(GPabEA`#HPwvRaa-$#HOia z)zRa}kM{#2QP|xxG#v>k6uA}&$2Bpm}x9NkAO&nNp;s+_X&NG@tww!CI# zC}r8&wKXAreg@#vaDEr(TYY}gh95i=A}`OoypS+?(S(_O2-$BIRxul6_F9P^IEkcO$7hhYd*A_7rl3DM(oe6iIA)#w7vv5p_Y^F#gC)ErzNrSJY&(`0Fkd1Dc3#Quf&QT!B#Kv2`cfgm z%wc8@VVixfFcX(|BD2!H$s%i{lp~4JY-;Uf0O+@Z4S&MvEze0V~#M0{D5UZ86BPNzs#}QjDX>l}i z#?tCM#LknnWhRzZA4TkDN&C2orPa?7d$*+hyNRXMF~r6sjXfA+X>|@_qms7N#M0`+ zUfKg*+S7gxgn(rsj;TiNUa)9taxgC-B|0C0My8#Iis!5 zA80zn3&~&c6v7d93N>k!yjZ zWV{A2V_OrW?Z?KGV@*e)o{<}lslwc`)?-p z+IndG@v-)UqwS~`(cm4ex_U(&uF#c=Bkn?+)#?I-94f07XB|3i7h-G#NvYX4NNfP1 zj@^RT8cF*w!qqsd#UwXL>?a6U;Y_OEAiPY{7Qx{25?hIw#=y zV^l>-Od4*9`a^-IF_x-dAw;hVT4kyNVY!-zutF_BI7KZ+I8`l0SS4kZx(M;O+J-Qp zdJra60b!ZC31Ldzg0NhgxKf`&JfZH&B3Vxr)8W{(zwy>n(}e*_=K3_4eetmKxD4Kfg=NGVy#e% zOicO}k8Fx$7b0tNvR4-;%Lg_Sk|kD6ma#N?ffw4OmAvWc$4Ku*2G*9HB;1gy^Kn*V zEL3VePL6*{t(CO72(@Lr4zW9MCPg%zJH#;|hsjD^rlU~E@5ST{6SG2p21%LC?JX@C z0%XkV&q@g-hPJ-`LI$1;`a3gtdZl6dFkq@o={<8}pfSY5HXkyDvwHP!mrFsRlPx@WM3A%=Yf`4KSy z{mX8g;Z8gcJ1Zi`45L)iEz9M)dpoWkveI0FG%XEdzBEn84&ZtMs|=VVv0{xWBm;S; z4D6B|Bb?>PaHAKGaBR6FZp|HIuZ+9?ESRdjCpc%mWH`tQzd3k$2dL+Qvp<~abewsx~GrM<_Lk`WmxRSE^eQjw;XiZNfRlW*RvGPike3RQ~Ryl?f{ zeZ9z8S9dZ^+cTKSnl>jyS`x<6vgC4_Dh0)xaP1!6-Qf{HRk7brqprO;K=CTU43?Ou z%ByG$$5u`A!3>l@x%0k{NkCHP1JFubN@rGnVMP7o>bDK||dDfAJ+QRUwiBcIrA zl5{`tZ<48t6dl)v8n<5#*|L4H0ivroq{+gIyjEJ6FP|} z_(Di3muqQj*w(c92(L?cz0JRl=6FbQ~|gIgv~1b@l9a`( zAAsG`zPV9fmk}4rZrai)`RbW{4#T{6Fkh+*1!aWDq#9s{eT!Y*4K^_W*58A6QV~H&7gEiK%=z@5y-TQDc zb*jN>;fm9asn;1e;t;#XwbiH1^K4J(mQ4!$yJfmH~ML*tJQ!d zZ)@;t@sgit*_c}E;0@}}$6KtNZHLACdb2Pn?YX4t0^!5wW80Y3mBqud?AM}t zEm0R6JhtA7!^KpK2dBpj+7R(=M!IizF=g$>;u|(_y!Ub8+6=yZiTI52YV@_ZPF9zw zsra2L+dyQb%)ztTkreW)kd6_5EIqRyjK}W{Z5;YHb({-NS zej=F~-vZ>#3*-riU1b*BrvYYm5g2*{BTvjPhQr*s3yut6W@sEDsqq9Rc?*$e_>(;B z_J$%fe|)@JDvlEM^;x)1(7mFO?QC365uX9p%btc?g7k7?lRTZa6ls-Av+n5(j`NXT zfwcrHG-X4~v0<065PdO$~NM9C15J0K8%A(lh=g2TI7{_^{07QPk7h2qr+boc}eXH zQ}j+58p)N#Ph4aP^`Def00=QCf8^?N#W7`AeH_kB)KI*#- zaOK{HXI>cRl{FP%N+f2LRmpo_eLo&!X!TjG_ zq2L_njVR0cf084&YLj{9o0tY%UcSU*0&C|HmjlL~M_hqxJH8O-PMn-SUx{BH(L8^= zxATY`U^$Pt3cmsmzIB3{bsM5ic%=OWCTWMeke(nS zX@hZDnq=SBge108t`72=Yk|Dxf_Q?2G<>WF*WtEBS|`)C>@r@sZCP8Q{Y`;oT?2eP zdhv_;z&tz$PeSp{Z>}f28;MUaKlMXN)_)xzBV{LK}>8?!<;o8VM?UUsQ$9bHK<820q zJC9=@5XD)dZZxpg=8MC{yscMOzt*mA3DFMdC?uP;>v=J4*Ka}D((0JlG5SIJ_d_41 zuTy%&k@>)W!b$CGo3=}cNo~_IPF)WekW*!5BMHZZw<3-GTpZ&quUU@sf>PONp>c8d z1O8P~?|BehZ%2a637qleW~6aW;EpdNNDH?C(m0tma4X<=gxf$GR$^_Ic8;Yw^$r93 zPW)m#5KYLw0F>wY2_CB)sWW3tfk;)Xlj8&H68%LF-KpB^l!^^7ew*M*aO2|pt)u=HQ?B#GV`mAZ8@SuVxMmZNaf2x>=lGc|n>D1nHIj11 zW87TI4W-pDf9;(bh9ULOBaV@{Bt|Q}9H-uV%JikXy7?mq@#M*r%ntcW%LGiXhT+h$`|kX zl7_<;JZ!kral#}ag}?E#94YZwo6c6Z{#XA~I=X24Ma!10SS>a!Fp~UE1IHO^iPA93 zBu&HU?S34ebze_Tl)6Vk2EwzmjhSPxrcS##bMCMIgHVup2eu8a&~bs$DXWP=kKAlO z*m5nQ4xkOwDueBd54?G7mC)8Z+ca_Hy?TE`%%tE~sa6Kw;aa9VSBRa9JZ{K+{`8Rt zlvt*1l{X^ig!LY1m7gR5ym5DWd^rT}4l9Ws%U>bAqJ0z9Z$zh@&Zf$?-mzN4jB2Bn;~1CvI*Q&P)C zMWhEna|R5by^-r%?*9;&u+USD7*j=Ke-t(eS3*P`7FrGYXSQ zf${W1T+vceC?LfwB*kOf5L&*fwG^hGzZW?tZ0~`7{(3N@dmG9{KAUm&qEU?ES1I|> zgv1yC#_QRFeH7adkM~GuEkVX5r1(ACJ3&wSIx4~GQ=}Mz_aI%vkRM`u1n0frhtG@A z8)Fmq@?}a<6Dge7KE#xjdds#+L65y0s;5@{9((yJEt^iU{d16?D^Y^SMW6$%O1_fu5VPg@nt{>v#iSoO zDLpYh=eG7E1(e%A&qh)_wg4e(PahWgu)#wZ-x3HzNwv*$iz1JQCA2zZL4gU_e6*Al z3fMenhVj_N2rU<2}?QS@~MD}$KHg{axp)mvC{;m_*ihIDR!D@!>xct2@Wm}IqeVWhCB9|3U>3T|EiPos~()bIJrYBTO(-;rJ6 zCL(U%kzKyJcA5W<>{Rt;ydyid2{)xNZOZNf22;+$*=SpW2En))eMfc>lbve-_Y-tW zJUA}NJF>fmh9toRmHxQlCEvt%Mx9$dW_%3%{2O}ryV*D5Na4&9F7(drsi6B)!2D(j z-l@gV|5mj+mMQYi?dd3AwH5)6T$iMpp_&8bqxPke?B>2eRlgKYyhX@XjztB5{1Gvwa zZ(uZ}u3z^J!V|nxxKv(ZgGm)#T5FV7(A^i#FUB}m3Nv^$UMpN1+CR7lGH~YBg_F;C z^%0xtJteNIvrk*O>ya6Y^#uugc6LRjU)GCHRdA%e*A;nJ?L09a4G&*ktpk8J*#?TjeN1 zwi{Svo+hjSucrV*c!5uErsc+{k|AN2*o0kqu`~Q;2>Lgv0nXdFi$NbTw+6Vc!AkWC z=z29TbT0@AT#nY12C)+S@`<~lJKGW1eg1xm|2}HvHSjGdF6i-MMue|`1rGCF*GizK zcFeo3RoIT`Px#`6p@I2G;R8o~OyxTtz4)RPzBky>c};ZyysQtOTLD?_?zQs8QSrs9 z^aPVka^WJLe~~ zbIwLeWuT(c=rBOr2lF{w;Zp|pPa0XwONtWcC8 zfh|rlV+l7`cjCaUiuwpNS7-BLq$b!Vt(nE~eA`yO=uNyZToURZT!P#mY6za;^bbXL zgPO`B{f8lGK$E2JYm&;KZaJn6lWPu<9|t|Q%74arnos`piOB2C zw%kZdz0sgNy-mOaO^j8iC(Tp{txPupTlZp4?u=Lx=+=TfhpYP|m^_f@58&6~`2^L? zg(G~Gm?Q(ebP=|vV`g`yr;G&dv9Lo+w`S3%v&j$qO zKnBp$gaA_34Was32}qg;7v$!7EX5W~R6qPu6h%B)>)^H#y=jHi8$#5V8|q8&dx}qe zeuTPgJCR-55#qcPVsj#;GPb$CJobP&ot12vA@y+6$QtUr5zqM4qfLWY@m{uks`;eo z7t{1Nja7ByccD)$s%fF7w|q~5p@2Digf2tQVpi5-*yGKO9Q2*DvKDW8gi=;UQm|V; z1hYDlf_X^@rZ$qYmZ}NNAc|GZB(^UdqHGIxO}ZK4G-{dH``IZ0dv2l>f!E83f;cDiZX+eOhrHWxpXkKi zZ8%Q3@5kK_{Bv|#lK zuZg8q5|8=#ytP85O)Ra>Mr?R!a2l(Y|;SXv!H>}g5+rHO$C zjQm+i+ht;D^%KOtD``J9v9wx;@$d(dR&QeP1ccc0lJRkb+1VzRR(B(IhNQjU#L{ZoG^{B|+DsEms~ZqoA!#?8 zSXzA&u?9(d#Kh9-F~qWx_N0lW)zgU8OWFYwORMiA#;5cZ>IWv4R{x6F1(G&yVrlhX zh^?2j|1q(&^nvRnZ5mn~V`+I?vrf`D>N=ZkA44Wol%EG=)g)k+%Iix^8Q?mS*C zX*Zb|WJ65L`-q95Eg-f@;0~EsTCJR})XP%8wI-HU7a;~^Lbgjx4CZix<1XOs>D$-Q z+ta1=i^OQ#@&d6^=EY%!7lxI*C=6Wkf-ryO#bER+i*cT`Z@O z?{)eTzG3hpIiKY0?HQ7ZyH4>j(X9YgY_ag|5}R9>IqQthvtUP9J36nw`#gOM^9Hrv z0G}t=-@xLs4?w$-;N$D0Jou@W81GwVN(_~c9XiZq4yqV2JS$R6Ps;mNFjd3?p26VQ zYCF7H(SO#_#@dgP&!flNNU&_h zQ!hS9X<84Bd>LN54$=SChGXzpHgdy3Rp`o7|lKHdhJhY_Ks4r}d}jQ@1x zhL`Ehi+;RbMmkgmZ(i*O;o8hr1F8Uy%HWbMOlSPwksFSxVd(H>czZ)lw7-mEwnnQx zuVP0b9sQAM?@g6ssgW0BW9^lrX;T}OE4~g7ant_j%Uhv-jv??CR7svwW9?O=)i+Z) zmA>)7SI8K0Qe%nRg{{i5=_6l>A$7D$BW$f)@!gx(vICj+VfbikJ*shv-=VLh45CZH zGRlDPFg5uipvPK)YF+!$LRv^r6^jmFP*#e#pnZ5?+oQe98A2K}y|E3SD@lQLW75M= zVC4a#Q6O}a5VDprXY4R+j8>3>+mm&N3%h*1vy!v^C5`Ab=h8SNAzD{NW9*>)Vi#@} zodQhSDoJcG$DnM@{yUzUcIz0ic+G&6>;0zi$|ysNqp|T?9~+C$aIk5B*-?GbCg29} z*m%z8nyg&lU%oO{ATjLUGi2ERu@|@e=J@d|X;H=ys$d9giO3UIG&F{LMW@GT)C>GZ zhvM+FmtyllW#KAC^DkU2ZVo$q!;jP{T_0ZP=ToHf{91?O8?Viv#ls#B(;m=5Yv1vd zxJ^vIxF6N_7z{@V=i&wtE*5FRBR5p4;k4wv_-O!$46~Uk9mF3ZNoU?onVP5q$mDt2 z;WdpN1S>_RN^vc?OAuV{t4?IHV6;=p)Zph+ro}!Y%4E9_I`*-KX2f}0KpayMm2O3# zL9rrcN@HOUI1X=z8VhT|vsCiWT9|h0KZ)?i5aVps0;73(vXbqYHUs>Uz-L4&M@O)n zcH?TXNc2Te-n93#GkWijB2ajiTQ=I<^6BuqwxP+|0oR2J1;zxWb7$ z&1-m`&jb}k-L02e8DBNlR0aK1deCjYY?Wir2z}2Aeht(0t-$FKrP52rTTT5=^~ve_ zwN=5^gD&5_{ ziT*eVcTmI0kj}ALI;t6a#Cr7%f(}sW==24#a6LYIen+9j15HPnV;zki9r8LIR&7S4*-wN@6)l+)||c6wkVhpI6tHPfM%BT)!&Y7F*#c59jV^R$_1lL8t`kXWEyhzvH{Zd^!C zx@qrvpWr^c;=8xsMNJ)F^nU(;4Op6H>M<H{ z9P7zy{LO)~y!#w)4iv-+t{Pu8^33t^8V2ZrsR*fl2@WEk-YMn6Ut-t^VBKJuf5Ib{ zI^j{0ilgmg5zeIe z+OYRm_ipH`7FEKm-{9!myZ-QjsJ!XXc`T$FWOPH>O*Xw#NOq_?nmqzq$Sm75Yu}30b=hK zxPSKGj(BOWgDL6U<%snN+!qo1s9<>xF^%Ovu*m;SNsD3KR;Mk+LcK1#2C?U*Y&~L{ zzh*COD`G#B+*=Xj!hf~853zBHJ&4%P5lgDiBc?G=t+c$%L+p8hdp%+rOFd$`Y#U;~ zl(OxJamg&HE<^0~Qlbm7Ur6jdh;c!`T73jDF85cfPa(#K3)SlTh$Rq%(-QMopjw@Z z7#~Met0jnW(YspJduf}!v>al598s|+zhO`>a<0OX}V2_aml_~U4qyw z!P15pAE97@7BSv)SF0<$wD%yU%YGX%J_e~)e0;D`V%#*R)3zhFLDJ~xMaSOjp9g?a8F+QwFs&2$I_kCX4I}xju z+}jc3BafuI6EQx1fnR^b_%J1@?nR7`Uy}0mCq8sZst+TL4^EQm0mS%NC8<7v*eZz~ zM+~Y)S|!%LTO@5JVwXsak2>{U5;%24tVGF+O!B!F*Y`hWlmgdU(}Sf>6AVM=`#VOo6=VTF1c;S}|E2&b!` zAe^aQLI}rL=tXC%MF{7q6$lros}P>5`VgL`h7c}PHzPbca@nR*xV&SN#y- z67_S0OH~DW)brIMgf;4Hgez4o!qtk8Y}cqEglp9Z!a8*u!gcbH7dwFvkExF!OsIzu zCe@D-rqnTn_$mVWW<1hFSfMUJSgAH3oFe@-9Ec$vSDgqG^5{3I9z{H*zKyV4{Ubs+ zi9v5%p(+tps_6))NIwi|5QjTbgbB3@VG?%=EOjr!3iT0$Q`8p_PE}7MoTk2yaEAIf zgw<*$dhS{34G3qejR@zcW`uL)(KB3gAzq@cLYPqRLRhLkj4-JlL0Be_qVWJ3@e=ht zgbDR)gr%xHMVLQ^1p*)9aaE5np*U?Ul?T)K6p*Cvll1E({qq7pf_RC#N7A2>^k)$! z<#BVF`Z?k$brfN_D#J(v*Et9)N$id^&N!e>TeLH<*_&3QbIhY{uN<~`geqIwv5rOR8=4>Q*#ie z)Ix;i>U@N0wG3f}T7j@q9+IPvLmY0t5SFMBgmHBj!i2g9VW~VcSL%MmW9rkA`%}q< zmp$apMu_ihh<;8-Jf_Y;SfbV;jH?!e3AGbpslK;WU6Ou{qz@uYs%sIJt1*O?>TZNn z)dL8psmBpksqZ12p$;LOsg5D6R=+_wN6o-^H&4EZIA5KE_^IkVgr~_k0ozABrZyog zRa+3EcSTsHb|WlT_-YmOfW7(914nX9GZ8OU_aIEF2N9O3&mc^xClHpaFCv74A@m{G zYJhl5y@0Sp#zKtFlJaYWa1V_UvQ*7PSf&;tOsQ1}%hg7NY4t{g6{;IyrRqaCRo#Ga zntBhyD)kYB)73{2&QO1faHe`1VYPhGah7@x@l#}!R_Y%RFH!%DFroepA-)NN5Uz~S zji=RV2rJYQgq5lR;S|+|aH{G?I89xTuu9#AaJu>s!kOw}gw^Uvgr}&lBAg@NXPm2k zh4?&m9N~PGz=(OOszmrYH5Xwz7SxRSvX^)b4EYGheM>A zDq{hv{C3pSHxparZ8yqKWuTqGM;8J)V$*!0;$D72s>G_PG8Ukkm5=|tTM$krt3%e2 zm0s*8q)MckDr4wG5El3S{Fr8J#f0PBNi#8U{^K1|KjGu1o>@`3C+PzAj5t zjiYDk&(FiCWb)W0rq|u!R`BNkJ9yVTVJTy8;+q_zo};ZjFO*d z*`S~Mpl$egi{-yaXfJ)qky8fjvLz+FZfp>gf3i+@8?R-dI?%*%xL)yyI1$m13v*vdM ztn3^QDSJj>PwaoX)0DM7|JI@GBtHM-9t+_ z4i=9UbKJy56U+~ByDu;Sk8#Y2$LPihE3N8-5B=gE{FtK&zZskYBWbrts8fu;-sQ{H zP7g*r_`XuBIh;maUO*pSUTjv21Vo(J-sz;jo5rolapD z9dgm_6kSa{_}Q<1842e2xcM!GbS1I*xY~o0ZmBYo<9ZV$o_vhStaBb`NN9cIVTBkA zYk={5;}Mr%s!5>T;A^V zq`pZo@?i%L%QM$~f;?v+q0jRcfp&uzaiL+zGqL>`=MwM?rQxs|3*xy-^0?r|!%|0; zgsAgN^FDRFj1xM_k*{G$o!A<1-UsS>p-;2{Z(wX2L2U#v-(c`&<=65<%0X>hfMq40 zpPNl7{o~pgo~ppcxU9%KtcKzHuuX(3Qnr`42=SBYCCIlvmO)Y;NkvJsh!Hy-pA?r7BJFjRT@z`F3l!iyp6FDD5o{U_+liD^g zqqR!8$R{oH3#h?u_{DNJy@Rh^t*%8pScAd3c!xkM`7pX~QIsiIgYN|6ehuDkO8Gzg zz>kI@KbIndFEjrT{Jhx%;^R<0b|fBBQ1U7CXYgx!QPbjrwB9R_N?jqpwk}S?RglB? zKun**zc!`(pE6L^FyxTfp1^tM3ccyWw}c>`?-~SM@@uK5aTTP#370A21A8w)1 zFr-dw&*6L))O!TTw)Y^O7Yu@44P(5AMybz%I(_O#Oez1T1=KYRsS}$#(nrJR3b(eF zxO^0?LCEL>s=M!YxKS$VB7oq zk$*Dn!f)@lKvEtlMM=pgXC-u0cr%kdxfmyP-QG9w632*ywwB4ZzS)mAg&OHnB>)C;BXzktDOZVcm5DN@{t7~$xY z@jfO8q#zzGMWf_l<|MyvT?mXP1#v}7>B6oQQ;-y_3w#p>Y1YPA;$&>h?|Z)uxwM6| zcE~5&^Hpd~e81e6E7%IS1&GH35?Z;UJ?&=$ZD)ZgC50sTC8%o{QYW^{ao!5*e=Paz z`IoP)k?&y#+j0;yXBIp@DWT4Qo3j@^8k5I1xbqz!6#762*fV$oiVW|i4aGMp6KbO$T9;J>? zraQ88dsFb(4C)$&)QRnGoZkg?ZaMcYA&6(a!Sf{zGhwej72Sxh`HLdd_kp^GA$4M7 z8=JaH`ylYC2k~5H@cdPPdeja-6ri4qP=61oYZy`|w)HsaPyShr*^K5vJe>xQ9-pn| zK`K=5e;=UEO;y3;VNlmFq)u!dICq1(94CcQP^p+p?d_g;0 ziw@JTiyI>Rd>8y^81h4GSK@pK{O~O~zb=A!-fi&wNW&OQh}Oj)1gPH~q5cx6YZy`| zwp($23)G+2m`z;-@!V_h{F8>6kotV6!=3c1+8Tn1}0x)FGM)(1X&G34vB3O&bNWX{}#+e{MJXj)YHOO*3>A@ z$+Q%V75G?V+-+oeSqg*M0n=BSi_KKVk6HFgJ-?*$WjmD`A>tVRDLaW z3~?dqPY0;SFvbOs=RjSk(XQsh3H$Z(RN(QNaACnf}ez*xVcx*wYh9Pxg zqeHdJF!XWTHNHH0u zJwzr4sCz9X$n$xIXFbcX^?oW!1to>2Ge=TxYYiU11h|Hwq{N27Ri$e6R&&2!4dU5p z@SG*uu+&L8Nc~R&)Gv=vUx%((!;m_$;f7Y73F=EUX49_*@myu_EDcbP_UbMA$4NQg8IdvuIDe-#)5cy44%dSb=F=`cDkaI6oG>m$k6d8psry^o!GvKa~G&{ zTRU1DoS$KuDO=8nhw{M+rstY z^iTVvgU2|RZ6(M9Gr){v)Sxrs-BMLU6Aeg zA_+=Ma2fK&)4L0>NeCDqd^W?78qB|CxMwhcYAYa{!70hmZ+i%fL18fwYH}qTt{}Z3 zy2$muzG&I(lVFev)8&X|h`G_~tv!H{er-d{MU~`fP2ADy9#v!U{nJi}#FPPTUq#aE8^^LIDi|uI9mIwT!Prc7 z_#8%5C`3=TxTh>ww(l=BL>9e1?dSXzYcuX~!ml3HtX{cF3S5;I2cf>x4+aw-~aLQMYLSHG`hw0#SOa|Unjn8Dv;`|OS!})@N`HlR>ihlKI z8{iTEzLW)Ua9&gFt4B+bz6UV(IdGXO%E7PqEZWYpJl=})VZfX`A`f)Yy{0Hb1zbV<^A0f7hN@^ZQNM_k(*C|5${YB|p5+ z|0^#iHm|YeB9Dir6& zU-0S74$-MVyK4jwZp`AZ7&*)x6&VU}Eq zOZsp}<8};A6^A++`4(kFDfVL})OmdG(ACA1MEn$p9nS$@ppcT#@w9O&KCuzuBNQq& zFw+tZY(zWohhtq{5=L)$3nWD21GUZJ|ihb&UDo9+osimnB zC1edY*VcOBX3-Y<)3SXX@@d`&fI5w{LVd!-(u(`tI4P}=54JLvR`(-~Jq^BeU}9;N z!pw57q*a<&TJ<4DyR1-yCYF|cXm6FYA0dsgv^o>B;aeo_91}~cVZ=ry?K%@nE4mxH zOVa4}g0ZyXGsi!Wv}O}as|OK#K+^u$#NdG+v4mR5Hm_N>6Y&&1N|1;oB1X$MU#tu8?~@&&iiK>Vt2{W1}0Y05bwx8lJM-lsG8A?MDx6kQ+H7 z%d!I_wgU|{UM>e3`T#qSt(6#a*L%5*CKuke#EBZvWlYk6>>`P=z+%)myni8grI(wv zxi_;;d~!q4R_$C_t|VqpzNCVn>+Kibx4 zFRA*`wr0=0p|78@=^`n;OHu)pRL7wKNUGz|05Iz~xCL4r*WBtjxCMtg4sIc-jza^G zRL7wKNUGz|fOrZeU9CNx4(Xsh9fu~NJspRn(1wmfQfNTOv!VeVZyddgg4?X-(Yq*k zSn2~=K4TLH1Fq3EqI(J@qD9iv-iE3>T2jXmTYGW!&@5tauD-oJbsL;aGWxX!c-o^w zK3vZf)*}PdBIc^uBE%w!e+^?UDtGM|4KHft*meD z?GL`1Yo~n){t6i(4ft^1z-+|fzxy3uhcDkR>oOxhho8-(RF$Au*M4mO>j-#|fT(Zn z)KD5~RyvLGG$7G|m=+HLUxP-Zu*EeeD2)hx8{4vYusk+;yTl>GaJlifO9!-1>Fstq*(vSs&-&fhy&;s24iX-i#ZYvVp`a9x zk%agB0FOK-J(hK`3Ga+>hKbJ=z${-TB1Egj>E+8~!sW}T{5Gfn48J@kZW0N27mrfF;-HF}E}EQGR0vbnoB$v;H-x061p$plVdK2aRyT@Z?)i2BhuOsas;ea94T3WNi`c|;U7wD0b(4* zl4>Dh9}u|Jh_42U zzKr-Z^$mno>iY<%iwnLPvZG|CINYmNFZgMi!T+ z^9i*bDW&QPgm7quuuNu3Smi-Hrfx)7qHaSNSMNobkU5jyMG{jFN$wXU_bZb7Erg}& zhX|AEUl5k5mk_4ZZxEKNG`gs?It5{cIvru9T8eOrszW$c9F|Q}+Yql(S0bFQ_8^=g z4kTx)+Yqmo*_l%BM?9wPM_8gBMi^Ig-kDHeMOdo1>lRMI5SFQf2vh21gt#fg91LH$ zLRg{ZAgmM@W>XY*hE7%M5l&Oh2&)twOHLQ3W;0Yj;xpBa2&=^w&~OlssrMr+ky)Tp z_e%=DNL3P(MSMRR4~!O#KhSl+-o2fX%{l1H!mE7hyszLs+W% z5SGbzDa+N{5wB2xgs@U^hB!ri65&+!S%g*UNrcnYHxSN{nI#tO5s#_=Kv=34!#3eA z57q)tG>FI4MF`{SVuT5qS7K*|q~{Tqr~%2nR&uXLSSmA4EX*SwQx766QGbRou6}|r zp`J%rD(w$Dn-Gtw7}`LoN+C=dcVM#-M=L;x_nZ;N)pCRhv;VVRa+@WWvr+IPDIJos z7hzltAWSGeGr(7Xy1VoEaL$l?@JHc3q6eGuGFW%$A4J(RhBAG5d|0Qqr!Sv5qbsvm z3hnP0!WVXi&N^F~<>r2TcL(c!8Qk$;;crQ%d$>>5ES6;Y2bqZ58Uorc^%S`Hfa}fe zEiL-1K6w0+>+b38#pm!^F3QMq0YC4f8$BRj(ZMOb{-Dp(5=$X`R$`S1ACg!VLaw3f z5BliX99*+v^#^@;Q;}2|gbO9M2qC-Bq*{!S9b{5oMx%=5!#}obZeDB#zl#^6+kTp* z`N~~zIe8w^a6cg3u(LoLS{lPmKJ^}1IpOj`2BnExI}u{ccU@#%s$+D2J_ZND_?*Kr z?_Pov6B!UHP-Z#KYB-}%>O6_Hh4|$27xGD&ze%OZ5j)4d`stYK$x%?i>2G3MSWxpzogtMHu~h|zWsK=1@C zUYe#Nst2_UVp}3kzDb#hEY^9c;I$|?td_Th#M;Sc!V*x z%fWQyAcfT$n?X$0g$d#LE)v^f0>3;iR`D6}1jaNKT&81Mu_ZdDPp~|9DVWrRfG1EGw$#E4oZ0sxm$=z%nV*Dv_3A8rrr^n}RfUaD;2Y za78$NrV;-FXVds(6XZ2MOg#u!jWmwCg3qMQM%n_Tm2*d*td+iWg#6NlR0ipZzQKIA zxOvesEJ9iwNmi!CxGu%l5A)r+9BC|Jn#?O+I#O0$q81>nNGk@Nc#Pl0F7F?}qgRYy z7Z680#`;*0%i&#xj^5n9?n1||-h7VZTduRWe`t6xulb2(0LP;;m)n=`Y|QsI0!I1< zzdvA~g8KHplzckMB#Lo^a+CExft7EeQBt)CxY&MS6B4&=<4mNx_IMVqZQEd(GjP)7 z*<$?ii01k2-@5c-TXEZ%kEcYP>)}bxVE=PAuK9b8`CWov+Bf;K{SEDxIF{mc`$O`= zcIe~x+aYl<-L{cs0l1Jn(2I}5cklKR`dh`f=};D%dykaDKFCW#mBEHO`wBVQOkACZ z{34GfU>{{#F0nx!_wBDtToL&;TPE(#g0>xxEeGzP&6UNdE7LXuRZV+j-pSbG3c&F= zkv-zcpIT{PSK&8ROj6j`@}lG6Bu`|FU9JI6YnO~$yIhO7YnOGnwzfyOTAZ}Yb@=5G z&GYRtnisXh^}s_ryukdv0l%~%@?q_ec1_w@oMAg;S(h(6t0!%a87EsVJieW5IXiZd z9@~V^OR!Ba-L{G509;6yXcImTzfJ7HSP^a$)Jp;%#O8ipwh_vU*Q@d9s86mrZsHZ+ z9Pbd>Ug`lqiDgK;VLi;(Vo@Z}t<@_knqcC&vkQx{sC0#l|g!ga8X&QzO_Rs)%X?KB>v3@6hTF9sZsa9f-T z3!Gx+ifyKi;jyl|#K5=Uw`wv?qRg2^+hydTtISb11D|b+jN7)@hPc}nx8mBiDZ*{R z$+ox+zdWLO(YEN9i?+q>z{B>m!~C}6mu-=JxNVU*-iWhUTlDcq=ba~8ZYpr|pggqU zlPwo+i#{*Gw#anb7ITREa3Nh9+E&kY-gcR3iyXV`_{6rzw&%7*wmr8kRyl3)Qou*7 z0d_;%r~aqAZP1%@m8qS`bKBmVck%S^s)Yi~CB_WE*L-n2c!huhv2rpyl0_O2vM zXzq6v(rO@mxb2bmlWBV$fa7tZw#RnFwztc`(_L0|RC7m8FWTNJWFoEigy{RJJj$m* zce3{BYzL6`c{R(x7VyOuw2yYU-!G}^F?ejhPZ-|7x^2SV2XrHyaQyY*VyYL{JfeAi zyXCx*Wo)0&kGR_>4B(pO*=}9jZ*g!3^L*U)9%m4+yvG^BFJ&Vh+dhU7FNXIP%+Yx7 zvIqIRZ@31(JW{+j;c}wb@=RHffa+AaxAvg#0r~*X`xe@stsmY86p$X-lp(m{v3#_{Bv)}M=Eq)VGEV%dPUBgYF>K;KCuh#>D_HifVE5(>8_qxAFF8SVOWTXTc zyNw3=DQ^FP-7#XzH&Q-SNOAiQ?fn5>+8@hU`@0!&*Zyw7wY5LOy&WgVq!Ik`ux;S2 z6TrR0z=XpZ@LUUg9R?>%KZB^Q43-@5V-^ zu3WyqyA+=yB7f+=W!ao|_%2)rv?n%Lrfwr#A38?vX3};kyjs|8+`_BVW48k~Y_Irw zhtyRH_Bw`q9`7ctAT_Bg@@)GZmZQw?VH(O%=hO{h?!+1DcdD3f>+HRVyLEOCu5F$9 z*7Adi{agD`i#4f&pzXB{PJ-1N!|Ye(nFSr zaWNkI0Md);leSz6eSXm3`$POD!Wd8|6Wcr%YVA%hz)_w*0uJh)_RqN0Ab$LIo zt-c8NVVt!8kK&g{u{=9Zu{QqzU}^IY;+OEOS09(Jd&`&A^CtlB!}&DXH}hVBbzp6N z2I9C^5c{UR^E#zs1Jw7&5D)EllX=L;2@|q)^60~gwM*UnG14ch8`}DxAfLx4@muL& zkll6A`NaK~w~Zut1Cqq1bdIGpF`EXUFW82VEh`Vj*%M+CUiYb2z*66{iA|0*+Q6`>I-tdUr zl(B8=X*(O=Ww#jEh_^k}WYe3)rz5NFhy1jCq z#rDc|(?<~J8g99_-(0VQQ3rlIw)gxM&YLM3j{2!oQvxrhaE*XNJH5`+G6K^h~<{3 zlFr>|`*!W3MkRr|e;?P9ZQ4qe;>!-*!@a#8U$v@?y%P5L`f%%ktJf))RplMSg?_w{ z+TUk!H6pDGBmN*>Ph#4iLYK`d!M8pIH|_l{=#0}>`vBaQeV>}@?*zXPk4OzI+S7e1 zIUu{;k;ePCN0Ans2hW%1nn+e<<_%1YXOfl}!pkO7&Rp|t5p(?+6iDpt@3Pllz;*eM zebLN|N4vd%PzzJSs$Q~VI#FmbIxr^6d1YYv%-?PN!g{rAYld(xZ!;Av+vW8l$U7zQ$Xe%7hw?ncJo_LIgs+sAx>3JDCV0!_{fgjy zQ<=Q{;NCN_uD*`)e4di_Efn?~mp<}CssdVW8XS~u`%?e0ZvfsMtAQi-O{9_M@cp>^ z+>~SVdW_|N4OkxE!teb-jU2fJYa^u1ehOMK^9{{QLWTP&ot}#HQ#!p;rPzjZeZzY_ zd8z_!Si@DT(%%05YdWpWb5uF|j2t@+o3_AO7j$dWaQ~z&$4OhHtyy5$FD~}1RF`Ag z61*O$yGlQ;MwJ;W^YO3rUL*9=Y6E?ozQ0@_=+CrF=)XF9JBEfRyydsCXde_;?1P$} zK8W)XZc6yJsVCM%i}L3qt_$-7U^s?-SAO+;>3YODU&0~o&e>P2dLNFy0E|R7dwChv6XV#d)4gOw_IMX8<-XfZn(^3!CjULN_L3|P zI;>f}YL&zVMq-@h=tJ;0?=E8p8t~L0BnSGieB5HL3FABBVIpTh+NI8VUgCJYgx1Xs znGqPzsVFt#m(qJZqzD36&)h&0k8$@D=XZZz82?YL7i$|$NIyB-*ey7$OH_;oQaj|6 z*!k`{cl7vlOnIPqwWJ;qBM7fa}BOkg~X5m&U76beXD zfuwkBCqnYI@ax}vW+ErKv^Lhv;Ofu**p~u^BS)pyk7M)PQ-seCFw`Ijt?V<22nS(; zTIK$;c#JPdSy62J*gUlNA3}LCZ-}4MV(U#yk+C~shrzzd9VT^N9_76hK(<){2sb6hM`9Ft{ zuVF}?*nWlcRBX}IW2U7Z#M5gK?2}(BJ6H};r>i!f`c0;k|1%f)8iv$~jnw}T)Y0EqttH&X`lLirj-A)3Dh+VsS_J<%tc3ZivU^KgLwYPAkbV`*-1xe zd7A$~fci&FDgUPn)HMvL6C0_Y3+kf+WT^-7e9Ryi(=bN%DD_VVsDHwg@_*hA>KcaB ziLD*y1)zSH09oomJfAWM^wi4AE~6rHe4CFaT+M&hl=6T0?R5=9>csXfoL7VT9|(}8 z9>nvwL7;2EQkNbbIX?C81gL+*l=6R`0(A{T>cn;h&c6Wl2Lvek`IB5x_p)nhYGken za;STmv%#fcHLi4ul_JQ`b3#KYJvXsZ=n}3JOVOCcqR>L&&eW9hf1ZaF8irC3TL$O% zAjLxhM1I!Ptd!9{$WIXS4+I*{4di!Xel`dA`H3mz|NIa5(JN3?cCH2o^psry^o!HotdO-a<0$`~J@$hLAkMBunWv7%Psb?)M0qUiuloXQS zUjeRRNS)Xy`&&U>AC`I$Pbz@NQimagsPm3f_!0QZU@2LjS+s+6X0l|AUYUYNIV!Wh zzQ%pmfesv-=r$9H&XQC%yQx_`>DA{h3WCG6VOzt_O?2W`pKF>ZF9-jdgL!P9?FHEK z?3>^u(w15Cf7p8$_^PTae|+6Xa&KBDO4*iPS%X>DgZXl=32srKpgF}AfGG<1I0VLEh%4!`er?Y+_W%3;K0i)!_FZT1wbxqvz0W>-tsRbY+5CF7Dad8M`f!l5qByDyGeH~%?pCWn zmlP0C1C!TG&sSG4$)^3pYqGNo163$2xtYxa^@RwU3)crWfYcjHs+7XpbZ}zvD1@%> z<)xlxNEsGhD=dOkr0^()x0X9%6t#X~jQ<4}c~1nN3(H0DC@I=G`#MFJvxe*K5Ub`%MaCAk#HMXdk_a zq>HbGF`SHkwJNBrj;O76#j4bCXOu(R3pX!BD{8qA(+QaioMwwhQPt959zBkJYk;#hfLF|t-(Lc6 zGjP6Q@yK^13x_WPC&2{=T*OnpruSZ{o^bfyaw>4%5x`S=c@`b#0`J2X$HlFuMaRHs zK>wedDe|j4yg$-H-wf3O!>h$87W(G*Z}jZt{JCxPZ9uZPxW%>CAJ)LpD{@LuhBm3)QlDX0EHDG!4(c%&XyXJWh}P^5%q)M7#@;gO0LtKUuw zrR1}o-&3C7&pf|hcz&m%`<|_F&#+KR?(+NwJwG);$kh9MB>cPD8=$ulgnpD4z7OR|Xaw4&Aw z!v0Ca;eqXG*}Vd`Pli^&A`c9oB!|)uAkM(9qsMZWs85Y*xE~%|q6omOuX)#h?11T* z!?fbVm}#{TgGZP_I{FH`6!ne|&5y(2jDZK|$CX-qU`JeTJ(ng`;6pn!xBuc8Vhpw% zGT}qD1JA&A4Md3#)((#`h@SHIV8fxI#zU~CHL&Z*vHr6()CiH>AHM_L!ZD4Sb}~aE zW{|O*lD>Yh5nPf1YNR8(%Rv*FJ9kCJ?)2v6?aV!OY`LHa4k49uTaHxkyOXeH@xhXX5_&B27Q?xE<;5EH#IVJ z6vFR14{47z990uSke~+eP(O(8MqwTrs!z_XxIafSiQ%t&9+g~fGNuD60iKFGt*5&3 z4dcuJWi_nN5pMU^~wYJb5h;EIaFP_Js$7k+AsO)UMJQ4PpbQK#Egt#pTc*h zF}U3}=qZ4w;x0$ecs_o4ogydI{VzsdoK*LB<6fj@HuA%5#lHeDKYzF_|8wx{>J#xU z$9+=W-_Hj(b}^5*UEI&3u!=GLnXkk((}!Do7&VPpbQC^+QWMsqW9OX?xHf@59X%SgPaj!rc9&y8lUa z|C8$eXbUIR{e$Z5ejma22!75lrrz$}{ZFd*eTRvF*Y33oJ z`xEocH*q^)nYZ(g@1Dl=nQu}C=FvbfDKWgBnsBDILgM`9uK0Y$J1$Q1?aeVhpVJcS zZ0j=SC4NR8A#>ez5$-IYocZP@xW*Ed7B&AwlgBRskJr!fJ0YB6HATR3M@oQVAEVq0!6s$YETzMX_<>?f#8Kw%@u@l`W!WjPbdKsJG zCV1`-+PJT`#ZV6_=d)JEBHRGaP473K`I+Z@30UiS8DkS^KpSv#gS^=}#V{Yr=&lx= zxpNSJT1inQ~x+ zS8$sgL#zn%_I%u1P!r6KIae0pT)hA|yk@BD%7VEbE{nH1AI%!*edJvc_!}H@C$+=4 zcY!;%$D&4Z%@TdSKA3c^GY?_P+yThz8g-pKtf66f2Eb2!RG!6(9dt7AH#n4s)VOW^ z8<59b*(|KzwDsB!!sK&nuGNMTEf$$;pStg<{kj32>M3im;;6Fj?CBwjST(gTssOAyA79ibF`3nx+7AOUl=K@=r>B(>~Pp+^P$ie*7>8xVPHd|r+gRE63kLDFob0&Wv>g<56Tr*{wu&! z9WJLYQC|?OT4CONB`+N6cZ-_lQ7!G_%V!5wr839WmAZV^>`OHUb*1W5SL&=wF-5c` zQ%qNi2kV8dBDzxFK|eARcrmNTGX)Wf=}Mi7K4}Zu%-v~xj>LXcZ19%M2)a_{5MiHl zeNBCR(6SIiF2lXV(_l5Ys$&%BJn743u?KihT3j{=)s+g^L?IqGn^sID1U)VNjTF^^ zT7&Ql5k6>f*})dmsj7wldo0e!Mxplx;C%++mByfucGx4)JJaIK(BIfz5q|%1 z=)nwye8A#-VHA2>fwvFg7czrzjg(##tIPvV3+^m#92!_O|Jc>HA^dB&d5uJm-T6;} zQ_fAtxQJIwC+#-)p8=fr2Jnnd8jKunGMdMX--Gi1l*QpQuRnvXnX!+9MvVgvUvFKr zMR^;q4Hih?Zg0jJ37p1et4jt&DXVV|1vya9h@gA;@!kkJd0+x zoQ6m8$l)G?k9+-HTT~S-yRo}>YilQ!vKHsb_er2~cJNW$+kN>a`#P;oK4bY`O$+$~ zQbEfTFsOFb4SJJt<8r!LH-mg+CxzgBj&3A17<8S^I=izcd_f``iCmv2_47btu6_&m zHXqrXA`%dB&K#$QTacS1dvzXJ)@PE{{>Udgp)fOg+qQLdsfrrUtMhW8$`%m|AO=IA zWRkC|cdli^eebvXOvV*5+1lE>rKsEud2)Xhq*#diaNpsRJfo20I<53=8#IqdoBD8` z_)f!);zzpp zDJP!e(A?dV^eKyyVhM&tvwUdhM+Mc7Y%TMDAyNWqxV!qPo6-Wd#aVG9N z{n8B_r0ANcry$N;B+G)5<))fQ534D8^C{NdsYRF1m185@0;U7vtl=YW5w2)rM(w<4 zUA;W7uAXJ-o{rzg{M48Ov$R?^<$CAL!5LYO+{3`~v`^;bk?RB*W==cqclzYgez_?* zJ?4!BSvWLS?-5*(N01saOm}sd;AwdT1HB;_I8j5C^Lv+bEafxt`*vT{K<}cWdP`IV zL|yOl03yda+qHMeXAE}_EUjGsZ1!u=hM9fPN zP~qfc+g>F=5~tMjLFJ0B_QqKVfj*B*H5u4ZLcCGJ&8efIS6XU?&xI z!rp~M^QM8ukLM?U!aiC8Z1%?Q(C`Zo{?+-@p%Z&_fBh^KL)8YK!I866`c11+ z>mlZm7yr=A7w%m#{jL{s-KwiP0Xm>i2ZdViGjUZ2h7#@3xr;K}nkavYIaD(gJ=Qdh zq7iQ>I#hG4Idj*({tFlg-Q~kjwH<6xb=h3)W(acxQ5ugN8#CB&a5%BQ;UKvWzZ>kB zZ#kpcIsy6NDYsfRT-C*O$7h3G)1!RW3n`CZN*orG_p_c9PPqQ5|SJ));kK6q<)^ zbgPk2=vK2f4AoCMf8KxqQn}H%xye++l`C{9pfca<}T9gI&5kkd_m># zF{4kd*##|Z%`PZw``M*zZFWKX+hiBCzo!g8q`KZH%j6Jiw;nvMbu=^B`0`N0%QL@r z@1p5HmznwhNz0&Id(laHcq)BlMvGfkUw+ z)a<4)0T5Y%difB#Y0>;dH|DoZh7Zm|)jc$@6P;d7JM)QDkb8%YHA8R^oS=>J(BKku zj(kKd(u$6llUN$)G#iiZP2WR~O=wBr2+SjUEABw3rrt^gOp_<@WnuofKHT{+qIQ0u ze1Vr8YCi#Wc+o7A)ocdyXQ9@wU^y&7zk6h;2|D-3;GiwJy62i&{VYq#dJJ4HxoQ@o z-`!2|csb(;z`21{8aQkl=n^6CVOBo-$jW!Adch>KY~^F8%HD_79F^~o$<)K9 zqYg^rMi*nJKm}|}x{<*AvUf-h)eeUHkbzxE$(6IYfm4zNE)PpCgX9F)qp)t^&7kskw&N-at!A?L#_lPlns z%RIQ1vJ!5Uw8O2I9NZcifLkkf!5t%SgIlL1jR_y%Q{?RJwslFJ5~Mw_Z&GF zJv5@sTOwoO!c(u8u36vO)zzKL zz@lRJ`b>_e$Yjhi5W+_bvjk4y=WO5vja4M^tZzNYb@NieS4i_xQHmC7UL{KPB$rF@ zRH{}hu2d)k_d129z-8|eG=4$jDV%Y|(W8!GM@ZHH16Gh$4`K5rI%hgvKOalXU20>2a$-Ig8x8 zICd~E=()!Wi4<92!zxzeh@#Zk&+q_o_*qz14YQiuYCEy%@((!T|=NRrb-zg2n zi(o6AqG=d6*Ns4dFiG^%qYg;Ifma7{5ttahjAwm7q^imA}+4u zL3xyi%`b;{3ghA0i8GjZHg62iJRgcYc-5J;)KK-Hp^+rQNh)Y)gvLiWy7*^H8$6CP z#53nf8zUtoPdw+xrVjQ2rSDUv8h#TTJyirhRgG6nf?vL}DHVG&@b`^2m^4g*UkvNj zE=_ELCA#2j&ekH23+QLh*5by=@$f6sDtM+?WFo@C8x>;_=GBRuUwta@c;#c%nSy6bGSv_Xf6u`)>o?_ceFf_;X`G8Y*jG>% zwnLx3-wsKG{;rK&5W>q#4=S@yBOR>|C=-0o5oQE*K&SD0S=WyMQMJ}YD_vJx1>PAS@w#`scvyL+CMC#*3 zz~gni`p8YT7hBxv_)Qi|DeBmaqT|abUl44)oB^7yUJ`coau(oVy}T69uI>?UCT`Zt z%kayqFwC!)g<*yDa5m_${#|Z=Y3PJ?h;q1k$a+oQb8+X_L&gotl|N3MXgoItxw`Gs z4A*V?yShCOu#cCQC#c)OFju!XqtEA=zrniA^kHLnHV0$bPI-sQ%e3RpXO4e36DiBh zKdkq2z;~1q*80!8$3tYwCL4j z+X^fb%R-CafZv+YauRWhpG95pRZo>Ct^+;SrU<(>wHR=)O)bH*Ya7I);Tg86zrZiA z!mz?N<;N>*Q%gaI?V{2CF2gU|6y*rEDbi@dU93&{^b6;HCmJumP5Cs#ZHoS`O_Mn+KdZ#&nsPg+lGjr--cE>nzjwK5QqCiJUQy*2KY@!n)BNbWj~QN zv>JH4j@O3R9@vK7VDWFnZ@Mt&MmQ(DT;IOT<_KfxaSh_9z<0EErpdJDyRshN#5kx6 zLBk(wEgjc?6DNy1ShwB0oVz@T$6p^WBJ1(Yt1!%Of1siKUEAJ>IKj5P$(9!mk)zXZWKP;e1zEhhJXd^Ns6d1N@P7IG@;UQZaM# zHu&>Bf_2Z859j4u;9v03U)x12vK3*$`sT`mWtl+fbRnEqH-6)VR7UMvwam?8koK)_ z0u9r*a^|jGy88FgA3R(>IhgZP!md6relPA|eP9^NqF5Nqnf|VvcK~J?xH_~G&xP@g zk`~as_t$>lu`l9Xh#!+(2eDD)Vwq25SMc! z^7579ymQvg@}chaq=J?4uaK0#1r&AI`PWD}PVdG3z1}Tty?wraS|VGB!;NwiglC>( zf2@s1zey6!@l0@slfjw9*s|t5#|*gx3uF3=23Kf%Rg_7nO2${zT0&7st61O@*(UEzf{&PGShTKaduBMrYwlLdC; zC27Z$_qeX^>tKSXbyFM8*zRmwZw~zK^TN}ciiBF)w}Upeaz7mqzT%=(2}MKx)m z%o*TUpfB_mSS_sqgiS%1TccpPux-qe;2H8U-G3PFOJlk_FxZbWZEr?g=GoG=?N%W@ z78!(Ju>a)w-uJ?f`JX=yv)6O|9{bnH=wF9`%j+%py}YnQM;L>{TgTWY??Zgkw?-6p zect`>5B7Nv;91)ycrwmgadY1KHvIB(eIxtcVt5Z)JlEH~9nb8G9x95De6aYGk+Qh{ zh4jh)Vcfy~qn_IKl%blA80JR2<->eg1+Mp!l|xt?5ambekhRF}tpCZ0W{a$>AaYBr;tiN=4xAn&@4K*$i-I&N1! zLjMYu7eA(((LUxMy&ixrRN1n>$f>CA5?&C#h49jURL&^SX`t zONZP|x*Dw?cmMn8Vv-fdOPBlP9gd}uLT9HX;T4Olf$K^jfgJS*Lyvj5cl!|!Np1YFXp;VBLk%#*OjcNCn4AKNTOl_=;g4dlFgWqGEhBLaE4^I(w!@1j~YSOe%OvFR#Vw22-Ipp;Q#c z(nz6Ha0VGZNxZxu72G=zi}33?-_Dj^IlskEMZHZ$rKW;X5s#XJ{LCCK3(_&Ea2*c_ z5yz_0la%6ksUWSwSd4>M0p)UjEXUh1TvryA1*xDmMJ$qrOP#|zANad(_}J|>73OSu zN<}>CCz|$9crIB8RHOLcrcIY{lGoK zT>2#L&x|#D^N`~kd)qjknoA|LJ(7v#@_DJnFe9nUXKj%P@lV12Ao%$`?K&IF|M?!m z4NeAWCpGp%hagYCBDqoy(=lxiYJUbNP zZg9w*)V_-QZg77 zgFAPg`h8}Y&i6G;h8)3t|F0i~FSB9=tvi}ZC_+yauC2S~=@aK@w;7~$Ry8`#kknl-E z+4c!xI#fpD^yiiQ~-c@SKGYY8%V{c@NMH4!M)sISj<2 z*tZqQaSzjJ&@hqj7#y4PrnLpr{+kf@#Wt4z^F?qsIOI-h?88szlAKizG zQ?d=Cg=e+Ds=vH`CYF3JpB}#Q&P+FNNA>lW&9A4OpUzx=U)u&f1>NTmI0@aMH}V|$ z5zo-}7ek9gMLN`Ui?`Kv6rA8HX>qjGnqlV9ZeL<2CV07nyKxMC(Qxl*`>-{dqPS|2 z1}1lKW<3w;#@ebDUUA7r$se;|T|Ame5SOouhil%M47MxT#qma9ui51m?Tf@*Y|pI^ zuHlb@=6%vDf&&{oPKZ&CL@&(fBJr5p*oPHhg8m=PXnunhgl_aJ2(&4=<`SQUi8Zf5 z3-X%4q46$Y^}PAlPp^mBplgbTy7YwhN!AlTb@3&agbrmtuAQMvX3v_Q;YB+`C2D8r z(WxS9ZRb(U&d^U>$Krldg=ez=ggqwutAFM|f(tLAMePjj#4PETScrHdrYE1nU50nI z4DAdB)}9#uI@}j>aviwpi=0t@0cP#|LKeLKNV_o?>aqhC+=?3XTSz-KYv!$7H6I5o zyxt~bX69|>ZbvfM^KZn>@9XA@R9g0P=3r9?zEc}DeSXL;$@X@4=iDLW`e_@V0@ncz z(TznIgO+RUP$Mw2^Eh%Hg+;a!xBGIBH{M#0V_*Ne_3a&F+2{*S{m@AMOJ-uz+y=e9ngGM$yF`Qi7EE3P* zWt!Xn^Ap(tdL-Y5J3!t~q;ALW-a%pqN2MOLcd`uB&33ElNyxh*QtEL!esk#9s&dg_tQ!bJ((MmxhL^QC%ZwArU9@<->l?@_9 zw&8=2Cr!du%5Xl}Iyoaxyt~1a`E&wM@7W!cXhwicA2Lh28z@I(J~-(w4RjZ1r>I1Q_yDz1Dxnkl*wp9z%UnhS%n$ ziYtgr)eX4)9xIY5&X6LsaSxZ80b-$gj6>zp*|yO$1;xZh`?VCP4eg8a7kQ$%1!K(B zgB5YAm%+VlJ>9*zQW5{*Zym=aAbv;o}rUt~S)57NHJUQiv;Cdny4;CJo1BAH85Al!Rrzm!$uF@eWq z7RoVQ*wjGct4O?Q!GcvQv!K8)Y24Y9u=&GhMoFwh4EW_47vW<+5^N2B@OXQE>#l&R z4Z7u?)?OHqB#ASDCM}Bk~bJefPLMgcg(0ui~%|afZ&rI|d| z)H!qCD{lcB$UCDEFgyVM#^%FH7<&L)7?l9S`QUXJ+WP}LP|nd|U>uSDs-c#HFk=Fh zedOA(8UTO?jl|HSknHeZQ99EZ<1_aS zchGtOY>*s=F%@PKO90YLWNt0?m0+9Kkp8^*FpB)h{`qJx*60aRZ*Wn&pfC$P|6>+6 zX>mEM!&Ji&FDLV)NFc`^B1)bhNA}mF3!?v#{qrgmf_WG=iK&n>sG;kGqnQP$>_X5* z6~zRds);HTRO4v|E~*(xXul?t2+j7O4WKw+wg+t%av>ww3Y#`VU}T+Fc~#;%G$U3` zSb~7@n7Gz0wz;HOTPy9FJ`jYNgrmorSKG|8&9O;?+v|a(Q3sx_2E<;dq95s^$_L64 z@Qp()o*z>-!Y$RF9-C4DM|3h3l{*2)gpDCC?^m1;!A}tO(Iv8|{2Sny z{1@D~B$191{+`7Yd~d>?L^jw^V{1RRxL!;Q;9xTR_yAtC<- zI4PwViOQrBZn>NRw?d}Et&(|gt7RqJ8rcB1R&ItnMz+JPlRM$2<*jhX$~)kWlXt-# zZ#Ne_0XQNbfg4jBSxI>oaGAUeHzkMQmJ4^-R>&l{m2w8$DjnUR00=lDGvLPL8n|(3 zgj*svz%7+lxCz+|Hz~KnEt9=)Q}R~0BaZ7q~Gw1UD|fhg%|1)SgnIU9N;of}50!;g;FY*;fL_2WGfY9aT~L)Mu;u z@brb4%**B4w)W&;MIh7d=7pIJm=wTCrAr%7cXC^;j-sgbvA1zx12&ZEWZ{z z#U-?KSvk=_6E+E9r-Z^3#VzD${L_Imz6cK2Xi1;p#c04n%GNgQh$c=3IAaVA zO=;_fn_IiqQ{y5kXClnXr(yUwhbe=RZz{q{vOWEM?dJI$JY(N=H#KP(_gp+zZf(u2 zZ_h&TTt{oC@xK86Wu&HI#_uBdRnQMBRJvQs(zqD@2|7z|YES^GpeW=NQ%0 zW*x2E(AL(opu1ah+^qBApYeDEAh(D$iTf16&+nXLnhn05lg87`RWl?+S=0t z4JOTZrez`g;{0%9@#wdRca*{|zsV2<1RSdKB( zyiQV9)*(xe`P~G1WnFf4zR#5TV)(Cuf2H+CliSd?-O%|9guyn&oBBJb*-)n%!+dFV z+C$WKSPq<^#s&Q-(}`&3t^gkETfVkLvH33N%QNs=(~LO0R%%?o2H*GpQ;mlfD=%fv zxOHfhN%8r=TXi<`)f*7kXfQ=<6b219rtx_-?)>*5j_H1wKc=D2R~l}vK@H{LT!UI* zZVU>>zX|@l3d8(4ftzbkGnxF?T3Y-@;nVW*-Pp%)UZm}CjZf6mTIQUAVZpf`zjC@e zD3^&FlZ^qo;rtjaEIf`{-P(qwrgciR_q+aIih z-x^33!{;vc8N^B0Z<6jg={|vKoO1nqSfX$H>>tYYt2O$~E~5n*(~r4H_YGO&7{3Jk z_)U?02>Gl9-)cuY&=)go1H#66Ve8s(q)D4a(Y}&6?Z6r9;b`w_Q7BhJKSKF^l;PQl zIFm;E)Mez2;EQ`fe@31s(w}t#Z>0WgQtu6Vab-MI2sT_^t3tZ6u3K#lCTw zzM=>5U0z->X4Cfcda?Dlx@XO1!K|joIuMFdSc%(44F+VKa=g{BvIokmT z`@EPB3b*$b7 zSgn^KnC*_wC1}enpv|_t3(v($o#QMup2K5rBEoz~v#sZU*tYeX;U`j;_WoTo} z;X}1&`|=LTP*iH8sn~;@<(kwCtVzwW<93eOEs^zHkK?&Tn+m)2&DmZafbqRW5e!L<|cR|@|6 zV2axGx*phvyd-bd`@sP3itu+|)ym}iu3LYjEQXga%Ui50C%P}$?oF}^j<1(aBX@Lh z7ngqpb>x`NScJQ|xPxoqH)p)!<1znv8J$MH5wLgWZZDH+w>#G0VBF^7i|(N1FL$+$ zwlA5q$lb)6MdZ+R7M=`F277Z!jeDGa4(@!n0A;(6JWR*!Z#F4*`;wEuS6<$}$tPr!fEdbaVM|vbvqsn4!M(B2ku?qexV||oDb9CD9p?3 zOLyGM;1lNlVu(A}DZD+0FT&BN{J8Mmt`+M-=LVX~G zu}`iMJm)Du28Y~9?QYyttIZY%Kj*`A9=GwY(qG4&^V%@?$$0d+f6~VCe_jA+aLAq1 zK8w2*+~+HjOM95kmo&^B?d!Pn6HA!;k3!tZD}4Po9t{q;FT@k~I(-Y=O}%#9!*txP zQd5f^_rh|&6y1rR_Fsiruip#aWhf@)j=e0mAKNThhcPC!dX4tTI_jCSmI9A{oS?sn!u5u@C z__`ITyoT=r_4YlZzJBGr)lKuTo%xdb>C?I0*}WO~7}$ngfWjArQ83)JKa9f7+xF$9 zFhJi}eD9S;CKc>P#_R9#162b85-ULykUx>CuQy0uIu+NS{gGH<9Fx@Ry-1oPqrH!W zWYR6@Rs+Gz08|RAcyRG0GykZ4;WICve#tCu3)g+&=KR@2x5(q#-=UUl=!J=zo7-Fo zp9A1T&YxY0TEX*Y?>2+4Zf4N)XV>-hIa>VHb5nvIfcNNrZ{H>XgO`EUFWA5XS3U9a z&Wn8lT7A>8|KbOiVitoA@e8spk`e4P&pUs1Dd=p(p#3S_yx8*>JAZZx{Clnyc@Xz| zaYxWHik)}53V5GDc-(d}7&eNYKg%`E2^MFT{&Jm}`{4ClRMT|J=j*LUa82F@ z-vyAq4EHs-AN59+$V631F(S;FW9;XcC%2vYoj~@^N6g0aO6)z`nZFx5=urFrejRiv{(@GE{sR);Fm(p3dT&a|+MOj?RnQFc8nB37;^e9GY} z${J7Fp?nL`-V)9=KCwP4-}U61e@;o0<;!s}kVWR45|>4odTxa>0=T!fx3#J&P^evp z*mRK16?qx=4v=RHydU?6{p8h!G7feL@h!9<^IQezmiuTn=ailP8js1wj=sKCSoguw zpLQ8EM3zv`?kzktI}LtZ5-XkG%7c%I#_r-thqkgUM{)Cex~;&WxSMc)6u9Psa>%k( zOPgJ;7;&@P`Z_ipPiFGSZB@CGS&+E_tvuaN*^%zQE!B1@$u9rZpur#=G(%|HwK%Y5qXsh*pdI(s(m? zFmrCl9cTpM(jc!5ZQ3y$2##`&8B-s@0*$G)CNH`+sO}asRD*k%d#?K~1vPxl4{H7` zf&jB{<04tA=4Aj!aJH~f%Tp@rSirpV)A3W_G95p}9cW|WbhK?~Ti?AwN5?-U9sQK2 zjq)%ZCRM>C+=OuZ=5-=T$e-AuE+Ao8>B8^l{bCP~n%B--yp$Qu`r*ws$c@F!S{2#C z6WL#afE-iGwqi_CYv~*d(VJKvk25{@o@{KFoa+H%S87E)P{7E&{FR)yI69-{= z$CooascviR+qA)TTP(mB3LsQFpes=LN)e>}ZJ&0y=8^VDq{%9x*_$u+WGnWW`2CJg zx=`#Hqtj+07+pE(G$)_ac?jjWG6naiM&cCG)b!eqV?74Z+;M056?UQ}&o!0r`sBkE zwntxxSFt88!ya!o)KKs27_l*NL}6j%PfN;eg)G7E-}#Kf(-M6nyN<6=3%k3NPiW+F z>g-=Y{F1)ldk{HeyTxM7!hF^YWGC8#J1~D9iS@PE%~ddHx-^Fv<@eS#HjOF#2Ffbj zTWcCS3WsIa{js#-z5ShDHiuZw&6~9I>{g~N5@tCzH2+bS-TnHS8_LiVNAG=cL0*DKV18O*g0&vK4ie-{wV|sO>gS%# z2d~wW_&9tmXUB~FfvXytvy0}fYFL?F(9{GQ@#Ow9Z_5;*{FR3iUSVP9Y7FjBWBXNLji?Sj9tazNVCJvp zlpyVKCL-W61Qa=2>r4bSB50K3hp2S@6QBgo`k?an0r=S+?ql(&qnKv3^5jrPiF=TP zW$L}4y|p(_hn#|OySfo9WcP)M;VzkgUHg^T&D^?`sy#0uAhCIC5AE&~@f~4AlV6lO z1McM*Pj7%d3ra*mIccxT`jWyrO`a}$zS?>%V*LWKQrVq516+URaW%66T~?w3`^yM0 z3hc}Q#w_z9k~W8`#Lca+d(fAAA0z|i0_vrG#e*e^mWw!;KL5 z0{V>l{g;JOvKIZt7u9crg;Me>K+mY(D;7#g7p8t+Q@>sdfiIx%sNXLwl#=_=Q~X^0 z9<&hh6i^&Fj4mo=pp@*eP`T{#{GJ8G0l8eBvrtN|L?q)^Z=saD84!&Sl*^EXQi3-Z zIYa%nTPP)e05nbgBIw5m!JGgfu0of~hb)A>tW~gAsD33D!s*X|>eX+pg;MfWK-a0? z*DaLN@AOUTcW$)^p_JSQ=mzzBn}t%?^M)@n>PNi`LMh$(wMG4Ih94p1J)oP_?-dKB z!aZEQERrh%2k8;}%NExtLaM(K5QwLda)8 z$PnPwTPP)2Kqv_Kt+x>JDjHALWa{^X27tgr=EBUvwymvQ8#3OaUxo)s_x1PCFi6`5 zDtj(C|NP8Wyc>eH4#=4{9W^p`l~-{%*MQz94w~)BwP&VofFK5ULq{KnnByQ{+19<0 zt1x`+N9;KntU2Ubw`VX#@9xdC<}znZ?K=zMOkaj?Q!tkSQ08g?MTUPzmp}ym^2gxb z0)P7L!q+Ce9?nsn){S`KLDJB5Vsw=Z=$sIL#~1`D$Da~Mvp%RM3p(|QX9bA{Ow=f5GF)LgaBbsEUnV2k|3|6Rc*e@o&pwZfeQsTh`Bx7(o`Z9f3 zKiBNNC4b|2Ws0Qsg>}U3=-Gmj}VHJbc2M*9@;8_?!I6U;g2LP)ni6g$h zvzuY<88{M0VADg5Ou$S=&ETRn1G~~NEz(YEu&1C@)$jv)ZTQfb#soEd09z0o=jgS+ zzDFT7*MR;*j5&spPzKJ^WUn#X0P7G(haMoO!Tax2N{DffA7lURZ@~jE z+rySBN4@c*^}hZih7N0;Dv)Q1!Mge4K}qq zc0f8guFN&i=9M%eP*j9+NG4sOgJ9MmB z+XU(z%!4ev_vr9vfW3ddselcK_wU&Q2E4T8Xu8>=jBHJ&0B7!_*_7({?E}ut7Y3dp z79O9O`%JC}r~{wZ^31`a&0!n3`)tajMGNyEXp+QeZfCsqdN{WDU|0vSmE3J-D<1Q* zne6Xjj1@&oJvFBn5fGm>e*=|IJ?Mq-#5P4V+rfOPWwXV8E6RiW_+ z7!5X}J2^79<>+md%q^3^is4@bD6yy8-*D7bprcxWAOia#Rv<)lDXkd(XFTk$H~o*2 z9-4papmt9ADS*&9MDH)B{NRfQ3ZpFe)iRyikjz~Oqc5(1g^ifxV67iM)R-PbE={0K zD{NZYH$2N`rRJT@%6s-8tS~q4r8lkYv#SVnOppWRb3CbN^yg1zX1W+#V~R3EIW_so zY;yT=*S`J>(P!_c)ToX%Cfz=w%MU~!jH-m7z9Kj9Oa%FY9)Kx(U=QLNA6WlErJMXb z1MjEzACVm+OK7s@Ph_lFGjNdg*49zS=&;rZ9s6JasL?zkL+a3*L}&@@Fil|{KGsw* z{LMhU4Nzh}`BWN?vUa)HXdvj{(5x$lf8@os1JJ$$!U zM}w9_%5b*#IVY&-OyJ)$oNXN~2QvYcK z(30sNU(iV>UwH|X2X;+}^rs60hnEF8zC6_MGP{wNk2R-@n0tb~HMAv@69Y#gyT=sL z!^91>%b?t~Z+9(P89IH}wM`m6gAa>(hFa1?@dt{rz?4dBDyENj?Yns#W`ux8b?jv?ty_t4-?b^0xvf}=h2YdT`dYrjH6DBBNT(_fVWA?NX2mUcygg64roan8L1?^ zq3w_g>52WxK#GpeZ9LrjfDY})k;u&r2M%JglpOf{2bh%pN$m%)mgGuhu;C}1lC}I~ zP+uE1d&M=_@S~xIAEEW_#ft%K?ZLd<9VGBo7D`2WcTGE~F)q5H z-pu$18@@Tz@=dndZ=%(rn3CoVsM#hFX7Q9O_@P}KB7%l^0J`MpaLFq>@x>GkUaj{b zxd+vHAL?YD&r1b9FBkY6DDXk0VqWZSL;dr|K$n2$h8mt@C-59PfuY8i1|#etOyE$< z%P`!CJ_2R*G7^bd8c+^!5`mtuf<_$=4>o>psO5Vuz476#Z1Iig^bQX#z4z!KV!nj( zAG(LdN862unmy``FO$;CLn+e@;cd!LXYON)gZ@6Mg^El>5-LdR@L?trAVb(;`kvqg- zkIxZ=gFEKx$)Son_`1;Si^Fan|H%D=7)uNL$Fw!!r*-CkGDET5-Ke?5e#RFKHPoc% zu6@;aX^wF=q(h&XAKmYUzCT}%Rs2ag#zD)-^gqclwM=TVKWSctY?H3|JWE`w-Eo5{ z3fByhW>B*fYJ3VOXlv0LY-FY7V46f19vD4Ps(jg?SZI9qjj+Gum6z#(Hx~2GcpGLN ziZeWk!bR*qHmjbeh6W#3q__uc%{`z4#*uMiSQ&wJ1;bngF1;h#13)A z8rStHk^dvh<;c(j6wVb*;oCl5%}wqUN&Bc}5U!3kKlrwe>9Wlax9;FoNmxleGO$DQ z;J9^@i(BD5@TTa0S{`7!^JmBgyVyB&4~v_l6Go3a2*)rIU_Iz|!df4=cp|wTw!GVB zXjRl2f^{6M2Dnnfdk66f%c+L(cF#~s8V{>EsBu~i(e;2S;}woASpNx5K|OI<|D3pl zow$TY5SKynCy1-@{uFVw+w_+`XYONT#K$hxfG(8`ps~2qy0g_lE4S_Ew>_I$Z>gO8zT|fqJX~N;P05YMU z_57ao{Qk@HdqdL2fB|XC;}H+~f(QLOAj4y7nZuh6$oQ=S^kYrYTF-Acpnp=o0YD}X z?g3=-;N5^;)X?{Pp-*_BPXYRohJMKl{jwMO0wBZp*MPW{vlMHxj>jPn?-(F{y-iD5 z3Y$O_uL_Wnr4EphIU>(#mfOQc>FHBSwn9J z^n!-o?S&3`p&tZvMDe}|=r;;|6%fB+mI}_Kk_ zG*M$50W?9O1jy1%a$3d#GG#Q&^IHbU)Z!Ze{aoq&(8D|IK~vCdO$%)XWT?E|^W(Q{ zL*-vR2sVN(-f4i&Qd#&_+r(}0pbkK1YAE)L*;GQi$foiRK-^J~mP3FHkKY3_l4fe0 z-wZ&8GOd1{uk>h-$oRe4gSd<5JPqZxCX=UBbTWDR89;_x6yL#9T1E*#GZ6!3vpv5v zJ?LyN^dip>n~ZGS#a`$N&u=}TB`QHXAS1z6Kt_UXfEFvaqkxR`6Y;J6jT&PrAmi5v zXpQ1t1ez3&?~{1hid4PxnG6 zd!c&)-Kn8(^FrV0g?w(zG5rp1%(KH1nEG#m8u8M=VF5?viyHczhSJ=6Tz&z!M0ZW0cLp5M zomJQch|xVJJjpgLYatu#ivW(uWpJZ1UqhE^=#6k;jvj6)&fw5|fSZ)J!!47?;HGr9 z6}Gekj>}izmdNvPOXa6<6Y>h&r2ISF3K@erLZvK$TP3UDR;&5+I@t<1Ew{oQrzgCQ zmk$7*AfJFcNqzwLbom9`vm}YR#o00*?m2Qc+-Yh%;#^q>_&nX?g>nR3DfhvxlJ~%^ zme0W*qct6Ssucby+&bB#X+H>9GYV-x2lJGe?)QQ+3gD=$RiDjpOJxV#gzo%8{RJG6 zx516dd*H_9BXCRPvv5o0n{X5IeYi<^5pGHjz%7>~<~J2m3Aa*ri=i$6j>t5)QJD!h zF4w{>kruefbGQlF2{)P{2|78@Mq&B`&VJ z({N&_`v1H7pN5%LT-yRl18`DS!mW@8;nv7^;f|4);MVDmHIe@XI3_8~ZE!FF+%kD9 z+?0F@Zn=CNZiRdkZk7B8+-f-`MH@s{z#Stu!bJ(fP0QQhj@7YEL z4mcuP;6`N|+?ec!TO#j=n~)E|P0AYC@~?0&l0U$`SS=k*mx-8-Tqftkoh=u_ zog-JmohwV=UMYVG_bTazd$sI_dyU)!w?Q6(d!6q86Zvbv5!nYfCf|iyA_w56WGChz z<#IRN3b_|%jXVW+jC=`hTKh(0eaGB~_rc_&~T$Kf?KVU`{16UI~GNE6Gr8;@QKTp;o^M^ZbE(lHz~h? zTPBC$rsQ{U%jFMnu{#$t2GlpWwYtj@wF5A$7{iUr)o@E>3EYHS4>u`qgj*(1O9h=< z;9`#`+zPo9ZnfM8w@!WsH!Zc86O5I~a3|=lNmzjc9F;5J#$_4YQn?XsLa>(~l()kz zliT2?=)UaVf)Wpj5`fO~^TLlhOzm`z+y>%Uy7*erRV_uH zo4u-~dh&R=`eoq9y}6~T8pM6BrD`3FwX_uNo;gftI@~1+&4T+Kg)WD?R-r55Zc?Zo zF53ciY|S3tQnh5vy}qU1E-oy%)L?D;So0LDU-2{H1oI(-s~3|HZz}FIdLv#KF3<*1 zF;Oo01{$W=@C<$*Ws>!Zgw+RhD`1ve8J+q~NXsFEIOJ5WIY3Ac6LSmF{Ahu1YmoIy zv%GpSFq~BR@=$ili((JjMkpo^w|W-H<5Zbxf5BRK$bb}C8u1AE;<=3hST}wtf={j$ zkkk8$?5%2HB+=@SM(5Aw$E;nRrw?-xd@1-e+%NhWd2V2*@SHhoVNtrXwHNzOJKM0& zbQ1trTkKyCOAqH1B!w!KteE|z%!8j>H>nO>2G1-^lO95Tdbp~8D^~UQF092zK)dZ} z@-qr^M_5ccAMKo1l5|gGiShfequHMqJ#cUPN>%M-dzk%A-7NemT4|7!TJ@ znD8x2gFc>Va+*AN)fpp5Aq6WQPmn@5NhNsLI@F`+R{=lv12oO+{HO-P;gxtxp`<{( zYWU&bnDDiJRKx{)Lk}9`#G^^s367ri8xKDY7iBzZK&vXv31d0~{|x-&T{w?i&Gwo! zOo3kvUM@}SsiE}<9}|x}I9xl^*EAnI34TRdD@_kacpOI9d~htnygCu{z!~82$~WDQ zlRmw6&%OiYt;c2%_bkMT7n25Q9Ic;eZriw^yT2=^S!DZ}DWGNgnMe&`*EY@u%zEVN z$~ky;^^tf}ar5Y?Y53(;80Pmw&U`l8O0bRjbfVs|LZ`4^gWkEoj z-?09Y#znY;{S9SdJM`)M?T|F+@7l;EA-ufwpfdY3{9~Pdi++_R>9xWNk3x&;*c|5} z4;$Ba<+3z69n&L_iYQ5<&Lm8_v<@2BuYU=-7&7^FHlar#h3j@K!X@Nzol8WRSGH}2 zikfwlVJA`_X9ADc@#-U{S2D}uUW(sjF?CSXu^C0jy;1Z-ZM~cgnyy|FcJ=ZKz`=Ss z2hXnV5$|%`te11~%d0TVua|{kh4t`C&|y8K`Dy-MjbGLw%HirE>os}TfAXW5$Wb%OBrPG@cu~$d7HpmnGaL=L; zE(1N+774qy*aSG(7FXcewJGB9;}+XuGk$p$h84C&KVD&5TnRdCPpj;23x3%aDMzp^ zlEw|Vi?v0ce&M|HMB`O~HZP`!b@)W%<+nv&mT+67ziW$Gz&>7HURvHRpWVFeM%xxS zcDbV$*cRFLf^AWcVhFUwnm}8;9{2^d0riGs7xTY1*ap2hS3-}{3AVjA05{n7ZsfB! z@AHpbG4sHLtg+#=Psd{%h@ao~-souBws#Y8^5%YP;Wr(r&u@E_{Y2VcEAV(7ukEoN zvF)w1`0MeTF3h>t&MMm8f<_R`dtV#kr@(i#_Nm!z%ok|;+{8Gj3#Et|la?m7i4IH0 z_4~wW#~o}FZf>^`{>0<2j~9_nJo73H^V=CjBOTX1`T-ZCdk5xde0SN5aK1Ne!7r~Q-%afCw4DEMg+HL`ouFa*WWFir`hfc1N`LTh`Q%`Z{e)e8VEkKf2kV0?r($6&XZpKxz5_7Jz}2Av zJQv1~=rJQe^WK+t1CR3n-i7!vxf|iUwCwSF7oJ%^-aG>RDvM8Aq*+XMhB5tq7(P%0 z;*owZEZ9%8O$5X8+k_wH*IVX2^T&-zOf&J`iaVI!#G^m+kupAD@l3h+d8he=O6v3S z=UuD;dn;seeiaY^OifFIKil*@pc81*UKsm_+Y!e8!H#!b|bEcU|kI zwgs>)2W#>g-sgp?wqsx#pX`##+;8&n8Y;-}E)>{xZ z1z~PYgyq7vF-uB~F*3!A$zJ${`_h=)N54Qn%Cy}NKjzuew(a&v$5`ZT#Ov;9>utp{ z_*E)X}3WA(N*ZD_@>6rO2;<1mU zQJoBa@r96OtH%%Z*k_pB_xoS?@%SQgz zU6ih=r2+duO8fmDZL`k$7@iAhN91w%^I{m=zt1-u#{MuE=K4y?&iO9$h;YWjr(k^- z`z&;Q_pia@eYn{lJc+xISBZQG{=8f~(m9cMf8)g~l)v1Dx$%fJ3wcN6V;0Y?Nf9rj zvY0uFpYEu9BET;{Pl96v*P$5CTz=o|c(A;S%M+E)jKU*dR+bsB{Icceyw6!W9H&_y z+&KLdU{hYEZhQgH`SJOV_QgParp3kod%zr@T)uv3g!unpaemgXq`0s)L1SvNk%wZX`H|O(PjggNgHSyioqq|0GaK>;p zcyNOkwpJ2)m_sX$GITO;kd*OT*V@P9m7RaPB#pnFcjb_GoiOsJp7ve;y^yU3b1cp@ zc=ou9o5NR-j^5l3KEDq*+a+ajuz(lfajV2SgR<3kz99|lgTvEQrVAHj2( zXGYh=`6&F#osD1E_a&W=!>`K2Q={w3^HKQgw<&9)oN|8>e)#9=zFG@seB$Bg)sTsQ z;(iMLY2vC4qz)WKYy3D5OR68teyZ##{h*z&AFs>P_St?}b~1A9gf_AH{8`X0<#Su7 z%KEo>)@>5j-ZXiA9)20{iqk?@pv>-+8s#21{K2a;_sCccyN;DIfWUgdKH)8r*6;=W zy}dA8)eQ4wv^wj>zaRC42TLrZy)s)a%pc?1OmpR4-cEsRRX#VGcGa-I1OBvd7%k3v zJRX$P&YddY%Ct{wirha9F+94uIj$(GPRhpda~-Hb-apXmj+hBYYNQilJsvezt|n@m%Je zETZ#Z^}mwovWDW+I;2e(>s&p;+}ykzIw0SKUx}J&X8dybHlE{r);Q&ABU!^|Fg&KV z%qxOs`EC9@fq1n+f6Wae(+db&2)<(i?Z}#~2F*IHuZs{~?b@CVB){(>Znb%HP>QTj z?ugKbWxUpqKvjg5)zc^(Emg)0UPEuMegw7Y`#xv| z-$Ptq_^4Fd*1o_Tb+WYxwPJKf@Xr)6cPpHJ8mh z>y1S*9sBA-W0CP&STMF2|3#s(#rQ4t#tie^RJ5NlVXH>$XJXpVtRAtSG4a>r^)q}& z;>Mt#+B{$?*V^~K@H*G2Zhg>P ztCoj<94_ZHoX`AHf4MQZ1kfH(2wv8>t;UVj{0bP90oQBySs7Tj&`PsCxn8f{#_^0V z%KFT3uHkd2b@iHS_}mcYp1FpPq1OvfOESA2rgE_a;L(Iq1Xo-zhcWGgbSGid#EBjo zyU-3PKgZpFfsF3TIODuF?aV`7F72<_w7cVXGYI={nBLhGT{ve=&-(SbzHC?bHUq6` zUo+2?&qc5E@w+@Y?|N{4@rO6?g%sCCfg|(yP7sR}J2VgJP;B$=5yioM{sDRniA8vX z9CVS<}c&#c>{Qh_rO@eWBa&uHWpb5mzz+{<>J4~J`)GA)@`)U7(oD; zBZHS%zq9q%9pcG!D~@;kB~#+ZYP7M;PcVPDLoybb0+)vZ&YJa}Hu6S!vGU>E9UyxkP_mN@I9Z951D$ z?#KF)jb(m<2NJR+#UiWVy8KRP4h3_Ay;v;5xg4>E&bs7QAN$+ti;+UpMX89#;}7dK zBv@XgV^Z-C8s^RkajBpLisPk%wES56Y%KE=Oa<2vVv+T5T`I~7Qo;Al$oT)(j@(*mRfG-ZkhRax|WhdTJZYbNDK(((E?@54+qvuVFD$yKkfX{6B z%s`cLwHV)2;bSh!!|U#l508bNJ?k=k|6nbTdF>)x!&@}22wN6vuRYxM6u{aFynLog zpZX}5n-x3gydC}q2l8k;ord6VL*^BV=1MtChiZhpR;uf`lTVoYV3f5nIwN?F%v`& z%IZh&CuJsKR8&UvFsMI4q=C_c!a%5~K>JaNMD=}Z?S1xH=iIBa;hsBp@3p?~TWjyL z&$)B=IY$foE9kMv_j!vO<-K(_&OwKZLcx5{d&Rd&XjdERAsTHifu5VhD6m_cM?AoY z+W2g6pRn0@)v!P9z2e&fw5tu-iN>sN0{f^K$;hmCI!qCA)M|GVeavya-r@RFuMmaR z^Sp5A|E}VAo`qT)#S-ikF^8XdulP2KDAa~g@ThnTUPlpyj@iI&alZ5bx66C$9(>=h zAM{@F?IEzM4cUptz3B`bc*n#juv?s;rOmm!)F$(wY8(4O!+z9z#kY^Zt~O*R8t0u0 z!G4bz1$K+`p9j!U9AXDmF7p>dOw9ZV>3-qe-M3&@8?qCPecl81ZDJDGEzU_E=V7(+ zv6IKfeurU~(`4}on}5NsHe@H-V|d*FcCPrxi1No=i*uG|e@1OQJC6*O{ZvdYQX}@f zt$i%nyd~v_pWW1z2Rh*4`&xIp?w0!l+4-1vUX*f<`@@s@;LWSpFVyd#ziZ# z>rwa@enio`D%;yuVv96OnI`!Nas7(A3B={kx(P52 zF`8AzMV%vf?L>dQ#^$uYZ00ZZnSWhve1A>GC);0RroVU;w&iWGs}0$S_99;2fc_o%V?A9fE zsas^XIJ`*$3r_4%TC>kVIwJe#0{b}F)rRau`vkAC#JPQVkL(tQw@P67Ubca~$@zw1 z-&SCM5$r#S4cUpthoEdv^hO={-hgwz&dyHv4_aV~8ANO9a$^Cl!T(W4H>}x+Ru5`#r>@!dsW8X1z&)?Cy%SSOo zqM#}=^8xR?>5q+qI2y%XHlduTHhvc62eC0x6urdNM8WG1Z4@&!3jaNh9uw%D%&}=X z;?l9f-l5KWfH9?k_*An$m$2jKU1`Jj2et8W703MbNRsRYV)wcCqDn2dp;2wfPP8A; zu&SXK`RXjuRjsr2SG6Qr&(u^(9IoCb?5CD}AKF>Yl=m>Act#)!)4u4!DN)pX zzZ9g*7~l7J0-YFEDx- zfz8czQEZF9Jjb2W9hJ*^4-ZWTV@ z6|NQbFzOIQF0PkxfQw^(MojUwo=$U8kUZ$yP- zcgt@#v+;otBN_Ywsnlvf&LW)rL_JZ4zEv5yiM5Gpprt&FxC{Xie3< zkgF-Xv0P2bZB1)J6jl%am%?(liK2KeQNr&|u`dpJFZJbi1W~9BqafPrsNIJs_#iv& zi*lvr_NRIzib}=3k=6u-mg^7CrQdSGXu%0}F3$&y!Zz-d`gl1tYvX# zdG==vJCkO|;gg2_f_VwW}Muj-JGI>q-RPM#ieSs?j@0UTx<(uwr|EV_61Jmcb;6 zGPM?4%D5!SH3+Z2v0Un8@kx(devl-6D1^egAN_q=>5UDXgRi$CRz)RL5P8TD7a3Xk zNUMY=OIKuBlx<&>4c|5)GkvWhAL8;G{IFSt@ZsCmXi7}LByQ#1on265NssB~*92LQ z(1A;q+WJh=%v~dpa^{=s`K$v|Ax*g@c10_W7hPXeXzLrO#XjcEClYiOc831OK&>Kw z>KMpLqD?PlEooRtM9~e`Jf`RjOPsL0&^jTKCOQb8u9_-3KtQTAPsfI1>rR1XSz}Xl z@@H3dStA6B@gh0M8p(c8w3PV$Vkz6o;Q$-~!s;vAsH3YzBDy+SNwOr+vR$Y9#6syuwl{B1-778H#bDF$#`UYMfpm1wLb7if z9=&zVXu9Cf+HsQTQ5A84C>McRGs$mHi-SOP52aqV^m}c4af) +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h new file mode 100644 index 0000000000..e25cb8c483 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_istream.h @@ -0,0 +1,10 @@ +#ifndef __PCCTS_ISTREAM_H__ +#define __PCCTS_ISTREAM_H__ + +#ifdef PCCTS_USE_NAMESPACE_STD +#include +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_release.lib new file mode 100644 index 0000000000000000000000000000000000000000..b237a09e4d683b0ed230cabb4556e6b7340756e0 GIT binary patch literal 83612 zcmeEv3wTw_m(Zaf@hCHxd;EF%ZHnXjbkCgk*E7x?LF`OreXa5{CxPQhVhSjzJ16rf}RIV!}xnXzr4jTj`jKdV#D~~XCxVv zm(O0&*x8>j%~cgO=9+gJ<>hVjwadIp)BV}h(-AjK?Nnv96<1c8OPlMPO#zpe_O^F- zZYVD)FD);ss_ieIS6)<6A;F2QsxWJ+8k)`ajt)XLw0C#+B+5(MySjQdl$UnLx0aW7 zfeBayn-1TeNW{1FCOW&XDlbj+fDXu(Hmz!u`0CvB#46S_n35#r zsM3IhIvxn9_?P6bfivNqiFjXoBJS~lN30@N(JG`B6#~09_Qk!hHI$zS!V?xDs|oIl zziXhg&j+v9UWuNzc4UE<@zz*X)yfrZ6)RSnX6tNIrGlcIQ@>zrs|5N z%A>*OQPQxaxzTKBTIq8wt*NMQG^?5$o16UZwRMd(W~_NtQ?<{1US;JnvoTh&yvC28 zS6A26Y{qJqH#DaNXlQJTnak5d%wO7Awao17zNWpav%?q1{AG1j^`uo*lfrFfg}Jn* zw!thfs$LfF?kHc_v$1?(f1-~?ps2dpM+Mkr)k~`d>%_7!(Q|dYI}F&A~ z^`?D&yo=QU>Ff7n8&K&Q>&*7vUWyEqQAHZbd@o~=lz1y?WrMk-u4WnJR#nTV7|?!H zE=1*sQOD*Bg`(BmRF}-p(hZy1`xrt?2+@`=Ah`|v<7pEro6MTp#zu2XXaAP=#D+~e z4W6Kma7jWM6>sqB3bV1Uda0??zp)3Ir^2#r=tBK1M*`L}rQK*El1)0`v#PfB4)kwIfvFZmAQFN&v_Dmw zI=ec&P&7|~>N>CTF4!Aw;zpFOHngNEAkCG_n#2b@i1VcRf}Xj>moY>mf#;a9L>WU}xoW+WZ)cyCot@3ld69REtl$Ol@cWy#1oyZhsP zXz(|pElwfiN(X&{FEf3LXUB1tbz3@U*hWDBxcXSCwN+q!u%3E3>PezTvhm@T5j%(VxH>8qq zMWJ)TbxORb0_jpuw0HUnrBfbQz7weh5}q<>Dle{XtZQU3sci4ZII{(V zQIs|~Hn6u^fkd}&G0ld0$si0-{c!KFwA!q$ud6XtU#IF4##b9VySn_{PmS5!RMlW6 z;@i+gpuN}_XSan8PeOXTnyN~(X=!7Hbd2!tjWZEXiab$I>q zXG!_IWZ#2+r@CTEz1f5gN%z9YV5E#))y9GD4T;X4ZrXbg0ooFdzB%S=HY*zuHrWeH zs(h(whG-fpO-QhFLpz28@xDIL@FpULx+A`R;3~-=lJMjd zFe+0JC8}x$UuHZ!+a-1B{^b>`=Td)k@6vV~{tJsc1d?9?m=$ ziShBR-Rt~lPo?PU>AAXnQ@p*y^g|$K4yjm5yV1N#~jT972`r;cs zEuL65G8;*pmRdS586@kpJ#B61mb=Ua=6cl01;u{jbj#?6YMYlenpmXasAYtHm7RDs z1{_PV5L2NRuQ=UBM~~U%);=sam6vw(Y{i_px2Llk%{FII=m2`Ib%;wHGf{)h+pxJ4m2rM%qHvU1(b zI-b^XcIA>fGiA+Tc5PKN2ACK~dR9ngFRfk1QD;qs&v{N&1^O0Z>l^(ZO|kk)<>6nW zE2&>v*Q}NXu{7(AqGVZBHJIUYjn}!fz5zpME?32|5S6;XHm`087If8OOZvjhf|~kT zE>L1!r(c%mJSkeZq_L(7epd~|(><}E+z_j*Q?-7S%7m&{*MN0OHS`v8h>?rOrD&~@ z#?&=Au7y=Lo3#}Uja&(HR(0YSysO^Bmwv2GRaVtim>5oDa?m%>rHA?)+l$nzs&v9> zsc%B$)GiLWPdYDJ?sb;L;*Hk*m+K5#G6gzjDNDTu$&8V|S!z$}#%QTl&RII7z;$7oPzlWzoPZ{_~ zQ{AT4fIMl!iUJ1W>GMx^7+8W?J$DWof2a9RAxV!K_5g}(+t!YaU5WnAtNbjXKgdYm z7cwnWX09YM%=-e80d|snOB!X6rY6)`q{1OQLP8Kjx~!z{Z*xOuOpF%Q`c5$4ug8{7 zUSrj=25Ximq5T6}^f2G?!?0O;e(kvmg}BQvU^M~|ae6_XsenU^NGS*LW&Kyp@l)X_ z02yAb1`z}V_%jda?VS)f5g;L4e5JP@yE;A&c@=#}d;>RAedUk|)k2bbo94^4Hctr8 z{9W*EY$wtJf#isRSPRnwai}GWwVwFY2C4Y;SI03=t&L;Prbe2>l*F>|63E%HpE&0i zA_C9sz!8ymxG2jyl7mg{sU?DSTrY(8_H}N-KsY%G_p!^k$c1k;#D|a=gXDu?*LH8% z!k`y*~)g*hOs3dJ2@sy%Pap|0=e>^2a=$&5aoB-E$`#Dr;$~gCv0-mA%N`^>( zT*pyab>?zZ8BmVgfVF{T$;C8d)4nH#Wn`!tNegUr#By2s@(JC^YoUNONS~)4y#D(6tU)pl;d#rY)dk+5P>3?I4F=FFe+1vq<5_RbvYrw zj46zed5{XjlXw0lylcl<3Ni0*seSbJmo)xgsx2MMa>_C2@>OQL!FsG}Q^&NL3NDUq z0qF0kl$HHfa^sYpSxa?hd9Qt8@vo*NmQ#JdiTf%$$+O&T&O@{wR ztB7w?fdcEV|GWA)(z<1GMX&0Z^{rXS->x#|G46>eZJ7UG7f46fO#NHv0gbW@%iJ7M z0aoQfcG^U~*%9Uj&XR6<+sK>#@b?ec{bBt|Cw@P7-r0T{YX)m+_ zyyHKj;`)fnME{IR9slIJA^&K#(tl!oFTLEAq5D${{?2k3w>^^TuIX!Hsz{4_%9f@t zU|=+v0&(ZS-_&E-{hw#cDx1S3o!Rbd9pCZ5k#(rDIMFh~wwk*Y<{v(Biv`<1?B+*5 z4|CkwfjrEW(u5-RV>?lkjf&yO%Gt?dH~!-<*bq(n=mR+;DsqpazdPb-p3!zWabQ-} z8Q+pMs;8qNIf6zVPur&GMyCaI$HLeLmfY{ndS^9AVK2))*AX;3k6ZKoSTqJlICP60 z-t1K9Q)e;3o9e#3W`FyMDu{4A(Bj#-A9a&C3q9DR@_zPgx?9&-@F=H$64c!O=RcD6 z_Rl8#J#~r8QO>gMx=}>**@wTmsz7$<^@5LFKph#nXI=k$l#gc;r6EmrBqMY&qIDrE z7D|4q1=ivJ*^l!5P4umyN8=wEN5`wXtX|9^u++w6}Ihw71JAY;u7tdqj=FVNHz1EFu z%sIo@aKZBnLMIr;WzZC&nbpx3-;lT_u6`NDd9W0PoL~CyxI$wV51)FRi(y}qf{PZ$ z*3FV*oJF+`v=El-fZMIHIrv>)SXh}#ZwK7(046dP78t@6z4k=AxTseYe->+u<7^fd z@0-=v;R7=K6~L|2SjG#SIm-_-E{6N&O!P9O<1XMn=b@J=9hA%0f%z|u8-w3La(Nw? zyf6STL2`-0?_^+RdvHPY%79tw!DZra9q6qB<{KK9lr!_UXd8T$nTS6>2j+Jgmy6#L z?=}k11x|w&pT zDAZ+g7X!Si<-7Zh(4;os00Sj7a%`Sg6lxBw5$Nc2j8S)p-BIj5ArlR@L%8Y2Yp zlJcBEezySkVT}!nm*wx%z&xdKBbC430Q2V*dKW=Gv3;N`(bc(rQDZ}8Rn+Uy+*sXI zv8-lA)LvN>+Vx~&sy$}czQj9P?RSOBURgUZ);9C4G4?pSB4jt@TjLIdjFNqL?cK|i z&Eg9NoRfKj5$72z>??}$TkTg%9$sySH_?69GZXII-(o*H9E)r&I6{}92SSKu@lPo6=^?6Yd~t=iD;>Z1IEQX4;; zlQ^N(k&OM&S`o2I4~vsx{T;AH@kH<##&mhR!e_Gc3}h4p8)>zB^J6Z(U9Sziy!L+5 zBM;}{Q8ZZPw2=%v7eDfhj(?-u=HX5J6YH?(YOH8oZC@KId8TCF!RjIjy=yoz#oo&N z2-(lRm~R)h+J}ah7uq-E+Yjv;9(ciSEGlTT?_b+tF;e65p$7^M6rkknWdSb56E@Im zNpl@Gm`dfgJZamrEc9#qFz)3`Y%Cy)@I)kJ32b45>1Gv)7}2q}pDxM3uS{kbhVJ=z z=Hdw(MR>Cis}}J}*qBjxB)?|Bo`>>&P>5O;`Bp{f{=MYE#G_kL*n$l1kpqf&#u%12 zMG-a%@TOG51{+7l6P6sQ5!+Eln11AQHLB~rfpMs|`F76o;n?H@`IN0= z7~)hNjPj--brmuuS-Z)E!x22Fjs=@@#I|=Y)763}Y@CR9li0}RGCUEfSdC(nAyrgX zn-)dS?dOGyhH;j>b#nkalkxV7yor!uW8@-VCe&x)nvOVZG=D_~Up1zB(G|TLHYEDn zx_h=N+ZCJi5O70puR@v|dbae=>g*Vfo@lUG|KEF{yE}S#aa}%`fkqa$;IsY(R2z*5OU*PyX&bh}>b`)RvPZE-6uZSjRGu zo5K+x%U@g1`Jt19a#7>#IVB6>1Vap(M7WgBQ%#m~q2ER)3Pss7Vr27_n=>76%J~C( zf1a-?uLPYraDowxQA8KS6-~O(@7g3~Qt;Lk))7}4EsuWVDn;2_Q`l{|n8B&Peo65` z%J0>bPZpl(^1)@gOsPDZ|*?Hew~eJF(H@!fVqU2>$wOH^*MNIm{!P7p^{kmK%FW zi;ft-#Mu40>0-!9Y3Vv$Fl>8C#$UUOHRaROB*syppYrKKxdtJ!zrZuIq6gHEGHVQ# zx77rBP;ct(-EykV6{t%^=T%Y>Z;p8xjw3o(mkQ-$*2)V?K?!JMBSP*u&3JujRx4s{ zZEaQCw$=9GbY6XXcSl#e&uBv#+kivxxR|0pfkdQVE1U6RRwYn5UFas+chq8pEgZE! zCRyTK;40f(N=L0SOQrU7zQ$cV$G?!{tW*W9I?iRXj&tU@XkB!@%(Ra4 z7Mp*s;X2Ox{(i4hf!jPKop%^mPx17-^uVCPI0sF9Et`25_NrzE9Lc?3V~C?s^I5ka zryKkGk7SAaL>4%+l>-!3C{D%s^LJ z#_ke^#URsq&knfP0P~>6QBI1UKR?*h|5jsQ6_Y97h_0GCS(Ob~zf z!0#lD5g=Yc>HRKnKNy8xF~UC$OrGvY7;mQZG6^R;oek_XLF+D2;EFx;GRc|oE&^t= z2bU>cvY*fx#z_+t?@r+E@X*T??>$K1M}cYL&;f>{gCO}$g6DYzzy#&T4)_&o3~@9; z^zH#}Ul#Np0cMGwU%L5`US3uL)8WBoOfUH92IeddJ7Cy-XOc7XV~)lUM-wFH^}zLM zY>-@H2){jrUXWbA58ThPp!X|a=5a^^w{~6+vK5_Nq&?| zUkbgTbbK7RuVq2+J6Y0u3AndLq1Oxk!c4Ts1o3wba5rh}NcpxmOM1Tm?v+vKMZwpf zv!r(h2A&sk@Ch>#e{+G^>A__x&#Y#*YK#!XE2tcN9JsG}=w&JgCc=LwgIGf89FK6>RH3n8OLGkVd?rx0@iZ=!dp9kj8 z8aI;sCZCA~VmvfK^rG;a1I%&{E>k+#4PBuzu!;#vM-Ol}c<5y+r_47Cn1y<=kSjGo z<=}Q;KA~|z=_rQBmw@^C*@`#vn<*V+>tCY^3qB#Cs}u$3sJ0kX$YVW|0S%NzPG(uLh>WgA1b94a}ei7ew!7jR9#fLG(Tg+`XgF z+nZw;2Y^{VP0?Z%&6IC+U&qOc#{`wXcLQf@EXZdZKeHXW6PO1z&aFrOa!?4|e`$;p zb*Az{+#fRH(#t_E=69#yp>g>0ZpQ`hrMZ%UJfjHpcqh!!@^Qdoi1rUPZEHXT@c z)usc7XJLcCxq1~g*t~Eo9X8YlIt=-)haq46Fz`hXI`dl_hWbp0p}y~7=!>TH_TTDV z&)9DyOgnElR$#xf>$Sv1_9SlN<#Tt+4s$Os-+sk@)Se`6125U(6?80AdwKS0E9}Rx z<>%kolg$lqW~|@~25DyQ8Rz4XZ3gT(GQ#ae1&C+-Ci<;D!uQYv`SzsM9Ezw?Ztm-1JwMj9d|zuh%#AuWkh>^z7gMxOKAO7>le)ZE`{CyJ&(u&sL7eT zb&AzkRLB(Be|6+6q4Mpc_G9*GTF$$Ei|x9Xv0azjY9EHYv5{10KR2{5WYJQLox<-R z>M57+8eTh4V09H0*blZzeD-OpBufyWK)HDLnm!B8nFQpBOdl3VO2}h@9j>>+*N(Gu zBs+#(IBMV~TW0wyR<+v2t9QL- zzcFw^+uAEj_FWF5Wv>sMz1fg-$;*E1AV&iRnXq3!LMt*R0-?Uc3sN4a6%%%Tl@O^J zlkFpRF0*8E*^xwzE}6*ii*<>E^>pQ$uea}n{9}rk)F{-n7jM@XSZ`j@YAbK-6s~m( z_Z$roimEDRpeRg%;;%2owy9IE0Oh78ocsFH-s@1kSjmxQbwY zaw7Bt(uKH^1jaZ7bcu{YGTf61%O-1+*tl<|+*mYOb|SJNs@%9wscLo5EG1C@9}L*pzP*Y|3|c()VAIzVC-kaR4I5 z=kSXLB~mKZGT5PGu?pMqXd$rA?v%!mvFl;`)x;`n%eN@$O}0-%#sBf}^2udC9{7oJ zV-qq(XO{hAHY@fFG%PU`yj2U}_cfgdXq#2zff9do;0ws@d&vlOE+}Mjw4E;)xC>`& z;F6q8wtoUf;;5J`{SJ@$1{`Bv?v9YVBLmO5+`WTb4=)Exs!W45DdJ%6TN#=AqRSkr z`6_Us@`b$Jz!!`oJ^JJsEfn9bho!xIbzq#T&X=Jff=DNW!|irgQ4~#U0xY!Uvs;1$ z6M1$Wdar>e?79NBw!8KXp0n$jf$^veg;FlmBY)Sh{mQ`2$<&Y`RiKxH>ved-#!Yx%i6>&nCyb)< z1*2$ZchvcQ(ab2mUKH(yS_(d%aBZ|_V^o0s2!q)J9_AuiP{}b;()v29?KgHklUQu$ zqM18v|AE}FqgH*kbkyirnf#ZKJ+qiW`Ao>FLOYK=b*ymhm2J9kfT(nP{OgpBIPB=4 zS!N6DS5a!mY1JTh2PzVYFXO;~-8KgX9;Fy17j_q0@PrNZ$)iO|5vP-1|AlX5`&hQN@5(m7OZOB1HH1Ky$lfv%|kQ z9CfB94;_GBg8NHAp8=cg9uu|O*Rm^WX;6PA7buZWGKV3z5KjF7%8HkY$; z_^qZg{7c?wzKBPuj}5)l2rWj)xDeU(sPMA~qj?B5v>d&HasXS7C&uV&n9*ykaYGL@ zdIsYV>M5Z59G-~GTz@Jya`u4O@RG3*QILs_J=MFCkj+aSJTi{o5Rk48g;^cOx23b zIdHVXl4!dLX;wpSkK++LJalvn=2DSF5k?kJ&eWswXD}7}@r$_}FDML@CgHz%jDxUS z5zTTTZH28XL-vDLrp$;Zg6oIzM2u;8GYt{ZXyi~dBD#{wjRQ*M)(o2pu_wU0P!#6E=7}>B11eh4}}y`7-Bja9yrMn6Nd32W9Vq^z_nfpg*?J&LX|9N(bCFC zJ+psYvFjPDDIc}@G;+iS61CYQ;IY2oj(~@bhOBVnfAyO*+(1_R=CZ&5))j`KFD_7KoQ$##hi%VJ|aK-K(yuJ>X|gDAbHTEv>)5VL||N_ zhLs@9jztw`&hJ$&EPzc(yc)J2;fWZR@JEW&!?3Fvw)8nMs6}g$AFRzM zP$uu=VNr>qlV0dewg_xBbc=x1fY?K3fnmi$RxDpAIV}RCdjXF`n^yhV27v}zExRIr z#{y#@d@zR!!xQc+G_8}N{3{JCKxsOzr0FyqXg2Kdp0#ed!%*O~WNjX=$~_7_TJ&Gr zlT^)?pLRGgKUr82Xv*&Ktv8=&KUO74@IeP&XnQEvSbJ{>@v_|Rsm~dDqin)^Z^ZAC zCwJe5KgMto3kkY$RZ`p5-pkz)qCHN`i4-R`hAB=Q6{I+^Z%J{=(@vw-iJ?Qo49aeC z6q7fq$;lg&mzNtNZmb6!W?x+h>TlqQNNG{|etyzz9&AU&mkpz`T?U)NwI|)!Fusl_ zY*4JPiR~`D6^<27+1S%4+mlJ#e}UKHQC zu>DDF3t;=b*cQX~N3of({XuNiu)QL-de~kSTO(}05t~yF`TaPj3NMPDf9?i~1eZwz zNP|Bz2xL`L6>8{c&h`mt88NsH?IHwuH*|EE&5e;5D}R`qVoruz0Uou4%$6oBy;6?Y z7Hb|Zl6K@$V==zDa#7F5i_{UvsD+Y`(Q&VT^XHr=RMEVws_#uRqiYaB-z^`qf82 z>4tKYw~6tG8s`hO`uqE_RXRPC#F$m7q686N#^uf*Y0vD z4{OSfLbWR~6hwrgOla=7{nU+aO3!CShatwFQf?Q!{5<#SC%%)ehJBh~it%RTZ~o|4 zXy`N>#u82WG$SgMU4AAfDZ^rHcykGgm%sl{5 zQXl-!yHQOYe(uzi&k%m#Z9E8ADj1eb zrg`Y+Z=&sG95ib*<*26Y=GRpCx(9+be(d_ERd|NFRfi(RpI_%lDAph+hG-f;(*zU4 zn`XiHi(YZj7z>J-rulJmrwHzDO2d1WbWKa6e6C3I^0 zWsk=E*ei3~l#UB2S7Q7rJs&PEKSZ6I#?N%Y6w?!?ZQY=!ty`oiPfttf1;F|#Pfw%F zv4xvE2R?l-##c-;O{=DSVH)Kb@by!^Fpcs|!Ss?4%z0<+ztg3h(3EGUQN9RRKjoQe zlxGQsxkGdBw`)J;QvR@}JS&az#lZS0&q||A3FqcS@uvCew%d2Ol)s@V7pGC44XjJK z?~*D1R-8r|MFAM{oP%fiRcF5LQhriXo}($dC8|V1si_&3#J0V2k6WUS>QKb^OVnHm zRfsp^qM4J%Pbpk;b4+@|m{;ENWfwi2jTKC3T1q)Va8s%<1bh20Gz!41qbJO^tv^`l zQm)sO=ciF#0IZ+#{4|~y3P$n>wwD)P^9Psm7EO7fP#*a}*&<(D_rAFCiiK%$l?mn^ zyg9-%J~@7^8`p<)TxB{HZhkG6P)>ere(%Ys1Z*p5zNJGEgV6=PE#B3$L41rfXn_J^&q)_AZJ;5>Uk**UxT(Mo#7@S%rKLhJtQTxnC(VDypWIZGXv!67@~MqIl=vx%6YVp6gQX*OaR?Wj6<_CDbW+(+pjB=XczcenE#K#-Gv} zxcF0AmBvr4U|6C!BLDao&pXfM=NV18HZ7%fKFUA(NpwSP8s&PyaB@t(Pwtu8;!>W* zsRm5FP;To_J*q~(ZeTj_mpRIjj4O=>y5w-wLDPHl1(2bW?+{PS})*3LUq9Z-lcyFY41I zwoEWlydg9rzUdo(bS1V~$F(diFPbEjQ|j;o8@j3Gxmhq#yh-`Dr+*MdgEpFbH09C9(xt7lzoYXi=jHZI!PH8l@DiMEaS)OZ^@wv;;RG^wWO$ZEtgNX~F~ zuI3U~_@ey9xAbt(4TznPR6;qt+eZ`;rIe)_~lXgQ_w%Nw~z zykpp>-;xqq66=w4W!B%oa&EfMM35{w{v+Om&q5*XYf8FQrSp^v<_Ccc;El1Rf_1W* zUwYQrRbwu#uZWoh%2(V6@TqfrpuSY8VCedUtDll(ZiJgTJ%SnO%PSeK?bHeLvWhhM zih97cpPA|i%H%3S~tZQ|DE+e2U9UJMk@ben;Ku`AS7SQx`&CisfU<{-T(k z>&apuSL~Y7N+~LD^Uhrs)3)}GYudXv_}Ud+|2(w4kx3|gJpfyKDH+bjJT*{Tc}gB1 zQ}C4BJoYceNo=wSIl|@Cx+Yba%c_@F^IP?}?D?AZuFj6~g%T7l%{teT(4{rC4Fbi^ zX8A%iF$-17UF^7v=axjhX0$sZ=Fcmhqwu^V;$pcY;uF}RcrVANFq!U%=+e_wg}^(* zU7wiu81Dn_96g=l3R|YLR}r``(HL08$QdZlT~Ku7zjX{ zfOrMTZ!>V$WkGLemh|ob?vta?V|n>5v%5yU-5KNH#O!&PI zm?t$ZsQyj`?#~(ntC&n@7{|ls9o&od7=?3}o9M-Sy8yU_8XLr46u2s2HfWq%-`vSP zAaWJujT*z>G(qux2Dtyw*pcGh56tr#$Hf9wuKe*by?@de#z_+tZ!W;6FaS(Yye9n4 z1m;Q)E>pax0C$zfz$zvv-s^zd?V%TRCif0t{$1mO$^kdEf2J`y+Q9U_2;7?*8Rssj|r;3=K@!%u|f1$uFA8d*9=_SDDlo@@=`f5aLrwgzWfgA1&|#nxaobRVt3 zs5Mw*4bHU&P3ykB2yESVhrF@$1^b8bK3F@Qa)i#T)mp%_3iZpm@jn2GmJvEgOde8Hf!%W5Fw%`=88ru)?OHG+SV zhB3&w3cI#YWtvjD#7(>f$h3fKcu8N$mDK_}(psxf+3-{N<6q5 zkX2~6#ft2f zLMt}iZi!g2nRd%$D^_f`OtE5f?UrIIw!m&#V8s^OEsL#~Y2PO0GFEL{A4JSneZ43G z!fFii1>Xoo5`Zp!TH76G|9%Q9fRIfToV zc_L@e_QGL=-1Qp5C8A{qx1MfSEZ9AXR2S?nG;86!^T`AnpKJbSxM2Yt0XcJb>+sGe z2PPe?C?@fTP=6{GwAHUg^oSa+j4Q>}DQAu}5)26gsMNSx*uj|;WnH4tx`m+DtaL)b zu-!0yd5cyDHUU3^2gmRuD!CE?H_r4X1Z*)pVdDb4mx*l_-i>&0Mx`HDbGP^5hVAZn z^xTf4^-J$-b<27wwQJ3E31 zDrODd((G*FPo50aXK)L3*HE$#$HCZnZ@?3l18*#F5kt>9m1aF$T;+FI$*wfB`l#4V zEV;-7_aNMKbrdXO-%2lgaJqdBE-pB^H8#9_ihBYLnL&NMtMP;lxyxKlk8!Od?pE%C zGj6q#x4fhTFeR!^r{}T%GU)*z)n(EuUkmYD36yGR%&v%mZ%U1Jm2@wFh!AzimO5?S zmaN&H(h86?)%+{s!C!VxEUd)4nT;QC^&56xP8`y@Ni*Upu@V!*usfh};$Y{LwWhM? z6C>1BJ{C>o#BE`!AHaBZ3z#FhIm}{~q327_Lh*MvqYI6?ikdbyddfsqZI)x{j!S0_ z=b@6v8m0bhPX1yj?=E;Qd~$Ol+W*3{cH-ol6P}q*LyU5}n?J<}9nV4nIaL~31sdUm z!396sg&6<79rvaE`*!IUYO^*g49WcHqK~81aX7r6PB39Z`0;2rvUIqVdChbHTx?r%bE0_D-27Vc``ujTX&#z! zX{liQ<)=I@jWXr!QhwntKm3MEnfu)|qvl=COwMUq$28vTQhrKPcJz{6X`BkIpXYQ9WA-?%cH?6Yp7ukR@~fJ%y6D-vBzIaG z<@BqTCkti=-ZTq-{`e7>^2xfWPfnBb>A<=?Z#?`TZ%s~fnpzjRIaBebdG?)ihTK}YTvH~--;Qx8o-5boGt@7Oo=3HC>hiy83o-uo zhdM)UN*`bH{GZZwpgB=c^(z;)b7szb#ZBpVHDyOr*d# z@$(afi_6dcyU!U&*Kej|6h9<$+k5vQrHX( z^D|9CvCK1ue=j@hj;U!Sp-3>M#(efOe<^nPxk^(mO5^8T3FY*}kNmFYahIPD>rlk_ z`Jp^r`Q%J{H_qy$wp!;4CW<#prn)xWkcZPmlvmfpOnfFaBSe%eT59&O|zk1Z{^nc z;qskp=N9#vAip*!h2SG=(Esu5GB-C>HJF^4l$WZt6}8*P@wBs3XGFzacupC!71?$N6DkOc?tU9T}tzttwaJqpH$uTH074`?%P@a9`aRf5;mjUHB_2{Z;^Hp6qM*L>I3SL!bR#z;kH=BC6 zfsE2zUaF>|<=9zvCZn|XfWQ6(q6N`*nWCmAvAkmST=zTgE3fU1o2Dvb{CGgKS=or_ zoK4SCz3Ev|0iwyz#QXDA%A)$He99L(U9ymBb$wlpDV0JIZPT+%Ee3Txe;Q@y>()vT zF|)a;ww7rsFO>jP>`)?~r|G<%@8=?6>bs2T(n1sB`&P12XuO(EJiR^4-QJUo4t&}12pYAEbOV`bw|9yj2xv&g-Ch%(mB776 zW7*HhYQ1Oj#qjxf?gr+w8pl7_oiM#$K_QMU^LOC6Pvh7%3eGcmB92|gBfvO=72<++ zF(+|^R>T}IU6Y*gqw7HW9`2fju(Sb)t6t2Uy% zWlJGnZj0fhJ}iS9PMjk0i8kgcC)BPff>rGUa3bmYal)#8nXu6yXPLQreH?oym`vbY zJ@!#DeE^Ti<^VS$pNHdgf&BPxV4&#aemyMPROBC&pK3`z?d~29m=y1v61&uxGOuBb zYLB2Pvg_f&D7FghR$PX(_&r0z!-)d(uGa?(8my*>)vE4P;#DQ}p$4ly#LGqa{k`oc z+9#Ln+dZbzI{C#Dl6OAf*!)1D-9%zmXt&)IsQ{7WEl^7lD+jA8g`F-#A}>l&?b^TAg2B4sPB6IC z6|{&Jm9RJneM1;)at?=|hAWL)M5FBhUt)wqPtTACS2r#~f|k{y@M8>z?|S(sZeBbF z7aFy!=3UOnei4l=I`j4;FGSD~&_?q=>W^MTYvbZKM)JxrH5JTFe=35O)!5oIhTY|V z#%h=oS6ExJUsk&SAuzr1)&vvk(NOD$zBE3=1+_`h0`*T$>il@`grTiw1i$%yzj>7$ z#HP<*e6s`vY8xR+?;NFkwm%B6CIirJOrff9Pl=i4UC&WhS5ME??VIB59Vz~h1QmZV zY9Dv;!qVi}ik8vFUGwKHoTmbC+*K^&E)!kFZsZzGrg7IDEXH0Fpk?=M;2aG)*0P{+ z*LDuRJVw5_oH9P+!oW`8zNoS6UxUV7g{TaU1|5r9rg0a0!wXqyJSJ!yvIsb8(9w)U zZ)KMBI)F=LL2ocidba}i(JbgWntduIIzK$E6WuA7dqL|^7W7iJ`-0?0?Y_50p%+EG zVPvYKxyQCIh~6ULmaqW81m(v%_^kxy-!+c?M-aUyf%)Yq^eC5?GzL~NLG<1Nu7Hgs zOb~y)@S6n8O&T{+dOrlr=SQIz1-*aQ7+A#w@%KaEUdV!;quDnaz3~|Op2guWOi+4v zz;8M*pY`B^`1=|#2Ryh;_4jVj`@Y7&Dkg|t*GahB6%S1ifA_%eCSc}q*9L~;1VztX zl%_k!&TBP>ziEQB*tP+8v&II+8%6l{rO*pX$Jc;6FbX}E)9+_Vk6LjrWkK(?Ea`=@ zcQuLoS1>{8ErwrIV+6?Gg|T(su?*drju>$3MxjUCW?-)K;DYGw1m+G8E>pRRg5F1g zxliLps+Ug!^UG1_F}*JVGlh)8P%c6Iod?W35AGP}yY{P_L(s9qWH!Xrn;S#ix(kbzD>oG*29-M0Ou7v=5(^vM zcyl98CPn!Bi|^r;wc&=8ntQV`Q{Vfj6B`?bMzJxT7O^poRrcx;XJWL@tz^J zBD{;mhL>>*UohxDSQPZ^-EIikIm6N9Y>z&vgCf$FnYpWX0X&gxTfBz65E&U2NnU}3 zx{+1kY7>!`(>1Yt(J(EzN!R(Zx#pC;pvnVc9FCnZOtsAZC5J~^nOF>@TA5I)I;6&J zAR15;g5(I)a4qCPiAadLl5EB;%k0v-@x1H3x*E9rEV(5;*BWrgb|A>X)FVkcp}D1ye|v^PqAx@?53Gz`>#1eD>1!zvfWf< z*G>l}&rx~hP1FN)Fv^n7QZt!)L3=`bE$GTs6xLf6ga^7U-6TY>TEDdaJ*QP|IXMCGWOvahZ=_7$k|@Q zD?ur#>5xZPC zuu=p%-)14QYbVcmx_M8*ZQrI$%l^Fm6ni1FaRD$$MP+l@(}TaYap`&OQ}(|xM!wq6RFM0`j33*N zSnxUml6xY1*q|(r?SFI3{=bazxAOP`%_hdco9T-n0yG_kLkFR1J$X;TSN23chJv@J z;Js}B(bU7wYAQne54}ya|E<$i%P$nAy+>Q0el@rW@*Q|0QaU!k7B=?aT`0Eq;jLPD zoUZHcNkrvF9DSkgdeOrM0;f{&=<+F@!8-g_Egkeop+P(sO>T@?7Qz+z$pQ|LjL7&G zp@jhJ2}}1}UvVZPwcTa!1LO(F_pvAj>xv`@&_j&62{31=*n(y3f?_qE+m26y^Q%MlUq4{3evtG}vSjpRz zvBCiz{8`7lp84%BO+PHG1Skb^-QnwJF7vE(IiA3)JXZ~y#lNQ^`Ibxrwr);t}`Pv$*^)l`S_6ck^Y<53)RD1YJ;WtL0X)RePd z;qC#gjz~QJ^5LQ{=q4M#pwJ04$IaYVvx#1$Qv!*hUfIV7#1OHZTpgt=_$FF);a z=qM?UcIhcY23>lJA}eOx4PV2MBS-&Q!fFZQTzcyA%z3Au=k)7K&rf1V;}iSe@sdmV zdQDj=4tmQN`!YY}boIUq1XE11Fh70voGV<)AJmjDfE4{b+J(USDPNGLI5@+H`S!1# z`HV~X8=CTrG|Dr5q3{EOl{FN$~@}rvaMQN000qf`aqBP1E z3x?8QzFqtE-^_CVrw`!Spcx z9k!AD+oX<|3(WNx1uiJ|8>)=WPY*q>(&QkfD>2X??+{fi7h}3sCjrZN#Y~`1mYRC3 z=)5kTAt=%z`)yk~yCv!UBVeFxh5Io^f~^sCOQqbE&L-k=6};*)`o}7?R;GUoF(X#C z5wRP3S;ZRe7$)`AGJ;2tPhWg1u6fIxZk3=d?R{5g_7~YH0mnN;GMRA!(TlivHQDl> zo-G+d@;(-(4SS`yZA52xdiorgzN2I*^yXsAOf?I|MKo-n%e8KwqqJHiI)1MDTsl$g zv^rdCbvbI-&JiV1SA{OCa7;p9e4{6Uu|yy0U8PE0M?90KPI~!lHwqO>Zy=X@^co$H zH5HYu#p)8TOukNfQWO`lnSAl=IX-p0(e{!{7M6PUl24btF2{whm)lh9F|$Ib#~ zB>swl>Gj}((t8~+yFIu}=_P-60P}zc7ewz-V4n5hGSTY=y(1dKbkGFRTZ0AKOXw@+gPh*uE31He5w3cYm*|FbOVEymQT5f4oee#YtbaM5pOqyrQYz&O29#y2e-i9MS$%;UpMwLTQ|xW|E9^7M z-n@JuA5ldt5F_C>Bu8kH0>^JOpd@V{cgJLH5g(kq7%Q=$qgUiQ)CuNwb`!s#TX2M- z)LPvp`iLA5{v!CDhDWU+Vrj}TA_w|7abWj>`m(5bA3Kzep10 z`T^&6iY7;-*4yP!(!M(uwSv(7Fufy?B-C};lxQQ zPF!o!TY&Vf4cX24a6VZ@i3RswXqK*RyZn9&TBc%2F1Iq$)qE)X`3F8~+&!QZ=AAc9>+?OrJqjI!F(Pz>mb@V}w=4_%n zzT&5(&gfa5!bU}cH>u+D!aeeJ`mKGPiFmZ5XKQz~x2Ll^!5dY&qZKPwR<`%Y7cEL~ z2uDhyqbwHvVqHQ!*u@;}{CqW#VF_O$HnyB5o`|gamy1nDINBL{ZU|;rq8^h`m^emh5CFFqABK(p9iN9(=+B-R>=>3zn^hH^QRwqeeF|O?R z!J97SbLa#UGNPdFrOe*jPdSt}(PR(mo~xbl+f5$IH6#mjJj=Z%!czthz1IF2muIJP zAJ1|x3oS^ap< ziLcX?uYY0d(=O#Fwd?Vm6E{JFavu8abA2x5ziP^(ofH4#!VC6{v~Wwx|MlD!+oe30 zPB2`!^)Jq;h18qZ?`+o@n%i)pNIW` zrhJ<4gT?rgQm{Zp2!_gZ9`;yIb591H+#C+bXukQ_7Hr^1Ta8~|)v*)fPuJ;ianpq# z;DaTxb{f14QU6}bh2z4wHv&7kE64KYxlNbTf z+ZXTY!vxk3;e@vXcggqlT$}D8y@l(%!nybwvGP9Sj)7j+Q1u4@~S zw0H-*AJbHzWGVzpP`u3%KzbOJ)YfDmkq8c2_Vgv1uZj0bhu6HZ8a-Z2b$C9WWKlw` zHdNP`%}bjbP2FR1odG8k9TMfG>@;zFPl!OdT(1o|689|$@kC-JZZ&RR2674!bnx%u z*>mSAU2gSu=Ii=kUD7Lg=5BWB++uO1?suON$C5n?R*KLPUywAIuPCpK}#&P)TF(z?5PU>-Eb3PHcN{wZ=DDxK2&M4uHc-8^)MU7*% z3DObY4A1Lyy&}7r=4ny5?*!(P9$e78@5{j4=fP#7R|tBCGzL~NLG*qM+>ue}MM2^B zz)Zwof`$!45WVw&nWu3<>D`C$CNXR&VK@L#^!)Qu&axJ33~@9;^TYQ5_dbmciZ_bz z9|q<-8aGlp9tY+ZqtIh{`HjZFDkexSXP^(bko^Em5PzgM7nlwYPUxkS({;dgYYePn zg5rG?xMw}|GL{!GbOe~A>`h>T@`L*kbJ+`cjLHvxzHtt*E+fv}=^+W0QyaK{)z~1p zn81B1geFIX#C7N^cAv1He3}Rc)Dlia&onXFfgbsC|(jOs4jL zON)oIz;WRFWR|$6vcR1PdOytqcLH$#odu5KcsUCk+s}e1ULF(FZ%vG1trQPUP=2ty z%#0ew6?kZf3o0)gqd04ihbD-g3BMgt!`O$1W~BP|!zj-1;GqekcMtqtj^aGSRH6)n zYnGYHi;Snv5lHftsk{(3Eh8?y|2Pl0c^VtU-z)GifhjIh(Nd=^6Mtjieuu^=WajeB zuH*d~aq0Yh8Mym2Hi*ApfZicsK6|c;mE+Y+{87{3sKzLy!(V#5=bVR22=UMa#rq2U z76UW$e1XZCgP?MC6EN@BxFC8_khvR}eHxb>KYMh=7*iphXMuS+3wlR^nLM4LFxA8p z#NRw%YBes1Kh~odFgvoK_fcTJJPN%i=-mszu%2dX)tPNP;IQC@VrfO_Z zIw-#xDfEKmQU=`8QRv+RdaHmL%K`=yRDU^5c(29?5U))2_Y$~&C<|OEa8GA}W4$ck zpweT4+SBpCou#os@-snaIxw3w&MjB|e50o0O&a4w9Te{!zB3}lkn*(W> z0z8@O`8c@$N@Iwl$s}j?N3UeWrMCy;FM?d~&;;?vaxfj3A8T9?e;hu5be8n~2e{W$=w-Jr zn=>YqUl=uaU_Z^S-KLKZ9--XqTR(}nbE!*ya-UFbT;;=$lkTu+B6A5w?b0Y4e*R4j z$G+<9-&CQv58y7XkBb&l<&;IFRLKC!VR^L7e#|NfuE zjTM=c!m@M5wlOR_^S6j?0p3+&Ta0(T*i5{CCAMn3pAZ{;9u^y3(9293#HMt&)$Shd z$1WOrX!7Qq)+6*-o7@zHWdaM%IkLA?5?}K=Yr}G_&55s|{RIj}JK*W3e z2D0UpRFz&1lFPsk-gvWiwr<=B8*ak7ktN!?aWCHPe!J4ENEzHpy7P=x z_DgIemgU>w79KELaIkg_BVzeARQbhmB6wPdAzv#`2kjlF~1T9sG0 zN5Z7Sz){)&{sl)Is7Nj4JyIy61@=!6_q%o6e?r_f=6zCfs@B-cs;#9R_Nsbo#U{I^ z(W*+=RiUznwokK{M(n@NIBK7~dU$!nF0>EvEZWj-wN~|4j}r3A;Lq*<6j45GE!}R} zI}oQm5G#4I>{aXQbf56C110;)-k9*QePss{%k3eip=^JmzUfxpu$fgK2DDs^QfQCow_J(PX*sa@mvsi0_ zH-I&5Us7LTwI-(Rw`#Y0x+zkg&zCY1$12!SDfa6FarF^)&$Cn$6ra*Bj+P2opIViND>w;#}UYoFm zgQ|*Yhpe>;haEYK$9~ir0|`x5vN=MU5FSrlPqA{WMNt1)OOb%9n|9EzDO71T zpwzV{EOBTPCW(<|Nxj&Sd=5{pfla(Si5{Cwyp;PDMKh7`=|c|`?s{e* zf7kGYou7o?(DtHe&On}kUo1_HA-%gPaPl6xGdM9N4s`p_z?0~9?Hj~5SwtUi%8RGl zO}%#HuH|X)0uppWw+702|X4Hoamkfe#A`16dRm!PM6MN#1@``4&~HH9m3@5ht{4gC>@ z2`JIKb2&*gZmupmWp^W<@Xq~-)9qEgcIev~sz+Vzjeiwp{|~#^sG1TmPI;jFb`FT_rs<_M6WlZ@5V2zdf=fbk$KX;a}Mp1XsbQM>b4q9?c{7+PNz`}z|z-mqV{|C5~A zPrwoP$3D`$|JP$M^nYaN`P@Hz60=ERR5im9`)Jl7?W*neiqMihjnjwis%_{=LN{}O z1&#H?%boE=VzM}4LR`bkM2_$xj|sP~8Xg{oT6)9|BT@Ko558rOXZrY|#Kt1I`sUYm z>s$6b3!{<2W;Du&y(1CT_|w(OQ_LeEbmNsfW5f>(;jBp%jN(P^&AIY&l(G8(n6k=V z`MI|c9@7lUCWsCMYUK=k-J12{H+09w!SF?RB68D^vT-Q=0G_aMJKp=n#^0(5os67P zgMc2`l-rF-+b3b02yDc7IO!HOYAYHV7m2d*#;%^Nm|Lh*Wx(M~C2%Z z!P$qF+l81X7Nj-|$Ov@25oe^?ww8lx3`a1imXT~#<+LX_sFojVWu!)bcQnxij+N}% zU}K(zjm=57?MWN!@b|@+by(GAc3`SDe;zgtyCNg^1Wtc}u4Ek0hVhiVMds2UJdEGL zLsSf6FgR6182=D;!Y+2QYBagpmM?qO>7kDNuty&1WS0%7Gj_pkc45nE&eccF3XbIq zFfdHmt)U8$yaoHMJHTkgl4*~qd5)aomg@xv`U0w$H+*a^p*| zsoeM)Y$`YQ!=`cr7UOq(!9c*$V?6;o`p0Sjmy-M$u#u~XAi6y_sfL ztbxNgTb5MeFfm=q$pzK(K;;Ax> z-?o%eRbkzC3vj#kS>ib1)*<||YZYrwN$YbvDz$<+Vp$VHE$K7J+BK@2Wk_gx(tWF6 zy2h7-HC51Ju&IJ}dD5*Hwus1R05&Bf7B3|u3$~NR_tvB@3zhO^AE%1f-AUh1C4E&f z;S4A)=ao_lL9zrOfbmtnU=WowncP28eVs?>4X(Iv1~ygPTaR7b>@q7d)$L=Exm&5{ zf-5EI8m2|$Mwu(O&9Lznq_EKgo04<_HYH0IASG$0P5JIg`rZkflJtj?z8_2a@?xvh zI_4Aa=K-Zb?D%gO+>}$zxqTbUajX4Rww1XL?Rrw}P$X)1y>>$ps@J8qwHH3RQ}H%$ zJW+=>8H?p-*s_n2)YFqj2O7_|M}gfT~w8zhX2#W&-OQkv~-M55X_?|#5B2xg`T zCfS>zocbMy3)eBs|-VVKhH51&bc|PS*K`(8~!fs zLX7_`Qy4D(vrOqH74rlW#T!{^bX{475ud}^m*GN_C#fiEoHJ)0+Qf*sux7V)^>kmg zc?#~NnN*k)(=A(K&*bFMC;5hJQgYl%~6#l>63 zPDSY4oOO7M=~@9I4xLMMs8dxaPwAZmuq)MTzkJspPfe5RX$k{kED7Ij|GUjLcDa49?2tP$fcKWD(jO(}lp6OUdQzC$o3Jz@Us>F0myrt}Oph%oO+li?J& z`YFF7O@^GP=H^84ruj^(iFFtVRLp!$`OGxRXTjf3`OGxRXA8zDnPcL!LCvAe&$rQ> zoklqdS3l*m(-K^wi~Q%`+J(J#RP4l5+kW}iBS?{cRQ=KwDab@`P$j} z>e6*9rA(KdahaCwwmVzeS^*7K4I(NDA2#v_jjbWX*r)`8n$!f;G=U}({}4+gG=3x| zZDT4B62;%|yz}P1J9nl9dy{#)bMN_`d(OG%o_lBJzVkfgocu%aX~X%La=w)0b&+q3 zUi-@9hVvhl^Q9!Oqn%m4eEGiL8qWVw&KFBwchAiS{~ji1ffFC`Oq~E-v7UO(GIj?s(ZxB?(dHUrQKU(i_=I%S0IEE{CW-mOw@){%a^U67` zoQ?N-g3`b@v?X)uu(9D^6-64`@)-;D%HO_m-k|=gDAL%L_XQPcab(>mH>4dc0-@n; zJ>1=1R?J{qhc{9_qSGZ9TGb;@7VTyZ9v=SsLq?uaMUlqVA}1*BF<3r!=FuYtRZtXZ zY%TJrF>&?s>O+qQjur)>c@H0KXc2Rk>|Y1Q&M@1KTirO8ZW%TX(LYIc+A9 z#cK`cQ7Vs87S4@M?=CJrD=VP0wJ1A%RfT31uXx#gO=(|MM~j-E;#yQ4&UK-=K{-G0 znGJ}L3A|(3t(@x)=Z$DJG9Ufw2X3u9ocaAvXdf<3cJ7Y{mGhKv#^=g4V+i?-f<*Pp z{Sn{g-Xxqqh%3u|=MMcM<}J#ZG`6>FLXDA`$SFtW=`Ic18?8A+{>U1ql=HM>4Sv=) zoKGJ;xnkPkjIa)xW4JO#ZF#A<({O&TE*dk+*~F;Lf?A0y%U3q+i>(gp6-63*c7G8y z$pqsq%TH>*zuwqqK~bc!Q8%L|nc!;3a^~zE-!-V{;di95QCm=B;?HHZ{pSqowDv_B zdn|4d)Rnl>x}SJ#%@1cBi)|Gek5|0B?-YM*EcTXi-s)KFRzdMIGRx+_9Dl>eb2S4i z3TbS48mKWNn0WU4zufA`vrTA@<9Y>NA3pi=V@95ga^B|1Gb<=<9(rc_?$`*BdH?%X-fvJh za8OZ5V{3tM6B`TC>~OSL?9#B^PW!)IIWMXfX04>wW|WCsbU5?7&ya@ge|qtWgT_Ah zE9cz~=cO(xK^V$z;rtX3=~ksPA5UK#WfUI4vs^Pn>D$^!iqz2@%dxf`+B5-hREvy3 zk_{={2s22>>buFK8@br6DViUtUtVcVy&bU__mQATzO!%ecgZkaany($+hLk%e*53x z&#Z1c9?=`?_@?FAWn^dakkjcx!iEXSqi&FwiD{OFjpUP7t9eBfvig5hHupT$m${a5 z1#coZQH$%59!rnKR7j`NYtt#Yvj?VW?`$I#R&`T(Dw3Azo0x7&e&U#FK{mTRN=z+A zwVPm1Jjl1dy&4U0!WY$JPuR8bk~q=V{fND|4w)d1cN_77%=VjE?USGF=AarmWc5Haa3d-m1!Km=!pSg z(lpU4P87@g9!(5VitXVx`*-%*m9Ye!2_rPyhLMzL{j>Rt-E;1UNKc^`j`*d5mmW`t z`Q5|1@j@xcc%kFcWjj{uSaGsYLu;RwN{|IJI((cR{5+@tF`O+6Do|t)q*FM0ZP9)% zSIk$zLQi8`ZGO$G)T_S76WU?-O@yCRcuqT=YAr1-E+KpUa&ISbSyIJ`LXM(TaF82+ zYT5%vy3y(xJ$QOwZw`k6fM%yDe)e6D4u%?$jR9QdaAWU40bp6zl_d`$cMJMJhG;@DOCo|!R$QI!w&|kg zE_`%AyAZ@4P!aK$SqF8y*7tFHQ{69wYzCzvL^{KzPHRa5Ky|h^k~3oap~SM96u5QB z_TM@9{Z~SD1qfD{D8tb?ODAMC#hijaVw&LO7%EGamt?D6HCqoIu7|#RtPH%cw$EZQ z-rE)HSg+y?id$J6I8Iucwk|$@O;>&l3Cgq$&^a?{G|H14{ z$q^ngc)l6eXK_!@CdZM)uX=t^$ap*$bZLFnb}hFTdlZLPMbD*S$O({tvx@wi_I{<= zyG? +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h new file mode 100644 index 0000000000..e957430c32 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdarg.h @@ -0,0 +1,10 @@ +#ifndef __PCCTS_STDARG_H__ +#define __PCCTS_STDARG_H__ + +#ifdef PCCTS_USE_NAMESPACE_STD +#include +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h new file mode 100644 index 0000000000..ac34d1086d --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdio.h @@ -0,0 +1,10 @@ +#ifndef __PCCTS_STDIO_H__ +#define __PCCTS_STDIO_H__ + +#ifdef PCCTS_USE_NAMESPACE_STD +#include +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h new file mode 100644 index 0000000000..f0b344e8dc --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_stdlib.h @@ -0,0 +1,10 @@ +#ifndef __PCCTS_STDLIB_H__ +#define __PCCTS_STDLIB_H__ + +#ifdef PCCTS_USE_NAMESPACE_STD +#include +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h new file mode 100644 index 0000000000..458a08a94b --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pccts_string.h @@ -0,0 +1,10 @@ +#ifndef __PCCTS_STRING_H__ +#define __PCCTS_STRING_H__ + +#ifdef PCCTS_USE_NAMESPACE_STD +#include +#else +#include +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h new file mode 100644 index 0000000000..9255d1e87e --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctscfg.h @@ -0,0 +1,350 @@ +#ifndef PCCTS_CONFIG_H +#define PCCTS_CONFIG_H +/* + * pcctscfg.h (formerly config.h) (for ANTLR, DLG, and SORCERER) + * + * This is a simple configuration file that doesn't have config stuff + * in it, but it's a start. + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to the Purdue Compiler Construction Tool + * Set (PCCTS) -- PCCTS is in the public domain. An individual or + * company may do whatever they wish with source code distributed with + * PCCTS or the code generated by PCCTS, including the incorporation of + * PCCTS, or its output, into commerical software. + * + * We encourage users to develop software with PCCTS. However, we do ask + * that credit is given to us for developing PCCTS. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like PCCTS and have developed a nice tool with the + * output, please mention that you developed it using PCCTS. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * Used by PCCTS 1.33 (SORCERER 1.00B11 and up) + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1989-1998 + */ + +/* This file knows about the following ``environments'' + UNIX (default) + DOS (use #define PC) + MAC (use #define MPW; has a few things for THINK C, Metrowerks) + MS/C++ (MR14 Microsoft Visual C++ environment uses symbol _MSC_VER) + + */ + +/* should test __STDC__ for 1, but some compilers don't set value, just def */ + +#ifndef __USE_PROTOS +#ifdef __STDC__ +#define __USE_PROTOS +#endif +#ifdef __cplusplus +#define __USE_PROTOS +#endif +#endif + +#ifdef PCCTS_USE_NAMESPACE_STD +#define PCCTS_NAMESPACE_STD namespace std {}; using namespace std; +#else +#define PCCTS_NAMESPACE_STD +#endif + +#include "pccts_stdio.h" +#include "pccts_stdlib.h" + +/* largest file name size */ + +#ifdef _MAX_PATH +#define MaxFileName _MAX_PATH /* MR9 RJV: MAX_PATH defined in stdlib.h (MSVC++ 5.0) */ +#else +#define MaxFileName 300 +#endif + +/* +* Define PC32 if in a 32-bit PC environment (e.g. extended DOS or Win32). +* The macros tested here are defined by Watcom, Microsoft, Borland, +* and djgpp, respectively, when they are used as 32-bit compilers. +* Users of these compilers *must* be sure to define PC in their +* makefiles for this to work correctly. +*/ +#ifdef PC +# if (defined(__WATCOMC__) || defined(_WIN32) || defined(__WIN32__) || \ + defined(__GNUC__) || defined(__GNUG__)) +# ifndef PC32 +# define PC32 +# endif +# endif +#endif + +/* MR1 10-Apr-97 Default for PC is short file names */ +/* MR1 Default for non-PC is long file names */ +/* MR1 Can override via command line option LONGFILENAMES */ + +#ifndef LONGFILENAMES +#ifndef PC +#define LONGFILENAMES +#endif +#endif + +#ifndef LONGFILENAMES +#define ATOKEN_H "AToken.h" +#define ATOKPTR_H "ATokPtr.h" +#define ATOKPTR_C "ATokPtr.cpp" +#define ATOKENBUFFER_H "ATokBuf.h" +#define ATOKENBUFFER_C "ATokBuf.cpp" +#define ATOKENSTREAM_H "ATokStr.h" +#define APARSER_H "AParser.h" +#define APARSER_C "AParser.cpp" +#define ASTBASE_H "ASTBase.h" +#define ASTBASE_C "ASTBase.cpp" +#define PCCTSAST_C "PCCTSAST.cpp" +#define LIST_C "List.cpp" +#define DLEXERBASE_H "DLexBase.h" +#define DLEXERBASE_C "DLexBase.cpp" +#define DLEXER_C "DLexer.cpp" +#define STREESUPPORT_C "STreeSup.C" +#else +#define ATOKEN_H "AToken.h" +#define ATOKPTR_H "ATokPtr.h" +#define ATOKPTR_C "ATokPtr.cpp" +#define ATOKENBUFFER_H "ATokenBuffer.h" +#define ATOKENBUFFER_C "ATokenBuffer.cpp" +#define ATOKENSTREAM_H "ATokenStream.h" +#define APARSER_H "AParser.h" +#define APARSER_C "AParser.cpp" +#define ASTBASE_H "ASTBase.h" +#define ASTBASE_C "ASTBase.cpp" +#define PCCTSAST_C "PCCTSAST.cpp" +#define LIST_C "List.cpp" +#define DLEXERBASE_H "DLexerBase.h" +#define DLEXERBASE_C "DLexerBase.cpp" +#define DLEXER_C "DLexer.cpp" +#define STREESUPPORT_C "STreeSupport.cpp" +#endif + +/* SORCERER Stuff */ + +/* MR8 6-Aug-97 Change from ifdef PC to ifndef LONGFILENAMES */ + +#ifndef LONGFILENAMES +#define STPARSER_H "STreePar.h" +#define STPARSER_C "STreePar.C" +#else +#define STPARSER_H "STreeParser.h" +#define STPARSER_C "STreeParser.cpp" +#endif + +#ifdef MPW +#define CPP_FILE_SUFFIX ".cp" +#define CPP_FILE_SUFFIX_NO_DOT "cp" +#define OBJ_FILE_SUFFIX ".o" +#else +#ifdef PC +#define CPP_FILE_SUFFIX ".cpp" +#define CPP_FILE_SUFFIX_NO_DOT "cpp" +#define OBJ_FILE_SUFFIX ".obj" +#else +#ifdef __VMS +#define CPP_FILE_SUFFIX ".cpp" +#define CPP_FILE_SUFFIX_NO_DOT "cpp" +#define OBJ_FILE_SUFFIX ".obj" +#else +#define CPP_FILE_SUFFIX ".cpp" +#define CPP_FILE_SUFFIX_NO_DOT "cpp" +#define OBJ_FILE_SUFFIX ".o" +#endif +#endif +#endif + +/* User may redefine how line information looks */ /* make it #line MR7 */ +/* MR21 Use #ifndef */ + +#ifndef LineInfoFormatStr +#define LineInfoFormatStr "#line %d \"%s\"\n" +#endif + +#ifdef MPW /* Macintosh Programmer's Workshop */ +#define ErrHdr "File \"%s\"; Line %d #" +#else +#ifdef _MSC_VER /* MR14 Microsoft Visual C++ environment */ +#define ErrHdr "%s(%d) :" +#else +#define ErrHdr "%s, line %d:" /* default */ +#endif +#endif + +/* must assume old K&R cpp here, can't use #if defined(..)... */ + +#ifdef MPW +#define TopDirectory ":" +#define DirectorySymbol ":" +#define OutputDirectoryOption "Directory where all output files should go (default=\":\")" +#else +#ifdef PC +#define TopDirectory "." +#define DirectorySymbol "\\" +#define OutputDirectoryOption "Directory where all output files should go (default=\".\")" +#else +#ifdef __VMS +#define TopDirectory "[000000]" +#define DirectorySymbol "]" +#define OutputDirectoryOption "Directory where all output files should go (default=\"[]\")" +#else +#define TopDirectory "." +#define DirectorySymbol "/" +#define OutputDirectoryOption "Directory where all output files should go (default=\".\")" +#endif +#endif +#endif + +#ifdef MPW + +/* Make sure we have prototypes for all functions under MPW */ + +#include "pccts_string.h" +#include "pccts_stdlib.h" + +/* MR6 2-Jun-97 Fixes false dependency caused by VC++ #include scanner */ +/* MR6 Reported by Brad Schick (schick@interaccess.com) */ +#define MPW_CursorCtl_Header +#include MPW_CursorCtl_Header +#ifdef __cplusplus +extern "C" { +#endif +extern void fsetfileinfo (const char *filename, unsigned long newcreator, unsigned long newtype); +#ifdef __cplusplus +} +#endif + +/* File creators for various popular development environments */ + +#define MAC_FILE_CREATOR 'MPS ' /* MPW Text files */ +#if 0 +#define MAC_FILE_CREATOR 'KAHL' /* THINK C/Symantec C++ Text files */ +#endif +#if 0 +#define MAC_FILE_CREATOR 'CWIE' /* Metrowerks C/C++ Text files */ +#endif + +#endif + +#ifdef MPW +#define DAWDLE SpinCursor(1) +#else +#define DAWDLE +#endif + +#ifdef MPW +#define SPECIAL_INITS +#define SPECIAL_FOPEN +#endif + +#ifdef MPW +#ifdef __cplusplus +inline +#else +static +#endif +void special_inits() +{ + InitCursorCtl((acurHandle) 0); +} +#endif + +#ifdef MPW +#ifdef __cplusplus +inline +#else +static +#endif +void special_fopen_actions(char * s) +{ + fsetfileinfo (s, MAC_FILE_CREATOR, 'TEXT'); +} +#endif + +/* Define usable bits for set.c stuff */ +#define BytesPerWord sizeof(unsigned) +#define WORDSIZE (sizeof(unsigned)*8) +#define LogWordSize (WORDSIZE==16?4:5) + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#if defined(VAXC) || defined(__VMS) +#include +#define PCCTS_EXIT_SUCCESS 1 +#define PCCTS_EXIT_FAILURE SS$_ABORT +#define zzDIE return SS$_ABORT; +#define zzDONE return 1; + +#else /* !VAXC and !__VMS */ + +#define PCCTS_EXIT_SUCCESS 0 +#define PCCTS_EXIT_FAILURE 1 +#define zzDIE return 1; +#define zzDONE return 0; + +#endif + +#ifdef USER_ZZMODE_STACK +# ifndef ZZSTACK_MAX_MODE +# define ZZSTACK_MAX_MODE 32 +# endif +# define ZZMAXSTK (ZZSTACK_MAX_MODE * 2) +#endif + +#ifndef DllExportPCCTS +#define DllExportPCCTS +#endif + +#ifdef PC +#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME +#define PCCTS_CASE_INSENSITIVE_FILE_NAME +#endif +#endif + +#ifdef PC32 +#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME +#define PCCTS_CASE_INSENSITIVE_FILE_NAME +#endif +#endif + +#ifdef __VMS +#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME +#define PCCTS_CASE_INSENSITIVE_FILE_NAME +#endif +#endif + +#ifdef __USE_PROTOS +#ifndef PCCTS_USE_STDARG +#define PCCTS_USE_STDARG +#endif +#endif + +#ifdef __STDC__ +#ifndef PCCTS_USE_STDARG +#define PCCTS_USE_STDARG +#endif +#endif + +#ifdef __cplusplus +#ifndef PCCTS_USE_STDARG +#define PCCTS_USE_STDARG +#endif +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp new file mode 100644 index 0000000000..26b88c3cf8 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsp @@ -0,0 +1,118 @@ +# Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pcctslib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pcctslib50.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pcctslib50.mak" CFG="pcctslib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "pcctslib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /YX +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pccts_release.lib" +# Begin Special Build Tool +SOURCE=$(InputPath) +PostBuild_Desc=Copy to ..\lib +PostBuild_Cmds=mkdir ..\lib copy pccts_release.lib ..\lib\pccts_release.lib +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pcctslib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /YX +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pccts_debug.lib" +# Begin Special Build Tool +SOURCE=$(InputPath) +PostBuild_Desc=Copy to ..\lib +PostBuild_Cmds=mkdir ..\lib copy pccts_debug.lib ..\lib\pccts_debug.lib +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pcctslib - Win32 Release" +# Name "pcctslib - Win32 Debug" +# Begin Source File + +SOURCE=.\AParser.cpp +# End Source File +# Begin Source File + +SOURCE=.\ASTBase.cpp +# End Source File +# Begin Source File + +SOURCE=.\ATokenBuffer.cpp +# End Source File +# Begin Source File + +SOURCE=.\BufFileInput.cpp +# End Source File +# Begin Source File + +SOURCE=.\DLexerBase.cpp +# End Source File +# Begin Source File + +SOURCE=.\PCCTSAST.cpp +# End Source File +# Begin Source File + +SOURCE=.\SList.cpp +# End Source File +# End Target +# End Project diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw new file mode 100644 index 0000000000..995e5bff2e --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib50.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "pcctslib"=.\pcctslib50.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp new file mode 100644 index 0000000000..d3e3b0c97c --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsp @@ -0,0 +1,124 @@ +# Microsoft Developer Studio Project File - Name="pcctslib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pcctslib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pcctslib60.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pcctslib60.mak" CFG="pcctslib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pcctslib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pcctslib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pcctslib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pccts_release.lib" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy to ..\lib +PostBuild_Cmds=mkdir ..\lib copy pccts_release.lib ..\lib\pccts_release.lib +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pcctslib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pccts_debug.lib" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copy to ..\lib +PostBuild_Cmds=mkdir ..\lib copy pccts_debug.lib ..\lib\pccts_debug.lib +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pcctslib - Win32 Release" +# Name "pcctslib - Win32 Debug" +# Begin Source File + +SOURCE=.\AParser.cpp +# End Source File +# Begin Source File + +SOURCE=.\ASTBase.cpp +# End Source File +# Begin Source File + +SOURCE=.\ATokenBuffer.cpp +# End Source File +# Begin Source File + +SOURCE=.\BufFileInput.cpp +# End Source File +# Begin Source File + +SOURCE=.\DLexerBase.cpp +# End Source File +# Begin Source File + +SOURCE=.\PCCTSAST.cpp +# End Source File +# Begin Source File + +SOURCE=.\SList.cpp +# End Source File +# End Target +# End Project diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw new file mode 100644 index 0000000000..3400c443cd --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcctslib60.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "pcctslib"=.\pcctslib60.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat new file mode 100644 index 0000000000..8784aee9ab --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/pcnames.bat @@ -0,0 +1,11 @@ +ren aparser.c aparser.cpp +ren astbase.c astbase.cpp +ren atokenbu.c atokbuf.cpp +ren atokenbu.h atokbuf.h +ren atokenst.h atokstr.h +ren dlexerba.c dlexbase.cpp +ren dlexerba.h dlexbase.h +ren dlexer.c dlexer.cpp +ren list.c list.cpp +ren pblackbo.h pblckbox.h +ren pcctsast.c pcctsast.cpp diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp new file mode 100644 index 0000000000..d6b8bf6c2d --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/slist.cpp @@ -0,0 +1,105 @@ +/* + * SList.C + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * PCCTS 1.33 + * Terence Parr + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1992-1998 + */ + +#define ANTLR_SUPPORT_CODE + +#include "SList.h" + +/* Iterate over a list of elements; returns ptr to a new element + * in list upon every call and NULL when no more are left. + * Very useful like this: + * + * cursor = mylist; + * while ( (p=mylist->iterate(&cursor)) ) { + * // place with element p + * } + * + * The cursor must be initialized to point to the list to iterate over. + */ +void *SList:: +iterate(SListNode **cursor) +{ + void *e; + + if ( cursor == NULL || *cursor==NULL ) return NULL; + if ( head == *cursor ) { *cursor = (*cursor)->next(); } + e = (*cursor)->elem(); + (*cursor) = (*cursor)->next(); + return e; +} + +/* add an element to end of list. */ +void SList:: +add(void *e) +{ + SListNode *p, *tail=NULL; + require(e!=NULL, "slist_add: attempting to add NULL list element"); + + p = new SListNode; + require(p!=NULL, "add: cannot alloc new list node"); + p->setElem(e); + if ( head == NULL ) + { + head = tail = p; + } + else /* find end of list */ + { + tail->setNext(p); + tail = p; + } +} + +void SList:: +lfree() +{ + SListNode *p,*q; + + if ( head==NULL ) return; /* empty list */ + for (p = head; p!=NULL; p=q) + { + q = p->next(); + free(p); + } +} + +PCCTS_AST *SList:: +to_ast(SList list) +{ + PCCTS_AST *t=NULL, *last=NULL; + SListNode *p; + + for (p = head; p!=NULL; p=p->next()) + { + PCCTS_AST *u = (PCCTS_AST *)p->elem(); + if ( last==NULL ) last = t = u; + else { last->setRight(u); last = u; } + } + return t; +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/lib/pccts_debug.lib new file mode 100644 index 0000000000000000000000000000000000000000..8d8601849dbc324ea4bdfbf1b3ca61b9a1600e02 GIT binary patch literal 158702 zcmeEv3w&I~b@!}xwOXxYTefBVgsh1H1IEa2SvJwimOuu{mLDPx0Tx+WVHsIcq?HXM z5I`hBC=dtstf z$tL0JFW>LuN_Ted%$f6=GmkrW?zs!scMNv!ena~FOz>E{YUT3Un&q`Cg2|a0bG>@) zYLj(US}FA>O09nPt8>2PQKf#L&L4h4ssGDo?A+Vbq~}$iQ?dVB=O-7a*vX!Mw^GIa z-#qK7x_cjdF$tqo1totLTl`el-s&9(;&kWX_J(j6uE4fojeJ4C+)!snp9{OSp@9m#4B5N-3x)o@ zZYG!!M6B!1;X-a#zOX-^50u}|+9nkQH6+rN&kt{a7oy=SuD53>P)}N`?YW-*UBlg3sqnoW*W}&ut{~LL z-i|_Npb~)tnlgqUxw(Ok!9q_*K=-f+4JFFx%kTH32%Am2my;E%=^N_V)!Wl|^^nUI ziBkL4?j0mh%FgDt4Z2zMT)n$6fx=khxkCRn`M%sxA)qo^?}kPp?f?~b1q50K1KQBo zpy~-i3zDYn@Bu7Pydw>*fWQ$AYTY=HTVXuLd^8tY13B1q{@Rcl1WrR02BD_j{I&T( zK=u?|K*J0KwIEs8rszngp~_%Clb6#lEZ81EB!UTMgQb{+)P+kbt83RyqTLMTbL?01 zePQ+ks*K=@u%JHX{c~WCZ7+noQ|%29etf)6uv5?vUI!C z)TPwbd2~3}gy^F6M73V%=m{95+c6cw2Fb?GHdDB6ARlZK(v<3J8aD4}*|vi%Vmk!y z*y{|@HH|G7wa~IQbPSoH8-|C(O??By1q;5ZSq!m$Sr8h8^+2Cn6D46s^I#E^dQmV{ z#M5JSSAN&<)xuFW0;9Re57L~AdaH*Xr4;H#%7t9EPX)vL&w;$7jAbR$YR04Wo zbgbcAYbJWC5iH3(+qLEgdOLS_3>Lv{W+Vf>V5Ug6hX8YrBH6lIA1Z+F?FG)Ff-I1E zZF)La2CboveXjsGUvRBzObh^ zFAVB7%1+6Q;kpH~y#@q;+H@OS7Ay@Wbb4-0FvDq=0YtWC2BAe3-7*NPo$u(% z20_39XH@JVIm6vZ+X+GdNu(zNL^mcha}=R@X^m7{eX(52La3opDBO|wbSw{6ThSaxW4lDg?LF7$ovy=Tuu9QD`7YhGC%~us zj1Y5T5ncJge7A$%lUI7fYYUi98;ViXoIDT=-Ibr|;IgdhnW}(D~b`9kaDYlJ}_hxIeE6~JhYk~)FSkQg1;PQ z)wshF5~e;ZS*IEX2J`)cXaYV597c$7Fh9^gSlF^JKe&Gox9wZH8*z)(*5A{|+bEAV zQ4xA*cvq*~nR+?IVrypf7d-dH`DB!YlKR9DiDa(?Ne z!WdQU>H+gZrW3UmgWKXJ+!S~A_YDp2HRGAh!}uVr$Yi$n6>#?ws6gFTM4c{>GYD8* zgcKvmw+>ysJcxxY3Kia{8zccH$Y&ie+a38V0SLmoduE$X+U8jFntWHjldG8lF({}} z($&NHAv1>9^2p`QoKwP?$qIa~s~^*H2Oyi(C?_q{&6~kUA$D7`8W6~_9a_&&V;=LX z3-egiY3l1hzaA2n#w$H9W_3a297sh4&M;_2BziN=ACP+@slm-1VT(X50!(8W?AeP! z#hW|^*d;C9TRZm!0SKWukx~cqL)Z0T)hbZJRFW8*fBz5wnG`7+NvBPW`v|mvrZvpcc(eN6J+tG#z?8q;8;e@v2!)zIl8|Z+> zP@#HM60j3PY|BGUL8)zB3kKZ42k=X!>9sw{?;j48b^wO4T4rrKh{ce2<uU6{Oww&QgKXybuF(N)c+RE~i=w9g=6tK)%D$Yr44i z4Oj!L?F4fpXHCoA07MGeMH(}ma*Eg-7Gd}EJKlP~vPHDwkIDk_ql3_VId`~L%wl== zrq2`tsI!jX7luiX#? zruF|jHw3Thb5w609~u2PNBMofy(s?B{rBzJ@Fe#@lRr1!^}n#__rG@+cJfcbPxRQv zJ_mOne@Xvlmy67E^vR!-Pqy0mYA&FlC426y6JF#p>R;P6o4 z_jMK9%wPOb-A+!lQ3NIeoM`^G4+eb#c3$KV2raQ0I(luT$ef|*eWw)qJzvr|nT;?f zz3%b5ZRMJLz4|0}<8VDBGJ5M}7k{ZFI2q(EIF<*vwsqpYJiqf}l2>Cl(8)Y&nfx)f zw`FLOy&AGKGWjF#$#&kI;F;y5yOd6}LWV7hx{?F8G-$g1BAS2{d$Pg(jiD#Sk%IoL zAIp+r87IFgH_?NWfs1bT6)gGtsSU(xo4 z6RuyL_*vrMWIN%!-4iD-g1=%K96HeZ6xp8f|Ik*u6YZ9DH$zM$x(j2sfSl};+(~!i z!V)7>2|Ln5^Y-DET`s|OcngX@LzrX=Qlwl^RA*LEjMl5XE`D;mA1B^1Gvx1joP2|$ z*^X!WNL@_#l#`d!Ft2Tl^oC)7i>Or%rz2XS|0^3KUzG>-cxV)yd+AQS=)`#P2Qt6a zHqFVm37p)E(^w!g{&P z&6f7>+M{fW%we%TB#_wXtwslu-Kl>dqrsU<1~c>|GMJ`2aY;MhzFcNFwK7@GO>$;g zP0i}nt23Ept7>X>k*m@zv5dOx?4Q=2e~wb$!1FI2OS=a1orQgQeWlb{h*X!_EAyMK z0vy$`XuHih7*}c?;9g&@Q>yXPtg1FFE#N-i0^xT>iBjW$IjvHuU*kMQy z>45#_6kYHq@*7i`D!_&4wgBXxkbnME4GZ+DxhhJR_%<4t9r8OdzRQsRiDLK`U8{*8 zT#WMx!2Ha>C2=isbafOuJSe5w5I=32lYnSe)jYNIS_1kA3D*a>FB#Z`z-6;xy_}2m ze*w(&Dy8P*OgnhwN_~;68`^^Y{1!q)5904w*|nl4f%aIdGNV)v3k20>7N74 zZw%Z-dOjU+GuRk$td!s4dhS7f9r7PEuoK}!SE2qKFh9jvK1<;lv&9#*dsf3V=4w*a{30JD(>i^IdG>urZlRqF4dw>KIXo5ud? zJZwVf8160f_Ux)_*|cF}W5!L{($cuOp|xpyhG@@Ky02T*SayQ6qUQW^{E(GPabEA`#HPwvRaa-$#HOia z)zRa}kM{#2QP|xxG#v>k6uA}&$2Bpm}x9NkAO&nNp;s+_X&NG@tww!CI# zC}r8&wKXAreg@#vaDEr(TYY}gh95i=A}`OoypS+?(S(_O2-$BIRxul6_F9P^IEkcO$7hhYd*A_7rl3DM(oe6iIA)#w7vv5p_Y^F#gC)ErzNrSJY&(`0Fkd1Dc3#Quf&QT!B#Kv2`cfgm z%wc8@VVixfFcX(|BD2!H$s%i{lp~4JY-;Uf0O+@Z4S&MvEze0V~#M0{D5UZ86BPNzs#}QjDX>l}i z#?tCM#LknnWhRzZA4TkDN&C2orPa?7d$*+hyNRXMF~r6sjXfA+X>|@_qms7N#M0`+ zUfKg*+S7gxgn(rsj;TiNUa)9taxgC-B|0C0My8#Iis!5 zA80zn3&~&c6v7d93N>k!yjZ zWV{A2V_OrW?Z?KGV@*e)o{<}lslwc`)?-p z+IndG@v-)UqwS~`(cm4ex_U(&uF#c=Bkn?+)#?I-94f07XB|3i7h-G#NvYX4NNfP1 zj@^RT8cF*w!qqsd#UwXL>?a6U;Y_OEAiPY{7Qx{25?hIw#=y zV^l>-Od4*9`a^-IF_x-dAw;hVT4kyNVY!-zutF_BI7KZ+I8`l0SS4kZx(M;O+J-Qp zdJra60b!ZC31Ldzg0NhgxKf`&JfZH&B3Vxr)8W{(zwy>n(}e*_=K3_4eetmKxD4Kfg=NGVy#e% zOicO}k8Fx$7b0tNvR4-;%Lg_Sk|kD6ma#N?ffw4OmAvWc$4Ku*2G*9HB;1gy^Kn*V zEL3VePL6*{t(CO72(@Lr4zW9MCPg%zJH#;|hsjD^rlU~E@5ST{6SG2p21%LC?JX@C z0%XkV&q@g-hPJ-`LI$1;`a3gtdZl6dFkq@o={<8}pfSY5HXkyDvwHP!mrFsRlPx@WM3A%=Yf`4KSy z{mX8g;Z8gcJ1Zi`45L)iEz9M)dpoWkveI0FG%XEdzBEn84&ZtMs|=VVv0{xWBm;S; z4D6B|Bb?>PaHAKGaBR6FZp|HIuZ+9?ESRdjCpc%mWH`tQzd3k$2dL+Qvp<~abewsx~GrM<_Lk`WmxRSE^eQjw;XiZNfRlW*RvGPike3RQ~Ryl?f{ zeZ9z8S9dZ^+cTKSnl>jyS`x<6vgC4_Dh0)xaP1!6-Qf{HRk7brqprO;K=CTU43?Ou z%ByG$$5u`A!3>l@x%0k{NkCHP1JFubN@rGnVMP7o>bDK||dDfAJ+QRUwiBcIrA zl5{`tZ<48t6dl)v8n<5#*|L4H0ivroq{+gIyjEJ6FP|} z_(Di3muqQj*w(c92(L?cz0JRl=6FbQ~|gIgv~1b@l9a`( zAAsG`zPV9fmk}4rZrai)`RbW{4#T{6Fkh+*1!aWDq#9s{eT!Y*4K^_W*58A6QV~H&7gEiK%=z@5y-TQDc zb*jN>;fm9asn;1e;t;#XwbiH1^K4J(mQ4!$yJfmH~ML*tJQ!d zZ)@;t@sgit*_c}E;0@}}$6KtNZHLACdb2Pn?YX4t0^!5wW80Y3mBqud?AM}t zEm0R6JhtA7!^KpK2dBpj+7R(=M!IizF=g$>;u|(_y!Ub8+6=yZiTI52YV@_ZPF9zw zsra2L+dyQb%)ztTkreW)kd6_5EIqRyjK}W{Z5;YHb({-NS zej=F~-vZ>#3*-riU1b*BrvYYm5g2*{BTvjPhQr*s3yut6W@sEDsqq9Rc?*$e_>(;B z_J$%fe|)@JDvlEM^;x)1(7mFO?QC365uX9p%btc?g7k7?lRTZa6ls-Av+n5(j`NXT zfwcrHG-X4~v0<065PdO$~NM9C15J0K8%A(lh=g2TI7{_^{07QPk7h2qr+boc}eXH zQ}j+58p)N#Ph4aP^`Def00=QCf8^?N#W7`AeH_kB)KI*#- zaOK{HXI>cRl{FP%N+f2LRmpo_eLo&!X!TjG_ zq2L_njVR0cf084&YLj{9o0tY%UcSU*0&C|HmjlL~M_hqxJH8O-PMn-SUx{BH(L8^= zxATY`U^$Pt3cmsmzIB3{bsM5ic%=OWCTWMeke(nS zX@hZDnq=SBge108t`72=Yk|Dxf_Q?2G<>WF*WtEBS|`)C>@r@sZCP8Q{Y`;oT?2eP zdhv_;z&tz$PeSp{Z>}f28;MUaKlMXN)_)xzBV{LK}>8?!<;o8VM?UUsQ$9bHK<820q zJC9=@5XD)dZZxpg=8MC{yscMOzt*mA3DFMdC?uP;>v=J4*Ka}D((0JlG5SIJ_d_41 zuTy%&k@>)W!b$CGo3=}cNo~_IPF)WekW*!5BMHZZw<3-GTpZ&quUU@sf>PONp>c8d z1O8P~?|BehZ%2a637qleW~6aW;EpdNNDH?C(m0tma4X<=gxf$GR$^_Ic8;Yw^$r93 zPW)m#5KYLw0F>wY2_CB)sWW3tfk;)Xlj8&H68%LF-KpB^l!^^7ew*M*aO2|pt)u=HQ?B#GV`mAZ8@SuVxMmZNaf2x>=lGc|n>D1nHIj11 zW87TI4W-pDf9;(bh9ULOBaV@{Bt|Q}9H-uV%JikXy7?mq@#M*r%ntcW%LGiXhT+h$`|kX zl7_<;JZ!kral#}ag}?E#94YZwo6c6Z{#XA~I=X24Ma!10SS>a!Fp~UE1IHO^iPA93 zBu&HU?S34ebze_Tl)6Vk2EwzmjhSPxrcS##bMCMIgHVup2eu8a&~bs$DXWP=kKAlO z*m5nQ4xkOwDueBd54?G7mC)8Z+ca_Hy?TE`%%tE~sa6Kw;aa9VSBRa9JZ{K+{`8Rt zlvt*1l{X^ig!LY1m7gR5ym5DWd^rT}4l9Ws%U>bAqJ0z9Z$zh@&Zf$?-mzN4jB2Bn;~1CvI*Q&P)C zMWhEna|R5by^-r%?*9;&u+USD7*j=Ke-t(eS3*P`7FrGYXSQ zf${W1T+vceC?LfwB*kOf5L&*fwG^hGzZW?tZ0~`7{(3N@dmG9{KAUm&qEU?ES1I|> zgv1yC#_QRFeH7adkM~GuEkVX5r1(ACJ3&wSIx4~GQ=}Mz_aI%vkRM`u1n0frhtG@A z8)Fmq@?}a<6Dge7KE#xjdds#+L65y0s;5@{9((yJEt^iU{d16?D^Y^SMW6$%O1_fu5VPg@nt{>v#iSoO zDLpYh=eG7E1(e%A&qh)_wg4e(PahWgu)#wZ-x3HzNwv*$iz1JQCA2zZL4gU_e6*Al z3fMenhVj_N2rU<2}?QS@~MD}$KHg{axp)mvC{;m_*ihIDR!D@!>xct2@Wm}IqeVWhCB9|3U>3T|EiPos~()bIJrYBTO(-;rJ6 zCL(U%kzKyJcA5W<>{Rt;ydyid2{)xNZOZNf22;+$*=SpW2En))eMfc>lbve-_Y-tW zJUA}NJF>fmh9toRmHxQlCEvt%Mx9$dW_%3%{2O}ryV*D5Na4&9F7(drsi6B)!2D(j z-l@gV|5mj+mMQYi?dd3AwH5)6T$iMpp_&8bqxPke?B>2eRlgKYyhX@XjztB5{1Gvwa zZ(uZ}u3z^J!V|nxxKv(ZgGm)#T5FV7(A^i#FUB}m3Nv^$UMpN1+CR7lGH~YBg_F;C z^%0xtJteNIvrk*O>ya6Y^#uugc6LRjU)GCHRdA%e*A;nJ?L09a4G&*ktpk8J*#?TjeN1 zwi{Svo+hjSucrV*c!5uErsc+{k|AN2*o0kqu`~Q;2>Lgv0nXdFi$NbTw+6Vc!AkWC z=z29TbT0@AT#nY12C)+S@`<~lJKGW1eg1xm|2}HvHSjGdF6i-MMue|`1rGCF*GizK zcFeo3RoIT`Px#`6p@I2G;R8o~OyxTtz4)RPzBky>c};ZyysQtOTLD?_?zQs8QSrs9 z^aPVka^WJLe~~ zbIwLeWuT(c=rBOr2lF{w;Zp|pPa0XwONtWcC8 zfh|rlV+l7`cjCaUiuwpNS7-BLq$b!Vt(nE~eA`yO=uNyZToURZT!P#mY6za;^bbXL zgPO`B{f8lGK$E2JYm&;KZaJn6lWPu<9|t|Q%74arnos`piOB2C zw%kZdz0sgNy-mOaO^j8iC(Tp{txPupTlZp4?u=Lx=+=TfhpYP|m^_f@58&6~`2^L? zg(G~Gm?Q(ebP=|vV`g`yr;G&dv9Lo+w`S3%v&j$qO zKnBp$gaA_34Was32}qg;7v$!7EX5W~R6qPu6h%B)>)^H#y=jHi8$#5V8|q8&dx}qe zeuTPgJCR-55#qcPVsj#;GPb$CJobP&ot12vA@y+6$QtUr5zqM4qfLWY@m{uks`;eo z7t{1Nja7ByccD)$s%fF7w|q~5p@2Digf2tQVpi5-*yGKO9Q2*DvKDW8gi=;UQm|V; z1hYDlf_X^@rZ$qYmZ}NNAc|GZB(^UdqHGIxO}ZK4G-{dH``IZ0dv2l>f!E83f;cDiZX+eOhrHWxpXkKi zZ8%Q3@5kK_{Bv|#lK zuZg8q5|8=#ytP85O)Ra>Mr?R!a2l(Y|;SXv!H>}g5+rHO$C zjQm+i+ht;D^%KOtD``J9v9wx;@$d(dR&QeP1ccc0lJRkb+1VzRR(B(IhNQjU#L{ZoG^{B|+DsEms~ZqoA!#?8 zSXzA&u?9(d#Kh9-F~qWx_N0lW)zgU8OWFYwORMiA#;5cZ>IWv4R{x6F1(G&yVrlhX zh^?2j|1q(&^nvRnZ5mn~V`+I?vrf`D>N=ZkA44Wol%EG=)g)k+%Iix^8Q?mS*C zX*Zb|WJ65L`-q95Eg-f@;0~EsTCJR})XP%8wI-HU7a;~^Lbgjx4CZix<1XOs>D$-Q z+ta1=i^OQ#@&d6^=EY%!7lxI*C=6Wkf-ryO#bER+i*cT`Z@O z?{)eTzG3hpIiKY0?HQ7ZyH4>j(X9YgY_ag|5}R9>IqQthvtUP9J36nw`#gOM^9Hrv z0G}t=-@xLs4?w$-;N$D0Jou@W81GwVN(_~c9XiZq4yqV2JS$R6Ps;mNFjd3?p26VQ zYCF7H(SO#_#@dgP&!flNNU&_h zQ!hS9X<84Bd>LN54$=SChGXzpHgdy3Rp`o7|lKHdhJhY_Ks4r}d}jQ@1x zhL`Ehi+;RbMmkgmZ(i*O;o8hr1F8Uy%HWbMOlSPwksFSxVd(H>czZ)lw7-mEwnnQx zuVP0b9sQAM?@g6ssgW0BW9^lrX;T}OE4~g7ant_j%Uhv-jv??CR7svwW9?O=)i+Z) zmA>)7SI8K0Qe%nRg{{i5=_6l>A$7D$BW$f)@!gx(vICj+VfbikJ*shv-=VLh45CZH zGRlDPFg5uipvPK)YF+!$LRv^r6^jmFP*#e#pnZ5?+oQe98A2K}y|E3SD@lQLW75M= zVC4a#Q6O}a5VDprXY4R+j8>3>+mm&N3%h*1vy!v^C5`Ab=h8SNAzD{NW9*>)Vi#@} zodQhSDoJcG$DnM@{yUzUcIz0ic+G&6>;0zi$|ysNqp|T?9~+C$aIk5B*-?GbCg29} z*m%z8nyg&lU%oO{ATjLUGi2ERu@|@e=J@d|X;H=ys$d9giO3UIG&F{LMW@GT)C>GZ zhvM+FmtyllW#KAC^DkU2ZVo$q!;jP{T_0ZP=ToHf{91?O8?Viv#ls#B(;m=5Yv1vd zxJ^vIxF6N_7z{@V=i&wtE*5FRBR5p4;k4wv_-O!$46~Uk9mF3ZNoU?onVP5q$mDt2 z;WdpN1S>_RN^vc?OAuV{t4?IHV6;=p)Zph+ro}!Y%4E9_I`*-KX2f}0KpayMm2O3# zL9rrcN@HOUI1X=z8VhT|vsCiWT9|h0KZ)?i5aVps0;73(vXbqYHUs>Uz-L4&M@O)n zcH?TXNc2Te-n93#GkWijB2ajiTQ=I<^6BuqwxP+|0oR2J1;zxWb7$ z&1-m`&jb}k-L02e8DBNlR0aK1deCjYY?Wir2z}2Aeht(0t-$FKrP52rTTT5=^~ve_ zwN=5^gD&5_{ ziT*eVcTmI0kj}ALI;t6a#Cr7%f(}sW==24#a6LYIen+9j15HPnV;zki9r8LIR&7S4*-wN@6)l+)||c6wkVhpI6tHPfM%BT)!&Y7F*#c59jV^R$_1lL8t`kXWEyhzvH{Zd^!C zx@qrvpWr^c;=8xsMNJ)F^nU(;4Op6H>M<H{ z9P7zy{LO)~y!#w)4iv-+t{Pu8^33t^8V2ZrsR*fl2@WEk-YMn6Ut-t^VBKJuf5Ib{ zI^j{0ilgmg5zeIe z+OYRm_ipH`7FEKm-{9!myZ-QjsJ!XXc`T$FWOPH>O*Xw#NOq_?nmqzq$Sm75Yu}30b=hK zxPSKGj(BOWgDL6U<%snN+!qo1s9<>xF^%Ovu*m;SNsD3KR;Mk+LcK1#2C?U*Y&~L{ zzh*COD`G#B+*=Xj!hf~853zBHJ&4%P5lgDiBc?G=t+c$%L+p8hdp%+rOFd$`Y#U;~ zl(OxJamg&HE<^0~Qlbm7Ur6jdh;c!`T73jDF85cfPa(#K3)SlTh$Rq%(-QMopjw@Z z7#~Met0jnW(YspJduf}!v>al598s|+zhO`>a<0OX}V2_aml_~U4qyw z!P15pAE97@7BSv)SF0<$wD%yU%YGX%J_e~)e0;D`V%#*R)3zhFLDJ~xMaSOjp9g?a8F+QwFs&2$I_kCX4I}xju z+}jc3BafuI6EQx1fnR^b_%J1@?nR7`Uy}0mCq8sZst+TL4^EQm0mS%NC8<7v*eZz~ zM+~Y)S|!%LTO@5JVwXsak2>{U5;%24tVGF+O!B!F*Y`hWlmgdU(}Sf>6AVM=`#VOo6=VTF1c;S}|E2&b!` zAe^aQLI}rL=tXC%MF{7q6$lros}P>5`VgL`h7c}PHzPbca@nR*xV&SN#y- z67_S0OH~DW)brIMgf;4Hgez4o!qtk8Y}cqEglp9Z!a8*u!gcbH7dwFvkExF!OsIzu zCe@D-rqnTn_$mVWW<1hFSfMUJSgAH3oFe@-9Ec$vSDgqG^5{3I9z{H*zKyV4{Ubs+ zi9v5%p(+tps_6))NIwi|5QjTbgbB3@VG?%=EOjr!3iT0$Q`8p_PE}7MoTk2yaEAIf zgw<*$dhS{34G3qejR@zcW`uL)(KB3gAzq@cLYPqRLRhLkj4-JlL0Be_qVWJ3@e=ht zgbDR)gr%xHMVLQ^1p*)9aaE5np*U?Ul?T)K6p*Cvll1E({qq7pf_RC#N7A2>^k)$! z<#BVF`Z?k$brfN_D#J(v*Et9)N$id^&N!e>TeLH<*_&3QbIhY{uN<~`geqIwv5rOR8=4>Q*#ie z)Ix;i>U@N0wG3f}T7j@q9+IPvLmY0t5SFMBgmHBj!i2g9VW~VcSL%MmW9rkA`%}q< zmp$apMu_ihh<;8-Jf_Y;SfbV;jH?!e3AGbpslK;WU6Ou{qz@uYs%sIJt1*O?>TZNn z)dL8psmBpksqZ12p$;LOsg5D6R=+_wN6o-^H&4EZIA5KE_^IkVgr~_k0ozABrZyog zRa+3EcSTsHb|WlT_-YmOfW7(914nX9GZ8OU_aIEF2N9O3&mc^xClHpaFCv74A@m{G zYJhl5y@0Sp#zKtFlJaYWa1V_UvQ*7PSf&;tOsQ1}%hg7NY4t{g6{;IyrRqaCRo#Ga zntBhyD)kYB)73{2&QO1faHe`1VYPhGah7@x@l#}!R_Y%RFH!%DFroepA-)NN5Uz~S zji=RV2rJYQgq5lR;S|+|aH{G?I89xTuu9#AaJu>s!kOw}gw^Uvgr}&lBAg@NXPm2k zh4?&m9N~PGz=(OOszmrYH5Xwz7SxRSvX^)b4EYGheM>A zDq{hv{C3pSHxparZ8yqKWuTqGM;8J)V$*!0;$D72s>G_PG8Ukkm5=|tTM$krt3%e2 zm0s*8q)MckDr4wG5El3S{Fr8J#f0PBNi#8U{^K1|KjGu1o>@`3C+PzAj5t zjiYDk&(FiCWb)W0rq|u!R`BNkJ9yVTVJTy8;+q_zo};ZjFO*d z*`S~Mpl$egi{-yaXfJ)qky8fjvLz+FZfp>gf3i+@8?R-dI?%*%xL)yyI1$m13v*vdM ztn3^QDSJj>PwaoX)0DM7|JI@GBtHM-9t+_ z4i=9UbKJy56U+~ByDu;Sk8#Y2$LPihE3N8-5B=gE{FtK&zZskYBWbrts8fu;-sQ{H zP7g*r_`XuBIh;maUO*pSUTjv21Vo(J-sz;jo5rolapD z9dgm_6kSa{_}Q<1842e2xcM!GbS1I*xY~o0ZmBYo<9ZV$o_vhStaBb`NN9cIVTBkA zYk={5;}Mr%s!5>T;A^V zq`pZo@?i%L%QM$~f;?v+q0jRcfp&uzaiL+zGqL>`=MwM?rQxs|3*xy-^0?r|!%|0; zgsAgN^FDRFj1xM_k*{G$o!A<1-UsS>p-;2{Z(wX2L2U#v-(c`&<=65<%0X>hfMq40 zpPNl7{o~pgo~ppcxU9%KtcKzHuuX(3Qnr`42=SBYCCIlvmO)Y;NkvJsh!Hy-pA?r7BJFjRT@z`F3l!iyp6FDD5o{U_+liD^g zqqR!8$R{oH3#h?u_{DNJy@Rh^t*%8pScAd3c!xkM`7pX~QIsiIgYN|6ehuDkO8Gzg zz>kI@KbIndFEjrT{Jhx%;^R<0b|fBBQ1U7CXYgx!QPbjrwB9R_N?jqpwk}S?RglB? zKun**zc!`(pE6L^FyxTfp1^tM3ccyWw}c>`?-~SM@@uK5aTTP#370A21A8w)1 zFr-dw&*6L))O!TTw)Y^O7Yu@44P(5AMybz%I(_O#Oez1T1=KYRsS}$#(nrJR3b(eF zxO^0?LCEL>s=M!YxKS$VB7oq zk$*Dn!f)@lKvEtlMM=pgXC-u0cr%kdxfmyP-QG9w632*ywwB4ZzS)mAg&OHnB>)C;BXzktDOZVcm5DN@{t7~$xY z@jfO8q#zzGMWf_l<|MyvT?mXP1#v}7>B6oQQ;-y_3w#p>Y1YPA;$&>h?|Z)uxwM6| zcE~5&^Hpd~e81e6E7%IS1&GH35?Z;UJ?&=$ZD)ZgC50sTC8%o{QYW^{ao!5*e=Paz z`IoP)k?&y#+j0;yXBIp@DWT4Qo3j@^8k5I1xbqz!6#762*fV$oiVW|i4aGMp6KbO$T9;J>? zraQ88dsFb(4C)$&)QRnGoZkg?ZaMcYA&6(a!Sf{zGhwej72Sxh`HLdd_kp^GA$4M7 z8=JaH`ylYC2k~5H@cdPPdeja-6ri4qP=61oYZy`|w)HsaPyShr*^K5vJe>xQ9-pn| zK`K=5e;=UEO;y3;VNlmFq)u!dICq1(94CcQP^p+p?d_g;0 ziw@JTiyI>Rd>8y^81h4GSK@pK{O~O~zb=A!-fi&wNW&OQh}Oj)1gPH~q5cx6YZy`| zwp($23)G+2m`z;-@!V_h{F8>6kotV6!=3c1+8Tn1}0x)FGM)(1X&G34vB3O&bNWX{}#+e{MJXj)YHOO*3>A@ z$+Q%V75G?V+-+oeSqg*M0n=BSi_KKVk6HFgJ-?*$WjmD`A>tVRDLaW z3~?dqPY0;SFvbOs=RjSk(XQsh3H$Z(RN(QNaACnf}ez*xVcx*wYh9Pxg zqeHdJF!XWTHNHH0u zJwzr4sCz9X$n$xIXFbcX^?oW!1to>2Ge=TxYYiU11h|Hwq{N27Ri$e6R&&2!4dU5p z@SG*uu+&L8Nc~R&)Gv=vUx%((!;m_$;f7Y73F=EUX49_*@myu_EDcbP_UbMA$4NQg8IdvuIDe-#)5cy44%dSb=F=`cDkaI6oG>m$k6d8psry^o!GvKa~G&{ zTRU1DoS$KuDO=8nhw{M+rstY z^iTVvgU2|RZ6(M9Gr){v)Sxrs-BMLU6Aeg zA_+=Ma2fK&)4L0>NeCDqd^W?78qB|CxMwhcYAYa{!70hmZ+i%fL18fwYH}qTt{}Z3 zy2$muzG&I(lVFev)8&X|h`G_~tv!H{er-d{MU~`fP2ADy9#v!U{nJi}#FPPTUq#aE8^^LIDi|uI9mIwT!Prc7 z_#8%5C`3=TxTh>ww(l=BL>9e1?dSXzYcuX~!ml3HtX{cF3S5;I2cf>x4+aw-~aLQMYLSHG`hw0#SOa|Unjn8Dv;`|OS!})@N`HlR>ihlKI z8{iTEzLW)Ua9&gFt4B+bz6UV(IdGXO%E7PqEZWYpJl=})VZfX`A`f)Yy{0Hb1zbV<^A0f7hN@^ZQNM_k(*C|5${YB|p5+ z|0^#iHm|YeB9Dir6& zU-0S74$-MVyK4jwZp`AZ7&*)x6&VU}Eq zOZsp}<8};A6^A++`4(kFDfVL})OmdG(ACA1MEn$p9nS$@ppcT#@w9O&KCuzuBNQq& zFw+tZY(zWohhtq{5=L)$3nWD21GUZJ|ihb&UDo9+osimnB zC1edY*VcOBX3-Y<)3SXX@@d`&fI5w{LVd!-(u(`tI4P}=54JLvR`(-~Jq^BeU}9;N z!pw57q*a<&TJ<4DyR1-yCYF|cXm6FYA0dsgv^o>B;aeo_91}~cVZ=ry?K%@nE4mxH zOVa4}g0ZyXGsi!Wv}O}as|OK#K+^u$#NdG+v4mR5Hm_N>6Y&&1N|1;oB1X$MU#tu8?~@&&iiK>Vt2{W1}0Y05bwx8lJM-lsG8A?MDx6kQ+H7 z%d!I_wgU|{UM>e3`T#qSt(6#a*L%5*CKuke#EBZvWlYk6>>`P=z+%)myni8grI(wv zxi_;;d~!q4R_$C_t|VqpzNCVn>+Kibx4 zFRA*`wr0=0p|78@=^`n;OHu)pRL7wKNUGz|05Iz~xCL4r*WBtjxCMtg4sIc-jza^G zRL7wKNUGz|fOrZeU9CNx4(Xsh9fu~NJspRn(1wmfQfNTOv!VeVZyddgg4?X-(Yq*k zSn2~=K4TLH1Fq3EqI(J@qD9iv-iE3>T2jXmTYGW!&@5tauD-oJbsL;aGWxX!c-o^w zK3vZf)*}PdBIc^uBE%w!e+^?UDtGM|4KHft*meD z?GL`1Yo~n){t6i(4ft^1z-+|fzxy3uhcDkR>oOxhho8-(RF$Au*M4mO>j-#|fT(Zn z)KD5~RyvLGG$7G|m=+HLUxP-Zu*EeeD2)hx8{4vYusk+;yTl>GaJlifO9!-1>Fstq*(vSs&-&fhy&;s24iX-i#ZYvVp`a9x zk%agB0FOK-J(hK`3Ga+>hKbJ=z${-TB1Egj>E+8~!sW}T{5Gfn48J@kZW0N27mrfF;-HF}E}EQGR0vbnoB$v;H-x061p$plVdK2aRyT@Z?)i2BhuOsas;ea94T3WNi`c|;U7wD0b(4* zl4>Dh9}u|Jh_42U zzKr-Z^$mno>iY<%iwnLPvZG|CINYmNFZgMi!T+ z^9i*bDW&QPgm7quuuNu3Smi-Hrfx)7qHaSNSMNobkU5jyMG{jFN$wXU_bZb7Erg}& zhX|AEUl5k5mk_4ZZxEKNG`gs?It5{cIvru9T8eOrszW$c9F|Q}+Yql(S0bFQ_8^=g z4kTx)+Yqmo*_l%BM?9wPM_8gBMi^Ig-kDHeMOdo1>lRMI5SFQf2vh21gt#fg91LH$ zLRg{ZAgmM@W>XY*hE7%M5l&Oh2&)twOHLQ3W;0Yj;xpBa2&=^w&~OlssrMr+ky)Tp z_e%=DNL3P(MSMRR4~!O#KhSl+-o2fX%{l1H!mE7hyszLs+W% z5SGbzDa+N{5wB2xgs@U^hB!ri65&+!S%g*UNrcnYHxSN{nI#tO5s#_=Kv=34!#3eA z57q)tG>FI4MF`{SVuT5qS7K*|q~{Tqr~%2nR&uXLSSmA4EX*SwQx766QGbRou6}|r zp`J%rD(w$Dn-Gtw7}`LoN+C=dcVM#-M=L;x_nZ;N)pCRhv;VVRa+@WWvr+IPDIJos z7hzltAWSGeGr(7Xy1VoEaL$l?@JHc3q6eGuGFW%$A4J(RhBAG5d|0Qqr!Sv5qbsvm z3hnP0!WVXi&N^F~<>r2TcL(c!8Qk$;;crQ%d$>>5ES6;Y2bqZ58Uorc^%S`Hfa}fe zEiL-1K6w0+>+b38#pm!^F3QMq0YC4f8$BRj(ZMOb{-Dp(5=$X`R$`S1ACg!VLaw3f z5BliX99*+v^#^@;Q;}2|gbO9M2qC-Bq*{!S9b{5oMx%=5!#}obZeDB#zl#^6+kTp* z`N~~zIe8w^a6cg3u(LoLS{lPmKJ^}1IpOj`2BnExI}u{ccU@#%s$+D2J_ZND_?*Kr z?_Pov6B!UHP-Z#KYB-}%>O6_Hh4|$27xGD&ze%OZ5j)4d`stYK$x%?i>2G3MSWxpzogtMHu~h|zWsK=1@C zUYe#Nst2_UVp}3kzDb#hEY^9c;I$|?td_Th#M;Sc!V*x z%fWQyAcfT$n?X$0g$d#LE)v^f0>3;iR`D6}1jaNKT&81Mu_ZdDPp~|9DVWrRfG1EGw$#E4oZ0sxm$=z%nV*Dv_3A8rrr^n}RfUaD;2Y za78$NrV;-FXVds(6XZ2MOg#u!jWmwCg3qMQM%n_Tm2*d*td+iWg#6NlR0ipZzQKIA zxOvesEJ9iwNmi!CxGu%l5A)r+9BC|Jn#?O+I#O0$q81>nNGk@Nc#Pl0F7F?}qgRYy z7Z680#`;*0%i&#xj^5n9?n1||-h7VZTduRWe`t6xulb2(0LP;;m)n=`Y|QsI0!I1< zzdvA~g8KHplzckMB#Lo^a+CExft7EeQBt)CxY&MS6B4&=<4mNx_IMVqZQEd(GjP)7 z*<$?ii01k2-@5c-TXEZ%kEcYP>)}bxVE=PAuK9b8`CWov+Bf;K{SEDxIF{mc`$O`= zcIe~x+aYl<-L{cs0l1Jn(2I}5cklKR`dh`f=};D%dykaDKFCW#mBEHO`wBVQOkACZ z{34GfU>{{#F0nx!_wBDtToL&;TPE(#g0>xxEeGzP&6UNdE7LXuRZV+j-pSbG3c&F= zkv-zcpIT{PSK&8ROj6j`@}lG6Bu`|FU9JI6YnO~$yIhO7YnOGnwzfyOTAZ}Yb@=5G z&GYRtnisXh^}s_ryukdv0l%~%@?q_ec1_w@oMAg;S(h(6t0!%a87EsVJieW5IXiZd z9@~V^OR!Ba-L{G509;6yXcImTzfJ7HSP^a$)Jp;%#O8ipwh_vU*Q@d9s86mrZsHZ+ z9Pbd>Ug`lqiDgK;VLi;(Vo@Z}t<@_knqcC&vkQx{sC0#l|g!ga8X&QzO_Rs)%X?KB>v3@6hTF9sZsa9f-T z3!Gx+ifyKi;jyl|#K5=Uw`wv?qRg2^+hydTtISb11D|b+jN7)@hPc}nx8mBiDZ*{R z$+ox+zdWLO(YEN9i?+q>z{B>m!~C}6mu-=JxNVU*-iWhUTlDcq=ba~8ZYpr|pggqU zlPwo+i#{*Gw#anb7ITREa3Nh9+E&kY-gcR3iyXV`_{6rzw&%7*wmr8kRyl3)Qou*7 z0d_;%r~aqAZP1%@m8qS`bKBmVck%S^s)Yi~CB_WE*L-n2c!huhv2rpyl0_O2vM zXzq6v(rO@mxb2bmlWBV$fa7tZw#RnFwztc`(_L0|RC7m8FWTNJWFoEigy{RJJj$m* zce3{BYzL6`c{R(x7VyOuw2yYU-!G}^F?ejhPZ-|7x^2SV2XrHyaQyY*VyYL{JfeAi zyXCx*Wo)0&kGR_>4B(pO*=}9jZ*g!3^L*U)9%m4+yvG^BFJ&Vh+dhU7FNXIP%+Yx7 zvIqIRZ@31(JW{+j;c}wb@=RHffa+AaxAvg#0r~*X`xe@stsmY86p$X-lp(m{v3#_{Bv)}M=Eq)VGEV%dPUBgYF>K;KCuh#>D_HifVE5(>8_qxAFF8SVOWTXTc zyNw3=DQ^FP-7#XzH&Q-SNOAiQ?fn5>+8@hU`@0!&*Zyw7wY5LOy&WgVq!Ik`ux;S2 z6TrR0z=XpZ@LUUg9R?>%KZB^Q43-@5V-^ zu3WyqyA+=yB7f+=W!ao|_%2)rv?n%Lrfwr#A38?vX3};kyjs|8+`_BVW48k~Y_Irw zhtyRH_Bw`q9`7ctAT_Bg@@)GZmZQw?VH(O%=hO{h?!+1DcdD3f>+HRVyLEOCu5F$9 z*7Adi{agD`i#4f&pzXB{PJ-1N!|Ye(nFSr zaWNkI0Md);leSz6eSXm3`$POD!Wd8|6Wcr%YVA%hz)_w*0uJh)_RqN0Ab$LIo zt-c8NVVt!8kK&g{u{=9Zu{QqzU}^IY;+OEOS09(Jd&`&A^CtlB!}&DXH}hVBbzp6N z2I9C^5c{UR^E#zs1Jw7&5D)EllX=L;2@|q)^60~gwM*UnG14ch8`}DxAfLx4@muL& zkll6A`NaK~w~Zut1Cqq1bdIGpF`EXUFW82VEh`Vj*%M+CUiYb2z*66{iA|0*+Q6`>I-tdUr zl(B8=X*(O=Ww#jEh_^k}WYe3)rz5NFhy1jCq z#rDc|(?<~J8g99_-(0VQQ3rlIw)gxM&YLM3j{2!oQvxrhaE*XNJH5`+G6K^h~<{3 zlFr>|`*!W3MkRr|e;?P9ZQ4qe;>!-*!@a#8U$v@?y%P5L`f%%ktJf))RplMSg?_w{ z+TUk!H6pDGBmN*>Ph#4iLYK`d!M8pIH|_l{=#0}>`vBaQeV>}@?*zXPk4OzI+S7e1 zIUu{;k;ePCN0Ans2hW%1nn+e<<_%1YXOfl}!pkO7&Rp|t5p(?+6iDpt@3Pllz;*eM zebLN|N4vd%PzzJSs$Q~VI#FmbIxr^6d1YYv%-?PN!g{rAYld(xZ!;Av+vW8l$U7zQ$Xe%7hw?ncJo_LIgs+sAx>3JDCV0!_{fgjy zQ<=Q{;NCN_uD*`)e4di_Efn?~mp<}CssdVW8XS~u`%?e0ZvfsMtAQi-O{9_M@cp>^ z+>~SVdW_|N4OkxE!teb-jU2fJYa^u1ehOMK^9{{QLWTP&ot}#HQ#!p;rPzjZeZzY_ zd8z_!Si@DT(%%05YdWpWb5uF|j2t@+o3_AO7j$dWaQ~z&$4OhHtyy5$FD~}1RF`Ag z61*O$yGlQ;MwJ;W^YO3rUL*9=Y6E?ozQ0@_=+CrF=)XF9JBEfRyydsCXde_;?1P$} zK8W)XZc6yJsVCM%i}L3qt_$-7U^s?-SAO+;>3YODU&0~o&e>P2dLNFy0E|R7dwChv6XV#d)4gOw_IMX8<-XfZn(^3!CjULN_L3|P zI;>f}YL&zVMq-@h=tJ;0?=E8p8t~L0BnSGieB5HL3FABBVIpTh+NI8VUgCJYgx1Xs znGqPzsVFt#m(qJZqzD36&)h&0k8$@D=XZZz82?YL7i$|$NIyB-*ey7$OH_;oQaj|6 z*!k`{cl7vlOnIPqwWJ;qBM7fa}BOkg~X5m&U76beXD zfuwkBCqnYI@ax}vW+ErKv^Lhv;Ofu**p~u^BS)pyk7M)PQ-seCFw`Ijt?V<22nS(; zTIK$;c#JPdSy62J*gUlNA3}LCZ-}4MV(U#yk+C~shrzzd9VT^N9_76hK(<){2sb6hM`9Ft{ zuVF}?*nWlcRBX}IW2U7Z#M5gK?2}(BJ6H};r>i!f`c0;k|1%f)8iv$~jnw}T)Y0EqttH&X`lLirj-A)3Dh+VsS_J<%tc3ZivU^KgLwYPAkbV`*-1xe zd7A$~fci&FDgUPn)HMvL6C0_Y3+kf+WT^-7e9Ryi(=bN%DD_VVsDHwg@_*hA>KcaB ziLD*y1)zSH09oomJfAWM^wi4AE~6rHe4CFaT+M&hl=6T0?R5=9>csXfoL7VT9|(}8 z9>nvwL7;2EQkNbbIX?C81gL+*l=6R`0(A{T>cn;h&c6Wl2Lvek`IB5x_p)nhYGken za;STmv%#fcHLi4ul_JQ`b3#KYJvXsZ=n}3JOVOCcqR>L&&eW9hf1ZaF8irC3TL$O% zAjLxhM1I!Ptd!9{$WIXS4+I*{4di!Xel`dA`H3mz|NIa5(JN3?cCH2o^psry^o!HotdO-a<0$`~J@$hLAkMBunWv7%Psb?)M0qUiuloXQS zUjeRRNS)Xy`&&U>AC`I$Pbz@NQimagsPm3f_!0QZU@2LjS+s+6X0l|AUYUYNIV!Wh zzQ%pmfesv-=r$9H&XQC%yQx_`>DA{h3WCG6VOzt_O?2W`pKF>ZF9-jdgL!P9?FHEK z?3>^u(w15Cf7p8$_^PTae|+6Xa&KBDO4*iPS%X>DgZXl=32srKpgF}AfGG<1I0VLEh%4!`er?Y+_W%3;K0i)!_FZT1wbxqvz0W>-tsRbY+5CF7Dad8M`f!l5qByDyGeH~%?pCWn zmlP0C1C!TG&sSG4$)^3pYqGNo163$2xtYxa^@RwU3)crWfYcjHs+7XpbZ}zvD1@%> z<)xlxNEsGhD=dOkr0^()x0X9%6t#X~jQ<4}c~1nN3(H0DC@I=G`#MFJvxe*K5Ub`%MaCAk#HMXdk_a zq>HbGF`SHkwJNBrj;O76#j4bCXOu(R3pX!BD{8qA(+QaioMwwhQPt959zBkJYk;#hfLF|t-(Lc6 zGjP6Q@yK^13x_WPC&2{=T*OnpruSZ{o^bfyaw>4%5x`S=c@`b#0`J2X$HlFuMaRHs zK>wedDe|j4yg$-H-wf3O!>h$87W(G*Z}jZt{JCxPZ9uZPxW%>CAJ)LpD{@LuhBm3)QlDX0EHDG!4(c%&XyXJWh}P^5%q)M7#@;gO0LtKUuw zrR1}o-&3C7&pf|hcz&m%`<|_F&#+KR?(+NwJwG);$kh9MB>cPD8=$ulgnpD4z7OR|Xaw4&Aw z!v0Ca;eqXG*}Vd`Pli^&A`c9oB!|)uAkM(9qsMZWs85Y*xE~%|q6omOuX)#h?11T* z!?fbVm}#{TgGZP_I{FH`6!ne|&5y(2jDZK|$CX-qU`JeTJ(ng`;6pn!xBuc8Vhpw% zGT}qD1JA&A4Md3#)((#`h@SHIV8fxI#zU~CHL&Z*vHr6()CiH>AHM_L!ZD4Sb}~aE zW{|O*lD>Yh5nPf1YNR8(%Rv*FJ9kCJ?)2v6?aV!OY`LHa4k49uTaHxkyOXeH@xhXX5_&B27Q?xE<;5EH#IVJ z6vFR14{47z990uSke~+eP(O(8MqwTrs!z_XxIafSiQ%t&9+g~fGNuD60iKFGt*5&3 z4dcuJWi_nN5pMU^~wYJb5h;EIaFP_Js$7k+AsO)UMJQ4PpbQK#Egt#pTc*h zF}U3}=qZ4w;x0$ecs_o4ogydI{VzsdoK*LB<6fj@HuA%5#lHeDKYzF_|8wx{>J#xU z$9+=W-_Hj(b}^5*UEI&3u!=GLnXkk((}!Do7&VPpbQC^+QWMsqW9OX?xHf@59X%SgPaj!rc9&y8lUa z|C8$eXbUIR{e$Z5ejma22!75lrrz$}{ZFd*eTRvF*Y33oJ z`xEocH*q^)nYZ(g@1Dl=nQu}C=FvbfDKWgBnsBDILgM`9uK0Y$J1$Q1?aeVhpVJcS zZ0j=SC4NR8A#>ez5$-IYocZP@xW*Ed7B&AwlgBRskJr!fJ0YB6HATR3M@oQVAEVq0!6s$YETzMX_<>?f#8Kw%@u@l`W!WjPbdKsJG zCV1`-+PJT`#ZV6_=d)JEBHRGaP473K`I+Z@30UiS8DkS^KpSv#gS^=}#V{Yr=&lx= zxpNSJT1inQ~x+ zS8$sgL#zn%_I%u1P!r6KIae0pT)hA|yk@BD%7VEbE{nH1AI%!*edJvc_!}H@C$+=4 zcY!;%$D&4Z%@TdSKA3c^GY?_P+yThz8g-pKtf66f2Eb2!RG!6(9dt7AH#n4s)VOW^ z8<59b*(|KzwDsB!!sK&nuGNMTEf$$;pStg<{kj32>M3im;;6Fj?CBwjST(gTssOAyA79ibF`3nx+7AOUl=K@=r>B(>~Pp+^P$ie*7>8xVPHd|r+gRE63kLDFob0&Wv>g<56Tr*{wu&! z9WJLYQC|?OT4CONB`+N6cZ-_lQ7!G_%V!5wr839WmAZV^>`OHUb*1W5SL&=wF-5c` zQ%qNi2kV8dBDzxFK|eARcrmNTGX)Wf=}Mi7K4}Zu%-v~xj>LXcZ19%M2)a_{5MiHl zeNBCR(6SIiF2lXV(_l5Ys$&%BJn743u?KihT3j{=)s+g^L?IqGn^sID1U)VNjTF^^ zT7&Ql5k6>f*})dmsj7wldo0e!Mxplx;C%++mByfucGx4)JJaIK(BIfz5q|%1 z=)nwye8A#-VHA2>fwvFg7czrzjg(##tIPvV3+^m#92!_O|Jc>HA^dB&d5uJm-T6;} zQ_fAtxQJIwC+#-)p8=fr2Jnnd8jKunGMdMX--Gi1l*QpQuRnvXnX!+9MvVgvUvFKr zMR^;q4Hih?Zg0jJ37p1et4jt&DXVV|1vya9h@gA;@!kkJd0+x zoQ6m8$l)G?k9+-HTT~S-yRo}>YilQ!vKHsb_er2~cJNW$+kN>a`#P;oK4bY`O$+$~ zQbEfTFsOFb4SJJt<8r!LH-mg+CxzgBj&3A17<8S^I=izcd_f``iCmv2_47btu6_&m zHXqrXA`%dB&K#$QTacS1dvzXJ)@PE{{>Udgp)fOg+qQLdsfrrUtMhW8$`%m|AO=IA zWRkC|cdli^eebvXOvV*5+1lE>rKsEud2)Xhq*#diaNpsRJfo20I<53=8#IqdoBD8` z_)f!);zzpp zDJP!e(A?dV^eKyyVhM&tvwUdhM+Mc7Y%TMDAyNWqxV!qPo6-Wd#aVG9N z{n8B_r0ANcry$N;B+G)5<))fQ534D8^C{NdsYRF1m185@0;U7vtl=YW5w2)rM(w<4 zUA;W7uAXJ-o{rzg{M48Ov$R?^<$CAL!5LYO+{3`~v`^;bk?RB*W==cqclzYgez_?* zJ?4!BSvWLS?-5*(N01saOm}sd;AwdT1HB;_I8j5C^Lv+bEafxt`*vT{K<}cWdP`IV zL|yOl03yda+qHMeXAE}_EUjGsZ1!u=hM9fPN zP~qfc+g>F=5~tMjLFJ0B_QqKVfj*B*H5u4ZLcCGJ&8efIS6XU?&xI z!rp~M^QM8ukLM?U!aiC8Z1%?Q(C`Zo{?+-@p%Z&_fBh^KL)8YK!I866`c11+ z>mlZm7yr=A7w%m#{jL{s-KwiP0Xm>i2ZdViGjUZ2h7#@3xr;K}nkavYIaD(gJ=Qdh zq7iQ>I#hG4Idj*({tFlg-Q~kjwH<6xb=h3)W(acxQ5ugN8#CB&a5%BQ;UKvWzZ>kB zZ#kpcIsy6NDYsfRT-C*O$7h3G)1!RW3n`CZN*orG_p_c9PPqQ5|SJ));kK6q<)^ zbgPk2=vK2f4AoCMf8KxqQn}H%xye++l`C{9pfca<}T9gI&5kkd_m># zF{4kd*##|Z%`PZw``M*zZFWKX+hiBCzo!g8q`KZH%j6Jiw;nvMbu=^B`0`N0%QL@r z@1p5HmznwhNz0&Id(laHcq)BlMvGfkUw+ z)a<4)0T5Y%difB#Y0>;dH|DoZh7Zm|)jc$@6P;d7JM)QDkb8%YHA8R^oS=>J(BKku zj(kKd(u$6llUN$)G#iiZP2WR~O=wBr2+SjUEABw3rrt^gOp_<@WnuofKHT{+qIQ0u ze1Vr8YCi#Wc+o7A)ocdyXQ9@wU^y&7zk6h;2|D-3;GiwJy62i&{VYq#dJJ4HxoQ@o z-`!2|csb(;z`21{8aQkl=n^6CVOBo-$jW!Adch>KY~^F8%HD_79F^~o$<)K9 zqYg^rMi*nJKm}|}x{<*AvUf-h)eeUHkbzxE$(6IYfm4zNE)PpCgX9F)qp)t^&7kskw&N-at!A?L#_lPlns z%RIQ1vJ!5Uw8O2I9NZcifLkkf!5t%SgIlL1jR_y%Q{?RJwslFJ5~Mw_Z&GF zJv5@sTOwoO!c(u8u36vO)zzKL zz@lRJ`b>_e$Yjhi5W+_bvjk4y=WO5vja4M^tZzNYb@NieS4i_xQHmC7UL{KPB$rF@ zRH{}hu2d)k_d129z-8|eG=4$jDV%Y|(W8!GM@ZHH16Gh$4`K5rI%hgvKOalXU20>2a$-Ig8x8 zICd~E=()!Wi4<92!zxzeh@#Zk&+q_o_*qz14YQiuYCEy%@((!T|=NRrb-zg2n zi(o6AqG=d6*Ns4dFiG^%qYg;Ifma7{5ttahjAwm7q^imA}+4u zL3xyi%`b;{3ghA0i8GjZHg62iJRgcYc-5J;)KK-Hp^+rQNh)Y)gvLiWy7*^H8$6CP z#53nf8zUtoPdw+xrVjQ2rSDUv8h#TTJyirhRgG6nf?vL}DHVG&@b`^2m^4g*UkvNj zE=_ELCA#2j&ekH23+QLh*5by=@$f6sDtM+?WFo@C8x>;_=GBRuUwta@c;#c%nSy6bGSv_Xf6u`)>o?_ceFf_;X`G8Y*jG>% zwnLx3-wsKG{;rK&5W>q#4=S@yBOR>|C=-0o5oQE*K&SD0S=WyMQMJ}YD_vJx1>PAS@w#`scvyL+CMC#*3 zz~gni`p8YT7hBxv_)Qi|DeBmaqT|abUl44)oB^7yUJ`coau(oVy}T69uI>?UCT`Zt z%kayqFwC!)g<*yDa5m_${#|Z=Y3PJ?h;q1k$a+oQb8+X_L&gotl|N3MXgoItxw`Gs z4A*V?yShCOu#cCQC#c)OFju!XqtEA=zrniA^kHLnHV0$bPI-sQ%e3RpXO4e36DiBh zKdkq2z;~1q*80!8$3tYwCL4j z+X^fb%R-CafZv+YauRWhpG95pRZo>Ct^+;SrU<(>wHR=)O)bH*Ya7I);Tg86zrZiA z!mz?N<;N>*Q%gaI?V{2CF2gU|6y*rEDbi@dU93&{^b6;HCmJumP5Cs#ZHoS`O_Mn+KdZ#&nsPg+lGjr--cE>nzjwK5QqCiJUQy*2KY@!n)BNbWj~QN zv>JH4j@O3R9@vK7VDWFnZ@Mt&MmQ(DT;IOT<_KfxaSh_9z<0EErpdJDyRshN#5kx6 zLBk(wEgjc?6DNy1ShwB0oVz@T$6p^WBJ1(Yt1!%Of1siKUEAJ>IKj5P$(9!mk)zXZWKP;e1zEhhJXd^Ns6d1N@P7IG@;UQZaM# zHu&>Bf_2Z859j4u;9v03U)x12vK3*$`sT`mWtl+fbRnEqH-6)VR7UMvwam?8koK)_ z0u9r*a^|jGy88FgA3R(>IhgZP!md6relPA|eP9^NqF5Nqnf|VvcK~J?xH_~G&xP@g zk`~as_t$>lu`l9Xh#!+(2eDD)Vwq25SMc! z^7579ymQvg@}chaq=J?4uaK0#1r&AI`PWD}PVdG3z1}Tty?wraS|VGB!;NwiglC>( zf2@s1zey6!@l0@slfjw9*s|t5#|*gx3uF3=23Kf%Rg_7nO2${zT0&7st61O@*(UEzf{&PGShTKaduBMrYwlLdC; zC27Z$_qeX^>tKSXbyFM8*zRmwZw~zK^TN}ciiBF)w}Upeaz7mqzT%=(2}MKx)m z%o*TUpfB_mSS_sqgiS%1TccpPux-qe;2H8U-G3PFOJlk_FxZbWZEr?g=GoG=?N%W@ z78!(Ju>a)w-uJ?f`JX=yv)6O|9{bnH=wF9`%j+%py}YnQM;L>{TgTWY??Zgkw?-6p zect`>5B7Nv;91)ycrwmgadY1KHvIB(eIxtcVt5Z)JlEH~9nb8G9x95De6aYGk+Qh{ zh4jh)Vcfy~qn_IKl%blA80JR2<->eg1+Mp!l|xt?5ambekhRF}tpCZ0W{a$>AaYBr;tiN=4xAn&@4K*$i-I&N1! zLjMYu7eA(((LUxMy&ixrRN1n>$f>CA5?&C#h49jURL&^SX`t zONZP|x*Dw?cmMn8Vv-fdOPBlP9gd}uLT9HX;T4Olf$K^jfgJS*Lyvj5cl!|!Np1YFXp;VBLk%#*OjcNCn4AKNTOl_=;g4dlFgWqGEhBLaE4^I(w!@1j~YSOe%OvFR#Vw22-Ipp;Q#c z(nz6Ha0VGZNxZxu72G=zi}33?-_Dj^IlskEMZHZ$rKW;X5s#XJ{LCCK3(_&Ea2*c_ z5yz_0la%6ksUWSwSd4>M0p)UjEXUh1TvryA1*xDmMJ$qrOP#|zANad(_}J|>73OSu zN<}>CCz|$9crIB8RHOLcrcIY{lGoK zT>2#L&x|#D^N`~kd)qjknoA|LJ(7v#@_DJnFe9nUXKj%P@lV12Ao%$`?K&IF|M?!m z4NeAWCpGp%hagYCBDqoy(=lxiYJUbNP zZg9w*)V_-QZg77 zgFAPg`h8}Y&i6G;h8)3t|F0i~FSB9=tvi}ZC_+yauC2S~=@aK@w;7~$Ry8`#kknl-E z+4c!xI#fpD^yiiQ~-c@SKGYY8%V{c@NMH4!M)sISj<2 z*tZqQaSzjJ&@hqj7#y4PrnLpr{+kf@#Wt4z^F?qsIOI-h?88szlAKizG zQ?d=Cg=e+Ds=vH`CYF3JpB}#Q&P+FNNA>lW&9A4OpUzx=U)u&f1>NTmI0@aMH}V|$ z5zo-}7ek9gMLN`Ui?`Kv6rA8HX>qjGnqlV9ZeL<2CV07nyKxMC(Qxl*`>-{dqPS|2 z1}1lKW<3w;#@ebDUUA7r$se;|T|Ame5SOouhil%M47MxT#qma9ui51m?Tf@*Y|pI^ zuHlb@=6%vDf&&{oPKZ&CL@&(fBJr5p*oPHhg8m=PXnunhgl_aJ2(&4=<`SQUi8Zf5 z3-X%4q46$Y^}PAlPp^mBplgbTy7YwhN!AlTb@3&agbrmtuAQMvX3v_Q;YB+`C2D8r z(WxS9ZRb(U&d^U>$Krldg=ez=ggqwutAFM|f(tLAMePjj#4PETScrHdrYE1nU50nI z4DAdB)}9#uI@}j>aviwpi=0t@0cP#|LKeLKNV_o?>aqhC+=?3XTSz-KYv!$7H6I5o zyxt~bX69|>ZbvfM^KZn>@9XA@R9g0P=3r9?zEc}DeSXL;$@X@4=iDLW`e_@V0@ncz z(TznIgO+RUP$Mw2^Eh%Hg+;a!xBGIBH{M#0V_*Ne_3a&F+2{*S{m@AMOJ-uz+y=e9ngGM$yF`Qi7EE3P* zWt!Xn^Ap(tdL-Y5J3!t~q;ALW-a%pqN2MOLcd`uB&33ElNyxh*QtEL!esk#9s&dg_tQ!bJ((MmxhL^QC%ZwArU9@<->l?@_9 zw&8=2Cr!du%5Xl}Iyoaxyt~1a`E&wM@7W!cXhwicA2Lh28z@I(J~-(w4RjZ1r>I1Q_yDz1Dxnkl*wp9z%UnhS%n$ ziYtgr)eX4)9xIY5&X6LsaSxZ80b-$gj6>zp*|yO$1;xZh`?VCP4eg8a7kQ$%1!K(B zgB5YAm%+VlJ>9*zQW5{*Zym=aAbv;o}rUt~S)57NHJUQiv;Cdny4;CJo1BAH85Al!Rrzm!$uF@eWq z7RoVQ*wjGct4O?Q!GcvQv!K8)Y24Y9u=&GhMoFwh4EW_47vW<+5^N2B@OXQE>#l&R z4Z7u?)?OHqB#ASDCM}Bk~bJefPLMgcg(0ui~%|afZ&rI|d| z)H!qCD{lcB$UCDEFgyVM#^%FH7<&L)7?l9S`QUXJ+WP}LP|nd|U>uSDs-c#HFk=Fh zedOA(8UTO?jl|HSknHeZQ99EZ<1_aS zchGtOY>*s=F%@PKO90YLWNt0?m0+9Kkp8^*FpB)h{`qJx*60aRZ*Wn&pfC$P|6>+6 zX>mEM!&Ji&FDLV)NFc`^B1)bhNA}mF3!?v#{qrgmf_WG=iK&n>sG;kGqnQP$>_X5* z6~zRds);HTRO4v|E~*(xXul?t2+j7O4WKw+wg+t%av>ww3Y#`VU}T+Fc~#;%G$U3` zSb~7@n7Gz0wz;HOTPy9FJ`jYNgrmorSKG|8&9O;?+v|a(Q3sx_2E<;dq95s^$_L64 z@Qp()o*z>-!Y$RF9-C4DM|3h3l{*2)gpDCC?^m1;!A}tO(Iv8|{2Sny z{1@D~B$191{+`7Yd~d>?L^jw^V{1RRxL!;Q;9xTR_yAtC<- zI4PwViOQrBZn>NRw?d}Et&(|gt7RqJ8rcB1R&ItnMz+JPlRM$2<*jhX$~)kWlXt-# zZ#Ne_0XQNbfg4jBSxI>oaGAUeHzkMQmJ4^-R>&l{m2w8$DjnUR00=lDGvLPL8n|(3 zgj*svz%7+lxCz+|Hz~KnEt9=)Q}R~0BaZ7q~Gw1UD|fhg%|1)SgnIU9N;of}50!;g;FY*;fL_2WGfY9aT~L)Mu;u z@brb4%**B4w)W&;MIh7d=7pIJm=wTCrAr%7cXC^;j-sgbvA1zx12&ZEWZ{z z#U-?KSvk=_6E+E9r-Z^3#VzD${L_Imz6cK2Xi1;p#c04n%GNgQh$c=3IAaVA zO=;_fn_IiqQ{y5kXClnXr(yUwhbe=RZz{q{vOWEM?dJI$JY(N=H#KP(_gp+zZf(u2 zZ_h&TTt{oC@xK86Wu&HI#_uBdRnQMBRJvQs(zqD@2|7z|YES^GpeW=NQ%0 zW*x2E(AL(opu1ah+^qBApYeDEAh(D$iTf16&+nXLnhn05lg87`RWl?+S=0t z4JOTZrez`g;{0%9@#wdRca*{|zsV2<1RSdKB( zyiQV9)*(xe`P~G1WnFf4zR#5TV)(Cuf2H+CliSd?-O%|9guyn&oBBJb*-)n%!+dFV z+C$WKSPq<^#s&Q-(}`&3t^gkETfVkLvH33N%QNs=(~LO0R%%?o2H*GpQ;mlfD=%fv zxOHfhN%8r=TXi<`)f*7kXfQ=<6b219rtx_-?)>*5j_H1wKc=D2R~l}vK@H{LT!UI* zZVU>>zX|@l3d8(4ftzbkGnxF?T3Y-@;nVW*-Pp%)UZm}CjZf6mTIQUAVZpf`zjC@e zD3^&FlZ^qo;rtjaEIf`{-P(qwrgciR_q+aIih z-x^33!{;vc8N^B0Z<6jg={|vKoO1nqSfX$H>>tYYt2O$~E~5n*(~r4H_YGO&7{3Jk z_)U?02>Gl9-)cuY&=)go1H#66Ve8s(q)D4a(Y}&6?Z6r9;b`w_Q7BhJKSKF^l;PQl zIFm;E)Mez2;EQ`fe@31s(w}t#Z>0WgQtu6Vab-MI2sT_^t3tZ6u3K#lCTw zzM=>5U0z->X4Cfcda?Dlx@XO1!K|joIuMFdSc%(44F+VKa=g{BvIokmT z`@EPB3b*$b7 zSgn^KnC*_wC1}enpv|_t3(v($o#QMup2K5rBEoz~v#sZU*tYeX;U`j;_WoTo} z;X}1&`|=LTP*iH8sn~;@<(kwCtVzwW<93eOEs^zHkK?&Tn+m)2&DmZafbqRW5e!L<|cR|@|6 zV2axGx*phvyd-bd`@sP3itu+|)ym}iu3LYjEQXga%Ui50C%P}$?oF}^j<1(aBX@Lh z7ngqpb>x`NScJQ|xPxoqH)p)!<1znv8J$MH5wLgWZZDH+w>#G0VBF^7i|(N1FL$+$ zwlA5q$lb)6MdZ+R7M=`F277Z!jeDGa4(@!n0A;(6JWR*!Z#F4*`;wEuS6<$}$tPr!fEdbaVM|vbvqsn4!M(B2ku?qexV||oDb9CD9p?3 zOLyGM;1lNlVu(A}DZD+0FT&BN{J8Mmt`+M-=LVX~G zu}`iMJm)Du28Y~9?QYyttIZY%Kj*`A9=GwY(qG4&^V%@?$$0d+f6~VCe_jA+aLAq1 zK8w2*+~+HjOM95kmo&^B?d!Pn6HA!;k3!tZD}4Po9t{q;FT@k~I(-Y=O}%#9!*txP zQd5f^_rh|&6y1rR_Fsiruip#aWhf@)j=e0mAKNThhcPC!dX4tTI_jCSmI9A{oS?sn!u5u@C z__`ITyoT=r_4YlZzJBGr)lKuTo%xdb>C?I0*}WO~7}$ngfWjArQ83)JKa9f7+xF$9 zFhJi}eD9S;CKc>P#_R9#162b85-ULykUx>CuQy0uIu+NS{gGH<9Fx@Ry-1oPqrH!W zWYR6@Rs+Gz08|RAcyRG0GykZ4;WICve#tCu3)g+&=KR@2x5(q#-=UUl=!J=zo7-Fo zp9A1T&YxY0TEX*Y?>2+4Zf4N)XV>-hIa>VHb5nvIfcNNrZ{H>XgO`EUFWA5XS3U9a z&Wn8lT7A>8|KbOiVitoA@e8spk`e4P&pUs1Dd=p(p#3S_yx8*>JAZZx{Clnyc@Xz| zaYxWHik)}53V5GDc-(d}7&eNYKg%`E2^MFT{&Jm}`{4ClRMT|J=j*LUa82F@ z-vyAq4EHs-AN59+$V631F(S;FW9;XcC%2vYoj~@^N6g0aO6)z`nZFx5=urFrejRiv{(@GE{sR);Fm(p3dT&a|+MOj?RnQFc8nB37;^e9GY} z${J7Fp?nL`-V)9=KCwP4-}U61e@;o0<;!s}kVWR45|>4odTxa>0=T!fx3#J&P^evp z*mRK16?qx=4v=RHydU?6{p8h!G7feL@h!9<^IQezmiuTn=ailP8js1wj=sKCSoguw zpLQ8EM3zv`?kzktI}LtZ5-XkG%7c%I#_r-thqkgUM{)Cex~;&WxSMc)6u9Psa>%k( zOPgJ;7;&@P`Z_ipPiFGSZB@CGS&+E_tvuaN*^%zQE!B1@$u9rZpur#=G(%|HwK%Y5qXsh*pdI(s(m? zFmrCl9cTpM(jc!5ZQ3y$2##`&8B-s@0*$G)CNH`+sO}asRD*k%d#?K~1vPxl4{H7` zf&jB{<04tA=4Aj!aJH~f%Tp@rSirpV)A3W_G95p}9cW|WbhK?~Ti?AwN5?-U9sQK2 zjq)%ZCRM>C+=OuZ=5-=T$e-AuE+Ao8>B8^l{bCP~n%B--yp$Qu`r*ws$c@F!S{2#C z6WL#afE-iGwqi_CYv~*d(VJKvk25{@o@{KFoa+H%S87E)P{7E&{FR)yI69-{= z$CooascviR+qA)TTP(mB3LsQFpes=LN)e>}ZJ&0y=8^VDq{%9x*_$u+WGnWW`2CJg zx=`#Hqtj+07+pE(G$)_ac?jjWG6naiM&cCG)b!eqV?74Z+;M056?UQ}&o!0r`sBkE zwntxxSFt88!ya!o)KKs27_l*NL}6j%PfN;eg)G7E-}#Kf(-M6nyN<6=3%k3NPiW+F z>g-=Y{F1)ldk{HeyTxM7!hF^YWGC8#J1~D9iS@PE%~ddHx-^Fv<@eS#HjOF#2Ffbj zTWcCS3WsIa{js#-z5ShDHiuZw&6~9I>{g~N5@tCzH2+bS-TnHS8_LiVNAG=cL0*DKV18O*g0&vK4ie-{wV|sO>gS%# z2d~wW_&9tmXUB~FfvXytvy0}fYFL?F(9{GQ@#Ow9Z_5;*{FR3iUSVP9Y7FjBWBXNLji?Sj9tazNVCJvp zlpyVKCL-W61Qa=2>r4bSB50K3hp2S@6QBgo`k?an0r=S+?ql(&qnKv3^5jrPiF=TP zW$L}4y|p(_hn#|OySfo9WcP)M;VzkgUHg^T&D^?`sy#0uAhCIC5AE&~@f~4AlV6lO z1McM*Pj7%d3ra*mIccxT`jWyrO`a}$zS?>%V*LWKQrVq516+URaW%66T~?w3`^yM0 z3hc}Q#w_z9k~W8`#Lca+d(fAAA0z|i0_vrG#e*e^mWw!;KL5 z0{V>l{g;JOvKIZt7u9crg;Me>K+mY(D;7#g7p8t+Q@>sdfiIx%sNXLwl#=_=Q~X^0 z9<&hh6i^&Fj4mo=pp@*eP`T{#{GJ8G0l8eBvrtN|L?q)^Z=saD84!&Sl*^EXQi3-Z zIYa%nTPP)e05nbgBIw5m!JGgfu0of~hb)A>tW~gAsD33D!s*X|>eX+pg;MfWK-a0? z*DaLN@AOUTcW$)^p_JSQ=mzzBn}t%?^M)@n>PNi`LMh$(wMG4Ih94p1J)oP_?-dKB z!aZEQERrh%2k8;}%NExtLaM(K5QwLda)8 z$PnPwTPP)2Kqv_Kt+x>JDjHALWa{^X27tgr=EBUvwymvQ8#3OaUxo)s_x1PCFi6`5 zDtj(C|NP8Wyc>eH4#=4{9W^p`l~-{%*MQz94w~)BwP&VofFK5ULq{KnnByQ{+19<0 zt1x`+N9;KntU2Ubw`VX#@9xdC<}znZ?K=zMOkaj?Q!tkSQ08g?MTUPzmp}ym^2gxb z0)P7L!q+Ce9?nsn){S`KLDJB5Vsw=Z=$sIL#~1`D$Da~Mvp%RM3p(|QX9bA{Ow=f5GF)LgaBbsEUnV2k|3|6Rc*e@o&pwZfeQsTh`Bx7(o`Z9f3 zKiBNNC4b|2Ws0Qsg>}U3=-Gmj}VHJbc2M*9@;8_?!I6U;g2LP)ni6g$h zvzuY<88{M0VADg5Ou$S=&ETRn1G~~NEz(YEu&1C@)$jv)ZTQfb#soEd09z0o=jgS+ zzDFT7*MR;*j5&spPzKJ^WUn#X0P7G(haMoO!Tax2N{DffA7lURZ@~jE z+rySBN4@c*^}hZih7N0;Dv)Q1!Mge4K}qq zc0f8guFN&i=9M%eP*j9+NG4sOgJ9MmB z+XU(z%!4ev_vr9vfW3ddselcK_wU&Q2E4T8Xu8>=jBHJ&0B7!_*_7({?E}ut7Y3dp z79O9O`%JC}r~{wZ^31`a&0!n3`)tajMGNyEXp+QeZfCsqdN{WDU|0vSmE3J-D<1Q* zne6Xjj1@&oJvFBn5fGm>e*=|IJ?Mq-#5P4V+rfOPWwXV8E6RiW_+ z7!5X}J2^79<>+md%q^3^is4@bD6yy8-*D7bprcxWAOia#Rv<)lDXkd(XFTk$H~o*2 z9-4papmt9ADS*&9MDH)B{NRfQ3ZpFe)iRyikjz~Oqc5(1g^ifxV67iM)R-PbE={0K zD{NZYH$2N`rRJT@%6s-8tS~q4r8lkYv#SVnOppWRb3CbN^yg1zX1W+#V~R3EIW_so zY;yT=*S`J>(P!_c)ToX%Cfz=w%MU~!jH-m7z9Kj9Oa%FY9)Kx(U=QLNA6WlErJMXb z1MjEzACVm+OK7s@Ph_lFGjNdg*49zS=&;rZ9s6JasL?zkL+a3*L}&@@Fil|{KGsw* z{LMhU4Nzh}`BWN?vUa)HXdvj{(5x$lf8@os1JJ$$!U zM}w9_%5b*#IVY&-OyJ)$oNXN~2QvYcK z(30sNU(iV>UwH|X2X;+}^rs60hnEF8zC6_MGP{wNk2R-@n0tb~HMAv@69Y#gyT=sL z!^91>%b?t~Z+9(P89IH}wM`m6gAa>(hFa1?@dt{rz?4dBDyENj?Yns#W`ux8b?jv?ty_t4-?b^0xvf}=h2YdT`dYrjH6DBBNT(_fVWA?NX2mUcygg64roan8L1?^ zq3w_g>52WxK#GpeZ9LrjfDY})k;u&r2M%JglpOf{2bh%pN$m%)mgGuhu;C}1lC}I~ zP+uE1d&M=_@S~xIAEEW_#ft%K?ZLd<9VGBo7D`2WcTGE~F)q5H z-pu$18@@Tz@=dndZ=%(rn3CoVsM#hFX7Q9O_@P}KB7%l^0J`MpaLFq>@x>GkUaj{b zxd+vHAL?YD&r1b9FBkY6DDXk0VqWZSL;dr|K$n2$h8mt@C-59PfuY8i1|#etOyE$< z%P`!CJ_2R*G7^bd8c+^!5`mtuf<_$=4>o>psO5Vuz476#Z1Iig^bQX#z4z!KV!nj( zAG(LdN862unmy``FO$;CLn+e@;cd!LXYON)gZ@6Mg^El>5-LdR@L?trAVb(;`kvqg- zkIxZ=gFEKx$)Son_`1;Si^Fan|H%D=7)uNL$Fw!!r*-CkGDET5-Ke?5e#RFKHPoc% zu6@;aX^wF=q(h&XAKmYUzCT}%Rs2ag#zD)-^gqclwM=TVKWSctY?H3|JWE`w-Eo5{ z3fByhW>B*fYJ3VOXlv0LY-FY7V46f19vD4Ps(jg?SZI9qjj+Gum6z#(Hx~2GcpGLN ziZeWk!bR*qHmjbeh6W#3q__uc%{`z4#*uMiSQ&wJ1;bngF1;h#13)A z8rStHk^dvh<;c(j6wVb*;oCl5%}wqUN&Bc}5U!3kKlrwe>9Wlax9;FoNmxleGO$DQ z;J9^@i(BD5@TTa0S{`7!^JmBgyVyB&4~v_l6Go3a2*)rIU_Iz|!df4=cp|wTw!GVB zXjRl2f^{6M2Dnnfdk66f%c+L(cF#~s8V{>EsBu~i(e;2S;}woASpNx5K|OI<|D3pl zow$TY5SKynCy1-@{uFVw+w_+`XYONT#K$hxfG(8`ps~2qy0g_lE4S_Ew>_I$Z>gO8zT|fqJX~N;P05YMU z_57ao{Qk@HdqdL2fB|XC;}H+~f(QLOAj4y7nZuh6$oQ=S^kYrYTF-Acpnp=o0YD}X z?g3=-;N5^;)X?{Pp-*_BPXYRohJMKl{jwMO0wBZp*MPW{vlMHxj>jPn?-(F{y-iD5 z3Y$O_uL_Wnr4EphIU>(#mfOQc>FHBSwn9J z^n!-o?S&3`p&tZvMDe}|=r;;|6%fB+mI}_Kk_ zG*M$50W?9O1jy1%a$3d#GG#Q&^IHbU)Z!Ze{aoq&(8D|IK~vCdO$%)XWT?E|^W(Q{ zL*-vR2sVN(-f4i&Qd#&_+r(}0pbkK1YAE)L*;GQi$foiRK-^J~mP3FHkKY3_l4fe0 z-wZ&8GOd1{uk>h-$oRe4gSd<5JPqZxCX=UBbTWDR89;_x6yL#9T1E*#GZ6!3vpv5v zJ?LyN^dip>n~ZGS#a`$N&u=}TB`QHXAS1z6Kt_UXfEFvaqkxR`6Y;J6jT&PrAmi5v zXpQ1t1ez3&?~{1hid4PxnG6 zd!c&)-Kn8(^FrV0g?w(zG5rp1%(KH1nEG#m8u8M=VF5?viyHczhSJ=6Tz&z!M0ZW0cLp5M zomJQch|xVJJjpgLYatu#ivW(uWpJZ1UqhE^=#6k;jvj6)&fw5|fSZ)J!!47?;HGr9 z6}Gekj>}izmdNvPOXa6<6Y>h&r2ISF3K@erLZvK$TP3UDR;&5+I@t<1Ew{oQrzgCQ zmk$7*AfJFcNqzwLbom9`vm}YR#o00*?m2Qc+-Yh%;#^q>_&nX?g>nR3DfhvxlJ~%^ zme0W*qct6Ssucby+&bB#X+H>9GYV-x2lJGe?)QQ+3gD=$RiDjpOJxV#gzo%8{RJG6 zx516dd*H_9BXCRPvv5o0n{X5IeYi<^5pGHjz%7>~<~J2m3Aa*ri=i$6j>t5)QJD!h zF4w{>kruefbGQlF2{)P{2|78@Mq&B`&VJ z({N&_`v1H7pN5%LT-yRl18`DS!mW@8;nv7^;f|4);MVDmHIe@XI3_8~ZE!FF+%kD9 z+?0F@Zn=CNZiRdkZk7B8+-f-`MH@s{z#Stu!bJ(fP0QQhj@7YEL z4mcuP;6`N|+?ec!TO#j=n~)E|P0AYC@~?0&l0U$`SS=k*mx-8-Tqftkoh=u_ zog-JmohwV=UMYVG_bTazd$sI_dyU)!w?Q6(d!6q86Zvbv5!nYfCf|iyA_w56WGChz z<#IRN3b_|%jXVW+jC=`hTKh(0eaGB~_rc_&~T$Kf?KVU`{16UI~GNE6Gr8;@QKTp;o^M^ZbE(lHz~h? zTPBC$rsQ{U%jFMnu{#$t2GlpWwYtj@wF5A$7{iUr)o@E>3EYHS4>u`qgj*(1O9h=< z;9`#`+zPo9ZnfM8w@!WsH!Zc86O5I~a3|=lNmzjc9F;5J#$_4YQn?XsLa>(~l()kz zliT2?=)UaVf)Wpj5`fO~^TLlhOzm`z+y>%Uy7*erRV_uH zo4u-~dh&R=`eoq9y}6~T8pM6BrD`3FwX_uNo;gftI@~1+&4T+Kg)WD?R-r55Zc?Zo zF53ciY|S3tQnh5vy}qU1E-oy%)L?D;So0LDU-2{H1oI(-s~3|HZz}FIdLv#KF3<*1 zF;Oo01{$W=@C<$*Ws>!Zgw+RhD`1ve8J+q~NXsFEIOJ5WIY3Ac6LSmF{Ahu1YmoIy zv%GpSFq~BR@=$ili((JjMkpo^w|W-H<5Zbxf5BRK$bb}C8u1AE;<=3hST}wtf={j$ zkkk8$?5%2HB+=@SM(5Aw$E;nRrw?-xd@1-e+%NhWd2V2*@SHhoVNtrXwHNzOJKM0& zbQ1trTkKyCOAqH1B!w!KteE|z%!8j>H>nO>2G1-^lO95Tdbp~8D^~UQF092zK)dZ} z@-qr^M_5ccAMKo1l5|gGiShfequHMqJ#cUPN>%M-dzk%A-7NemT4|7!TJ@ znD8x2gFc>Va+*AN)fpp5Aq6WQPmn@5NhNsLI@F`+R{=lv12oO+{HO-P;gxtxp`<{( zYWU&bnDDiJRKx{)Lk}9`#G^^s367ri8xKDY7iBzZK&vXv31d0~{|x-&T{w?i&Gwo! zOo3kvUM@}SsiE}<9}|x}I9xl^*EAnI34TRdD@_kacpOI9d~htnygCu{z!~82$~WDQ zlRmw6&%OiYt;c2%_bkMT7n25Q9Ic;eZriw^yT2=^S!DZ}DWGNgnMe&`*EY@u%zEVN z$~ky;^^tf}ar5Y?Y53(;80Pmw&U`l8O0bRjbfVs|LZ`4^gWkEoj z-?09Y#znY;{S9SdJM`)M?T|F+@7l;EA-ufwpfdY3{9~Pdi++_R>9xWNk3x&;*c|5} z4;$Ba<+3z69n&L_iYQ5<&Lm8_v<@2BuYU=-7&7^FHlar#h3j@K!X@Nzol8WRSGH}2 zikfwlVJA`_X9ADc@#-U{S2D}uUW(sjF?CSXu^C0jy;1Z-ZM~cgnyy|FcJ=ZKz`=Ss z2hXnV5$|%`te11~%d0TVua|{kh4t`C&|y8K`Dy-MjbGLw%HirE>os}TfAXW5$Wb%OBrPG@cu~$d7HpmnGaL=L; zE(1N+774qy*aSG(7FXcewJGB9;}+XuGk$p$h84C&KVD&5TnRdCPpj;23x3%aDMzp^ zlEw|Vi?v0ce&M|HMB`O~HZP`!b@)W%<+nv&mT+67ziW$Gz&>7HURvHRpWVFeM%xxS zcDbV$*cRFLf^AWcVhFUwnm}8;9{2^d0riGs7xTY1*ap2hS3-}{3AVjA05{n7ZsfB! z@AHpbG4sHLtg+#=Psd{%h@ao~-souBws#Y8^5%YP;Wr(r&u@E_{Y2VcEAV(7ukEoN zvF)w1`0MeTF3h>t&MMm8f<_R`dtV#kr@(i#_Nm!z%ok|;+{8Gj3#Et|la?m7i4IH0 z_4~wW#~o}FZf>^`{>0<2j~9_nJo73H^V=CjBOTX1`T-ZCdk5xde0SN5aK1Ne!7r~Q-%afCw4DEMg+HL`ouFa*WWFir`hfc1N`LTh`Q%`Z{e)e8VEkKf2kV0?r($6&XZpKxz5_7Jz}2Av zJQv1~=rJQe^WK+t1CR3n-i7!vxf|iUwCwSF7oJ%^-aG>RDvM8Aq*+XMhB5tq7(P%0 z;*owZEZ9%8O$5X8+k_wH*IVX2^T&-zOf&J`iaVI!#G^m+kupAD@l3h+d8he=O6v3S z=UuD;dn;seeiaY^OifFIKil*@pc81*UKsm_+Y!e8!H#!b|bEcU|kI zwgs>)2W#>g-sgp?wqsx#pX`##+;8&n8Y;-}E)>{xZ z1z~PYgyq7vF-uB~F*3!A$zJ${`_h=)N54Qn%Cy}NKjzuew(a&v$5`ZT#Ov;9>utp{ z_*E)X}3WA(N*ZD_@>6rO2;<1mU zQJoBa@r96OtH%%Z*k_pB_xoS?@%SQgz zU6ih=r2+duO8fmDZL`k$7@iAhN91w%^I{m=zt1-u#{MuE=K4y?&iO9$h;YWjr(k^- z`z&;Q_pia@eYn{lJc+xISBZQG{=8f~(m9cMf8)g~l)v1Dx$%fJ3wcN6V;0Y?Nf9rj zvY0uFpYEu9BET;{Pl96v*P$5CTz=o|c(A;S%M+E)jKU*dR+bsB{Icceyw6!W9H&_y z+&KLdU{hYEZhQgH`SJOV_QgParp3kod%zr@T)uv3g!unpaemgXq`0s)L1SvNk%wZX`H|O(PjggNgHSyioqq|0GaK>;p zcyNOkwpJ2)m_sX$GITO;kd*OT*V@P9m7RaPB#pnFcjb_GoiOsJp7ve;y^yU3b1cp@ zc=ou9o5NR-j^5l3KEDq*+a+ajuz(lfajV2SgR<3kz99|lgTvEQrVAHj2( zXGYh=`6&F#osD1E_a&W=!>`K2Q={w3^HKQgw<&9)oN|8>e)#9=zFG@seB$Bg)sTsQ z;(iMLY2vC4qz)WKYy3D5OR68teyZ##{h*z&AFs>P_St?}b~1A9gf_AH{8`X0<#Su7 z%KEo>)@>5j-ZXiA9)20{iqk?@pv>-+8s#21{K2a;_sCccyN;DIfWUgdKH)8r*6;=W zy}dA8)eQ4wv^wj>zaRC42TLrZy)s)a%pc?1OmpR4-cEsRRX#VGcGa-I1OBvd7%k3v zJRX$P&YddY%Ct{wirha9F+94uIj$(GPRhpda~-Hb-apXmj+hBYYNQilJsvezt|n@m%Je zETZ#Z^}mwovWDW+I;2e(>s&p;+}ykzIw0SKUx}J&X8dybHlE{r);Q&ABU!^|Fg&KV z%qxOs`EC9@fq1n+f6Wae(+db&2)<(i?Z}#~2F*IHuZs{~?b@CVB){(>Znb%HP>QTj z?ugKbWxUpqKvjg5)zc^(Emg)0UPEuMegw7Y`#xv| z-$Ptq_^4Fd*1o_Tb+WYxwPJKf@Xr)6cPpHJ8mh z>y1S*9sBA-W0CP&STMF2|3#s(#rQ4t#tie^RJ5NlVXH>$XJXpVtRAtSG4a>r^)q}& z;>Mt#+B{$?*V^~K@H*G2Zhg>P ztCoj<94_ZHoX`AHf4MQZ1kfH(2wv8>t;UVj{0bP90oQBySs7Tj&`PsCxn8f{#_^0V z%KFT3uHkd2b@iHS_}mcYp1FpPq1OvfOESA2rgE_a;L(Iq1Xo-zhcWGgbSGid#EBjo zyU-3PKgZpFfsF3TIODuF?aV`7F72<_w7cVXGYI={nBLhGT{ve=&-(SbzHC?bHUq6` zUo+2?&qc5E@w+@Y?|N{4@rO6?g%sCCfg|(yP7sR}J2VgJP;B$=5yioM{sDRniA8vX z9CVS<}c&#c>{Qh_rO@eWBa&uHWpb5mzz+{<>J4~J`)GA)@`)U7(oD; zBZHS%zq9q%9pcG!D~@;kB~#+ZYP7M;PcVPDLoybb0+)vZ&YJa}Hu6S!vGU>E9UyxkP_mN@I9Z951D$ z?#KF)jb(m<2NJR+#UiWVy8KRP4h3_Ay;v;5xg4>E&bs7QAN$+ti;+UpMX89#;}7dK zBv@XgV^Z-C8s^RkajBpLisPk%wES56Y%KE=Oa<2vVv+T5T`I~7Qo;Al$oT)(j@(*mRfG-ZkhRax|WhdTJZYbNDK(((E?@54+qvuVFD$yKkfX{6B z%s`cLwHV)2;bSh!!|U#l508bNJ?k=k|6nbTdF>)x!&@}22wN6vuRYxM6u{aFynLog zpZX}5n-x3gydC}q2l8k;ord6VL*^BV=1MtChiZhpR;uf`lTVoYV3f5nIwN?F%v`& z%IZh&CuJsKR8&UvFsMI4q=C_c!a%5~K>JaNMD=}Z?S1xH=iIBa;hsBp@3p?~TWjyL z&$)B=IY$foE9kMv_j!vO<-K(_&OwKZLcx5{d&Rd&XjdERAsTHifu5VhD6m_cM?AoY z+W2g6pRn0@)v!P9z2e&fw5tu-iN>sN0{f^K$;hmCI!qCA)M|GVeavya-r@RFuMmaR z^Sp5A|E}VAo`qT)#S-ikF^8XdulP2KDAa~g@ThnTUPlpyj@iI&alZ5bx66C$9(>=h zAM{@F?IEzM4cUptz3B`bc*n#juv?s;rOmm!)F$(wY8(4O!+z9z#kY^Zt~O*R8t0u0 z!G4bz1$K+`p9j!U9AXDmF7p>dOw9ZV>3-qe-M3&@8?qCPecl81ZDJDGEzU_E=V7(+ zv6IKfeurU~(`4}on}5NsHe@H-V|d*FcCPrxi1No=i*uG|e@1OQJC6*O{ZvdYQX}@f zt$i%nyd~v_pWW1z2Rh*4`&xIp?w0!l+4-1vUX*f<`@@s@;LWSpFVyd#ziZ# z>rwa@enio`D%;yuVv96OnI`!Nas7(A3B={kx(P52 zF`8AzMV%vf?L>dQ#^$uYZ00ZZnSWhve1A>GC);0RroVU;w&iWGs}0$S_99;2fc_o%V?A9fE zsas^XIJ`*$3r_4%TC>kVIwJe#0{b}F)rRau`vkAC#JPQVkL(tQw@P67Ubca~$@zw1 z-&SCM5$r#S4cUpthoEdv^hO={-hgwz&dyHv4_aV~8ANO9a$^Cl!T(W4H>}x+Ru5`#r>@!dsW8X1z&)?Cy%SSOo zqM#}=^8xR?>5q+qI2y%XHlduTHhvc62eC0x6urdNM8WG1Z4@&!3jaNh9uw%D%&}=X z;?l9f-l5KWfH9?k_*An$m$2jKU1`Jj2et8W703MbNRsRYV)wcCqDn2dp;2wfPP8A; zu&SXK`RXjuRjsr2SG6Qr&(u^(9IoCb?5CD}AKF>Yl=m>Act#)!)4u4!DN)pX zzZ9g*7~l7J0-YFEDx- zfz8czQEZF9Jjb2W9hJ*^4-ZWTV@ z6|NQbFzOIQF0PkxfQw^(MojUwo=$U8kUZ$yP- zcgt@#v+;otBN_Ywsnlvf&LW)rL_JZ4zEv5yiM5Gpprt&FxC{Xie3< zkgF-Xv0P2bZB1)J6jl%am%?(liK2KeQNr&|u`dpJFZJbi1W~9BqafPrsNIJs_#iv& zi*lvr_NRIzib}=3k=6u-mg^7CrQdSGXu%0}F3$&y!Zz-d`gl1tYvX# zdG==vJCkO|;gg2_f_VwW}Muj-JGI>q-RPM#ieSs?j@0UTx<(uwr|EV_61Jmcb;6 zGPM?4%D5!SH3+Z2v0Un8@kx(devl-6D1^egAN_q=>5UDXgRi$CRz)RL5P8TD7a3Xk zNUMY=OIKuBlx<&>4c|5)GkvWhAL8;G{IFSt@ZsCmXi7}LByQ#1on265NssB~*92LQ z(1A;q+WJh=%v~dpa^{=s`K$v|Ax*g@c10_W7hPXeXzLrO#XjcEClYiOc831OK&>Kw z>KMpLqD?PlEooRtM9~e`Jf`RjOPsL0&^jTKCOQb8u9_-3KtQTAPsfI1>rR1XSz}Xl z@@H3dStA6B@gh0M8p(c8w3PV$Vkz6o;Q$-~!s;vAsH3YzBDy+SNwOr+vR$Y9#6syuwl{B1-778H#bDF$#`UYMfpm1wLb7if z9=&zVXu9Cf+HsQTQ5A84C>McRGs$mHi-SOP52aqV^m}c4af)_m(Zaf@hCHxd;EF%ZHnXjbkCgk*E7x?LF`OreXa5{CxPQhVhSjzJ16rf}RIV!}xnXzr4jTj`jKdV#D~~XCxVv zm(O0&*x8>j%~cgO=9+gJ<>hVjwadIp)BV}h(-AjK?Nnv96<1c8OPlMPO#zpe_O^F- zZYVD)FD);ss_ieIS6)<6A;F2QsxWJ+8k)`ajt)XLw0C#+B+5(MySjQdl$UnLx0aW7 zfeBayn-1TeNW{1FCOW&XDlbj+fDXu(Hmz!u`0CvB#46S_n35#r zsM3IhIvxn9_?P6bfivNqiFjXoBJS~lN30@N(JG`B6#~09_Qk!hHI$zS!V?xDs|oIl zziXhg&j+v9UWuNzc4UE<@zz*X)yfrZ6)RSnX6tNIrGlcIQ@>zrs|5N z%A>*OQPQxaxzTKBTIq8wt*NMQG^?5$o16UZwRMd(W~_NtQ?<{1US;JnvoTh&yvC28 zS6A26Y{qJqH#DaNXlQJTnak5d%wO7Awao17zNWpav%?q1{AG1j^`uo*lfrFfg}Jn* zw!thfs$LfF?kHc_v$1?(f1-~?ps2dpM+Mkr)k~`d>%_7!(Q|dYI}F&A~ z^`?D&yo=QU>Ff7n8&K&Q>&*7vUWyEqQAHZbd@o~=lz1y?WrMk-u4WnJR#nTV7|?!H zE=1*sQOD*Bg`(BmRF}-p(hZy1`xrt?2+@`=Ah`|v<7pEro6MTp#zu2XXaAP=#D+~e z4W6Kma7jWM6>sqB3bV1Uda0??zp)3Ir^2#r=tBK1M*`L}rQK*El1)0`v#PfB4)kwIfvFZmAQFN&v_Dmw zI=ec&P&7|~>N>CTF4!Aw;zpFOHngNEAkCG_n#2b@i1VcRf}Xj>moY>mf#;a9L>WU}xoW+WZ)cyCot@3ld69REtl$Ol@cWy#1oyZhsP zXz(|pElwfiN(X&{FEf3LXUB1tbz3@U*hWDBxcXSCwN+q!u%3E3>PezTvhm@T5j%(VxH>8qq zMWJ)TbxORb0_jpuw0HUnrBfbQz7weh5}q<>Dle{XtZQU3sci4ZII{(V zQIs|~Hn6u^fkd}&G0ld0$si0-{c!KFwA!q$ud6XtU#IF4##b9VySn_{PmS5!RMlW6 z;@i+gpuN}_XSan8PeOXTnyN~(X=!7Hbd2!tjWZEXiab$I>q zXG!_IWZ#2+r@CTEz1f5gN%z9YV5E#))y9GD4T;X4ZrXbg0ooFdzB%S=HY*zuHrWeH zs(h(whG-fpO-QhFLpz28@xDIL@FpULx+A`R;3~-=lJMjd zFe+0JC8}x$UuHZ!+a-1B{^b>`=Td)k@6vV~{tJsc1d?9?m=$ ziShBR-Rt~lPo?PU>AAXnQ@p*y^g|$K4yjm5yV1N#~jT972`r;cs zEuL65G8;*pmRdS586@kpJ#B61mb=Ua=6cl01;u{jbj#?6YMYlenpmXasAYtHm7RDs z1{_PV5L2NRuQ=UBM~~U%);=sam6vw(Y{i_px2Llk%{FII=m2`Ib%;wHGf{)h+pxJ4m2rM%qHvU1(b zI-b^XcIA>fGiA+Tc5PKN2ACK~dR9ngFRfk1QD;qs&v{N&1^O0Z>l^(ZO|kk)<>6nW zE2&>v*Q}NXu{7(AqGVZBHJIUYjn}!fz5zpME?32|5S6;XHm`087If8OOZvjhf|~kT zE>L1!r(c%mJSkeZq_L(7epd~|(><}E+z_j*Q?-7S%7m&{*MN0OHS`v8h>?rOrD&~@ z#?&=Au7y=Lo3#}Uja&(HR(0YSysO^Bmwv2GRaVtim>5oDa?m%>rHA?)+l$nzs&v9> zsc%B$)GiLWPdYDJ?sb;L;*Hk*m+K5#G6gzjDNDTu$&8V|S!z$}#%QTl&RII7z;$7oPzlWzoPZ{_~ zQ{AT4fIMl!iUJ1W>GMx^7+8W?J$DWof2a9RAxV!K_5g}(+t!YaU5WnAtNbjXKgdYm z7cwnWX09YM%=-e80d|snOB!X6rY6)`q{1OQLP8Kjx~!z{Z*xOuOpF%Q`c5$4ug8{7 zUSrj=25Ximq5T6}^f2G?!?0O;e(kvmg}BQvU^M~|ae6_XsenU^NGS*LW&Kyp@l)X_ z02yAb1`z}V_%jda?VS)f5g;L4e5JP@yE;A&c@=#}d;>RAedUk|)k2bbo94^4Hctr8 z{9W*EY$wtJf#isRSPRnwai}GWwVwFY2C4Y;SI03=t&L;Prbe2>l*F>|63E%HpE&0i zA_C9sz!8ymxG2jyl7mg{sU?DSTrY(8_H}N-KsY%G_p!^k$c1k;#D|a=gXDu?*LH8% z!k`y*~)g*hOs3dJ2@sy%Pap|0=e>^2a=$&5aoB-E$`#Dr;$~gCv0-mA%N`^>( zT*pyab>?zZ8BmVgfVF{T$;C8d)4nH#Wn`!tNegUr#By2s@(JC^YoUNONS~)4y#D(6tU)pl;d#rY)dk+5P>3?I4F=FFe+1vq<5_RbvYrw zj46zed5{XjlXw0lylcl<3Ni0*seSbJmo)xgsx2MMa>_C2@>OQL!FsG}Q^&NL3NDUq z0qF0kl$HHfa^sYpSxa?hd9Qt8@vo*NmQ#JdiTf%$$+O&T&O@{wR ztB7w?fdcEV|GWA)(z<1GMX&0Z^{rXS->x#|G46>eZJ7UG7f46fO#NHv0gbW@%iJ7M z0aoQfcG^U~*%9Uj&XR6<+sK>#@b?ec{bBt|Cw@P7-r0T{YX)m+_ zyyHKj;`)fnME{IR9slIJA^&K#(tl!oFTLEAq5D${{?2k3w>^^TuIX!Hsz{4_%9f@t zU|=+v0&(ZS-_&E-{hw#cDx1S3o!Rbd9pCZ5k#(rDIMFh~wwk*Y<{v(Biv`<1?B+*5 z4|CkwfjrEW(u5-RV>?lkjf&yO%Gt?dH~!-<*bq(n=mR+;DsqpazdPb-p3!zWabQ-} z8Q+pMs;8qNIf6zVPur&GMyCaI$HLeLmfY{ndS^9AVK2))*AX;3k6ZKoSTqJlICP60 z-t1K9Q)e;3o9e#3W`FyMDu{4A(Bj#-A9a&C3q9DR@_zPgx?9&-@F=H$64c!O=RcD6 z_Rl8#J#~r8QO>gMx=}>**@wTmsz7$<^@5LFKph#nXI=k$l#gc;r6EmrBqMY&qIDrE z7D|4q1=ivJ*^l!5P4umyN8=wEN5`wXtX|9^u++w6}Ihw71JAY;u7tdqj=FVNHz1EFu z%sIo@aKZBnLMIr;WzZC&nbpx3-;lT_u6`NDd9W0PoL~CyxI$wV51)FRi(y}qf{PZ$ z*3FV*oJF+`v=El-fZMIHIrv>)SXh}#ZwK7(046dP78t@6z4k=AxTseYe->+u<7^fd z@0-=v;R7=K6~L|2SjG#SIm-_-E{6N&O!P9O<1XMn=b@J=9hA%0f%z|u8-w3La(Nw? zyf6STL2`-0?_^+RdvHPY%79tw!DZra9q6qB<{KK9lr!_UXd8T$nTS6>2j+Jgmy6#L z?=}k11x|w&pT zDAZ+g7X!Si<-7Zh(4;os00Sj7a%`Sg6lxBw5$Nc2j8S)p-BIj5ArlR@L%8Y2Yp zlJcBEezySkVT}!nm*wx%z&xdKBbC430Q2V*dKW=Gv3;N`(bc(rQDZ}8Rn+Uy+*sXI zv8-lA)LvN>+Vx~&sy$}czQj9P?RSOBURgUZ);9C4G4?pSB4jt@TjLIdjFNqL?cK|i z&Eg9NoRfKj5$72z>??}$TkTg%9$sySH_?69GZXII-(o*H9E)r&I6{}92SSKu@lPo6=^?6Yd~t=iD;>Z1IEQX4;; zlQ^N(k&OM&S`o2I4~vsx{T;AH@kH<##&mhR!e_Gc3}h4p8)>zB^J6Z(U9Sziy!L+5 zBM;}{Q8ZZPw2=%v7eDfhj(?-u=HX5J6YH?(YOH8oZC@KId8TCF!RjIjy=yoz#oo&N z2-(lRm~R)h+J}ah7uq-E+Yjv;9(ciSEGlTT?_b+tF;e65p$7^M6rkknWdSb56E@Im zNpl@Gm`dfgJZamrEc9#qFz)3`Y%Cy)@I)kJ32b45>1Gv)7}2q}pDxM3uS{kbhVJ=z z=Hdw(MR>Cis}}J}*qBjxB)?|Bo`>>&P>5O;`Bp{f{=MYE#G_kL*n$l1kpqf&#u%12 zMG-a%@TOG51{+7l6P6sQ5!+Eln11AQHLB~rfpMs|`F76o;n?H@`IN0= z7~)hNjPj--brmuuS-Z)E!x22Fjs=@@#I|=Y)763}Y@CR9li0}RGCUEfSdC(nAyrgX zn-)dS?dOGyhH;j>b#nkalkxV7yor!uW8@-VCe&x)nvOVZG=D_~Up1zB(G|TLHYEDn zx_h=N+ZCJi5O70puR@v|dbae=>g*Vfo@lUG|KEF{yE}S#aa}%`fkqa$;IsY(R2z*5OU*PyX&bh}>b`)RvPZE-6uZSjRGu zo5K+x%U@g1`Jt19a#7>#IVB6>1Vap(M7WgBQ%#m~q2ER)3Pss7Vr27_n=>76%J~C( zf1a-?uLPYraDowxQA8KS6-~O(@7g3~Qt;Lk))7}4EsuWVDn;2_Q`l{|n8B&Peo65` z%J0>bPZpl(^1)@gOsPDZ|*?Hew~eJF(H@!fVqU2>$wOH^*MNIm{!P7p^{kmK%FW zi;ft-#Mu40>0-!9Y3Vv$Fl>8C#$UUOHRaROB*syppYrKKxdtJ!zrZuIq6gHEGHVQ# zx77rBP;ct(-EykV6{t%^=T%Y>Z;p8xjw3o(mkQ-$*2)V?K?!JMBSP*u&3JujRx4s{ zZEaQCw$=9GbY6XXcSl#e&uBv#+kivxxR|0pfkdQVE1U6RRwYn5UFas+chq8pEgZE! zCRyTK;40f(N=L0SOQrU7zQ$cV$G?!{tW*W9I?iRXj&tU@XkB!@%(Ra4 z7Mp*s;X2Ox{(i4hf!jPKop%^mPx17-^uVCPI0sF9Et`25_NrzE9Lc?3V~C?s^I5ka zryKkGk7SAaL>4%+l>-!3C{D%s^LJ z#_ke^#URsq&knfP0P~>6QBI1UKR?*h|5jsQ6_Y97h_0GCS(Ob~zf z!0#lD5g=Yc>HRKnKNy8xF~UC$OrGvY7;mQZG6^R;oek_XLF+D2;EFx;GRc|oE&^t= z2bU>cvY*fx#z_+t?@r+E@X*T??>$K1M}cYL&;f>{gCO}$g6DYzzy#&T4)_&o3~@9; z^zH#}Ul#Np0cMGwU%L5`US3uL)8WBoOfUH92IeddJ7Cy-XOc7XV~)lUM-wFH^}zLM zY>-@H2){jrUXWbA58ThPp!X|a=5a^^w{~6+vK5_Nq&?| zUkbgTbbK7RuVq2+J6Y0u3AndLq1Oxk!c4Ts1o3wba5rh}NcpxmOM1Tm?v+vKMZwpf zv!r(h2A&sk@Ch>#e{+G^>A__x&#Y#*YK#!XE2tcN9JsG}=w&JgCc=LwgIGf89FK6>RH3n8OLGkVd?rx0@iZ=!dp9kj8 z8aI;sCZCA~VmvfK^rG;a1I%&{E>k+#4PBuzu!;#vM-Ol}c<5y+r_47Cn1y<=kSjGo z<=}Q;KA~|z=_rQBmw@^C*@`#vn<*V+>tCY^3qB#Cs}u$3sJ0kX$YVW|0S%NzPG(uLh>WgA1b94a}ei7ew!7jR9#fLG(Tg+`XgF z+nZw;2Y^{VP0?Z%&6IC+U&qOc#{`wXcLQf@EXZdZKeHXW6PO1z&aFrOa!?4|e`$;p zb*Az{+#fRH(#t_E=69#yp>g>0ZpQ`hrMZ%UJfjHpcqh!!@^Qdoi1rUPZEHXT@c z)usc7XJLcCxq1~g*t~Eo9X8YlIt=-)haq46Fz`hXI`dl_hWbp0p}y~7=!>TH_TTDV z&)9DyOgnElR$#xf>$Sv1_9SlN<#Tt+4s$Os-+sk@)Se`6125U(6?80AdwKS0E9}Rx z<>%kolg$lqW~|@~25DyQ8Rz4XZ3gT(GQ#ae1&C+-Ci<;D!uQYv`SzsM9Ezw?Ztm-1JwMj9d|zuh%#AuWkh>^z7gMxOKAO7>le)ZE`{CyJ&(u&sL7eT zb&AzkRLB(Be|6+6q4Mpc_G9*GTF$$Ei|x9Xv0azjY9EHYv5{10KR2{5WYJQLox<-R z>M57+8eTh4V09H0*blZzeD-OpBufyWK)HDLnm!B8nFQpBOdl3VO2}h@9j>>+*N(Gu zBs+#(IBMV~TW0wyR<+v2t9QL- zzcFw^+uAEj_FWF5Wv>sMz1fg-$;*E1AV&iRnXq3!LMt*R0-?Uc3sN4a6%%%Tl@O^J zlkFpRF0*8E*^xwzE}6*ii*<>E^>pQ$uea}n{9}rk)F{-n7jM@XSZ`j@YAbK-6s~m( z_Z$roimEDRpeRg%;;%2owy9IE0Oh78ocsFH-s@1kSjmxQbwY zaw7Bt(uKH^1jaZ7bcu{YGTf61%O-1+*tl<|+*mYOb|SJNs@%9wscLo5EG1C@9}L*pzP*Y|3|c()VAIzVC-kaR4I5 z=kSXLB~mKZGT5PGu?pMqXd$rA?v%!mvFl;`)x;`n%eN@$O}0-%#sBf}^2udC9{7oJ zV-qq(XO{hAHY@fFG%PU`yj2U}_cfgdXq#2zff9do;0ws@d&vlOE+}Mjw4E;)xC>`& z;F6q8wtoUf;;5J`{SJ@$1{`Bv?v9YVBLmO5+`WTb4=)Exs!W45DdJ%6TN#=AqRSkr z`6_Us@`b$Jz!!`oJ^JJsEfn9bho!xIbzq#T&X=Jff=DNW!|irgQ4~#U0xY!Uvs;1$ z6M1$Wdar>e?79NBw!8KXp0n$jf$^veg;FlmBY)Sh{mQ`2$<&Y`RiKxH>ved-#!Yx%i6>&nCyb)< z1*2$ZchvcQ(ab2mUKH(yS_(d%aBZ|_V^o0s2!q)J9_AuiP{}b;()v29?KgHklUQu$ zqM18v|AE}FqgH*kbkyirnf#ZKJ+qiW`Ao>FLOYK=b*ymhm2J9kfT(nP{OgpBIPB=4 zS!N6DS5a!mY1JTh2PzVYFXO;~-8KgX9;Fy17j_q0@PrNZ$)iO|5vP-1|AlX5`&hQN@5(m7OZOB1HH1Ky$lfv%|kQ z9CfB94;_GBg8NHAp8=cg9uu|O*Rm^WX;6PA7buZWGKV3z5KjF7%8HkY$; z_^qZg{7c?wzKBPuj}5)l2rWj)xDeU(sPMA~qj?B5v>d&HasXS7C&uV&n9*ykaYGL@ zdIsYV>M5Z59G-~GTz@Jya`u4O@RG3*QILs_J=MFCkj+aSJTi{o5Rk48g;^cOx23b zIdHVXl4!dLX;wpSkK++LJalvn=2DSF5k?kJ&eWswXD}7}@r$_}FDML@CgHz%jDxUS z5zTTTZH28XL-vDLrp$;Zg6oIzM2u;8GYt{ZXyi~dBD#{wjRQ*M)(o2pu_wU0P!#6E=7}>B11eh4}}y`7-Bja9yrMn6Nd32W9Vq^z_nfpg*?J&LX|9N(bCFC zJ+psYvFjPDDIc}@G;+iS61CYQ;IY2oj(~@bhOBVnfAyO*+(1_R=CZ&5))j`KFD_7KoQ$##hi%VJ|aK-K(yuJ>X|gDAbHTEv>)5VL||N_ zhLs@9jztw`&hJ$&EPzc(yc)J2;fWZR@JEW&!?3Fvw)8nMs6}g$AFRzM zP$uu=VNr>qlV0dewg_xBbc=x1fY?K3fnmi$RxDpAIV}RCdjXF`n^yhV27v}zExRIr z#{y#@d@zR!!xQc+G_8}N{3{JCKxsOzr0FyqXg2Kdp0#ed!%*O~WNjX=$~_7_TJ&Gr zlT^)?pLRGgKUr82Xv*&Ktv8=&KUO74@IeP&XnQEvSbJ{>@v_|Rsm~dDqin)^Z^ZAC zCwJe5KgMto3kkY$RZ`p5-pkz)qCHN`i4-R`hAB=Q6{I+^Z%J{=(@vw-iJ?Qo49aeC z6q7fq$;lg&mzNtNZmb6!W?x+h>TlqQNNG{|etyzz9&AU&mkpz`T?U)NwI|)!Fusl_ zY*4JPiR~`D6^<27+1S%4+mlJ#e}UKHQC zu>DDF3t;=b*cQX~N3of({XuNiu)QL-de~kSTO(}05t~yF`TaPj3NMPDf9?i~1eZwz zNP|Bz2xL`L6>8{c&h`mt88NsH?IHwuH*|EE&5e;5D}R`qVoruz0Uou4%$6oBy;6?Y z7Hb|Zl6K@$V==zDa#7F5i_{UvsD+Y`(Q&VT^XHr=RMEVws_#uRqiYaB-z^`qf82 z>4tKYw~6tG8s`hO`uqE_RXRPC#F$m7q686N#^uf*Y0vD z4{OSfLbWR~6hwrgOla=7{nU+aO3!CShatwFQf?Q!{5<#SC%%)ehJBh~it%RTZ~o|4 zXy`N>#u82WG$SgMU4AAfDZ^rHcykGgm%sl{5 zQXl-!yHQOYe(uzi&k%m#Z9E8ADj1eb zrg`Y+Z=&sG95ib*<*26Y=GRpCx(9+be(d_ERd|NFRfi(RpI_%lDAph+hG-f;(*zU4 zn`XiHi(YZj7z>J-rulJmrwHzDO2d1WbWKa6e6C3I^0 zWsk=E*ei3~l#UB2S7Q7rJs&PEKSZ6I#?N%Y6w?!?ZQY=!ty`oiPfttf1;F|#Pfw%F zv4xvE2R?l-##c-;O{=DSVH)Kb@by!^Fpcs|!Ss?4%z0<+ztg3h(3EGUQN9RRKjoQe zlxGQsxkGdBw`)J;QvR@}JS&az#lZS0&q||A3FqcS@uvCew%d2Ol)s@V7pGC44XjJK z?~*D1R-8r|MFAM{oP%fiRcF5LQhriXo}($dC8|V1si_&3#J0V2k6WUS>QKb^OVnHm zRfsp^qM4J%Pbpk;b4+@|m{;ENWfwi2jTKC3T1q)Va8s%<1bh20Gz!41qbJO^tv^`l zQm)sO=ciF#0IZ+#{4|~y3P$n>wwD)P^9Psm7EO7fP#*a}*&<(D_rAFCiiK%$l?mn^ zyg9-%J~@7^8`p<)TxB{HZhkG6P)>ere(%Ys1Z*p5zNJGEgV6=PE#B3$L41rfXn_J^&q)_AZJ;5>Uk**UxT(Mo#7@S%rKLhJtQTxnC(VDypWIZGXv!67@~MqIl=vx%6YVp6gQX*OaR?Wj6<_CDbW+(+pjB=XczcenE#K#-Gv} zxcF0AmBvr4U|6C!BLDao&pXfM=NV18HZ7%fKFUA(NpwSP8s&PyaB@t(Pwtu8;!>W* zsRm5FP;To_J*q~(ZeTj_mpRIjj4O=>y5w-wLDPHl1(2bW?+{PS})*3LUq9Z-lcyFY41I zwoEWlydg9rzUdo(bS1V~$F(diFPbEjQ|j;o8@j3Gxmhq#yh-`Dr+*MdgEpFbH09C9(xt7lzoYXi=jHZI!PH8l@DiMEaS)OZ^@wv;;RG^wWO$ZEtgNX~F~ zuI3U~_@ey9xAbt(4TznPR6;qt+eZ`;rIe)_~lXgQ_w%Nw~z zykpp>-;xqq66=w4W!B%oa&EfMM35{w{v+Om&q5*XYf8FQrSp^v<_Ccc;El1Rf_1W* zUwYQrRbwu#uZWoh%2(V6@TqfrpuSY8VCedUtDll(ZiJgTJ%SnO%PSeK?bHeLvWhhM zih97cpPA|i%H%3S~tZQ|DE+e2U9UJMk@ben;Ku`AS7SQx`&CisfU<{-T(k z>&apuSL~Y7N+~LD^Uhrs)3)}GYudXv_}Ud+|2(w4kx3|gJpfyKDH+bjJT*{Tc}gB1 zQ}C4BJoYceNo=wSIl|@Cx+Yba%c_@F^IP?}?D?AZuFj6~g%T7l%{teT(4{rC4Fbi^ zX8A%iF$-17UF^7v=axjhX0$sZ=Fcmhqwu^V;$pcY;uF}RcrVANFq!U%=+e_wg}^(* zU7wiu81Dn_96g=l3R|YLR}r``(HL08$QdZlT~Ku7zjX{ zfOrMTZ!>V$WkGLemh|ob?vta?V|n>5v%5yU-5KNH#O!&PI zm?t$ZsQyj`?#~(ntC&n@7{|ls9o&od7=?3}o9M-Sy8yU_8XLr46u2s2HfWq%-`vSP zAaWJujT*z>G(qux2Dtyw*pcGh56tr#$Hf9wuKe*by?@de#z_+tZ!W;6FaS(Yye9n4 z1m;Q)E>pax0C$zfz$zvv-s^zd?V%TRCif0t{$1mO$^kdEf2J`y+Q9U_2;7?*8Rssj|r;3=K@!%u|f1$uFA8d*9=_SDDlo@@=`f5aLrwgzWfgA1&|#nxaobRVt3 zs5Mw*4bHU&P3ykB2yESVhrF@$1^b8bK3F@Qa)i#T)mp%_3iZpm@jn2GmJvEgOde8Hf!%W5Fw%`=88ru)?OHG+SV zhB3&w3cI#YWtvjD#7(>f$h3fKcu8N$mDK_}(psxf+3-{N<6q5 zkX2~6#ft2f zLMt}iZi!g2nRd%$D^_f`OtE5f?UrIIw!m&#V8s^OEsL#~Y2PO0GFEL{A4JSneZ43G z!fFii1>Xoo5`Zp!TH76G|9%Q9fRIfToV zc_L@e_QGL=-1Qp5C8A{qx1MfSEZ9AXR2S?nG;86!^T`AnpKJbSxM2Yt0XcJb>+sGe z2PPe?C?@fTP=6{GwAHUg^oSa+j4Q>}DQAu}5)26gsMNSx*uj|;WnH4tx`m+DtaL)b zu-!0yd5cyDHUU3^2gmRuD!CE?H_r4X1Z*)pVdDb4mx*l_-i>&0Mx`HDbGP^5hVAZn z^xTf4^-J$-b<27wwQJ3E31 zDrODd((G*FPo50aXK)L3*HE$#$HCZnZ@?3l18*#F5kt>9m1aF$T;+FI$*wfB`l#4V zEV;-7_aNMKbrdXO-%2lgaJqdBE-pB^H8#9_ihBYLnL&NMtMP;lxyxKlk8!Od?pE%C zGj6q#x4fhTFeR!^r{}T%GU)*z)n(EuUkmYD36yGR%&v%mZ%U1Jm2@wFh!AzimO5?S zmaN&H(h86?)%+{s!C!VxEUd)4nT;QC^&56xP8`y@Ni*Upu@V!*usfh};$Y{LwWhM? z6C>1BJ{C>o#BE`!AHaBZ3z#FhIm}{~q327_Lh*MvqYI6?ikdbyddfsqZI)x{j!S0_ z=b@6v8m0bhPX1yj?=E;Qd~$Ol+W*3{cH-ol6P}q*LyU5}n?J<}9nV4nIaL~31sdUm z!396sg&6<79rvaE`*!IUYO^*g49WcHqK~81aX7r6PB39Z`0;2rvUIqVdChbHTx?r%bE0_D-27Vc``ujTX&#z! zX{liQ<)=I@jWXr!QhwntKm3MEnfu)|qvl=COwMUq$28vTQhrKPcJz{6X`BkIpXYQ9WA-?%cH?6Yp7ukR@~fJ%y6D-vBzIaG z<@BqTCkti=-ZTq-{`e7>^2xfWPfnBb>A<=?Z#?`TZ%s~fnpzjRIaBebdG?)ihTK}YTvH~--;Qx8o-5boGt@7Oo=3HC>hiy83o-uo zhdM)UN*`bH{GZZwpgB=c^(z;)b7szb#ZBpVHDyOr*d# z@$(afi_6dcyU!U&*Kej|6h9<$+k5vQrHX( z^D|9CvCK1ue=j@hj;U!Sp-3>M#(efOe<^nPxk^(mO5^8T3FY*}kNmFYahIPD>rlk_ z`Jp^r`Q%J{H_qy$wp!;4CW<#prn)xWkcZPmlvmfpOnfFaBSe%eT59&O|zk1Z{^nc z;qskp=N9#vAip*!h2SG=(Esu5GB-C>HJF^4l$WZt6}8*P@wBs3XGFzacupC!71?$N6DkOc?tU9T}tzttwaJqpH$uTH074`?%P@a9`aRf5;mjUHB_2{Z;^Hp6qM*L>I3SL!bR#z;kH=BC6 zfsE2zUaF>|<=9zvCZn|XfWQ6(q6N`*nWCmAvAkmST=zTgE3fU1o2Dvb{CGgKS=or_ zoK4SCz3Ev|0iwyz#QXDA%A)$He99L(U9ymBb$wlpDV0JIZPT+%Ee3Txe;Q@y>()vT zF|)a;ww7rsFO>jP>`)?~r|G<%@8=?6>bs2T(n1sB`&P12XuO(EJiR^4-QJUo4t&}12pYAEbOV`bw|9yj2xv&g-Ch%(mB776 zW7*HhYQ1Oj#qjxf?gr+w8pl7_oiM#$K_QMU^LOC6Pvh7%3eGcmB92|gBfvO=72<++ zF(+|^R>T}IU6Y*gqw7HW9`2fju(Sb)t6t2Uy% zWlJGnZj0fhJ}iS9PMjk0i8kgcC)BPff>rGUa3bmYal)#8nXu6yXPLQreH?oym`vbY zJ@!#DeE^Ti<^VS$pNHdgf&BPxV4&#aemyMPROBC&pK3`z?d~29m=y1v61&uxGOuBb zYLB2Pvg_f&D7FghR$PX(_&r0z!-)d(uGa?(8my*>)vE4P;#DQ}p$4ly#LGqa{k`oc z+9#Ln+dZbzI{C#Dl6OAf*!)1D-9%zmXt&)IsQ{7WEl^7lD+jA8g`F-#A}>l&?b^TAg2B4sPB6IC z6|{&Jm9RJneM1;)at?=|hAWL)M5FBhUt)wqPtTACS2r#~f|k{y@M8>z?|S(sZeBbF z7aFy!=3UOnei4l=I`j4;FGSD~&_?q=>W^MTYvbZKM)JxrH5JTFe=35O)!5oIhTY|V z#%h=oS6ExJUsk&SAuzr1)&vvk(NOD$zBE3=1+_`h0`*T$>il@`grTiw1i$%yzj>7$ z#HP<*e6s`vY8xR+?;NFkwm%B6CIirJOrff9Pl=i4UC&WhS5ME??VIB59Vz~h1QmZV zY9Dv;!qVi}ik8vFUGwKHoTmbC+*K^&E)!kFZsZzGrg7IDEXH0Fpk?=M;2aG)*0P{+ z*LDuRJVw5_oH9P+!oW`8zNoS6UxUV7g{TaU1|5r9rg0a0!wXqyJSJ!yvIsb8(9w)U zZ)KMBI)F=LL2ocidba}i(JbgWntduIIzK$E6WuA7dqL|^7W7iJ`-0?0?Y_50p%+EG zVPvYKxyQCIh~6ULmaqW81m(v%_^kxy-!+c?M-aUyf%)Yq^eC5?GzL~NLG<1Nu7Hgs zOb~y)@S6n8O&T{+dOrlr=SQIz1-*aQ7+A#w@%KaEUdV!;quDnaz3~|Op2guWOi+4v zz;8M*pY`B^`1=|#2Ryh;_4jVj`@Y7&Dkg|t*GahB6%S1ifA_%eCSc}q*9L~;1VztX zl%_k!&TBP>ziEQB*tP+8v&II+8%6l{rO*pX$Jc;6FbX}E)9+_Vk6LjrWkK(?Ea`=@ zcQuLoS1>{8ErwrIV+6?Gg|T(su?*drju>$3MxjUCW?-)K;DYGw1m+G8E>pRRg5F1g zxliLps+Ug!^UG1_F}*JVGlh)8P%c6Iod?W35AGP}yY{P_L(s9qWH!Xrn;S#ix(kbzD>oG*29-M0Ou7v=5(^vM zcyl98CPn!Bi|^r;wc&=8ntQV`Q{Vfj6B`?bMzJxT7O^poRrcx;XJWL@tz^J zBD{;mhL>>*UohxDSQPZ^-EIikIm6N9Y>z&vgCf$FnYpWX0X&gxTfBz65E&U2NnU}3 zx{+1kY7>!`(>1Yt(J(EzN!R(Zx#pC;pvnVc9FCnZOtsAZC5J~^nOF>@TA5I)I;6&J zAR15;g5(I)a4qCPiAadLl5EB;%k0v-@x1H3x*E9rEV(5;*BWrgb|A>X)FVkcp}D1ye|v^PqAx@?53Gz`>#1eD>1!zvfWf< z*G>l}&rx~hP1FN)Fv^n7QZt!)L3=`bE$GTs6xLf6ga^7U-6TY>TEDdaJ*QP|IXMCGWOvahZ=_7$k|@Q zD?ur#>5xZPC zuu=p%-)14QYbVcmx_M8*ZQrI$%l^Fm6ni1FaRD$$MP+l@(}TaYap`&OQ}(|xM!wq6RFM0`j33*N zSnxUml6xY1*q|(r?SFI3{=bazxAOP`%_hdco9T-n0yG_kLkFR1J$X;TSN23chJv@J z;Js}B(bU7wYAQne54}ya|E<$i%P$nAy+>Q0el@rW@*Q|0QaU!k7B=?aT`0Eq;jLPD zoUZHcNkrvF9DSkgdeOrM0;f{&=<+F@!8-g_Egkeop+P(sO>T@?7Qz+z$pQ|LjL7&G zp@jhJ2}}1}UvVZPwcTa!1LO(F_pvAj>xv`@&_j&62{31=*n(y3f?_qE+m26y^Q%MlUq4{3evtG}vSjpRz zvBCiz{8`7lp84%BO+PHG1Skb^-QnwJF7vE(IiA3)JXZ~y#lNQ^`Ibxrwr);t}`Pv$*^)l`S_6ck^Y<53)RD1YJ;WtL0X)RePd z;qC#gjz~QJ^5LQ{=q4M#pwJ04$IaYVvx#1$Qv!*hUfIV7#1OHZTpgt=_$FF);a z=qM?UcIhcY23>lJA}eOx4PV2MBS-&Q!fFZQTzcyA%z3Au=k)7K&rf1V;}iSe@sdmV zdQDj=4tmQN`!YY}boIUq1XE11Fh70voGV<)AJmjDfE4{b+J(USDPNGLI5@+H`S!1# z`HV~X8=CTrG|Dr5q3{EOl{FN$~@}rvaMQN000qf`aqBP1E z3x?8QzFqtE-^_CVrw`!Spcx z9k!AD+oX<|3(WNx1uiJ|8>)=WPY*q>(&QkfD>2X??+{fi7h}3sCjrZN#Y~`1mYRC3 z=)5kTAt=%z`)yk~yCv!UBVeFxh5Io^f~^sCOQqbE&L-k=6};*)`o}7?R;GUoF(X#C z5wRP3S;ZRe7$)`AGJ;2tPhWg1u6fIxZk3=d?R{5g_7~YH0mnN;GMRA!(TlivHQDl> zo-G+d@;(-(4SS`yZA52xdiorgzN2I*^yXsAOf?I|MKo-n%e8KwqqJHiI)1MDTsl$g zv^rdCbvbI-&JiV1SA{OCa7;p9e4{6Uu|yy0U8PE0M?90KPI~!lHwqO>Zy=X@^co$H zH5HYu#p)8TOukNfQWO`lnSAl=IX-p0(e{!{7M6PUl24btF2{whm)lh9F|$Ib#~ zB>swl>Gj}((t8~+yFIu}=_P-60P}zc7ewz-V4n5hGSTY=y(1dKbkGFRTZ0AKOXw@+gPh*uE31He5w3cYm*|FbOVEymQT5f4oee#YtbaM5pOqyrQYz&O29#y2e-i9MS$%;UpMwLTQ|xW|E9^7M z-n@JuA5ldt5F_C>Bu8kH0>^JOpd@V{cgJLH5g(kq7%Q=$qgUiQ)CuNwb`!s#TX2M- z)LPvp`iLA5{v!CDhDWU+Vrj}TA_w|7abWj>`m(5bA3Kzep10 z`T^&6iY7;-*4yP!(!M(uwSv(7Fufy?B-C};lxQQ zPF!o!TY&Vf4cX24a6VZ@i3RswXqK*RyZn9&TBc%2F1Iq$)qE)X`3F8~+&!QZ=AAc9>+?OrJqjI!F(Pz>mb@V}w=4_%n zzT&5(&gfa5!bU}cH>u+D!aeeJ`mKGPiFmZ5XKQz~x2Ll^!5dY&qZKPwR<`%Y7cEL~ z2uDhyqbwHvVqHQ!*u@;}{CqW#VF_O$HnyB5o`|gamy1nDINBL{ZU|;rq8^h`m^emh5CFFqABK(p9iN9(=+B-R>=>3zn^hH^QRwqeeF|O?R z!J97SbLa#UGNPdFrOe*jPdSt}(PR(mo~xbl+f5$IH6#mjJj=Z%!czthz1IF2muIJP zAJ1|x3oS^ap< ziLcX?uYY0d(=O#Fwd?Vm6E{JFavu8abA2x5ziP^(ofH4#!VC6{v~Wwx|MlD!+oe30 zPB2`!^)Jq;h18qZ?`+o@n%i)pNIW` zrhJ<4gT?rgQm{Zp2!_gZ9`;yIb591H+#C+bXukQ_7Hr^1Ta8~|)v*)fPuJ;ianpq# z;DaTxb{f14QU6}bh2z4wHv&7kE64KYxlNbTf z+ZXTY!vxk3;e@vXcggqlT$}D8y@l(%!nybwvGP9Sj)7j+Q1u4@~S zw0H-*AJbHzWGVzpP`u3%KzbOJ)YfDmkq8c2_Vgv1uZj0bhu6HZ8a-Z2b$C9WWKlw` zHdNP`%}bjbP2FR1odG8k9TMfG>@;zFPl!OdT(1o|689|$@kC-JZZ&RR2674!bnx%u z*>mSAU2gSu=Ii=kUD7Lg=5BWB++uO1?suON$C5n?R*KLPUywAIuPCpK}#&P)TF(z?5PU>-Eb3PHcN{wZ=DDxK2&M4uHc-8^)MU7*% z3DObY4A1Lyy&}7r=4ny5?*!(P9$e78@5{j4=fP#7R|tBCGzL~NLG*qM+>ue}MM2^B zz)Zwof`$!45WVw&nWu3<>D`C$CNXR&VK@L#^!)Qu&axJ33~@9;^TYQ5_dbmciZ_bz z9|q<-8aGlp9tY+ZqtIh{`HjZFDkexSXP^(bko^Em5PzgM7nlwYPUxkS({;dgYYePn zg5rG?xMw}|GL{!GbOe~A>`h>T@`L*kbJ+`cjLHvxzHtt*E+fv}=^+W0QyaK{)z~1p zn81B1geFIX#C7N^cAv1He3}Rc)Dlia&onXFfgbsC|(jOs4jL zON)oIz;WRFWR|$6vcR1PdOytqcLH$#odu5KcsUCk+s}e1ULF(FZ%vG1trQPUP=2ty z%#0ew6?kZf3o0)gqd04ihbD-g3BMgt!`O$1W~BP|!zj-1;GqekcMtqtj^aGSRH6)n zYnGYHi;Snv5lHftsk{(3Eh8?y|2Pl0c^VtU-z)GifhjIh(Nd=^6Mtjieuu^=WajeB zuH*d~aq0Yh8Mym2Hi*ApfZicsK6|c;mE+Y+{87{3sKzLy!(V#5=bVR22=UMa#rq2U z76UW$e1XZCgP?MC6EN@BxFC8_khvR}eHxb>KYMh=7*iphXMuS+3wlR^nLM4LFxA8p z#NRw%YBes1Kh~odFgvoK_fcTJJPN%i=-mszu%2dX)tPNP;IQC@VrfO_Z zIw-#xDfEKmQU=`8QRv+RdaHmL%K`=yRDU^5c(29?5U))2_Y$~&C<|OEa8GA}W4$ck zpweT4+SBpCou#os@-snaIxw3w&MjB|e50o0O&a4w9Te{!zB3}lkn*(W> z0z8@O`8c@$N@Iwl$s}j?N3UeWrMCy;FM?d~&;;?vaxfj3A8T9?e;hu5be8n~2e{W$=w-Jr zn=>YqUl=uaU_Z^S-KLKZ9--XqTR(}nbE!*ya-UFbT;;=$lkTu+B6A5w?b0Y4e*R4j z$G+<9-&CQv58y7XkBb&l<&;IFRLKC!VR^L7e#|NfuE zjTM=c!m@M5wlOR_^S6j?0p3+&Ta0(T*i5{CCAMn3pAZ{;9u^y3(9293#HMt&)$Shd z$1WOrX!7Qq)+6*-o7@zHWdaM%IkLA?5?}K=Yr}G_&55s|{RIj}JK*W3e z2D0UpRFz&1lFPsk-gvWiwr<=B8*ak7ktN!?aWCHPe!J4ENEzHpy7P=x z_DgIemgU>w79KELaIkg_BVzeARQbhmB6wPdAzv#`2kjlF~1T9sG0 zN5Z7Sz){)&{sl)Is7Nj4JyIy61@=!6_q%o6e?r_f=6zCfs@B-cs;#9R_Nsbo#U{I^ z(W*+=RiUznwokK{M(n@NIBK7~dU$!nF0>EvEZWj-wN~|4j}r3A;Lq*<6j45GE!}R} zI}oQm5G#4I>{aXQbf56C110;)-k9*QePss{%k3eip=^JmzUfxpu$fgK2DDs^QfQCow_J(PX*sa@mvsi0_ zH-I&5Us7LTwI-(Rw`#Y0x+zkg&zCY1$12!SDfa6FarF^)&$Cn$6ra*Bj+P2opIViND>w;#}UYoFm zgQ|*Yhpe>;haEYK$9~ir0|`x5vN=MU5FSrlPqA{WMNt1)OOb%9n|9EzDO71T zpwzV{EOBTPCW(<|Nxj&Sd=5{pfla(Si5{Cwyp;PDMKh7`=|c|`?s{e* zf7kGYou7o?(DtHe&On}kUo1_HA-%gPaPl6xGdM9N4s`p_z?0~9?Hj~5SwtUi%8RGl zO}%#HuH|X)0uppWw+702|X4Hoamkfe#A`16dRm!PM6MN#1@``4&~HH9m3@5ht{4gC>@ z2`JIKb2&*gZmupmWp^W<@Xq~-)9qEgcIev~sz+Vzjeiwp{|~#^sG1TmPI;jFb`FT_rs<_M6WlZ@5V2zdf=fbk$KX;a}Mp1XsbQM>b4q9?c{7+PNz`}z|z-mqV{|C5~A zPrwoP$3D`$|JP$M^nYaN`P@Hz60=ERR5im9`)Jl7?W*neiqMihjnjwis%_{=LN{}O z1&#H?%boE=VzM}4LR`bkM2_$xj|sP~8Xg{oT6)9|BT@Ko558rOXZrY|#Kt1I`sUYm z>s$6b3!{<2W;Du&y(1CT_|w(OQ_LeEbmNsfW5f>(;jBp%jN(P^&AIY&l(G8(n6k=V z`MI|c9@7lUCWsCMYUK=k-J12{H+09w!SF?RB68D^vT-Q=0G_aMJKp=n#^0(5os67P zgMc2`l-rF-+b3b02yDc7IO!HOYAYHV7m2d*#;%^Nm|Lh*Wx(M~C2%Z z!P$qF+l81X7Nj-|$Ov@25oe^?ww8lx3`a1imXT~#<+LX_sFojVWu!)bcQnxij+N}% zU}K(zjm=57?MWN!@b|@+by(GAc3`SDe;zgtyCNg^1Wtc}u4Ek0hVhiVMds2UJdEGL zLsSf6FgR6182=D;!Y+2QYBagpmM?qO>7kDNuty&1WS0%7Gj_pkc45nE&eccF3XbIq zFfdHmt)U8$yaoHMJHTkgl4*~qd5)aomg@xv`U0w$H+*a^p*| zsoeM)Y$`YQ!=`cr7UOq(!9c*$V?6;o`p0Sjmy-M$u#u~XAi6y_sfL ztbxNgTb5MeFfm=q$pzK(K;;Ax> z-?o%eRbkzC3vj#kS>ib1)*<||YZYrwN$YbvDz$<+Vp$VHE$K7J+BK@2Wk_gx(tWF6 zy2h7-HC51Ju&IJ}dD5*Hwus1R05&Bf7B3|u3$~NR_tvB@3zhO^AE%1f-AUh1C4E&f z;S4A)=ao_lL9zrOfbmtnU=WowncP28eVs?>4X(Iv1~ygPTaR7b>@q7d)$L=Exm&5{ zf-5EI8m2|$Mwu(O&9Lznq_EKgo04<_HYH0IASG$0P5JIg`rZkflJtj?z8_2a@?xvh zI_4Aa=K-Zb?D%gO+>}$zxqTbUajX4Rww1XL?Rrw}P$X)1y>>$ps@J8qwHH3RQ}H%$ zJW+=>8H?p-*s_n2)YFqj2O7_|M}gfT~w8zhX2#W&-OQkv~-M55X_?|#5B2xg`T zCfS>zocbMy3)eBs|-VVKhH51&bc|PS*K`(8~!fs zLX7_`Qy4D(vrOqH74rlW#T!{^bX{475ud}^m*GN_C#fiEoHJ)0+Qf*sux7V)^>kmg zc?#~NnN*k)(=A(K&*bFMC;5hJQgYl%~6#l>63 zPDSY4oOO7M=~@9I4xLMMs8dxaPwAZmuq)MTzkJspPfe5RX$k{kED7Ij|GUjLcDa49?2tP$fcKWD(jO(}lp6OUdQzC$o3Jz@Us>F0myrt}Oph%oO+li?J& z`YFF7O@^GP=H^84ruj^(iFFtVRLp!$`OGxRXTjf3`OGxRXA8zDnPcL!LCvAe&$rQ> zoklqdS3l*m(-K^wi~Q%`+J(J#RP4l5+kW}iBS?{cRQ=KwDab@`P$j} z>e6*9rA(KdahaCwwmVzeS^*7K4I(NDA2#v_jjbWX*r)`8n$!f;G=U}({}4+gG=3x| zZDT4B62;%|yz}P1J9nl9dy{#)bMN_`d(OG%o_lBJzVkfgocu%aX~X%La=w)0b&+q3 zUi-@9hVvhl^Q9!Oqn%m4eEGiL8qWVw&KFBwchAiS{~ji1ffFC`Oq~E-v7UO(GIj?s(ZxB?(dHUrQKU(i_=I%S0IEE{CW-mOw@){%a^U67` zoQ?N-g3`b@v?X)uu(9D^6-64`@)-;D%HO_m-k|=gDAL%L_XQPcab(>mH>4dc0-@n; zJ>1=1R?J{qhc{9_qSGZ9TGb;@7VTyZ9v=SsLq?uaMUlqVA}1*BF<3r!=FuYtRZtXZ zY%TJrF>&?s>O+qQjur)>c@H0KXc2Rk>|Y1Q&M@1KTirO8ZW%TX(LYIc+A9 z#cK`cQ7Vs87S4@M?=CJrD=VP0wJ1A%RfT31uXx#gO=(|MM~j-E;#yQ4&UK-=K{-G0 znGJ}L3A|(3t(@x)=Z$DJG9Ufw2X3u9ocaAvXdf<3cJ7Y{mGhKv#^=g4V+i?-f<*Pp z{Sn{g-Xxqqh%3u|=MMcM<}J#ZG`6>FLXDA`$SFtW=`Ic18?8A+{>U1ql=HM>4Sv=) zoKGJ;xnkPkjIa)xW4JO#ZF#A<({O&TE*dk+*~F;Lf?A0y%U3q+i>(gp6-63*c7G8y z$pqsq%TH>*zuwqqK~bc!Q8%L|nc!;3a^~zE-!-V{;di95QCm=B;?HHZ{pSqowDv_B zdn|4d)Rnl>x}SJ#%@1cBi)|Gek5|0B?-YM*EcTXi-s)KFRzdMIGRx+_9Dl>eb2S4i z3TbS48mKWNn0WU4zufA`vrTA@<9Y>NA3pi=V@95ga^B|1Gb<=<9(rc_?$`*BdH?%X-fvJh za8OZ5V{3tM6B`TC>~OSL?9#B^PW!)IIWMXfX04>wW|WCsbU5?7&ya@ge|qtWgT_Ah zE9cz~=cO(xK^V$z;rtX3=~ksPA5UK#WfUI4vs^Pn>D$^!iqz2@%dxf`+B5-hREvy3 zk_{={2s22>>buFK8@br6DViUtUtVcVy&bU__mQATzO!%ecgZkaany($+hLk%e*53x z&#Z1c9?=`?_@?FAWn^dakkjcx!iEXSqi&FwiD{OFjpUP7t9eBfvig5hHupT$m${a5 z1#coZQH$%59!rnKR7j`NYtt#Yvj?VW?`$I#R&`T(Dw3Azo0x7&e&U#FK{mTRN=z+A zwVPm1Jjl1dy&4U0!WY$JPuR8bk~q=V{fND|4w)d1cN_77%=VjE?USGF=AarmWc5Haa3d-m1!Km=!pSg z(lpU4P87@g9!(5VitXVx`*-%*m9Ye!2_rPyhLMzL{j>Rt-E;1UNKc^`j`*d5mmW`t z`Q5|1@j@xcc%kFcWjj{uSaGsYLu;RwN{|IJI((cR{5+@tF`O+6Do|t)q*FM0ZP9)% zSIk$zLQi8`ZGO$G)T_S76WU?-O@yCRcuqT=YAr1-E+KpUa&ISbSyIJ`LXM(TaF82+ zYT5%vy3y(xJ$QOwZw`k6fM%yDe)e6D4u%?$jR9QdaAWU40bp6zl_d`$cMJMJhG;@DOCo|!R$QI!w&|kg zE_`%AyAZ@4P!aK$SqF8y*7tFHQ{69wYzCzvL^{KzPHRa5Ky|h^k~3oap~SM96u5QB z_TM@9{Z~SD1qfD{D8tb?ODAMC#hijaVw&LO7%EGamt?D6HCqoIu7|#RtPH%cw$EZQ z-rE)HSg+y?id$J6I8Iucwk|$@O;>&l3Cgq$&^a?{G|H14{ z$q^ngc)l6eXK_!@CdZM)uX=t^$ap*$bZLFnb}hFTdlZLPMbD*S$O({tvx@wi_I{<= zyG? +#include "PCCTSAST.h" +#include "SASTBase.h" + +/* If you use SORCERER alone, you can subclass this to get a nice tree def */ + +class SORCommonAST : public SORASTBase { +protected: + SORCommonAST *_right, *_down; + int _type; + +public: + SORCommonAST() { _right = _down = NULL; } + PCCTS_AST *right() { return _right; } // define the SORCERER interface + PCCTS_AST *down() { return _down; } + int type() { return _type; } + void setRight(PCCTS_AST *t) { _right = (SORCommonAST *)t; } + void setDown(PCCTS_AST *t) { _down = (SORCommonAST *)t; } + void setType(int t) { _type = t; } + virtual PCCTS_AST *shallowCopy() {return NULL;} +}; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h new file mode 100644 index 0000000000..558f6a572b --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h @@ -0,0 +1,110 @@ +#ifndef STreeParser_h +#define STreeParser_h + +/* + * STreeParser.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Parr Research Corporation + * with Purdue University and AHPCRC, University of Minnesota + * 1992-1994 + */ + +/* The programmer should derive a class from SORASTBase; SORASTBase defines + * the minimum public interface that a tree node must follow for SORCERER to + * be able to walk the trees. + */ + +/* The @-vars are added by the subclass created by SORCERER; the constructor + * is used to init the @-vars. + */ + +#include +#include +#include +#include "SASTBase.h" + +#define _DOWN _t=(SORASTBase *)_t->down() +#define _RIGHT _t=(SORASTBase *)_t->right() + +#define _SAVE SORASTBase *_save=_t +#define _RESTORE _t = _save +#define _GUESS_BLOCK STreeParser _st; int _gv; SORASTBase *_savet=NULL; +#define _GUESS {save_state(&_st); \ + _savet = _t; \ + guessing = 1; \ + _gv = setjmp(startofguess.state);} +#define _GUESS_FAIL longjmp(startofguess.state, 1) +#define _GUESS_DONE {restore_state(&_st); _t = _savet;} +#define _MATCH(tok) MATCH(_t,tok) +#define _MATCHRANGE(t1,t2) MATCHRANGE(_t,t1,t2) +#define _WILDCARD WILDCARD(_t) + +#define ast_return(t) *_result = (SORASTBase *)t; + +#define STreeTry(r,p,t) \ + (p)->try_result = NULL; \ + (p)->sjrv = setjmp((p)->startofguess); \ + if ( !(p)->sjrv ) { \ + rule(p,t,&try_result); \ + (p)->try_ok = 1; \ + } \ + else { \ + (p)->try_ok = 0; \ + } \ + if ( (p)->try_ok ) + + +/* Used only during TRANSFORM mode */ +#define TREE_CONSTR_PTRS SORASTBase *_r=NULL,*_s=NULL,*_e=NULL + +typedef struct _Sjmp_buf { + jmp_buf state; + } Sjmp_buf; + +class STreeParser { +protected: + int try_ok, sjrv; /* used by STreeTry macro */ + SORASTBase *try_result; /* tree coming back from try */ + int guessing; + Sjmp_buf startofguess; +// SORASTBase *t; + + void _mkroot(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *); + void _mkchild(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *); + virtual void mismatched_range(int looking_for, int upper_token, SORASTBase *found); + virtual void missing_wildcard(); + virtual void mismatched_token(int looking_for, SORASTBase *found); + virtual void no_viable_alt(char *rulename, SORASTBase *root); + virtual void MATCH(SORASTBase *_t, int tok); + virtual void MATCHRANGE(SORASTBase *_t, int tok, int tok2); + virtual void WILDCARD(SORASTBase *_t); + +public: + STreeParser() { guessing = 0; } + virtual void panic(char *err); + void save_state(STreeParser *); + void restore_state(STreeParser *); +}; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h new file mode 100644 index 0000000000..9c7fd693f2 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/astlib.h @@ -0,0 +1,72 @@ +#ifndef astlib_h +#define astlib_h + +/* + * astlib.h -- C ast_* library header + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ +#include +#include "sorcerer.h" +#include "sorlist.h" + +#define MaxTreeStackDepth 400 + +#ifdef __USE_PROTOS +extern SORAST *ast_make(SORAST *rt, ...); +extern SORAST *ast_find_all(SORAST *t, SORAST *u, SORAST **cursor); +extern int ast_match(SORAST *t, SORAST *u); +extern void ast_insert_after(SORAST *a, SORAST *b); +extern void ast_append(SORAST *a, SORAST *b); +extern SORAST *ast_tail(SORAST *a); +extern SORAST *ast_bottom(SORAST *a); +extern SORAST *ast_cut_between(SORAST *a, SORAST *b); +extern SList *ast_to_slist(SORAST *t); +extern SORAST *slist_to_ast(SList *list); +extern void ast_free(SORAST *t); +extern int ast_scan(char *template, SORAST *tree, ...); +extern int ast_nsiblings(SORAST *t); +extern SORAST *ast_sibling_index(SORAST *t, int i); +extern int ast_match_partial(SORAST *t, SORAST *u); +#else +extern SORAST *ast_make(); +extern SORAST *ast_find_all(); +extern int ast_match(); +extern void ast_insert_after(); +extern void ast_append(); +extern SORAST *ast_tail(); +extern SORAST *ast_bottom(); +extern SORAST *ast_cut_between(); +extern SList *ast_to_slist(); +extern SORAST *slist_to_ast(); +extern void ast_free(); +extern int ast_scan(); +extern int ast_nsiblings(); +extern SORAST *ast_sibling_index(); +extern int ast_match_partial(); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h new file mode 100644 index 0000000000..a8e14bb7af --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sintstack.h @@ -0,0 +1,61 @@ +#ifndef SINTSTACK_H +#define SINTSTACK_H + +/* + * SIntStack.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ + +#include "sorcerer.h" + +typedef struct _istack { + int *data; + int sp; + int size; + } SIntStack; + +#ifdef __USE_PROTOS +extern SIntStack *sint_newstack(int size); +extern void sint_freestack(SIntStack *st); +extern void sint_push(SIntStack *st, int i); +extern int sint_pop(SIntStack *st); +extern int sint_stacksize(SIntStack *st); +extern void sint_stackreset(SIntStack *st); +extern int sint_stackempty(SIntStack *st); +extern int sint_top(SIntStack *st); +#else +extern SIntStack *sint_newstack(); +extern void sint_freestack(); +extern void sint_push(); +extern int sint_pop(); +extern int sint_stacksize(); +extern void sint_stackreset(); +extern int sint_stackempty(); +extern int sint_top(); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h new file mode 100644 index 0000000000..29f77029ed --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorcerer.h @@ -0,0 +1,172 @@ +#ifndef sorcerer_h +#define sorcerer_h + +/* + * sorcerer.h -- header for all sorcerer files + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ + +#include "pcctscfg.h" + +#ifdef __USE_PROTOS +#include +#else +#include +#endif + +#include + +/* SUPERCLASS SORAST (your tree must look at minimum like this) +typedef struct _node { + struct _node *right, *down; + int token; + -- user-defined stuff goes here + } SORAST; +*/ + +/* Can be used sort of like inheritance to get the desired struct def */ +#define AST_REQD_FIELDS \ + struct _node *right, *down; \ + int token; + +/* C MATCH */ /* MR21 Short circuit on null pointer */ +#define _MATCH(tok) if (! _t || _t->token!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t) +#define _MATCHRANGE(tok,tok2) \ + if (! _t || _t->tokentoken>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t) + +/* C++ MATCH */ +#define _CPPMATCH(tok) if ( _t->token()!=tok ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_token(_parser, tok, _t) +#define _CPPMATCHRANGE(tok,tok2) \ + if ( _t->token()token()>tok2 ) if ( _parser->guessing ) _GUESS_FAIL; else mismatched_range(_parser, tok, tok2, _t) + +/* Normal DOWN and RIGHT */ +#define _DOWN _t=_t->down +#define _RIGHT _t=_t->right + +/* C++ DOWN and RIGHT */ +#define _CPPDOWN _t=(SORAST *) _t->down() +#define _CPPRIGHT _t=(SORAST *) _t->right() + +#define _SAVE SORAST *_save=_t +#define _RESTORE _t = _save +#define _SETLABEL(u) u=_t +#define _WILDCARD if ( _t==NULL ) if ( _parser->guessing ) _GUESS_FAIL; else missing_wildcard(_parser) +#define _GUESS_BLOCK STreeParser _st; int _gv; SORAST *_savet=NULL; +#define _GUESS {_st = *_parser; \ + _savet = _t; \ + _parser->guessing = 1; \ + _gv = setjmp(_parser->startofguess.state);} +#define _GUESS_FAIL longjmp(_parser->startofguess.state, 1) +#define _GUESS_DONE {*_parser = _st; _t = _savet;} + +/* These are used mainly by the C output */ +#ifndef ast_down +#define ast_down down +#endif +#ifndef ast_right +#define ast_right right +#endif + +#define STreeTry(r,p,t) \ + (p)->try_result = NULL; \ + (p)->sjrv = setjmp((p)->startofguess); \ + if ( !(p)->sjrv ) { \ + rule(p,t,&try_result); \ + (p)->try_ok = 1; \ + } \ + else { \ + (p)->try_ok = 0; \ + } \ + if ( (p)->try_ok ) + + +/* Used only during TRANSFORM mode */ +#define TREE_CONSTR_PTRS SORAST *_r=NULL,*_s=NULL,*_e=NULL + +typedef struct _Sjmp_buf { + jmp_buf state; + } Sjmp_buf; + +#ifndef _PARSER_VARS +#define _PARSER_VARS +#endif + +#ifndef _REFVARS +#define _REFVARS +#endif + +typedef struct _STreeParser { + int try_ok, sjrv; /* used by STreeTry macro */ + SORAST *try_result; /* tree coming back from try */ + int guessing; + Sjmp_buf startofguess; + SORAST *t; + _REFVARS + _PARSER_VARS + } STreeParser; + +#define STreeParserInit(_p) { (_p)->guessing = 0; _refvar_inits(_p); } + + + /* S a n i t y C h e c k i n g */ + +#ifndef require +#define require(expr, err) {if ( !(expr) ) sorcerer_panic(err);} +#endif + + + /* T r a n s f o r m M a c r o s */ +#define ast_return(_t) *_result = _t + + +#ifdef __USE_PROTOS +extern void mismatched_range(STreeParser *_parser, int looking_for, int upper_token, SORAST *found); +extern void missing_wildcard(STreeParser *_parser); +extern void mismatched_token(STreeParser *_parser, int looking_for, SORAST *found); +extern void no_viable_alt(STreeParser *_parser, char *rulename, SORAST *root); +extern void sorcerer_panic(char *err); +extern void _refvar_inits(STreeParser *); /* MR15 Kevin J. Cummings */ +extern void _mkroot(SORAST **, SORAST **, SORAST **, SORAST *); +extern void _mkchild(SORAST **, SORAST **, SORAST **, SORAST *); +extern SORAST *ast_alloc(void); +extern SORAST *ast_dup(SORAST *t); +extern SORAST *ast_dup_node(SORAST *t); +#else +extern void mismatched_range(); +extern void missing_wildcard(); +extern void mismatched_token(); +extern void no_viable_alt(); +extern void sorcerer_panic(); +extern void _refvar_inits(); /* MR15 Kevin J. Cummings */ +extern void _mkroot(); +extern void _mkchild(); +extern SORAST *ast_alloc(); +extern SORAST *ast_dup(); +extern SORAST *ast_dup_node(); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h new file mode 100644 index 0000000000..08c1ad0e1f --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sorlist.h @@ -0,0 +1,52 @@ +#ifndef SLIST_H +#define SLIST_H + +/* + * SList.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ + +#include "sorcerer.h" + +typedef struct _SList { + void *elem; /* pointer to any kind of element */ + struct _SList *next; + } SList; + +#define newSList (SList *) calloc(1, sizeof(SList)); + +#ifdef __USE_PROTOS +extern void *slist_iterate(SList *list, SList **); +extern void slist_add( SList **list, void *e ); +extern void slist_free(SList *list); +#else +extern void *slist_iterate(); +extern void slist_add(); +extern void slist_free(); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h new file mode 100644 index 0000000000..fe80598977 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/sstack.h @@ -0,0 +1,46 @@ +#ifndef SSTACK_H +#define SSTACK_H + +/* + * SStack.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ +#include "sorlist.h" + +typedef SList SStack; + +#define newSStack (SStack *) calloc(1, sizeof(SStack)); + +#ifdef __USE_PROTOS +extern void sstack_push( SStack **st, void *e ); +extern void *sstack_pop( SStack **st ); +#else +extern void sstack_push(); +extern void *sstack_pop(); +#endif + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h new file mode 100644 index 0000000000..35be33e6c7 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/CASTBase.h @@ -0,0 +1,45 @@ +#ifndef CASTBase_h +#define CASTBase_h + +/* + * CASTBase.h + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ + +/* ONLY USED TO C COMPILE LIBRARY FUNCTIONS; YOU CAN FORCE THEM TO COMPILE WITH + * YOUR SORAST DEF IF YOU WANT (THAT WAY, ORDER OF FIELD DEFINITION IS IRRELEVANT) + */ + +/* Typically, this file is not used / seen by the programmer */ + +/* Used as "super-class" for compiling C library routines */ +typedef struct _nodebase { + struct _nodebase *right, *down; + int token; + } SORAST; + +#endif diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp new file mode 100644 index 0000000000..0d50a337f0 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp @@ -0,0 +1,151 @@ +#include +#include "STreeParser.h" + +void STreeParser:: +MATCH(SORASTBase *_t,int tok) +{ + if ( _t->type()!=tok ) + { + if ( guessing ) _GUESS_FAIL; + else mismatched_token(tok, _t); + } +} + +void STreeParser:: +MATCHRANGE(SORASTBase *_t,int tok,int tok2) +{ + if ( _t->type()type()>tok2 ) + { + if ( guessing ) _GUESS_FAIL; + else mismatched_range(tok, tok2, _t); + } +} + +void STreeParser:: +WILDCARD(SORASTBase *_t) +{ + if ( _t==NULL ) + { + if ( guessing ) _GUESS_FAIL; + else missing_wildcard(); + } +} + +void STreeParser:: +mismatched_range(int looking_for, int upper_token, SORASTBase *found) +{ + if ( found!=NULL ) { + fprintf(stderr, + "parse error: expected token range %d..%d found token %d\n", + looking_for, upper_token, + found->type()); + } + else { + fprintf(stderr, + "parse error: expected token range %d..%d found NULL tree\n", + looking_for, upper_token); + } +} + +void STreeParser:: +missing_wildcard() +{ + fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n"); +} + +void STreeParser:: +mismatched_token(int looking_for, SORASTBase *found) +{ + if ( found!=NULL ) { + fprintf(stderr, + "parse error: expected token %d found token %d\n", + looking_for, + found->type()); + } + else { + fprintf(stderr, + "parse error: expected token %d found NULL tree\n", + looking_for); + } +} + +void STreeParser:: +no_viable_alt(char *rulename, SORASTBase *root) +{ + if ( root==NULL ) + fprintf(stderr, + "parse error: in rule %s, no viable alternative for NULL tree\n", + rulename); + else + fprintf(stderr, + "parse error: in rule %s, no viable alternative for tree\n", + rulename); +} + +void STreeParser:: +panic(char *err) +{ + fprintf(stderr, "panic: %s\n", err); + exit(-1); +} + +void STreeParser:: +save_state(STreeParser *buf) +{ + buf->try_ok = this->try_ok; + buf->sjrv = this->sjrv; + buf->guessing = this->guessing; + buf->startofguess = this->startofguess; +} + +void STreeParser:: +restore_state(STreeParser *buf) +{ + this->try_ok = buf->try_ok; + this->sjrv = buf->sjrv; + this->guessing = buf->guessing; + this->startofguess = buf->startofguess; +} + +void STreeParser:: +_mkroot(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t) +{ + *r = t; +} + +void STreeParser:: +_mkchild(SORASTBase **r, SORASTBase **s, SORASTBase **e, SORASTBase *t) +{ +#ifdef BEFORE_GARYS_FIX + /* if no sibling list, must attach to any existing root */ + if ( *s==NULL ) + { + *s = *e = t; + /* If r is NULL, then there was no root defined--must be sibling list */ + if ( *r==NULL ) *r = *s; + else (*r)->setDown(t); + } + else { (*e)->setRight(t); *e = t; } +#endif +/* + should do nothing if asked to add a NULL argument. NULL's come up + when a rule wants to return "nothing". +*/ + /* if no sibling list, must attach to any existing root */ + if (*s == NULL) + { + *s = *e = t; + // If r is NULL then there was no root defined--must be sibling list + if (*r == NULL) *r = *s; + else (*r)->setDown(t); + } + else if (*e != NULL) + { + (*e)->setRight(t); + *e = t; + } + if (*e != NULL) { + while ((*e)->right() != NULL) *e = (SORASTBase *)(*e)->right(); + } +} + diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c new file mode 100644 index 0000000000..8ba1a49b50 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/astlib.c @@ -0,0 +1,834 @@ +/* + * astlib.c + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ + +#include +#include "pcctscfg.h" +#include + +#define SORCERER_TRANSFORM + +#include "CASTBase.h" +#include "astlib.h" + +#ifdef PCCTS_USE_STDARG +#include +#else +#include +#endif + + /* String Scanning/Parsing Stuff */ + +#define StringScanMaxText 50 + +typedef struct stringlexer { +#ifdef __USE_PROTOS + signed int c; +#else + int c; +#endif + char *input; + char *p; + char text[StringScanMaxText]; + } StringLexer; + +#define LPAREN 1 +#define RPAREN 2 +#define PERCENT 3 +#define INT 4 +#define COLON 5 +#define POUND 6 +#define PERIOD 7 +#define StringScanEOF -1 +#define VALID_SCAN_TOKEN(t) (t>=LPAREN && t<=PERIOD) + +static char *scan_token_tbl[] = { + "invalid", /* 0 */ + "LPAREN", /* 1 */ + "RPAREN", /* 2 */ + "PERCENT", /* 3 */ + "INT", /* 4 */ + "COLON", /* 5 */ + "POUND", /* 6 */ + "PERIOD", /* 7 */ +}; + +char * +#ifdef __USE_PROTOS +scan_token_str(int t) +#else +scan_token_str(t) +int t; +#endif +{ + if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t]; + else if ( t==StringScanEOF ) return ""; + else return ""; +} + +typedef struct stringparser { + int token; + StringLexer *lexer; + int num_labels; + } StringParser; + + /* This type ONLY USED by ast_scan() */ + +typedef struct _scanast { + struct _scanast *right, *down; + int token; + int label_num; + } ScanAST; + +#ifdef __USE_PROTOS +static void stringlexer_init(StringLexer *scanner, char *input); +static void stringparser_init(StringParser *, StringLexer *); +static ScanAST *stringparser_parse_scanast(char *templ, int *n); +static ScanAST *stringparser_parse_tree(StringParser *parser); +static ScanAST *stringparser_parse_element(StringParser *parser); +static void stringscan_advance(StringLexer *scanner); +static int stringscan_gettok(StringLexer *scanner); +#else +static void stringlexer_init(); +static void stringparser_init(); +static ScanAST *stringparser_parse_scanast(); +static ScanAST *stringparser_parse_tree(); +static ScanAST *stringparser_parse_element(); +static void stringscan_advance(); +static int stringscan_gettok(); +#endif + +/* build a tree (root child1 child2 ... NULL) + * If root is NULL, simply make the children siblings and return ptr + * to 1st sibling (child1). If root is not single node, return NULL. + * + * Siblings that are actually sibling lists themselves are handled + * correctly. For example #( NULL, #( NULL, A, B, C), D) results + * in the tree ( NULL A B C D ). + * + * Requires at least two parameters with the last one being NULL. If + * both are NULL, return NULL. + * + * The ast_down and ast_right down/right pointers are used to make the tree. + */ +SORAST * +#ifdef PCCTS_USE_STDARG +ast_make(SORAST *rt, ...) +#else +ast_make(va_alist) +va_dcl +#endif +{ + va_list ap; + register SORAST *child, *sibling=NULL, *tail = NULL, *w; + SORAST *root; + +#ifdef PCCTS_USE_STDARG + va_start(ap, rt); + root = rt; +#else + va_start(ap); + root = va_arg(ap, SORAST *); +#endif + + if ( root != NULL ) + if ( root->ast_down != NULL ) return NULL; + child = va_arg(ap, SORAST *); + while ( child != NULL ) + { + /* find end of child */ + for (w=child; w->ast_right!=NULL; w=w->ast_right) {;} + if ( sibling == NULL ) {sibling = child; tail = w;} + else {tail->ast_right = child; tail = w;} + child = va_arg(ap, SORAST *); + } + if ( root==NULL ) root = sibling; + else root->ast_down = sibling; + va_end(ap); + return root; +} + +/* The following push and pop routines are only used by ast_find_all() */ + +static void +#ifdef __USE_PROTOS +_push(SORAST **st, int *sp, SORAST *e) +#else +_push(st, sp, e) +SORAST **st; +int *sp; +SORAST *e; +#endif +{ + (*sp)--; + require((*sp)>=0, "stack overflow"); + st[(*sp)] = e; +} + +static SORAST * +#ifdef __USE_PROTOS +_pop(SORAST **st, int *sp) +#else +_pop(st, sp) +SORAST **st; +int *sp; +#endif +{ + SORAST *e = st[*sp]; + (*sp)++; + require((*sp)<=MaxTreeStackDepth, "stack underflow"); + return e; +} + +/* Is 'u' a subtree of 't' beginning at the root? */ +int +#ifdef __USE_PROTOS +ast_match_partial(SORAST *t, SORAST *u) +#else +ast_match_partial(t, u) +SORAST *t, *u; +#endif +{ + SORAST *sib; + + if ( u==NULL ) return 1; + if ( t==NULL ) if ( u!=NULL ) return 0; else return 1; + + for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right) + { + if ( sib->token != u->token ) return 0; + if ( sib->ast_down!=NULL ) + if ( !ast_match_partial(sib->ast_down, u->ast_down) ) return 0; + } + return 1; +} + +/* Find all occurrences of u in t. + * 'cursor' must be initialized to 't'. It eventually + * returns NULL when no more occurrences of 'u' are found. + */ +SORAST * +#ifdef __USE_PROTOS +ast_find_all(SORAST *t, SORAST *u, SORAST **cursor) +#else +ast_find_all(t, u, cursor) +SORAST *t, *u, **cursor; +#endif +{ + SORAST *sib; + static SORAST *template_stack[MaxTreeStackDepth]; + static int tsp = MaxTreeStackDepth; + + if ( *cursor == NULL ) return NULL; + if ( *cursor!=t ) sib = *cursor; + else { + /* else, first time--start at top of template 't' */ + tsp = MaxTreeStackDepth; + sib = t; + /* bottom of stack is always a NULL--"cookie" indicates "done" */ + _push(template_stack, &tsp, NULL); + } + +keep_looking: + if ( sib==NULL ) /* hit end of sibling list */ + { + sib = _pop(template_stack, &tsp); + if ( sib == NULL ) { *cursor = NULL; return NULL; } + } + + if ( sib->token != u->token ) + { + /* look for another match */ + if ( sib->ast_down!=NULL ) + { + if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right); + sib=sib->ast_down; + goto keep_looking; + } + /* nothing below to try, try next sibling */ + sib=sib->ast_right; + goto keep_looking; + } + + /* found a matching root node, try to match what's below */ + if ( ast_match_partial(sib, u) ) + { + /* record sibling cursor so we can pick up next from there */ + if ( sib->ast_down!=NULL ) + { + if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right); + *cursor = sib->ast_down; + } + else if ( sib->ast_right!=NULL ) *cursor = sib->ast_right; + else *cursor = _pop(template_stack, &tsp); + return sib; + } + + /* no match, keep searching */ + if ( sib->ast_down!=NULL ) + { + if ( sib->ast_right!=NULL ) _push(template_stack, &tsp, sib->ast_right); + sib=sib->ast_down; + } + else sib = sib->ast_right; /* else, try to right if zip below */ + goto keep_looking; +} + +/* are two trees exactly alike? */ +int +#ifdef __USE_PROTOS +ast_match(SORAST *t, SORAST *u) +#else +ast_match(t, u) +SORAST *t, *u; +#endif +{ + SORAST *sib; + + if ( t==NULL ) if ( u!=NULL ) return 0; else return 1; + if ( u==NULL ) return 0; + + for (sib=t; sib!=NULL&&u!=NULL; sib=sib->ast_right, u=u->ast_right) + { + if ( sib->token != u->token ) return 0; + if ( sib->ast_down!=NULL ) + if ( !ast_match(sib->ast_down, u->ast_down) ) return 0; + } + return 1; +} + +static int +#ifdef __USE_PROTOS +ast_scanmatch(ScanAST *t, SORAST *u, SORAST **labels[], int *n) +#else +ast_scanmatch(t, u, labels, n) +ScanAST *t; +SORAST *u; +SORAST **labels[]; +int *n; +#endif +{ + ScanAST *sib; + + if ( t==NULL ) if ( u!=NULL ) return 0; else return 1; + if ( u==NULL ) return 0; + + for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right, u=u->ast_right) + { + /* make sure tokens match; token of '0' means wildcard match */ + if ( sib->token != u->token && sib->token!=0 ) return 0; + /* we have a matched token here; set label pointers if exists */ + if ( sib->label_num>0 ) + { + require(labels!=NULL, "label found in template, but no array of labels"); + (*n)++; + *(labels[sib->label_num-1]) = u; + } + /* match what's below if something there and current node is not wildcard */ + if ( sib->down!=NULL && sib->token!=0 ) + if ( !ast_scanmatch(sib->down, u->ast_down, labels, n) ) return 0; + } + return 1; +} + +void +#ifdef __USE_PROTOS +ast_insert_after(SORAST *a, SORAST *b) +#else +ast_insert_after(a, b) +SORAST *a,*b; +#endif +{ + SORAST *end; + require(a!=NULL, "ast_insert_after: NULL input tree"); + if ( b==NULL ) return; + /* find end of b's child list */ + for (end=b; end->ast_right!=NULL; end=end->ast_right) {;} + end->ast_right = a->ast_right; + a->ast_right = b; +} + +void +#ifdef __USE_PROTOS +ast_append(SORAST *a, SORAST *b) +#else +ast_append(a, b) +SORAST *a,*b; +#endif +{ + SORAST *end; + require(a!=NULL&&b!=NULL, "ast_append: NULL input tree"); + /* find end of child list */ + for (end=a; end->ast_right!=NULL; end=end->ast_right) {;} + end->ast_right = b; +} + +SORAST * +#ifdef __USE_PROTOS +ast_tail(SORAST *a) +#else +ast_tail(a) +SORAST *a; +#endif +{ + SORAST *end; + require(a!=NULL, "ast_tail: NULL input tree"); + /* find end of child list */ + for (end=a; end->ast_right!=NULL; end=end->ast_right) {;} + return end; +} + +SORAST * +#ifdef __USE_PROTOS +ast_bottom(SORAST *a) +#else +ast_bottom(a) +SORAST *a; +#endif +{ + SORAST *end; + require(a!=NULL, "ast_bottom: NULL input tree"); + /* find end of child list */ + for (end=a; end->ast_down!=NULL; end=end->ast_down) {;} + return end; +} + +SORAST * +#ifdef __USE_PROTOS +ast_cut_between(SORAST *a, SORAST *b) +#else +ast_cut_between(a, b) +SORAST *a,*b; +#endif +{ + SORAST *end, *ret; + require(a!=NULL&&b!=NULL, "ast_cut_between: NULL input tree"); + /* find node pointing to b */ + for (end=a; end->ast_right!=NULL&&end->ast_right!=b; end=end->ast_right) + {;} + require(end->ast_right!=NULL, "ast_cut_between: a,b not connected"); + end->ast_right = NULL; /* don't want it point to 'b' anymore */ + ret = a->ast_right; + a->ast_right = b; + return ret; +} + +SList * +#ifdef __USE_PROTOS +ast_to_slist(SORAST *t) +#else +ast_to_slist(t) +SORAST *t; +#endif +{ + SList *list=NULL; + SORAST *p; + + for (p=t; p!=NULL; p=p->ast_right) + { + slist_add(&list, p); + } + return list; +} + +SORAST * +#ifdef __USE_PROTOS +slist_to_ast(SList *list) +#else +slist_to_ast(list) +SList *list; +#endif +{ + SORAST *t=NULL, *last=NULL; + SList *p; + + for (p = list->next; p!=NULL; p=p->next) + { + SORAST *u = (SORAST *)p->elem; + if ( last==NULL ) last = t = u; + else { last->ast_right = u; last = u; } + } + return t; +} + +void +#ifdef __USE_PROTOS +ast_free(SORAST *t) +#else +ast_free(t) +SORAST *t; +#endif +{ + if ( t == NULL ) return; + ast_free( t->ast_down ); + ast_free( t->ast_right ); + free( t ); +} + +int +#ifdef __USE_PROTOS +ast_nsiblings(SORAST *t) +#else +ast_nsiblings(t) +SORAST *t; +#endif +{ + int n=0; + + while ( t!=NULL ) + { + n++; + t = t->ast_right; + } + return n; +} + +SORAST * +#ifdef __USE_PROTOS +ast_sibling_index(SORAST *t, int i) +#else +ast_sibling_index(t,i) +SORAST *t; +int i; +#endif +{ + int j=1; + require(i>0, "ast_sibling_index: i<=0"); + + while ( t!=NULL ) + { + if ( j==i ) return t; + j++; + t = t->ast_right; + } + return NULL; +} + +static void +#ifdef __USE_PROTOS +scanast_free(ScanAST *t) +#else +scanast_free(t) +ScanAST *t; +#endif +{ + if ( t == NULL ) return; + scanast_free( t->down ); + scanast_free( t->right ); + free( t ); +} + +/* + * ast_scan + * + * This function is like scanf(): it attempts to match a template + * against an input tree. A variable number of tree pointers + * may be set according to the '%i' labels in the template string. + * For example: + * + * ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )", + * t, &w, &x, &y, &z); + * + * Naturally, you'd want this converted from + * + * ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )", + * t, &w, &x, &y, &z); + * + * by SORCERER. + * + * This function call must be done withing a SORCERER file because SORCERER + * must convert the token references to the associated token number. + * + * This functions parses the template and creates trees which are then + * matched against the input tree. The labels are set as they are + * encountered; hence, partial matches may leave some pointers set + * and some NULL. This routines initializes all argument pointers to NULL + * at the beginning. + * + * This function returns the number of labels matched. + */ +int +#ifdef PCCTS_USE_STDARG +ast_scan(char *templ, SORAST *tree, ...) +#else +ast_scan(va_alist) +va_dcl +#endif +{ + va_list ap; + ScanAST *t; + int n, i, found=0; + SORAST ***label_ptrs=NULL; + +#ifdef PCCTS_USE_STDARG + va_start(ap, tree); +#else + char *templ; + SORAST *tree; + + va_start(ap); + templ = va_arg(ap, char *); + tree = va_arg(ap, SORAST *); +#endif + + /* make a ScanAST tree out of the template */ + t = stringparser_parse_scanast(templ, &n); + + /* make an array out of the labels */ + if ( n>0 ) + { + label_ptrs = (SORAST ***) calloc(n, sizeof(SORAST **)); + require(label_ptrs!=NULL, "ast_scan: out of memory"); + for (i=1; i<=n; i++) + { + label_ptrs[i-1] = va_arg(ap, SORAST **); + *(label_ptrs[i-1]) = NULL; + } + } + + /* match the input tree against the template */ + ast_scanmatch(t, tree, label_ptrs, &found); + + scanast_free(t); + free(label_ptrs); + + return found; +} + +static ScanAST * +#ifdef __USE_PROTOS +new_scanast(int tok) +#else +new_scanast(tok) +int tok; +#endif +{ + ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST)); + if ( p == NULL ) {fprintf(stderr, "out of mem\n"); exit(-1);} + p->token = tok; + return p; +} + +static ScanAST * +#ifdef __USE_PROTOS +stringparser_parse_scanast(char *templ, int *num_labels) +#else +stringparser_parse_scanast(templ, num_labels) +char *templ; +int *num_labels; +#endif +{ + StringLexer lex; + StringParser parser; + ScanAST *t; + + stringlexer_init(&lex, templ); + stringparser_init(&parser, &lex); + t = stringparser_parse_tree(&parser); + *num_labels = parser.num_labels; + return t; +} + +static void +#ifdef __USE_PROTOS +stringparser_match(StringParser *parser, int token) +#else +stringparser_match(parser, token) +StringParser *parser; +int token; +#endif +{ + if ( parser->token != token ) sorcerer_panic("bad tree in ast_scan()"); +} + +/* + * Match a tree of the form: + * (root child1 child2 ... childn) + * or, + * node + * + * where the elements are integers or labeled integers. + */ +static ScanAST * +#ifdef __USE_PROTOS +stringparser_parse_tree(StringParser *parser) +#else +stringparser_parse_tree(parser) +StringParser *parser; +#endif +{ + ScanAST *t=NULL, *root, *child, *last = NULL; + + if ( parser->token != POUND ) + { + return stringparser_parse_element(parser); + } + stringparser_match(parser,POUND); + parser->token = stringscan_gettok(parser->lexer); + stringparser_match(parser,LPAREN); + parser->token = stringscan_gettok(parser->lexer); + root = stringparser_parse_element(parser); + while ( parser->token != RPAREN ) + { + child = stringparser_parse_element(parser); + if ( t==NULL ) { t = child; last = t; } + else { last->right = child; last = child; } + } + stringparser_match(parser,RPAREN); + parser->token = stringscan_gettok(parser->lexer); + root->down = t; + return root; +} + +static ScanAST * +#ifdef __USE_PROTOS +stringparser_parse_element(StringParser *parser) +#else +stringparser_parse_element(parser) +StringParser *parser; +#endif +{ + static char ebuf[100]; + int label = 0; + + if ( parser->token == POUND ) + { + return stringparser_parse_tree(parser); + } + if ( parser->token == PERCENT ) + { + parser->token = stringscan_gettok(parser->lexer); + stringparser_match(parser,INT); + label = atoi(parser->lexer->text); + parser->num_labels++; + if ( label==0 ) sorcerer_panic("%%0 is an invalid label"); + parser->token = stringscan_gettok(parser->lexer); + stringparser_match(parser,COLON); + parser->token = stringscan_gettok(parser->lexer); + /* can label tokens and wildcards */ + if ( parser->token != INT && parser->token != PERIOD ) + sorcerer_panic("can only label tokens"); + } + if ( parser->token == INT ) + { + ScanAST *p = new_scanast(atoi(parser->lexer->text)); + parser->token = stringscan_gettok(parser->lexer); + p->label_num = label; + return p; + } + if ( parser->token == PERIOD ) + { + ScanAST *p = new_scanast(0); /* token of 0 is wildcard */ + parser->token = stringscan_gettok(parser->lexer); + p->label_num = label; + return p; + } + sprintf(ebuf, "mismatch token in ast_scan(): %s", scan_token_str(parser->token)); + sorcerer_panic(ebuf); + return NULL; /* MR20 make -Wall happy */ +} + +static void +#ifdef __USE_PROTOS +stringparser_init(StringParser *parser, StringLexer *input) +#else +stringparser_init(parser, input) +StringParser *parser; +StringLexer *input; +#endif +{ + parser->lexer = input; + parser->token = stringscan_gettok(parser->lexer); + parser->num_labels = 0; +} + +static void +#ifdef __USE_PROTOS +stringlexer_init(StringLexer *scanner, char *input) +#else +stringlexer_init(scanner, input) +StringLexer *scanner; +char *input; +#endif +{ + scanner->text[0]='\0'; + scanner->input = input; + scanner->p = input; + stringscan_advance(scanner); +} + +static void +#ifdef __USE_PROTOS +stringscan_advance(StringLexer *scanner) +#else +stringscan_advance(scanner) +StringLexer *scanner; +#endif +{ + if ( *(scanner->p) == '\0' ) scanner->c = StringScanEOF; + scanner->c = *(scanner->p)++; +} + +static int +#ifdef __USE_PROTOS +stringscan_gettok(StringLexer *scanner) +#else +stringscan_gettok(scanner) +StringLexer *scanner; +#endif +{ + char *index = &scanner->text[0]; + static char ebuf[100]; + + while ( isspace(scanner->c) ) { stringscan_advance(scanner); } + if ( isdigit(scanner->c) ) + { + int tok = INT; + while ( isdigit(scanner->c) ) { + *index++ = scanner->c; + stringscan_advance(scanner); + } + *index = '\0'; + return tok; + } + switch ( scanner->c ) + { + case '#' : stringscan_advance(scanner); return POUND; + case '(' : stringscan_advance(scanner); return LPAREN; + case ')' : stringscan_advance(scanner); return RPAREN; + case '%' : stringscan_advance(scanner); return PERCENT; + case ':' : stringscan_advance(scanner); return COLON; + case '.' : stringscan_advance(scanner); return PERIOD; + case '\0' : return StringScanEOF; + case StringScanEOF : return StringScanEOF; + default : + sprintf(ebuf, "invalid char in ast_scan: '%c'", scanner->c); + sorcerer_panic(ebuf); + return 0; /* MR20 Make -Wall happy */ + } +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c new file mode 100644 index 0000000000..4048ba50b2 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/errsupport.c @@ -0,0 +1,100 @@ +/* + * errsupport.c -- error support code for SORCERER output + * + * Define your own or compile and link this in. + * + * Terence Parr + * U of MN, AHPCRC + * February 1994 + */ +#include "sorcerer.h" + +void +#ifdef __USE_PROTOS +mismatched_range( STreeParser *_parser, int looking_for, int upper_token, SORAST *found ) +#else +mismatched_range( _parser, looking_for, upper_token, found ) +int looking_for; +int upper_token; +SORAST *found; +STreeParser *_parser; +#endif +{ + if ( found!=NULL ) { + fprintf(stderr, + "parse error: expected token range %d..%d found token %d\n", + looking_for, upper_token, + found->token); + } + else { + fprintf(stderr, + "parse error: expected token range %d..%d found NULL tree\n", + looking_for, upper_token); + } +} + +void +#ifdef __USE_PROTOS +missing_wildcard(STreeParser *_parser) +#else +missing_wildcard(_parser) +STreeParser *_parser; +#endif +{ + fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n"); +} + +void +#ifdef __USE_PROTOS +mismatched_token( STreeParser *_parser, int looking_for, SORAST *found ) +#else +mismatched_token( _parser, looking_for, found ) +int looking_for; +SORAST *found; +STreeParser *_parser; +#endif +{ + if ( found!=NULL ) { + fprintf(stderr, + "parse error: expected token %d found token %d\n", + looking_for, + found->token); + } + else { + fprintf(stderr, + "parse error: expected token %d found NULL tree\n", + looking_for); + } +} + +void +#ifdef __USE_PROTOS +no_viable_alt( STreeParser *_parser, char *rulename, SORAST *root ) +#else +no_viable_alt( _parser, rulename, root ) +char *rulename; +SORAST *root; +STreeParser *_parser; +#endif +{ + if ( root==NULL ) + fprintf(stderr, + "parse error: in rule %s, no viable alternative for NULL tree\n", + rulename); + else + fprintf(stderr, + "parse error: in rule %s, no viable alternative for tree\n", + rulename); +} + +void +#ifdef __USE_PROTOS +sorcerer_panic(char *err) +#else +sorcerer_panic(err) +char *err; +#endif +{ + fprintf(stderr, "panic: %s\n", err); + exit(-1); +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile new file mode 100644 index 0000000000..c4e9bca9e8 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/makefile @@ -0,0 +1,21 @@ +# +# Makefile for SORCERER libraries +# +SRC = astlib.c sstack.c sorlist.c sintstack.c +OBJ = astlib.o sstack.o sorlist.o sintstack.o +CFLAGS=-g -I../../h -I../h +CC=cc + +libs : $(OBJ) $(SRC) + +clean: + rm -f *.o core + +scrub: + rm -f *.o core + +ci: + ci -u $(SRC) *.h makefile + +co: + co -l $(SRC) *.h makefile diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp new file mode 100644 index 0000000000..390d34fc06 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/msvc.dsp @@ -0,0 +1,130 @@ +# Microsoft Developer Studio Project File - Name="lib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=lib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "lib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "lib.mak" CFG="lib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "lib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "lib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName ""$/pccts/Sorcerer/lib", EPABAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe + +!IF "$(CFG)" == "lib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "h" /I "..\h" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "lib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "h" /I "..\h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "PC" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "lib - Win32 Release" +# Name "lib - Win32 Debug" +# Begin Group "Header files" + +# PROP Default_Filter "h" +# Begin Source File + +SOURCE=.\CASTBase.h +# End Source File +# End Group +# Begin Group "Source files" + +# PROP Default_Filter "c,cpp" +# Begin Source File + +SOURCE=.\astlib.c +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\errsupport.c +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\PCCTSAST.cpp +# End Source File +# Begin Source File + +SOURCE=.\sintstack.c +# End Source File +# Begin Source File + +SOURCE=.\SList.cpp +# End Source File +# Begin Source File + +SOURCE=.\sorcerer.c +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\sorlist.c +# PROP Exclude_From_Build 1 +# End Source File +# Begin Source File + +SOURCE=.\sstack.c +# End Source File +# Begin Source File + +SOURCE=.\STreeParser.cpp +# End Source File +# End Group +# End Target +# End Project diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c new file mode 100644 index 0000000000..a3708c94fb --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sintstack.c @@ -0,0 +1,140 @@ +/* + * sint.c + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ +#include +#include + +#ifdef PCCTS_USE_STDARG +#include +#else +#include +#endif + +#include "CASTBase.h" +#include "sintstack.h" + +SIntStack * +#ifdef __USE_PROTOS +sint_newstack(int size) +#else +sint_newstack(size) +int size; +#endif +{ + SIntStack *p = (SIntStack *) calloc(1, sizeof(SIntStack)); + require(p!=NULL, "sint_newstack: out of memory"); + p->data = (int *) calloc(size, sizeof(int)); + require(p!=NULL, "sint_newstack: out of memory"); + p->size = size; + p->sp = size; + return p; +} + +void +#ifdef __USE_PROTOS +sint_freestack(SIntStack *st) +#else +sint_freestack(st) +SIntStack *st; +#endif +{ + if ( st==NULL ) return; + if ( st->data==NULL ) return; + free(st->data); + free(st); +} + +void +#ifdef __USE_PROTOS +sint_push(SIntStack *st,int i) +#else +sint_push(st,i) +SIntStack *st; +int i; +#endif +{ + require(st->sp>0, "sint_push: stack overflow"); + st->data[--(st->sp)] = i; +} + +int +#ifdef __USE_PROTOS +sint_pop(SIntStack *st) +#else +sint_pop(st) +SIntStack *st; +#endif +{ + require(st->spsize, "sint_pop: stack underflow"); + return st->data[st->sp++]; +} + +int +#ifdef __USE_PROTOS +sint_stacksize(SIntStack *st) +#else +sint_stacksize(st) +SIntStack *st; +#endif +{ + return st->size - st->sp; +} + +void +#ifdef __USE_PROTOS +sint_stackreset(SIntStack *st) +#else +sint_stackreset(st) +SIntStack *st; +#endif +{ + st->sp = st->size; +} + +int +#ifdef __USE_PROTOS +sint_stackempty(SIntStack *st) +#else +sint_stackempty(st) +SIntStack *st; +#endif +{ + return st->sp==st->size; +} + +int +#ifdef __USE_PROTOS +sint_top(SIntStack *st) +#else +sint_top(st) +SIntStack *st; +#endif +{ + require(st->spsize, "sint_top: stack underflow"); + return st->data[st->sp]; +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c new file mode 100644 index 0000000000..ad4c3a7eee --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorcerer.c @@ -0,0 +1,169 @@ +/* + * sorcerer.c -- support code for SORCERER output + * + * Define your own or compile and link this in. + * + * Terence Parr + * U of MN, AHPCRC + * February 1994 + */ + +/*********************************************************************** + 2-Oct-97 The routine ast_dup() appeared to have a bug in it. Instead + of providing a deep copy of its argument it made a bushy copy + of its argument - by duplicating the nodes pointed to by + its right link. This is certainly not deliberate and does + not match code in PCCTSAST.cpp (which had its own bug). This + has been changed to do a deep copy in the traditional sense. +***********************************************************************/ + +#ifdef OLD +/* Given a result pointer, return the same one if *t is NULL, + * else find the end of the sibling list and return the address + * the 'next[write]' field in that last node. + */ +AST ** +#ifdef __USE_PROTOS +_nextresult(STreeParser *_parser, AST **t) +#else +_nextresult(_parser, t) +AST **t; +STreeParser *_parser; +#endif +{ + AST *p = *t; + + if ( p==NULL ) return t; + while ( p->ast_right(_parser->write) != NULL ) + { + p = p->ast_right(_parser->write); + } + return &(p->ast_right(_parser->write)); +} + +/* + * Copy the read pointers to the write pointers for a node or entire subtree + */ +void +#ifdef __USE_PROTOS +_copy_wildcard(STreeParser *_parser, AST *t, int root) +#else +_copy_wildcard(_parser, t, root) +STreeParser *_parser; +AST *t; +int root; +#endif +{ + while ( t!=NULL ) + { + if ( !root ) t->ast_right(_parser->write) = t->ast_right(_parser->read); + t->ast_down(_parser->write) = t->ast_down(_parser->read); + if ( t->ast_down(_parser->read)!=NULL ) + _copy_wildcard(_parser, t->ast_down(_parser->read), 0); + if ( root ) return; + else root=0; + t = t->ast_right(_parser->read); + } +} +#endif + +void +#ifdef __USE_PROTOS +_mkroot(SORAST **r, SORAST **s, SORAST **e, SORAST *t) +#else +_mkroot(r,s,e,t) +SORAST **r, **s, **e, *t; +#endif +{ + *r = t; +} + +void +#ifdef __USE_PROTOS +_mkchild(SORAST **r, SORAST **s, SORAST **e, SORAST *t) +#else +_mkchild(r,s,e,t) +SORAST **r, **s, **e, *t; +#endif +{ + /* if no sibling list, must attach to any existing root */ + if ( *s==NULL ) + { + *s = *e = t; + /* If r is NULL, then there was no root defined--must be sibling list */ + if ( *r==NULL ) *r = *s; + else (*r)->ast_down = t; + } + else { (*e)->ast_right = t; *e = t; } +} + +/* THESE FUNCS HAVE TO GO HERE BECAUSE THEY ARE SENSITIVE TO USER'S SORAST DEF */ +SORAST * +#ifdef __USE_PROTOS +ast_alloc(void) +#else +ast_alloc() +#endif +{ + SORAST *t = (SORAST *)calloc(1, sizeof(SORAST)); + if ( t==NULL ) sorcerer_panic("out of memory"); + return t; +} + +SORAST * +#ifdef __USE_PROTOS +ast_dup_bushy(SORAST *t) +#else +ast_dup_bushy(t) +SORAST *t; +#endif +{ + SORAST *u; + + if ( t == NULL ) return NULL; + u = ast_alloc(); + *u = *t; /* copy contents */ + u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */ + u->ast_right = ast_dup_bushy(t->ast_right); + return u; +} + + +/* Assume t is a root node of a tree--duplicate that node and what's below */ + +SORAST * +#ifdef __USE_PROTOS +ast_dup(SORAST *t) +#else +ast_dup(t) +SORAST *t; +#endif +{ + SORAST *u; + + if ( t == NULL ) return NULL; + u = ast_alloc(); + *u = *t; /* copy contents */ + u->ast_down = ast_dup_bushy(t->ast_down); /* copy the rest of the tree */ + u->ast_right = NULL; + return u; +} + +/* Assume t is a root node of a tree--duplicate that node and what's below */ +SORAST * +#ifdef __USE_PROTOS +ast_dup_node(SORAST *t) +#else +ast_dup_node(t) +SORAST *t; +#endif +{ + SORAST *u; + + if ( t == NULL ) return NULL; + u = ast_alloc(); + *u = *t; /* copy contents */ + u->down = NULL; + u->right = NULL; + return u; +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c new file mode 100644 index 0000000000..6872974c26 --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sorlist.c @@ -0,0 +1,123 @@ +/* + * slist.c + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ +#include +#include + +#ifdef PCCTS_USE_STDARG +#include +#else +#include +#endif + +#include "CASTBase.h" +#include "sorlist.h" + +/* Iterate over a list of elements; returns ptr to a new element + * in list upon every call and NULL when no more are left. + * Very useful like this: + * + * cursor = mylist; + * while ( (p=slist_iterate(mylist,&cursor)) ) { + * / * place with element p * / + * } + * + * The cursor must be initialized to point to the list to iterate over. + */ +void * +#ifdef __USE_PROTOS +slist_iterate(SList *list, SList **cursor) +#else +slist_iterate(list, cursor) +SList *list, **cursor; +#endif +{ + void *e; + + if ( list==NULL || cursor == NULL || *cursor==NULL ) return NULL; + if ( list== *cursor ) { *cursor = (*cursor)->next; } + e = (*cursor)->elem; + (*cursor) = (*cursor)->next; + return e; +} + +/* + * add an element to a list. + * + * Any non-empty list has a sentinel node whose 'elem' pointer is really + * a pointer to the last element. (i.e. length(list) = #elemIn(list)+1). + * Elements are appended to the list. + */ +void +#ifdef __USE_PROTOS +slist_add( SList **list, void *e ) +#else +slist_add( list, e ) +SList **list; +void *e; +#endif +{ + SList *p, *tail; + require(e!=NULL, "slist_add: attempting to add NULL list element"); + + p = newSList; + require(p!=NULL, "slist_add: cannot alloc new list node"); + p->elem = e; + if ( *list == NULL ) + { + SList *sentinel = newSList; + require(sentinel!=NULL, "slist_add: cannot alloc sentinel node"); + *list=sentinel; + sentinel->next = p; + sentinel->elem = (char *)p; /* set tail pointer */ + } + else /* find end of list */ + { + tail = (SList *) (*list)->elem; /* get tail pointer */ + tail->next = p; + (*list)->elem = (char *) p; /* reset tail */ + } +} + +void +#ifdef __USE_PROTOS +slist_free(SList *list) +#else +slist_free(list) +SList *list; +#endif +{ + SList *p,*q; + + if ( list==NULL ) return; /* empty list */ + for (p = list->next; p!=NULL; p=q) + { + q = p->next; + free(p); + } +} diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c new file mode 100644 index 0000000000..c8a97b06fa --- /dev/null +++ b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/sstack.c @@ -0,0 +1,78 @@ +/* + * sstack.c + * + * SOFTWARE RIGHTS + * + * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public + * domain. An individual or company may do whatever they wish with + * source code distributed with SORCERER or the code generated by + * SORCERER, including the incorporation of SORCERER, or its output, into + * commerical software. + * + * We encourage users to develop software with SORCERER. However, we do + * ask that credit is given to us for developing SORCERER. By "credit", + * we mean that if you incorporate our source code into one of your + * programs (commercial product, research project, or otherwise) that you + * acknowledge this fact somewhere in the documentation, research report, + * etc... If you like SORCERER and have developed a nice tool with the + * output, please mention that you developed it using SORCERER. In + * addition, we ask that this header remain intact in our source code. + * As long as these guidelines are kept, we expect to continue enhancing + * this system and expect to make other tools available as they are + * completed. + * + * SORCERER 1.00B + * Terence Parr + * AHPCRC, University of Minnesota + * 1992-1994 + */ + +#include "pcctscfg.h" +#include +#include + +#ifdef PCCTS_USE_STDARG +#include +#else +#include +#endif + +#include "CASTBase.h" +#include "sstack.h" + +void +#ifdef __USE_PROTOS +sstack_push( SStack **st, void *e ) +#else +sstack_push( st, e ) +SStack **st; +void *e; +#endif +{ + SStack *p; + require(e!=NULL, "sstack_push: attempting to add NULL list element"); + + p = newSStack; + require(p!=NULL, "sstack_push: cannot alloc new list node"); + p->elem = e; + p->next = *st; + *st = p; +} + +void * +#ifdef __USE_PROTOS +sstack_pop( SStack **st ) +#else +sstack_pop( st ) +SStack **st; +#endif +{ + SStack *p = *st; + void *r; + + *st = (*st)->next; + r = p->elem; + free(p); + return r; +} + diff --git a/EdkCompatibilityPkg/Sample/CommonTools.env b/EdkCompatibilityPkg/Sample/CommonTools.env new file mode 100644 index 0000000000..2d97156a02 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/CommonTools.env @@ -0,0 +1,672 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CommonTools.env +# +# Abstract: +# +# This file should not need to be customized. Customizations should +# be done in LocalTools.env if at all possible. +# +# This file can be included by other makefiles. +# +# It defines variables used by the different toolchains. It first includes +# the user-customized LocalTools.env, and then uses those defines to +# define other variables. +# +# It basically has sections for different toolchains which define variables +# used to build. +# +#--*/ + +# +# Everything depends on EDK_SOURCE. Make sure it's defined +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Tools depend on BUILD_DIR. Make sure it's defined +# +!IFNDEF BUILD_DIR +!ERROR BUILD_DIR environmental variable not set. Should be set in PlatformTools.env +!ENDIF + +# +# This include file gets customized by the developer. Get the customizations. +# +!INCLUDE $(EDK_SOURCE)\Sample\LocalTools.env + +################################################################################ +# +# Define paths for EFI build tools +# +################################################################################ +!IFNDEF EDK_TOOLS_PATH +EDK_TOOLS_BIN = $(EDK_SOURCE)\Tools\Bin +!ELSE +EDK_TOOLS_BIN = $(EDK_TOOLS_PATH)\Bin +!ENDIF +EDK_TOOLS_DIR = $(EDK_SOURCE)\Sample\Tools +EDK_TOOLS_SOURCE = $(EDK_TOOLS_DIR)\Source +EDK_TOOLS_COMMON = $(EDK_TOOLS_DIR)\Source\Common +EDK_TOOLS_OUTPUT = $(BUILD_DIR)\Tools +PCCTS_DIR = $(EDK_SOURCE)\Other\Maintained\Tools\Pccts + +# +# This include file gets some version info. +# +!INCLUDE $(EDK_SOURCE)\Sample\Version.env + +# +# Macros to define the build tools +# +ANTLR = $(PCCTS_DIR)\bin\antlr +DLG = $(PCCTS_DIR)\bin\dlg +FWIMAGE = $(EDK_TOOLS_OUTPUT)\FwImage +GENDEPEX = $(EDK_TOOLS_OUTPUT)\GenDepex +GENFDIMAGE = $(EDK_TOOLS_OUTPUT)\GenFdImage +GENFFSFILE = $(EDK_TOOLS_OUTPUT)\GenFfsFile +GENFVIMAGE = $(EDK_TOOLS_OUTPUT)\GenFvImage +GENSECTION = $(EDK_TOOLS_OUTPUT)\GenSection +GUIDCHK = $(EDK_TOOLS_OUTPUT)\GuidChk +MAKEDEPS = $(EDK_TOOLS_OUTPUT)\MakeDeps +PROCESSDSC = $(EDK_TOOLS_OUTPUT)\ProcessDsc +STRGATHER = $(EDK_TOOLS_OUTPUT)\StrGather +SETSTAMP = $(EDK_TOOLS_OUTPUT)\SetStamp +VFRCOMPILE = $(EDK_TOOLS_OUTPUT)\VfrCompile +GENAPRIORI = $(EDK_TOOLS_OUTPUT)\GenAprioriFile +MODIFYINF = $(EDK_TOOLS_OUTPUT)\ModifyInf + +MAKE = nmake -nologo + +# +# Everything else requires that TOOLCHAIN be defined. This should be defined +# by the calling makefile. +# +!IFNDEF TOOLCHAIN +!ERROR TOOLCHAIN not defined for $(EDK_SOURCE)\Sample\CommonTools.env +!ENDIF + +############################################################################### +# +# Specify the path and macros for ASL tools +# +############################################################################### +!IF "$(EFI_ASL_LOCAL)" == "YES" +ASL = $(ASLPATH)\Iasl +!ELSE +ASL = $(EDK_TOOLS_BIN)\Iasl +!ENDIF + +ASL_FLAGS = +C_FLAGS_ASL = /nologo /EP /C + +############################################################################### +# +# Specify the path and macros for IA32 tools +# +############################################################################### + +!IF "$(TOOLCHAIN)" == "TOOLCHAIN_IA32" + +# +# Globally relevant flags. Options not appropriate for all builds may be +# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or +# in the platform specific macros (xxx_PROJ_FLAGS) +# +C_STD_INCLUDE = /X +!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES" +!IF "$(USE_VC8)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /GS- /D USE_VC8 /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ELSE +C_STD_FLAGS = /nologo /W4 /WX /GX /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ENDIF +!ELSE +!IF "$(USE_VC8)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /GS- /D USE_VC8 /c /Fo$@ $(INC) +!ELSE +C_STD_FLAGS = /nologo /W4 /WX /GX /Gy /c /Fo$@ $(INC) +!ENDIF +!ENDIF +ASM_STD_FLAGS = /nologo $(INC) +LINK_STD_FLAGS = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108 $(BUILD_DIR)\IA32\CompilerStub.lib +LIB_STD_FLAGS = /nologo + +# +# Build type specific flags. Globally relevant flags belong in the standard +# macros, xxx_STD_FLAGS defined above. Platform specific macros belong in the +# PlatformTools.env file in macros named xxx_PROJ_FLAGS. +# +C_ARCH_FLAGS = /D EFI32 +ASM_ARCH_FLAGS = /W3 /WX /c /coff /Fo$@ /DEFI32 +LINK_ARCH_FLAGS = /MACHINE:I386 +LIB_ARCH_FLAGS = + +ASM16_FLAGS = /nologo /c /omf /Fo$@ +ASMLINK16_FLAGS = + +# +# Build tools +# +CC = cl +LINK = link +LIB = lib +# +# When using VS ml to compile 16bit code, please add /omf compiler option +# +ASM = ml + +!IF "$(EFI_ASSEMBLER_NAME)" == "" +ASM16 = $(MASMPATH)\bin\ml +ASMLINK16 = $(MASMPATH)\binr\link +ASMLINK = $(MASMPATH)\binr\link +!ELSE +ASM16 = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\bin\ml +ASMLINK16 = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link +ASMLINK = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link +!ENDIF + +BSCMAKE = bscmake + +!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES" +ASM_ARCH_FLAGS = $(ASM_ARCH_FLAGS) /Zi /DDEBUG +C_STD_FLAGS = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj +LINK_STD_FLAGS = $(LINK_STD_FLAGS) /DEBUG +!ENDIF + +# END OF TOOLCHAIN_IA32 +############################################################################### + +############################################################################### +# +# Specify the path and macros for the X64 (also called x86-64, EM64T, AMD64) tools +# +############################################################################### + +!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_X64" + +# +# Globally relevant flags. Options not appropriate for all builds may be +# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or +# in the platform specific macros (xxx_PROJ_FLAGS) +# +C_STD_INCLUDE = /X +!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /Gy /c /GS- /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ELSE +C_STD_FLAGS = /nologo /W4 /WX /Gy /c /GS- /Fo$@ $(INC) +!ENDIF +ASM_STD_FLAGS = /nologo $(INC) +LINK_STD_FLAGS = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108 $(BUILD_DIR)\X64\CompilerStub.lib +LIB_STD_FLAGS = /nologo + +# +# Build type specific flags. Globally relevant flags belong in the standard +# macros, xxx_STD_FLAGS defined above. Platform specific macros belong in the +# PlatformTools.env file in macros named xxx_PROJ_FLAGS. +# +C_ARCH_FLAGS = /D EFIX64 +ASM_ARCH_FLAGS = /W3 /WX /c /Fo$@ /DEFIX64 +LINK_ARCH_FLAGS = /Machine:AMD64 +LIB_ARCH_FLAGS = + +ASM16_FLAGS = /nologo /c /omf /Fo$@ +ASMLINK16_FLAGS = + +# +# Build tools +# +!IF "$(EFI_COMPILER_X64_NAME)" == "" +!IF "$(USE_VC8_X64)" == "YES" +# +# Use VC8 as X64 compiler +# +CC = "$(VC8_X64_PATH)\cl" +LINK = "$(VC8_X64_PATH)\link" +LIB = "$(VC8_X64_PATH)\lib" +ASM = "$(VC8_X64_PATH)\ml64" +!ELSE +# +# Use DDK as X64 compiler +# +CC = $(WIN_DDK_X64_PATH)\cl +LINK = $(WIN_DDK_X64_PATH)\link +LIB = $(WIN_DDK_X64_PATH)\lib +ASM = $(WIN_DDK_X64_PATH)\ml64 +!ENDIF +!ELSE +CC = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\cl +LINK = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\link +LIB = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\lib +ASM = $(EDK_TOOLS_BIN)\X64\$(EFI_COMPILER_X64_NAME)\ml64 +!ENDIF + +!IF "$(EFI_ASSEMBLER_NAME)" == "" +ASM16 = $(MASMPATH)\bin\ml +ASMLINK16 = $(MASMPATH)\binr\link +ASMLINK = $(MASMPATH)\binr\link +!ELSE +ASM16 = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\bin\ml +ASMLINK16 = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link +ASMLINK = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link +!ENDIF + +BSCMAKE = bscmake + +!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES" +ASM_ARCH_FLAGS = $(ASM_ARCH_FLAGS) /Zi /DDEBUG +C_STD_FLAGS = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj +LINK_STD_FLAGS = $(LINK_STD_FLAGS) /DEBUG +!ENDIF + +# END OF TOOLCHAIN_X64 +############################################################################### + +############################################################################### +# +# Specify the path and macros for the IPF tools +# +############################################################################### + +!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_IPF" + +# +# Globally relevant flags. Options not appropriate for all builds may be +# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or +# in the platform specific macros (xxx_PROJ_FLAGS) +# +C_STD_INCLUDE = /X +!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES" +!IF "$(USE_VC8_IPF)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ELSE +!IF "$(USE_NEWDDK)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ELSE +C_STD_FLAGS = /nologo /W4 /WX /GX /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ENDIF +!ENDIF +!ELSE +!IF "$(USE_VC8_IPF)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fo$@ $(INC) +!ELSE +!IF "$(USE_NEWDDK)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /GS- /c /Fo$@ $(INC) +!ELSE +C_STD_FLAGS = /nologo /W4 /WX /GX /Gy /c /Fo$@ $(INC) +!ENDIF +!ENDIF +!ENDIF + +ASM_STD_FLAGS = $(INC) +LINK_STD_FLAGS = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF /BASE:0 /IGNORE:4001,4078,4086,4096,4108 +LIB_STD_FLAGS = /nologo + +# +# Build type specific flags. Globally relevant flags belong in the standard +# macros, xxx_STD_FLAGS defined above. Platform specific macros belong in the +# PlatformTools.env file in macros named xxx_PROJ_FLAGS. +# +C_ARCH_FLAGS = /D EFI64 +ASM_ARCH_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -o $@ +LINK_ARCH_FLAGS = /MACHINE:IA64 +LIB_ARCH_FLAGS = + +# +# This is used for preprocessing IPF Assembly files +# +C_FLAGS_PRO = /nologo /EP /C $(C_STD_FLAGS) $(C_ARCH_FLAGS) $(C_PROJ_FLAGS) $(C_STD_INCLUDE) + +!IF "$(EFI_DEBUG)" == "YES" +ASM_ARCH_FLAGS = $(ASM_ARCH_FLAGS) -d debug +!ENDIF + +# +# Build tools +# +!IF "$(EFI_COMPILER_NAME)" == "" +!IF "$(USE_VC8_IPF)" == "YES" +CC = "$(VC8_IPF_PATH)\cl" +LINK = "$(VC8_IPF_PATH)\link" +LIB = "$(VC8_IPF_PATH)\lib" +!ELSE +CC = $(EFI_IA64TOOLPATH)\cl +LINK = $(EFI_IA64TOOLPATH)\link +LIB = $(EFI_IA64TOOLPATH)\lib +!ENDIF +!ELSE +CC = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\cl +LINK = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\link +LIB = $(EDK_TOOLS_BIN)\Ipf\$(EFI_COMPILER_NAME)\lib +!ENDIF + +!IF "$(EFI_ASSEMBLER_NAME)" == "" +!IF "$(USE_VC8_IPF)" == "YES" +ASM = "$(VC8_IPF_PATH)\ias" +ASMLINK = "$(VC8_IPF_PATH)\link" +!ELSE +ASM = $(EFI_IA64ASMPATH)\ias +ASMLINK = $(EFI_IA64ASMPATH)\link +!ENDIF +!ELSE +ASM = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\ias +ASMLINK = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\link +!ENDIF + +BSCMAKE = bscmake + +!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj +LINK_STD_FLAGS = $(LINK_STD_FLAGS) /DEBUG +!ENDIF + +# END TOOLCHAIN_IPF +############################################################################### + +############################################################################### +# +# Define toolchain for building the EFI tools on an IA32 system. +# +############################################################################### + +!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_MSVC" + +# +# Globally relevant flags. Options not appropriate for all builds may be +# appropriate in the processor architecture specific macros (xxx_ARCH_FLAGS) or +# in the platform specific macros (xxx_PROJ_FLAGS) +# +!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES" +!IF "$(USE_VC8)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /D _CRT_SECURE_NO_DEPRECATE /D USE_VC8 /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ELSE +C_STD_FLAGS = /nologo /W4 /WX /GX /Gy /c /Fa$* /FAsc /Fo$@ /FR$(@R).SBR $(INC) +!ENDIF +!ELSE +!IF "$(USE_VC8)" == "YES" +C_STD_FLAGS = /nologo /W4 /WX /EHsc /Gy /D _CRT_SECURE_NO_DEPRECATE /D USE_VC8 /c /Fo$@ $(INC) +!ELSE +C_STD_FLAGS = /nologo /W4 /WX /GX /Gy /c /Fo$@ $(INC) +!ENDIF +!ENDIF +ASM_STD_FLAGS = /nologo $(INC) +LINK_STD_FLAGS = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB /MAP /OPT:REF +LIB_STD_FLAGS = /nologo + +MSVS_LINK_LIBPATHS = + +# +# Build type specific flags. Globally relevant flags belong in the standard +# macros, xxx_STD_FLAGS defined above. Platform specific macros belong in the +# PlatformTools.env file in macros named xxx_PROJ_FLAGS. +# + +# +# Add a define to skip inclusion of Microsoft include file rpcasync.h, which +# results in a compile warning at W4. +# +C_ARCH_FLAGS = /Od /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D __RPCASYNC_H__ +ASM_ARCH_FLAGS = +LINK_ARCH_FLAGS = /MACHINE:i386 +LIB_ARCH_FLAGS = + +# +# Always turn on debug for the build tools so that we can debug problems +# quickly. +# NOTE: Ideally all the tools makefiles should be updated to use LINK_FLAGS_EXE +# instead of L_FLAGS for linking. When this happens we can get rid of +# the L_FLAGS definition here. +# + +#!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /Zi /Gm /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj +LINK_ARCH_FLAGS = $(LINK_ARCH_FLAGS) /DEBUG +L_FLAGS = $(L_FLAGS) /DEBUG +#!ENDIF + +# +# Clear any project flags when building tools +# +C_PROJ_FLAGS = +ASM_PROJ_FLAGS = +LINK_PROJ_FLAGS = +LIB_PROJ_FLAGS = +EBC_C_PROJ_FLAGS = +EBC_LINK_PROJ_FLAGS = +EBC_LIB_PROJ_FLAGS = + +# +# Build tools +# +CC = cl +LINK = link +BSCMAKE = bscmake +ASM = ml +ASMLINK = link +# +# Use a different macro name for tools build to avoid conflict with environment +# variable LIB +# +LIB_EXE = lib + +INC = -I $(EDK_SOURCE)\Foundation \ + -I $(EDK_SOURCE)\Foundation\Efi \ + -I $(EDK_SOURCE)\Foundation\Framework \ + -I $(EDK_SOURCE)\Sample\Platform\Nt32 \ + -I $(EDK_SOURCE)\Foundation\Core\Dxe \ + -I $(EDK_SOURCE)\Foundation\Include \ + -I $(EDK_SOURCE)\Foundation\Efi\Include \ + -I $(EDK_SOURCE)\Foundation\Framework\Include \ + -I $(EDK_SOURCE)\Foundation\Include\IndustryStandard \ + -I $(EDK_SOURCE)\Foundation\Include\Ia32 \ + -I $(EDK_SOURCE)\Foundation\Include\Pei \ + -I $(EDK_SOURCE)\Foundation\Library\Pei\Include \ + -I $(EDK_SOURCE)\Sample\Include \ + -I "$(EDK_TOOLS_COMMON)" + +# END TOOLCHAIN_MSVC +############################################################################### + +############################################################################### +# +# Specify the path and macros for the EBC tools +# +############################################################################### + +!ELSEIF "$(TOOLCHAIN)" == "TOOLCHAIN_EBC" + +!IF "$(EFI_GENERATE_INTERMEDIATE_FILE)" == "YES" +EBC_C_STD_FLAGS = /nologo /W3 /WX /c /Fa$* /FAsc /Fo$@ $(INC) /X +!ELSE +EBC_C_STD_FLAGS = /nologo /W3 /WX /c /Fo$@ $(INC) /X +!ENDIF + +# +# All EBC entry point functions must be called EfiMain. Redefine it. +# +!IF "$(IMAGE_ENTRY_POINT)" == "" +IMAGE_ENTRY_POINT = EfiMain +!ENDIF +EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D $(IMAGE_ENTRY_POINT)=EfiMain +EBC_LINK_STD_FLAGS = /nologo /MACHINE:EBC /BASE:0 /OPT:REF /NODEFAULTLIB +EBC_LIB_STD_FLAGS = /nologo /MACHINE:EBC + +# +# EBC tools path should be defined in LocalTools.env. +# +EBC_CC = $(EBC_TOOLS_PATH)\Bin\Iec +EBC_LINK = $(EBC_TOOLS_PATH)\Bin\Link +EBC_LIB = $(EBC_TOOLS_PATH)\Bin\Link /lib + +!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES" +EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /Zd /Zi +EBC_LINK_STD_FLAGS = $(EBC_LINK_STD_FLAGS) /DEBUG +!ENDIF + +# END TOOLCHAIN_EBC + +############################################################################### +# +# Let the caller define a NULL toolchain if they don't care. This way you can +# pick up at least some defines. +# +############################################################################### + +!ELSEIF "$(TOOLCHAIN)" == "" + +############################################################################### +# +# You get this if the calling makefile did not define TOOLCHAIN_xxx before +# including this file. +# +############################################################################### + +!ELSE +!ERROR Unknown toolchain $(TOOLCHAIN) defined for $(EDK_SOURCE)\Sample\CommonTools.env use +!ENDIF + + +############################################################################### +# +# These are standard settings for all tool chains +# +############################################################################### + +# +# These are standard build options +# +VERSION_FLAGS = /D EFI_SPECIFICATION_VERSION=$(EFI_SPECIFICATION_VERSION) \ + /D PI_SPECIFICATION_VERSION=$(PI_SPECIFICATION_VERSION) \ + /D TIANO_RELEASE_VERSION=$(TIANO_RELEASE_VERSION) +C_STD_FLAGS = $(C_STD_FLAGS) $(VERSION_FLAGS) +EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) $(VERSION_FLAGS) +VFRCOMPILE_FLAGS = $(VFRCOMPILE_FLAGS) -ppflag "$(VERSION_FLAGS)" + +!IF "$(EFI_DEBUG)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_DEBUG +EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EFI_DEBUG +VFRCOMPILE_FLAGS = $(VFRCOMPILE_FLAGS) -ppflag "/D EFI_DEBUG" +!ENDIF + +!IF "$(EFI_DEBUG_CLEAR_MEMORY)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_DEBUG_CLEAR_MEMORY +!ENDIF + +!IF "$(EFI_PEI_PERFORMANCE)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_PEI_PERFORMANCE /D EFI_DXE_PERFORMANCE +!ENDIF + +!IF "$(EFI_ADDTIONAL_DRIVERS)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_ADDTIONAL_DRIVERS +!ENDIF + +!IF "$(EFI_USE_CUSTOM_COMPRESS)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_USE_CUSTOM_COMPRESS +!ENDIF + +!IF "$(EFI_UNLOCK_FWH)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_UNLOCK_FWH +!ENDIF + +!IF "$(EFI_DXE_PERFORMANCE)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_DXE_PERFORMANCE +!ENDIF + +!IF "$(EFI_DEBUG_SERIAL_PRINT)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_DEBUG_SERIAL_PRINT +!ENDIF + +!IF "$(EFI_S3_RESUME)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_S3_RESUME +!ENDIF + +!IF "$(EFI_PEI_REPORT_STATUS_CODE)" == "YES" +C_STD_FLAGS = $(C_STD_FLAGS) /D EFI_PEI_REPORT_STATUS_CODE_ON +!ENDIF + +############################################################################### + +############################################################################### +# +# Collect final build flags for components. These flags are used to build +# any standard component and some non-standard components. +# +############################################################################### +C_FLAGS = $(C_STD_FLAGS) $(C_ARCH_FLAGS) $(C_PROJ_FLAGS) $(C_STD_INCLUDE) +ASM_FLAGS = $(ASM_STD_FLAGS) $(ASM_ARCH_FLAGS) $(ASM_PROJ_FLAGS) +LINK_FLAGS_DLL = $(LINK_STD_FLAGS) $(LINK_ARCH_FLAGS) $(LINK_PROJ_FLAGS) /DLL +LINK_FLAGS_EXE = $(LINK_STD_FLAGS) $(LINK_ARCH_FLAGS) $(LINK_PROJ_FLAGS) +LIB_FLAGS = $(LIB_STD_FLAGS) $(LIB_ARCH_FLAGS) $(LIB_PROJ_FLAGS) +EBC_C_FLAGS = $(EBC_C_STD_FLAGS) $(EBC_C_ARCH_FLAGS) $(EBC_C_PROJ_FLAGS) +EBC_LINK_FLAGS = $(EBC_LINK_STD_FLAGS) $(EBC_LINK_ARCH_FLAGS) $(EBC_LINK_PROJ_FLAGS) +EBC_LIB_FLAGS = $(EBC_LIB_STD_FLAGS) $(EBC_LIB_ARCH_FLAGS) $(EBC_LIB_PROJ_FLAGS) + +############################################################################### +# +# define X64 denpendant driver files +# +############################################################################### +!IF "$(EFI_BUILD_TARGET_X64)" == "YES" +BUILD_TARGET_PROCESSOR = X64 +DXE_IPL = DxeIplX64 +!ELSE +BUILD_TARGET_PROCESSOR = IA32 +DXE_IPL = DxeIpl +!ENDIF +############################################################################### +# +# define EFI specification denpendant driver files +# +############################################################################### +!IF "$(UEFI_MODE)" == "YES" +UEFI_PREFIX = Uefi +ATAPI_PASS_THRU_INF = Sample\Bus\Pci\AtapiExtPassThru\Dxe\AtapiExtPassThru.inf +!IF "$(CAPSULE_INF)" == "" +CAPSULE_INF = Sample\Universal\Capsule\RuntimeDxe\Capsule.inf +!ENDIF +DEVPATH_INF = Sample\Universal\DevicePath\Dxe\DevicePath.inf +!ELSE +UEFI_PREFIX = +CAPSULE_INF = +DEVPATH_INF = +ATAPI_PASS_THRU_INF = Sample\Bus\Pci\AtapiPassThru\Dxe\AtapiPassThru.inf +!ENDIF +############################################################################### +# +# define PIWG specification denpendant driver files +# +############################################################################### +!IF "$(PI_MODE)" == "YES" +PI_PREFIX = Pi +!ELSE +PI_PREFIX = +!ENDIF +############################################################################### +# +# define customized compress makefile +# +############################################################################### +CUSTOMIZEDCOMPRESS_MAKEFILE = $(EDK_TOOLS_SOURCE)\CustomizedCompress\Makefile +COMPRESS_METHOD = Dummy +############################################################################### +# +# define EFI_BINARY default path +# +############################################################################### +!IFNDEF EFI_BINARY +EFI_BINARY=$(EDK_TOOLS_OUTPUT)\Bin +!ENDIF + +EFI_PLATFORM_BIN=$(EFI_BINARY)\$(PROJECT_NAME)$(BUILD_TARGET_DIRECTORY) diff --git a/EdkCompatibilityPkg/Sample/Include/Efi2WinNT.h b/EdkCompatibilityPkg/Sample/Include/Efi2WinNT.h new file mode 100644 index 0000000000..031a1d96fc --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Include/Efi2WinNT.h @@ -0,0 +1,59 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Efi2WinNT.h + +Abstract: + + Tiano mechanism to create WIN32 EFI code. + + Only used for NT emulation environment. This file replaces the Tiano.h + when you need to access Win32 stuff in EFI. + + Don't access Win32 APIs directly allways go WinNtThunk protocol. + + In most envirnments gWinNt is a pointer to a EFI_WIN_NT_THUNK_PROTOCOL. + +--*/ + +#ifndef _EFI_WIN_NT_H_ +#define _EFI_WIN_NT_H_ + +// +// Win32 include files do not compile clean with /W4, so we use the warning +// pragma to suppress the warnings for Win32 only. This way our code can stil +// compile at /W4 (highest warning level) with /WX (warnings cause build +// errors). +// +#pragma warning(disable : 4115) +#pragma warning(disable : 4201) +#pragma warning(disable : 4214) +#pragma warning(disable : 4028) +#pragma warning(disable : 4133) + +#include "windows.h" + +// +// Set the warnings back on so the EFI code must be /W4. +// +#pragma warning(default : 4115) +#pragma warning(default : 4201) +#pragma warning(default : 4214) +// +// We replaced Tiano.h so we must include it. +// +#include "Tiano.h" + +#include EFI_PROTOCOL_DEFINITION (WinNtThunk) + +#endif diff --git a/EdkCompatibilityPkg/Sample/Include/EfiCompNameSupport.h b/EdkCompatibilityPkg/Sample/Include/EfiCompNameSupport.h new file mode 100644 index 0000000000..7159588ee1 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Include/EfiCompNameSupport.h @@ -0,0 +1,58 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCompNameSupport.h + +Abstract: + + Private data structures for the Console Splitter driver + +--*/ + +#ifndef EFI_COMPONENT_NAME_SUPPORT_H +#define EFI_COMPONENT_NAME_SUPPORT_H + +#include "Tiano.h" + +#ifndef EFI_SIZE_REDUCTION_APPLIED + +#define INSTALL_ALL_DRIVER_PROTOCOLS(ImageHandle, \ + SystemTable, \ + DriverBinding, \ + DriverBindingHandle, \ + ComponentName, \ + DriverConfiguration, \ + DriverDiagnostics) \ + EfiLibInstallAllDriverProtocols ((ImageHandle), \ + (SystemTable), \ + (DriverBinding), \ + (DriverBindingHandle), \ + (ComponentName), \ + (DriverConfiguration), \ + (DriverDiagnostics)) +#else + +#define INSTALL_ALL_DRIVER_PROTOCOLS(ImageHandle, \ + SystemTable, \ + DriverBinding, \ + DriverBindingHandle, \ + ComponentName, \ + DriverConfiguration, \ + DriverDiagnostics) \ + EfiLibInstallDriverBinding ((ImageHandle), \ + (SystemTable), \ + (DriverBinding), \ + (DriverBindingHandle)) +#endif + +#endif diff --git a/EdkCompatibilityPkg/Sample/Include/EfiWinNt.h b/EdkCompatibilityPkg/Sample/Include/EfiWinNt.h new file mode 100644 index 0000000000..7722e6a45a --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Include/EfiWinNt.h @@ -0,0 +1,46 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiWinNt.h + +Abstract: + + EFI master include file for WinNt components. + +--*/ + +#ifndef _EFI_WIN_NT_H_ + +#ifdef EFI_NT_EMULATOR + +#define _EFI_WIN_NT_H_ + +#pragma warning(disable : 4115) +#pragma warning(disable : 4201) +#pragma warning(disable : 4214) + +#include "windows.h" +#include "stdio.h" + +// +// Set the warnings back on so the EFI code must be /W4. +// +#pragma warning(default : 4115) +#pragma warning(default : 4201) +#pragma warning(default : 4214) + +#endif + +#include "Tiano.h" + +#endif diff --git a/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.c b/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.c new file mode 100644 index 0000000000..f883a9c500 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.c @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WinNtLib.c + +Abstract: + + Setup gWinNt global + +--*/ + +#include "Efi2WinNT.h" +#include "EfiWinNtLib.h" +#include "EfiDriverLib.h" +#include "EfiHobLib.h" +#include EFI_GUID_DEFINITION (Hob) + +EFI_WIN_NT_THUNK_PROTOCOL *gWinNt; + +EFI_GUID mEfiHobListGuid = EFI_HOB_LIST_GUID; + +EFI_STATUS +EfiInitializeWinNtDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Intialize gWinNt and initialize debug console. + +Arguments: + + (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) + +Returns: + + None + +--*/ +// TODO: ImageHandle - add argument and description to function comment +// TODO: SystemTable - add argument and description to function comment +// TODO: EFI_NOT_FOUND - add return value to function comment +// TODO: EFI_NOT_FOUND - add return value to function comment +// TODO: EFI_SUCCESS - add return value to function comment +{ + EFI_STATUS Status; + VOID *HobList; + VOID *Pointer; + + Status = EfiLibGetSystemConfigurationTable (&mEfiHobListGuid, &HobList); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + ASSERT (NULL != HobList); + Status = GetNextGuidHob (&HobList, &gEfiWinNtThunkProtocolGuid, &Pointer, NULL); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + gWinNt = (VOID *) (*(UINTN *) (Pointer)); + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.inf b/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.inf new file mode 100644 index 0000000000..bbadcb9ec2 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Library/Dxe/WinNt/WinNtLib.inf @@ -0,0 +1,49 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# WinNtLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME = WinNtLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + WinNtLib.c + +[libraries.common] + HobLib + EdkNt32ProtocolLib + +[includes.common] + $(EDK_SOURCE)\Sample\Platform\Nt32 + $(EDK_SOURCE)\Foundation\Framework + $(EDK_SOURCE)\Foundation + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi + . + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Sample\Include + + +[nmake.common] +C_STD_INCLUDE= diff --git a/EdkCompatibilityPkg/Sample/LocalTools.env b/EdkCompatibilityPkg/Sample/LocalTools.env new file mode 100644 index 0000000000..e5fe750388 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/LocalTools.env @@ -0,0 +1,95 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# LocalTools.env +# +# Abstract: +# +# This file is included by CommonTools.env, which is included by +# makefiles when building. +# +# It can be customized to identify the locations of the tools +# necessary to build the EFI source code for different systems. +# +#--*/ + +# +# Customize to define the base path to MASM for IA32 +# +!IFNDEF MASMPATH +MASMPATH = c:\masm611 +!ENDIF + +# +# Customize to define the base path to iASL +# +!IFNDEF ASLPATH +ASLPATH = c:\Asl +!ENDIF + +# +# Customize to define the base path to the tools for IPF +# +!IFNDEF EFI_IA64TOOLPATH +!IF "$(USE_NEWDDK)" == "YES" +EFI_IA64TOOLPATH = C:\WINDDK\3790.1830\bin\win64\x86 +!ELSE +EFI_IA64TOOLPATH = C:\DDK3790 +!ENDIF +!ENDIF + +!IFNDEF EFI_IA64ASMPATH +!IF "$(USE_NEWDDK)" == "YES" +EFI_IA64ASMPATH = C:\WINDDK\3790.1830\bin\win64\x86 +!ELSE +EFI_IA64ASMPATH = C:\DDK3790 +!ENDIF +!ENDIF + +# +# Customize to define the base path to the EBC tools +# +!IFNDEF EBC_TOOLS_PATH +EBC_TOOLS_PATH = c:\progra~1\intel\ebc +!ENDIF + +# +# Customize to define the base path to WINDDK for X64 +# +!IFNDEF WIN_DDK_PATH +WIN_DDK_X64_PATH = C:\WINDDK\3790.1830\bin\win64\x86\amd64 +!ELSE +WIN_DDK_X64_PATH = $(WIN_DDK_PATH)\bin\win64\x86\amd64 +!ENDIF + +# +# Customize to define the base path to VC8 for X64 +# +!IF "$(USE_VC8_X64)" == "YES" +!IFNDEF VCINSTALLDIR +VC8_X64_PATH = c:\Program Files\Microsoft Visual Studio 8\VC\bin\x86_amd64 +!ELSE +VC8_X64_PATH = $(VCINSTALLDIR)\bin\x86_amd64 +!ENDIF +!ENDIF + +# +# Customize to define the base path to VC8 for IPF +# +!IF "$(USE_VC8_IPF)" == "YES" +!IFNDEF VCINSTALLDIR +VC8_IPF_PATH = c:\Program Files\Microsoft Visual Studio 8\VC\bin\x86_ia64 +!ELSE +VC8_IPF_PATH = $(VCINSTALLDIR)\bin\x86_ia64 +!ENDIF +!ENDIF diff --git a/EdkCompatibilityPkg/Sample/Platform/Common.dsc b/EdkCompatibilityPkg/Sample/Platform/Common.dsc new file mode 100644 index 0000000000..c40c4e7de8 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/Common.dsc @@ -0,0 +1,1522 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Common.dsc +# +# Abstract: +# +# This is the build description file containing the platform +# independent build instructions. Platform specific instructions will +# be prepended to produce the final build DSC file. +# +# +# Notes: +# +# The info in this file is broken down into sections. The start of a section +# is designated by a "[" in the first column. So the [=====] separater ends +# a section. +# +#--*/ + +[=============================================================================] +# +# These get emitted at the top of the generated master makefile. +# +[=============================================================================] +[Makefile.out] +# +# From the [makefile.out] section of the DSC file +# +TOOLCHAIN = +MAKE = nmake -nologo + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +all : libraries fvs + +[=============================================================================] +# +# These get expanded and dumped out to each component makefile after the +# component INF [defines] section gets parsed. +# +[=============================================================================] +[Makefile.Common] +# +# From the [Makefile.Common] section of the description file. +# +PROCESSOR = $(PROCESSOR) +BASE_NAME = $(BASE_NAME) +BUILD_NUMBER = $(BUILD_NUMBER) +VERSION_STRING = $(VERSION_STRING) +TOOLCHAIN = TOOLCHAIN_$(PROCESSOR) +FILE_GUID = $(FILE_GUID) +COMPONENT_TYPE = $(COMPONENT_TYPE) +FV_DIR = $(BUILD_DIR)\FV +PLATFORM = $(PROJECT_NAME) + +# +# Define the global dependency files +# +!IF EXIST ($(DEST_DIR)\$(BASE_NAME)StrDefs.h) +INC_DEPS = $(INC_DEPS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h +!ENDIF +#ENV_DEPS = $(ENV_DEPS) $(EDK_SOURCE)\Sample\CommonTools.env +#ENV_DEPS = $(ENV_DEPS) $(BUILD_DIR)\PlatformTools.env +#ENV_DEPS = $(ENV_DEPS) $(BUILD_DIR)\Config.env +ALL_DEPS = $(INC_DEPS) $(ENV_DEPS) + +!IF "$(LANGUAGE)" != "" +LANGUAGE_FLAGS = -lang $(LANGUAGE) +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +!IF "$(COMPONENT_TYPE)" == "PIC_PEIM" || "$(COMPONENT_TYPE)" == "PE32_PEIM" || "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM" || "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER" +DEPEX_TYPE = EFI_SECTION_PEI_DEPEX +!ELSE +DEPEX_TYPE = EFI_SECTION_DXE_DEPEX +!ENDIF + +# +# Command flags for MAKEDEPS tool +# +DEP_FLAGS = -target $** -o $(DEP_FILE) $(INC) -ignorenotfound -q + +[=============================================================================] +# +# These are the commands to compile source files. One of these blocks gets +# emitted to the component's makefile for each source file. The section +# name is encoded as [Compile.$(PROCESSOR).source_filename_extension], where +# the source filename comes from the sources section of the component INF file. +# +# If the dependency list file already exists, then include it for this +# source file. If it doesn't exist, then this is a clean build and the +# dependency file will get created below and the source file will get +# compiled. +# +# Current behavior is that the first clean build will not create dep files. +# But the following second build has to create dep files before build source files. +# CREATEDEPS flag is used to judge whether current build is the second build or not. +# +# +[=============================================================================] +[Compile.Ia32.asm,Compile.x64.asm] + +DEP_FILE = $(DEST_DIR)\$(FILE)Asm.dep + +!IF EXIST($(DEST_DIR)\$(FILE).obj) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Asm.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) -asm + +# +# Compile the file +# +$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(ASM) $(ASM_FLAGS) $(SOURCE_FILE_NAME) + +[=============================================================================] +[Compile.Ipf.s] + +DEP_FILE = $(DEST_DIR)\$(FILE)S.dep + +!IF EXIST($(DEST_DIR)\$(FILE).pro) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)S.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).pro + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) + +# +# Compile the file +# +$(DEST_DIR)\$(FILE).pro : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(CC) $(C_FLAGS_PRO) $(SOURCE_FILE_NAME) > $@ + +$(DEST_DIR)\$(FILE).obj : $(DEST_DIR)\$(FILE).pro + $(ASM) $(ASM_FLAGS) $(DEST_DIR)\$(FILE).pro + +[=============================================================================] +[Compile.Ia32.c,Compile.Ipf.c,Compile.x64.c] + +DEP_FILE = $(DEST_DIR)\$(FILE).dep + +!IF EXIST($(DEST_DIR)\$(FILE).obj) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE).dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) + +# +# Compile the file +# +$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(CC) $(C_FLAGS) $(SOURCE_FILE_NAME) + +[=============================================================================] +[Compile.Ebc.c] + +DEP_FILE = $(DEST_DIR)\$(FILE).dep + +!IF EXIST($(DEST_DIR)\$(FILE).obj) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE).dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) + +# +# Compile the file +# +$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(EBC_CC) $(EBC_C_FLAGS) $(SOURCE_FILE_NAME) + +[=============================================================================] +# +# Commands for compiling a ".apr" Apriori source file. +# +[=============================================================================] +[Compile.Ia32.Apr,Compile.Ipf.Apr,Compile.Ebc.Apr,Compile.x64.Apr] +# +# Create the raw binary file. If you get an error on the build saying it doesn't +# know how to create the .apr file, then you're missing (or mispelled) the +# "APRIORI=" on the component lines in components section in the DSC file. +# +$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME) + $(GENAPRIORI) -v -f $(SOURCE_FILE_NAME) -o $(DEST_DIR)\$(BASE_NAME).bin + +$(DEST_DIR)\$(BASE_NAME).sec : $(DEST_DIR)\$(BASE_NAME).bin + $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW + +[=============================================================================] +[Build.Ia32.Apriori,Build.Ipf.Apriori,Build.Ebc.Apriori,Build.x64.Apriori] + +all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).FFS + +# +# Run GenFfsFile on the package file and .raw file to create the firmware file +# +$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).FFS : $(DEST_DIR)\$(BASE_NAME).sec $(PACKAGE_FILENAME) + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +[Build.Ia32.Makefile,Build.Ipf.Makefile,Build.Ebc.Makefile,Build.x64.Makefile] + +# +# Copy the makefile directly from the source directory, then make it +# writable so we can copy over it later if we try to. +# +$(DEST_DIR)\makefile.new : $(SOURCE_DIR)\makefile.new + copy $(SOURCE_DIR)\makefile.new $(DEST_DIR)\makefile.new + attrib -r $(DEST_DIR)\makefile.new + +# +# Make the all target, set some required macros. +# +call_makefile : + $(MAKE) -f $(DEST_DIR)\makefile.new all \ + SOURCE_DIR=$(SOURCE_DIR) \ + BUILD_DIR=$(BUILD_DIR) \ + FILE_GUID=$(FILE_GUID) \ + DEST_DIR=$(DEST_DIR) \ + PROCESSOR=$(PROCESSOR) \ + TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \ + BASE_NAME=$(BASE_NAME) \ + PACKAGE_FILENAME=$(PACKAGE_FILENAME) + +all : $(DEST_DIR)\makefile.new call_makefile + +# +# Remove the generated temp and final files for this modules. +# +clean : + @- $(MAKE) -f $(DEST_DIR)\makefile.new clean > NUL 2>&1 +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +# +# Instructions for building a component that uses a custom makefile. Encoding +# is [build.$(PROCESSOR).$(BUILD_TYPE)]. +# +# To build these components, simply call the makefile from the source +# directory. +# +[=============================================================================] +[Build.Ia32.Custom_Makefile,Build.Ipf.Custom_Makefile,Build.Ebc.Custom_Makefile,Build.x64.Custom_Makefile] + +# +# Just call the makefile from the source directory, passing in some +# useful info. +# +all : + $(MAKE) -f $(SOURCE_DIR)\makefile all \ + SOURCE_DIR=$(SOURCE_DIR) \ + BUILD_DIR=$(BUILD_DIR) \ + DEST_DIR=$(DEST_DIR) \ + FILE_GUID=$(FILE_GUID) \ + PROCESSOR=$(PROCESSOR) \ + TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \ + BASE_NAME=$(BASE_NAME) \ + PLATFORM=$(PLATFORM) \ + SOURCE_FV=$(SOURCE_FV) \ + PACKAGE_FILENAME=$(PACKAGE_FILENAME) + +# +# Remove the generated temp and final files for this modules. +# +clean : + @- $(MAKE) -f $(SOURCE_DIR)\makefile clean > NUL 2>&1 +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +# +# These commands are used to build libraries +# +[=============================================================================] +[Build.Ia32.LIBRARY,Build.Ipf.LIBRARY,Build.x64.LIBRARY] +# +# LIB all the object files into to our target lib file. Put +# a dependency on the component's INF file in case it changes. +# +LIB_NAME = $(LIB_DIR)\$(BASE_NAME).lib + +$(LIB_NAME) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS) + $(LIB) $(LIB_FLAGS) $(OBJECTS) $(LIBS) /OUT:$@ + +!IF "$(CREATEDEPS)"=="YES" +all : $(DEP_TARGETS) + $(MAKE) -f $(MAKEFILE_NAME) all +!ELSE +all : $(LIB_NAME) $(DEP_TARGETS) +!ENDIF + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +[Build.Ebc.LIBRARY] +# +# LIB all the object files into to our target lib file. Put +# a dependency on the component's INF file in case it changes. +# +LIB_NAME = $(LIB_DIR)\$(BASE_NAME).lib + +$(LIB_NAME) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS) + $(EBC_LIB) $(EBC_LIB_FLAGS) $(OBJECTS) $(LIBS) /OUT:$@ + +!IF "$(CREATEDEPS)"=="YES" +all : $(DEP_TARGETS) + $(MAKE) -f $(MAKEFILE_NAME) all +!ELSE +all : $(LIB_NAME) $(DEP_TARGETS) +!ENDIF + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +# +# This is the Build.$(PROCESSOR).$(COMPONENT_TYPE) section that tells how to +# convert a firmware volume into an FV FFS file. Simply run it through +# GenFfsFile with the appropriate package file. SOURCE_FV must be defined +# in the component INF file Defines section. +# +[=============================================================================] +[Build.Ia32.FvImageFile,Build.x64.FvImageFile,Build.Ipf.FvImageFile] + +all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).Fvi + +# +# Run GenFfsFile on the package file and FV file to create the firmware +# volume FFS file. This FFS file maybe contain one pad section for alignment requirement. +# +$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).Fvi : $(DEST_DIR)\$(SOURCE_FV)Fv.sec $(PACKAGE_FILENAME) $(PAD_SECTION) + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +# +# Since many of the steps are the same for the different component types, we +# share this section for BS_DRIVER, RT_DRIVER, .... and IFDEF the parts that +# differ. The entire section gets dumped to the output makefile. +# +[=============================================================================] +[Build.Ia32.BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|PE32_PEIM|PEI_CORE|PIC_PEIM|RELOCATABLE_PEIM|DXE_CORE|APPLICATION|COMBINED_PEIM_DRIVER, Build.Ipf.BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|PEI_CORE|PE32_PEIM|PIC_PEIM|DXE_CORE|APPLICATION|COMBINED_PEIM_DRIVER, Build.x64.BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|PE32_PEIM|PEI_CORE|PIC_PEIM|RELOCATABLE_PEIM|DXE_CORE|APPLICATION|COMBINED_PEIM_DRIVER] + +!IF "$(LOCALIZE)" == "YES" + +!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES" +STRGATHER_FLAGS = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk + +# +# There will be one HII pack containing all the strings. Add that file +# to the list of HII pack files we'll use to create our final HII export file. +# +HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk +LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii +!ENDIF + +$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES) + $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \ + -skipext .uni -skipext .h $(SOURCE_FILES) + +$(DEST_DIR)\$(BASE_NAME)Strings.c : $(DEST_DIR)\$(BASE_NAME).sdb + $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \ + -oc $(DEST_DIR)\$(BASE_NAME)Strings.c + +$(DEST_DIR)\$(BASE_NAME)StrDefs.h : $(DEST_DIR)\$(BASE_NAME).sdb + $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \ + -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h + +$(DEST_DIR)\$(BASE_NAME)Strings.hpk : $(DEST_DIR)\$(BASE_NAME).sdb + $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \ + -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk + +OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj + +$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS) + $(CC) $(C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c + +LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h + +!ENDIF + +# +# If we have any objects associated with this component, then we're +# going to build a local library from them. +# +!IFNDEF OBJECTS +!ERROR No source files to build were defined in the INF file +!ENDIF + +TARGET_LOCAL_LIB = $(DEST_DIR)\$(BASE_NAME)Local.lib + +# +# LIB all the object files into our (local) target lib file. Put +# a dependency on the component's INF file in case it changes. +# +$(TARGET_LOCAL_LIB) : $(OBJECTS) $(INF_FILENAME) $(ENV_DEPS) + $(LIB) $(LIB_FLAGS) $(OBJECTS) /OUT:$@ + +# +# Defines for standard intermediate files and build targets +# +TARGET_DLL = $(BIN_DIR)\$(BASE_NAME).dll +TARGET_EFI = $(BIN_DIR)\$(BASE_NAME).efi +TARGET_DPX = $(DEST_DIR)\$(BASE_NAME).dpx +TARGET_UI = $(DEST_DIR)\$(BASE_NAME).ui +TARGET_VER = $(DEST_DIR)\$(BASE_NAME).ver +TARGET_MAP = $(BIN_DIR)\$(BASE_NAME).map +TARGET_PDB = $(BIN_DIR)\$(BASE_NAME).pdb +TARGET_SYM = $(BIN_DIR)\$(BASE_NAME).sym + +# +# Target executable section extension depends on the component type. +# Only define "TARGET_DXE_DPX" if it's a combined peim driver. +# +!IF "$(COMPONENT_TYPE)" == "PIC_PEIM" +TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pic +!ELSE +TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32 +!ENDIF + +# +# Target FFS file extension depends on the component type +# Also define "TARGET_DXE_DPX" if it's a combined PEIM driver. +# +SUBSYSTEM = EFI_BOOT_SERVICE_DRIVER + +!IF "$(COMPONENT_TYPE)" == "APPLICATION" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app +SUBSYSTEM = EFI_APPLICATION +!ELSE IF "$(COMPONENT_TYPE)" == "PEI_CORE" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei +!ELSE IF "$(COMPONENT_TYPE)" == "PE32_PEIM" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei +!ELSE IF "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei +!ELSE IF "$(COMPONENT_TYPE)" == "PIC_PEIM" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei +!ELSE IF "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei +TARGET_DXE_DPX = $(DEST_DIR)\$(BASE_NAME).dpxd +!ELSE +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe +!ENDIF + +# +# Different methods to build section based on if PIC_PEIM +# +!IF "$(COMPONENT_TYPE)" == "PIC_PEIM" + +$(TARGET_PE32) : $(TARGET_DLL) + $(PE2BIN) $(TARGET_DLL) $(DEST_DIR)\$(BASE_NAME).TMP +# +# BUGBUG: Build PEIM header, needs to go away with new PEI. +# + $(TEMPGENSECTION) -P $(SOURCE_DIR)\$(BASE_NAME).INF -I $(DEST_DIR)\$(BASE_NAME).TMP -O $(TARGET_PIC_PEI).tmp -M $(TARGET_MAP) -S EFI_SECTION_TYPE_NO_HEADER + $(GENSECTION) -I $(TARGET_PIC_PEI).tmp -O $(TARGET_PE32) -S EFI_SECTION_PIC + del $(DEST_DIR)\$(BASE_NAME).TMP + +!ELSE + +$(TARGET_PE32) : $(TARGET_EFI) + $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32 + +# +# Run FWImage on the DLL to set it as an EFI image type. +# +$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME) + $(FWIMAGE) -t 0 $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI) + +!ENDIF + +# +# Link all objects and libs to create the executable +# +$(TARGET_DLL) : $(TARGET_LOCAL_LIB) $(LIBS) $(INF_FILENAME) $(ENV_DEPS) + $(LINK) $(LINK_FLAGS_DLL) $(LIBS) /ENTRY:$(IMAGE_ENTRY_POINT) \ + $(TARGET_LOCAL_LIB) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP) \ + /PDB:$(TARGET_PDB) + $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt +!IF "$(EFI_GENERATE_SYM_FILE)" == "YES" + if exist $(TARGET_PDB) $(PE2SYM) $(TARGET_PDB) $(TARGET_SYM) +!ENDIF + +!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES" + $(ZERODEBUGDATA) $(TARGET_DLL) +!ENDIF + +# +# Create the user interface section +# +$(TARGET_UI) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)" + +# +# Create the version section +# +!IF "$(BUILD_NUMBER)" != "" +!IF "$(VERSION_STRING)" != "" +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)" +!ELSE +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) +!ENDIF +!ELSE +$(TARGET_VER) : + echo.>$(TARGET_VER) + type $(TARGET_VER)>$(TARGET_VER) +!ENDIF + +# +# Makefile entries to create the dependency expression section. +# Use the DPX file from the source directory unless an override file +# was specified. +# If no DPX source file was specified, then create an empty file to +# be used. +# +!IF "$(DPX_SOURCE)" != "" +DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE) +!ENDIF + +!IF "$(DPX_SOURCE_OVERRIDE)" != "" +DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE) +!ENDIF + +!IF "$(DPX_SOURCE_FILE)" != "" +!IF EXIST ($(DPX_SOURCE_FILE)) +# +# Add dependency check for dxs file, because dxs file depends on PPI or +# PROTOCOL guid defintions. +# +DEP_FILE = $(DEST_DIR)\$(BASE_NAME)dxs.dep + +!IF EXIST($(TARGET_DPX)) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(TARGET_DPX) + $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS) + +$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME) + $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1 + $(GENDEPEX) -I $*.tmp1 -O $*.tmp2 + $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE) + del $*.tmp1 > NUL + del $*.tmp2 > NUL +!ELSE +!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist. +!ENDIF +!ELSE +$(TARGET_DPX) : + echo. > $(TARGET_DPX) + type $(TARGET_DPX) > $(TARGET_DPX) +!ENDIF + +# +# Makefile entries for DXE DPX for combined PEIM drivers. +# If a DXE_DPX_SOURCE file was specified in the INF file, use it. Otherwise +# create an empty file and use it as a DPX file. +# +!IF "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER" +!IF "$(DXE_DPX_SOURCE)" != "" +!IF EXIST ($(SOURCE_DIR)\$(DXE_DPX_SOURCE)) +$(TARGET_DXE_DPX) : $(SOURCE_DIR)\$(DXE_DPX_SOURCE) $(INF_FILENAME) + $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(SOURCE_DIR)\$(DXE_DPX_SOURCE) > $*.tmp1 + $(GENDEPEX) -I $*.tmp1 -O $*.tmp2 + $(GENSECTION) -I $*.tmp2 -O $@ -S EFI_SECTION_DXE_DEPEX + del $*.tmp1 > NUL + del $*.tmp2 > NUL +!ELSE +!ERROR Dependency expression source file "$(SOURCE_DIR)\$(DXE_DPX_SOURCE)" does not exist. +!ENDIF +!ELSE +$(TARGET_DXE_DPX) : + echo. > $(TARGET_DXE_DPX) + type $(TARGET_DXE_DPX) > $(TARGET_DXE_DPX) +!ENDIF +!ENDIF + +# +# Describe how to build the HII export file from all the input HII pack files. +# Use the FFS file GUID for the package GUID in the export file. Only used +# when multiple VFR share strings. +# +$(DEST_DIR)\$(BASE_NAME).hii : $(HII_PACK_FILES) + $(HIIPACK) create -g $(FILE_GUID) -p $(HII_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME).hii + +# +# If the build calls for creating an FFS file with the IFR included as +# a separate binary (not compiled into the driver), then build the binary +# section now. Note that the PACKAGE must be set correctly to actually get +# this IFR section pulled into the FFS file. +# +!IF ("$(HII_IFR_PACK_FILES)" != "") + +$(DEST_DIR)\$(BASE_NAME)IfrBin.sec : $(HII_IFR_PACK_FILES) + $(HIIPACK) create -novarpacks -p $(HII_IFR_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME)IfrBin.hii + $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME)IfrBin.hii -O $(DEST_DIR)\$(BASE_NAME)IfrBin.sec -S EFI_SECTION_RAW + +BIN_TARGETS = $(BIN_TARGETS) $(DEST_DIR)\$(BASE_NAME)IfrBin.sec + +!ENDIF + +# +# Build a FFS file from the sections and package +# +$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(TARGET_DXE_DPX) $(PACKAGE_FILENAME) +# +# Some of our components require padding to align code +# +!IF "$(PROCESSOR)" == "IPF" +!IF "$(COMPONENT_TYPE)" == "PIC_PEIM" || "$(COMPONENT_TYPE)" == "PE32_PEIM" || "$(COMPONENT_TYPE)" == "RELOCATABLE_PEIM" || "$(COMPONENT_TYPE)" == "SECURITY_CORE" || "$(COMPONENT_TYPE)" == "PEI_CORE" || "$(COMPONENT_TYPE)" == "COMBINED_PEIM_DRIVER" + copy $(BIN_DIR)\Blank.pad $(DEST_DIR) +!ENDIF +!ENDIF + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +!IF "$(CREATEDEPS)"=="YES" +all : $(DEP_TARGETS) + $(MAKE) -f $(MAKEFILE_NAME) all +!ELSE +all : $(LOCALIZE_TARGETS) $(BIN_TARGETS) $(TARGET_FFS_FILE) $(DEP_TARGETS) +!ENDIF + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +[Build.Ia32.TE_PEIM,Build.Ipf.TE_PEIM,Build.x64.TE_PEIM] +# +# Define the library file we'll build if we have any objects defined. +# +!IFDEF OBJECTS +TARGET_LOCAL_LIB = $(DEST_DIR)\$(BASE_NAME)Local.lib +# +# LIB all the object files into our (local) target lib file. Put +# a dependency on the component's INF file in case it changes. +# +$(TARGET_LOCAL_LIB) : $(OBJECTS) $(INF_FILENAME) $(ENV_DEPS) + $(LIB) $(LIB_FLAGS) $(OBJECTS) /OUT:$@ + +!ELSE +!ERROR No source files to build were defined in the INF file +!ENDIF + +# +# Defines for standard intermediate files and build targets +# +TARGET_DLL = $(BIN_DIR)\$(BASE_NAME).dll +TARGET_EFI = $(BIN_DIR)\$(BASE_NAME).efi +TARGET_DPX = $(DEST_DIR)\$(BASE_NAME).dpx +TARGET_UI = $(DEST_DIR)\$(BASE_NAME).ui +TARGET_VER = $(DEST_DIR)\$(BASE_NAME).ver +TARGET_MAP = $(BIN_DIR)\$(BASE_NAME).map +TARGET_PDB = $(BIN_DIR)\$(BASE_NAME).pdb +TARGET_SYM = $(BIN_DIR)\$(BASE_NAME).sym +TARGET_TE = $(BIN_DIR)\$(BASE_NAME).te +TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32 +TARGET_TES = $(DEST_DIR)\$(BASE_NAME).tes +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei + +# +# Create our TE section from our TE file +# +$(TARGET_TES) : $(TARGET_TE) + $(GENSECTION) -I $(TARGET_TE) -O $(TARGET_TES) -S EFI_SECTION_TE + +# +# Run FWImage on the DLL to set it as an EFI image type. +# +$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME) + $(FWIMAGE) $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI) + +# +# Run GenTEImage on the built .efi file to create our TE file. +# +$(TARGET_TE) : $(TARGET_EFI) + $(GENTEIMAGE) -o $(TARGET_TE) $(TARGET_EFI) + +# +# Link all objects and libs to create the executable +# +$(TARGET_DLL) : $(TARGET_LOCAL_LIB) $(LIBS) $(INF_FILENAME) $(ENV_DEPS) + $(LINK) $(LINK_FLAGS_DLL) $(LIBS) /ENTRY:$(IMAGE_ENTRY_POINT) \ + $(TARGET_LOCAL_LIB) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP) \ + /PDB:$(TARGET_PDB) + $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt +!IF "$(EFI_GENERATE_SYM_FILE)" == "YES" + if exist $(TARGET_PDB) $(PE2SYM) $(TARGET_PDB) $(TARGET_SYM) +!ENDIF + +!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES" + $(ZERODEBUGDATA) $(TARGET_DLL) +!ENDIF + +# +# Create the user interface section +# +$(TARGET_UI) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)" + +# +# Create the version section +# +!IF "$(BUILD_NUMBER)" != "" +!IF "$(VERSION_STRING)" != "" +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)" +!ELSE +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) +!ENDIF +!ELSE +$(TARGET_VER) : + echo.>$(TARGET_VER) + type $(TARGET_VER)>$(TARGET_VER) +!ENDIF + +# +# Makefile entries to create the dependency expression section. +# Use the DPX file from the source directory unless an override file +# was specified. +# If no DPX source file was specified, then create an empty file to +# be used. +# +!IF "$(DPX_SOURCE)" != "" +DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE) +!ENDIF + +!IF "$(DPX_SOURCE_OVERRIDE)" != "" +DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE) +!ENDIF + +!IF "$(DPX_SOURCE_FILE)" != "" +!IF EXIST ($(DPX_SOURCE_FILE)) +# +# Add dependency check for dxs file, because dxs file depends on PPI or +# PROTOCOL guid defintions. +# +DEP_FILE = $(DEST_DIR)\$(BASE_NAME)dxs.dep + +!IF EXIST($(TARGET_DPX)) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(TARGET_DPX) + $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS) + +$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME) + $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1 + $(GENDEPEX) -I $*.tmp1 -O $*.tmp2 + $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE) + del $*.tmp1 > NUL + del $*.tmp2 > NUL +!ELSE +!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist. +!ENDIF +!ELSE +$(TARGET_DPX) : + echo. > $(TARGET_DPX) + type $(TARGET_DPX) > $(TARGET_DPX) +!ENDIF + +# +# Build an FFS file from the sections and package +# +$(TARGET_FFS_FILE) : $(TARGET_TES) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME) + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +!IF "$(CREATEDEPS)"=="YES" +all : $(DEP_TARGETS) + $(MAKE) -f $(MAKEFILE_NAME) all +!ELSE +all : $(TARGET_FFS_FILE) $(DEP_TARGETS) +!ENDIF + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +# +# These are the commands to build EBC EFI targets +# +[=============================================================================] +[Build.Ebc.BS_DRIVER|RT_DRIVER|APPLICATION] + +# +# Add the EBC library to our list of libs +# +LIBS = $(LIBS) $(EBC_TOOLS_PATH)\lib\EbcLib.lib + +!IF "$(LOCALIZE)" == "YES" + +!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES" +STRGATHER_FLAGS = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk + +# +# There will be one HII pack containing all the strings. Add that file +# to the list of HII pack files we'll use to create our final HII export file. +# +HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk + +LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii +!ENDIF + +$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES) + $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \ + -skipext .uni -skipext .h $(SOURCE_FILES) + +$(DEST_DIR)\$(BASE_NAME)Strings.c : $(DEST_DIR)\$(BASE_NAME).sdb + $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \ + -oc $(DEST_DIR)\$(BASE_NAME)Strings.c + +$(DEST_DIR)\$(BASE_NAME)StrDefs.h : $(DEST_DIR)\$(BASE_NAME).sdb + $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \ + -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h + +$(DEST_DIR)\$(BASE_NAME)Strings.hpk : $(DEST_DIR)\$(BASE_NAME).sdb + $(STRGATHER) -dump $(LANGUAGE_FLAGS) -bn $(BASE_NAME)Strings -db $(DEST_DIR)\$(BASE_NAME).sdb \ + -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk + +OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj + +$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS) + $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c + +LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h + +!ENDIF + +# +# If building an application, then the target is a .app, not .dxe +# +!IF "$(COMPONENT_TYPE)" == "APPLICATION" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app +SUBSYSTEM = EFI_APPLICATION +!ELSE +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe +SUBSYSTEM = EFI_BOOT_SERVICE_DRIVER +!ENDIF + +# +# Defines for standard intermediate files and build targets +# +TARGET_EFI = $(BIN_DIR)\$(BASE_NAME).efi +TARGET_DPX = $(DEST_DIR)\$(BASE_NAME).dpx +TARGET_UI = $(DEST_DIR)\$(BASE_NAME).ui +TARGET_VER = $(DEST_DIR)\$(BASE_NAME).ver +TARGET_MAP = $(BIN_DIR)\$(BASE_NAME).map +TARGET_PDB = $(BIN_DIR)\$(BASE_NAME).pdb +TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32 +TARGET_DLL = $(BIN_DIR)\$(BASE_NAME).dll + +# +# First link all the objects and libs together to make a .dll file +# +$(TARGET_DLL) : $(OBJECTS) $(LIBS) $(INF_FILENAME) $(ENV_DEPS) + $(EBC_LINK) $(EBC_LINK_FLAGS) /SUBSYSTEM:$(SUBSYSTEM) /ENTRY:EfiStart \ + $(OBJECTS) $(LIBS) /OUT:$(TARGET_DLL) /MAP:$(TARGET_MAP) + $(SETSTAMP) $(TARGET_DLL) $(BUILD_DIR)\GenStamp.txt +!IF "$(EFI_ZERO_DEBUG_DATA)" == "YES" + $(ZERODEBUGDATA) $(TARGET_DLL) +!ENDIF + +# +# Now take the .dll file and make a .efi file +# +$(TARGET_EFI) : $(TARGET_DLL) $(INF_FILENAME) + $(FWIMAGE) -t 0 $(COMPONENT_TYPE) $(TARGET_DLL) $(TARGET_EFI) + +# +# Now take the .efi file and make a .pe32 section +# +$(TARGET_PE32) : $(TARGET_EFI) + $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32 + +# +# Create the user interface section +# +$(TARGET_UI) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)" + +# +# Create the version section +# +!IF "$(BUILD_NUMBER)" != "" +!IF "$(VERSION_STRING)" != "" +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)" +!ELSE +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) +!ENDIF +!ELSE +$(TARGET_VER) : + echo. > $(TARGET_VER) + type $(TARGET_VER) > $(TARGET_VER) +!ENDIF + +# +# Makefile entries to create the dependency expression section. +# Use the DPX file from the source directory unless an override file +# was specified. +# If no DPX source file was specified, then create an empty file to +# be used. +# +!IF "$(DPX_SOURCE)" != "" +DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE) +!ENDIF + +!IF "$(DPX_SOURCE_OVERRIDE)" != "" +DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE) +!ENDIF + +!IF "$(DPX_SOURCE_FILE)" != "" +!IF EXIST ($(DPX_SOURCE_FILE)) +# +# Add dependency check for dxs file, because dxs file depends on PPI or +# PROTOCOL guid defintions. +# +DEP_FILE = $(DEST_DIR)\$(BASE_NAME)dxs.dep + +!IF EXIST($(TARGET_DPX)) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(TARGET_DPX) + $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS) + +$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME) + $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1 + $(GENDEPEX) -I $*.tmp1 -O $*.tmp2 + $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE) + del $*.tmp1 > NUL + del $*.tmp2 > NUL +!ELSE +!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist. +!ENDIF +!ELSE +$(TARGET_DPX) : + echo. > $(TARGET_DPX) + type $(TARGET_DPX) > $(TARGET_DPX) +!ENDIF + +# +# Describe how to build the HII export file from all the input HII pack files. +# Use the FFS file GUID for the package GUID in the export file. Only used +# when multiple VFR share strings. +# +$(DEST_DIR)\$(BASE_NAME).hii : $(HII_PACK_FILES) + $(HIIPACK) create -g $(FILE_GUID) -p $(HII_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME).hii + +# +# If the build calls for creating an FFS file with the IFR included as +# a separate binary (not compiled into the driver), then build the binary +# section now. Note that the PACKAGE must be set correctly to actually get +# this IFR section pulled into the FFS file. +# +!IF ("$(HII_IFR_PACK_FILES)" != "") + +$(DEST_DIR)\$(BASE_NAME)IfrBin.sec : $(HII_IFR_PACK_FILES) + $(HIIPACK) create -novarpacks -p $(HII_IFR_PACK_FILES) -o $(DEST_DIR)\$(BASE_NAME)IfrBin.hii + $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME)IfrBin.hii -O $(DEST_DIR)\$(BASE_NAME)IfrBin.sec -S EFI_SECTION_RAW + +BIN_TARGETS = $(BIN_TARGETS) $(DEST_DIR)\$(BASE_NAME)IfrBin.sec + +!ENDIF + +# +# Build an FFS file from the sections and package +# +$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME) + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +!IF "$(CREATEDEPS)"=="YES" +all : $(DEP_TARGETS) + $(MAKE) -f $(MAKEFILE_NAME) all +!ELSE +all : $(LOCALIZE_TARGETS) $(BIN_TARGETS) $(TARGET_FFS_FILE) $(DEP_TARGETS) +!ENDIF + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +# +# These are the commands to build vendor-provided *.EFI files into an FV. +# To use them, create an INF file with BUILD_TYPE=BS_DRIVER_EFI. +# This section, as it now exists, only supports boot service drivers. +# +[=============================================================================] +[Build.Ia32.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.Ipf.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.Ebc.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.x64.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI] +# +# Defines for standard intermediate files and build targets. For the source +# .efi file, take the one in the source directory if it exists. If there's not +# one there, look for one in the processor-specfic subdirectory. +# +!IF EXIST ("$(SOURCE_DIR)\$(BASE_NAME).efi") +TARGET_EFI = $(SOURCE_DIR)\$(BASE_NAME).efi +!ELSEIF EXIST ("$(SOURCE_DIR)\$(PROCESSOR)\$(BASE_NAME).efi") +TARGET_EFI = $(SOURCE_DIR)\$(PROCESSOR)\$(BASE_NAME).efi +!ELSE +!ERROR Pre-existing $(BASE_NAME).efi file not found in $(SOURCE_DIR) nor $(SOURCE_DIR)\$(PROCESSOR) +!ENDIF + +TARGET_DPX = $(DEST_DIR)\$(BASE_NAME).dpx +TARGET_UI = $(DEST_DIR)\$(BASE_NAME).ui +TARGET_VER = $(DEST_DIR)\$(BASE_NAME).ver +TARGET_MAP = $(BIN_DIR)\$(BASE_NAME).map +TARGET_PDB = $(BIN_DIR)\$(BASE_NAME).pdb +TARGET_PE32 = $(DEST_DIR)\$(BASE_NAME).pe32 +TARGET_DLL = $(BIN_DIR)\$(BASE_NAME).dll + +# +# If building an application, then the target is a .app, not .dxe +# +!IF "$(COMPONENT_TYPE)" == "APPLICATION" +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app +!ELSE +TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe +!ENDIF + +# +# Take the .efi file and make a .pe32 file +# +$(TARGET_PE32) : $(TARGET_EFI) + $(GENSECTION) -I $(TARGET_EFI) -O $(TARGET_PE32) -S EFI_SECTION_PE32 + +# +# Create the user interface section +# +$(TARGET_UI) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_UI) -S EFI_SECTION_USER_INTERFACE -A "$(BASE_NAME)" + +# +# Create the version section +# +!IF "$(BUILD_NUMBER)" != "" +!IF "$(VERSION_STRING)" != "" +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) -A "$(VERSION_STRING)" +!ELSE +$(TARGET_VER) : $(INF_FILENAME) + $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER) +!ENDIF +!ELSE +$(TARGET_VER) : + echo. > $(TARGET_VER) + type $(TARGET_VER) > $(TARGET_VER) +!ENDIF + +# +# Makefile entries to create the dependency expression section. +# Use the DPX file from the source directory unless an override file +# was specified. +# If no DPX source file was specified, then create an empty file to +# be used. +# +!IF "$(DPX_SOURCE)" != "" +DPX_SOURCE_FILE = $(SOURCE_DIR)\$(DPX_SOURCE) +!ENDIF + +!IF "$(DPX_SOURCE_OVERRIDE)" != "" +DPX_SOURCE_FILE = $(DPX_SOURCE_OVERRIDE) +!ENDIF + +!IF "$(DPX_SOURCE_FILE)" != "" +!IF EXIST ($(DPX_SOURCE_FILE)) +# +# Add dependency check for dxs file, because dxs file depends on PPI or +# PROTOCOL guid defintions. +# +DEP_FILE = $(DEST_DIR)\$(BASE_NAME)dxs.dep + +!IF EXIST($(TARGET_DPX)) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(BASE_NAME)dxs.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(TARGET_DPX) + $(MAKEDEPS) -f $(DPX_SOURCE_FILE) $(DEP_FLAGS) + +$(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME) + $(CC) /nologo $(INC) $(VERSION_FLAGS) /EP $(DPX_SOURCE_FILE) > $*.tmp1 + $(GENDEPEX) -I $*.tmp1 -O $*.tmp2 + $(GENSECTION) -I $*.tmp2 -O $@ -S $(DEPEX_TYPE) + del $*.tmp1 > NUL + del $*.tmp2 > NUL +!ELSE +!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist. +!ENDIF +!ELSE +$(TARGET_DPX) : + echo. > $(TARGET_DPX) + type $(TARGET_DPX) > $(TARGET_DPX) +!ENDIF + +# +# Build a FFS file from the sections and package +# +$(TARGET_FFS_FILE) : $(TARGET_PE32) $(TARGET_DPX) $(TARGET_UI) $(TARGET_VER) $(PACKAGE_FILENAME) + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +all : $(TARGET_FFS_FILE) + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +[Compile.Ia32.Bin|Bmp,Compile.x64.Bin|Bmp,Compile.Ipf.Bin|Bmp] +# +# We simply copy the binary file from the source directory to the destination directory +# +$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME) + copy $** $@ + +[=============================================================================] +[Build.Ia32.BINARY|Legacy16|Logo,Build.Ipf.BINARY|Legacy16|Logo,Build.x64.BINARY|Legacy16|Logo] +# +# Use GenFfsFile to convert it to an FFS file +# +$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME) + $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +[Build.Ia32.RAWFILE|CONFIG,Build.Ipf.RAWFILE|CONFIG,Build.x64.RAWFILE|CONFIG] +# +# Use GenFfsFile to convert it to an raw FFS file +# +$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME) + $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V + +all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw + +# +# Remove the generated temp and final files for this modules. +# +clean : +!IF ("$(FILE_GUID)" != "") + @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* +!ENDIF + @if exist $(BIN_DIR)\$(BASE_NAME).* del $(BIN_DIR)\$(BASE_NAME).* + @del /q $(DEST_OUTPUT_DIRS) + +[=============================================================================] +# +# These are commands to compile unicode .uni files. +# +[=============================================================================] +[Compile.Ia32.Uni,Compile.Ipf.Uni,Compile.Ebc.Uni,Compile.x64.Uni] +# +# Emit an error message if the file's base name is the same as the +# component base name. This causes build issues. +# +!IF "$(FILE)" == "$(BASE_NAME)" +!ERROR Component Unicode string file name cannot be the same as the component BASE_NAME. +!ENDIF + +# +# Always create dep file for uni file as it can be created at the same time when +# strgather is parsing uni file. +# +DEP_FILE = $(DEST_DIR)\$(FILE)Uni.dep + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +$(DEST_DIR)\$(FILE).sdb : $(SOURCE_FILE_NAME) $(INF_FILENAME) + $(STRGATHER) -parse -newdb -db $(DEST_DIR)\$(FILE).sdb -dep $(DEP_FILE) $(INC) $(SOURCE_FILE_NAME) + +SDB_FILES = $(SDB_FILES) $(DEST_DIR)\$(FILE).sdb +STRGATHER_FLAGS = $(STRGATHER_FLAGS) -db $(DEST_DIR)\$(FILE).sdb +LOCALIZE = YES + +[=============================================================================] +[Compile.Ia32.Vfr,Compile.Ipf.Vfr,Compile.x64.Vfr] + +DEP_FILE = $(DEST_DIR)\$(FILE)Vfr.dep + +!IF EXIST($(DEST_DIR)\$(FILE).obj) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) + +HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk + +# +# Add a dummy command for building the HII pack file. In reality, it's built +# below, but the C_FLAGS macro reference the target as $@, so you can't specify +# the obj and hpk files as dual targets of the same command. +# +$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj + +$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \ + -l $(VFR_FLAGS) $(SOURCE_FILE_NAME) + $(CC) $(C_FLAGS) $(DEST_DIR)\$(FILE).c + +[=============================================================================] +[Compile.Ebc.Vfr] + +DEP_FILE = $(DEST_DIR)\$(FILE)Vfr.dep + +!IF EXIST($(DEST_DIR)\$(FILE).obj) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) + +HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk + +# +# Add a dummy command for building the HII pack file. In reality, it's built +# below, but the C_FLAGS macro reference the target as $@, so you can't specify +# the obj and hpk files as dual targets of the same command. +# +$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj + +$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \ + -l $(VFR_FLAGS) $(SOURCE_FILE_NAME) + $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(FILE).c + +[=============================================================================] +# +# Commands for building IFR as uncompressed binary into the FFS file. To +# use it, set COMPILE_SELECT=.vfr=Ifr_Bin for the component in the DSC file. +# +[=============================================================================] +[Compile.Ia32.Ifr_Bin,Compile.Ipf.Ifr_Bin,Compile.x64.Ifr_Bin] + +DEP_FILE = $(DEST_DIR)\$(FILE)Vfr.dep + +!IF EXIST($(DEST_DIR)\$(FILE).obj) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) + +HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk + +# +# Add a dummy command for building the HII pack file. In reality, it's built +# below, but the C_FLAGS macro reference the target as $@, so you can't specify +# the obj and hpk files as dual targets of the same command. +# +$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj + +$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \ + -l $(VFR_FLAGS) $(SOURCE_FILE_NAME) + $(CC) $(C_FLAGS) $(DEST_DIR)\$(FILE).c + +# +# Add to the variable that contains the list of VFR binary files we're going +# to merge together at the end of the build. +# +HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk + +[=============================================================================] +# +# Commands for building IFR as uncompressed binary into the FFS file. To +# use it, set COMPILE_SELECT=.vfr=Ifr_Bin for the component in the DSC file. +# +[=============================================================================] +[Compile.Ebc.Ifr_Bin] + +DEP_FILE = $(DEST_DIR)\$(FILE)Vfr.dep + +!IF EXIST($(DEST_DIR)\$(FILE).obj) +DEP_TARGETS = $(DEP_TARGETS) $(DEST_DIR)\$(FILE)Vfr.dep +!IF !EXIST($(DEP_FILE)) +CREATEDEPS = YES +!ENDIF +!ENDIF + +!IF EXIST($(DEP_FILE)) +!INCLUDE $(DEP_FILE) +!ENDIF + +# +# Update dep file for next round incremental build +# +$(DEP_FILE) : $(DEST_DIR)\$(FILE).obj + $(MAKEDEPS) -f $(SOURCE_FILE_NAME) $(DEP_FLAGS) + +HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(FILE).hpk + +# +# Add a dummy command for building the HII pack file. In reality, it's built +# below, but the C_FLAGS macro reference the target as $@, so you can't specify +# the obj and hpk files as dual targets of the same command. +# +$(DEST_DIR)\$(FILE).hpk : $(DEST_DIR)\$(FILE).obj + +$(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS) + $(VFRCOMPILE) $(VFRCOMPILE_FLAGS) $(INC) -ibin -od $(DEST_DIR)\$(SOURCE_RELATIVE_PATH) \ + -l $(VFR_FLAGS) $(SOURCE_FILE_NAME) + $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(FILE).c + +# +# Add to the variable that contains the list of VFR binary files we're going +# to merge together at the end of the build. +# +HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk + +[=============================================================================] +[Compile.Ia32.Fv,Compile.Ipf.Fv,Compile.x64.Fv] +# +# Run GenSection on the firmware volume image. +# +$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME) + $(GENSECTION) -I $(SOURCE_FILE_NAME) -O $(DEST_DIR)\$(SOURCE_FV)Fv.sec -S EFI_SECTION_FIRMWARE_VOLUME_IMAGE + +[=============================================================================] diff --git a/EdkCompatibilityPkg/Sample/Platform/CommonIa32.dsc b/EdkCompatibilityPkg/Sample/Platform/CommonIa32.dsc new file mode 100644 index 0000000000..f9fae29359 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/CommonIa32.dsc @@ -0,0 +1,558 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CommonIa32.dsc +# +# Abstract: +# +# This is the build description file containing the processor architecture +# dependent build instructions. +# +# Notes: +# +# The info in this file is broken down into sections. The start of a section +# is designated by a "[" in the first column. So the [=====] separater ends +# a section. +# +#--*/ + + +[=============================================================================] +# +# These are the package descriptions. They are tagged as +# [Package.$(COMPONENT_TYPE).$(PACKAGE)], where COMPONENT_TYPE is typically +# defined in the component INF file, and PACKAGE is typically specified +# in the components section in the main DSC file. Main DSC file can also define +# platform specific package descriptions. +# + +[=============================================================================] +[Package.APPLICATION.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.Apriori.Default|DefaultStripped,Package.FILE.Default|DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).sec +} + +[=============================================================================] +[Package.RAWFILE.Default|DefaultStripped,Package.Config.Default|DefaultStripped|Config,Package.Microcode.Default|DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_RAW +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).Bin +} + +[=============================================================================] +[Package.BINARY.Default,Package.Legacy16.Default,Package.Logo.Default|Logo] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( $(OEMTOOLPATH)\GenCRC32Section + ARGS = -i $(DEST_DIR)\$(BASE_NAME).sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +# +# Package definition for TE files +# +[Package.PE32_PEIM.TE_PEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + $(BASE_NAME).tes + $(BASE_NAME).ui + $(BASE_NAME).ver +} + +[=============================================================================] +# +# Package definition to put the IFR data in a separate section in the +# FFS file. +# +[Package.BS_DRIVER.Ifr_Bin] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + $(DEST_DIR)\$(BASE_NAME)IfrBin.sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.PEI_CORE.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PEI_CORE.TE_PEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).tes \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PE32_PEIM.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PE32_PEIM.Relocatable] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.PE32_PEIM.CompressPEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + $(BASE_NAME).ui + $(BASE_NAME).ver + } +} + +[=============================================================================] +[Package.COMBINED_PEIM_DRIVER.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).dpxd \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.BS_DRIVER.DxeMain] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DXE_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + $(BASE_NAME).ui + $(BASE_NAME).ver + } +} + + +[=============================================================================] +[Package.BS_DRIVER.Default,Package.RT_DRIVER.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.FvImageFile.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec + -o $(DEST_DIR)\$(BASE_NAME)fv.crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME)fv.crc32 + ) + } +} + +[=============================================================================] +# +# Define a package that "signs" our capsule cargo FV +# +[Package.FvImageFile.SignedFVPackage] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) +} + +[=============================================================================] +[Package.FvImageFile.FvMainCompact] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Blank.pad + $(SOURCE_FV)Fv.sec + } +} +[=============================================================================] +# +# Stripped package descriptions for size reduction. +# +[=============================================================================] +[Package.APPLICATION.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(BASE_NAME).pe32 + } +} + +[=============================================================================] +[Package.BINARY.DefaultStripped,Package.Legacy16.DefaultStripped,Package.Logo.DefaultStripped|LogoStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(BASE_NAME).sec + } +} + +[=============================================================================] +[Package.PEI_CORE.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.PEI_CORE.TE_PEIMStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).tes +} +[=============================================================================] +[Package.PE32_PEIM.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.PE32_PEIM.CompressPEIMStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + } +} + +[=============================================================================] +# +# Package definition for TE files +# +[Package.PE32_PEIM.TE_PEIMStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + $(BASE_NAME).tes +} + +[=============================================================================] +[Package.COMBINED_PEIM_DRIVER.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).dpxd \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.BS_DRIVER.DxeMainStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DXE_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + } +} + + +[=============================================================================] +[Package.BS_DRIVER.DefaultStripped,Package.RT_DRIVER.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + } +} + + +[=============================================================================] +[Package.FvImageFile.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(SOURCE_FV)Fv.sec + } +} + +[=============================================================================] +[Package.SECURITY_CORE.Default|DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_SECURITY_CORE +FFS_ATTRIB_CHECKSUM = FALSE + +IMAGE_SCRIPT = +{ \ + Blank1.pad \ + $(BASE_NAME).tes \ + ResetVec.raw \ +} + +[=============================================================================] diff --git a/EdkCompatibilityPkg/Sample/Platform/CommonIpf.dsc b/EdkCompatibilityPkg/Sample/Platform/CommonIpf.dsc new file mode 100644 index 0000000000..13bfe9171b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/CommonIpf.dsc @@ -0,0 +1,391 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CommonIpf.dsc +# +# Abstract: +# +# This is the build description file containing the processor architecture +# dependent build instructions. +# +# Notes: +# +# The info in this file is broken down into sections. The start of a section +# is designated by a "[" in the first column. So the [=====] separater ends +# a section. +# +#--*/ + + +[=============================================================================] +# +# These are the package descriptions. They are tagged as +# [Package.$(COMPONENT_TYPE).$(PACKAGE)], where COMPONENT_TYPE is typically +# defined in the component INF file, and PACKAGE is typically specified +# in the components section in the main DSC file. Main DSC file can also define +# platform specific package descriptions. +# + +[=============================================================================] +[Package.APPLICATION.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.Apriori.Default,Package.FILE.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).sec +} + +[=============================================================================] +[Package.RAWFILE.Default,Package.Config.Default|Config] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_RAW +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).Bin +} + +[=============================================================================] +[Package.BINARY.Default,Package.Legacy16.Default,Package.Logo.Default|Logo] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( $(OEMTOOLPATH)\GenCRC32Section + ARGS = -i $(DEST_DIR)\$(BASE_NAME).sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +# +# Package definition for TE files +# +[Package.PE32_PEIM.TE_PEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + $(BASE_NAME).tes + $(BASE_NAME).ui + $(BASE_NAME).ver +} + +[=============================================================================] +# +# Package definition to put the IFR data in a separate section in the +# FFS file. +# +[Package.BS_DRIVER.Ifr_Bin] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + $(DEST_DIR)\$(BASE_NAME)IfrBin.sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.SECURITY_CORE.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_SECURITY_CORE +FFS_ATTRIB_CHECKSUM = TRUE +FFS_ALIGNMENT = 0x1 + +IMAGE_SCRIPT = +{ \ + Blank.pad \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PEI_CORE.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE +FFS_ALIGNMENT = 0x1 + +IMAGE_SCRIPT = +{ \ + Blank.pad \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PE32_PEIM.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE +FFS_ALIGNMENT = 0x1 + +IMAGE_SCRIPT = +{ \ + Blank.pad \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).dpx \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PE32_PEIM.CompressPEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + $(BASE_NAME).ui + $(BASE_NAME).ver + } +} + +[=============================================================================] +[Package.COMBINED_PEIM_DRIVER.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE +FFS_ALIGNMENT = 0x1 + +IMAGE_SCRIPT = +{ \ + Blank.pad \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).dpx \ + $(BASE_NAME).dpxd \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PIC_PEIM.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE +FFS_ALIGNMENT = 0x1 + +IMAGE_SCRIPT = +{ \ + Blank.pad \ + $(BASE_NAME).dpx \ + $(BASE_NAME).pic \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + + +[=============================================================================] +[Package.DxeIplPad.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_RAW +FFS_ATTRIB_CHECKSUM = TRUE +FFS_ALIGNMENT = 0x7 + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).pad \ +} + + +[=============================================================================] +[Package.BS_DRIVER.DxeMain] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DXE_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + $(BASE_NAME).ui + $(BASE_NAME).ver + } +} + + +[=============================================================================] +[Package.BS_DRIVER.Default,Package.RT_DRIVER.Default,Package.SAL_RT_DRIVER.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.FvImageFile.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec + -o $(DEST_DIR)\$(BASE_NAME)fv.crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME)fv.crc32 + ) + } +} + +[=============================================================================] +# +# Define a package that "signs" our capsule cargo FV +# +[Package.FvImageFile.SignedFVPackage] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) +} + +[=============================================================================] +[Package.FvImageFile.FvMainCompact] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Blank.pad + $(SOURCE_FV)Fv.sec + } +} +[=============================================================================] diff --git a/EdkCompatibilityPkg/Sample/Platform/CommonX64.dsc b/EdkCompatibilityPkg/Sample/Platform/CommonX64.dsc new file mode 100644 index 0000000000..4314049361 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/CommonX64.dsc @@ -0,0 +1,558 @@ +#/*++ +# +# Copyright (c) 2005 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# CommonX64.dsc +# +# Abstract: +# +# This is the build description file containing the processor architecture +# dependent build instructions. +# +# Notes: +# +# The info in this file is broken down into sections. The start of a section +# is designated by a "[" in the first column. So the [=====] separater ends +# a section. +# +#--*/ + + +[=============================================================================] +# +# These are the package descriptions. They are tagged as +# [Package.$(COMPONENT_TYPE).$(PACKAGE)], where COMPONENT_TYPE is typically +# defined in the component INF file, and PACKAGE is typically specified +# in the components section in the main DSC file. Main DSC file can also define +# platform specific package descriptions. +# + +[=============================================================================] +[Package.APPLICATION.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.Apriori.Default|DefaultStripped,Package.FILE.Default|DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).sec +} + +[=============================================================================] +[Package.RAWFILE.Default|DefaultStripped,Package.Config.Default|DefaultStripped|Config,Package.Microcode.Default|DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_RAW +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).Bin +} + +[=============================================================================] +[Package.BINARY.Default,Package.Legacy16.Default,Package.Logo.Default|Logo] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( $(OEMTOOLPATH)\GenCRC32Section + ARGS = -i $(DEST_DIR)\$(BASE_NAME).sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +# +# Package definition for TE files +# +[Package.PE32_PEIM.TE_PEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + $(BASE_NAME).tes + $(BASE_NAME).ui + $(BASE_NAME).ver +} + +[=============================================================================] +# +# Package definition to put the IFR data in a separate section in the +# FFS file. +# +[Package.BS_DRIVER.Ifr_Bin] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + $(DEST_DIR)\$(BASE_NAME)IfrBin.sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.PEI_CORE.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PEI_CORE.TE_PEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).tes \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PE32_PEIM.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.PE32_PEIM.Relocatable] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.PE32_PEIM.CompressPEIM] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + $(BASE_NAME).ui + $(BASE_NAME).ver + } +} + +[=============================================================================] +[Package.COMBINED_PEIM_DRIVER.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).dpxd \ + $(BASE_NAME).pe32 \ + $(BASE_NAME).ui \ + $(BASE_NAME).ver \ +} + +[=============================================================================] +[Package.BS_DRIVER.DxeMain] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DXE_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + $(BASE_NAME).ui + $(BASE_NAME).ver + } +} + + +[=============================================================================] +[Package.BS_DRIVER.Default,Package.RT_DRIVER.Default,Package.SAL_RT_DRIVER.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + $(DEST_DIR)\$(BASE_NAME).ui + $(DEST_DIR)\$(BASE_NAME).ver + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) + } +} + +[=============================================================================] +[Package.FvImageFile.Default] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec + -o $(DEST_DIR)\$(BASE_NAME)fv.crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME)fv.crc32 + ) + } +} + +[=============================================================================] +# +# Define a package that "signs" our capsule cargo FV +# +[Package.FvImageFile.SignedFVPackage] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Tool ( + $(OEMTOOLPATH)\GenCRC32Section + ARGS= -i $(DEST_DIR)\$(SOURCE_FV)Fv.sec + -o $(DEST_DIR)\$(BASE_NAME).crc32 + OUTPUT = $(DEST_DIR)\$(BASE_NAME).crc32 + ) +} + +[=============================================================================] +# +# Stripped package descriptions for size reduction. +# +[=============================================================================] +[Package.APPLICATION.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(BASE_NAME).pe32 + } +} + +[=============================================================================] +[Package.BINARY.DefaultStripped,Package.Legacy16.DefaultStripped,Package.Logo.DefaultStripped|LogoStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FREEFORM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(BASE_NAME).sec + } +} + +[=============================================================================] +[Package.PEI_CORE.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.PEI_CORE.TE_PEIMStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEI_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).tes +} +[=============================================================================] +[Package.PE32_PEIM.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.PE32_PEIM.CompressPEIMStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + } +} + +[=============================================================================] +# +# Package definition for TE files +# +[Package.PE32_PEIM.TE_PEIMStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_PEIM +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + $(BASE_NAME).dpx + $(BASE_NAME).tes +} + +[=============================================================================] +[Package.COMBINED_PEIM_DRIVER.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ \ + $(BASE_NAME).dpx \ + $(BASE_NAME).dpxd \ + $(BASE_NAME).pe32 \ +} + +[=============================================================================] +[Package.BS_DRIVER.DxeMainStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DXE_CORE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(BASE_NAME).pe32 + } +} + + +[=============================================================================] +[Package.BS_DRIVER.DefaultStripped,Package.RT_DRIVER.DefaultStripped,Package.SAL_RT_DRIVER.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_DRIVER +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(BASE_NAME).dpx + $(DEST_DIR)\$(BASE_NAME).pe32 + } +} + + +[=============================================================================] +[Package.FvImageFile.DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + $(DEST_DIR)\$(SOURCE_FV)Fv.sec + } +} + +[=============================================================================] +[Package.FvImageFile.FvMainCompact] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE +FFS_ATTRIB_CHECKSUM = TRUE + +IMAGE_SCRIPT = +{ + Compress ($(COMPRESS_METHOD)) { + Blank.pad + $(SOURCE_FV)Fv.sec + } +} +[=============================================================================] +[Package.SECURITY_CORE.Default|DefaultStripped] +PACKAGE.INF +\[.] +BASE_NAME = $(BASE_NAME) +FFS_FILEGUID = $(FILE_GUID) +FFS_FILETYPE = EFI_FV_FILETYPE_SECURITY_CORE +FFS_ATTRIB_CHECKSUM = FALSE + +IMAGE_SCRIPT = +{ \ + Blank1.pad \ + $(BASE_NAME).tes \ + ResetVec.raw \ +} + +[=============================================================================] diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLib32.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLib32.dsc new file mode 100644 index 0000000000..5c71f41108 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLib32.dsc @@ -0,0 +1,39 @@ +#/*++ +# Copyright (c) 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#--*/ +# +# EdkII Glue Library for PEI usage (32bit) +# +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseLib\BaseLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\BaseMemoryLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePrintLib\BasePrintLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseDebugLibNull\BaseDebugLibNull.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseIoLibIntrinsic\BaseIoLibIntrinsic.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibPort80\BasePostCodeLibPort80.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibDebug\BasePostCodeLibDebug.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseCacheMaintenanceLib\BaseCacheMaintenanceLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciCf8Lib\BasePciCf8Lib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciExpressLib\BasePciExpressLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibCf8\BasePciLibCf8.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibPciExpress\BasePciLibPciExpress.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffGetEntryPointLib\BasePeCoffGetEntryPointLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffLib\BasePeCoffLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibLocalApic\BaseTimerLibLocalApic.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseUefiDecompressLib\BaseUefiDecompressLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxeDebugLibReportStatusCode\PeiDxeDebugLibReportStatusCode.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxePostCodeLibReportStatusCode\PeiDxePostCodeLibReportStatusCode.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibMm7\PeiServicesTablePointerLibMm7.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLib\PeiServicesTablePointerLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiMemoryAllocationLib\PeiMemoryAllocationLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesLib\PeiServicesLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiHobLib\PeiHobLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiResourcePublicationLib\PeiResourcePublicationLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib\PeiSmbusLib.inf diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc new file mode 100644 index 0000000000..8879bf3737 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc @@ -0,0 +1,54 @@ +#/*++ +# Copyright (c) 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +#--*/ +# +# EdkII Glue Library +# +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseLib\BaseLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\BaseMemoryLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePrintLib\BasePrintLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseDebugLibNull\BaseDebugLibNull.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseIoLibIntrinsic\BaseIoLibIntrinsic.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiBootServicesTableLib\UefiBootServicesTableLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeIoLibCpuIo\DxeIoLibCpuIo.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibPort80\BasePostCodeLibPort80.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibDebug\BasePostCodeLibDebug.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseCacheMaintenanceLib\BaseCacheMaintenanceLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciCf8Lib\BasePciCf8Lib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciExpressLib\BasePciExpressLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibCf8\BasePciLibCf8.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePciLibPciExpress\BasePciLibPciExpress.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffGetEntryPointLib\BasePeCoffGetEntryPointLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BasePeCoffLib\BasePeCoffLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibLocalApic\BaseTimerLibLocalApic.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\BaseUefiDecompressLib\BaseUefiDecompressLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxeDebugLibReportStatusCode\PeiDxeDebugLibReportStatusCode.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiDxePostCodeLibReportStatusCode\PeiDxePostCodeLibReportStatusCode.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeMemoryAllocationLib\DxeMemoryAllocationLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiLib\UefiLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeHobLib\DxeHobLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiRuntimeServicesTableLib\UefiRuntimeServicesTableLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\HiiLib\HiiLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibMm7\PeiServicesTablePointerLibMm7.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibKr1\PeiServicesTablePointerLibKr1.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLib\PeiServicesTablePointerLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiMemoryAllocationLib\PeiMemoryAllocationLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiServicesLib\PeiServicesLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiHobLib\PeiHobLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiReportStatusCodeLib\PeiReportStatusCodeLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiResourcePublicationLib\PeiResourcePublicationLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiDevicePathLib\UefiDevicePathLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\UefiDriverModelLib\UefiDriverModelLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeServicesTableLib\DxeServicesTableLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\EdkDxeSalLib\EdkDxeSalLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\EdkDxeRuntimeDriverLib\EdkDxeRuntimeDriverLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeSmbusLib\DxeSmbusLib.inf +$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib\PeiSmbusLib.inf \ No newline at end of file diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkLib32.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkLib32.dsc new file mode 100644 index 0000000000..7be8ebbe80 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/EdkLib32.dsc @@ -0,0 +1,36 @@ +#/*++ +# +# Copyright (c) 2004 - 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#--*/ +# +# EDK Common Library for PEI usage (32bit) +# + +# +# Libraries common to PEI and DXE +# +$(EDK_PREFIX)Foundation\Efi\Guid\EfiGuidLib.inf +$(EDK_PREFIX)Foundation\Framework\Guid\EdkFrameworkGuidLib.inf +$(EDK_PREFIX)Foundation\Guid\EdkGuidLib.inf +$(EDK_PREFIX)Foundation\Library\EfiCommonLib\EfiCommonLib.inf +$(EDK_PREFIX)Foundation\Cpu\Pentium\CpuIA32Lib\CpuIA32Lib.inf +$(EDK_PREFIX)Foundation\Cpu\Itanium\CpuIA64Lib\CpuIA64Lib.inf +$(EDK_PREFIX)Foundation\Library\CustomizedDecompress\CustomizedDecompress.inf +$(EDK_PREFIX)Foundation\Library\CompilerStub\CompilerStubLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\Hob\HobLib.inf + +# +# PEI libraries +# +$(EDK_PREFIX)Foundation\Framework\Ppi\EdkFrameworkPpiLib.inf +$(EDK_PREFIX)Foundation\Ppi\EdkPpiLib.inf +$(EDK_PREFIX)Foundation\Library\Pei\PeiLib\PeiLib.inf +$(EDK_PREFIX)Foundation\Library\Pei\Hob\PeiHobLib.inf diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkLibAll.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkLibAll.dsc new file mode 100644 index 0000000000..346946f5ec --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/EdkLibAll.dsc @@ -0,0 +1,63 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#--*/ +# +# EDK Common Library +# + +# +# Libraries common to PEI and DXE +# +$(EDK_PREFIX)Foundation\Efi\Guid\EfiGuidLib.inf +$(EDK_PREFIX)Foundation\Framework\Guid\EdkFrameworkGuidLib.inf +$(EDK_PREFIX)Foundation\Guid\EdkGuidLib.inf +$(EDK_PREFIX)Foundation\Library\EfiCommonLib\EfiCommonLib.inf +$(EDK_PREFIX)Foundation\Cpu\Pentium\CpuIA32Lib\CpuIA32Lib.inf +$(EDK_PREFIX)Foundation\Cpu\Itanium\CpuIA64Lib\CpuIA64Lib.inf +$(EDK_PREFIX)Foundation\Library\CustomizedDecompress\CustomizedDecompress.inf +$(EDK_PREFIX)Foundation\Library\CompilerStub\CompilerStubLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\Hob\HobLib.inf + +# +# PEI libraries +# +$(EDK_PREFIX)Foundation\Framework\Ppi\EdkFrameworkPpiLib.inf +$(EDK_PREFIX)Foundation\Ppi\EdkPpiLib.inf +$(EDK_PREFIX)Foundation\Library\Pei\PeiLib\PeiLib.inf +$(EDK_PREFIX)Foundation\Library\Pei\Hob\PeiHobLib.inf + +# +# DXE libraries +# +$(EDK_PREFIX)Foundation\Core\Dxe\ArchProtocol\ArchProtocolLib.inf +$(EDK_PREFIX)Foundation\Efi\Protocol\EfiProtocolLib.inf +$(EDK_PREFIX)Foundation\Framework\Protocol\EdkFrameworkProtocolLib.inf +$(EDK_PREFIX)Foundation\Protocol\EdkProtocolLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\EfiDriverLib\EfiDriverLib.inf +$(EDK_PREFIX)Foundation\Library\RuntimeDxe\EfiRuntimeLib\EfiRuntimeLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\Graphics\Graphics.inf +$(EDK_PREFIX)Foundation\Library\Dxe\EfiIfrSupportLib\EfiIfrSupportLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\Print\PrintLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\EfiScriptLib\EfiScriptLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\EfiUiLib\EfiUiLib.inf + +# +# Print/Graphics Library consume SetupBrowser Print Protocol +# +$(EDK_PREFIX)Foundation\Library\Dxe\PrintLite\PrintLib.inf +$(EDK_PREFIX)Foundation\Library\Dxe\GraphicsLite\Graphics.inf + +# +# Module Libraries +# +$(EDK_PREFIX)Sample\Platform\Generic\Dxe\GenericBds\GenericBds.inf +$(EDK_PREFIX)Sample\Bus\Usb\UsbLib\Dxe\UsbDxeLib.inf diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/EdkNt32ProtocolLib.inf b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/EdkNt32ProtocolLib.inf new file mode 100644 index 0000000000..1abff26c06 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/EdkNt32ProtocolLib.inf @@ -0,0 +1,46 @@ +#/*++ +# +# Copyright (c) 2004, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# EdkNt32ProtocolLib.inf +# +# Abstract: +# +# Component description file. +# +#--*/ + +[defines] +BASE_NAME= EdkNt32ProtocolLib +COMPONENT_TYPE= LIBRARY + +[includes.common] + $(EDK_SOURCE)\Sample\Platform\Nt32 + $(EDK_SOURCE)\Foundation\Efi + $(EDK_SOURCE)\Foundation\Include + $(EDK_SOURCE)\Foundation\Efi\Include + $(EDK_SOURCE)\Foundation\Framework\Include + $(EDK_SOURCE)\Foundation\Include\IndustryStandard + $(EDK_SOURCE)\Foundation\Include\Pei + $(EDK_SOURCE)\Foundation\Library\Pei\Include + $(EDK_SOURCE)\Foundation\Core\Dxe + $(EDK_SOURCE)\Foundation\Library\Dxe\Include + $(EDK_SOURCE)\Sample\Include + +[nmake.common] +C_STD_INCLUDE= + +[sources.common] + WinNtIo\WinNtIo.h + WinNtIo\WinNtIo.c + WinNtThunk\WinNtThunk.h + WinNtThunk\WinNtThunk.c diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.c b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.c new file mode 100644 index 0000000000..318ff33684 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.c @@ -0,0 +1,40 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WinNtIo.c + +Abstract: + + This protocol allows an EFI driver (DLL) in the NT emulation envirnment + to make Win32 API calls. + +--*/ + +#include "EfiWinNt.h" +#include EFI_PROTOCOL_DEFINITION (WinNtIo) + +EFI_GUID gEfiWinNtIoProtocolGuid = EFI_WIN_NT_IO_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiWinNtIoProtocolGuid, "EFI Win NT I/O Protocol", "Win32 API I/O protocol"); + +EFI_GUID gEfiWinNtVirtualDisksGuid = EFI_WIN_NT_VIRTUAL_DISKS_GUID; +EFI_GUID gEfiWinNtPhysicalDisksGuid = EFI_WIN_NT_PHYSICAL_DISKS_GUID; +EFI_GUID gEfiWinNtFileSystemGuid = EFI_WIN_NT_FILE_SYSTEM_GUID; +EFI_GUID gEfiWinNtSerialPortGuid = EFI_WIN_NT_SERIAL_PORT_GUID; +EFI_GUID gEfiWinNtUgaGuid = EFI_WIN_NT_UGA_GUID; +EFI_GUID gEfiWinNtGopGuid = EFI_WIN_NT_GOP_GUID; +EFI_GUID gEfiWinNtConsoleGuid = EFI_WIN_NT_CONSOLE_GUID; +EFI_GUID gEfiWinNtMemoryGuid = EFI_WIN_NT_MEMORY_GUID; +EFI_GUID gEfiWinNtCPUModelGuid = EFI_WIN_NT_CPU_MODEL_GUID; +EFI_GUID gEfiWinNtCPUSpeedGuid = EFI_WIN_NT_CPU_SPEED_GUID; +EFI_GUID gEfiWinNtPassThroughGuid = EFI_WIN_NT_PASS_THROUGH_GUID; diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.h b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.h new file mode 100644 index 0000000000..7da6099499 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtIo/WinNtIo.h @@ -0,0 +1,163 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WinNtIo.h + +Abstract: + +--*/ + +#ifndef _WIN_NT_IO_H_ +#define _WIN_NT_IO_H_ + +#define EFI_WIN_NT_IO_PROTOCOL_GUID \ + { \ + 0x96eb4ad6, 0xa32a, 0x11d4, 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +// +// The following APIs require EfiWinNT.h. In some environmnets the GUID +// definitions are needed but the EfiWinNT.h is not included. +// EfiWinNT.h is needed to support WINDOWS API requirements. +// +#ifdef _EFI_WIN_NT_H_ + +#include EFI_PROTOCOL_DEFINITION (WinNtThunk) + +typedef struct { + EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk; + EFI_GUID *TypeGuid; + CHAR16 *EnvString; + UINT16 InstanceNumber; +} EFI_WIN_NT_IO_PROTOCOL; + +#endif + +extern EFI_GUID gEfiWinNtIoProtocolGuid; + +// +// The following GUIDs are used in EFI_WIN_NT_IO_PROTOCOL_GUID +// Device paths. They map 1:1 with NT envirnment variables. The variables +// define what virtual hardware the emulator/WinNtBusDriver will produce. +// +// +// EFI_WIN_NT_VIRTUAL_DISKS +// +#define EFI_WIN_NT_VIRTUAL_DISKS_GUID \ + { \ + 0xc95a928, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtVirtualDisksGuid; + +// +// EFI_WIN_NT_PHYSICAL_DISKS +// +#define EFI_WIN_NT_PHYSICAL_DISKS_GUID \ + { \ + 0xc95a92f, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtPhysicalDisksGuid; + +// +// EFI_WIN_NT_FILE_SYSTEM +// +#define EFI_WIN_NT_FILE_SYSTEM_GUID \ + { \ + 0xc95a935, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtFileSystemGuid; + +// +// EFI_WIN_NT_SERIAL_PORT +// +#define EFI_WIN_NT_SERIAL_PORT_GUID \ + { \ + 0xc95a93d, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtSerialPortGuid; + +// +// EFI_WIN_NT_UGA +// +#define EFI_WIN_NT_UGA_GUID \ + { \ + 0xab248e99, 0xabe1, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtUgaGuid; + +// +// EFI_WIN_NT_GOP +// +#define EFI_WIN_NT_GOP_GUID \ + { \ + 0x4e11e955, 0xccca, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtGopGuid; + +// +// EFI_WIN_NT_CONSOLE +// +#define EFI_WIN_NT_CONSOLE_GUID \ + { \ + 0xba73672c, 0xa5d3, 0x11d4, 0xbd, 0x0, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtConsoleGuid; + +// +// EFI_WIN_NT_MEMORY +// +#define EFI_WIN_NT_MEMORY_GUID \ + { \ + 0x99042912, 0x122a, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtMemoryGuid; + +// +// EFI_WIN_NT_CPU_MODEL +// +#define EFI_WIN_NT_CPU_MODEL_GUID \ + { \ + 0xbee9b6ce, 0x2f8a, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtCPUModelGuid; + +// +// EFI_WIN_NT_CPU_SPEED +// +#define EFI_WIN_NT_CPU_SPEED_GUID \ + { \ + 0xd4f29055, 0xe1fb, 0x11d4, 0xbd, 0xd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +extern EFI_GUID gEfiWinNtCPUSpeedGuid; + +// +// EFI_WIN_NT_PASS_THROUGH +// +#define EFI_WIN_NT_PASS_THROUGH_GUID \ + { \ + 0xcc664eb8, 0x3c24, 0x4086, 0xb6, 0xf6, 0x34, 0xe8, 0x56, 0xbc, 0xe3, 0x6e \ + } + +extern EFI_GUID gEfiWinNtPassThroughGuid; + +#endif diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.c b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.c new file mode 100644 index 0000000000..f0e827bb0e --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WinNtThunk.c + +Abstract: + + This protocol allows an EFI driver (DLL) in the NT emulation envirnment + to make Win32 API calls. + +--*/ + +#include "Tiano.h" +#include EFI_PROTOCOL_DEFINITION (WinNtThunk) + +EFI_GUID gEfiWinNtThunkProtocolGuid = EFI_WIN_NT_THUNK_PROTOCOL_GUID; + +EFI_GUID_STRING(&gEfiWinNtThunkProtocolGuid, "EFI Win NT Thunk", "Win32 API thunk protocol"); diff --git a/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.h b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.h new file mode 100644 index 0000000000..5ad6245682 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Platform/Nt32/Protocol/WinNtThunk/WinNtThunk.h @@ -0,0 +1,1276 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + WinNtThunk.h + +Abstract: + + This protocol allows an EFI driver (DLL) in the NT emulation envirnment + to make Win32 API calls. + + NEVER make a Win32 call directly, always make the call via this protocol. + + There are no This pointers on the protocol member functions as they map + exactly into Win32 system calls. + + YOU MUST include EfiWinNT.h in place of Efi.h to make this file compile. + +--*/ + +#ifndef _WIN_NT_THUNK_H_ +#define _WIN_NT_THUNK_H_ + +#define EFI_WIN_NT_THUNK_PROTOCOL_GUID \ + { \ + 0x58c518b1, 0x76f3, 0x11d4, 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \ + } + +// +// The following APIs require EfiWinNT.h. In some environmnets the GUID +// definitions are needed but the EfiWinNT.h is not included. +// EfiWinNT.h is needed to support WINDOWS API requirements. +// +#ifdef _EFI_WIN_NT_H_ + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtSleep) ( + DWORD Milliseconds + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtSuspendThread) ( + HANDLE hThread + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtGetCurrentThread) ( + VOID + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtGetCurrentThreadId) ( + VOID + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtGetCurrentProcess) ( + VOID + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtCreateThread) ( + LPSECURITY_ATTRIBUTES lpThreadAttributes, + DWORD dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, + LPVOID lpParameter, + DWORD dwCreationFlags, + LPDWORD lpThreadId + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtTerminateThread) ( + HANDLE hThread, + DWORD dwExitCode + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSendMessage) ( + HWND hWnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtExitThread) ( + DWORD dwExitCode + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtResumeThread) ( + HANDLE hThread + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetThreadPriority) ( + HANDLE hThread, + INTN nPriority + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtInitializeCriticalSection) ( + LPCRITICAL_SECTION lpCriticalSection + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtDeleteCriticalSection) ( + LPCRITICAL_SECTION lpCriticalSection + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtEnterCriticalSection) ( + LPCRITICAL_SECTION lpCriticalSection + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtLeaveCriticalSection) ( + LPCRITICAL_SECTION lpCriticalSection + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtTlsAlloc) ( + VOID + ); + +typedef +WINBASEAPI +LPVOID +(WINAPI *WinNtTlsGetValue) ( + DWORD dwTlsIndex + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtTlsSetValue) ( + DWORD dwTlsIndex, + LPVOID lpTlsValue + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtTlsFree) ( + DWORD dwTlsIndex + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtCreateSemaphore) ( + LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, + LONG lInitialCount, + LONG lMaximumCount, + LPCWSTR lpName + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtWaitForSingleObject) ( + HANDLE hHandle, + DWORD dwMilliseconds + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtReleaseSemaphore) ( + HANDLE hSemaphore, + LONG lReleaseCount, + LPLONG lpPreviousCount + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtDuplicateHandle) ( + HANDLE hSourceProcessHandle, + HANDLE hSourceHandle, + HANDLE hTargetProcessHandle, + LPHANDLE lpTargetHandle, + DWORD dwDesiredAccess, + BOOL bInheritHandle, + DWORD dwOptions + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtCreateConsoleScreenBuffer) ( + DWORD DesiredAccess, + DWORD ShareMode, + CONST SECURITY_ATTRIBUTES *SecurityAttributes, + DWORD Flags, + LPVOID ScreenBufferData + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetConsoleScreenBufferSize) ( + HANDLE ConsoleOutput, + COORD Size + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetConsoleActiveScreenBuffer) ( + HANDLE ConsoleOutput + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFillConsoleOutputAttribute) ( + HANDLE ConsoleOutput, + WORD Attribute, + DWORD Length, + COORD WriteCoord, + LPDWORD NumberOfAttrsWritten + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFillConsoleOutputCharacter) ( + HANDLE ConsoleOutput, + TCHAR Character, + DWORD Length, + COORD WriteCoord, + LPDWORD NumberOfCharsWritten + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtWriteConsoleOutput) ( + HANDLE ConsoleOutput, + CONST CHAR_INFO *Buffer, + COORD BufferSize, + COORD BufferCoord, + PSMALL_RECT WriteRegion + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtScrollConsoleScreenBuffer) ( + HANDLE ConsoleOutput, + CONST SMALL_RECT *ScrollRectangle, + CONST SMALL_RECT *ClipRectangle, + COORD DestinationOrigin, + CONST CHAR_INFO *Fill + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetConsoleTitleW) ( + LPCTSTR ConsoleTitle + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtGetConsoleCursorInfo) ( + HANDLE ConsoleOutput, + PCONSOLE_CURSOR_INFO ConsoleCursorInfo + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetConsoleCursorInfo) ( + HANDLE ConsoleOutput, + CONST CONSOLE_CURSOR_INFO *ConsoleCursorInfo + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetPriorityClass) ( + HANDLE Process, + DWORD PriorityClass + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtWriteConsoleInput) ( + HANDLE ConsoleInput, + CONST INPUT_RECORD *Buffer, + DWORD Legnth, + LPDWORD NumberOfEventsWritten + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtGetNumberOfConsoleInputEvents) ( + HANDLE ConsoleInput, + LPDWORD NumberOfEvents + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtGetStdHandle) ( + DWORD StdHandle + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtReadConsoleInput) ( + HANDLE ConsoleInput, + PINPUT_RECORD Buffer, + DWORD Length, + LPDWORD NumberOfEventsRead + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtPeekConsoleInput) ( + HANDLE ConsoleInput, + PINPUT_RECORD Buffer, + DWORD Length, + LPDWORD NumberOfEventsRead + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetConsoleCursorPosition) ( + HANDLE ConsoleInput, + COORD CursorPosition + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtCreateFile) ( + LPCWSTR FileName, + DWORD DesiredAccess, + DWORD SharedMode, + LPSECURITY_ATTRIBUTES SecurityAttributes, + DWORD CreationDisposition, + DWORD FlagsAndAttributes, + HANDLE TemplateFile + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtDeviceIoControl) ( + HANDLE DeviceHandle, + DWORD IoControlCode, + LPVOID InBuffer, + DWORD InBufferSize, + LPVOID OutBuffer, + DWORD OutBufferSize, + LPDWORD BytesReturned, + LPOVERLAPPED Overlapped + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtCreateDirectory) ( + LPCWSTR PathName, + LPSECURITY_ATTRIBUTES SecurityAttributes + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtRemoveDirectory) ( + LPCWSTR PathName + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtGetFileAttributes) ( + LPCWSTR FileName + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetFileAttributes) ( + LPCWSTR FileName, + DWORD FileAttributes + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtCreateFileMapping) ( + HANDLE FileHandle, + LPSECURITY_ATTRIBUTES Attributes, + DWORD Protect, + DWORD MaximumSizeHigh, + DWORD MaximumSizeLow, + LPCTSTR Name + ); + +typedef +WINBASEAPI +LPVOID +(WINAPI *WinNtMapViewOfFileEx) ( + HANDLE FileHandle, + DWORD DesiredAccess, + DWORD FileOffsetHigh, + DWORD FileOffsetLow, + DWORD NumberOfBytesToMap, + LPVOID BaseAddress + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtGetEnvironmentVariable) ( + LPCTSTR Name, + LPTSTR Buffer, + DWORD Size + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtCloseHandle) ( + HANDLE Object + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtSetFilePointer) ( + HANDLE FileHandle, + LONG DistanceToMove, + PLONG DistanceToHoveHigh, + DWORD MoveMethod + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetEndOfFile) ( + HANDLE FileHandle + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtReadFile) ( + HANDLE FileHandle, + LPVOID Buffer, + DWORD NumberOfBytesToRead, + LPDWORD NumberOfBytesRead, + LPOVERLAPPED Overlapped + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtWriteFile) ( + HANDLE FileHandle, + LPCVOID Buffer, + DWORD NumberOfBytesToWrite, + LPDWORD NumberOfBytesWritten, + LPOVERLAPPED Overlapped + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtGetFileInformationByHandle) ( + HANDLE FileHandle, + BY_HANDLE_FILE_INFORMATION *FileInfo + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtGetDiskFreeSpace) ( + LPCTSTR RootPathName, + LPDWORD SectorsPerCluster, + LPDWORD BytesPerSector, + LPDWORD NumberOfFreeClusters, + LPDWORD TotalNumberOfClusters + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtGetDiskFreeSpaceEx) ( + LPCTSTR DirectoryName, + PULARGE_INTEGER FreeBytesAvailable, + PULARGE_INTEGER TotalNumberOfBytes, + PULARGE_INTEGER TotoalNumberOfFreeBytes + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtMoveFile) ( + LPCTSTR ExistingFileName, + LPCTSTR NewFileName + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetFileTime) ( + HANDLE FileHandle, + FILETIME *CreationTime, + FILETIME *LastAccessTime, + FILETIME *LastWriteTime + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSystemTimeToFileTime) ( + SYSTEMTIME * SystemTime, + FILETIME * FileTime + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtDeleteFile) ( + LPCTSTR FileName + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFlushFileBuffers) ( + HANDLE + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtGetLastError) ( + VOID + ); + +typedef +WINBASEAPI +UINT +(WINAPI *WinNtSetErrorMode) ( + UINT Mode + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtGetTickCount) ( + VOID + ); + +typedef +WINBASEAPI +HMODULE +(WINAPI *WinNtLoadLibraryEx) ( + LPCTSTR LibFileName, + HANDLE FileHandle, + DWORD Flags + ); + +typedef +WINBASEAPI +FARPROC +(WINAPI *WinNtGetProcAddress) ( + HMODULE Module, + LPCSTR ProcName + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtGetTimeZoneInformation) ( + LPTIME_ZONE_INFORMATION timeZoneInformation + ); + +typedef +WINBASEAPI +MMRESULT +(WINAPI *WinNttimeSetEvent) ( + UINT uDelay, + UINT uResolution, + LPTIMECALLBACK lpTimeProc, + DWORD_PTR dwUser, + UINT fuEvent + ); + +typedef +WINBASEAPI +MMRESULT +(WINAPI *WinNttimeKillEvent) ( + UINT uTimerID + ); + +typedef +WINBASEAPI +DWORD +(WINAPI *WinNtSetTimeZoneInformation) ( + LPTIME_ZONE_INFORMATION timeZoneInformation + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtGetSystemTime) ( + LPSYSTEMTIME SystemTime + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetSystemTime) ( + CONST SYSTEMTIME *SystemTime + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtGetLocalTime) ( + LPSYSTEMTIME SystemTime + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetLocalTime) ( + CONST SYSTEMTIME *SystemTime + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFileTimeToLocalFileTime) ( + CONST FILETIME *FileTime, + LPFILETIME LocalFileTime + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFileTimeToSystemTime) ( + CONST FILETIME *FileTime, + LPSYSTEMTIME SystemTime + ); + +typedef +WINBASEAPI +HANDLE +(WINAPI *WinNtFindFirstFile) ( + LPCTSTR FileName, + LPWIN32_FIND_DATA FindFileData + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFindNextFile) ( + HANDLE FindFile, + LPWIN32_FIND_DATA FindFileData + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFindClose) ( + HANDLE FindFile + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtGetCommState) ( + HANDLE FileHandle, + LPDCB DCB + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetCommState) ( + HANDLE FileHandle, + LPDCB DCB + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetCommState) ( + HANDLE FileHandle, + LPDCB DCB + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtSetCommTimeouts) ( + HANDLE FileHandle, + LPCOMMTIMEOUTS CommTimeouts + ); + +typedef +WINBASEAPI +VOID +(WINAPI *WinNtExitProcess) ( + UINT uExitCode // exit code for all threads + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtPurgeComm) ( + HANDLE FileHandle, + DWORD Flags + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtEscapeCommFunction) ( + HANDLE FileHandle, + DWORD Func + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtGetCommModemStatus) ( + HANDLE FileHandle, + LPDWORD ModemStat + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtClearCommError) ( + HANDLE FileHandle, + LPDWORD Errors, + LPCOMSTAT Stat + ); + +typedef +WINUSERAPI +INT32 +(WINAPIV *WinNtSprintf) ( + LPWSTR Buffer, + LPCWSTR String, + ... + ); + +typedef +WINUSERAPI +HWND +(WINAPI *WinNtGetDesktopWindow) ( + VOID + ); + +typedef +WINUSERAPI +HWND +(WINAPI *WinNtGetForegroundWindow) ( + VOID + ); + +typedef +WINUSERAPI +HWND +(WINAPI *WinNtCreateWindowEx) ( + DWORD dwExStyle, + LPCTSTR lpClassName, + LPCTSTR lpWindowName, + DWORD dwStyle, + INT32 x, + INT32 y, + INT32 nWidth, + INT32 nHeight, + HWND hWndParent, + HMENU hMenu, + HINSTANCE hInstance, + LPVOID *lpParam + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtUpdateWindow) ( + HWND hWnd + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtShowWindow) ( + HWND hWnd, + INT32 nCmdShow + ); + +typedef +WINGDIAPI +BOOL +(WINAPI *WinNtDestroyWindow) ( + HWND hWnd + ); + +typedef +WINUSERAPI +HDC +(WINAPI *WinNtGetWindowDC) ( + HWND hWnd + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtGetClientRect) ( + HWND hWnd, + LPRECT lpRect + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtAdjustWindowRect) ( + LPRECT lpRect, + DWORD dwStyle, + BOOL bMenu + ); + +typedef +WINGDIAPI +INT32 +(WINAPI *WinNtSetDIBitsToDevice) ( + HDC, + INT32, + INT32, + DWORD, + DWORD, + INT32, + INT32, + UINT, + UINT, + CONST VOID *, + CONST BITMAPINFO *, + UINT + ); + +typedef +WINGDIAPI +BOOL +(WINAPI *WinNtBitBlt) ( + HDC, + INT32, + INT32, + INT32, + INT32, + HDC, + INT32, + INT32, + DWORD + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtInvalidateRect) ( + HWND hWnd, + CONST RECT *lpRect, + BOOL bErase + ); + +typedef +WINUSERAPI +HDC +(WINAPI *WinNtGetDC) ( + HWND hWnd + ); + +typedef +WINUSERAPI +INT32 +(WINAPI *WinNtReleaseDC) ( + HWND hWnd, + HDC hDC + ); + +typedef +WINUSERAPI +ATOM +(WINAPI *WinNtRegisterClassEx) ( + CONST WNDCLASSEX * + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtUnregisterClass) ( + LPCTSTR lpClassName, + HINSTANCE hInstance + ); + +typedef +WINUSERAPI +HDC +(WINAPI *WinNtBeginPaint) ( + HWND hWnd, + LPPAINTSTRUCT lpPaint + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtEndPaint) ( + HWND hWnd, + CONST PAINTSTRUCT *lpPaint + ); + +typedef +WINUSERAPI +VOID +(WINAPI *WinNtPostQuitMessage) ( + INT32 nExitCode + ); + +typedef +WINUSERAPI +LRESULT +(WINAPI *WinNtDefWindowProc) ( + HWND hWnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam + ); + +typedef +WINUSERAPI +HICON +(WINAPI *WinNtLoadIcon) ( + HINSTANCE hInstance, + LPCTSTR lpIconName + ); + +typedef +WINUSERAPI +HCURSOR +(WINAPI *WinNtLoadCursor) ( + HINSTANCE hInstance, + LPCTSTR lpCursorName + ); + +typedef +WINGDIAPI +HGDIOBJ +(WINAPI *WinNtGetStockObject) ( + INT32 + ); + +typedef +WINGDIAPI +BOOL +(WINAPI *WinNtSetViewportOrgEx) ( + HDC, + INT32, + INT32, + LPPOINT + ); + +typedef +WINGDIAPI +BOOL +(WINAPI *WinNtSetWindowOrgEx) ( + HDC, + INT32, + INT32, + LPPOINT + ); +typedef +WINGDIAPI +BOOL +(WINAPI *WinNtMoveWindow) ( + HWND, + INT32, + INT32, + INT32, + INT32, + BOOL + ); + +typedef +WINGDIAPI +BOOL +(WINAPI *WinNtGetWindowRect) ( + HWND, + LPRECT + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtGetMessage) ( + LPMSG lpMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtTranslateMessage) ( + CONST MSG *lpMsg + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtDispatchMessage) ( + CONST MSG *lpMsg + ); + +typedef +WINUSERAPI +HANDLE +(WINAPI *WinNtGetProcessHeap) (); + +typedef +WINUSERAPI +LPVOID +(WINAPI *WinNtHeapAlloc) ( + HANDLE hHeap, + DWORD dwFlags, + SIZE_T dwBytes + ); + +typedef +WINUSERAPI +BOOL +(WINAPI *WinNtHeapFree) ( + HANDLE hHeap, + DWORD dwFlags, + LPVOID lpMem + ); + +typedef +WINBASEAPI +BOOL +(WINAPI *WinNtFreeLibrary) ( + HANDLE ModHandle + ); +// +// +// +EFI_FORWARD_DECLARATION (EFI_WIN_NT_THUNK_PROTOCOL); + +#define EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'T', 'T') + +typedef struct _EFI_WIN_NT_THUNK_PROTOCOL { + UINT64 Signature; + + // + // Win32 Process APIs + // + WinNtGetProcAddress GetProcAddress; + WinNtGetTickCount GetTickCount; + WinNtLoadLibraryEx LoadLibraryEx; + WinNtFreeLibrary FreeLibrary; + + WinNtSetPriorityClass SetPriorityClass; + WinNtSetThreadPriority SetThreadPriority; + WinNtSleep Sleep; + + WinNtSuspendThread SuspendThread; + WinNtGetCurrentThread GetCurrentThread; + WinNtGetCurrentThreadId GetCurrentThreadId; + WinNtGetCurrentProcess GetCurrentProcess; + WinNtCreateThread CreateThread; + WinNtTerminateThread TerminateThread; + WinNtSendMessage SendMessage; + WinNtExitThread ExitThread; + WinNtResumeThread ResumeThread; + WinNtDuplicateHandle DuplicateHandle; + + // + // Wint32 Mutex primitive + // + WinNtInitializeCriticalSection InitializeCriticalSection; + WinNtEnterCriticalSection EnterCriticalSection; + WinNtLeaveCriticalSection LeaveCriticalSection; + WinNtDeleteCriticalSection DeleteCriticalSection; + WinNtTlsAlloc TlsAlloc; + WinNtTlsFree TlsFree; + WinNtTlsSetValue TlsSetValue; + WinNtTlsGetValue TlsGetValue; + WinNtCreateSemaphore CreateSemaphore; + WinNtWaitForSingleObject WaitForSingleObject; + WinNtReleaseSemaphore ReleaseSemaphore; + + // + // Win32 Console APIs + // + WinNtCreateConsoleScreenBuffer CreateConsoleScreenBuffer; + WinNtFillConsoleOutputAttribute FillConsoleOutputAttribute; + WinNtFillConsoleOutputCharacter FillConsoleOutputCharacter; + WinNtGetConsoleCursorInfo GetConsoleCursorInfo; + WinNtGetNumberOfConsoleInputEvents GetNumberOfConsoleInputEvents; + WinNtPeekConsoleInput PeekConsoleInput; + WinNtScrollConsoleScreenBuffer ScrollConsoleScreenBuffer; + WinNtReadConsoleInput ReadConsoleInput; + + WinNtSetConsoleActiveScreenBuffer SetConsoleActiveScreenBuffer; + WinNtSetConsoleCursorInfo SetConsoleCursorInfo; + WinNtSetConsoleCursorPosition SetConsoleCursorPosition; + WinNtSetConsoleScreenBufferSize SetConsoleScreenBufferSize; + WinNtSetConsoleTitleW SetConsoleTitleW; + WinNtWriteConsoleInput WriteConsoleInput; + WinNtWriteConsoleOutput WriteConsoleOutput; + + // + // Win32 File APIs + // + WinNtCreateFile CreateFile; + WinNtDeviceIoControl DeviceIoControl; + WinNtCreateDirectory CreateDirectory; + WinNtRemoveDirectory RemoveDirectory; + WinNtGetFileAttributes GetFileAttributes; + WinNtSetFileAttributes SetFileAttributes; + WinNtCreateFileMapping CreateFileMapping; + WinNtCloseHandle CloseHandle; + WinNtDeleteFile DeleteFile; + WinNtFindFirstFile FindFirstFile; + WinNtFindNextFile FindNextFile; + WinNtFindClose FindClose; + WinNtFlushFileBuffers FlushFileBuffers; + WinNtGetEnvironmentVariable GetEnvironmentVariable; + WinNtGetLastError GetLastError; + WinNtSetErrorMode SetErrorMode; + WinNtGetStdHandle GetStdHandle; + WinNtMapViewOfFileEx MapViewOfFileEx; + WinNtReadFile ReadFile; + WinNtSetEndOfFile SetEndOfFile; + WinNtSetFilePointer SetFilePointer; + WinNtWriteFile WriteFile; + WinNtGetFileInformationByHandle GetFileInformationByHandle; + WinNtGetDiskFreeSpace GetDiskFreeSpace; + WinNtGetDiskFreeSpaceEx GetDiskFreeSpaceEx; + WinNtMoveFile MoveFile; + WinNtSetFileTime SetFileTime; + WinNtSystemTimeToFileTime SystemTimeToFileTime; + + // + // Win32 Time APIs + // + WinNtFileTimeToLocalFileTime FileTimeToLocalFileTime; + WinNtFileTimeToSystemTime FileTimeToSystemTime; + WinNtGetSystemTime GetSystemTime; + WinNtSetSystemTime SetSystemTime; + WinNtGetLocalTime GetLocalTime; + WinNtSetLocalTime SetLocalTime; + WinNtGetTimeZoneInformation GetTimeZoneInformation; + WinNtSetTimeZoneInformation SetTimeZoneInformation; + WinNttimeSetEvent timeSetEvent; + WinNttimeKillEvent timeKillEvent; + + // + // Win32 Serial APIs + // + WinNtClearCommError ClearCommError; + WinNtEscapeCommFunction EscapeCommFunction; + WinNtGetCommModemStatus GetCommModemStatus; + WinNtGetCommState GetCommState; + WinNtSetCommState SetCommState; + WinNtPurgeComm PurgeComm; + WinNtSetCommTimeouts SetCommTimeouts; + + WinNtExitProcess ExitProcess; + + WinNtSprintf SPrintf; + + WinNtGetDesktopWindow GetDesktopWindow; + WinNtGetForegroundWindow GetForegroundWindow; + WinNtCreateWindowEx CreateWindowEx; + WinNtShowWindow ShowWindow; + WinNtUpdateWindow UpdateWindow; + WinNtDestroyWindow DestroyWindow; + WinNtInvalidateRect InvalidateRect; + WinNtGetWindowDC GetWindowDC; + WinNtGetClientRect GetClientRect; + WinNtAdjustWindowRect AdjustWindowRect; + WinNtSetDIBitsToDevice SetDIBitsToDevice; + WinNtBitBlt BitBlt; + WinNtGetDC GetDC; + WinNtReleaseDC ReleaseDC; + WinNtRegisterClassEx RegisterClassEx; + WinNtUnregisterClass UnregisterClass; + + WinNtBeginPaint BeginPaint; + WinNtEndPaint EndPaint; + WinNtPostQuitMessage PostQuitMessage; + WinNtDefWindowProc DefWindowProc; + WinNtLoadIcon LoadIcon; + WinNtLoadCursor LoadCursor; + WinNtGetStockObject GetStockObject; + WinNtSetViewportOrgEx SetViewportOrgEx; + WinNtSetWindowOrgEx SetWindowOrgEx; + WinNtMoveWindow MoveWindow; + WinNtGetWindowRect GetWindowRect; + + WinNtGetMessage GetMessage; + WinNtTranslateMessage TranslateMessage; + WinNtDispatchMessage DispatchMessage; + + WinNtGetProcessHeap GetProcessHeap; + WinNtHeapAlloc HeapAlloc; + WinNtHeapFree HeapFree; + +} EFI_WIN_NT_THUNK_PROTOCOL; + +#endif + +extern EFI_GUID gEfiWinNtThunkProtocolGuid; + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/Makefile new file mode 100644 index 0000000000..b067e85619 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/Makefile @@ -0,0 +1,97 @@ +#/*++ +# +# Copyright (c) 2006 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the BootsectImage utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=BootsectImage +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\BootsectImage.c" +TARGET_EXE_INCLUDE = "$(TARGET_SOURCE_DIR)\fat.h" \ + "$(TARGET_SOURCE_DIR)\mbr.h" \ + + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(EDK_TOOLS_OUTPUT)\Common.lib + $(LINK) $(MSVS_LINK_LIBPATHS) $(EDK_TOOLS_OUTPUT)\Common.lib $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/bootsectimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/bootsectimage.c new file mode 100644 index 0000000000..d71a03df0b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/bootsectimage.c @@ -0,0 +1,881 @@ +/*++ + +Copyright 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + bootsectimage.c + +Abstract: + Patch the BPB information in boot sector image file. + Patch the MBR code in MBR image file. + +--*/ + + +#include +#include +#include "fat.h" +#include "mbr.h" +#include "EfiUtilityMsgs.h" + +#define DEBUG_WARN 0x1 +#define DEBUG_ERROR 0x2 +int WriteToFile ( + void *BootSector, + char *FileName + ) +/*++ +Routine Description: + Write 512 bytes boot sector to file. + +Arguments: + BootSector - point to a buffer containing 512 bytes boot sector to write + FileName - file to write to + +Return: + int - number of bytes wrote, + 512 indicates write successful + 0 indicates write failure +--*/ +{ + FILE *FileHandle; + int result; + + FileHandle = fopen (FileName, "r+b"); + if (FileHandle == NULL) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Open file: %s", FileName); + return 0; + } + fseek (FileHandle, 0, SEEK_SET); + + result = fwrite (BootSector, 1, 512, FileHandle); + if (result != 512) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Write file: %s", FileName); + result = 0; + } + + fclose (FileHandle); + return result; +} + +int ReadFromFile ( + void *BootSector, + char *FileName + ) +/*++ +Routine Description: + Read first 512 bytes from file. + +Arguments: + BootSector - point to a buffer receiving the first 512 bytes data from file + FileName - file to read from + +Return: + int - number of bytes read, + 512 indicates read successful + 0 indicates read failure +--*/ +{ + FILE *FileHandle; + int result; + + FileHandle = fopen (FileName, "rb"); + if (FileHandle == NULL) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Open file: %s", FileName); + return 0; + } + + result = fread (BootSector, 1, 512, FileHandle); + if (result != 512) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Read file: %s", FileName); + result = 0; + } + + fclose (FileHandle); + return result; +} + +char * +FatTypeToString ( + IN FAT_TYPE FatType + ) +/*++ +Routine Description: + Convert enum type of FatType to string +--*/ +{ + switch (FatType) { + case FatTypeFat12: + return "FAT12"; + case FatTypeFat16: + return "FAT16"; + case FatTypeFat32: + return "FAT32"; + default: + break; + } + return "FAT Unknown"; +} + +FAT_TYPE +GetFatType ( + IN FAT_BPB_STRUCT *FatBpb + ) +/*++ +Routine Description: + Determine the FAT type according to BIOS Paramater Block (BPB) data + +Arguments: + FatBpb - BIOS Parameter Block (BPB) data, 512 Bytes + +Return: + FatTypeUnknown - Cannot determine the FAT type + FatTypeFat12 - FAT12 + FatTypeFat16 - FAT16 + FatTypeFat32 - FAT32 +--*/ +{ + FAT_TYPE FatType; + UINTN RootDirSectors; + UINTN FATSz; + UINTN TotSec; + UINTN DataSec; + UINTN CountOfClusters; + CHAR8 FilSysType[9]; + + FatType = FatTypeUnknown; + + // + // Simple check + // + if (FatBpb->Fat12_16.Signature != FAT_BS_SIGNATURE) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: Signature Invalid - %04x, expected - %04x", + FatBpb->Fat12_16.Signature, FAT_BS_SIGNATURE); + return FatTypeUnknown; + } + + // + // Check according to FAT spec + // + if ((FatBpb->Fat12_16.BS_jmpBoot[0] != FAT_BS_JMP1) && + (FatBpb->Fat12_16.BS_jmpBoot[0] != FAT_BS_JMP2)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BS_jmpBoot - %02x, expected - %02x or %02x", + FatBpb->Fat12_16.BS_jmpBoot[0], FAT_BS_JMP1, FAT_BS_JMP2); + return FatTypeUnknown; + } + + if ((FatBpb->Fat12_16.BPB_BytsPerSec != 512) && + (FatBpb->Fat12_16.BPB_BytsPerSec != 1024) && + (FatBpb->Fat12_16.BPB_BytsPerSec != 2048) && + (FatBpb->Fat12_16.BPB_BytsPerSec != 4096)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_BytsPerSec - %04x, expected - %04x, %04x, %04x, or %04x", + FatBpb->Fat12_16.BPB_BytsPerSec, 512, 1024, 2048, 4096); + return FatTypeUnknown; + } + if (FatBpb->Fat12_16.BPB_BytsPerSec != 512) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT: BPB_BytsPerSec - %04x, expected - %04x", + FatBpb->Fat12_16.BPB_BytsPerSec, 512); + } + if ((FatBpb->Fat12_16.BPB_SecPerClus != 1) && + (FatBpb->Fat12_16.BPB_SecPerClus != 2) && + (FatBpb->Fat12_16.BPB_SecPerClus != 4) && + (FatBpb->Fat12_16.BPB_SecPerClus != 8) && + (FatBpb->Fat12_16.BPB_SecPerClus != 16) && + (FatBpb->Fat12_16.BPB_SecPerClus != 32) && + (FatBpb->Fat12_16.BPB_SecPerClus != 64) && + (FatBpb->Fat12_16.BPB_SecPerClus != 128)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_SecPerClus - %02x, expected - %02x, %02x, %02x, %02x, %02x, %02x, %02x, or %02x", + FatBpb->Fat12_16.BPB_BytsPerSec, 1, 2, 4, 8, 16, 32, 64, 128); + return FatTypeUnknown; + } + if (FatBpb->Fat12_16.BPB_BytsPerSec * FatBpb->Fat12_16.BPB_SecPerClus > 32 * 1024) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_BytsPerSec * BPB_SecPerClus - %08x, expected <= %08x", + FatBpb->Fat12_16.BPB_BytsPerSec * FatBpb->Fat12_16.BPB_SecPerClus, 32 * 1024); + return FatTypeUnknown; + } + if (FatBpb->Fat12_16.BPB_RsvdSecCnt == 0) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_RsvdSecCnt - %04x, expected - Non-Zero", + FatBpb->Fat12_16.BPB_RsvdSecCnt); + return FatTypeUnknown; + } + if (FatBpb->Fat12_16.BPB_NumFATs != 2) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT: BPB_NumFATs - %02x, expected - %02x", + FatBpb->Fat12_16.BPB_NumFATs, 2); + } + if ((FatBpb->Fat12_16.BPB_Media != 0xF0) && + (FatBpb->Fat12_16.BPB_Media != 0xF8) && + (FatBpb->Fat12_16.BPB_Media != 0xF9) && + (FatBpb->Fat12_16.BPB_Media != 0xFA) && + (FatBpb->Fat12_16.BPB_Media != 0xFB) && + (FatBpb->Fat12_16.BPB_Media != 0xFC) && + (FatBpb->Fat12_16.BPB_Media != 0xFD) && + (FatBpb->Fat12_16.BPB_Media != 0xFE) && + (FatBpb->Fat12_16.BPB_Media != 0xFF)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_Media - %02x, expected - %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, or %02x", + FatBpb->Fat12_16.BPB_Media, 0xF0, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF); + return FatTypeUnknown; + } + + // + // Algo in FAT spec + // + RootDirSectors = ((FatBpb->Fat12_16.BPB_RootEntCnt * sizeof(FAT_DIRECTORY_ENTRY)) + + (FatBpb->Fat12_16.BPB_BytsPerSec - 1)) / + FatBpb->Fat12_16.BPB_BytsPerSec; + + if (FatBpb->Fat12_16.BPB_FATSz16 != 0) { + FATSz = FatBpb->Fat12_16.BPB_FATSz16; + } else { + FATSz = FatBpb->Fat32.BPB_FATSz32; + } + if (FATSz == 0) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_FATSz16, BPB_FATSz32 - 0, expected - Non-Zero"); + return FatTypeUnknown; + } + + if (FatBpb->Fat12_16.BPB_TotSec16 != 0) { + TotSec = FatBpb->Fat12_16.BPB_TotSec16; + } else { + TotSec = FatBpb->Fat12_16.BPB_TotSec32; + } + if (TotSec == 0) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT: BPB_TotSec16, BPB_TotSec32 - 0, expected - Non-Zero"); + return FatTypeUnknown; + } + + DataSec = TotSec - ( + FatBpb->Fat12_16.BPB_RsvdSecCnt + + FatBpb->Fat12_16.BPB_NumFATs * FATSz + + RootDirSectors + ); + + CountOfClusters = DataSec / FatBpb->Fat12_16.BPB_SecPerClus; + + if (CountOfClusters < FAT_MAX_FAT12_CLUSTER) { + FatType = FatTypeFat12; + } else if (CountOfClusters < FAT_MAX_FAT16_CLUSTER) { + FatType = FatTypeFat16; + } else { + FatType = FatTypeFat32; + } + // + // Check according to FAT spec + // + if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) && + (FatBpb->Fat12_16.BPB_RsvdSecCnt != 1)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT12_16: BPB_RsvdSecCnt - %04x, expected - %04x", + FatBpb->Fat12_16.BPB_RsvdSecCnt, 1); + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat12_16.BPB_RsvdSecCnt != 32)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_RsvdSecCnt - %04x, expected - %04x", + FatBpb->Fat12_16.BPB_RsvdSecCnt, 32); + } + if ((FatType == FatTypeFat16) && + (FatBpb->Fat12_16.BPB_RootEntCnt != 512)) { + printf ("WARNING: FAT16: BPB_RootEntCnt - %04x, expected - %04x\n", + FatBpb->Fat12_16.BPB_RootEntCnt, 512); + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat12_16.BPB_RootEntCnt != 0)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_RootEntCnt - %04x, expected - %04x", + FatBpb->Fat12_16.BPB_RootEntCnt, 0); + return FatTypeUnknown; + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat12_16.BPB_TotSec16 != 0)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_TotSec16 - %04x, expected - %04x", + FatBpb->Fat12_16.BPB_TotSec16, 0); + return FatTypeUnknown; + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat12_16.BPB_FATSz16 != 0)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_FATSz16 - %04x, expected - %04x", + FatBpb->Fat12_16.BPB_FATSz16, 0); + return FatTypeUnknown; + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat12_16.BPB_TotSec32 == 0)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_TotSec32 - %04x, expected - Non-Zero", + FatBpb->Fat12_16.BPB_TotSec32); + return FatTypeUnknown; + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat32.BPB_FATSz32 == 0)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_FATSz32 - %08x, expected - Non-Zero", + FatBpb->Fat32.BPB_FATSz32); + return FatTypeUnknown; + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat32.BPB_FSVer != 0)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_FSVer - %08x, expected - %04x", + FatBpb->Fat32.BPB_FSVer, 0); + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat32.BPB_RootClus != 2)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_RootClus - %08x, expected - %04x", + FatBpb->Fat32.BPB_RootClus, 2); + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat32.BPB_FSInfo != 1)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_FSInfo - %08x, expected - %04x", + FatBpb->Fat32.BPB_FSInfo, 1); + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat32.BPB_BkBootSec != 6)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BPB_BkBootSec - %08x, expected - %04x", + FatBpb->Fat32.BPB_BkBootSec, 6); + } + if ((FatType == FatTypeFat32) && + ((*(UINT32 *)FatBpb->Fat32.BPB_Reserved != 0) || + (*((UINT32 *)FatBpb->Fat32.BPB_Reserved + 1) != 0) || + (*((UINT32 *)FatBpb->Fat32.BPB_Reserved + 2) != 0))) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BPB_Reserved - %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x, expected - 0", + FatBpb->Fat32.BPB_Reserved[0], + FatBpb->Fat32.BPB_Reserved[1], + FatBpb->Fat32.BPB_Reserved[2], + FatBpb->Fat32.BPB_Reserved[3], + FatBpb->Fat32.BPB_Reserved[4], + FatBpb->Fat32.BPB_Reserved[5], + FatBpb->Fat32.BPB_Reserved[6], + FatBpb->Fat32.BPB_Reserved[7], + FatBpb->Fat32.BPB_Reserved[8], + FatBpb->Fat32.BPB_Reserved[9], + FatBpb->Fat32.BPB_Reserved[10], + FatBpb->Fat32.BPB_Reserved[11]); + return FatTypeUnknown; + } + if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) && + (FatBpb->Fat12_16.BS_Reserved1 != 0)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT12_16: BS_Reserved1 - %02x, expected - 0\n", + FatBpb->Fat12_16.BS_Reserved1); + return FatTypeUnknown; + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat32.BS_Reserved1 != 0)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BS_Reserved1 - %02x, expected - 0\n", + FatBpb->Fat32.BS_Reserved1); + return FatTypeUnknown; + } + if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) && + (FatBpb->Fat12_16.BS_BootSig != FAT_BS_BOOTSIG)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT12_16: BS_BootSig - %02x, expected - %02x\n", + FatBpb->Fat12_16.BS_BootSig, FAT_BS_BOOTSIG); + return FatTypeUnknown; + } + if ((FatType == FatTypeFat32) && + (FatBpb->Fat32.BS_BootSig != FAT_BS_BOOTSIG)) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT32: BS_BootSig - %02x, expected - %02x\n", + FatBpb->Fat32.BS_BootSig, FAT_BS_BOOTSIG); + return FatTypeUnknown; + } + + if ((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) { + memcpy (FilSysType, FatBpb->Fat12_16.BS_FilSysType, 8); + FilSysType[8] = 0; + if ((FatType == FatTypeFat12) && + (strcmp (FilSysType, FAT12_FILSYSTYPE) != 0) && + (strcmp (FilSysType, FAT_FILSYSTYPE) != 0)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT12: BS_FilSysType - %s, expected - %s, or %s\n", + FilSysType, FAT12_FILSYSTYPE, FAT_FILSYSTYPE); + } + if ((FatType == FatTypeFat16) && + (strcmp (FilSysType, FAT16_FILSYSTYPE) != 0) && + (strcmp (FilSysType, FAT_FILSYSTYPE) != 0)) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT16: BS_FilSysType - %s, expected - %s, or %s\n", + FilSysType, FAT16_FILSYSTYPE, FAT_FILSYSTYPE); + } + } + if (FatType == FatTypeFat32) { + memcpy (FilSysType, FatBpb->Fat32.BS_FilSysType, 8); + FilSysType[8] = 0; + if (strcmp (FilSysType, FAT32_FILSYSTYPE) != 0) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT32: BS_FilSysType - %s, expected - %s\n", + FilSysType, FAT32_FILSYSTYPE); + } + } + + // + // pass all check, get FAT type + // + return FatType; +} + + +void +ParseBootSector ( + char *FileName + ) +{ + FAT_BPB_STRUCT FatBpb; + FAT_TYPE FatType; + + if (ReadFromFile ((void *)&FatBpb, FileName) == 0) { + return ; + } + + FatType = GetFatType (&FatBpb); + if (FatType <= FatTypeUnknown || FatType >= FatTypeMax) { + printf ("ERROR: Unknown Fat Type!\n"); + return; + } + + printf ("\nBoot Sector %s:\n", FatTypeToString (FatType)); + printf ("\n"); + printf (" Offset Title Data\n"); + printf ("==================================================================\n"); + printf (" 0 JMP instruction %02x %02x %02x\n", + FatBpb.Fat12_16.BS_jmpBoot[0], + FatBpb.Fat12_16.BS_jmpBoot[1], + FatBpb.Fat12_16.BS_jmpBoot[2]); + printf (" 3 OEM %c%c%c%c%c%c%c%c\n", + FatBpb.Fat12_16.BS_OEMName[0], + FatBpb.Fat12_16.BS_OEMName[1], + FatBpb.Fat12_16.BS_OEMName[2], + FatBpb.Fat12_16.BS_OEMName[3], + FatBpb.Fat12_16.BS_OEMName[4], + FatBpb.Fat12_16.BS_OEMName[5], + FatBpb.Fat12_16.BS_OEMName[6], + FatBpb.Fat12_16.BS_OEMName[7]); + printf ("\n"); + printf ("BIOS Parameter Block\n"); + printf (" B Bytes per sector %04x\n", FatBpb.Fat12_16.BPB_BytsPerSec); + printf (" D Sectors per cluster %02x\n", FatBpb.Fat12_16.BPB_SecPerClus); + printf (" E Reserved sectors %04x\n", FatBpb.Fat12_16.BPB_RsvdSecCnt); + printf (" 10 Number of FATs %02x\n", FatBpb.Fat12_16.BPB_NumFATs); + printf (" 11 Root entries %04x\n", FatBpb.Fat12_16.BPB_RootEntCnt); + printf (" 13 Sectors (under 32MB) %04x\n", FatBpb.Fat12_16.BPB_TotSec16); + printf (" 15 Media descriptor %02x\n", FatBpb.Fat12_16.BPB_Media); + printf (" 16 Sectors per FAT (small vol.) %04x\n", FatBpb.Fat12_16.BPB_FATSz16); + printf (" 18 Sectors per track %04x\n", FatBpb.Fat12_16.BPB_SecPerTrk); + printf (" 1A Heads %04x\n", FatBpb.Fat12_16.BPB_NumHeads); + printf (" 1C Hidden sectors %08x\n", FatBpb.Fat12_16.BPB_HiddSec); + printf (" 20 Sectors (over 32MB) %08x\n", FatBpb.Fat12_16.BPB_TotSec32); + printf ("\n"); + if (FatType != FatTypeFat32) { + printf (" 24 BIOS drive %02x\n", FatBpb.Fat12_16.BS_DrvNum); + printf (" 25 (Unused) %02x\n", FatBpb.Fat12_16.BS_Reserved1); + printf (" 26 Ext. boot signature %02x\n", FatBpb.Fat12_16.BS_BootSig); + printf (" 27 Volume serial number %08x\n", FatBpb.Fat12_16.BS_VolID); + printf (" 2B Volume lable %c%c%c%c%c%c%c%c%c%c%c\n", + FatBpb.Fat12_16.BS_VolLab[0], + FatBpb.Fat12_16.BS_VolLab[1], + FatBpb.Fat12_16.BS_VolLab[2], + FatBpb.Fat12_16.BS_VolLab[3], + FatBpb.Fat12_16.BS_VolLab[4], + FatBpb.Fat12_16.BS_VolLab[5], + FatBpb.Fat12_16.BS_VolLab[6], + FatBpb.Fat12_16.BS_VolLab[7], + FatBpb.Fat12_16.BS_VolLab[8], + FatBpb.Fat12_16.BS_VolLab[9], + FatBpb.Fat12_16.BS_VolLab[10]); + printf (" 36 File system %c%c%c%c%c%c%c%c\n", + FatBpb.Fat12_16.BS_FilSysType[0], + FatBpb.Fat12_16.BS_FilSysType[1], + FatBpb.Fat12_16.BS_FilSysType[2], + FatBpb.Fat12_16.BS_FilSysType[3], + FatBpb.Fat12_16.BS_FilSysType[4], + FatBpb.Fat12_16.BS_FilSysType[5], + FatBpb.Fat12_16.BS_FilSysType[6], + FatBpb.Fat12_16.BS_FilSysType[7]); + printf ("\n"); + } else { + printf ("FAT32 Section\n"); + printf (" 24 Sectors per FAT (large vol.) %08x\n", FatBpb.Fat32.BPB_FATSz32); + printf (" 28 Flags %04x\n", FatBpb.Fat32.BPB_ExtFlags); + printf (" 2A Version %04x\n", FatBpb.Fat32.BPB_FSVer); + printf (" 2C Root dir 1st cluster %08x\n", FatBpb.Fat32.BPB_RootClus); + printf (" 30 FSInfo sector %04x\n", FatBpb.Fat32.BPB_FSInfo); + printf (" 32 Backup boot sector %04x\n", FatBpb.Fat32.BPB_BkBootSec); + printf (" 34 (Reserved) %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", + FatBpb.Fat32.BPB_Reserved[0], + FatBpb.Fat32.BPB_Reserved[1], + FatBpb.Fat32.BPB_Reserved[2], + FatBpb.Fat32.BPB_Reserved[3], + FatBpb.Fat32.BPB_Reserved[4], + FatBpb.Fat32.BPB_Reserved[5], + FatBpb.Fat32.BPB_Reserved[6], + FatBpb.Fat32.BPB_Reserved[7], + FatBpb.Fat32.BPB_Reserved[8], + FatBpb.Fat32.BPB_Reserved[9], + FatBpb.Fat32.BPB_Reserved[10], + FatBpb.Fat32.BPB_Reserved[11]); + printf ("\n"); + printf (" 40 BIOS drive %02x\n", FatBpb.Fat32.BS_DrvNum); + printf (" 41 (Unused) %02x\n", FatBpb.Fat32.BS_Reserved1); + printf (" 42 Ext. boot signature %02x\n", FatBpb.Fat32.BS_BootSig); + printf (" 43 Volume serial number %08x\n", FatBpb.Fat32.BS_VolID); + printf (" 47 Volume lable %c%c%c%c%c%c%c%c%c%c%c\n", + FatBpb.Fat32.BS_VolLab[0], + FatBpb.Fat32.BS_VolLab[1], + FatBpb.Fat32.BS_VolLab[2], + FatBpb.Fat32.BS_VolLab[3], + FatBpb.Fat32.BS_VolLab[4], + FatBpb.Fat32.BS_VolLab[5], + FatBpb.Fat32.BS_VolLab[6], + FatBpb.Fat32.BS_VolLab[7], + FatBpb.Fat32.BS_VolLab[8], + FatBpb.Fat32.BS_VolLab[9], + FatBpb.Fat32.BS_VolLab[10]); + printf (" 52 File system %c%c%c%c%c%c%c%c\n", + FatBpb.Fat32.BS_FilSysType[0], + FatBpb.Fat32.BS_FilSysType[1], + FatBpb.Fat32.BS_FilSysType[2], + FatBpb.Fat32.BS_FilSysType[3], + FatBpb.Fat32.BS_FilSysType[4], + FatBpb.Fat32.BS_FilSysType[5], + FatBpb.Fat32.BS_FilSysType[6], + FatBpb.Fat32.BS_FilSysType[7]); + printf ("\n"); + } + printf (" 1FE Signature %04x\n", FatBpb.Fat12_16.Signature); + printf ("\n"); + + + return ; +} + +void +PatchBootSector ( + char *DestFileName, + char *SourceFileName, + BOOL ForcePatch + ) +/*++ +Routine Description: + Patch destination file according to the information from source file. + Only patch BPB data but leave boot code un-touched. + +Arguments: + DestFileName - Destination file to patch + SourceFileName - Source file where patch from +--*/ +{ + FAT_BPB_STRUCT DestFatBpb; + FAT_BPB_STRUCT SourceFatBpb; + FAT_TYPE DestFatType; + FAT_TYPE SourceFatType; + CHAR8 VolLab[11]; + CHAR8 FilSysType[8]; + + if (ReadFromFile ((void *)&DestFatBpb, DestFileName) == 0) { + return ; + } + if (ReadFromFile ((void *)&SourceFatBpb, SourceFileName) == 0) { + return ; + } + + DestFatType = GetFatType (&DestFatBpb); + SourceFatType = GetFatType (&SourceFatBpb); + + if (DestFatType != SourceFatType) { + // + // FAT type mismatch + // + if (ForcePatch) { + DebugMsg (NULL, 0, DEBUG_WARN, NULL, "FAT type mismatch: Dest - %s, Source - %s", + FatTypeToString(DestFatType), FatTypeToString(SourceFatType)); + } else { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "FAT type mismatch: Dest - %s, Source - %s", + FatTypeToString(DestFatType), FatTypeToString(SourceFatType)); + return ; + } + } + + if (SourceFatType <= FatTypeUnknown || SourceFatType >= FatTypeMax) { + DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Unknown Fat Type!\n"); + return; + } + + // + // Copy BPB/boot data (excluding BS_jmpBoot, BS_OEMName, BootCode and Signature) from SourceFatBpb to DestFatBpb + // + printf ("Patching %s BPB: ", FatTypeToString (SourceFatType)); + if (SourceFatType != FatTypeFat32) { + memcpy ( + &DestFatBpb.Fat12_16.BPB_BytsPerSec, + &SourceFatBpb.Fat12_16.BPB_BytsPerSec, + ((UINTN)&DestFatBpb.Fat12_16.Reserved - (UINTN)&DestFatBpb.Fat12_16.BPB_BytsPerSec) + ); + } else { + memcpy ( + &DestFatBpb.Fat32.BPB_BytsPerSec, + &SourceFatBpb.Fat32.BPB_BytsPerSec, + ((UINTN)&DestFatBpb.Fat32.Reserved - (UINTN)&DestFatBpb.Fat32.BPB_BytsPerSec) + ); + } + + // + // Set BS_VolLab and BS_FilSysType of DestFatBpb + // + // BS_VolLab BS_FilSysType + // FAT12: EFI FAT12 FAT12 + // FAT16: EFI FAT16 FAT16 + // FAT32: EFI FAT32 FAT32 + // + if (SourceFatType == FatTypeFat32) { + memcpy (VolLab, "EFI FAT32 ", sizeof(VolLab)); + memcpy (FilSysType, FAT32_FILSYSTYPE, sizeof(FilSysType)); + } else if (SourceFatType == FatTypeFat16) { + memcpy (VolLab, "EFI FAT16 ", sizeof(VolLab)); + memcpy (FilSysType, FAT16_FILSYSTYPE, sizeof(FilSysType)); + } else { + memcpy (VolLab, "EFI FAT12 ", sizeof(VolLab)); + memcpy (FilSysType, FAT12_FILSYSTYPE, sizeof(FilSysType)); + } + if (SourceFatType != FatTypeFat32) { + memcpy (DestFatBpb.Fat12_16.BS_VolLab, VolLab, sizeof(VolLab)); + memcpy (DestFatBpb.Fat12_16.BS_FilSysType, FilSysType, sizeof(FilSysType)); + } else { + memcpy (DestFatBpb.Fat32.BS_VolLab, VolLab, sizeof(VolLab)); + memcpy (DestFatBpb.Fat32.BS_FilSysType, FilSysType, sizeof(FilSysType)); + } + + // + // Set Signature of DestFatBpb to 55AA + // + DestFatBpb.Fat12_16.Signature = FAT_BS_SIGNATURE; + + // + // Write DestFatBpb + // + if (WriteToFile ((void *)&DestFatBpb, DestFileName)) { + printf ("successfully!\n"); + } else { + printf ("failed!\n"); + } + + return ; +} + +void +ParseMbr ( + char *FileName + ) +{ + MASTER_BOOT_RECORD Mbr; + + if (ReadFromFile ((void *)&Mbr, FileName) == 0) { + return ; + } + + printf ("\nMaster Boot Record:\n"); + printf ("\n"); + printf (" Offset Title Value\n"); + printf ("==================================================================\n"); + printf (" 0 Master bootstrap loader code (not list)\n"); + printf (" 1B8 Windows disk signature %08x\n", Mbr.UniqueMbrSignature); + printf ("\n"); + printf ("Partition Table Entry #1\n"); + printf (" 1BE 80 = active partition %02x\n", Mbr.PartitionRecord[0].BootIndicator); + printf (" 1BF Start head %02x\n", Mbr.PartitionRecord[0].StartHead); + printf (" 1C0 Start sector %02x\n", Mbr.PartitionRecord[0].StartSector); + printf (" 1C1 Start cylinder %02x\n", Mbr.PartitionRecord[0].StartTrack); + printf (" 1C2 Partition type indicator %02x\n", Mbr.PartitionRecord[0].OSType); + printf (" 1C3 End head %02x\n", Mbr.PartitionRecord[0].EndHead); + printf (" 1C4 End sector %02x\n", Mbr.PartitionRecord[0].EndSector); + printf (" 1C5 End cylinder %02x\n", Mbr.PartitionRecord[0].EndTrack); + printf (" 1C6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[0].StartingLBA); + printf (" 1CA Sectors in partition %08x\n", Mbr.PartitionRecord[0].SizeInLBA); + printf ("\n"); + printf ("Partition Table Entry #2\n"); + printf (" 1CE 80 = active partition %02x\n", Mbr.PartitionRecord[1].BootIndicator); + printf (" 1CF Start head %02x\n", Mbr.PartitionRecord[1].StartHead); + printf (" 1D0 Start sector %02x\n", Mbr.PartitionRecord[1].StartSector); + printf (" 1D1 Start cylinder %02x\n", Mbr.PartitionRecord[1].StartTrack); + printf (" 1D2 Partition type indicator %02x\n", Mbr.PartitionRecord[1].OSType); + printf (" 1D3 End head %02x\n", Mbr.PartitionRecord[1].EndHead); + printf (" 1D4 End sector %02x\n", Mbr.PartitionRecord[1].EndSector); + printf (" 1D5 End cylinder %02x\n", Mbr.PartitionRecord[1].EndTrack); + printf (" 1D6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[1].StartingLBA); + printf (" 1DA Sectors in partition %08x\n", Mbr.PartitionRecord[1].SizeInLBA); + printf ("\n"); + printf ("Partition Table Entry #3\n"); + printf (" 1DE 80 = active partition %02x\n", Mbr.PartitionRecord[2].BootIndicator); + printf (" 1DF Start head %02x\n", Mbr.PartitionRecord[2].StartHead); + printf (" 1E0 Start sector %02x\n", Mbr.PartitionRecord[2].StartSector); + printf (" 1E1 Start cylinder %02x\n", Mbr.PartitionRecord[2].StartTrack); + printf (" 1E2 Partition type indicator %02x\n", Mbr.PartitionRecord[2].OSType); + printf (" 1E3 End head %02x\n", Mbr.PartitionRecord[2].EndHead); + printf (" 1E4 End sector %02x\n", Mbr.PartitionRecord[2].EndSector); + printf (" 1E5 End cylinder %02x\n", Mbr.PartitionRecord[2].EndTrack); + printf (" 1E6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[2].StartingLBA); + printf (" 1EA Sectors in partition %08x\n", Mbr.PartitionRecord[2].SizeInLBA); + printf ("\n"); + printf ("Partition Table Entry #4\n"); + printf (" 1EE 80 = active partition %02x\n", Mbr.PartitionRecord[3].BootIndicator); + printf (" 1EF Start head %02x\n", Mbr.PartitionRecord[3].StartHead); + printf (" 1F0 Start sector %02x\n", Mbr.PartitionRecord[3].StartSector); + printf (" 1F1 Start cylinder %02x\n", Mbr.PartitionRecord[3].StartTrack); + printf (" 1F2 Partition type indicator %02x\n", Mbr.PartitionRecord[3].OSType); + printf (" 1F3 End head %02x\n", Mbr.PartitionRecord[3].EndHead); + printf (" 1F4 End sector %02x\n", Mbr.PartitionRecord[3].EndSector); + printf (" 1F5 End cylinder %02x\n", Mbr.PartitionRecord[3].EndTrack); + printf (" 1F6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[3].StartingLBA); + printf (" 1FA Sectors in partition %08x\n", Mbr.PartitionRecord[3].SizeInLBA); + printf ("\n"); + printf (" 1FE Signature %04x\n", Mbr.Signature); + printf ("\n"); + + return ; +} + +void +PatchMbr ( + char *DestFileName, + char *SourceFileName + ) +{ + MASTER_BOOT_RECORD DestMbr; + MASTER_BOOT_RECORD SourceMbr; + + if (ReadFromFile ((void *)&DestMbr, DestFileName) == 0) { + return ; + } + if (ReadFromFile ((void *)&SourceMbr, SourceFileName) == 0) { + return ; + } + + if (SourceMbr.Signature != MBR_SIGNATURE) { + printf ("ERROR: Invalid MBR!\n"); + return; + } + + printf ("Patching MBR:\n"); + memcpy ( + &DestMbr.PartitionRecord[0], + &SourceMbr.PartitionRecord[0], + sizeof(DestMbr.PartitionRecord) + ); + + DestMbr.Signature = MBR_SIGNATURE; + + + if (WriteToFile ((void *)&DestMbr, DestFileName)) { + printf ("\tsuccessfully!\n"); + } + + return ; +} + +void +PrintUsage ( + void + ) +{ + printf ( + "Usage:\n" + "bootsectimage [-m] [-v] -p SrcImage\n" + "bootsectimage [-m] [-v] [-f] -g SrcImage DstImage\n" + "where\n" + " -p: parse SrcImage\n" + " -g: get info from SrcImage, and patch to DstImage\n" + " -f: force patch even FAT type of SrcImage and DstImage mismatch\n" + " -m: process MBR instead of boot sector\n" + " -v: verbose\n" + ); +} + +int +main ( + int argc, + char *argv[] + ) +{ + char *SrcImage; + char *DstImage; + BOOL ForcePatch; // -f + BOOL ProcessMbr; // -m + BOOL DoParse; // -p SrcImage or -g SrcImage DstImage + BOOL Verbose; // -v + + SrcImage = DstImage = NULL; + ForcePatch = FALSE; + ProcessMbr = FALSE; + DoParse = TRUE; + Verbose = FALSE; + + SetUtilityName ("bootsectimage"); + + argc--; argv++; + + if (argc == 0) { + PrintUsage (); + return -1; + } + + while (argc != 0) { + if (strcmp (*argv, "-f") == 0) { + ForcePatch = TRUE; + } else if (strcmp (*argv, "-p") == 0) { + DoParse = TRUE; + argc--; argv++; + if (argc < 1) { + PrintUsage (); + return -1; + } + SrcImage = *argv; + } else if (strcmp (*argv, "-g") == 0) { + DoParse = FALSE; + argc--; argv++; + if (argc < 2) { + PrintUsage (); + return -1; + } + SrcImage = *argv; + argc--; argv++; + DstImage = *argv; + } else if (strcmp (*argv, "-m") == 0) { + ProcessMbr = TRUE; + } else if (strcmp (*argv, "-v") == 0) { + Verbose = TRUE; + } else { + PrintUsage (); + return -1; + } + + argc--; argv++; + } + + if (ForcePatch && DoParse) { + printf ("Cannot apply force(-f) to parse(-p)!\n"); + PrintUsage (); + return -1; + } + if (ForcePatch && !DoParse && ProcessMbr) { + printf ("Cannot apply force(-f) to processing MBR (-g -m)!\n"); + PrintUsage (); + return -1; + } + + if (Verbose) { + SetDebugMsgMask (DEBUG_WARN | DEBUG_ERROR); + } else { + SetDebugMsgMask (0); + } + + if (DoParse) { + if (ProcessMbr) { + ParseMbr (SrcImage); + } else { + ParseBootSector (SrcImage); + } + } else { + if (ProcessMbr) { + PatchMbr (DstImage, SrcImage); + } else { + PatchBootSector (DstImage, SrcImage, ForcePatch); + } + } + + return 0; +} + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/fat.h b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/fat.h new file mode 100644 index 0000000000..330312688b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/fat.h @@ -0,0 +1,158 @@ +/*++ + +Copyright 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + fat.h + +Abstract: + +Revision History + +--*/ + +#ifndef _FAT_BPB_H_ +#define _FAT_BPB_H_ + +#include "Tiano.h" + +#pragma pack(1) + +typedef struct { + // + // Fat common field + // + UINT8 BS_jmpBoot[3]; + CHAR8 BS_OEMName[8]; + UINT16 BPB_BytsPerSec; + UINT8 BPB_SecPerClus; + UINT16 BPB_RsvdSecCnt; + UINT8 BPB_NumFATs; + UINT16 BPB_RootEntCnt; + UINT16 BPB_TotSec16; + UINT8 BPB_Media; + UINT16 BPB_FATSz16; + UINT16 BPB_SecPerTrk; + UINT16 BPB_NumHeads; + UINT32 BPB_HiddSec; + UINT32 BPB_TotSec32; + + // + // Fat12/16 specific field + // + UINT8 BS_DrvNum; + UINT8 BS_Reserved1; + UINT8 BS_BootSig; + UINT32 BS_VolID; + CHAR8 BS_VolLab[11]; + CHAR8 BS_FilSysType[8]; + + // + // Boot Code and Data + // + UINT8 Reserved[448]; + + // + // Fat common signature - 0xAA55 + // + UINT16 Signature; +} FAT12_16_BPB_STRUCT; + +typedef struct { + // + // Fat common field + // + UINT8 BS_jmpBoot[3]; + CHAR8 BS_OEMName[8]; + UINT16 BPB_BytsPerSec; + UINT8 BPB_SecPerClus; + UINT16 BPB_RsvdSecCnt; + UINT8 BPB_NumFATs; + UINT16 BPB_RootEntCnt; + UINT16 BPB_TotSec16; + UINT8 BPB_Media; + UINT16 BPB_FATSz16; + UINT16 BPB_SecPerTrk; + UINT16 BPB_NumHeads; + UINT32 BPB_HiddSec; + UINT32 BPB_TotSec32; + + // + // Fat32 specific field + // + UINT32 BPB_FATSz32; + UINT16 BPB_ExtFlags; + UINT16 BPB_FSVer; + UINT32 BPB_RootClus; + UINT16 BPB_FSInfo; + UINT16 BPB_BkBootSec; + UINT8 BPB_Reserved[12]; + UINT8 BS_DrvNum; + UINT8 BS_Reserved1; + UINT8 BS_BootSig; + UINT32 BS_VolID; + CHAR8 BS_VolLab[11]; + CHAR8 BS_FilSysType[8]; + + // + // Boot Code and Data + // + UINT8 Reserved[420]; + + // + // Fat common signature - 0xAA55 + // + UINT16 Signature; +} FAT32_BPB_STRUCT; + +typedef union { + FAT12_16_BPB_STRUCT Fat12_16; + FAT32_BPB_STRUCT Fat32; +} FAT_BPB_STRUCT; + +typedef enum { + FatTypeUnknown, + FatTypeFat12, + FatTypeFat16, + FatTypeFat32, + FatTypeMax +} FAT_TYPE; + +typedef struct { + CHAR8 DIR_Name[11]; + UINT8 DIR_Attr; + UINT8 DIR_NTRes; + UINT8 DIR_CrtTimeTenth; + UINT16 DIR_CrtTime; + UINT16 DIR_CrtDate; + UINT16 DIR_LstAccDate; + UINT16 DIR_FstClusHI; + UINT16 DIR_WrtTime; + UINT16 DIR_WrtDate; + UINT16 DIR_FstClusLO; + UINT32 DIR_FileSize; +} FAT_DIRECTORY_ENTRY; + +#pragma pack() + +#define FAT_MAX_FAT12_CLUSTER 0xFF5 +#define FAT_MAX_FAT16_CLUSTER 0xFFF5 + +#define FAT_BS_SIGNATURE 0xAA55 +#define FAT_BS_BOOTSIG 0x29 +#define FAT_BS_JMP1 0xEB +#define FAT_BS_JMP2 0xE9 +#define FAT_FILSYSTYPE "FAT " +#define FAT12_FILSYSTYPE "FAT12 " +#define FAT16_FILSYSTYPE "FAT16 " +#define FAT32_FILSYSTYPE "FAT32 " + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/mbr.h b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/mbr.h new file mode 100644 index 0000000000..5a95097dc1 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/BootsectImage/mbr.h @@ -0,0 +1,64 @@ +/*++ + +Copyright 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + mbr.h + +Abstract: + +Revision History + +--*/ + +#ifndef _MBR_H_ +#define _MBR_H_ + +#include "Tiano.h" + +#pragma pack(1) + +#define MAX_MBR_PARTITIONS 4 + +// +// MBR Partition Entry +// +typedef struct { + UINT8 BootIndicator; + UINT8 StartHead; + UINT8 StartSector; + UINT8 StartTrack; + UINT8 OSType; + UINT8 EndHead; + UINT8 EndSector; + UINT8 EndTrack; + UINT32 StartingLBA; + UINT32 SizeInLBA; +} MBR_PARTITION_RECORD; + +// +// MBR Partition table +// +typedef struct { + UINT8 BootCode[440]; + UINT32 UniqueMbrSignature; + UINT16 Unknown; + MBR_PARTITION_RECORD PartitionRecord[MAX_MBR_PARTITIONS]; + UINT16 Signature; +} MASTER_BOOT_RECORD; + +#pragma pack() + +#define MBR_SIGNATURE 0xAA55 +#define EXTENDED_DOS_PARTITION 0x05 +#define EXTENDED_WINDOWS_PARTITION 0x0F + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.c new file mode 100644 index 0000000000..aa2a22edd1 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.c @@ -0,0 +1,497 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CommonLib.c + +Abstract: + + Common Library Functions + +--*/ + +#include "TianoCommon.h" +#include "PeiHob.h" +#include +#include +#include +#include "CommonLib.h" + +VOID +PeiZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + Set Buffer to zero for Size bytes. + +Arguments: + + Buffer - Memory to set. + + Size - Number of bytes to set + +Returns: + + None + +--*/ +{ + INT8 *Ptr; + + Ptr = Buffer; + while (Size--) { + *(Ptr++) = 0; + } +} + +VOID +PeiCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +/*++ + +Routine Description: + + Copy Length bytes from Source to Destination. + +Arguments: + + Destination - Target of copy + + Source - Place to copy from + + Length - Number of bytes to copy + +Returns: + + None + +--*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + + Destination8 = Destination; + Source8 = Source; + while (Length--) { + *(Destination8++) = *(Source8++); + } +} + +VOID +ZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +{ + PeiZeroMem (Buffer, Size); +} + +VOID +CopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +{ + PeiCopyMem (Destination, Source, Length); +} + +INTN +CompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +/*++ + +Routine Description: + + Compares to GUIDs + +Arguments: + + Guid1 - guid to compare + Guid2 - guid to compare + +Returns: + = 0 if Guid1 == Guid2 + != 0 if Guid1 != Guid2 + +--*/ +{ + INT32 *g1; + INT32 *g2; + INT32 r; + + // + // Compare 32 bits at a time + // + g1 = (INT32 *) Guid1; + g2 = (INT32 *) Guid2; + + r = g1[0] - g2[0]; + r |= g1[1] - g2[1]; + r |= g1[2] - g2[2]; + r |= g1[3] - g2[3]; + + return r; +} + +EFI_STATUS +GetFileImage ( + IN CHAR8 *InputFileName, + OUT CHAR8 **InputFileImage, + OUT UINT32 *BytesRead + ) +/*++ + +Routine Description: + + This function opens a file and reads it into a memory buffer. The function + will allocate the memory buffer and returns the size of the buffer. + +Arguments: + + InputFileName The name of the file to read. + InputFileImage A pointer to the memory buffer. + BytesRead The size of the memory buffer. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + EFI_ABORTED An error occurred. + EFI_OUT_OF_RESOURCES No resource to complete operations. + +--*/ +{ + FILE *InputFile; + UINT32 FileSize; + + // + // Verify input parameters. + // + if (InputFileName == NULL || strlen (InputFileName) == 0 || InputFileImage == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Open the file and copy contents into a memory buffer. + // + // + // Open the file + // + InputFile = fopen (InputFileName, "rb"); + if (InputFile == NULL) { + printf ("ERROR: Could not open input file \"%s\".\n", InputFileName); + return EFI_ABORTED; + } + // + // Go to the end so that we can determine the file size + // + if (fseek (InputFile, 0, SEEK_END)) { + printf ("ERROR: System error reading input file \"%s\".\n", InputFileName); + fclose (InputFile); + return EFI_ABORTED; + } + // + // Get the file size + // + FileSize = ftell (InputFile); + if (FileSize == -1) { + printf ("ERROR: System error parsing input file \"%s\".\n", InputFileName); + fclose (InputFile); + return EFI_ABORTED; + } + // + // Allocate a buffer + // + *InputFileImage = malloc (FileSize); + if (*InputFileImage == NULL) { + fclose (InputFile); + return EFI_OUT_OF_RESOURCES; + } + // + // Reset to the beginning of the file + // + if (fseek (InputFile, 0, SEEK_SET)) { + printf ("ERROR: System error reading input file \"%s\".\n", InputFileName); + fclose (InputFile); + free (*InputFileImage); + *InputFileImage = NULL; + return EFI_ABORTED; + } + // + // Read all of the file contents. + // + *BytesRead = fread (*InputFileImage, sizeof (UINT8), FileSize, InputFile); + if (*BytesRead != sizeof (UINT8) * FileSize) { + printf ("ERROR: Reading file \"%s\"%i.\n", InputFileName); + fclose (InputFile); + free (*InputFileImage); + *InputFileImage = NULL; + return EFI_ABORTED; + } + // + // Close the file + // + fclose (InputFile); + + return EFI_SUCCESS; +} + +UINT8 +CalculateChecksum8 ( + IN UINT8 *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + This function calculates the value needed for a valid UINT8 checksum + +Arguments: + + Buffer Pointer to buffer containing byte data of component. + Size Size of the buffer + +Returns: + + The 8 bit checksum value needed. + +--*/ +{ + return (UINT8) (0x100 - CalculateSum8 (Buffer, Size)); +} + +UINT8 +CalculateSum8 ( + IN UINT8 *Buffer, + IN UINT32 Size + ) +/*++ + +Routine Description:: + + This function calculates the UINT8 sum for the requested region. + +Arguments: + + Buffer Pointer to buffer containing byte data of component. + Size Size of the buffer + +Returns: + + The 8 bit checksum value needed. + +--*/ +{ + UINTN Index; + UINT8 Sum; + + Sum = 0; + + // + // Perform the byte sum for buffer + // + for (Index = 0; Index < Size; Index++) { + Sum = (UINT8) (Sum + Buffer[Index]); + } + + return Sum; +} + +UINT16 +CalculateChecksum16 ( + IN UINT16 *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description:: + + This function calculates the value needed for a valid UINT16 checksum + +Arguments: + + Buffer Pointer to buffer containing byte data of component. + Size Size of the buffer + +Returns: + + The 16 bit checksum value needed. + +--*/ +{ + return (UINT16) (0x10000 - CalculateSum16 (Buffer, Size)); +} + +UINT16 +CalculateSum16 ( + IN UINT16 *Buffer, + IN UINTN Size + ) +/*++ + +Routine Description: + + This function calculates the UINT16 sum for the requested region. + +Arguments: + + Buffer Pointer to buffer containing byte data of component. + Size Size of the buffer + +Returns: + + The 16 bit checksum + +--*/ +{ + UINTN Index; + UINT16 Sum; + + Sum = 0; + + // + // Perform the word sum for buffer + // + for (Index = 0; Index < Size; Index++) { + Sum = (UINT16) (Sum + Buffer[Index]); + } + + return (UINT16) Sum; +} + +EFI_STATUS +PrintGuid ( + IN EFI_GUID *Guid + ) +/*++ + +Routine Description: + + This function prints a GUID to STDOUT. + +Arguments: + + Guid Pointer to a GUID to print. + +Returns: + + EFI_SUCCESS The GUID was printed. + EFI_INVALID_PARAMETER The input was NULL. + +--*/ +{ + if (Guid == NULL) { + printf ("ERROR: PrintGuid called with a NULL value.\n"); + return EFI_INVALID_PARAMETER; + } + + printf ( + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", + Guid->Data1, + Guid->Data2, + Guid->Data3, + Guid->Data4[0], + Guid->Data4[1], + Guid->Data4[2], + Guid->Data4[3], + Guid->Data4[4], + Guid->Data4[5], + Guid->Data4[6], + Guid->Data4[7] + ); + return EFI_SUCCESS; +} + +EFI_STATUS +PrintGuidToBuffer ( + IN EFI_GUID *Guid, + IN OUT UINT8 *Buffer, + IN UINT32 BufferLen, + IN BOOLEAN Uppercase + ) +/*++ + +Routine Description: + + This function prints a GUID to a buffer + +Arguments: + + Guid - Pointer to a GUID to print. + Buffer - Pointer to a user-provided buffer to print to + BufferLen - Size of the Buffer + Uppercase - If use upper case. + +Returns: + + EFI_SUCCESS The GUID was printed. + EFI_INVALID_PARAMETER The input was NULL. + EFI_BUFFER_TOO_SMALL The input buffer was not big enough + +--*/ +{ + if (Guid == NULL) { + printf ("ERROR: PrintGuidToBuffer() called with a NULL value\n"); + return EFI_INVALID_PARAMETER; + } + + if (BufferLen < PRINTED_GUID_BUFFER_SIZE) { + printf ("ERORR: PrintGuidToBuffer() called with invalid buffer size\n"); + return EFI_BUFFER_TOO_SMALL; + } + + if (Uppercase) { + sprintf ( + Buffer, + "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", + Guid->Data1, + Guid->Data2, + Guid->Data3, + Guid->Data4[0], + Guid->Data4[1], + Guid->Data4[2], + Guid->Data4[3], + Guid->Data4[4], + Guid->Data4[5], + Guid->Data4[6], + Guid->Data4[7] + ); + } else { + sprintf ( + Buffer, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + Guid->Data1, + Guid->Data2, + Guid->Data3, + Guid->Data4[0], + Guid->Data4[1], + Guid->Data4[2], + Guid->Data4[3], + Guid->Data4[4], + Guid->Data4[5], + Guid->Data4[6], + Guid->Data4[7] + ); + } + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.h new file mode 100644 index 0000000000..f36856e5fb --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/CommonLib.h @@ -0,0 +1,120 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CommonLib.h + +Abstract: + + Common library assistance routines. + +--*/ + +#ifndef _EFI_COMMON_LIB_H +#define _EFI_COMMON_LIB_H + +#include "TianoCommon.h" + +#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination +// +// Function declarations +// +VOID +PeiZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +; + +VOID +PeiCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +; + +VOID +ZeroMem ( + IN VOID *Buffer, + IN UINTN Size + ) +; + +VOID +CopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +; + +INTN +CompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +; + +EFI_STATUS +GetFileImage ( + IN CHAR8 *InputFileName, + OUT CHAR8 **InputFileImage, + OUT UINT32 *BytesRead + ) +; + +UINT8 +CalculateChecksum8 ( + IN UINT8 *Buffer, + IN UINTN Size + ) +; + +UINT8 +CalculateSum8 ( + IN UINT8 *Buffer, + IN UINTN Size + ) +; + +UINT16 +CalculateChecksum16 ( + IN UINT16 *Buffer, + IN UINTN Size + ) +; + +UINT16 +CalculateSum16 ( + IN UINT16 *Buffer, + IN UINTN Size + ) +; + +EFI_STATUS +PrintGuid ( + IN EFI_GUID *Guid + ) +; + +#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination +EFI_STATUS +PrintGuidToBuffer ( + IN EFI_GUID *Guid, + IN OUT UINT8 *Buffer, + IN UINT32 BufferLen, + IN BOOLEAN Uppercase + ) +; + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Compress.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Compress.h new file mode 100644 index 0000000000..43535936a6 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Compress.h @@ -0,0 +1,90 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Compress.h + +Abstract: + + Header file for compression routine. + Providing both EFI and Tiano Compress algorithms. + +--*/ + +#ifndef _COMPRESS_H_ +#define _COMPRESS_H_ + +/*++ + +Routine Description: + + Tiano compression routine. + +--*/ +EFI_STATUS +TianoCompress ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize + ) +; + +/*++ + +Routine Description: + + Efi compression routine. + +--*/ +EFI_STATUS +EfiCompress ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize + ) +; + +/*++ + +Routine Description: + + The compression routine. + +Arguments: + + SrcBuffer - The buffer storing the source data + SrcSize - The size of source data + DstBuffer - The buffer to store the compressed data + DstSize - On input, the size of DstBuffer; On output, + the size of the actual compressed data. + +Returns: + + EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case, + DstSize contains the size needed. + EFI_SUCCESS - Compression is successful. + EFI_OUT_OF_RESOURCES - No resource to complete function. + EFI_INVALID_PARAMETER - Parameter supplied is wrong. + +--*/ +typedef +EFI_STATUS +(*COMPRESS_FUNCTION) ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize + ); + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c new file mode 100644 index 0000000000..6239ccc31e --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c @@ -0,0 +1,327 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + crc32.c + +Abstract: + + CalcuateCrc32 routine. + +--*/ + +#include +#include "TianoCommon.h" +#include "crc32.h" + +UINT32 mCrcTable[256] = { + 0x00000000, + 0x77073096, + 0xEE0E612C, + 0x990951BA, + 0x076DC419, + 0x706AF48F, + 0xE963A535, + 0x9E6495A3, + 0x0EDB8832, + 0x79DCB8A4, + 0xE0D5E91E, + 0x97D2D988, + 0x09B64C2B, + 0x7EB17CBD, + 0xE7B82D07, + 0x90BF1D91, + 0x1DB71064, + 0x6AB020F2, + 0xF3B97148, + 0x84BE41DE, + 0x1ADAD47D, + 0x6DDDE4EB, + 0xF4D4B551, + 0x83D385C7, + 0x136C9856, + 0x646BA8C0, + 0xFD62F97A, + 0x8A65C9EC, + 0x14015C4F, + 0x63066CD9, + 0xFA0F3D63, + 0x8D080DF5, + 0x3B6E20C8, + 0x4C69105E, + 0xD56041E4, + 0xA2677172, + 0x3C03E4D1, + 0x4B04D447, + 0xD20D85FD, + 0xA50AB56B, + 0x35B5A8FA, + 0x42B2986C, + 0xDBBBC9D6, + 0xACBCF940, + 0x32D86CE3, + 0x45DF5C75, + 0xDCD60DCF, + 0xABD13D59, + 0x26D930AC, + 0x51DE003A, + 0xC8D75180, + 0xBFD06116, + 0x21B4F4B5, + 0x56B3C423, + 0xCFBA9599, + 0xB8BDA50F, + 0x2802B89E, + 0x5F058808, + 0xC60CD9B2, + 0xB10BE924, + 0x2F6F7C87, + 0x58684C11, + 0xC1611DAB, + 0xB6662D3D, + 0x76DC4190, + 0x01DB7106, + 0x98D220BC, + 0xEFD5102A, + 0x71B18589, + 0x06B6B51F, + 0x9FBFE4A5, + 0xE8B8D433, + 0x7807C9A2, + 0x0F00F934, + 0x9609A88E, + 0xE10E9818, + 0x7F6A0DBB, + 0x086D3D2D, + 0x91646C97, + 0xE6635C01, + 0x6B6B51F4, + 0x1C6C6162, + 0x856530D8, + 0xF262004E, + 0x6C0695ED, + 0x1B01A57B, + 0x8208F4C1, + 0xF50FC457, + 0x65B0D9C6, + 0x12B7E950, + 0x8BBEB8EA, + 0xFCB9887C, + 0x62DD1DDF, + 0x15DA2D49, + 0x8CD37CF3, + 0xFBD44C65, + 0x4DB26158, + 0x3AB551CE, + 0xA3BC0074, + 0xD4BB30E2, + 0x4ADFA541, + 0x3DD895D7, + 0xA4D1C46D, + 0xD3D6F4FB, + 0x4369E96A, + 0x346ED9FC, + 0xAD678846, + 0xDA60B8D0, + 0x44042D73, + 0x33031DE5, + 0xAA0A4C5F, + 0xDD0D7CC9, + 0x5005713C, + 0x270241AA, + 0xBE0B1010, + 0xC90C2086, + 0x5768B525, + 0x206F85B3, + 0xB966D409, + 0xCE61E49F, + 0x5EDEF90E, + 0x29D9C998, + 0xB0D09822, + 0xC7D7A8B4, + 0x59B33D17, + 0x2EB40D81, + 0xB7BD5C3B, + 0xC0BA6CAD, + 0xEDB88320, + 0x9ABFB3B6, + 0x03B6E20C, + 0x74B1D29A, + 0xEAD54739, + 0x9DD277AF, + 0x04DB2615, + 0x73DC1683, + 0xE3630B12, + 0x94643B84, + 0x0D6D6A3E, + 0x7A6A5AA8, + 0xE40ECF0B, + 0x9309FF9D, + 0x0A00AE27, + 0x7D079EB1, + 0xF00F9344, + 0x8708A3D2, + 0x1E01F268, + 0x6906C2FE, + 0xF762575D, + 0x806567CB, + 0x196C3671, + 0x6E6B06E7, + 0xFED41B76, + 0x89D32BE0, + 0x10DA7A5A, + 0x67DD4ACC, + 0xF9B9DF6F, + 0x8EBEEFF9, + 0x17B7BE43, + 0x60B08ED5, + 0xD6D6A3E8, + 0xA1D1937E, + 0x38D8C2C4, + 0x4FDFF252, + 0xD1BB67F1, + 0xA6BC5767, + 0x3FB506DD, + 0x48B2364B, + 0xD80D2BDA, + 0xAF0A1B4C, + 0x36034AF6, + 0x41047A60, + 0xDF60EFC3, + 0xA867DF55, + 0x316E8EEF, + 0x4669BE79, + 0xCB61B38C, + 0xBC66831A, + 0x256FD2A0, + 0x5268E236, + 0xCC0C7795, + 0xBB0B4703, + 0x220216B9, + 0x5505262F, + 0xC5BA3BBE, + 0xB2BD0B28, + 0x2BB45A92, + 0x5CB36A04, + 0xC2D7FFA7, + 0xB5D0CF31, + 0x2CD99E8B, + 0x5BDEAE1D, + 0x9B64C2B0, + 0xEC63F226, + 0x756AA39C, + 0x026D930A, + 0x9C0906A9, + 0xEB0E363F, + 0x72076785, + 0x05005713, + 0x95BF4A82, + 0xE2B87A14, + 0x7BB12BAE, + 0x0CB61B38, + 0x92D28E9B, + 0xE5D5BE0D, + 0x7CDCEFB7, + 0x0BDBDF21, + 0x86D3D2D4, + 0xF1D4E242, + 0x68DDB3F8, + 0x1FDA836E, + 0x81BE16CD, + 0xF6B9265B, + 0x6FB077E1, + 0x18B74777, + 0x88085AE6, + 0xFF0F6A70, + 0x66063BCA, + 0x11010B5C, + 0x8F659EFF, + 0xF862AE69, + 0x616BFFD3, + 0x166CCF45, + 0xA00AE278, + 0xD70DD2EE, + 0x4E048354, + 0x3903B3C2, + 0xA7672661, + 0xD06016F7, + 0x4969474D, + 0x3E6E77DB, + 0xAED16A4A, + 0xD9D65ADC, + 0x40DF0B66, + 0x37D83BF0, + 0xA9BCAE53, + 0xDEBB9EC5, + 0x47B2CF7F, + 0x30B5FFE9, + 0xBDBDF21C, + 0xCABAC28A, + 0x53B39330, + 0x24B4A3A6, + 0xBAD03605, + 0xCDD70693, + 0x54DE5729, + 0x23D967BF, + 0xB3667A2E, + 0xC4614AB8, + 0x5D681B02, + 0x2A6F2B94, + 0xB40BBE37, + 0xC30C8EA1, + 0x5A05DF1B, + 0x2D02EF8D +}; + +EFI_STATUS +CalculateCrc32 ( + IN UINT8 *Data, + IN UINTN DataSize, + IN OUT UINT32 *CrcOut + ) +/*++ + +Routine Description: + + The CalculateCrc32 routine. + +Arguments: + + Data - The buffer contaning the data to be processed + DataSize - The size of data to be processed + CrcOut - A pointer to the caller allocated UINT32 that on + contains the CRC32 checksum of Data + +Returns: + + EFI_SUCCESS - Calculation is successful. + EFI_INVALID_PARAMETER - Data / CrcOut = NULL, or DataSize = 0 + +--*/ +{ + UINT32 Crc; + UINTN Index; + UINT8 *Ptr; + + if ((DataSize == 0) || (Data == NULL) || (CrcOut == NULL)) { + return EFI_INVALID_PARAMETER; + } + + Crc = 0xffffffff; + for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) { + Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr]; + } + + *CrcOut = Crc ^ 0xffffffff; + + return EFI_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.h new file mode 100644 index 0000000000..51e98757a1 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.h @@ -0,0 +1,51 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + crc32.h + +Abstract: + + Header file for CalcuateCrc32 routine + +--*/ + +#ifndef _CRC32_H +#define _CRC32_H +EFI_STATUS +CalculateCrc32 ( + IN UINT8 *Data, + IN UINTN DataSize, + IN OUT UINT32 *CrcOut + ) +; + +/*++ + +Routine Description: + + The CalculateCrc32 routine. + +Arguments: + + Data - The buffer contaning the data to be processed + DataSize - The size of data to be processed + CrcOut - A pointer to the caller allocated UINT32 that on + contains the CRC32 checksum of Data + +Returns: + + EFI_SUCCESS - Calculation is successful. + EFI_INVALID_PARAMETER - Data / CrcOut = NULL, or DataSize = 0 + +--*/ +#endif \ No newline at end of file diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.c new file mode 100644 index 0000000000..8afabae7d6 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.c @@ -0,0 +1,995 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Decompress.c + +Abstract: + + Decompressor. Algorithm Ported from OPSD code (Decomp.asm) + +--*/ + +#include "TianoCommon.h" + + +// +// Decompression algorithm begins here +// +#define BITBUFSIZ 32 +#define MAXMATCH 256 +#define THRESHOLD 3 +#define CODE_BIT 16 +#define UINT8_MAX 0xff +#define BAD_TABLE - 1 + +// +// C: Char&Len Set; P: Position Set; T: exTra Set +// +#define NC (0xff + MAXMATCH + 2 - THRESHOLD) +#define CBIT 9 +#define MAXPBIT 5 +#define TBIT 5 +#define MAXNP ((1U << MAXPBIT) - 1) +#define NT (CODE_BIT + 3) +#if NT > MAXNP +#define NPT NT +#else +#define NPT MAXNP +#endif + +typedef struct { + UINT8 *mSrcBase; // Starting address of compressed data + UINT8 *mDstBase; // Starting address of decompressed data + UINT32 mOutBuf; + UINT32 mInBuf; + + UINT16 mBitCount; + UINT32 mBitBuf; + UINT32 mSubBitBuf; + UINT16 mBlockSize; + UINT32 mCompSize; + UINT32 mOrigSize; + + UINT16 mBadTableFlag; + + UINT16 mLeft[2 * NC - 1]; + UINT16 mRight[2 * NC - 1]; + UINT8 mCLen[NC]; + UINT8 mPTLen[NPT]; + UINT16 mCTable[4096]; + UINT16 mPTTable[256]; + + // + // The length of the field 'Position Set Code Length Array Size' in Block Header. + // For EFI 1.1 de/compression algorithm, mPBit = 4 + // For Tiano de/compression algorithm, mPBit = 5 + // + UINT8 mPBit; +} SCRATCH_DATA; + +STATIC +VOID +FillBuf ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +/*++ + +Routine Description: + + Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. + +Arguments: + + Sd - The global scratch data + NumOfBits - The number of bits to shift and read. + +Returns: (VOID) + +--*/ +{ + Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits); + + while (NumOfBits > Sd->mBitCount) { + + Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount))); + + if (Sd->mCompSize > 0) { + // + // Get 1 byte into SubBitBuf + // + Sd->mCompSize--; + Sd->mSubBitBuf = 0; + Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; + Sd->mBitCount = 8; + + } else { + // + // No more bits from the source, just pad zero bit. + // + Sd->mSubBitBuf = 0; + Sd->mBitCount = 8; + + } + } + + Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits); + Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount; +} + +STATIC +UINT32 +GetBits ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfBits + ) +/*++ + +Routine Description: + + Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent + NumOfBits of bits from source. Returns NumOfBits of bits that are + popped out. + +Arguments: + + Sd - The global scratch data. + NumOfBits - The number of bits to pop and read. + +Returns: + + The bits that are popped out. + +--*/ +{ + UINT32 OutBits; + + OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits)); + + FillBuf (Sd, NumOfBits); + + return OutBits; +} + +STATIC +UINT16 +MakeTable ( + IN SCRATCH_DATA *Sd, + IN UINT16 NumOfChar, + IN UINT8 *BitLen, + IN UINT16 TableBits, + OUT UINT16 *Table + ) +/*++ + +Routine Description: + + Creates Huffman Code mapping table according to code length array. + +Arguments: + + Sd - The global scratch data + NumOfChar - Number of symbols in the symbol set + BitLen - Code length array + TableBits - The width of the mapping table + Table - The table + +Returns: + + 0 - OK. + BAD_TABLE - The table is corrupted. + +--*/ +{ + UINT16 Count[17]; + UINT16 Weight[17]; + UINT16 Start[18]; + UINT16 *Pointer; + UINT16 Index3; + UINT16 Index; + UINT16 Len; + UINT16 Char; + UINT16 JuBits; + UINT16 Avail; + UINT16 NextCode; + UINT16 Mask; + + for (Index = 1; Index <= 16; Index++) { + Count[Index] = 0; + } + + for (Index = 0; Index < NumOfChar; Index++) { + Count[BitLen[Index]]++; + } + + Start[1] = 0; + + for (Index = 1; Index <= 16; Index++) { + Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index))); + } + + if (Start[17] != 0) { + /*(1U << 16)*/ + return (UINT16) BAD_TABLE; + } + + JuBits = (UINT16) (16 - TableBits); + + for (Index = 1; Index <= TableBits; Index++) { + Start[Index] >>= JuBits; + Weight[Index] = (UINT16) (1U << (TableBits - Index)); + } + + while (Index <= 16) { + Weight[Index++] = (UINT16) (1U << (16 - Index)); + } + + Index = (UINT16) (Start[TableBits + 1] >> JuBits); + + if (Index != 0) { + Index3 = (UINT16) (1U << TableBits); + while (Index != Index3) { + Table[Index++] = 0; + } + } + + Avail = NumOfChar; + Mask = (UINT16) (1U << (15 - TableBits)); + + for (Char = 0; Char < NumOfChar; Char++) { + + Len = BitLen[Char]; + if (Len == 0) { + continue; + } + + NextCode = (UINT16) (Start[Len] + Weight[Len]); + + if (Len <= TableBits) { + + for (Index = Start[Len]; Index < NextCode; Index++) { + Table[Index] = Char; + } + + } else { + + Index3 = Start[Len]; + Pointer = &Table[Index3 >> JuBits]; + Index = (UINT16) (Len - TableBits); + + while (Index != 0) { + if (*Pointer == 0) { + Sd->mRight[Avail] = Sd->mLeft[Avail] = 0; + *Pointer = Avail++; + } + + if (Index3 & Mask) { + Pointer = &Sd->mRight[*Pointer]; + } else { + Pointer = &Sd->mLeft[*Pointer]; + } + + Index3 <<= 1; + Index--; + } + + *Pointer = Char; + + } + + Start[Len] = NextCode; + } + // + // Succeeds + // + return 0; +} + +STATIC +UINT32 +DecodeP ( + IN SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Decodes a position value. + +Arguments: + + Sd - the global scratch data + +Returns: + + The position value decoded. + +--*/ +{ + UINT16 Val; + UINT32 Mask; + UINT32 Pos; + + Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + + if (Val >= MAXNP) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Sd->mBitBuf & Mask) { + Val = Sd->mRight[Val]; + } else { + Val = Sd->mLeft[Val]; + } + + Mask >>= 1; + } while (Val >= MAXNP); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[Val]); + + Pos = Val; + if (Val > 1) { + Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1))); + } + + return Pos; +} + +STATIC +UINT16 +ReadPTLen ( + IN SCRATCH_DATA *Sd, + IN UINT16 nn, + IN UINT16 nbit, + IN UINT16 Special + ) +/*++ + +Routine Description: + + Reads code lengths for the Extra Set or the Position Set + +Arguments: + + Sd - The global scratch data + nn - Number of symbols + nbit - Number of bits needed to represent nn + Special - The special symbol that needs to be taken care of + +Returns: + + 0 - OK. + BAD_TABLE - Table is corrupted. + +--*/ +{ + UINT16 Number; + UINT16 CharC; + UINT16 Index; + UINT32 Mask; + + Number = (UINT16) GetBits (Sd, nbit); + + if (Number == 0) { + CharC = (UINT16) GetBits (Sd, nbit); + + for (Index = 0; Index < 256; Index++) { + Sd->mPTTable[Index] = CharC; + } + + for (Index = 0; Index < nn; Index++) { + Sd->mPTLen[Index] = 0; + } + + return 0; + } + + Index = 0; + + while (Index < Number) { + + CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3)); + + if (CharC == 7) { + Mask = 1U << (BITBUFSIZ - 1 - 3); + while (Mask & Sd->mBitBuf) { + Mask >>= 1; + CharC += 1; + } + } + + FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3)); + + Sd->mPTLen[Index++] = (UINT8) CharC; + + if (Index == Special) { + CharC = (UINT16) GetBits (Sd, 2); + while ((INT16) (--CharC) >= 0) { + Sd->mPTLen[Index++] = 0; + } + } + } + + while (Index < nn) { + Sd->mPTLen[Index++] = 0; + } + + return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable); +} + +STATIC +VOID +ReadCLen ( + SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Reads code lengths for Char&Len Set. + +Arguments: + + Sd - the global scratch data + +Returns: (VOID) + +--*/ +{ + UINT16 Number; + UINT16 CharC; + UINT16 Index; + UINT32 Mask; + + Number = (UINT16) GetBits (Sd, CBIT); + + if (Number == 0) { + CharC = (UINT16) GetBits (Sd, CBIT); + + for (Index = 0; Index < NC; Index++) { + Sd->mCLen[Index] = 0; + } + + for (Index = 0; Index < 4096; Index++) { + Sd->mCTable[Index] = CharC; + } + + return ; + } + + Index = 0; + while (Index < Number) { + + CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; + if (CharC >= NT) { + Mask = 1U << (BITBUFSIZ - 1 - 8); + + do { + + if (Mask & Sd->mBitBuf) { + CharC = Sd->mRight[CharC]; + } else { + CharC = Sd->mLeft[CharC]; + } + + Mask >>= 1; + + } while (CharC >= NT); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mPTLen[CharC]); + + if (CharC <= 2) { + + if (CharC == 0) { + CharC = 1; + } else if (CharC == 1) { + CharC = (UINT16) (GetBits (Sd, 4) + 3); + } else if (CharC == 2) { + CharC = (UINT16) (GetBits (Sd, CBIT) + 20); + } + + while ((INT16) (--CharC) >= 0) { + Sd->mCLen[Index++] = 0; + } + + } else { + + Sd->mCLen[Index++] = (UINT8) (CharC - 2); + + } + } + + while (Index < NC) { + Sd->mCLen[Index++] = 0; + } + + MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable); + + return ; +} + +STATIC +UINT16 +DecodeC ( + SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Decode a character/length value. + +Arguments: + + Sd - The global scratch data. + +Returns: + + The value decoded. + +--*/ +{ + UINT16 Index2; + UINT32 Mask; + + if (Sd->mBlockSize == 0) { + // + // Starting a new block + // + Sd->mBlockSize = (UINT16) GetBits (Sd, 16); + Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3); + if (Sd->mBadTableFlag != 0) { + return 0; + } + + ReadCLen (Sd); + + Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1)); + if (Sd->mBadTableFlag != 0) { + return 0; + } + } + + Sd->mBlockSize--; + Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)]; + + if (Index2 >= NC) { + Mask = 1U << (BITBUFSIZ - 1 - 12); + + do { + if (Sd->mBitBuf & Mask) { + Index2 = Sd->mRight[Index2]; + } else { + Index2 = Sd->mLeft[Index2]; + } + + Mask >>= 1; + } while (Index2 >= NC); + } + // + // Advance what we have read + // + FillBuf (Sd, Sd->mCLen[Index2]); + + return Index2; +} + +STATIC +VOID +Decode ( + SCRATCH_DATA *Sd + ) +/*++ + +Routine Description: + + Decode the source data and put the resulting data into the destination buffer. + +Arguments: + + Sd - The global scratch data + +Returns: (VOID) + + --*/ +{ + UINT16 BytesRemain; + UINT32 DataIdx; + UINT16 CharC; + + BytesRemain = (UINT16) (-1); + + DataIdx = 0; + + for (;;) { + CharC = DecodeC (Sd); + if (Sd->mBadTableFlag != 0) { + return ; + } + + if (CharC < 256) { + // + // Process an Original character + // + if (Sd->mOutBuf >= Sd->mOrigSize) { + return ; + } else { + Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC; + } + + } else { + // + // Process a Pointer + // + CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD)); + + BytesRemain = CharC; + + DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1; + + BytesRemain--; + while ((INT16) (BytesRemain) >= 0) { + Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++]; + if (Sd->mOutBuf >= Sd->mOrigSize) { + return ; + } + + BytesRemain--; + } + } + } + + return ; +} + +EFI_STATUS +GetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + UINT8 *Src; + + *ScratchSize = sizeof (SCRATCH_DATA); + + Src = Source; + if (SrcSize < 8) { + return EFI_INVALID_PARAMETER; + } + + *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); + return EFI_SUCCESS; +} + +EFI_STATUS +Decompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize, + IN UINT8 Version + ) +/*++ + +Routine Description: + + The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + Version - The version of de/compression algorithm. + Version 1 for EFI 1.1 de/compression algorithm. + Version 2 for Tiano de/compression algorithm. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + UINT32 Index; + UINT32 CompSize; + UINT32 OrigSize; + EFI_STATUS Status; + SCRATCH_DATA *Sd; + UINT8 *Src; + UINT8 *Dst; + + Status = EFI_SUCCESS; + Src = Source; + Dst = Destination; + + if (ScratchSize < sizeof (SCRATCH_DATA)) { + return EFI_INVALID_PARAMETER; + } + + Sd = (SCRATCH_DATA *) Scratch; + + if (SrcSize < 8) { + return EFI_INVALID_PARAMETER; + } + + CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24); + OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); + + // + // If compressed file size is 0, return + // + if (OrigSize == 0) { + return Status; + } + + if (SrcSize < CompSize + 8) { + return EFI_INVALID_PARAMETER; + } + + if (DstSize != OrigSize) { + return EFI_INVALID_PARAMETER; + } + + Src = Src + 8; + + for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) { + ((UINT8 *) Sd)[Index] = 0; + } + // + // The length of the field 'Position Set Code Length Array Size' in Block Header. + // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4 + // For Tiano de/compression algorithm(Version 2), mPBit = 5 + // + switch (Version) { + case 1: + Sd->mPBit = 4; + break; + + case 2: + Sd->mPBit = 5; + break; + + default: + // + // Currently, only have 2 versions + // + return EFI_INVALID_PARAMETER; + } + + Sd->mSrcBase = Src; + Sd->mDstBase = Dst; + Sd->mCompSize = CompSize; + Sd->mOrigSize = OrigSize; + + // + // Fill the first BITBUFSIZ bits + // + FillBuf (Sd, BITBUFSIZ); + + // + // Decompress it + // + Decode (Sd); + + if (Sd->mBadTableFlag != 0) { + // + // Something wrong with the source + // + Status = EFI_INVALID_PARAMETER; + } + + return Status; +} + +EFI_STATUS +EFIAPI +EfiGetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + return GetInfo ( + Source, + SrcSize, + DstSize, + ScratchSize + ); +} + +EFI_STATUS +EFIAPI +EfiDecompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + // + // For EFI 1.1 de/compression algorithm, the version is 1. + // + return Decompress ( + Source, + SrcSize, + Destination, + DstSize, + Scratch, + ScratchSize, + 1 + ); +} + +EFI_STATUS +EFIAPI +TianoGetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + return GetInfo ( + Source, + SrcSize, + DstSize, + ScratchSize + ); +} + +EFI_STATUS +EFIAPI +TianoDecompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +{ + // + // For Tiano de/compression algorithm, the version is 2. + // + return Decompress ( + Source, + SrcSize, + Destination, + DstSize, + Scratch, + ScratchSize, + 2 + ); +} + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.h new file mode 100644 index 0000000000..515e7fdbed --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Decompress.h @@ -0,0 +1,174 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Decompress.h + +Abstract: + + Header file for decompression routine. + Providing both EFI and Tiano decompress algorithms. + +--*/ + +#ifndef _DECOMPRESS_H_ +#define _DECOMPRESS_H_ + +EFI_STATUS +EFIAPI +EfiGetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +; + +EFI_STATUS +EFIAPI +EfiDecompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +; + +EFI_STATUS +EFIAPI +TianoGetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +; + +EFI_STATUS +EFIAPI +TianoDecompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +; + +typedef +EFI_STATUS +(*GETINFO_FUNCTION) ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ); + +typedef +EFI_STATUS +(*DECOMPRESS_FUNCTION) ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ); + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCompress.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCompress.c new file mode 100644 index 0000000000..6f2922ea3d --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCompress.c @@ -0,0 +1,1600 @@ +/* + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCompress.c + +Abstract: + + Compression routine. The compression algorithm is a mixture of + LZ77 and Huffman coding. LZ77 transforms the source data into a + sequence of Original Characters and Pointers to repeated strings. + This sequence is further divided into Blocks and Huffman codings + are applied to each Block. + +--*/ + +#include +#include +#include "TianoCommon.h" +#include "Compress.h" + + +// +// Macro Definitions +// + +typedef INT16 NODE; +#define UINT8_MAX 0xff +#define UINT8_BIT 8 +#define THRESHOLD 3 +#define INIT_CRC 0 +#define WNDBIT 13 +#define WNDSIZ (1U << WNDBIT) +#define MAXMATCH 256 +#define PERC_FLAG 0x8000U +#define CODE_BIT 16 +#define NIL 0 +#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX) +#define HASH(p, c) ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2) +#define CRCPOLY 0xA001 +#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT) + +// +// C: the Char&Len Set; P: the Position Set; T: the exTra Set +// + +#define NC (UINT8_MAX + MAXMATCH + 2 - THRESHOLD) +#define CBIT 9 +#define NP (WNDBIT + 1) +#define PBIT 4 +#define NT (CODE_BIT + 3) +#define TBIT 5 +#if NT > NP + #define NPT NT +#else + #define NPT NP +#endif + +// +// Function Prototypes +// + +STATIC +VOID +PutDword( + IN UINT32 Data + ); + +STATIC +EFI_STATUS +AllocateMemory ( + ); + +STATIC +VOID +FreeMemory ( + ); + +STATIC +VOID +InitSlide ( + ); + +STATIC +NODE +Child ( + IN NODE q, + IN UINT8 c + ); + +STATIC +VOID +MakeChild ( + IN NODE q, + IN UINT8 c, + IN NODE r + ); + +STATIC +VOID +Split ( + IN NODE Old + ); + +STATIC +VOID +InsertNode ( + ); + +STATIC +VOID +DeleteNode ( + ); + +STATIC +VOID +GetNextMatch ( + ); + +STATIC +EFI_STATUS +Encode ( + ); + +STATIC +VOID +CountTFreq ( + ); + +STATIC +VOID +WritePTLen ( + IN INT32 n, + IN INT32 nbit, + IN INT32 Special + ); + +STATIC +VOID +WriteCLen ( + ); + +STATIC +VOID +EncodeC ( + IN INT32 c + ); + +STATIC +VOID +EncodeP ( + IN UINT32 p + ); + +STATIC +VOID +SendBlock ( + ); + +STATIC +VOID +Output ( + IN UINT32 c, + IN UINT32 p + ); + +STATIC +VOID +HufEncodeStart ( + ); + +STATIC +VOID +HufEncodeEnd ( + ); + +STATIC +VOID +MakeCrcTable ( + ); + +STATIC +VOID +PutBits ( + IN INT32 n, + IN UINT32 x + ); + +STATIC +INT32 +FreadCrc ( + OUT UINT8 *p, + IN INT32 n + ); + +STATIC +VOID +InitPutBits ( + ); + +STATIC +VOID +CountLen ( + IN INT32 i + ); + +STATIC +VOID +MakeLen ( + IN INT32 Root + ); + +STATIC +VOID +DownHeap ( + IN INT32 i + ); + +STATIC +VOID +MakeCode ( + IN INT32 n, + IN UINT8 Len[], + OUT UINT16 Code[] + ); + +STATIC +INT32 +MakeTree ( + IN INT32 NParm, + IN UINT16 FreqParm[], + OUT UINT8 LenParm[], + OUT UINT16 CodeParm[] + ); + + +// +// Global Variables +// + +STATIC UINT8 *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit; + +STATIC UINT8 *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen; +STATIC INT16 mHeap[NC + 1]; +STATIC INT32 mRemainder, mMatchLen, mBitCount, mHeapSize, mN; +STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc; +STATIC UINT32 mCompSize, mOrigSize; + +STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], + mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC], + mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1]; + +STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL; + + +// +// functions +// + +EFI_STATUS +EfiCompress ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize + ) +/*++ + +Routine Description: + + The main compression routine. + +Arguments: + + SrcBuffer - The buffer storing the source data + SrcSize - The size of source data + DstBuffer - The buffer to store the compressed data + DstSize - On input, the size of DstBuffer; On output, + the size of the actual compressed data. + +Returns: + + EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case, + DstSize contains the size needed. + EFI_SUCCESS - Compression is successful. + +--*/ +{ + EFI_STATUS Status = EFI_SUCCESS; + + // + // Initializations + // + mBufSiz = 0; + mBuf = NULL; + mText = NULL; + mLevel = NULL; + mChildCount = NULL; + mPosition = NULL; + mParent = NULL; + mPrev = NULL; + mNext = NULL; + + + mSrc = SrcBuffer; + mSrcUpperLimit = mSrc + SrcSize; + mDst = DstBuffer; + mDstUpperLimit = mDst + *DstSize; + + PutDword(0L); + PutDword(0L); + + MakeCrcTable (); + + mOrigSize = mCompSize = 0; + mCrc = INIT_CRC; + + // + // Compress it + // + + Status = Encode(); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Null terminate the compressed data + // + if (mDst < mDstUpperLimit) { + *mDst++ = 0; + } + + // + // Fill in compressed size and original size + // + mDst = DstBuffer; + PutDword(mCompSize+1); + PutDword(mOrigSize); + + // + // Return + // + + if (mCompSize + 1 + 8 > *DstSize) { + *DstSize = mCompSize + 1 + 8; + return EFI_BUFFER_TOO_SMALL; + } else { + *DstSize = mCompSize + 1 + 8; + return EFI_SUCCESS; + } + +} + +STATIC +VOID +PutDword( + IN UINT32 Data + ) +/*++ + +Routine Description: + + Put a dword to output stream + +Arguments: + + Data - the dword to put + +Returns: (VOID) + +--*/ +{ + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8)(((UINT8)(Data )) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8)(((UINT8)(Data >> 0x08)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8)(((UINT8)(Data >> 0x10)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8)(((UINT8)(Data >> 0x18)) & 0xff); + } +} + +STATIC +EFI_STATUS +AllocateMemory () +/*++ + +Routine Description: + + Allocate memory spaces for data structures used in compression process + +Argements: (VOID) + +Returns: + + EFI_SUCCESS - Memory is allocated successfully + EFI_OUT_OF_RESOURCES - Allocation fails + +--*/ +{ + UINT32 i; + + mText = malloc (WNDSIZ * 2 + MAXMATCH); + for (i = 0 ; i < WNDSIZ * 2 + MAXMATCH; i ++) { + mText[i] = 0; + } + + mLevel = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mLevel)); + mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mChildCount)); + mPosition = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mPosition)); + mParent = malloc (WNDSIZ * 2 * sizeof(*mParent)); + mPrev = malloc (WNDSIZ * 2 * sizeof(*mPrev)); + mNext = malloc ((MAX_HASH_VAL + 1) * sizeof(*mNext)); + + mBufSiz = 16 * 1024U; + while ((mBuf = malloc(mBufSiz)) == NULL) { + mBufSiz = (mBufSiz / 10U) * 9U; + if (mBufSiz < 4 * 1024U) { + return EFI_OUT_OF_RESOURCES; + } + } + mBuf[0] = 0; + + return EFI_SUCCESS; +} + +VOID +FreeMemory () +/*++ + +Routine Description: + + Called when compression is completed to free memory previously allocated. + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + if (mText) { + free (mText); + } + + if (mLevel) { + free (mLevel); + } + + if (mChildCount) { + free (mChildCount); + } + + if (mPosition) { + free (mPosition); + } + + if (mParent) { + free (mParent); + } + + if (mPrev) { + free (mPrev); + } + + if (mNext) { + free (mNext); + } + + if (mBuf) { + free (mBuf); + } + + return; +} + + +STATIC +VOID +InitSlide () +/*++ + +Routine Description: + + Initialize String Info Log data structures + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + NODE i; + + for (i = WNDSIZ; i <= WNDSIZ + UINT8_MAX; i++) { + mLevel[i] = 1; + mPosition[i] = NIL; /* sentinel */ + } + for (i = WNDSIZ; i < WNDSIZ * 2; i++) { + mParent[i] = NIL; + } + mAvail = 1; + for (i = 1; i < WNDSIZ - 1; i++) { + mNext[i] = (NODE)(i + 1); + } + + mNext[WNDSIZ - 1] = NIL; + for (i = WNDSIZ * 2; i <= MAX_HASH_VAL; i++) { + mNext[i] = NIL; + } +} + + +STATIC +NODE +Child ( + IN NODE q, + IN UINT8 c + ) +/*++ + +Routine Description: + + Find child node given the parent node and the edge character + +Arguments: + + q - the parent node + c - the edge character + +Returns: + + The child node (NIL if not found) + +--*/ +{ + NODE r; + + r = mNext[HASH(q, c)]; + mParent[NIL] = q; /* sentinel */ + while (mParent[r] != q) { + r = mNext[r]; + } + + return r; +} + +STATIC +VOID +MakeChild ( + IN NODE q, + IN UINT8 c, + IN NODE r + ) +/*++ + +Routine Description: + + Create a new child for a given parent node. + +Arguments: + + q - the parent node + c - the edge character + r - the child node + +Returns: (VOID) + +--*/ +{ + NODE h, t; + + h = (NODE)HASH(q, c); + t = mNext[h]; + mNext[h] = r; + mNext[r] = t; + mPrev[t] = r; + mPrev[r] = h; + mParent[r] = q; + mChildCount[q]++; +} + +STATIC +VOID +Split ( + NODE Old + ) +/*++ + +Routine Description: + + Split a node. + +Arguments: + + Old - the node to split + +Returns: (VOID) + +--*/ +{ + NODE New, t; + + New = mAvail; + mAvail = mNext[New]; + mChildCount[New] = 0; + t = mPrev[Old]; + mPrev[New] = t; + mNext[t] = New; + t = mNext[Old]; + mNext[New] = t; + mPrev[t] = New; + mParent[New] = mParent[Old]; + mLevel[New] = (UINT8)mMatchLen; + mPosition[New] = mPos; + MakeChild(New, mText[mMatchPos + mMatchLen], Old); + MakeChild(New, mText[mPos + mMatchLen], mPos); +} + +STATIC +VOID +InsertNode () +/*++ + +Routine Description: + + Insert string info for current position into the String Info Log + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + NODE q, r, j, t; + UINT8 c, *t1, *t2; + + if (mMatchLen >= 4) { + + // + // We have just got a long match, the target tree + // can be located by MatchPos + 1. Travese the tree + // from bottom up to get to a proper starting point. + // The usage of PERC_FLAG ensures proper node deletion + // in DeleteNode() later. + // + + mMatchLen--; + r = (INT16)((mMatchPos + 1) | WNDSIZ); + while ((q = mParent[r]) == NIL) { + r = mNext[r]; + } + while (mLevel[q] >= mMatchLen) { + r = q; q = mParent[q]; + } + t = q; + while (mPosition[t] < 0) { + mPosition[t] = mPos; + t = mParent[t]; + } + if (t < WNDSIZ) { + mPosition[t] = (NODE)(mPos | PERC_FLAG); + } + } else { + + // + // Locate the target tree + // + + q = (INT16)(mText[mPos] + WNDSIZ); + c = mText[mPos + 1]; + if ((r = Child(q, c)) == NIL) { + MakeChild(q, c, mPos); + mMatchLen = 1; + return; + } + mMatchLen = 2; + } + + // + // Traverse down the tree to find a match. + // Update Position value along the route. + // Node split or creation is involved. + // + + for ( ; ; ) { + if (r >= WNDSIZ) { + j = MAXMATCH; + mMatchPos = r; + } else { + j = mLevel[r]; + mMatchPos = (NODE)(mPosition[r] & ~PERC_FLAG); + } + if (mMatchPos >= mPos) { + mMatchPos -= WNDSIZ; + } + t1 = &mText[mPos + mMatchLen]; + t2 = &mText[mMatchPos + mMatchLen]; + while (mMatchLen < j) { + if (*t1 != *t2) { + Split(r); + return; + } + mMatchLen++; + t1++; + t2++; + } + if (mMatchLen >= MAXMATCH) { + break; + } + mPosition[r] = mPos; + q = r; + if ((r = Child(q, *t1)) == NIL) { + MakeChild(q, *t1, mPos); + return; + } + mMatchLen++; + } + t = mPrev[r]; + mPrev[mPos] = t; + mNext[t] = mPos; + t = mNext[r]; + mNext[mPos] = t; + mPrev[t] = mPos; + mParent[mPos] = q; + mParent[r] = NIL; + + // + // Special usage of 'next' + // + mNext[r] = mPos; + +} + +STATIC +VOID +DeleteNode () +/*++ + +Routine Description: + + Delete outdated string info. (The Usage of PERC_FLAG + ensures a clean deletion) + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + NODE q, r, s, t, u; + + if (mParent[mPos] == NIL) { + return; + } + + r = mPrev[mPos]; + s = mNext[mPos]; + mNext[r] = s; + mPrev[s] = r; + r = mParent[mPos]; + mParent[mPos] = NIL; + if (r >= WNDSIZ || --mChildCount[r] > 1) { + return; + } + t = (NODE)(mPosition[r] & ~PERC_FLAG); + if (t >= mPos) { + t -= WNDSIZ; + } + s = t; + q = mParent[r]; + while ((u = mPosition[q]) & PERC_FLAG) { + u &= ~PERC_FLAG; + if (u >= mPos) { + u -= WNDSIZ; + } + if (u > s) { + s = u; + } + mPosition[q] = (INT16)(s | WNDSIZ); + q = mParent[q]; + } + if (q < WNDSIZ) { + if (u >= mPos) { + u -= WNDSIZ; + } + if (u > s) { + s = u; + } + mPosition[q] = (INT16)(s | WNDSIZ | PERC_FLAG); + } + s = Child(r, mText[t + mLevel[r]]); + t = mPrev[s]; + u = mNext[s]; + mNext[t] = u; + mPrev[u] = t; + t = mPrev[r]; + mNext[t] = s; + mPrev[s] = t; + t = mNext[r]; + mPrev[t] = s; + mNext[s] = t; + mParent[s] = mParent[r]; + mParent[r] = NIL; + mNext[r] = mAvail; + mAvail = r; +} + +STATIC +VOID +GetNextMatch () +/*++ + +Routine Description: + + Advance the current position (read in new data if needed). + Delete outdated string info. Find a match string for current position. + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + INT32 n; + + mRemainder--; + if (++mPos == WNDSIZ * 2) { + memmove(&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH); + n = FreadCrc(&mText[WNDSIZ + MAXMATCH], WNDSIZ); + mRemainder += n; + mPos = WNDSIZ; + } + DeleteNode(); + InsertNode(); +} + +STATIC +EFI_STATUS +Encode () +/*++ + +Routine Description: + + The main controlling routine for compression process. + +Arguments: (VOID) + +Returns: + + EFI_SUCCESS - The compression is successful + EFI_OUT_0F_RESOURCES - Not enough memory for compression process + +--*/ +{ + EFI_STATUS Status; + INT32 LastMatchLen; + NODE LastMatchPos; + + Status = AllocateMemory(); + if (EFI_ERROR(Status)) { + FreeMemory(); + return Status; + } + + InitSlide(); + + HufEncodeStart(); + + mRemainder = FreadCrc(&mText[WNDSIZ], WNDSIZ + MAXMATCH); + + mMatchLen = 0; + mPos = WNDSIZ; + InsertNode(); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + while (mRemainder > 0) { + LastMatchLen = mMatchLen; + LastMatchPos = mMatchPos; + GetNextMatch(); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + + if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) { + + // + // Not enough benefits are gained by outputting a pointer, + // so just output the original character + // + + Output(mText[mPos - 1], 0); + } else { + + // + // Outputting a pointer is beneficial enough, do it. + // + + Output(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD), + (mPos - LastMatchPos - 2) & (WNDSIZ - 1)); + while (--LastMatchLen > 0) { + GetNextMatch(); + } + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + } + } + + HufEncodeEnd(); + FreeMemory(); + return EFI_SUCCESS; +} + +STATIC +VOID +CountTFreq () +/*++ + +Routine Description: + + Count the frequencies for the Extra Set + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + INT32 i, k, n, Count; + + for (i = 0; i < NT; i++) { + mTFreq[i] = 0; + } + n = NC; + while (n > 0 && mCLen[n - 1] == 0) { + n--; + } + i = 0; + while (i < n) { + k = mCLen[i++]; + if (k == 0) { + Count = 1; + while (i < n && mCLen[i] == 0) { + i++; + Count++; + } + if (Count <= 2) { + mTFreq[0] = (UINT16)(mTFreq[0] + Count); + } else if (Count <= 18) { + mTFreq[1]++; + } else if (Count == 19) { + mTFreq[0]++; + mTFreq[1]++; + } else { + mTFreq[2]++; + } + } else { + mTFreq[k + 2]++; + } + } +} + +STATIC +VOID +WritePTLen ( + IN INT32 n, + IN INT32 nbit, + IN INT32 Special + ) +/*++ + +Routine Description: + + Outputs the code length array for the Extra Set or the Position Set. + +Arguments: + + n - the number of symbols + nbit - the number of bits needed to represent 'n' + Special - the special symbol that needs to be take care of + +Returns: (VOID) + +--*/ +{ + INT32 i, k; + + while (n > 0 && mPTLen[n - 1] == 0) { + n--; + } + PutBits(nbit, n); + i = 0; + while (i < n) { + k = mPTLen[i++]; + if (k <= 6) { + PutBits(3, k); + } else { + PutBits(k - 3, (1U << (k - 3)) - 2); + } + if (i == Special) { + while (i < 6 && mPTLen[i] == 0) { + i++; + } + PutBits(2, (i - 3) & 3); + } + } +} + +STATIC +VOID +WriteCLen () +/*++ + +Routine Description: + + Outputs the code length array for Char&Length Set + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + INT32 i, k, n, Count; + + n = NC; + while (n > 0 && mCLen[n - 1] == 0) { + n--; + } + PutBits(CBIT, n); + i = 0; + while (i < n) { + k = mCLen[i++]; + if (k == 0) { + Count = 1; + while (i < n && mCLen[i] == 0) { + i++; + Count++; + } + if (Count <= 2) { + for (k = 0; k < Count; k++) { + PutBits(mPTLen[0], mPTCode[0]); + } + } else if (Count <= 18) { + PutBits(mPTLen[1], mPTCode[1]); + PutBits(4, Count - 3); + } else if (Count == 19) { + PutBits(mPTLen[0], mPTCode[0]); + PutBits(mPTLen[1], mPTCode[1]); + PutBits(4, 15); + } else { + PutBits(mPTLen[2], mPTCode[2]); + PutBits(CBIT, Count - 20); + } + } else { + PutBits(mPTLen[k + 2], mPTCode[k + 2]); + } + } +} + +STATIC +VOID +EncodeC ( + IN INT32 c + ) +{ + PutBits(mCLen[c], mCCode[c]); +} + +STATIC +VOID +EncodeP ( + IN UINT32 p + ) +{ + UINT32 c, q; + + c = 0; + q = p; + while (q) { + q >>= 1; + c++; + } + PutBits(mPTLen[c], mPTCode[c]); + if (c > 1) { + PutBits(c - 1, p & (0xFFFFU >> (17 - c))); + } +} + +STATIC +VOID +SendBlock () +/*++ + +Routine Description: + + Huffman code the block and output it. + +Argument: (VOID) + +Returns: (VOID) + +--*/ +{ + UINT32 i, k, Flags, Root, Pos, Size; + Flags = 0; + + Root = MakeTree(NC, mCFreq, mCLen, mCCode); + Size = mCFreq[Root]; + PutBits(16, Size); + if (Root >= NC) { + CountTFreq(); + Root = MakeTree(NT, mTFreq, mPTLen, mPTCode); + if (Root >= NT) { + WritePTLen(NT, TBIT, 3); + } else { + PutBits(TBIT, 0); + PutBits(TBIT, Root); + } + WriteCLen(); + } else { + PutBits(TBIT, 0); + PutBits(TBIT, 0); + PutBits(CBIT, 0); + PutBits(CBIT, Root); + } + Root = MakeTree(NP, mPFreq, mPTLen, mPTCode); + if (Root >= NP) { + WritePTLen(NP, PBIT, -1); + } else { + PutBits(PBIT, 0); + PutBits(PBIT, Root); + } + Pos = 0; + for (i = 0; i < Size; i++) { + if (i % UINT8_BIT == 0) { + Flags = mBuf[Pos++]; + } else { + Flags <<= 1; + } + if (Flags & (1U << (UINT8_BIT - 1))) { + EncodeC(mBuf[Pos++] + (1U << UINT8_BIT)); + k = mBuf[Pos++] << UINT8_BIT; + k += mBuf[Pos++]; + EncodeP(k); + } else { + EncodeC(mBuf[Pos++]); + } + } + for (i = 0; i < NC; i++) { + mCFreq[i] = 0; + } + for (i = 0; i < NP; i++) { + mPFreq[i] = 0; + } +} + + +STATIC +VOID +Output ( + IN UINT32 c, + IN UINT32 p + ) +/*++ + +Routine Description: + + Outputs an Original Character or a Pointer + +Arguments: + + c - The original character or the 'String Length' element of a Pointer + p - The 'Position' field of a Pointer + +Returns: (VOID) + +--*/ +{ + STATIC UINT32 CPos; + + if ((mOutputMask >>= 1) == 0) { + mOutputMask = 1U << (UINT8_BIT - 1); + if (mOutputPos >= mBufSiz - 3 * UINT8_BIT) { + SendBlock(); + mOutputPos = 0; + } + CPos = mOutputPos++; + mBuf[CPos] = 0; + } + mBuf[mOutputPos++] = (UINT8) c; + mCFreq[c]++; + if (c >= (1U << UINT8_BIT)) { + mBuf[CPos] |= mOutputMask; + mBuf[mOutputPos++] = (UINT8)(p >> UINT8_BIT); + mBuf[mOutputPos++] = (UINT8) p; + c = 0; + while (p) { + p >>= 1; + c++; + } + mPFreq[c]++; + } +} + +STATIC +VOID +HufEncodeStart () +{ + INT32 i; + + for (i = 0; i < NC; i++) { + mCFreq[i] = 0; + } + for (i = 0; i < NP; i++) { + mPFreq[i] = 0; + } + mOutputPos = mOutputMask = 0; + InitPutBits(); + return; +} + +STATIC +VOID +HufEncodeEnd () +{ + SendBlock(); + + // + // Flush remaining bits + // + PutBits(UINT8_BIT - 1, 0); + + return; +} + + +STATIC +VOID +MakeCrcTable () +{ + UINT32 i, j, r; + + for (i = 0; i <= UINT8_MAX; i++) { + r = i; + for (j = 0; j < UINT8_BIT; j++) { + if (r & 1) { + r = (r >> 1) ^ CRCPOLY; + } else { + r >>= 1; + } + } + mCrcTable[i] = (UINT16)r; + } +} + +STATIC +VOID +PutBits ( + IN INT32 n, + IN UINT32 x + ) +/*++ + +Routine Description: + + Outputs rightmost n bits of x + +Argments: + + n - the rightmost n bits of the data is used + x - the data + +Returns: (VOID) + +--*/ +{ + UINT8 Temp; + + if (n < mBitCount) { + mSubBitBuf |= x << (mBitCount -= n); + } else { + + Temp = (UINT8)(mSubBitBuf | (x >> (n -= mBitCount))); + if (mDst < mDstUpperLimit) { + *mDst++ = Temp; + } + mCompSize++; + + if (n < UINT8_BIT) { + mSubBitBuf = x << (mBitCount = UINT8_BIT - n); + } else { + + Temp = (UINT8)(x >> (n - UINT8_BIT)); + if (mDst < mDstUpperLimit) { + *mDst++ = Temp; + } + mCompSize++; + + mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - n); + } + } +} + +STATIC +INT32 +FreadCrc ( + OUT UINT8 *p, + IN INT32 n + ) +/*++ + +Routine Description: + + Read in source data + +Arguments: + + p - the buffer to hold the data + n - number of bytes to read + +Returns: + + number of bytes actually read + +--*/ +{ + INT32 i; + + for (i = 0; mSrc < mSrcUpperLimit && i < n; i++) { + *p++ = *mSrc++; + } + n = i; + + p -= n; + mOrigSize += n; + while (--i >= 0) { + UPDATE_CRC(*p++); + } + return n; +} + + +STATIC +VOID +InitPutBits () +{ + mBitCount = UINT8_BIT; + mSubBitBuf = 0; +} + +STATIC +VOID +CountLen ( + IN INT32 i + ) +/*++ + +Routine Description: + + Count the number of each code length for a Huffman tree. + +Arguments: + + i - the top node + +Returns: (VOID) + +--*/ +{ + STATIC INT32 Depth = 0; + + if (i < mN) { + mLenCnt[(Depth < 16) ? Depth : 16]++; + } else { + Depth++; + CountLen(mLeft [i]); + CountLen(mRight[i]); + Depth--; + } +} + +STATIC +VOID +MakeLen ( + IN INT32 Root + ) +/*++ + +Routine Description: + + Create code length array for a Huffman tree + +Arguments: + + Root - the root of the tree + +--*/ +{ + INT32 i, k; + UINT32 Cum; + + for (i = 0; i <= 16; i++) { + mLenCnt[i] = 0; + } + CountLen(Root); + + // + // Adjust the length count array so that + // no code will be generated longer than its designated length + // + + Cum = 0; + for (i = 16; i > 0; i--) { + Cum += mLenCnt[i] << (16 - i); + } + while (Cum != (1U << 16)) { + mLenCnt[16]--; + for (i = 15; i > 0; i--) { + if (mLenCnt[i] != 0) { + mLenCnt[i]--; + mLenCnt[i+1] += 2; + break; + } + } + Cum--; + } + for (i = 16; i > 0; i--) { + k = mLenCnt[i]; + while (--k >= 0) { + mLen[*mSortPtr++] = (UINT8)i; + } + } +} + +STATIC +VOID +DownHeap ( + IN INT32 i + ) +{ + INT32 j, k; + + // + // priority queue: send i-th entry down heap + // + + k = mHeap[i]; + while ((j = 2 * i) <= mHeapSize) { + if (j < mHeapSize && mFreq[mHeap[j]] > mFreq[mHeap[j + 1]]) { + j++; + } + if (mFreq[k] <= mFreq[mHeap[j]]) { + break; + } + mHeap[i] = mHeap[j]; + i = j; + } + mHeap[i] = (INT16)k; +} + +STATIC +VOID +MakeCode ( + IN INT32 n, + IN UINT8 Len[], + OUT UINT16 Code[] + ) +/*++ + +Routine Description: + + Assign code to each symbol based on the code length array + +Arguments: + + n - number of symbols + Len - the code length array + Code - stores codes for each symbol + +Returns: (VOID) + +--*/ +{ + INT32 i; + UINT16 Start[18]; + + Start[1] = 0; + for (i = 1; i <= 16; i++) { + Start[i + 1] = (UINT16)((Start[i] + mLenCnt[i]) << 1); + } + for (i = 0; i < n; i++) { + Code[i] = Start[Len[i]]++; + } +} + +STATIC +INT32 +MakeTree ( + IN INT32 NParm, + IN UINT16 FreqParm[], + OUT UINT8 LenParm[], + OUT UINT16 CodeParm[] + ) +/*++ + +Routine Description: + + Generates Huffman codes given a frequency distribution of symbols + +Arguments: + + NParm - number of symbols + FreqParm - frequency of each symbol + LenParm - code length for each symbol + CodeParm - code for each symbol + +Returns: + + Root of the Huffman tree. + +--*/ +{ + INT32 i, j, k, Avail; + + // + // make tree, calculate len[], return root + // + + mN = NParm; + mFreq = FreqParm; + mLen = LenParm; + Avail = mN; + mHeapSize = 0; + mHeap[1] = 0; + for (i = 0; i < mN; i++) { + mLen[i] = 0; + if (mFreq[i]) { + mHeap[++mHeapSize] = (INT16)i; + } + } + if (mHeapSize < 2) { + CodeParm[mHeap[1]] = 0; + return mHeap[1]; + } + for (i = mHeapSize / 2; i >= 1; i--) { + + // + // make priority queue + // + DownHeap(i); + } + mSortPtr = CodeParm; + do { + i = mHeap[1]; + if (i < mN) { + *mSortPtr++ = (UINT16)i; + } + mHeap[1] = mHeap[mHeapSize--]; + DownHeap(1); + j = mHeap[1]; + if (j < mN) { + *mSortPtr++ = (UINT16)j; + } + k = Avail++; + mFreq[k] = (UINT16)(mFreq[i] + mFreq[j]); + mHeap[1] = (INT16)k; + DownHeap(1); + mLeft[k] = (UINT16)i; + mRight[k] = (UINT16)j; + } while (mHeapSize > 1); + + mSortPtr = CodeParm; + MakeLen(k); + MakeCode(NParm, LenParm, CodeParm); + + // + // return root + // + return k; +} + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCustomizedCompress.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCustomizedCompress.h new file mode 100644 index 0000000000..b01f538f3d --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiCustomizedCompress.h @@ -0,0 +1,138 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiCustomizedCompress.h + +Abstract: + + Header file for Customized compression routine + +--*/ + +#ifndef _EFICUSTOMIZEDCOMPRESS_H +#define _EFICUSTOMIZEDCOMPRESS_H +EFI_STATUS +SetCustomizedCompressionType ( + IN CHAR8 *Type + ) +; + +/*++ + +Routine Description: + +The implementation of Customized SetCompressionType(). + +Arguments: + Type - The type if compression. + +Returns: + + EFI_SUCCESS - The type has been set. + EFI_UNSUPPORTED - This type is unsupported. + + +--*/ +EFI_STATUS +CustomizedGetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +; + +/*++ + +Routine Description: + + The implementation of Customized GetInfo(). + +Arguments: + + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +EFI_STATUS +CustomizedDecompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +; + +/*++ + +Routine Description: + + The implementation of Customized Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + +--*/ +EFI_STATUS +CustomizedCompress ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize + ) +; + +/*++ + +Routine Description: + + The Customized compression routine. + +Arguments: + + SrcBuffer - The buffer storing the source data + SrcSize - The size of source data + DstBuffer - The buffer to store the compressed data + DstSize - On input, the size of DstBuffer; On output, + the size of the actual compressed data. + +Returns: + + EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case, + DstSize contains the size needed. + EFI_SUCCESS - Compression is successful. + +--*/ + +#endif \ No newline at end of file diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.c new file mode 100644 index 0000000000..37705a84f1 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.c @@ -0,0 +1,756 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiUtilityMsgs.c + +Abstract: + + EFI tools utility functions to display warning, error, and informational + messages. + +--*/ + +#include +#include +#include +#include + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" + +#define MAX_LINE_LEN 200 + +// +// Declare module globals for keeping track of the the utility's +// name and other settings. +// +static STATUS mStatus = STATUS_SUCCESS; +static INT8 mUtilityName[50] = { 0 }; +static UINT32 mDebugMsgMask = 0; +static INT8 *mSourceFileName = NULL; +static UINT32 mSourceFileLineNum = 0; +static UINT32 mErrorCount = 0; +static UINT32 mWarningCount = 0; +static UINT32 mMaxErrors = 0; +static UINT32 mMaxWarnings = 0; +static UINT32 mMaxWarningsPlusErrors = 0; +static INT8 mPrintLimitsSet = 0; + +static +void +PrintMessage ( + INT8 *Type, + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + va_list List + ); + +static +void +PrintLimitExceeded ( + VOID + ); + +void +Error ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Prints an error message. + +Arguments: + All arguments are optional, though the printed message may be useless if + at least something valid is not specified. + + FileName - name of the file or application. If not specified, then the + utilty name (as set by the utility calling SetUtilityName() + earlier) is used. Otherwise "Unknown utility" is used. + + LineNumber - the line number of error, typically used by parsers. If the + utility is not a parser, then 0 should be specified. Otherwise + the FileName and LineNumber info can be used to cause + MS Visual Studio to jump to the error. + + MessageCode - an application-specific error code that can be referenced in + other documentation. + + Text - the text in question, typically used by parsers. + + MsgFmt - the format string for the error message. Can contain formatting + controls for use with the varargs. + +Returns: + None. + +Notes: + We print the following (similar to the Warn() and Debug() + W + Typical error/warning message format: + + bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters + + BUGBUG -- these three utility functions are almost identical, and + should be modified to share code. + + Visual Studio does not find error messages with: + + " error :" + " error 1:" + " error c1:" + " error 1000:" + " error c100:" + + It does find: + " error c1000:" +--*/ +{ + va_list List; + // + // If limits have been set, then check that we have not exceeded them + // + if (mPrintLimitsSet) { + // + // See if we've exceeded our total count + // + if (mMaxWarningsPlusErrors != 0) { + if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) { + PrintLimitExceeded (); + return ; + } + } + // + // See if we've exceeded our error count + // + if (mMaxErrors != 0) { + if (mErrorCount > mMaxErrors) { + PrintLimitExceeded (); + return ; + } + } + } + + mErrorCount++; + va_start (List, MsgFmt); + PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_ERROR) { + mStatus = STATUS_ERROR; + } +} + +void +ParserError ( + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a parser error, using the source file name and line number + set by a previous call to SetParserPosition(). + +Arguments: + MessageCode - application-specific error code + Text - text to print in the error message + MsgFmt - format string to print at the end of the error message + +Returns: + NA + +--*/ +{ + va_list List; + // + // If limits have been set, then check them + // + if (mPrintLimitsSet) { + // + // See if we've exceeded our total count + // + if (mMaxWarningsPlusErrors != 0) { + if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) { + PrintLimitExceeded (); + return ; + } + } + // + // See if we've exceeded our error count + // + if (mMaxErrors != 0) { + if (mErrorCount > mMaxErrors) { + PrintLimitExceeded (); + return ; + } + } + } + + mErrorCount++; + va_start (List, MsgFmt); + PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_ERROR) { + mStatus = STATUS_ERROR; + } +} + +void +ParserWarning ( + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a parser warning, using the source file name and line number + set by a previous call to SetParserPosition(). + +Arguments: + ErrorCode - application-specific error code + OffendingText - text to print in the warning message + MsgFmt - format string to print at the end of the warning message + +Returns: + NA + +--*/ +{ + va_list List; + // + // If limits have been set, then check them + // + if (mPrintLimitsSet) { + // + // See if we've exceeded our total count + // + if (mMaxWarningsPlusErrors != 0) { + if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) { + PrintLimitExceeded (); + return ; + } + } + // + // See if we've exceeded our warning count + // + if (mMaxWarnings != 0) { + if (mWarningCount > mMaxWarnings) { + PrintLimitExceeded (); + return ; + } + } + } + + mWarningCount++; + va_start (List, MsgFmt); + PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_WARNING) { + mStatus = STATUS_WARNING; + } +} + +void +Warning ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a warning message. + +Arguments: + FileName - name of the file where the warning was detected, or the name + of the application that detected the warning + + LineNumber - the line number where the warning was detected (parsers). + 0 should be specified if the utility is not a parser. + + MessageCode - an application-specific warning code that can be referenced in + other documentation. + + Text - the text in question (parsers) + + MsgFmt - the format string for the warning message. Can contain formatting + controls for use with varargs. + +Returns: + None. + +--*/ +{ + va_list List; + // + // If limits have been set, then check them + // + if (mPrintLimitsSet) { + // + // See if we've exceeded our total count + // + if (mMaxWarningsPlusErrors != 0) { + if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) { + PrintLimitExceeded (); + return ; + } + } + // + // See if we've exceeded our warning count + // + if (mMaxWarnings != 0) { + if (mWarningCount > mMaxWarnings) { + PrintLimitExceeded (); + return ; + } + } + } + + mWarningCount++; + va_start (List, MsgFmt); + PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_WARNING) { + mStatus = STATUS_WARNING; + } +} + +void +DebugMsg ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MsgMask, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a warning message. + +Arguments: + FileName - typically the name of the utility printing the debug message, but + can be the name of a file being parsed. + + LineNumber - the line number in FileName (parsers) + + MsgMask - an application-specific bitmask that, in combination with mDebugMsgMask, + determines if the debug message gets printed. + + Text - the text in question (parsers) + + MsgFmt - the format string for the debug message. Can contain formatting + controls for use with varargs. + +Returns: + None. + +--*/ +{ + va_list List; + // + // If the debug mask is not applicable, then do nothing. + // + if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) { + return ; + } + + va_start (List, MsgFmt); + PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List); + va_end (List); +} + +static +void +PrintMessage ( + INT8 *Type, + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + va_list List + ) +/*++ + +Routine Description: + Worker routine for all the utility printing services. Prints the message in + a format that Visual Studio will find when scanning build outputs for + errors or warnings. + +Arguments: + Type - "warning" or "error" string to insert into the message to be + printed. The first character of this string (converted to uppercase) + is used to preceed the MessageCode value in the output string. + + FileName - name of the file where the warning was detected, or the name + of the application that detected the warning + + LineNumber - the line number where the warning was detected (parsers). + 0 should be specified if the utility is not a parser. + + MessageCode - an application-specific warning code that can be referenced in + other documentation. + + Text - part of the message to print + + MsgFmt - the format string for the message. Can contain formatting + controls for use with varargs. + List - the variable list. + +Returns: + None. + +Notes: + If FileName == NULL then this utility will use the string passed into SetUtilityName(). + + LineNumber is only used if the caller is a parser, in which case FileName refers to the + file being parsed. + + Text and MsgFmt are both optional, though it would be of little use calling this function with + them both NULL. + + Output will typically be of the form: + () : : : + + Parser (LineNumber != 0) + VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters + Generic utility (LineNumber == 0) + UtilityName : error E1234 : Text string : MsgFmt string and args + +--*/ +{ + INT8 Line[MAX_LINE_LEN]; + INT8 Line2[MAX_LINE_LEN]; + INT8 *Cptr; + // + // If given a filename, then add it (and the line number) to the string. + // If there's no filename, then use the program name if provided. + // + if (FileName != NULL) { + Cptr = FileName; + } else if (mUtilityName[0] != 0) { + Cptr = mUtilityName; + } else { + Cptr = "Unknown utility"; + } + + strcpy (Line, Cptr); + if (LineNumber != 0) { + sprintf (Line2, "(%d)", LineNumber); + strcat (Line, Line2); + } + // + // Have to print an error code or Visual Studio won't find the + // message for you. It has to be decimal digits too. + // + sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode); + strcat (Line, Line2); + fprintf (stdout, "%s", Line); + // + // If offending text was provided, then print it + // + if (Text != NULL) { + fprintf (stdout, ": %s ", Text); + } + // + // Print formatted message if provided + // + if (MsgFmt != NULL) { + vsprintf (Line2, MsgFmt, List); + fprintf (stdout, ": %s", Line2); + } + + fprintf (stdout, "\n"); +} + +void +ParserSetPosition ( + INT8 *SourceFileName, + UINT32 LineNum + ) +/*++ + +Routine Description: + Set the position in a file being parsed. This can be used to + print error messages deeper down in a parser. + +Arguments: + SourceFileName - name of the source file being parsed + LineNum - line number of the source file being parsed + +Returns: + NA + +--*/ +{ + mSourceFileName = SourceFileName; + mSourceFileLineNum = LineNum; +} + +void +SetUtilityName ( + INT8 *UtilityName + ) +/*++ + +Routine Description: + All printed error/warning/debug messages follow the same format, and + typically will print a filename or utility name followed by the error + text. However if a filename is not passed to the print routines, then + they'll print the utility name if you call this function early in your + app to set the utility name. + +Arguments: + UtilityName - name of the utility, which will be printed with all + error/warning/debug messags. + +Returns: + NA + +--*/ +{ + // + // Save the name of the utility in our local variable. Make sure its + // length does not exceed our buffer. + // + if (UtilityName != NULL) { + if (strlen (UtilityName) >= sizeof (mUtilityName)) { + Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size"); + strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1); + mUtilityName[sizeof (mUtilityName) - 1] = 0; + return ; + } else { + strcpy (mUtilityName, UtilityName); + } + } else { + Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name"); + } +} + +STATUS +GetUtilityStatus ( + VOID + ) +/*++ + +Routine Description: + When you call Error() or Warning(), this module keeps track of it and + sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility + exits, it can call this function to get the status and use it as a return + value. + +Arguments: + None. + +Returns: + Worst-case status reported, as defined by which print function was called. + +--*/ +{ + return mStatus; +} + +void +SetDebugMsgMask ( + UINT32 DebugMask + ) +/*++ + +Routine Description: + Set the debug printing mask. This is used by the DebugMsg() function + to determine when/if a debug message should be printed. + +Arguments: + DebugMask - bitmask, specific to the calling application + +Returns: + NA + +--*/ +{ + mDebugMsgMask = DebugMask; +} + +void +SetPrintLimits ( + UINT32 MaxErrors, + UINT32 MaxWarnings, + UINT32 MaxWarningsPlusErrors + ) +/*++ + +Routine Description: + Set the limits of how many errors, warnings, and errors+warnings + we will print. + +Arguments: + MaxErrors - maximum number of error messages to print + MaxWarnings - maximum number of warning messages to print + MaxWarningsPlusErrors + - maximum number of errors+warnings to print + +Returns: + NA + +--*/ +{ + mMaxErrors = MaxErrors; + mMaxWarnings = MaxWarnings; + mMaxWarningsPlusErrors = MaxWarningsPlusErrors; + mPrintLimitsSet = 1; +} + +static +void +PrintLimitExceeded ( + VOID + ) +{ + static INT8 mPrintLimitExceeded = 0; + // + // If we've already printed the message, do nothing. Otherwise + // temporarily increase our print limits so we can pass one + // more message through. + // + if (mPrintLimitExceeded == 0) { + mPrintLimitExceeded++; + mMaxErrors++; + mMaxWarnings++; + mMaxWarningsPlusErrors++; + Error (NULL, 0, 0, "error/warning print limit exceeded", NULL); + mMaxErrors--; + mMaxWarnings--; + mMaxWarningsPlusErrors--; + } +} + +#if 0 +void +TestUtilityMessages ( + VOID + ) +{ + char *ArgStr = "ArgString"; + int ArgInt; + + ArgInt = 0x12345678; + // + // Test without setting utility name + // + fprintf (stdout, "* Testing without setting utility name\n"); + fprintf (stdout, "** Test debug message not printed\n"); + DebugMsg (NULL, 0, 0x00000001, NULL, NULL); + fprintf (stdout, "** Test warning with two strings and two args\n"); + Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt); + fprintf (stdout, "** Test error with two strings and two args\n"); + Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt); + fprintf (stdout, "** Test parser warning with nothing\n"); + ParserWarning (0, NULL, NULL); + fprintf (stdout, "** Test parser error with nothing\n"); + ParserError (0, NULL, NULL); + // + // Test with utility name set now + // + fprintf (stdout, "** Testingin with utility name set\n"); + SetUtilityName ("MyUtilityName"); + // + // Test debug prints + // + SetDebugMsgMask (2); + fprintf (stdout, "** Test debug message with one string\n"); + DebugMsg (NULL, 0, 0x00000002, "Text1", NULL); + fprintf (stdout, "** Test debug message with one string\n"); + DebugMsg (NULL, 0, 0x00000002, NULL, "Text2"); + fprintf (stdout, "** Test debug message with two strings\n"); + DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2"); + fprintf (stdout, "** Test debug message with two strings and two args\n"); + DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt); + // + // Test warning prints + // + fprintf (stdout, "** Test warning with no strings\n"); + Warning (NULL, 0, 1234, NULL, NULL); + fprintf (stdout, "** Test warning with one string\n"); + Warning (NULL, 0, 1234, "Text1", NULL); + fprintf (stdout, "** Test warning with one string\n"); + Warning (NULL, 0, 1234, NULL, "Text2"); + fprintf (stdout, "** Test warning with two strings and two args\n"); + Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt); + // + // Test error prints + // + fprintf (stdout, "** Test error with no strings\n"); + Error (NULL, 0, 1234, NULL, NULL); + fprintf (stdout, "** Test error with one string\n"); + Error (NULL, 0, 1234, "Text1", NULL); + fprintf (stdout, "** Test error with one string\n"); + Error (NULL, 0, 1234, NULL, "Text2"); + fprintf (stdout, "** Test error with two strings and two args\n"); + Error (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt); + // + // Test parser prints + // + fprintf (stdout, "** Test parser errors\n"); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserError (1234, NULL, NULL); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserError (1234, "Text1", NULL); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserError (1234, NULL, "Text2"); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserError (1234, "Text1", "Text2"); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserError (1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt); + + fprintf (stdout, "** Test parser warnings\n"); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserWarning (4321, NULL, NULL); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserWarning (4321, "Text1", NULL); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserWarning (4321, NULL, "Text2"); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserWarning (4321, "Text1", "Text2"); + ParserSetPosition (__FILE__, __LINE__ + 1); + ParserWarning (4321, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt); +} +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.h new file mode 100644 index 0000000000..2da1fe58f6 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/EfiUtilityMsgs.h @@ -0,0 +1,135 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiUtilityMsgs.h + +Abstract: + + Defines and prototypes for common EFI utility error and debug messages. + +--*/ + +#ifndef _EFI_UTILITY_MSGS_H_ +#define _EFI_UTILITY_MSGS_H_ + +// +// Status codes returned by EFI utility programs and functions +// +#define STATUS_SUCCESS 0 +#define STATUS_WARNING 1 +#define STATUS_ERROR 2 +#define VOID void + +typedef int STATUS; + +#ifdef __cplusplus +extern "C" { +#endif +// +// When we call Error() or Warning(), the module keeps track of the worst +// case reported. GetUtilityStatus() will get the worst-case results, which +// can be used as the return value from the app. +// +STATUS +GetUtilityStatus ( + void + ); + +// +// If someone prints an error message and didn't specify a source file name, +// then we print the utility name instead. However they must tell us the +// utility name early on via this function. +// +void +SetUtilityName ( + INT8 *ProgramName + ) +; + +void +Error ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +Warning ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +DebugMsg ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MsgLevel, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +SetDebugMsgMask ( + UINT32 MsgMask + ) +; + +void +ParserSetPosition ( + INT8 *SourceFileName, + UINT32 LineNum + ) +; + +void +ParserError ( + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +ParserWarning ( + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +SetPrintLimits ( + UINT32 NumErrors, + UINT32 NumWarnings, + UINT32 NumWarningsPlusErrors + ) +; + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef _EFI_UTILITY_MSGS_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c new file mode 100644 index 0000000000..4b2bf81147 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c @@ -0,0 +1,786 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FvLib.c + +Abstract: + + These functions assist in parsing and manipulating a Firmware Volume. + +--*/ + +// +// Include files +// +#include "FvLib.h" +#include "CommonLib.h" +#include "EfiUtilityMsgs.h" + +// +// Module global variables +// +EFI_FIRMWARE_VOLUME_HEADER *mFvHeader = NULL; +UINT32 mFvLength = 0; + +// +// External function implementations +// +EFI_STATUS +InitializeFvLib ( + IN VOID *Fv, + IN UINT32 FvLength + ) +/*++ + +Routine Description: + + This initializes the FV lib with a pointer to the FV and length. It does not + verify the FV in any way. + +Arguments: + + Fv Buffer containing the FV. + FvLength Length of the FV + +Returns: + + EFI_SUCCESS Function Completed successfully. + EFI_INVALID_PARAMETER A required parameter was NULL. + +--*/ +{ + // + // Verify input arguments + // + if (Fv == NULL) { + return EFI_INVALID_PARAMETER; + } + + mFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Fv; + mFvLength = FvLength; + + return EFI_SUCCESS; +} + +EFI_STATUS +GetFvHeader ( + OUT EFI_FIRMWARE_VOLUME_HEADER **FvHeader, + OUT UINT32 *FvLength + ) +/*++ + +Routine Description: + + This function returns a pointer to the current FV and the size. + +Arguments: + + FvHeader Pointer to the FV buffer. + FvLength Length of the FV + +Returns: + + EFI_SUCCESS Function Completed successfully. + EFI_INVALID_PARAMETER A required parameter was NULL. + EFI_ABORTED The library needs to be initialized. + +--*/ +{ + // + // Verify library has been initialized. + // + if (mFvHeader == NULL || mFvLength == 0) { + return EFI_ABORTED; + } + // + // Verify input arguments + // + if (FvHeader == NULL) { + return EFI_INVALID_PARAMETER; + } + + *FvHeader = mFvHeader; + return EFI_SUCCESS; +} + +EFI_STATUS +GetNextFile ( + IN EFI_FFS_FILE_HEADER *CurrentFile, + OUT EFI_FFS_FILE_HEADER **NextFile + ) +/*++ + +Routine Description: + + This function returns the next file. If the current file is NULL, it returns + the first file in the FV. If the function returns EFI_SUCCESS and the file + pointer is NULL, then there are no more files in the FV. + +Arguments: + + CurrentFile Pointer to the current file, must be within the current FV. + NextFile Pointer to the next file in the FV. + +Returns: + + EFI_SUCCESS Function completed successfully. + EFI_INVALID_PARAMETER A required parameter was NULL or is out of range. + EFI_ABORTED The library needs to be initialized. + +--*/ +{ + EFI_STATUS Status; + + // + // Verify library has been initialized. + // + if (mFvHeader == NULL || mFvLength == 0) { + return EFI_ABORTED; + } + // + // Verify input arguments + // + if (NextFile == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Verify FV header + // + Status = VerifyFv (mFvHeader); + if (EFI_ERROR (Status)) { + return EFI_ABORTED; + } + // + // Get first file + // + if (CurrentFile == NULL) { + CurrentFile = (EFI_FFS_FILE_HEADER *) ((UINTN) mFvHeader + mFvHeader->HeaderLength); + + // + // Verify file is valid + // + Status = VerifyFfsFile (CurrentFile); + if (EFI_ERROR (Status)) { + // + // no files in this FV + // + *NextFile = NULL; + return EFI_SUCCESS; + } else { + // + // Verify file is in this FV. + // + if ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength) { + *NextFile = NULL; + return EFI_SUCCESS; + } + + *NextFile = CurrentFile; + return EFI_SUCCESS; + } + } + // + // Verify current file is in range + // + if (((UINTN) CurrentFile < (UINTN) mFvHeader + mFvHeader->HeaderLength) || + ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength) + ) { + return EFI_INVALID_PARAMETER; + } + // + // Get next file, compensate for 8 byte alignment if necessary. + // + *NextFile = (EFI_FFS_FILE_HEADER *) (((UINTN) CurrentFile + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3)); + + // + // Verify file is in this FV. + // + if (((UINTN) *NextFile + sizeof (EFI_FFS_FILE_HEADER) >= (UINTN) mFvHeader + mFvLength) || + ((UINTN) *NextFile + GetLength ((*NextFile)->Size) > (UINTN) mFvHeader + mFvLength) + ) { + *NextFile = NULL; + return EFI_SUCCESS; + } + // + // Verify file is valid + // + Status = VerifyFfsFile (*NextFile); + if (EFI_ERROR (Status)) { + // + // no more files in this FV + // + *NextFile = NULL; + return EFI_SUCCESS; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +GetFileByName ( + IN EFI_GUID *FileName, + OUT EFI_FFS_FILE_HEADER **File + ) +/*++ + +Routine Description: + + Find a file by name. The function will return NULL if the file is not found. + +Arguments: + + FileName The GUID file name of the file to search for. + File Return pointer. In the case of an error, contents are undefined. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_ABORTED An error was encountered. + EFI_INVALID_PARAMETER One of the parameters was NULL. + +--*/ +{ + EFI_FFS_FILE_HEADER *CurrentFile; + EFI_STATUS Status; + + // + // Verify library has been initialized. + // + if (mFvHeader == NULL || mFvLength == 0) { + return EFI_ABORTED; + } + // + // Verify input parameters + // + if (FileName == NULL || File == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Verify FV header + // + Status = VerifyFv (mFvHeader); + if (EFI_ERROR (Status)) { + return EFI_ABORTED; + } + // + // Get the first file + // + Status = GetNextFile (NULL, &CurrentFile); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "error parsing the FV", NULL); + return EFI_ABORTED; + } + // + // Loop as long as we have a valid file + // + while (CurrentFile) { + if (!CompareGuid (&CurrentFile->Name, FileName)) { + *File = CurrentFile; + return EFI_SUCCESS; + } + + Status = GetNextFile (CurrentFile, &CurrentFile); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "error parsing the FV", NULL); + return EFI_ABORTED; + } + } + // + // File not found in this FV. + // + *File = NULL; + return EFI_SUCCESS; +} + +EFI_STATUS +GetFileByType ( + IN EFI_FV_FILETYPE FileType, + IN UINTN Instance, + OUT EFI_FFS_FILE_HEADER **File + ) +/*++ + +Routine Description: + + Find a file by type and instance. An instance of 1 is the first instance. + The function will return NULL if a matching file cannot be found. + File type EFI_FV_FILETYPE_ALL means any file type is valid. + +Arguments: + + FileType Type of file to search for. + Instance Instace of the file type to return. + File Return pointer. In the case of an error, contents are undefined. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_ABORTED An error was encountered. + EFI_INVALID_PARAMETER One of the parameters was NULL. + +--*/ +{ + EFI_FFS_FILE_HEADER *CurrentFile; + EFI_STATUS Status; + UINTN FileCount; + + // + // Verify library has been initialized. + // + if (mFvHeader == NULL || mFvLength == 0) { + return EFI_ABORTED; + } + // + // Verify input parameters + // + if (File == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Verify FV header + // + Status = VerifyFv (mFvHeader); + if (EFI_ERROR (Status)) { + return EFI_ABORTED; + } + // + // Initialize the number of matching files found. + // + FileCount = 0; + + // + // Get the first file + // + Status = GetNextFile (NULL, &CurrentFile); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "error parsing FV", NULL); + return EFI_ABORTED; + } + // + // Loop as long as we have a valid file + // + while (CurrentFile) { + if (FileType == EFI_FV_FILETYPE_ALL || CurrentFile->Type == FileType) { + FileCount++; + } + + if (FileCount == Instance) { + *File = CurrentFile; + return EFI_SUCCESS; + } + + Status = GetNextFile (CurrentFile, &CurrentFile); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "error parsing the FV", NULL); + return EFI_ABORTED; + } + } + + *File = NULL; + return EFI_SUCCESS; +} + +EFI_STATUS +GetSectionByType ( + IN EFI_FFS_FILE_HEADER *File, + IN EFI_SECTION_TYPE SectionType, + IN UINTN Instance, + OUT EFI_FILE_SECTION_POINTER *Section + ) +/*++ + +Routine Description: + + Find a section in a file by type and instance. An instance of 1 is the first + instance. The function will return NULL if a matching section cannot be found. + The function will not handle encapsulating sections. + +Arguments: + + File The file to search. + SectionType Type of file to search for. + Instance Instace of the section to return. + Section Return pointer. In the case of an error, contents are undefined. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_ABORTED An error was encountered. + EFI_INVALID_PARAMETER One of the parameters was NULL. + EFI_NOT_FOUND No found. +--*/ +{ + EFI_FILE_SECTION_POINTER CurrentSection; + EFI_STATUS Status; + UINTN SectionCount; + + // + // Verify input parameters + // + if (File == NULL || Instance == 0) { + return EFI_INVALID_PARAMETER; + } + // + // Verify FFS header + // + Status = VerifyFfsFile (File); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "invalid FFS file", NULL); + return EFI_ABORTED; + } + // + // Initialize the number of matching sections found. + // + SectionCount = 0; + + // + // Get the first section + // + CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + sizeof (EFI_FFS_FILE_HEADER)); + + // + // Loop as long as we have a valid file + // + while ((UINTN) CurrentSection.CommonHeader < (UINTN) File + GetLength (File->Size)) { + if (CurrentSection.CommonHeader->Type == SectionType) { + SectionCount++; + } + + if (SectionCount == Instance) { + *Section = CurrentSection; + return EFI_SUCCESS; + } + // + // Find next section (including compensating for alignment issues. + // + CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetLength (CurrentSection.CommonHeader->Size) + 0x03) & (-1 << 2)); + } + // + // Section not found + // + (*Section).Code16Section = NULL; + return EFI_NOT_FOUND; +} +// +// will not parse compressed sections +// +EFI_STATUS +VerifyFv ( + IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader + ) +/*++ + +Routine Description: + + Verify the current pointer points to a valid FV header. + +Arguments: + + FvHeader Pointer to an alleged FV file. + +Returns: + + EFI_SUCCESS The FV header is valid. + EFI_VOLUME_CORRUPTED The FV header is not valid. + EFI_INVALID_PARAMETER A required parameter was NULL. + EFI_ABORTED Operation aborted. + +--*/ +{ + UINT16 Checksum; + + // + // Verify input parameters + // + if (FvHeader == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (FvHeader->Signature != EFI_FVH_SIGNATURE) { + Error (NULL, 0, 0, "invalid FV header signature", NULL); + return EFI_VOLUME_CORRUPTED; + } + // + // Verify header checksum + // + Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16)); + + if (Checksum != 0) { + Error (NULL, 0, 0, "invalid FV header checksum", NULL); + return EFI_ABORTED; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +VerifyFfsFile ( + IN EFI_FFS_FILE_HEADER *FfsHeader + ) +/*++ + +Routine Description: + + Verify the current pointer points to a FFS file header. + +Arguments: + + FfsHeader Pointer to an alleged FFS file. + +Returns: + + EFI_SUCCESS The Ffs header is valid. + EFI_NOT_FOUND This "file" is the beginning of free space. + EFI_VOLUME_CORRUPTED The Ffs header is not valid. + EFI_ABORTED The erase polarity is not known. + +--*/ +{ + BOOLEAN ErasePolarity; + EFI_STATUS Status; + EFI_FFS_FILE_HEADER BlankHeader; + UINT8 Checksum; + UINT32 FileLength; + UINT32 OccupiedFileLength; + UINT8 SavedChecksum; + UINT8 SavedState; + UINT8 FileGuidString[80]; + UINT32 TailSize; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_FFS_FILE_TAIL *Tail; +#endif + + // + // Verify library has been initialized. + // + if (mFvHeader == NULL || mFvLength == 0) { + return EFI_ABORTED; + } + // + // Verify FV header + // + Status = VerifyFv (mFvHeader); + if (EFI_ERROR (Status)) { + return EFI_ABORTED; + } + // + // Get the erase polarity. + // + Status = GetErasePolarity (&ErasePolarity); + if (EFI_ERROR (Status)) { + return EFI_ABORTED; + } + // + // Check if we have free space + // + if (ErasePolarity) { + memset (&BlankHeader, -1, sizeof (EFI_FFS_FILE_HEADER)); + } else { + memset (&BlankHeader, 0, sizeof (EFI_FFS_FILE_HEADER)); + } + + if (memcmp (&BlankHeader, FfsHeader, sizeof (EFI_FFS_FILE_HEADER)) == 0) { + return EFI_NOT_FOUND; + } + // + // Convert the GUID to a string so we can at least report which file + // if we find an error. + // + PrintGuidToBuffer (&FfsHeader->Name, FileGuidString, sizeof (FileGuidString), TRUE); + if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) { + TailSize = sizeof (EFI_FFS_FILE_TAIL); + } else { + TailSize = 0; + } + // + // Verify file header checksum + // + SavedState = FfsHeader->State; + FfsHeader->State = 0; + SavedChecksum = FfsHeader->IntegrityCheck.Checksum.File; + FfsHeader->IntegrityCheck.Checksum.File = 0; + Checksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER)); + FfsHeader->State = SavedState; + FfsHeader->IntegrityCheck.Checksum.File = SavedChecksum; + if (Checksum != 0) { + Error (NULL, 0, 0, FileGuidString, "invalid FFS file header checksum"); + return EFI_ABORTED; + } + // + // Verify file checksum + // + if (FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) { + // + // Verify file data checksum + // + FileLength = GetLength (FfsHeader->Size); + OccupiedFileLength = (FileLength + 0x07) & (-1 << 3); + Checksum = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize); + Checksum = (UINT8) (Checksum - FfsHeader->State); + if (Checksum != 0) { + Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum"); + return EFI_ABORTED; + } + } else { + // + // File does not have a checksum + // Verify contents are 0x5A as spec'd + // + if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) { + Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum"); + return EFI_ABORTED; + } + } +#if (PI_SPECIFICATION_VERSION < 0x00010000) + // + // Check if the tail is present and verify it if it is. + // + if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) { + // + // Verify tail is complement of integrity check field in the header. + // + Tail = (EFI_FFS_FILE_TAIL *) ((UINTN) FfsHeader + GetLength (FfsHeader->Size) - sizeof (EFI_FFS_FILE_TAIL)); + if (FfsHeader->IntegrityCheck.TailReference != (EFI_FFS_FILE_TAIL)~(*Tail)) { + Error (NULL, 0, 0, FileGuidString, "invalid FFS file tail"); + return EFI_ABORTED; + } + } +#endif + return EFI_SUCCESS; +} + +UINT32 +GetLength ( + UINT8 *ThreeByteLength + ) +/*++ + +Routine Description: + + Converts a three byte length value into a UINT32. + +Arguments: + + ThreeByteLength Pointer to the first of the 3 byte length. + +Returns: + + UINT32 Size of the section + +--*/ +{ + UINT32 Length; + + if (ThreeByteLength == NULL) { + return 0; + } + + Length = *((UINT32 *) ThreeByteLength); + Length = Length & 0x00FFFFFF; + + return Length; +} + +EFI_STATUS +GetErasePolarity ( + OUT BOOLEAN *ErasePolarity + ) +/*++ + +Routine Description: + + This function returns with the FV erase polarity. If the erase polarity + for a bit is 1, the function return TRUE. + +Arguments: + + ErasePolarity A pointer to the erase polarity. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + EFI_ABORTED Operation aborted. + +--*/ +{ + EFI_STATUS Status; + + // + // Verify library has been initialized. + // + if (mFvHeader == NULL || mFvLength == 0) { + return EFI_ABORTED; + } + // + // Verify FV header + // + Status = VerifyFv (mFvHeader); + if (EFI_ERROR (Status)) { + return EFI_ABORTED; + } + // + // Verify input parameters. + // + if (ErasePolarity == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (mFvHeader->Attributes & EFI_FVB_ERASE_POLARITY) { + *ErasePolarity = TRUE; + } else { + *ErasePolarity = FALSE; + } + + return EFI_SUCCESS; +} + +UINT8 +GetFileState ( + IN BOOLEAN ErasePolarity, + IN EFI_FFS_FILE_HEADER *FfsHeader + ) +/*++ + +Routine Description: + + This function returns a the highest state bit in the FFS that is set. + It in no way validate the FFS file. + +Arguments: + + ErasePolarity The erase polarity for the file state bits. + FfsHeader Pointer to a FFS file. + +Returns: + + UINT8 The hightest set state of the file. + +--*/ +{ + UINT8 FileState; + UINT8 HighestBit; + + FileState = FfsHeader->State; + + if (ErasePolarity) { + FileState = (UINT8)~FileState; + } + + HighestBit = 0x80; + while (HighestBit != 0 && (HighestBit & FileState) == 0) { + HighestBit >>= 1; + } + + return HighestBit; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.h new file mode 100644 index 0000000000..4b7ef0a332 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.h @@ -0,0 +1,177 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FvLib.h + +Abstract: + + These functions assist in parsing and manipulating a Firmware Volume. + +--*/ + +#ifndef _EFI_FV_LIB_H +#define _EFI_FV_LIB_H + +// +// Include files +// +#include "TianoCommon.h" +#include "EfiFirmwareVolumeHeader.h" +#include "EfiFirmwareFileSystem.h" +#include + +EFI_STATUS +InitializeFvLib ( + IN VOID *Fv, + IN UINT32 FvLength + ) +; + +EFI_STATUS +GetFvHeader ( + OUT EFI_FIRMWARE_VOLUME_HEADER **FvHeader, + OUT UINT32 *FvLength + ) +; + +EFI_STATUS +GetNextFile ( + IN EFI_FFS_FILE_HEADER *CurrentFile, + OUT EFI_FFS_FILE_HEADER **NextFile + ) +; + +EFI_STATUS +GetFileByName ( + IN EFI_GUID *FileName, + OUT EFI_FFS_FILE_HEADER **File + ) +; + +EFI_STATUS +GetFileByType ( + IN EFI_FV_FILETYPE FileType, + IN UINTN Instance, + OUT EFI_FFS_FILE_HEADER **File + ) +; + +EFI_STATUS +GetSectionByType ( + IN EFI_FFS_FILE_HEADER *File, + IN EFI_SECTION_TYPE SectionType, + IN UINTN Instance, + OUT EFI_FILE_SECTION_POINTER *Section + ) +; +// +// will not parse compressed sections +// +EFI_STATUS +VerifyFv ( + IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader + ) +; + +EFI_STATUS +VerifyFfsFile ( + IN EFI_FFS_FILE_HEADER *FfsHeader + ) +; + +/*++ + +Routine Description: + + Verify the current pointer points to a FFS file header. + +Arguments: + + FfsHeader Pointer to an alleged FFS file. + +Returns: + + EFI_SUCCESS The Ffs header is valid. + EFI_NOT_FOUND This "file" is the beginning of free space. + EFI_VOLUME_CORRUPTED The Ffs header is not valid. + +--*/ +UINT32 +GetLength ( + UINT8 *ThreeByteLength + ) +; + +/*++ + +Routine Description: + + Converts a three byte length value into a UINT32. + +Arguments: + + ThreeByteLength Pointer to the first of the 3 byte length. + +Returns: + + UINT32 Size of the section + +--*/ +EFI_STATUS +GetErasePolarity ( + OUT BOOLEAN *ErasePolarity + ) +; + +/*++ + +Routine Description: + + This function returns with the FV erase polarity. If the erase polarity + for a bit is 1, the function return TRUE. + +Arguments: + + ErasePolarity A pointer to the erase polarity. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + +--*/ +UINT8 +GetFileState ( + IN BOOLEAN ErasePolarity, + IN EFI_FFS_FILE_HEADER *FfsHeader + ) +; + +/*++ + +Routine Description: + + This function returns a the highest state bit in the FFS that is set. + It in no way validate the FFS file. + +Arguments: + + ErasePolarity The erase polarity for the file state bits. + FfsHeader Pointer to a FFS file. + +Returns: + + UINT8 The hightest set state of the file. + +--*/ +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Makefile new file mode 100644 index 0000000000..464d0e9930 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/Makefile @@ -0,0 +1,145 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +TARGET_NAME = Common +TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +TARGET_LIB = $(EDK_TOOLS_OUTPUT)\Common.lib +TARGET_SOURCE_DIR = $(COMMON_SOURCE) + +OBJECTS = "$(EDK_TOOLS_OUTPUT)\ParseInf.obj" \ + "$(EDK_TOOLS_OUTPUT)\EfiCompress.obj" \ + "$(EDK_TOOLS_OUTPUT)\TianoCompress.obj" \ + "$(EDK_TOOLS_OUTPUT)\Decompress.obj" \ + "$(EDK_TOOLS_OUTPUT)\crc32.obj" \ + "$(EDK_TOOLS_OUTPUT)\CommonLib.obj" \ + "$(EDK_TOOLS_OUTPUT)\PeCoffLoader.obj" \ + "$(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.obj" \ + "$(EDK_TOOLS_OUTPUT)\FvLib.obj" \ + "$(EDK_TOOLS_OUTPUT)\EfiUtilityMsgs.obj" \ + "$(EDK_TOOLS_OUTPUT)\SimpleFileParsing.obj" \ + "$(EDK_TOOLS_OUTPUT)\MyAlloc.obj" + +# +# Build targets +# + +all: $(TARGET_LIB) + +# +# Object targets +# + +"$(EDK_TOOLS_OUTPUT)\ParseInf.obj": "$(TARGET_SOURCE_DIR)\ParseInf.c" "$(TARGET_SOURCE_DIR)\ParseInf.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\ParseInf.c" /Fo"$(EDK_TOOLS_OUTPUT)\ParseInf.obj" + +"$(EDK_TOOLS_OUTPUT)\MyAlloc.obj": "$(TARGET_SOURCE_DIR)\MyAlloc.c" "$(TARGET_SOURCE_DIR)\MyAlloc.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\MyAlloc.c" /Fo"$(EDK_TOOLS_OUTPUT)\MyAlloc.obj" + +"$(EDK_TOOLS_OUTPUT)\EfiCompress.obj": "$(TARGET_SOURCE_DIR)\EfiCompress.c" "$(TARGET_SOURCE_DIR)\Compress.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\EfiCompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\EfiCompress.obj" + +"$(EDK_TOOLS_OUTPUT)\TianoCompress.obj": "$(TARGET_SOURCE_DIR)\TianoCompress.c" "$(TARGET_SOURCE_DIR)\Compress.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\TianoCompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\TianoCompress.obj" + +"$(EDK_TOOLS_OUTPUT)\Decompress.obj": "$(TARGET_SOURCE_DIR)\Decompress.c" "$(TARGET_SOURCE_DIR)\Decompress.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\Decompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\Decompress.obj" + +"$(EDK_TOOLS_OUTPUT)\crc32.obj": "$(TARGET_SOURCE_DIR)\crc32.c" "$(TARGET_SOURCE_DIR)\crc32.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\crc32.c" /Fo"$(EDK_TOOLS_OUTPUT)\crc32.obj" + +"$(EDK_TOOLS_OUTPUT)\CommonLib.obj": "$(TARGET_SOURCE_DIR)\CommonLib.c" "$(TARGET_SOURCE_DIR)\CommonLib.h" $(EDK_SOURCE)\Foundation\Include\TianoCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\CommonLib.c" /Fo"$(EDK_TOOLS_OUTPUT)\CommonLib.obj" + +"$(EDK_TOOLS_OUTPUT)\PeCoffLoader.obj": "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)\PeCoffLoaderEx.h" "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\PeCoffLoader.c" +# +# This tool is built differently based on the target processor architecture. +# PE32/PE32+ headers are different for IA32 and IPF, so copy the correct file +# to the tools directory and include it in the build. +# Also copy PeCoffLoaderEx.h because it contains the checks for valid image +# type. +# + @copy "$(EDK_SOURCE)\Foundation\Include\$(PROCESSOR)\EfiPeOptionalHeader.h" $(EDK_TOOLS_OUTPUT) + @copy "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)\PeCoffLoaderEx.h" $(EDK_TOOLS_OUTPUT) + $(CC) -I $(EDK_TOOLS_OUTPUT) $(C_FLAGS) -I "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)" "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\PeCoffLoader.c" /Fo"$(EDK_TOOLS_OUTPUT)\PeCoffLoader.obj" + +"$(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.obj": "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)\PeCoffLoaderEx.c" + $(CC) $(C_FLAGS) "$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)\PeCoffLoaderEx.c" /Fo"$(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.obj" + +"$(EDK_TOOLS_OUTPUT)\FvLib.obj": "$(TARGET_SOURCE_DIR)\FvLib.c" "$(TARGET_SOURCE_DIR)\FvLib.h" $(EDK_SOURCE)\Sample\Include\Efi2WinNt.h $(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\FvLib.c" /Fo"$(EDK_TOOLS_OUTPUT)\FvLib.obj" + +"$(EDK_TOOLS_OUTPUT)\EfiUtilityMsgs.obj": "$(TARGET_SOURCE_DIR)\EfiUtilityMsgs.c" "$(TARGET_SOURCE_DIR)\EfiUtilityMsgs.h" + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\EfiUtilityMsgs.c" /Fo"$(EDK_TOOLS_OUTPUT)\EfiUtilityMsgs.obj" + +"$(EDK_TOOLS_OUTPUT)\SimpleFileParsing.obj" : "$(TARGET_SOURCE_DIR)\SimpleFileParsing.c" "$(TARGET_SOURCE_DIR)\SimpleFileParsing.h" + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\SimpleFileParsing.c" /Fo"$(EDK_TOOLS_OUTPUT)\SimpleFileParsing.obj" + +# +# Build LIB +# + +# +# Add Binary Build description for this lib. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib)) +$(TARGET_LIB): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib $(TARGET_LIB) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb /Y +!ELSE +$(TARGET_LIB): $(OBJECTS) + $(LIB_EXE) $(LIB_FLAGS) $(OBJECTS) /OUT:$(TARGET_LIB) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_LIB) copy $(TARGET_LIB) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).lib /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\ParseInf.* del /q $(EDK_TOOLS_OUTPUT)\ParseInf.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\ParsePeim.* del /q $(EDK_TOOLS_OUTPUT)\ParsePeim.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\EfiCompress.* del /q $(EDK_TOOLS_OUTPUT)\EfiCompress.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\TianoCompress.* del /q $(EDK_TOOLS_OUTPUT)\TianoCompress.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\Decompress.* del /q $(EDK_TOOLS_OUTPUT)\Decompress.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\crc32.* del /q $(EDK_TOOLS_OUTPUT)\crc32.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\CommonLib.* del /q $(EDK_TOOLS_OUTPUT)\CommonLib.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\PeCoffLoader.* del /q $(EDK_TOOLS_OUTPUT)\PeCoffLoader.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.* del /q $(EDK_TOOLS_OUTPUT)\PeCoffLoaderEx.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\FvLib.* del /q $(EDK_TOOLS_OUTPUT)\FvLib.* > NUL + @if exist $(TARGET_LIB) del $(TARGET_LIB) diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.c new file mode 100644 index 0000000000..39fddf7428 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.c @@ -0,0 +1,516 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MyAlloc.c + +Abstract: + + File for memory allocation tracking functions. + +--*/ + +#include "MyAlloc.h" + +#if USE_MYALLOC +// +// Get back to original alloc/free calls. +// +#undef malloc +#undef calloc +#undef realloc +#undef free +// +// Start of allocation list. +// +static MY_ALLOC_STRUCT *MyAllocData = NULL; + +// +// +// +static UINT32 MyAllocHeadMagik = MYALLOC_HEAD_MAGIK; +static UINT32 MyAllocTailMagik = MYALLOC_TAIL_MAGIK; + +// +// //////////////////////////////////////////////////////////////////////////// +// +// +VOID +MyCheck ( + BOOLEAN Final, + UINT8 File[], + UINTN Line + ) +// *++ +// Description: +// +// Check for corruptions in the allocated memory chain. If a corruption +// is detection program operation stops w/ an exit(1) call. +// +// Parameters: +// +// Final := When FALSE, MyCheck() returns if the allocated memory chain +// has not been corrupted. When TRUE, MyCheck() returns if there +// are no un-freed allocations. If there are un-freed allocations, +// they are displayed and exit(1) is called. +// +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// n/a +// +// --*/ +// +{ + MY_ALLOC_STRUCT *Tmp; + + // + // Check parameters. + // + if (File == NULL || Line == 0) { + printf ( + "\nMyCheck(Final=%u, File=%xh, Line=%u)" + "Invalid parameter(s).\n", + Final, + File, + Line + ); + + exit (1); + } + + if (strlen (File) == 0) { + printf ( + "\nMyCheck(Final=%u, File=%s, Line=%u)" + "Invalid parameter.\n", + Final, + File, + Line + ); + + exit (1); + } + // + // Check structure contents. + // + for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) { + if (memcmp(Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik) || + memcmp(&Tmp->Buffer[Tmp->Size + sizeof(UINT32)], &MyAllocTailMagik, sizeof MyAllocTailMagik)) { + break; + } + } + // + // If Tmp is not NULL, the structure is corrupt. + // + if (Tmp != NULL) { + printf ( + "\nMyCheck(Final=%u, File=%s, Line=%u)""\nStructure corrupted!" + "\nFile=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n", + Final, + File, + Line, + Tmp->File, + Tmp->Line, + Tmp->Size, + *(UINT32 *) (Tmp->Buffer), + *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)]) + ); + + exit (1); + } + // + // If Final is TRUE, display the state of the structure chain. + // + if (Final) { + if (MyAllocData != NULL) { + printf ( + "\nMyCheck(Final=%u, File=%s, Line=%u)" + "\nSome allocated items have not been freed.\n", + Final, + File, + Line + ); + + for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) { + printf ( + "File=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n", + Tmp->File, + Tmp->Line, + Tmp->Size, + *(UINT32 *) (Tmp->Buffer), + *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)]) + ); + } + } + } +} +// +// //////////////////////////////////////////////////////////////////////////// +// +// +VOID * +MyAlloc ( + UINTN Size, + UINT8 File[], + UINTN Line + ) +// *++ +// Description: +// +// Allocate a new link in the allocation chain along with enough storage +// for the File[] string, requested Size and alignment overhead. If +// memory cannot be allocated or the allocation chain has been corrupted, +// exit(1) will be called. +// +// Parameters: +// +// Size := Number of bytes (UINT8) requested by the called. +// Size cannot be zero. +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// Pointer to the caller's buffer. +// +// --*/ +// +{ + MY_ALLOC_STRUCT *Tmp; + UINTN Len; + + // + // Check for invalid parameters. + // + if (Size == 0 || File == NULL || Line == 0) { + printf ( + "\nMyAlloc(Size=%u, File=%xh, Line=%u)" + "\nInvalid parameter(s).\n", + Size, + File, + Line + ); + + exit (1); + } + + Len = strlen (File); + if (Len == 0) { + printf ( + "\nMyAlloc(Size=%u, File=%s, Line=%u)" + "\nInvalid parameter.\n", + Size, + File, + Line + ); + + exit (1); + } + // + // Check the allocation list for corruption. + // + MyCheck (0, __FILE__, __LINE__); + + // + // Allocate a new entry. + // + Tmp = calloc ( + 1, + sizeof (MY_ALLOC_STRUCT) + Len + 1 + sizeof (UINT64) + Size + (sizeof MyAllocHeadMagik) + (sizeof MyAllocTailMagik) + ); + + if (Tmp == NULL) { + printf ( + "\nMyAlloc(Size=%u, File=%s, Line=%u)" + "\nOut of memory.\n", + Size, + File, + Line + ); + + exit (1); + } + // + // Fill in the new entry. + // + Tmp->File = ((UINT8 *) Tmp) + sizeof (MY_ALLOC_STRUCT); + strcpy (Tmp->File, File); + Tmp->Line = Line; + Tmp->Size = Size; + Tmp->Buffer = (UINT8 *) (((UINTN) Tmp + Len + 9) &~7); + + memcpy (Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik); + + memcpy ( + &Tmp->Buffer[Size + sizeof (UINT32)], + &MyAllocTailMagik, + sizeof MyAllocTailMagik + ); + + Tmp->Next = MyAllocData; + Tmp->Cksum = (UINTN) Tmp + (UINTN) (Tmp->Next) + Tmp->Line + Tmp->Size + (UINTN) (Tmp->File) + (UINTN) (Tmp->Buffer); + + MyAllocData = Tmp; + + return Tmp->Buffer + sizeof (UINT32); +} +// +// //////////////////////////////////////////////////////////////////////////// +// +// +VOID * +MyRealloc ( + VOID *Ptr, + UINTN Size, + UINT8 File[], + UINTN Line + ) +// *++ +// Description: +// +// This does a MyAlloc(), memcpy() and MyFree(). There is no optimization +// for shrinking or expanding buffers. An invalid parameter will cause +// MyRealloc() to fail with a call to exit(1). +// +// Parameters: +// +// Ptr := Pointer to the caller's buffer to be re-allocated. +// +// Size := Size of new buffer. Size cannot be zero. +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// Pointer to new caller's buffer. +// +// --*/ +// +{ + MY_ALLOC_STRUCT *Tmp; + VOID *Buffer; + + // + // Check for invalid parameter(s). + // + if (Size == 0 || File == NULL || Line == 0) { + printf ( + "\nMyRealloc(Ptr=%xh, Size=%u, File=%xh, Line=%u)" + "\nInvalid parameter(s).\n", + Ptr, + Size, + File, + Line + ); + + exit (1); + } + + if (strlen (File) == 0) { + printf ( + "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)" + "\nInvalid parameter.\n", + Ptr, + Size, + File, + Line + ); + + exit (1); + } + // + // Find existing buffer in allocation list. + // + if (Ptr == NULL) { + Tmp = NULL; + } else if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) { + Tmp = MyAllocData; + } else { + for (Tmp = MyAllocData;; Tmp = Tmp->Next) { + if (Tmp->Next == NULL) { + printf ( + "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)" + "\nCould not find buffer.\n", + Ptr, + Size, + File, + Line + ); + + exit (1); + } + + Tmp = Tmp->Next; + } + } + // + // Allocate new buffer, copy old data, free old buffer. + // + Buffer = MyAlloc (Size, File, Line); + + if (Buffer != NULL && Tmp != NULL) { + memcpy ( + Buffer, + &Tmp->Buffer[sizeof (UINT32)], + ((Size <= Tmp->Size) ? Size : Tmp->Size) + ); + + MyFree (Ptr, __FILE__, __LINE__); + } + + return Buffer; +} +// +// //////////////////////////////////////////////////////////////////////////// +// +// +VOID +MyFree ( + VOID *Ptr, + UINT8 File[], + UINTN Line + ) +// *++ +// Description: +// +// Release a previously allocated buffer. Invalid parameters will cause +// MyFree() to fail with an exit(1) call. +// +// Parameters: +// +// Ptr := Pointer to the caller's buffer to be freed. +// A NULL pointer will be ignored. +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// n/a +// +// --*/ +// +{ + MY_ALLOC_STRUCT *Tmp; + MY_ALLOC_STRUCT *Tmp2; + + // + // Check for invalid parameter(s). + // + if (File == NULL || Line == 0) { + printf ( + "\nMyFree(Ptr=%xh, File=%xh, Line=%u)" + "\nInvalid parameter(s).\n", + Ptr, + File, + Line + ); + + exit (1); + } + + if (strlen (File) == 0) { + printf ( + "\nMyFree(Ptr=%xh, File=%s, Line=%u)" + "\nInvalid parameter.\n", + Ptr, + File, + Line + ); + + exit (1); + } + // + // Freeing NULL is always valid. + // + if (Ptr == NULL) { + return ; + } + // + // Fail if nothing is allocated. + // + if (MyAllocData == NULL) { + printf ( + "\nMyFree(Ptr=%xh, File=%s, Line=%u)" + "\nCalled before memory allocated.\n", + Ptr, + File, + Line + ); + + exit (1); + } + // + // Check for corrupted allocation list. + // + MyCheck (0, __FILE__, __LINE__); + + // + // Need special check for first item in list. + // + if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) { + // + // Unlink first item in list. + // + Tmp = MyAllocData; + MyAllocData = MyAllocData->Next; + } else { + // + // Walk list looking for matching item. + // + for (Tmp = MyAllocData;; Tmp = Tmp->Next) { + // + // Fail if end of list is reached. + // + if (Tmp->Next == NULL) { + printf ( + "\nMyFree(Ptr=%xh, File=%s, Line=%u)\n" + "\nNot found.\n", + Ptr, + File, + Line + ); + + exit (1); + } + // + // Leave loop when match is found. + // + if (&Tmp->Next->Buffer[sizeof (UINT32)] == Ptr) { + break; + } + } + // + // Unlink item from list. + // + Tmp2 = Tmp->Next; + Tmp->Next = Tmp->Next->Next; + Tmp = Tmp2; + } + // + // Release item. + // + free (Tmp); +} + +#endif /* USE_MYALLOC */ + +/* eof - MyAlloc.c */ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.h new file mode 100644 index 0000000000..2d195c2561 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/MyAlloc.h @@ -0,0 +1,222 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MyAlloc.h + +Abstract: + + Header file for memory allocation tracking functions. + +--*/ + +#ifndef _MYALLOC_H_ +#define _MYALLOC_H_ + +#include +#include +#include + +#include "Tiano.h" + +// +// Default operation is to use the memory allocation tracking functions. +// To over-ride add "#define USE_MYALLOC 0" to your program header and/or +// source files as needed. Or, just do not include this header file in +// your project. +// +#ifndef USE_MYALLOC +#define USE_MYALLOC 1 +#endif + +#if USE_MYALLOC +// +// Replace C library allocation routines with MyAlloc routines. +// +#define malloc(size) MyAlloc ((size), __FILE__, __LINE__) +#define calloc(count, size) MyAlloc ((count) * (size), __FILE__, __LINE__) +#define realloc(ptr, size) MyRealloc ((ptr), (size), __FILE__, __LINE__) +#define free(ptr) MyFree ((ptr), __FILE__, __LINE__) +#define alloc_check(final) MyCheck ((final), __FILE__, __LINE__) + +// +// Structure for checking/tracking memory allocations. +// +typedef struct MyAllocStruct { + UINTN Cksum; + struct MyAllocStruct *Next; + UINTN Line; + UINTN Size; + UINT8 *File; + UINT8 *Buffer; +} MY_ALLOC_STRUCT; +// +// Cksum := (UINTN)This + (UINTN)Next + Line + Size + (UINTN)File + +// (UINTN)Buffer; +// +// Next := Pointer to next allocation structure in the list. +// +// Line := __LINE__ +// +// Size := Size of allocation request. +// +// File := Pointer to __FILE__ string stored immediately following +// MY_ALLOC_STRUCT in memory. +// +// Buffer := Pointer to UINT32 aligned storage immediately following +// the NULL terminated __FILE__ string. This is UINT32 +// aligned because the underflow signature is 32-bits and +// this will place the first caller address on a 64-bit +// boundary. +// +// +// Signatures used to check for buffer overflow/underflow conditions. +// +#define MYALLOC_HEAD_MAGIK 0xBADFACED +#define MYALLOC_TAIL_MAGIK 0xDEADBEEF + +VOID +MyCheck ( + BOOLEAN Final, + UINT8 File[], + UINTN Line + ) +; +// +// *++ +// Description: +// +// Check for corruptions in the allocated memory chain. If a corruption +// is detection program operation stops w/ an exit(1) call. +// +// Parameters: +// +// Final := When FALSE, MyCheck() returns if the allocated memory chain +// has not been corrupted. When TRUE, MyCheck() returns if there +// are no un-freed allocations. If there are un-freed allocations, +// they are displayed and exit(1) is called. +// +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// n/a +// +// --*/ +// +VOID * +MyAlloc ( + UINTN Size, + UINT8 File[], + UINTN Line + ) +; +// +// *++ +// Description: +// +// Allocate a new link in the allocation chain along with enough storage +// for the File[] string, requested Size and alignment overhead. If +// memory cannot be allocated or the allocation chain has been corrupted, +// exit(1) will be called. +// +// Parameters: +// +// Size := Number of bytes (UINT8) requested by the called. +// Size cannot be zero. +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// Pointer to the caller's buffer. +// +// --*/ +// +VOID * +MyRealloc ( + VOID *Ptr, + UINTN Size, + UINT8 File[], + UINTN Line + ) +; +// +// *++ +// Description: +// +// This does a MyAlloc(), memcpy() and MyFree(). There is no optimization +// for shrinking or expanding buffers. An invalid parameter will cause +// MyRealloc() to fail with a call to exit(1). +// +// Parameters: +// +// Ptr := Pointer to the caller's buffer to be re-allocated. +// Ptr cannot be NULL. +// +// Size := Size of new buffer. Size cannot be zero. +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// Pointer to new caller's buffer. +// +// --*/ +// +VOID +MyFree ( + VOID *Ptr, + UINT8 File[], + UINTN Line + ) +; +// +// *++ +// Description: +// +// Release a previously allocated buffer. Invalid parameters will cause +// MyFree() to fail with an exit(1) call. +// +// Parameters: +// +// Ptr := Pointer to the caller's buffer to be freed. +// A NULL pointer will be ignored. +// +// File := Set to __FILE__ by macro expansion. +// +// Line := Set to __LINE__ by macro expansion. +// +// Returns: +// +// n/a +// +// --*/ +// +#else /* USE_MYALLOC */ + +// +// Nothing to do when USE_MYALLOC is zero. +// +#define alloc_check(final) + +#endif /* USE_MYALLOC */ +#endif /* _MYALLOC_H_ */ + +/* eof - MyAlloc.h */ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c new file mode 100644 index 0000000000..159d81b207 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c @@ -0,0 +1,625 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ParseInf.c + +Abstract: + + This contains some useful functions for parsing INF files. + +--*/ + +#include "ParseInf.h" +#include +#include +#include + +CHAR8 * +ReadLine ( + IN MEMORY_FILE *InputFile, + IN OUT CHAR8 *InputBuffer, + IN UINTN MaxLength + ) +/*++ + +Routine Description: + + This function reads a line, stripping any comments. + The function reads a string from the input stream argument and stores it in + the input string. ReadLine reads characters from the current file position + to and including the first newline character, to the end of the stream, or + until the number of characters read is equal to MaxLength - 1, whichever + comes first. The newline character, if read, is replaced with a \0. + +Arguments: + + InputFile Memory file image. + InputBuffer Buffer to read into, must be _MAX_PATH size. + MaxLength The maximum size of the input buffer. + +Returns: + + NULL if error or EOF + InputBuffer otherwise + +--*/ +{ + CHAR8 *CharPtr; + CHAR8 *EndOfLine; + UINTN CharsToCopy; + + // + // Verify input parameters are not null + // + assert (InputBuffer); + assert (InputFile->FileImage); + assert (InputFile->Eof); + assert (InputFile->CurrentFilePointer); + + // + // Check for end of file condition + // + if (InputFile->CurrentFilePointer >= InputFile->Eof) { + return NULL; + } + // + // Find the next newline char + // + EndOfLine = strchr (InputFile->CurrentFilePointer, '\n'); + + // + // Determine the number of characters to copy. + // + if (EndOfLine == 0) { + // + // If no newline found, copy to the end of the file. + // + CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer; + } else if (EndOfLine >= InputFile->Eof) { + // + // If the newline found was beyond the end of file, copy to the eof. + // + CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer; + } else { + // + // Newline found in the file. + // + CharsToCopy = EndOfLine - InputFile->CurrentFilePointer; + } + // + // If the end of line is too big for the current buffer, set it to the max + // size of the buffer (leaving room for the \0. + // + if (CharsToCopy > MaxLength - 1) { + CharsToCopy = MaxLength - 1; + } + // + // Copy the line. + // + memcpy (InputBuffer, InputFile->CurrentFilePointer, CharsToCopy); + + // + // Add the null termination over the 0x0D + // + InputBuffer[CharsToCopy - 1] = '\0'; + + // + // Increment the current file pointer (include the 0x0A) + // + InputFile->CurrentFilePointer += CharsToCopy + 1; + + // + // Strip any comments + // + CharPtr = strstr (InputBuffer, "//"); + if (CharPtr != 0) { + CharPtr[0] = 0; + } + // + // Return the string + // + return InputBuffer; +} + +BOOLEAN +FindSection ( + IN MEMORY_FILE *InputFile, + IN CHAR8 *Section + ) +/*++ + +Routine Description: + + This function parses a file from the beginning to find a section. + The section string may be anywhere within a line. + +Arguments: + + InputFile Memory file image. + Section Section to search for + +Returns: + + FALSE if error or EOF + TRUE if section found + +--*/ +{ + CHAR8 InputBuffer[_MAX_PATH]; + CHAR8 *CurrentToken; + + // + // Verify input is not NULL + // + assert (InputFile->FileImage); + assert (InputFile->Eof); + assert (InputFile->CurrentFilePointer); + assert (Section); + + // + // Rewind to beginning of file + // + InputFile->CurrentFilePointer = InputFile->FileImage; + + // + // Read lines until the section is found + // + while (InputFile->CurrentFilePointer < InputFile->Eof) { + // + // Read a line + // + ReadLine (InputFile, InputBuffer, _MAX_PATH); + + // + // Check if the section is found + // + CurrentToken = strstr (InputBuffer, Section); + if (CurrentToken != NULL) { + return TRUE; + } + } + + return FALSE; +} + +EFI_STATUS +FindToken ( + IN MEMORY_FILE *InputFile, + IN CHAR8 *Section, + IN CHAR8 *Token, + IN UINTN Instance, + OUT CHAR8 *Value + ) +/*++ + +Routine Description: + + Finds a token value given the section and token to search for. + +Arguments: + + InputFile Memory file image. + Section The section to search for, a string within []. + Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file. + Instance The instance of the token to search for. Zero is the first instance. + Value The string that holds the value following the =. Must be _MAX_PATH in size. + +Returns: + + EFI_SUCCESS Value found. + EFI_ABORTED Format error detected in INF file. + EFI_INVALID_PARAMETER Input argument was null. + EFI_LOAD_ERROR Error reading from the file. + EFI_NOT_FOUND Section/Token/Value not found. + +--*/ +{ + CHAR8 InputBuffer[_MAX_PATH]; + CHAR8 *CurrentToken; + BOOLEAN ParseError; + BOOLEAN ReadError; + UINTN Occurrance; + + // + // Check input parameters + // + if (InputFile->FileImage == NULL || + InputFile->Eof == NULL || + InputFile->CurrentFilePointer == NULL || + Section == NULL || + strlen (Section) == 0 || + Token == NULL || + strlen (Token) == 0 || + Value == NULL + ) { + return EFI_INVALID_PARAMETER; + } + // + // Initialize error codes + // + ParseError = FALSE; + ReadError = FALSE; + + // + // Initialize our instance counter for the search token + // + Occurrance = 0; + + if (FindSection (InputFile, Section)) { + // + // Found the desired section, find and read the desired token + // + do { + // + // Read a line from the file + // + if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) { + // + // Error reading from input file + // + ReadError = TRUE; + break; + } + // + // Get the first non-whitespace string + // + CurrentToken = strtok (InputBuffer, " \t\n"); + if (CurrentToken == NULL) { + // + // Whitespace line found (or comment) so continue + // + CurrentToken = InputBuffer; + continue; + } + // + // Make sure we have not reached the end of the current section + // + if (CurrentToken[0] == '[') { + break; + } + // + // Compare the current token with the desired token + // + if (strcmp (CurrentToken, Token) == 0) { + // + // Found it + // + // + // Check if it is the correct instance + // + if (Instance == Occurrance) { + // + // Copy the contents following the = + // + CurrentToken = strtok (NULL, "= \t\n"); + if (CurrentToken == NULL) { + // + // Nothing found, parsing error + // + ParseError = TRUE; + } else { + // + // Copy the current token to the output value + // + strcpy (Value, CurrentToken); + return EFI_SUCCESS; + } + } else { + // + // Increment the occurrance found + // + Occurrance++; + } + } + } while ( + !ParseError && + !ReadError && + InputFile->CurrentFilePointer < InputFile->Eof && + CurrentToken[0] != '[' && + Occurrance <= Instance + ); + } + // + // Distinguish between read errors and INF file format errors. + // + if (ReadError) { + return EFI_LOAD_ERROR; + } + + if (ParseError) { + return EFI_ABORTED; + } + + return EFI_NOT_FOUND; +} + +EFI_STATUS +StringToGuid ( + IN CHAR8 *AsciiGuidBuffer, + OUT EFI_GUID *GuidBuffer + ) +/*++ + +Routine Description: + + Converts a string to an EFI_GUID. The string must be in the + xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format. + +Arguments: + + AsciiGuidBuffer - pointer to ascii string + GuidBuffer - pointer to destination Guid + +Returns: + + EFI_ABORTED Could not convert the string + EFI_SUCCESS The string was successfully converted + EFI_INVALID_PARAMETER Input parameter is invalid. + +--*/ +{ + INT32 Index; + UINTN Data1; + UINTN Data2; + UINTN Data3; + UINTN Data4[8]; + + if (AsciiGuidBuffer == NULL || GuidBuffer == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Scan the guid string into the buffer + // + Index = sscanf ( + AsciiGuidBuffer, + "%08x-%04x-%04x-%02x%02x-%02hx%02hx%02hx%02hx%02hx%02hx", + &Data1, + &Data2, + &Data3, + &Data4[0], + &Data4[1], + &Data4[2], + &Data4[3], + &Data4[4], + &Data4[5], + &Data4[6], + &Data4[7] + ); + + // + // Verify the correct number of items were scanned. + // + if (Index != 11) { + printf ("ERROR: Malformed GUID \"%s\".\n\n", AsciiGuidBuffer); + return EFI_ABORTED; + } + // + // Copy the data into our GUID. + // + GuidBuffer->Data1 = (UINT32) Data1; + GuidBuffer->Data2 = (UINT16) Data2; + GuidBuffer->Data3 = (UINT16) Data3; + GuidBuffer->Data4[0] = (UINT8) Data4[0]; + GuidBuffer->Data4[1] = (UINT8) Data4[1]; + GuidBuffer->Data4[2] = (UINT8) Data4[2]; + GuidBuffer->Data4[3] = (UINT8) Data4[3]; + GuidBuffer->Data4[4] = (UINT8) Data4[4]; + GuidBuffer->Data4[5] = (UINT8) Data4[5]; + GuidBuffer->Data4[6] = (UINT8) Data4[6]; + GuidBuffer->Data4[7] = (UINT8) Data4[7]; + + return EFI_SUCCESS; +} + +EFI_STATUS +AsciiStringToUint64 ( + IN CONST CHAR8 *AsciiString, + IN BOOLEAN IsHex, + OUT UINT64 *ReturnValue + ) +/*++ + +Routine Description: + + Converts a null terminated ascii string that represents a number into a + UINT64 value. A hex number may be preceeded by a 0x, but may not be + succeeded by an h. A number without 0x or 0X is considered to be base 10 + unless the IsHex input is true. + +Arguments: + + AsciiString The string to convert. + IsHex Force the string to be treated as a hex number. + ReturnValue The return value. + +Returns: + + EFI_SUCCESS Number successfully converted. + EFI_ABORTED Invalid character encountered. + +--*/ +{ + UINT8 Index; + UINT64 HexNumber; + CHAR8 CurrentChar; + + // + // Initialize the result + // + HexNumber = 0; + + // + // Add each character to the result + // + if (IsHex || (AsciiString[0] == '0' && (AsciiString[1] == 'x' || AsciiString[1] == 'X'))) { + // + // Verify string is a hex number + // + for (Index = 2; Index < strlen (AsciiString); Index++) { + if (isxdigit (AsciiString[Index]) == 0) { + return EFI_ABORTED; + } + } + // + // Convert the hex string. + // + for (Index = 2; AsciiString[Index] != '\0'; Index++) { + CurrentChar = AsciiString[Index]; + HexNumber *= 16; + if (CurrentChar >= '0' && CurrentChar <= '9') { + HexNumber += CurrentChar - '0'; + } else if (CurrentChar >= 'a' && CurrentChar <= 'f') { + HexNumber += CurrentChar - 'a' + 10; + } else if (CurrentChar >= 'A' && CurrentChar <= 'F') { + HexNumber += CurrentChar - 'A' + 10; + } else { + // + // Unrecognized character + // + return EFI_ABORTED; + } + } + + *ReturnValue = HexNumber; + } else { + // + // Verify string is a number + // + for (Index = 0; Index < strlen (AsciiString); Index++) { + if (isdigit (AsciiString[Index]) == 0) { + return EFI_ABORTED; + } + } + + *ReturnValue = atol (AsciiString); + } + + return EFI_SUCCESS; +}; + +CHAR8 * +ReadLineInStream ( + IN FILE *InputFile, + IN OUT CHAR8 *InputBuffer + ) +/*++ + +Routine Description: + + This function reads a line, stripping any comments. + // BUGBUG: This is obsolete once genmake goes away... + +Arguments: + + InputFile Stream pointer. + InputBuffer Buffer to read into, must be _MAX_PATH size. + +Returns: + + NULL if error or EOF + InputBuffer otherwise + +--*/ +{ + CHAR8 *CharPtr; + + // + // Verify input parameters are not null + // + assert (InputFile); + assert (InputBuffer); + + // + // Read a line + // + if (fgets (InputBuffer, _MAX_PATH, InputFile) == NULL) { + return NULL; + } + // + // Strip any comments + // + CharPtr = strstr (InputBuffer, "//"); + if (CharPtr != 0) { + CharPtr[0] = 0; + } + + CharPtr = strstr (InputBuffer, "#"); + if (CharPtr != 0) { + CharPtr[0] = 0; + } + // + // Return the string + // + return InputBuffer; +} + +BOOLEAN +FindSectionInStream ( + IN FILE *InputFile, + IN CHAR8 *Section + ) +/*++ + +Routine Description: + + This function parses a stream file from the beginning to find a section. + The section string may be anywhere within a line. + // BUGBUG: This is obsolete once genmake goes away... + +Arguments: + + InputFile Stream pointer. + Section Section to search for + +Returns: + + FALSE if error or EOF + TRUE if section found + +--*/ +{ + CHAR8 InputBuffer[_MAX_PATH]; + CHAR8 *CurrentToken; + + // + // Verify input is not NULL + // + assert (InputFile); + assert (Section); + + // + // Rewind to beginning of file + // + if (fseek (InputFile, 0, SEEK_SET) != 0) { + return FALSE; + } + // + // Read lines until the section is found + // + while (feof (InputFile) == 0) { + // + // Read a line + // + ReadLineInStream (InputFile, InputBuffer); + + // + // Check if the section is found + // + CurrentToken = strstr (InputBuffer, Section); + if (CurrentToken != NULL) { + return TRUE; + } + } + + return FALSE; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h new file mode 100644 index 0000000000..0b4fec7a1f --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h @@ -0,0 +1,233 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ParseInf.h + +Abstract: + + Header file for helper functions useful for parsing INF files. + +--*/ + +#ifndef _EFI_PARSE_INF_H +#define _EFI_PARSE_INF_H + +#include "TianoCommon.h" +#include +#include + +// +// Common data structures +// +typedef struct { + CHAR8 *FileImage; + CHAR8 *Eof; + CHAR8 *CurrentFilePointer; +} MEMORY_FILE; + +// +// Functions declarations +// +CHAR8 * +ReadLine ( + IN MEMORY_FILE *InputFile, + IN OUT CHAR8 *InputBuffer, + IN UINT32 MaxLength + ) +; + +/*++ + +Routine Description: + + This function reads a line, stripping any comments. + The function reads a string from the input stream argument and stores it in + the input string. ReadLine reads characters from the current file position + to and including the first newline character, to the end of the stream, or + until the number of characters read is equal to MaxLength - 1, whichever + comes first. The newline character, if read, is replaced with a \0. + +Arguments: + + InputFile Memory file image. + InputBuffer Buffer to read into, must be _MAX_PATH size. + MaxLength The maximum size of the input buffer. + +Returns: + + NULL if error or EOF + InputBuffer otherwise + +--*/ +BOOLEAN +FindSection ( + IN MEMORY_FILE *InputFile, + IN CHAR8 *Section + ) +; + +/*++ + +Routine Description: + + This function parses a file from the beginning to find a section. + The section string may be anywhere within a line. + +Arguments: + + InputFile Memory file image. + Section Section to search for + +Returns: + + FALSE if error or EOF + TRUE if section found + +--*/ +EFI_STATUS +FindToken ( + IN MEMORY_FILE *InputFile, + IN CHAR8 *Section, + IN CHAR8 *Token, + IN UINTN Instance, + OUT CHAR8 *Value + ) +; + +/*++ + +Routine Description: + + Finds a token value given the section and token to search for. + +Arguments: + + InputFile Memory file image. + Section The section to search for, a string within []. + Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file. + Instance The instance of the token to search for. Zero is the first instance. + Value The string that holds the value following the =. Must be _MAX_PATH in size. + +Returns: + + EFI_SUCCESS Value found. + EFI_ABORTED Format error detected in INF file. + EFI_INVALID_PARAMETER Input argument was null. + EFI_LOAD_ERROR Error reading from the file. + EFI_NOT_FOUND Section/Token/Value not found. + +--*/ +EFI_STATUS +StringToGuid ( + IN CHAR8 *AsciiGuidBuffer, + OUT EFI_GUID *GuidBuffer + ) +; + +/*++ + +Routine Description: + + Converts a string to an EFI_GUID. The string must be in the + xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format. + +Arguments: + + GuidBuffer - pointer to destination Guid + AsciiGuidBuffer - pointer to ascii string + +Returns: + + EFI_ABORTED Could not convert the string + EFI_SUCCESS The string was successfully converted + +--*/ +EFI_STATUS +AsciiStringToUint64 ( + IN CONST CHAR8 *AsciiString, + IN BOOLEAN IsHex, + OUT UINT64 *ReturnValue + ) +; + +/*++ + +Routine Description: + + Converts a null terminated ascii string that represents a number into a + UINT64 value. A hex number may be preceeded by a 0x, but may not be + succeeded by an h. A number without 0x or 0X is considered to be base 10 + unless the IsHex input is true. + +Arguments: + + AsciiString The string to convert. + IsHex Force the string to be treated as a hex number. + ReturnValue The return value. + +Returns: + + EFI_SUCCESS Number successfully converted. + EFI_ABORTED Invalid character encountered. + +--*/ +CHAR8 * +ReadLineInStream ( + IN FILE *InputFile, + IN OUT CHAR8 *InputBuffer + ) +; + +/*++ + +Routine Description: + + This function reads a line, stripping any comments. + +Arguments: + + InputFile Stream pointer. + InputBuffer Buffer to read into, must be _MAX_PATH size. + +Returns: + + NULL if error or EOF + InputBuffer otherwise + +--*/ +BOOLEAN +FindSectionInStream ( + IN FILE *InputFile, + IN CHAR8 *Section + ) +; + +/*++ + +Routine Description: + + This function parses a stream file from the beginning to find a section. + The section string may be anywhere within a line. + +Arguments: + + InputFile Stream pointer. + Section Section to search for + +Returns: + + FALSE if error or EOF + TRUE if section found + +--*/ +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.c new file mode 100644 index 0000000000..2a2fbe6d90 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.c @@ -0,0 +1,1456 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleFileParsing.c + +Abstract: + + Generic but simple file parsing routines. + +--*/ + +#include +#include +#include +#include + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" +#include "SimpleFileParsing.h" + +#define MAX_PATH 255 +// +// just in case we get in an endless loop. +// +#define MAX_NEST_DEPTH 20 +// +// number of wchars +// +#define MAX_STRING_IDENTIFIER_NAME 100 + +#define MAX_LINE_LEN 400 + +#define T_CHAR_SPACE ' ' +#define T_CHAR_NULL 0 +#define T_CHAR_CR '\r' +#define T_CHAR_TAB '\t' +#define T_CHAR_LF '\n' +#define T_CHAR_SLASH '/' +#define T_CHAR_BACKSLASH '\\' +#define T_CHAR_DOUBLE_QUOTE '"' +#define T_CHAR_LC_X 'x' +#define T_CHAR_0 '0' +#define T_CHAR_STAR '*' + +// +// We keep a linked list of these for the source files we process +// +typedef struct _SOURCE_FILE { + FILE *Fptr; + T_CHAR *FileBuffer; + T_CHAR *FileBufferPtr; + unsigned int FileSize; + char FileName[MAX_PATH]; + unsigned int LineNum; + BOOLEAN EndOfFile; + BOOLEAN SkipToHash; + struct _SOURCE_FILE *Previous; + struct _SOURCE_FILE *Next; + T_CHAR ControlCharacter; +} SOURCE_FILE; + +typedef struct { + T_CHAR *FileBufferPtr; +} FILE_POSITION; + +// +// Keep all our module globals in this structure +// +static struct { + SOURCE_FILE SourceFile; + BOOLEAN VerboseFile; + BOOLEAN VerboseToken; +} mGlobals; + +static +unsigned int +t_strcmp ( + T_CHAR *Buffer, + T_CHAR *Str + ); + +static +unsigned int +t_strncmp ( + T_CHAR *Str1, + T_CHAR *Str2, + int Len + ); + +static +unsigned int +t_strlen ( + T_CHAR *Str + ); + +static +void +RewindFile ( + SOURCE_FILE *SourceFile + ); + +static +BOOLEAN +IsWhiteSpace ( + SOURCE_FILE *SourceFile + ); + +static +unsigned int +SkipWhiteSpace ( + SOURCE_FILE *SourceFile + ); + +static +BOOLEAN +EndOfFile ( + SOURCE_FILE *SourceFile + ); + +static +void +PreprocessFile ( + SOURCE_FILE *SourceFile + ); + +static +T_CHAR * +t_strcpy ( + T_CHAR *Dest, + T_CHAR *Src + ); + +static +STATUS +ProcessIncludeFile ( + SOURCE_FILE *SourceFile, + SOURCE_FILE *ParentSourceFile + ); + +static +STATUS +ParseFile ( + SOURCE_FILE *SourceFile + ); + +static +FILE * +FindFile ( + char *FileName, + char *FoundFileName, + unsigned int FoundFileNameLen + ); + +static +STATUS +ProcessFile ( + SOURCE_FILE *SourceFile + ); + +static +STATUS +GetFilePosition ( + FILE_POSITION *Fpos + ); + +static +STATUS +SetFilePosition ( + FILE_POSITION *Fpos + ); + +STATUS +SFPInit ( + VOID + ) +/*++ + +Routine Description: + +Arguments: + None. + +Returns: + STATUS_SUCCESS always + +--*/ +{ + memset ((void *) &mGlobals, 0, sizeof (mGlobals)); + return STATUS_SUCCESS; +} + +unsigned +int +SFPGetLineNumber ( + VOID + ) +/*++ + +Routine Description: + Return the line number of the file we're parsing. Used + for error reporting purposes. + +Arguments: + None. + +Returns: + The line number, or 0 if no file is being processed + +--*/ +{ + return mGlobals.SourceFile.LineNum; +} + +T_CHAR * +SFPGetFileName ( + VOID + ) +/*++ + +Routine Description: + Return the name of the file we're parsing. Used + for error reporting purposes. + +Arguments: + None. + +Returns: + A pointer to the file name. Null if no file is being + processed. + +--*/ +{ + if (mGlobals.SourceFile.FileName[0]) { + return mGlobals.SourceFile.FileName; + } + + return NULL; +} + +STATUS +SFPOpenFile ( + char *FileName + ) +/*++ + +Routine Description: + Open a file for parsing. + +Arguments: + FileName - name of the file to parse + +Returns: + + +--*/ +{ + STATUS Status; + t_strcpy (mGlobals.SourceFile.FileName, FileName); + Status = ProcessIncludeFile (&mGlobals.SourceFile, NULL); + return Status; +} + +BOOLEAN +SFPIsToken ( + T_CHAR *Str + ) +/*++ + +Routine Description: + Check to see if the specified token is found at + the current position in the input file. + +Arguments: + Str - the token to look for + +Returns: + TRUE - the token is next + FALSE - the token is not next + +Notes: + We do a simple string comparison on this function. It is + the responsibility of the caller to ensure that the token + is not a subset of some other token. + + The file pointer is advanced past the token in the input file. + +--*/ +{ + unsigned int Len; + SkipWhiteSpace (&mGlobals.SourceFile); + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + + if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) { + mGlobals.SourceFile.FileBufferPtr += Len; + if (mGlobals.VerboseToken) { + printf ("Token: '%s'\n", Str); + } + + return TRUE; + } + + return FALSE; +} + +BOOLEAN +SFPIsKeyword ( + T_CHAR *Str + ) +/*++ + +Routine Description: + Check to see if the specified keyword is found at + the current position in the input file. + +Arguments: + Str - keyword to look for + +Returns: + TRUE - the keyword is next + FALSE - the keyword is not next + +Notes: + A keyword is defined as a "special" string that has a non-alphanumeric + character following it. + +--*/ +{ + unsigned int Len; + SkipWhiteSpace (&mGlobals.SourceFile); + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + + if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) { + if (isalnum (mGlobals.SourceFile.FileBufferPtr[Len])) { + return FALSE; + } + + mGlobals.SourceFile.FileBufferPtr += Len; + if (mGlobals.VerboseToken) { + printf ("Token: '%s'\n", Str); + } + + return TRUE; + } + + return FALSE; +} + +BOOLEAN +SFPGetNextToken ( + T_CHAR *Str, + unsigned int Len + ) +/*++ + +Routine Description: + Get the next token from the input stream. + +Arguments: + Str - pointer to a copy of the next token + Len - size of buffer pointed to by Str + +Returns: + TRUE - next token successfully returned + FALSE - otherwise + +Notes: + Preceeding white space is ignored. + The parser's buffer pointer is advanced past the end of the + token. + +--*/ +{ + unsigned int Index; + T_CHAR TempChar; + + SkipWhiteSpace (&mGlobals.SourceFile); + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + // + // Have to have enough string for at least one char and a null-terminator + // + if (Len < 2) { + return FALSE; + } + // + // Look at the first character. If it's an identifier, then treat it + // as such + // + TempChar = mGlobals.SourceFile.FileBufferPtr[0]; + if (((TempChar >= 'a') && (TempChar <= 'z')) || ((TempChar >= 'A') && (TempChar <= 'Z')) || (TempChar == '_')) { + Str[0] = TempChar; + mGlobals.SourceFile.FileBufferPtr++; + Index = 1; + while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) { + TempChar = mGlobals.SourceFile.FileBufferPtr[0]; + if (((TempChar >= 'a') && (TempChar <= 'z')) || + ((TempChar >= 'A') && (TempChar <= 'Z')) || + ((TempChar >= '0') && (TempChar <= '9')) || + (TempChar == '_') + ) { + Str[Index] = mGlobals.SourceFile.FileBufferPtr[0]; + mGlobals.SourceFile.FileBufferPtr++; + Index++; + } else { + // + // Invalid character for symbol name, so break out + // + break; + } + } + // + // Null terminate and return success + // + Str[Index] = 0; + return TRUE; + } else if ((TempChar == ')') || (TempChar == '(') || (TempChar == '*')) { + Str[0] = mGlobals.SourceFile.FileBufferPtr[0]; + mGlobals.SourceFile.FileBufferPtr++; + Str[1] = 0; + return TRUE; + } else { + // + // Everything else is white-space (or EOF) separated + // + Index = 0; + while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) { + if (IsWhiteSpace (&mGlobals.SourceFile)) { + if (Index > 0) { + Str[Index] = 0; + return TRUE; + } + + return FALSE; + } else { + Str[Index] = mGlobals.SourceFile.FileBufferPtr[0]; + mGlobals.SourceFile.FileBufferPtr++; + Index++; + } + } + // + // See if we just ran out of file contents, but did find a token + // + if ((Index > 0) && EndOfFile (&mGlobals.SourceFile)) { + Str[Index] = 0; + return TRUE; + } + } + + return FALSE; +} + +BOOLEAN +SFPGetGuidToken ( + T_CHAR *Str, + UINT32 Len + ) +/*++ + +Routine Description: + Parse a GUID from the input stream. Stop when you discover white space. + +Arguments: + Str - pointer to a copy of the next token + Len - size of buffer pointed to by Str + +Returns: + TRUE - GUID string returned successfully + FALSE - otherwise + +--*/ +{ + UINT32 Index; + SkipWhiteSpace (&mGlobals.SourceFile); + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + + Index = 0; + while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) { + if (IsWhiteSpace (&mGlobals.SourceFile)) { + if (Index > 0) { + Str[Index] = 0; + return TRUE; + } + + return FALSE; + } else { + Str[Index] = mGlobals.SourceFile.FileBufferPtr[0]; + mGlobals.SourceFile.FileBufferPtr++; + Index++; + } + } + + return FALSE; +} + +BOOLEAN +SFPSkipToToken ( + T_CHAR *Str + ) +{ + unsigned int Len; + T_CHAR *SavePos; + Len = t_strlen (Str); + SavePos = mGlobals.SourceFile.FileBufferPtr; + SkipWhiteSpace (&mGlobals.SourceFile); + while (!EndOfFile (&mGlobals.SourceFile)) { + if (t_strncmp (Str, mGlobals.SourceFile.FileBufferPtr, Len) == 0) { + mGlobals.SourceFile.FileBufferPtr += Len; + return TRUE; + } + + mGlobals.SourceFile.FileBufferPtr++; + SkipWhiteSpace (&mGlobals.SourceFile); + } + + mGlobals.SourceFile.FileBufferPtr = SavePos; + return FALSE; +} + +BOOLEAN +SFPGetNumber ( + unsigned int *Value + ) +/*++ + +Routine Description: + Check the token at the current file position for a numeric value. + May be either decimal or hex. + +Arguments: + Value - pointer where to store the value + +Returns: + FALSE - current token is not a number + TRUE - current token is a number + +--*/ +{ + SkipWhiteSpace (&mGlobals.SourceFile); + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + + if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) { + // + // Check for hex value + // + if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) { + if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) { + return FALSE; + } + + mGlobals.SourceFile.FileBufferPtr += 2; + sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", Value); + while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) { + mGlobals.SourceFile.FileBufferPtr++; + } + + return TRUE; + } else { + *Value = atoi (mGlobals.SourceFile.FileBufferPtr); + while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) { + mGlobals.SourceFile.FileBufferPtr++; + } + + return TRUE; + } + } else { + return FALSE; + } +} + +STATUS +SFPCloseFile ( + VOID + ) +/*++ + +Routine Description: + Close the file being parsed. + +Arguments: + None. + +Returns: + STATUS_SUCCESS - the file was closed + STATUS_ERROR - no file is currently open + +--*/ +{ + if (mGlobals.SourceFile.FileBuffer != NULL) { + free (mGlobals.SourceFile.FileBuffer); + memset (&mGlobals.SourceFile, 0, sizeof (mGlobals.SourceFile)); + return STATUS_SUCCESS; + } + + return STATUS_ERROR; +} + +static +STATUS +ProcessIncludeFile ( + SOURCE_FILE *SourceFile, + SOURCE_FILE *ParentSourceFile + ) +/*++ + +Routine Description: + + Given a source file, open the file and parse it + +Arguments: + + SourceFile - name of file to parse + ParentSourceFile - for error reporting purposes, the file that #included SourceFile. + +Returns: + + Standard status. + +--*/ +{ + static unsigned int NestDepth = 0; + char FoundFileName[MAX_PATH]; + STATUS Status; + + Status = STATUS_SUCCESS; + NestDepth++; + // + // Print the file being processed. Indent so you can tell the include nesting + // depth. + // + if (mGlobals.VerboseFile) { + fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName); + fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile); + } + + // + // Make sure we didn't exceed our maximum nesting depth + // + if (NestDepth > MAX_NEST_DEPTH) { + Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth); + Status = STATUS_ERROR; + goto Finish; + } + // + // Try to open the file locally, and if that fails try along our include paths. + // + strcpy (FoundFileName, SourceFile->FileName); + if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) { + return STATUS_ERROR; + } + // + // Process the file found + // + ProcessFile (SourceFile); +Finish: + // + // Close open files and return status + // + if (SourceFile->Fptr != NULL) { + fclose (SourceFile->Fptr); + SourceFile->Fptr = NULL; + } + + return Status; +} + +static +STATUS +ProcessFile ( + SOURCE_FILE *SourceFile + ) +/*++ + +Routine Description: + + Given a source file that's been opened, read the contents into an internal + buffer and pre-process it to remove comments. + +Arguments: + + SourceFile - structure containing info on the file to process + +Returns: + + Standard status. + +--*/ +{ + // + // Get the file size, and then read the entire thing into memory. + // Allocate extra space for a terminator character. + // + fseek (SourceFile->Fptr, 0, SEEK_END); + SourceFile->FileSize = ftell (SourceFile->Fptr); + if (mGlobals.VerboseFile) { + printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize); + } + + fseek (SourceFile->Fptr, 0, SEEK_SET); + SourceFile->FileBuffer = (T_CHAR *) malloc (SourceFile->FileSize + sizeof (T_CHAR)); + if (SourceFile->FileBuffer == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + fread ((void *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr); + SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (T_CHAR))] = T_CHAR_NULL; + // + // Pre-process the file to replace comments with spaces + // + PreprocessFile (SourceFile); + SourceFile->LineNum = 1; + return STATUS_SUCCESS; +} + +static +void +PreprocessFile ( + SOURCE_FILE *SourceFile + ) +/*++ + +Routine Description: + Preprocess a file to replace all carriage returns with NULLs so + we can print lines (as part of error messages) from the file to the screen. + +Arguments: + SourceFile - structure that we use to keep track of an input file. + +Returns: + Nothing. + +--*/ +{ + BOOLEAN InComment; + BOOLEAN SlashSlashComment; + int LineNum; + + RewindFile (SourceFile); + InComment = FALSE; + SlashSlashComment = FALSE; + while (!EndOfFile (SourceFile)) { + // + // If a line-feed, then no longer in a comment if we're in a // comment + // + if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) { + SourceFile->FileBufferPtr++; + SourceFile->LineNum++; + if (InComment && SlashSlashComment) { + InComment = FALSE; + SlashSlashComment = FALSE; + } + } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) { + // + // Replace all carriage returns with a NULL so we can print stuff + // + SourceFile->FileBufferPtr[0] = 0; + SourceFile->FileBufferPtr++; + // + // Check for */ comment end + // + } else if (InComment && + !SlashSlashComment && + (SourceFile->FileBufferPtr[0] == T_CHAR_STAR) && + (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH) + ) { + SourceFile->FileBufferPtr[0] = T_CHAR_SPACE; + SourceFile->FileBufferPtr++; + SourceFile->FileBufferPtr[0] = T_CHAR_SPACE; + SourceFile->FileBufferPtr++; + InComment = FALSE; + } else if (InComment) { + SourceFile->FileBufferPtr[0] = T_CHAR_SPACE; + SourceFile->FileBufferPtr++; + // + // Check for // comments + // + } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)) { + InComment = TRUE; + SlashSlashComment = TRUE; + // + // Check for /* comment start + // + } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_STAR)) { + SourceFile->FileBufferPtr[0] = T_CHAR_SPACE; + SourceFile->FileBufferPtr++; + SourceFile->FileBufferPtr[0] = T_CHAR_SPACE; + SourceFile->FileBufferPtr++; + SlashSlashComment = FALSE; + InComment = TRUE; + } else { + SourceFile->FileBufferPtr++; + } + } + // + // Could check for end-of-file and still in a comment, but + // should not be necessary. So just restore the file pointers. + // + RewindFile (SourceFile); + // + // Dump the reformatted file if verbose mode + // + if (mGlobals.VerboseFile) { + LineNum = 1; + printf ("%04d: ", LineNum); + while (!EndOfFile (SourceFile)) { + if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) { + printf ("'\n%04d: '", ++LineNum); + } else { + printf ("%c", SourceFile->FileBufferPtr[0]); + } + + SourceFile->FileBufferPtr++; + } + + printf ("'\n"); + printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize); + RewindFile (SourceFile); + } +} + +BOOLEAN +SFPGetQuotedString ( + T_CHAR *Str, + int Length + ) +/*++ + +Routine Description: + Retrieve a quoted-string from the input file. + +Arguments: + Str - pointer to a copy of the quoted string parsed + Length - size of buffer pointed to by Str + +Returns: + TRUE - next token in input stream was a quoted string, and + the string value was returned in Str + FALSE - otherwise + +--*/ +{ + SkipWhiteSpace (&mGlobals.SourceFile); + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + + if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) { + mGlobals.SourceFile.FileBufferPtr++; + while (Length > 0) { + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + // + // Check for closing quote + // + if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) { + mGlobals.SourceFile.FileBufferPtr++; + *Str = 0; + return TRUE; + } + + *Str = mGlobals.SourceFile.FileBufferPtr[0]; + Str++; + Length--; + mGlobals.SourceFile.FileBufferPtr++; + } + } + // + // First character was not a quote, or the input string length was + // insufficient to contain the quoted string, so return failure code. + // + return FALSE; +} + +BOOLEAN +SFPIsEOF ( + VOID + ) +/*++ + +Routine Description: + Return TRUE of FALSE to indicate whether or not we've reached the end of the + file we're parsing. + +Arguments: + NA + +Returns: + TRUE - EOF reached + FALSE - otherwise + +--*/ +{ + SkipWhiteSpace (&mGlobals.SourceFile); + return EndOfFile (&mGlobals.SourceFile); +} + +#if 0 +static +T_CHAR * +GetQuotedString ( + SOURCE_FILE *SourceFile, + BOOLEAN Optional + ) +{ + T_CHAR *String; + T_CHAR *Start; + T_CHAR *Ptr; + unsigned int Len; + BOOLEAN PreviousBackslash; + + if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) { + if (Optional == FALSE) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr); + } + + return NULL; + } + + Len = 0; + SourceFile->FileBufferPtr++; + Start = Ptr = SourceFile->FileBufferPtr; + PreviousBackslash = FALSE; + while (!EndOfFile (SourceFile)) { + if ((SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) && (PreviousBackslash == FALSE)) { + break; + } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) { + Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start); + PreviousBackslash = FALSE; + } else if (SourceFile->FileBufferPtr[0] == T_CHAR_BACKSLASH) { + PreviousBackslash = TRUE; + } else { + PreviousBackslash = FALSE; + } + + SourceFile->FileBufferPtr++; + Len++; + } + + if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) { + Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start); + } else { + SourceFile->FileBufferPtr++; + } + // + // Now allocate memory for the string and save it off + // + String = (T_CHAR *) malloc ((Len + 1) * sizeof (T_CHAR)); + if (String == NULL) { + Error (NULL, 0, 0, "memory allocation failed", NULL); + return NULL; + } + // + // Copy the string from the file buffer to the local copy. + // We do no reformatting of it whatsoever at this point. + // + Ptr = String; + while (Len > 0) { + *Ptr = *Start; + Start++; + Ptr++; + Len--; + } + + *Ptr = 0; + return String; +} +#endif +static +BOOLEAN +EndOfFile ( + SOURCE_FILE *SourceFile + ) +{ + // + // The file buffer pointer will typically get updated before the End-of-file flag in the + // source file structure, so check it first. + // + if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (T_CHAR)) { + SourceFile->EndOfFile = TRUE; + return TRUE; + } + + if (SourceFile->EndOfFile) { + return TRUE; + } + + return FALSE; +} + +#if 0 +static +void +ProcessTokenInclude ( + SOURCE_FILE *SourceFile + ) +{ + char IncludeFileName[MAX_PATH]; + char *To; + unsigned int Len; + BOOLEAN ReportedError; + SOURCE_FILE IncludedSourceFile; + + ReportedError = FALSE; + if (SkipWhiteSpace (SourceFile) == 0) { + Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL); + } + // + // Should be quoted file name + // + if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL); + goto FailDone; + } + + SourceFile->FileBufferPtr++; + // + // Copy the filename as ascii to our local string + // + To = IncludeFileName; + Len = 0; + while (!EndOfFile (SourceFile)) { + if ((SourceFile->FileBufferPtr[0] == T_CHAR_CR) || (SourceFile->FileBufferPtr[0] == T_CHAR_LF)) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL); + goto FailDone; + } + + if (SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) { + SourceFile->FileBufferPtr++; + break; + } + // + // If too long, then report the error once and process until the closing quote + // + Len++; + if (!ReportedError && (Len >= sizeof (IncludeFileName))) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL); + ReportedError = TRUE; + } + + if (!ReportedError) { + *To = (T_CHAR) SourceFile->FileBufferPtr[0]; + To++; + } + + SourceFile->FileBufferPtr++; + } + + if (!ReportedError) { + *To = 0; + memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE)); + strcpy (IncludedSourceFile.FileName, IncludeFileName); + ProcessIncludeFile (&IncludedSourceFile, SourceFile); + } + + return ; +FailDone: + // + // Error recovery -- skip to next # + // + SourceFile->SkipToHash = TRUE; +} +#endif +static +BOOLEAN +IsWhiteSpace ( + SOURCE_FILE *SourceFile + ) +{ + switch (*SourceFile->FileBufferPtr) { + case T_CHAR_NULL: + case T_CHAR_CR: + case T_CHAR_SPACE: + case T_CHAR_TAB: + case T_CHAR_LF: + return TRUE; + + default: + return FALSE; + } +} + +unsigned int +SkipWhiteSpace ( + SOURCE_FILE *SourceFile + ) +{ + unsigned int Count; + + Count = 0; + while (!EndOfFile (SourceFile)) { + Count++; + switch (*SourceFile->FileBufferPtr) { + case T_CHAR_NULL: + case T_CHAR_CR: + case T_CHAR_SPACE: + case T_CHAR_TAB: + SourceFile->FileBufferPtr++; + break; + + case T_CHAR_LF: + SourceFile->FileBufferPtr++; + SourceFile->LineNum++; + break; + + default: + return Count - 1; + } + } + // + // Some tokens require trailing whitespace. If we're at the end of the + // file, then we count that as well. + // + if ((Count == 0) && (EndOfFile (SourceFile))) { + Count++; + } + + return Count; +} + +static +unsigned int +t_strcmp ( + T_CHAR *Buffer, + T_CHAR *Str + ) +/*++ + +Routine Description: + Compare two strings for equality. The string pointed to by 'Buffer' may or may not be null-terminated, + so only compare up to the length of Str. + +Arguments: + Buffer - pointer to first (possibly not null-terminated) string + Str - pointer to null-terminated string to compare to Buffer + +Returns: + Number of bytes matched if exact match + 0 if Buffer does not start with Str + +--*/ +{ + unsigned int Len; + + Len = 0; + while (*Str && (*Str == *Buffer)) { + Buffer++; + Str++; + Len++; + } + + if (*Str) { + return 0; + } + + return Len; +} + +static +unsigned int +t_strlen ( + T_CHAR *Str + ) +{ + unsigned int Len; + Len = 0; + while (*Str) { + Len++; + Str++; + } + + return Len; +} + +static +unsigned int +t_strncmp ( + T_CHAR *Str1, + T_CHAR *Str2, + int Len + ) +{ + while (Len > 0) { + if (*Str1 != *Str2) { + return Len; + } + + Len--; + Str1++; + Str2++; + } + + return 0; +} + +static +T_CHAR * +t_strcpy ( + T_CHAR *Dest, + T_CHAR *Src + ) +{ + T_CHAR *SaveDest; + SaveDest = Dest; + while (*Src) { + *Dest = *Src; + Dest++; + Src++; + } + + *Dest = 0; + return SaveDest; +} + +static +void +RewindFile ( + SOURCE_FILE *SourceFile + ) +{ + SourceFile->LineNum = 1; + SourceFile->FileBufferPtr = SourceFile->FileBuffer; + SourceFile->EndOfFile = 0; +} + +static +UINT32 +GetHexChars ( + T_CHAR *Buffer, + UINT32 BufferLen + ) +{ + UINT32 Len; + Len = 0; + while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) { + if (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) { + *Buffer = mGlobals.SourceFile.FileBufferPtr[0]; + Buffer++; + Len++; + BufferLen--; + mGlobals.SourceFile.FileBufferPtr++; + } else { + break; + } + } + // + // Null terminate if we can + // + if ((Len > 0) && (BufferLen > 0)) { + *Buffer = 0; + } + + return Len; +} + +BOOLEAN +SFPGetGuid ( + int GuidStyle, + EFI_GUID *Value + ) +/*++ + +Routine Description: + Parse a GUID from the input stream. Stop when you discover white space. + +Arguments: + GuidStyle - Style of the following GUID token + Value - pointer to EFI_GUID struct for output + +Returns: + TRUE - GUID string parsed successfully + FALSE - otherwise + + GUID styles + Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD + +--*/ +{ + UINT32 Value32; + UINT32 Index; + FILE_POSITION FPos; + T_CHAR TempString[20]; + T_CHAR TempString2[3]; + T_CHAR *From; + T_CHAR *To; + UINT32 Len; + BOOLEAN Status; + + Status = FALSE; + // + // Skip white space, then start parsing + // + SkipWhiteSpace (&mGlobals.SourceFile); + GetFilePosition (&FPos); + if (EndOfFile (&mGlobals.SourceFile)) { + return FALSE; + } + + if (GuidStyle == PARSE_GUID_STYLE_5_FIELDS) { + // + // Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD + // + Len = GetHexChars (TempString, sizeof (TempString)); + if ((Len == 0) || (Len > 8)) { + goto Done; + } + + sscanf (TempString, "%x", &Value32); + Value->Data1 = Value32; + // + // Next two UINT16 fields + // + if (mGlobals.SourceFile.FileBufferPtr[0] != '-') { + goto Done; + } + + mGlobals.SourceFile.FileBufferPtr++; + Len = GetHexChars (TempString, sizeof (TempString)); + if ((Len == 0) || (Len > 4)) { + goto Done; + } + + sscanf (TempString, "%x", &Value32); + Value->Data2 = (UINT16) Value32; + + if (mGlobals.SourceFile.FileBufferPtr[0] != '-') { + goto Done; + } + + mGlobals.SourceFile.FileBufferPtr++; + Len = GetHexChars (TempString, sizeof (TempString)); + if ((Len == 0) || (Len > 4)) { + goto Done; + } + + sscanf (TempString, "%x", &Value32); + Value->Data3 = (UINT16) Value32; + // + // Parse the "AAAA" as two bytes + // + if (mGlobals.SourceFile.FileBufferPtr[0] != '-') { + goto Done; + } + + mGlobals.SourceFile.FileBufferPtr++; + Len = GetHexChars (TempString, sizeof (TempString)); + if ((Len == 0) || (Len > 4)) { + goto Done; + } + + sscanf (TempString, "%x", &Value32); + Value->Data4[0] = (UINT8) (Value32 >> 8); + Value->Data4[1] = (UINT8) Value32; + if (mGlobals.SourceFile.FileBufferPtr[0] != '-') { + goto Done; + } + + mGlobals.SourceFile.FileBufferPtr++; + // + // Read the last 6 bytes of the GUID + // + // + Len = GetHexChars (TempString, sizeof (TempString)); + if ((Len == 0) || (Len > 12)) { + goto Done; + } + // + // Insert leading 0's to make life easier + // + if (Len != 12) { + From = TempString + Len - 1; + To = TempString + 11; + TempString[12] = 0; + while (From >= TempString) { + *To = *From; + To--; + From--; + } + + while (To >= TempString) { + *To = '0'; + To--; + } + } + // + // Now parse each byte + // + TempString2[2] = 0; + for (Index = 0; Index < 6; Index++) { + // + // Copy the two characters from the input string to something + // we can parse. + // + TempString2[0] = TempString[Index * 2]; + TempString2[1] = TempString[Index * 2 + 1]; + sscanf (TempString2, "%x", &Value32); + Value->Data4[Index + 2] = (UINT8) Value32; + } + + Status = TRUE; + } else { + // + // Unsupported GUID style + // + return FALSE; + } + +Done: + if (Status == FALSE) { + SetFilePosition (&FPos); + } + + return Status; +} + +static +STATUS +GetFilePosition ( + FILE_POSITION *Fpos + ) +{ + Fpos->FileBufferPtr = mGlobals.SourceFile.FileBufferPtr; + return STATUS_SUCCESS; +} + +static +STATUS +SetFilePosition ( + FILE_POSITION *Fpos + ) +{ + // + // Should check range of pointer + // + mGlobals.SourceFile.FileBufferPtr = Fpos->FileBufferPtr; + return STATUS_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.h new file mode 100644 index 0000000000..ee59a6d8d4 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/SimpleFileParsing.h @@ -0,0 +1,118 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + SimpleFileParsing.h + +Abstract: + + Function prototypes and defines for the simple file parsing routines. + +--*/ + +#ifndef _SIMPLE_FILE_PARSING_H_ +#define _SIMPLE_FILE_PARSING_H_ + +#define T_CHAR char + +STATUS +SFPInit ( + VOID + ) +; + +STATUS +SFPOpenFile ( + char *FileName + ) +; + +BOOLEAN +SFPIsKeyword ( + T_CHAR *Str + ) +; + +BOOLEAN +SFPIsToken ( + T_CHAR *Str + ) +; + +BOOLEAN +SFPGetNextToken ( + T_CHAR *Str, + unsigned int Len + ) +; + +BOOLEAN +SFPGetGuidToken ( + T_CHAR *Str, + UINT32 Len + ) +; + +#define PARSE_GUID_STYLE_5_FIELDS 0 + +BOOLEAN +SFPGetGuid ( + int GuidStyle, + EFI_GUID *Value + ) +; + +BOOLEAN +SFPSkipToToken ( + T_CHAR *Str + ) +; + +BOOLEAN +SFPGetNumber ( + unsigned int *Value + ) +; + +BOOLEAN +SFPGetQuotedString ( + T_CHAR *Str, + int Length + ) +; + +BOOLEAN +SFPIsEOF ( + VOID + ) +; + +STATUS +SFPCloseFile ( + VOID + ) +; + +unsigned +int +SFPGetLineNumber ( + VOID + ) +; + +T_CHAR * +SFPGetFileName ( + VOID + ) +; + +#endif // #ifndef _SIMPLE_FILE_PARSING_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/TianoCompress.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/TianoCompress.c new file mode 100644 index 0000000000..5cb13b2304 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/TianoCompress.c @@ -0,0 +1,1765 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + TianoCompress.c + +Abstract: + + Compression routine. The compression algorithm is a mixture of + LZ77 and Huffman coding. LZ77 transforms the source data into a + sequence of Original Characters and Pointers to repeated strings. + This sequence is further divided into Blocks and Huffman codings + are applied to each Block. + +--*/ + +#include +#include +#include "TianoCommon.h" +#include "Compress.h" + +// +// Macro Definitions +// +typedef INT32 NODE; +#define UINT8_MAX 0xff +#define UINT8_BIT 8 +#define THRESHOLD 3 +#define INIT_CRC 0 +#define WNDBIT 19 +#define WNDSIZ (1U << WNDBIT) +#define MAXMATCH 256 +#define BLKSIZ (1U << 14) // 16 * 1024U +#define PERC_FLAG 0x80000000U +#define CODE_BIT 16 +#define NIL 0 +#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX) +#define HASH(p, c) ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2) +#define CRCPOLY 0xA001 +#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT) + +// +// C: the Char&Len Set; P: the Position Set; T: the exTra Set +// +#define NC (UINT8_MAX + MAXMATCH + 2 - THRESHOLD) +#define CBIT 9 +#define NP (WNDBIT + 1) +#define PBIT 5 +#define NT (CODE_BIT + 3) +#define TBIT 5 +#if NT > NP +#define NPT NT +#else +#define NPT NP +#endif +// +// Function Prototypes +// +STATIC +EFI_STATUS +Compress ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize, + IN UINT8 Version + ); + +STATIC +VOID +PutDword( + IN UINT32 Data + ); + +STATIC +EFI_STATUS +AllocateMemory ( + VOID + ); + +STATIC +VOID +FreeMemory ( + VOID + ); + +STATIC +VOID +InitSlide ( + VOID + ); + +STATIC +NODE +Child ( + IN NODE NodeQ, + IN UINT8 CharC + ); + +STATIC +VOID +MakeChild ( + IN NODE NodeQ, + IN UINT8 CharC, + IN NODE NodeR + ); + +STATIC +VOID +Split ( + IN NODE Old + ); + +STATIC +VOID +InsertNode ( + VOID + ); + +STATIC +VOID +DeleteNode ( + VOID + ); + +STATIC +VOID +GetNextMatch ( + VOID + ); + +STATIC +EFI_STATUS +Encode ( + VOID + ); + +STATIC +VOID +CountTFreq ( + VOID + ); + +STATIC +VOID +WritePTLen ( + IN INT32 Number, + IN INT32 nbit, + IN INT32 Special + ); + +STATIC +VOID +WriteCLen ( + VOID + ); + +STATIC +VOID +EncodeC ( + IN INT32 Value + ); + +STATIC +VOID +EncodeP ( + IN UINT32 Value + ); + +STATIC +VOID +SendBlock ( + VOID + ); + +STATIC +VOID +Output ( + IN UINT32 c, + IN UINT32 p + ); + +STATIC +VOID +HufEncodeStart ( + VOID + ); + +STATIC +VOID +HufEncodeEnd ( + VOID + ); + +STATIC +VOID +MakeCrcTable ( + VOID + ); + +STATIC +VOID +PutBits ( + IN INT32 Number, + IN UINT32 Value + ); + +STATIC +INT32 +FreadCrc ( + OUT UINT8 *Pointer, + IN INT32 Number + ); + +STATIC +VOID +InitPutBits ( + VOID + ); + +STATIC +VOID +CountLen ( + IN INT32 Index + ); + +STATIC +VOID +MakeLen ( + IN INT32 Root + ); + +STATIC +VOID +DownHeap ( + IN INT32 Index + ); + +STATIC +VOID +MakeCode ( + IN INT32 Number, + IN UINT8 Len[ ], + OUT UINT16 Code[] + ); + +STATIC +INT32 +MakeTree ( + IN INT32 NParm, + IN UINT16 FreqParm[], + OUT UINT8 LenParm[ ], + OUT UINT16 CodeParm[] + ); + +// +// Global Variables +// +STATIC UINT8 *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit; + +STATIC UINT8 *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen; +STATIC INT16 mHeap[NC + 1]; +STATIC INT32 mRemainder, mMatchLen, mBitCount, mHeapSize, mN; +STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc; +STATIC UINT32 mCompSize, mOrigSize; + +STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], mCrcTable[UINT8_MAX + 1], + mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC], mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1]; + +STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL; + +// +// functions +// + +EFI_STATUS +TianoCompress ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize + ) +/*++ + +Routine Description: + + The internal implementation of [Efi/Tiano]Compress(). + +Arguments: + + SrcBuffer - The buffer storing the source data + SrcSize - The size of source data + DstBuffer - The buffer to store the compressed data + DstSize - On input, the size of DstBuffer; On output, + the size of the actual compressed data. + Version - The version of de/compression algorithm. + Version 1 for EFI 1.1 de/compression algorithm. + Version 2 for Tiano de/compression algorithm. + +Returns: + + EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case, + DstSize contains the size needed. + EFI_SUCCESS - Compression is successful. + EFI_OUT_OF_RESOURCES - No resource to complete function. + EFI_INVALID_PARAMETER - Parameter supplied is wrong. + +--*/ +{ + EFI_STATUS Status; + + // + // Initializations + // + mBufSiz = 0; + mBuf = NULL; + mText = NULL; + mLevel = NULL; + mChildCount = NULL; + mPosition = NULL; + mParent = NULL; + mPrev = NULL; + mNext = NULL; + + mSrc = SrcBuffer; + mSrcUpperLimit = mSrc + SrcSize; + mDst = DstBuffer; + mDstUpperLimit = mDst + *DstSize; + + PutDword (0L); + PutDword (0L); + + MakeCrcTable (); + + mOrigSize = mCompSize = 0; + mCrc = INIT_CRC; + + // + // Compress it + // + Status = Encode (); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + // + // Null terminate the compressed data + // + if (mDst < mDstUpperLimit) { + *mDst++ = 0; + } + // + // Fill in compressed size and original size + // + mDst = DstBuffer; + PutDword (mCompSize + 1); + PutDword (mOrigSize); + + // + // Return + // + if (mCompSize + 1 + 8 > *DstSize) { + *DstSize = mCompSize + 1 + 8; + return EFI_BUFFER_TOO_SMALL; + } else { + *DstSize = mCompSize + 1 + 8; + return EFI_SUCCESS; + } + +} + +STATIC +VOID +PutDword ( + IN UINT32 Data + ) +/*++ + +Routine Description: + + Put a dword to output stream + +Arguments: + + Data - the dword to put + +Returns: (VOID) + +--*/ +{ + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff); + } + + if (mDst < mDstUpperLimit) { + *mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff); + } +} + +STATIC +EFI_STATUS +AllocateMemory ( + VOID + ) +/*++ + +Routine Description: + + Allocate memory spaces for data structures used in compression process + +Argements: + VOID + +Returns: + + EFI_SUCCESS - Memory is allocated successfully + EFI_OUT_OF_RESOURCES - Allocation fails + +--*/ +{ + UINT32 Index; + + mText = malloc (WNDSIZ * 2 + MAXMATCH); + for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) { + mText[Index] = 0; + } + + mLevel = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel)); + mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount)); + mPosition = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition)); + mParent = malloc (WNDSIZ * 2 * sizeof (*mParent)); + mPrev = malloc (WNDSIZ * 2 * sizeof (*mPrev)); + mNext = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext)); + + mBufSiz = BLKSIZ; + mBuf = malloc (mBufSiz); + while (mBuf == NULL) { + mBufSiz = (mBufSiz / 10U) * 9U; + if (mBufSiz < 4 * 1024U) { + return EFI_OUT_OF_RESOURCES; + } + + mBuf = malloc (mBufSiz); + } + + mBuf[0] = 0; + + return EFI_SUCCESS; +} + +VOID +FreeMemory ( + VOID + ) +/*++ + +Routine Description: + + Called when compression is completed to free memory previously allocated. + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + if (mText != NULL) { + free (mText); + } + + if (mLevel != NULL) { + free (mLevel); + } + + if (mChildCount != NULL) { + free (mChildCount); + } + + if (mPosition != NULL) { + free (mPosition); + } + + if (mParent != NULL) { + free (mParent); + } + + if (mPrev != NULL) { + free (mPrev); + } + + if (mNext != NULL) { + free (mNext); + } + + if (mBuf != NULL) { + free (mBuf); + } + + return ; +} + +STATIC +VOID +InitSlide ( + VOID + ) +/*++ + +Routine Description: + + Initialize String Info Log data structures + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + NODE Index; + + for (Index = WNDSIZ; Index <= WNDSIZ + UINT8_MAX; Index++) { + mLevel[Index] = 1; + mPosition[Index] = NIL; /* sentinel */ + } + + for (Index = WNDSIZ; Index < WNDSIZ * 2; Index++) { + mParent[Index] = NIL; + } + + mAvail = 1; + for (Index = 1; Index < WNDSIZ - 1; Index++) { + mNext[Index] = (NODE) (Index + 1); + } + + mNext[WNDSIZ - 1] = NIL; + for (Index = WNDSIZ * 2; Index <= MAX_HASH_VAL; Index++) { + mNext[Index] = NIL; + } +} + +STATIC +NODE +Child ( + IN NODE NodeQ, + IN UINT8 CharC + ) +/*++ + +Routine Description: + + Find child node given the parent node and the edge character + +Arguments: + + NodeQ - the parent node + CharC - the edge character + +Returns: + + The child node (NIL if not found) + +--*/ +{ + NODE NodeR; + + NodeR = mNext[HASH (NodeQ, CharC)]; + // + // sentinel + // + mParent[NIL] = NodeQ; + while (mParent[NodeR] != NodeQ) { + NodeR = mNext[NodeR]; + } + + return NodeR; +} + +STATIC +VOID +MakeChild ( + IN NODE Parent, + IN UINT8 CharC, + IN NODE Child + ) +/*++ + +Routine Description: + + Create a new child for a given parent node. + +Arguments: + + Parent - the parent node + CharC - the edge character + Child - the child node + +Returns: (VOID) + +--*/ +{ + NODE Node1; + NODE Node2; + + Node1 = (NODE) HASH (Parent, CharC); + Node2 = mNext[Node1]; + mNext[Node1] = Child; + mNext[Child] = Node2; + mPrev[Node2] = Child; + mPrev[Child] = Node1; + mParent[Child] = Parent; + mChildCount[Parent]++; +} + +STATIC +VOID +Split ( + NODE Old + ) +/*++ + +Routine Description: + + Split a node. + +Arguments: + + Old - the node to split + +Returns: (VOID) + +--*/ +{ + NODE New; + NODE TempNode; + + New = mAvail; + mAvail = mNext[New]; + mChildCount[New] = 0; + TempNode = mPrev[Old]; + mPrev[New] = TempNode; + mNext[TempNode] = New; + TempNode = mNext[Old]; + mNext[New] = TempNode; + mPrev[TempNode] = New; + mParent[New] = mParent[Old]; + mLevel[New] = (UINT8) mMatchLen; + mPosition[New] = mPos; + MakeChild (New, mText[mMatchPos + mMatchLen], Old); + MakeChild (New, mText[mPos + mMatchLen], mPos); +} + +STATIC +VOID +InsertNode ( + VOID + ) +/*++ + +Routine Description: + + Insert string info for current position into the String Info Log + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + NODE NodeQ; + NODE NodeR; + NODE Index2; + NODE NodeT; + UINT8 CharC; + UINT8 *t1; + UINT8 *t2; + + if (mMatchLen >= 4) { + // + // We have just got a long match, the target tree + // can be located by MatchPos + 1. Travese the tree + // from bottom up to get to a proper starting point. + // The usage of PERC_FLAG ensures proper node deletion + // in DeleteNode() later. + // + mMatchLen--; + NodeR = (NODE) ((mMatchPos + 1) | WNDSIZ); + NodeQ = mParent[NodeR]; + while (NodeQ == NIL) { + NodeR = mNext[NodeR]; + NodeQ = mParent[NodeR]; + } + + while (mLevel[NodeQ] >= mMatchLen) { + NodeR = NodeQ; + NodeQ = mParent[NodeQ]; + } + + NodeT = NodeQ; + while (mPosition[NodeT] < 0) { + mPosition[NodeT] = mPos; + NodeT = mParent[NodeT]; + } + + if (NodeT < WNDSIZ) { + mPosition[NodeT] = (NODE) (mPos | (UINT32) PERC_FLAG); + } + } else { + // + // Locate the target tree + // + NodeQ = (NODE) (mText[mPos] + WNDSIZ); + CharC = mText[mPos + 1]; + NodeR = Child (NodeQ, CharC); + if (NodeR == NIL) { + MakeChild (NodeQ, CharC, mPos); + mMatchLen = 1; + return ; + } + + mMatchLen = 2; + } + // + // Traverse down the tree to find a match. + // Update Position value along the route. + // Node split or creation is involved. + // + for (;;) { + if (NodeR >= WNDSIZ) { + Index2 = MAXMATCH; + mMatchPos = NodeR; + } else { + Index2 = mLevel[NodeR]; + mMatchPos = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG); + } + + if (mMatchPos >= mPos) { + mMatchPos -= WNDSIZ; + } + + t1 = &mText[mPos + mMatchLen]; + t2 = &mText[mMatchPos + mMatchLen]; + while (mMatchLen < Index2) { + if (*t1 != *t2) { + Split (NodeR); + return ; + } + + mMatchLen++; + t1++; + t2++; + } + + if (mMatchLen >= MAXMATCH) { + break; + } + + mPosition[NodeR] = mPos; + NodeQ = NodeR; + NodeR = Child (NodeQ, *t1); + if (NodeR == NIL) { + MakeChild (NodeQ, *t1, mPos); + return ; + } + + mMatchLen++; + } + + NodeT = mPrev[NodeR]; + mPrev[mPos] = NodeT; + mNext[NodeT] = mPos; + NodeT = mNext[NodeR]; + mNext[mPos] = NodeT; + mPrev[NodeT] = mPos; + mParent[mPos] = NodeQ; + mParent[NodeR] = NIL; + + // + // Special usage of 'next' + // + mNext[NodeR] = mPos; + +} + +STATIC +VOID +DeleteNode ( + VOID + ) +/*++ + +Routine Description: + + Delete outdated string info. (The Usage of PERC_FLAG + ensures a clean deletion) + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + NODE NodeQ; + NODE NodeR; + NODE NodeS; + NODE NodeT; + NODE NodeU; + + if (mParent[mPos] == NIL) { + return ; + } + + NodeR = mPrev[mPos]; + NodeS = mNext[mPos]; + mNext[NodeR] = NodeS; + mPrev[NodeS] = NodeR; + NodeR = mParent[mPos]; + mParent[mPos] = NIL; + if (NodeR >= WNDSIZ) { + return ; + } + + mChildCount[NodeR]--; + if (mChildCount[NodeR] > 1) { + return ; + } + + NodeT = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG); + if (NodeT >= mPos) { + NodeT -= WNDSIZ; + } + + NodeS = NodeT; + NodeQ = mParent[NodeR]; + NodeU = mPosition[NodeQ]; + while (NodeU & (UINT32) PERC_FLAG) { + NodeU &= (UINT32)~PERC_FLAG; + if (NodeU >= mPos) { + NodeU -= WNDSIZ; + } + + if (NodeU > NodeS) { + NodeS = NodeU; + } + + mPosition[NodeQ] = (NODE) (NodeS | WNDSIZ); + NodeQ = mParent[NodeQ]; + NodeU = mPosition[NodeQ]; + } + + if (NodeQ < WNDSIZ) { + if (NodeU >= mPos) { + NodeU -= WNDSIZ; + } + + if (NodeU > NodeS) { + NodeS = NodeU; + } + + mPosition[NodeQ] = (NODE) (NodeS | WNDSIZ | (UINT32) PERC_FLAG); + } + + NodeS = Child (NodeR, mText[NodeT + mLevel[NodeR]]); + NodeT = mPrev[NodeS]; + NodeU = mNext[NodeS]; + mNext[NodeT] = NodeU; + mPrev[NodeU] = NodeT; + NodeT = mPrev[NodeR]; + mNext[NodeT] = NodeS; + mPrev[NodeS] = NodeT; + NodeT = mNext[NodeR]; + mPrev[NodeT] = NodeS; + mNext[NodeS] = NodeT; + mParent[NodeS] = mParent[NodeR]; + mParent[NodeR] = NIL; + mNext[NodeR] = mAvail; + mAvail = NodeR; +} + +STATIC +VOID +GetNextMatch ( + VOID + ) +/*++ + +Routine Description: + + Advance the current position (read in new data if needed). + Delete outdated string info. Find a match string for current position. + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + INT32 Number; + + mRemainder--; + mPos++; + if (mPos == WNDSIZ * 2) { + memmove (&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH); + Number = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ); + mRemainder += Number; + mPos = WNDSIZ; + } + + DeleteNode (); + InsertNode (); +} + +STATIC +EFI_STATUS +Encode ( + VOID + ) +/*++ + +Routine Description: + + The main controlling routine for compression process. + +Arguments: (VOID) + +Returns: + + EFI_SUCCESS - The compression is successful + EFI_OUT_0F_RESOURCES - Not enough memory for compression process + +--*/ +{ + EFI_STATUS Status; + INT32 LastMatchLen; + NODE LastMatchPos; + + Status = AllocateMemory (); + if (EFI_ERROR (Status)) { + FreeMemory (); + return Status; + } + + InitSlide (); + + HufEncodeStart (); + + mRemainder = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH); + + mMatchLen = 0; + mPos = WNDSIZ; + InsertNode (); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + + while (mRemainder > 0) { + LastMatchLen = mMatchLen; + LastMatchPos = mMatchPos; + GetNextMatch (); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + + if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) { + // + // Not enough benefits are gained by outputting a pointer, + // so just output the original character + // + Output (mText[mPos - 1], 0); + + } else { + + if (LastMatchLen == THRESHOLD) { + if (((mPos - LastMatchPos - 2) & (WNDSIZ - 1)) > (1U << 11)) { + Output (mText[mPos - 1], 0); + continue; + } + } + // + // Outputting a pointer is beneficial enough, do it. + // + Output ( + LastMatchLen + (UINT8_MAX + 1 - THRESHOLD), + (mPos - LastMatchPos - 2) & (WNDSIZ - 1) + ); + LastMatchLen--; + while (LastMatchLen > 0) { + GetNextMatch (); + LastMatchLen--; + } + + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } + } + } + + HufEncodeEnd (); + FreeMemory (); + return EFI_SUCCESS; +} + +STATIC +VOID +CountTFreq ( + VOID + ) +/*++ + +Routine Description: + + Count the frequencies for the Extra Set + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + INT32 Index; + INT32 Index3; + INT32 Number; + INT32 Count; + + for (Index = 0; Index < NT; Index++) { + mTFreq[Index] = 0; + } + + Number = NC; + while (Number > 0 && mCLen[Number - 1] == 0) { + Number--; + } + + Index = 0; + while (Index < Number) { + Index3 = mCLen[Index++]; + if (Index3 == 0) { + Count = 1; + while (Index < Number && mCLen[Index] == 0) { + Index++; + Count++; + } + + if (Count <= 2) { + mTFreq[0] = (UINT16) (mTFreq[0] + Count); + } else if (Count <= 18) { + mTFreq[1]++; + } else if (Count == 19) { + mTFreq[0]++; + mTFreq[1]++; + } else { + mTFreq[2]++; + } + } else { + mTFreq[Index3 + 2]++; + } + } +} + +STATIC +VOID +WritePTLen ( + IN INT32 Number, + IN INT32 nbit, + IN INT32 Special + ) +/*++ + +Routine Description: + + Outputs the code length array for the Extra Set or the Position Set. + +Arguments: + + Number - the number of symbols + nbit - the number of bits needed to represent 'n' + Special - the special symbol that needs to be take care of + +Returns: (VOID) + +--*/ +{ + INT32 Index; + INT32 Index3; + + while (Number > 0 && mPTLen[Number - 1] == 0) { + Number--; + } + + PutBits (nbit, Number); + Index = 0; + while (Index < Number) { + Index3 = mPTLen[Index++]; + if (Index3 <= 6) { + PutBits (3, Index3); + } else { + PutBits (Index3 - 3, (1U << (Index3 - 3)) - 2); + } + + if (Index == Special) { + while (Index < 6 && mPTLen[Index] == 0) { + Index++; + } + + PutBits (2, (Index - 3) & 3); + } + } +} + +STATIC +VOID +WriteCLen ( + VOID + ) +/*++ + +Routine Description: + + Outputs the code length array for Char&Length Set + +Arguments: (VOID) + +Returns: (VOID) + +--*/ +{ + INT32 Index; + INT32 Index3; + INT32 Number; + INT32 Count; + + Number = NC; + while (Number > 0 && mCLen[Number - 1] == 0) { + Number--; + } + + PutBits (CBIT, Number); + Index = 0; + while (Index < Number) { + Index3 = mCLen[Index++]; + if (Index3 == 0) { + Count = 1; + while (Index < Number && mCLen[Index] == 0) { + Index++; + Count++; + } + + if (Count <= 2) { + for (Index3 = 0; Index3 < Count; Index3++) { + PutBits (mPTLen[0], mPTCode[0]); + } + } else if (Count <= 18) { + PutBits (mPTLen[1], mPTCode[1]); + PutBits (4, Count - 3); + } else if (Count == 19) { + PutBits (mPTLen[0], mPTCode[0]); + PutBits (mPTLen[1], mPTCode[1]); + PutBits (4, 15); + } else { + PutBits (mPTLen[2], mPTCode[2]); + PutBits (CBIT, Count - 20); + } + } else { + PutBits (mPTLen[Index3 + 2], mPTCode[Index3 + 2]); + } + } +} + +STATIC +VOID +EncodeC ( + IN INT32 Value + ) +{ + PutBits (mCLen[Value], mCCode[Value]); +} + +STATIC +VOID +EncodeP ( + IN UINT32 Value + ) +{ + UINT32 Index; + UINT32 NodeQ; + + Index = 0; + NodeQ = Value; + while (NodeQ) { + NodeQ >>= 1; + Index++; + } + + PutBits (mPTLen[Index], mPTCode[Index]); + if (Index > 1) { + PutBits (Index - 1, Value & (0xFFFFFFFFU >> (32 - Index + 1))); + } +} + +STATIC +VOID +SendBlock ( + VOID + ) +/*++ + +Routine Description: + + Huffman code the block and output it. + +Arguments: + (VOID) + +Returns: + (VOID) + +--*/ +{ + UINT32 Index; + UINT32 Index2; + UINT32 Index3; + UINT32 Flags; + UINT32 Root; + UINT32 Pos; + UINT32 Size; + Flags = 0; + + Root = MakeTree (NC, mCFreq, mCLen, mCCode); + Size = mCFreq[Root]; + PutBits (16, Size); + if (Root >= NC) { + CountTFreq (); + Root = MakeTree (NT, mTFreq, mPTLen, mPTCode); + if (Root >= NT) { + WritePTLen (NT, TBIT, 3); + } else { + PutBits (TBIT, 0); + PutBits (TBIT, Root); + } + + WriteCLen (); + } else { + PutBits (TBIT, 0); + PutBits (TBIT, 0); + PutBits (CBIT, 0); + PutBits (CBIT, Root); + } + + Root = MakeTree (NP, mPFreq, mPTLen, mPTCode); + if (Root >= NP) { + WritePTLen (NP, PBIT, -1); + } else { + PutBits (PBIT, 0); + PutBits (PBIT, Root); + } + + Pos = 0; + for (Index = 0; Index < Size; Index++) { + if (Index % UINT8_BIT == 0) { + Flags = mBuf[Pos++]; + } else { + Flags <<= 1; + } + + if (Flags & (1U << (UINT8_BIT - 1))) { + EncodeC (mBuf[Pos++] + (1U << UINT8_BIT)); + Index3 = mBuf[Pos++]; + for (Index2 = 0; Index2 < 3; Index2++) { + Index3 <<= UINT8_BIT; + Index3 += mBuf[Pos++]; + } + + EncodeP (Index3); + } else { + EncodeC (mBuf[Pos++]); + } + } + + for (Index = 0; Index < NC; Index++) { + mCFreq[Index] = 0; + } + + for (Index = 0; Index < NP; Index++) { + mPFreq[Index] = 0; + } +} + +STATIC +VOID +Output ( + IN UINT32 CharC, + IN UINT32 Pos + ) +/*++ + +Routine Description: + + Outputs an Original Character or a Pointer + +Arguments: + + CharC - The original character or the 'String Length' element of a Pointer + Pos - The 'Position' field of a Pointer + +Returns: (VOID) + +--*/ +{ + STATIC UINT32 CPos; + + if ((mOutputMask >>= 1) == 0) { + mOutputMask = 1U << (UINT8_BIT - 1); + // + // Check the buffer overflow per outputing UINT8_BIT symbols + // which is an Original Character or a Pointer. The biggest + // symbol is a Pointer which occupies 5 bytes. + // + if (mOutputPos >= mBufSiz - 5 * UINT8_BIT) { + SendBlock (); + mOutputPos = 0; + } + + CPos = mOutputPos++; + mBuf[CPos] = 0; + } + + mBuf[mOutputPos++] = (UINT8) CharC; + mCFreq[CharC]++; + if (CharC >= (1U << UINT8_BIT)) { + mBuf[CPos] |= mOutputMask; + mBuf[mOutputPos++] = (UINT8) (Pos >> 24); + mBuf[mOutputPos++] = (UINT8) (Pos >> 16); + mBuf[mOutputPos++] = (UINT8) (Pos >> (UINT8_BIT)); + mBuf[mOutputPos++] = (UINT8) Pos; + CharC = 0; + while (Pos) { + Pos >>= 1; + CharC++; + } + + mPFreq[CharC]++; + } +} + +STATIC +VOID +HufEncodeStart ( + VOID + ) +{ + INT32 Index; + + for (Index = 0; Index < NC; Index++) { + mCFreq[Index] = 0; + } + + for (Index = 0; Index < NP; Index++) { + mPFreq[Index] = 0; + } + + mOutputPos = mOutputMask = 0; + InitPutBits (); + return ; +} + +STATIC +VOID +HufEncodeEnd ( + VOID + ) +{ + SendBlock (); + + // + // Flush remaining bits + // + PutBits (UINT8_BIT - 1, 0); + + return ; +} + +STATIC +VOID +MakeCrcTable ( + VOID + ) +{ + UINT32 Index; + UINT32 Index2; + UINT32 Temp; + + for (Index = 0; Index <= UINT8_MAX; Index++) { + Temp = Index; + for (Index2 = 0; Index2 < UINT8_BIT; Index2++) { + if (Temp & 1) { + Temp = (Temp >> 1) ^ CRCPOLY; + } else { + Temp >>= 1; + } + } + + mCrcTable[Index] = (UINT16) Temp; + } +} + +STATIC +VOID +PutBits ( + IN INT32 Number, + IN UINT32 Value + ) +/*++ + +Routine Description: + + Outputs rightmost n bits of x + +Arguments: + + Number - the rightmost n bits of the data is used + x - the data + +Returns: (VOID) + +--*/ +{ + UINT8 Temp; + + while (Number >= mBitCount) { + // + // Number -= mBitCount should never equal to 32 + // + Temp = (UINT8) (mSubBitBuf | (Value >> (Number -= mBitCount))); + if (mDst < mDstUpperLimit) { + *mDst++ = Temp; + } + + mCompSize++; + mSubBitBuf = 0; + mBitCount = UINT8_BIT; + } + + mSubBitBuf |= Value << (mBitCount -= Number); +} + +STATIC +INT32 +FreadCrc ( + OUT UINT8 *Pointer, + IN INT32 Number + ) +/*++ + +Routine Description: + + Read in source data + +Arguments: + + Pointer - the buffer to hold the data + Number - number of bytes to read + +Returns: + + number of bytes actually read + +--*/ +{ + INT32 Index; + + for (Index = 0; mSrc < mSrcUpperLimit && Index < Number; Index++) { + *Pointer++ = *mSrc++; + } + + Number = Index; + + Pointer -= Number; + mOrigSize += Number; + Index--; + while (Index >= 0) { + UPDATE_CRC (*Pointer++); + Index--; + } + + return Number; +} + +STATIC +VOID +InitPutBits ( + VOID + ) +{ + mBitCount = UINT8_BIT; + mSubBitBuf = 0; +} + +STATIC +VOID +CountLen ( + IN INT32 Index + ) +/*++ + +Routine Description: + + Count the number of each code length for a Huffman tree. + +Arguments: + + Index - the top node + +Returns: (VOID) + +--*/ +{ + STATIC INT32 Depth = 0; + + if (Index < mN) { + mLenCnt[(Depth < 16) ? Depth : 16]++; + } else { + Depth++; + CountLen (mLeft[Index]); + CountLen (mRight[Index]); + Depth--; + } +} + +STATIC +VOID +MakeLen ( + IN INT32 Root + ) +/*++ + +Routine Description: + + Create code length array for a Huffman tree + +Arguments: + + Root - the root of the tree + +Returns: + + VOID + +--*/ +{ + INT32 Index; + INT32 Index3; + UINT32 Cum; + + for (Index = 0; Index <= 16; Index++) { + mLenCnt[Index] = 0; + } + + CountLen (Root); + + // + // Adjust the length count array so that + // no code will be generated longer than its designated length + // + Cum = 0; + for (Index = 16; Index > 0; Index--) { + Cum += mLenCnt[Index] << (16 - Index); + } + + while (Cum != (1U << 16)) { + mLenCnt[16]--; + for (Index = 15; Index > 0; Index--) { + if (mLenCnt[Index] != 0) { + mLenCnt[Index]--; + mLenCnt[Index + 1] += 2; + break; + } + } + + Cum--; + } + + for (Index = 16; Index > 0; Index--) { + Index3 = mLenCnt[Index]; + Index3--; + while (Index3 >= 0) { + mLen[*mSortPtr++] = (UINT8) Index; + Index3--; + } + } +} + +STATIC +VOID +DownHeap ( + IN INT32 Index + ) +{ + INT32 Index2; + INT32 Index3; + + // + // priority queue: send Index-th entry down heap + // + Index3 = mHeap[Index]; + Index2 = 2 * Index; + while (Index2 <= mHeapSize) { + if (Index2 < mHeapSize && mFreq[mHeap[Index2]] > mFreq[mHeap[Index2 + 1]]) { + Index2++; + } + + if (mFreq[Index3] <= mFreq[mHeap[Index2]]) { + break; + } + + mHeap[Index] = mHeap[Index2]; + Index = Index2; + Index2 = 2 * Index; + } + + mHeap[Index] = (INT16) Index3; +} + +STATIC +VOID +MakeCode ( + IN INT32 Number, + IN UINT8 Len[ ], + OUT UINT16 Code[] + ) +/*++ + +Routine Description: + + Assign code to each symbol based on the code length array + +Arguments: + + Number - number of symbols + Len - the code length array + Code - stores codes for each symbol + +Returns: (VOID) + +--*/ +{ + INT32 Index; + UINT16 Start[18]; + + Start[1] = 0; + for (Index = 1; Index <= 16; Index++) { + Start[Index + 1] = (UINT16) ((Start[Index] + mLenCnt[Index]) << 1); + } + + for (Index = 0; Index < Number; Index++) { + Code[Index] = Start[Len[Index]]++; + } +} + +STATIC +INT32 +MakeTree ( + IN INT32 NParm, + IN UINT16 FreqParm[], + OUT UINT8 LenParm[ ], + OUT UINT16 CodeParm[] + ) +/*++ + +Routine Description: + + Generates Huffman codes given a frequency distribution of symbols + +Arguments: + + NParm - number of symbols + FreqParm - frequency of each symbol + LenParm - code length for each symbol + CodeParm - code for each symbol + +Returns: + + Root of the Huffman tree. + +--*/ +{ + INT32 Index; + INT32 Index2; + INT32 Index3; + INT32 Avail; + + // + // make tree, calculate len[], return root + // + mN = NParm; + mFreq = FreqParm; + mLen = LenParm; + Avail = mN; + mHeapSize = 0; + mHeap[1] = 0; + for (Index = 0; Index < mN; Index++) { + mLen[Index] = 0; + if (mFreq[Index]) { + mHeapSize++; + mHeap[mHeapSize] = (INT16) Index; + } + } + + if (mHeapSize < 2) { + CodeParm[mHeap[1]] = 0; + return mHeap[1]; + } + + for (Index = mHeapSize / 2; Index >= 1; Index--) { + // + // make priority queue + // + DownHeap (Index); + } + + mSortPtr = CodeParm; + do { + Index = mHeap[1]; + if (Index < mN) { + *mSortPtr++ = (UINT16) Index; + } + + mHeap[1] = mHeap[mHeapSize--]; + DownHeap (1); + Index2 = mHeap[1]; + if (Index2 < mN) { + *mSortPtr++ = (UINT16) Index2; + } + + Index3 = Avail++; + mFreq[Index3] = (UINT16) (mFreq[Index] + mFreq[Index2]); + mHeap[1] = (INT16) Index3; + DownHeap (1); + mLeft[Index3] = (UINT16) Index; + mRight[Index3] = (UINT16) Index2; + } while (mHeapSize > 1); + + mSortPtr = CodeParm; + MakeLen (Index3); + MakeCode (NParm, LenParm, CodeParm); + + // + // return root + // + return Index3; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/CustomizedCompress.c b/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/CustomizedCompress.c new file mode 100644 index 0000000000..a4af74aff2 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/CustomizedCompress.c @@ -0,0 +1,146 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CustomizedCompress.c + +Abstract: + + Header file for Customized compression routine + +--*/ + +#include "TianoCommon.h" + +EFI_STATUS +SetCustomizedCompressionType ( + IN CHAR8 *Type + ) +/*++ + +Routine Description: + +The implementation of Customized SetCompressionType(). + +Arguments: + Type - The type if compression. + +Returns: + + EFI_SUCCESS - The type has been set. + EFI_UNSUPPORTED - This type is unsupported. + + +--*/ +{ + return EFI_UNSUPPORTED; +} + +EFI_STATUS +CustomizedGetInfo ( + IN VOID *Source, + IN UINT32 SrcSize, + OUT UINT32 *DstSize, + OUT UINT32 *ScratchSize + ) +/*++ + +Routine Description: + +The implementation of Customized GetInfo(). + +Arguments: + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + DstSize - The size of destination buffer. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved. + EFI_INVALID_PARAMETER - The source data is corrupted + EFI_UNSUPPORTED - The operation is unsupported. + + +--*/ +{ + return EFI_UNSUPPORTED; +} + +EFI_STATUS +CustomizedDecompress ( + IN VOID *Source, + IN UINT32 SrcSize, + IN OUT VOID *Destination, + IN UINT32 DstSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +/*++ + +Routine Description: + + The implementation of Customized Decompress(). + +Arguments: + + This - The protocol instance pointer + Source - The source buffer containing the compressed data. + SrcSize - The size of source buffer + Destination - The destination buffer to store the decompressed data + DstSize - The size of destination buffer. + Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. + ScratchSize - The size of scratch buffer. + +Returns: + + EFI_SUCCESS - Decompression is successfull + EFI_INVALID_PARAMETER - The source data is corrupted + EFI_UNSUPPORTED - The operation is unsupported. + +--*/ +{ + return EFI_UNSUPPORTED; +} + +EFI_STATUS +CustomizedCompress ( + IN UINT8 *SrcBuffer, + IN UINT32 SrcSize, + IN UINT8 *DstBuffer, + IN OUT UINT32 *DstSize + ) +/*++ + +Routine Description: + + The Customized compression routine. + +Arguments: + + SrcBuffer - The buffer storing the source data + SrcSize - The size of source data + DstBuffer - The buffer to store the compressed data + DstSize - On input, the size of DstBuffer; On output, + the size of the actual compressed data. + +Returns: + + EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case, + DstSize contains the size needed. + EFI_SUCCESS - Compression is successful. + + EFI_UNSUPPORTED - The operation is unsupported. +--*/ +{ + return EFI_UNSUPPORTED; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/makefile new file mode 100644 index 0000000000..4e36514509 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/CustomizedCompress/makefile @@ -0,0 +1,82 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +TARGET_NAME = CustomizedCompress +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +TARGET_LIB = $(EDK_TOOLS_OUTPUT)\CustomizedCompress.lib + +OBJECTS = "$(EDK_TOOLS_OUTPUT)\CustomizedCompress.obj" + +# +# Build targets +# + +all: $(TARGET_LIB) + +# +# Object targets +# + +"$(EDK_TOOLS_OUTPUT)\CustomizedCompress.obj": "$(TARGET_SOURCE_DIR)\CustomizedCompress.c" $(EDK_SOURCE)\Foundation\Include\EfiCommon.h + $(CC) $(C_FLAGS) "$(TARGET_SOURCE_DIR)\CustomizedCompress.c" /Fo"$(EDK_TOOLS_OUTPUT)\CustomizedCompress.obj" + +# +# Build LIB +# + +# +# Add Binary Build description for this lib. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib)) +$(TARGET_LIB): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).lib $(TARGET_LIB) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb /Y +!ELSE +$(TARGET_LIB): $(OBJECTS) + $(LIB_EXE) $(LIB_FLAGS) $(OBJECTS) /OUT:$(TARGET_LIB) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_LIB) copy $(TARGET_LIB) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).lib /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj.pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME)Obj.pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\CustomizedCompress.* del /q $(EDK_TOOLS_OUTPUT)\CustomizedCompress.* > NUL + @if exist $(TARGET_LIB) del $(TARGET_LIB) diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c new file mode 100644 index 0000000000..180422cae2 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c @@ -0,0 +1,386 @@ +/*++ + +Copyright 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + EfiCompressMain.c + +Abstract: + +--*/ + +#include +#include +#include +#include +#include +#include +#include "TianoCommon.h" +#include "Compress.h" + +typedef enum { + EFI_COMPRESS = 1, + TIANO_COMPRESS = 2 +} COMPRESS_TYPE; + +typedef struct _COMPRESS_ACTION_LIST { + struct _COMPRESS_ACTION_LIST *NextAction; + INT32 CompressType; + CHAR8 *InFileName; + CHAR8 *OutFileName; +} COMPRESS_ACTION_LIST; + + +STATIC +BOOLEAN +ParseCommandLine ( + INT32 argc, + CHAR8 *argv[], + COMPRESS_ACTION_LIST **ActionListHead + ) +/*++ + +Routine Description: + + Parse command line options + +Arguments: + + argc - number of arguments passed into the command line. + argv[] - files to compress and files to output compressed data to. + Options - Point to COMMAND_LINE_OPTIONS, receiving command line options. + +Returns: + + BOOLEAN: TRUE for a successful parse. +--*/ +; + +STATIC +VOID +Usage ( + CHAR8 *ExeName + ) +/*++ + +Routine Description: + + Print usage. + +Arguments: + + ExeName - Application's full path + +--*/ +; + + +STATIC +BOOLEAN +ProcessFile ( + CHAR8 *InFileName, + CHAR8 *OutFileName, + COMPRESS_TYPE CompressType + ) +/*++ + +Routine Description: + + Compress InFileName to OutFileName using algorithm specified by CompressType. + +Arguments: + + InFileName - Input file to compress + OutFileName - Output file compress to + CompressType - Compress algorithm, can be EFI_COMPRESS or TIANO_COMPRESS + +Returns: + + BOOLEAN: TRUE for compress file successfully + +--*/ +; + +int +main ( + INT32 argc, + CHAR8 *argv[] + ) +/*++ + +Routine Description: + + Compresses the input files + +Arguments: + + argc - number of arguments passed into the command line. + argv[] - files to compress and files to output compressed data to. + +Returns: + + int: 0 for successful execution of the function. + +--*/ +{ + COMPRESS_ACTION_LIST *ActionList; + COMPRESS_ACTION_LIST *NextAction; + UINT32 ActionCount; + UINT32 SuccessCount; + + ActionList = NULL; + ActionCount = SuccessCount = 0; + + if (!ParseCommandLine (argc, argv, &ActionList)) { + Usage (*argv); + return 1; + } + + while (ActionList != NULL) { + ++ActionCount; + if (ProcessFile ( + ActionList->InFileName, + ActionList->OutFileName, + ActionList->CompressType) + ) { + ++SuccessCount; + } + NextAction = ActionList; + ActionList = ActionList->NextAction; + free (NextAction); + } + + fprintf (stdout, "\nCompressed %d files, %d succeed!\n", ActionCount, SuccessCount); + if (SuccessCount < ActionCount) { + return 1; + } + + return 0; +} + +STATIC +BOOLEAN +ParseCommandLine ( + INT32 argc, + CHAR8 *argv[], + COMPRESS_ACTION_LIST **ActionListHead + ) +{ + COMPRESS_TYPE CurrentType; + + COMPRESS_ACTION_LIST **Action; + + Action = ActionListHead; + CurrentType = EFI_COMPRESS; // default compress algorithm + + // Skip Exe Name + --argc; + ++argv; + + while (argc > 0) { + if (strcmp (*argv, "-h") == 0 || strcmp (*argv, "-?") == 0) { + // + // 1. Directly return, help message will be printed. + // + return FALSE; + + } else if (strncmp (*argv, "-t", 2) == 0) { + // + // 2. Specifying CompressType + // + if (_stricmp ((*argv)+2, "EFI") == 0) { + CurrentType = EFI_COMPRESS; + } else if (_stricmp ((*argv)+2, "Tiano") == 0) { + CurrentType = TIANO_COMPRESS; + } else { + fprintf (stdout, " ERROR: CompressType %s not supported!\n", (*argv)+2); + return FALSE; + } + } else { + // + // 3. Current parameter is *FileName + // + if (*Action == NULL) { + // + // need to create a new action item + // + *Action = (COMPRESS_ACTION_LIST*) malloc (sizeof **Action); + if (*Action == NULL) { + fprintf (stdout, " ERROR: malloc failed!\n"); + return FALSE; + } + memset (*Action, 0, sizeof **Action); + (*Action)->CompressType = CurrentType; + } + + // + // Assignment to InFileName and OutFileName in order + // + if ((*Action)->InFileName == NULL) { + (*Action)->InFileName = *argv; + } else { + (*Action)->OutFileName = *argv; + Action = &(*Action)->NextAction; + } + } + + --argc; + ++argv; + + } + + if (*Action != NULL) { + assert ((*Action)->InFileName != NULL); + fprintf (stdout, " ERROR: Compress OutFileName not specified with InFileName: %s!\n", (*Action)->InFileName); + return FALSE; + } + + if (*ActionListHead == NULL) { + return FALSE; + } + return TRUE; +} + +STATIC +BOOLEAN +ProcessFile ( + CHAR8 *InFileName, + CHAR8 *OutFileName, + COMPRESS_TYPE CompressType + ) +{ + EFI_STATUS Status; + FILE *InFileP; + FILE *OutFileP; + UINT32 SrcSize; + UINT32 DstSize; + UINT8 *SrcBuffer; + UINT8 *DstBuffer; + COMPRESS_FUNCTION CompressFunc; + + SrcBuffer = DstBuffer = NULL; + InFileP = OutFileP = NULL; + + fprintf (stdout, "%s --> %s\n", InFileName, OutFileName); + + if ((OutFileP = fopen (OutFileName, "wb")) == NULL) { + fprintf (stdout, " ERROR: Can't open output file %s for write!\n", OutFileName); + goto ErrorHandle; + } + + if ((InFileP = fopen (InFileName, "rb")) == NULL) { + fprintf (stdout, " ERROR: Can't open input file %s for read!\n", InFileName); + goto ErrorHandle; + } + + // + // Get the size of source file + // + fseek (InFileP, 0, SEEK_END); + SrcSize = ftell (InFileP); + rewind (InFileP); + // + // Read in the source data + // + if ((SrcBuffer = malloc (SrcSize)) == NULL) { + fprintf (stdout, " ERROR: Can't allocate memory!\n"); + goto ErrorHandle; + } + + if (fread (SrcBuffer, 1, SrcSize, InFileP) != SrcSize) { + fprintf (stdout, " ERROR: Can't read from source!\n"); + goto ErrorHandle; + } + + // + // Choose the right compress algorithm + // + CompressFunc = (CompressType == EFI_COMPRESS) ? EfiCompress : TianoCompress; + + // + // Get destination data size and do the compression + // + DstSize = 0; + Status = CompressFunc (SrcBuffer, SrcSize, DstBuffer, &DstSize); + if (Status != EFI_BUFFER_TOO_SMALL) { + fprintf (stdout, " Error: Compress failed: %x!\n", Status); + goto ErrorHandle; + } + if ((DstBuffer = malloc (DstSize)) == NULL) { + fprintf (stdout, " ERROR: Can't allocate memory!\n"); + goto ErrorHandle; + } + + Status = CompressFunc (SrcBuffer, SrcSize, DstBuffer, &DstSize); + if (EFI_ERROR (Status)) { + fprintf (stdout, " ERROR: Compress Error!\n"); + goto ErrorHandle; + } + + fprintf (stdout, " Orig Size = %ld\tComp Size = %ld\n", SrcSize, DstSize); + + if (DstBuffer == NULL) { + fprintf (stdout, " ERROR: No destination to write to!\n"); + goto ErrorHandle; + } + + // + // Write out the result + // + if (fwrite (DstBuffer, 1, DstSize, OutFileP) != DstSize) { + fprintf (stdout, " ERROR: Can't write to destination file!\n"); + goto ErrorHandle; + } + + return TRUE; + +ErrorHandle: + if (SrcBuffer) { + free (SrcBuffer); + } + + if (DstBuffer) { + free (DstBuffer); + } + + if (InFileP) { + fclose (InFileP); + } + + if (OutFileP) { + fclose (OutFileP); + } + return FALSE; +} + +VOID +Usage ( + CHAR8 *ExeName + ) +{ + fprintf ( + stdout, + "\n" + "Usage: %s [-tCompressType] InFileName OutFileName\n" + " %*c [[-tCompressType] InFileName OutFileName ...]\n" + "\n" + "where:\n" + " CompressType - optional compress algorithm (EFI | Tiano), case insensitive.\n" + " If ommitted, compress type specified ahead is used, \n" + " default is EFI\n" + " e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\ \n" + " c.in c.out -tEFI d.in d.out\n" + " a.in and d.in are compressed using EFI compress algorithm\n" + " b.in and c.in are compressed using Tiano compress algorithm\n" + " InFileName - input file path\n" + " OutFileName - output file path\n", + ExeName, strlen(ExeName), ' ' + ); +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/makefile new file mode 100644 index 0000000000..3f034288e0 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/makefile @@ -0,0 +1,89 @@ +#/*++ +# +# Copyright (c) 2006 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=EfiCompress +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\EfiCompressMain.c" +TARGET_EXE_INCLUDE = "$(COMMON_SOURCE)\Compress.h" +TARGET_EXE_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj $(TARGET_EXE_LIBS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\EfiCompressMain.obj $(TARGET_EXE_LIBS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Main.* del /q $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Main.* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c new file mode 100644 index 0000000000..06a8581669 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c @@ -0,0 +1,1545 @@ +/*++ + +Copyright (c) 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + EfiRom.c + +Abstract: + + Utility program to create an EFI option ROM image from binary and + EFI PE32 files. + + +--*/ + +#include +#include +#include + +// +// Includes for EFI 1.1 build +// +// #include "Tiano.h" // required defines for Compress.h +// #include "EfiImage.h" // for PE32 structure definitions +// #include "Compress.h" // for compression function +// Includes for Tiano build +// +#include "TianoCommon.h" +#include "EfiImage.h" // for PE32 structure definitions +#include "Compress.h" + +// +// END include differences +// +#include "Pci22.h" // for option ROM header structures +// +// Version of this utility +// +#define UTILITY_VERSION "v2.5" + +// +// Define some status return values +// +#define STATUS_SUCCESS 0 +#define STATUS_WARNING 1 +#define STATUS_ERROR 2 + +// +// Define the max length of a filename +// +#define MAX_PATH 200 + +#define DEFAULT_OUTPUT_EXTENSION ".rom" + +// +// Max size for an option ROM image +// +#define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16) // 16MB +// +// Values for the indicator field in the PCI data structure +// +#define INDICATOR_LAST 0x80 // last file in series of files +// +// Masks for the FILE_LIST.FileFlags field +// +#define FILE_FLAG_BINARY 0x01 +#define FILE_FLAG_EFI 0x02 +#define FILE_FLAG_COMPRESS 0x04 + +// +// Use this linked list structure to keep track of all the filenames +// specified on the command line. +// +typedef struct _FILE_LIST { + struct _FILE_LIST *Next; + INT8 *FileName; + UINT32 FileFlags; + UINT32 ClassCode; + UINT16 CodeRevision; +} FILE_LIST; + +// +// Use this to track our command-line options +// +typedef struct { + INT8 OutFileName[MAX_PATH]; + INT8 NoLast; + INT8 Verbose; + INT8 DumpOption; + UINT8 DevIdValid; + UINT8 VendIdValid; + UINT16 VendId; + UINT16 DevId; + FILE_LIST *FileList; +} OPTIONS; + +// +// Make a global structure to keep track of command-line options +// +static OPTIONS mOptions; + +// +// Use these to convert from machine type value to a named type +// +typedef struct { + UINT16 Value; + char *Name; +} STRING_LOOKUP; + +static STRING_LOOKUP mMachineTypes[] = { + EFI_IMAGE_MACHINE_IA32, + "IA32", + EFI_IMAGE_MACHINE_IA64, + "IA64", + EFI_IMAGE_MACHINE_EBC, + "EBC", + 0, + NULL +}; + +static STRING_LOOKUP mSubsystemTypes[] = { + EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION, + "EFI application", + EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, + "EFI boot service driver", + EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER, + "EFI runtime driver", + 0, + NULL +}; +// +// Function prototypes +// +static +void +Usage ( + VOID + ); + +static +int +ParseCommandLine ( + int Argc, + char *Argv[], + OPTIONS *Options + ); + +static +int +CheckPE32File ( + FILE *Fptr, + UINT16 *MachineType, + UINT16 *SubSystem + ); + +static +int +ProcessEfiFile ( + FILE *OutFptr, + FILE_LIST *InFile, + UINT16 VendId, + UINT16 DevId, + UINT32 *Size + ); + +static +int +ProcessBinFile ( + FILE *OutFptr, + FILE_LIST *InFile, + UINT32 *Size + ); + +static +void +DumpImage ( + FILE_LIST *InFile + ); + +char * +GetMachineTypeStr ( + UINT16 MachineType + ); + +static +char * +GetSubsystemTypeStr ( + UINT16 SubsystemType + ); + +int +main ( + int Argc, + char *Argv[] + ) +/*++ + +Routine Description: + + Given an EFI image filename, create a ROM-able image by creating an option + ROM header and PCI data structure, filling them in, and then writing the + option ROM header + PCI data structure + EFI image out to the output file. + +Arguments: + + Argc - standard C main() argument count + + Argv - standard C main() argument list + +Returns: + + 0 success + non-zero otherwise + +--*/ +// GC_TODO: ] - add argument and description to function comment +{ + INT8 *Ext; + FILE *FptrOut; + UINT32 Status; + FILE_LIST *FList; + UINT32 TotalSize; + UINT32 Size; + + Status = STATUS_SUCCESS; + FptrOut = NULL; + + // + // Parse the command line arguments + // + if (ParseCommandLine (Argc, Argv, &mOptions)) { + return STATUS_ERROR; + } + // + // If dumping an image, then do that and quit + // + if (mOptions.DumpOption) { + DumpImage (mOptions.FileList); + goto BailOut; + } + // + // Determine the output filename. Either what they specified on + // the command line, or the first input filename with a different extension. + // + if (!mOptions.OutFileName[0]) { + strcpy (mOptions.OutFileName, mOptions.FileList->FileName); + // + // Find the last . on the line and replace the filename extension with + // the default + // + for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1; + (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\'); + Ext-- + ) + ; + // + // If dot here, then insert extension here, otherwise append + // + if (*Ext != '.') { + Ext = mOptions.OutFileName + strlen (mOptions.OutFileName); + } + + strcpy (Ext, DEFAULT_OUTPUT_EXTENSION); + } + // + // Make sure we don't have the same filename for input and output files + // + for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) { + if (_stricmp (mOptions.OutFileName, FList->FileName) == 0) { + Status = STATUS_ERROR; + fprintf ( + stdout, + "ERROR: Input and output file names must be different - %s = %s\n", + FList->FileName, + mOptions.OutFileName + ); + goto BailOut; + } + } + // + // Now open our output file + // + if ((FptrOut = fopen (mOptions.OutFileName, "w+b")) == NULL) { + fprintf (stdout, "ERROR: Failed to open output file %s\n", mOptions.OutFileName); + goto BailOut; + } + // + // Process all our files + // + TotalSize = 0; + for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) { + Size = 0; + if (FList->FileFlags & FILE_FLAG_EFI) { + if (mOptions.Verbose) { + fprintf (stdout, "Processing EFI file %s\n", FList->FileName); + } + + Status = ProcessEfiFile (FptrOut, FList, mOptions.VendId, mOptions.DevId, &Size); + } else if (FList->FileFlags & FILE_FLAG_BINARY) { + if (mOptions.Verbose) { + fprintf (stdout, "Processing binary file %s\n", FList->FileName); + } + + Status = ProcessBinFile (FptrOut, FList, &Size); + } else { + fprintf (stdout, "ERROR: File not specified as EFI or binary: %s\n", FList->FileName); + Status = STATUS_ERROR; + } + + if (mOptions.Verbose) { + fprintf (stdout, " Output size = 0x%X\n", Size); + } + + if (Status != STATUS_SUCCESS) { + break; + } + + TotalSize += Size; + } + // + // Check total size + // + if (TotalSize > MAX_OPTION_ROM_SIZE) { + fprintf ( + stdout, + "ERROR: Option ROM image size exceeds limit 0x%X bytes\n", + MAX_OPTION_ROM_SIZE + ); + Status = STATUS_ERROR; + } + +BailOut: + if (FptrOut != NULL) { + fclose (FptrOut); + } + // + // Clean up our file list + // + while (mOptions.FileList != NULL) { + FList = mOptions.FileList->Next; + free (mOptions.FileList); + mOptions.FileList = FList; + } + + return Status; +} + +static +int +ProcessBinFile ( + FILE *OutFptr, + FILE_LIST *InFile, + UINT32 *Size + ) +/*++ + +Routine Description: + + Process a binary input file. + +Arguments: + + OutFptr - file pointer to output binary ROM image file we're creating + InFile - structure contains information on the binary file to process + Size - pointer to where to return the size added to the output file + +Returns: + + 0 - successful + +--*/ +{ + FILE *InFptr; + UINT32 TotalSize; + UINT32 FileSize; + UINT8 *Buffer; + UINT32 Status; + PCI_EXPANSION_ROM_HEADER *RomHdr; + PCI_DATA_STRUCTURE *PciDs; + UINT32 Index; + UINT8 ByteCheckSum; + + Status = STATUS_SUCCESS; + + // + // Try to open the input file + // + if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) { + fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName); + return STATUS_ERROR; + } + // + // Seek to the end of the input file and get the file size. Then allocate + // a buffer to read it in to. + // + fseek (InFptr, 0, SEEK_END); + FileSize = ftell (InFptr); + if (mOptions.Verbose) { + fprintf (stdout, " File size = 0x%X\n", FileSize); + } + + fseek (InFptr, 0, SEEK_SET); + Buffer = (INT8 *) malloc (FileSize); + if (Buffer == NULL) { + fprintf (stdout, "ERROR: Memory allocation failed\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + if (fread (Buffer, FileSize, 1, InFptr) != 1) { + fprintf (stdout, "ERROR: Failed to read all bytes from input file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + // + // Total size must be an even multiple of 512 bytes, and can't exceed + // the option ROM image size. + // + TotalSize = FileSize; + if (TotalSize & 0x1FF) { + TotalSize = (TotalSize + 0x200) &~0x1ff; + } + + if (TotalSize > MAX_OPTION_ROM_SIZE) { + fprintf ( + stdout, + "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n", + InFile->FileName, + MAX_OPTION_ROM_SIZE + ); + Status = STATUS_ERROR; + goto BailOut; + } + // + // Return the size to the caller so they can keep track of the running total. + // + *Size = TotalSize; + + // + // Crude check to make sure it's a legitimate ROM image + // + RomHdr = (PCI_EXPANSION_ROM_HEADER *) Buffer; + if (RomHdr->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) { + fprintf (stdout, "ERROR: ROM image file has invalid ROM signature\n"); + Status = STATUS_ERROR; + goto BailOut; + } + // + // Make sure the pointer to the PCI data structure is within the size of the image. + // Then check it for valid signature. + // + if ((RomHdr->PcirOffset > FileSize) || (RomHdr->PcirOffset == 0)) { + fprintf (stdout, "ERROR: Invalid PCI data structure offset\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + PciDs = (PCI_DATA_STRUCTURE *) (Buffer + RomHdr->PcirOffset); + if (PciDs->Signature != PCI_DATA_STRUCTURE_SIGNATURE) { + fprintf (stdout, "ERROR: PCI data structure has invalid signature\n"); + Status = STATUS_ERROR; + goto BailOut; + } + // + // If this is the last image, then set the LAST bit unless requested not + // to via the command-line -l argument. Otherwise, make sure you clear it. + // + if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) { + PciDs->Indicator = INDICATOR_LAST; + } else { + PciDs->Indicator = 0; + } + + ByteCheckSum = 0; + for (Index = 0; Index < FileSize - 1; Index++) { + ByteCheckSum = (UINT8) (ByteCheckSum + Buffer[Index]); + } + + Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1); + fprintf (stdout, "CheckSUm = %02x\n", (UINT32) Buffer[FileSize - 1]); + + // + // Now copy the input file contents out to the output file + // + if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) { + fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + TotalSize -= FileSize; + // + // Pad the rest of the image to make it a multiple of 512 bytes + // + while (TotalSize > 0) { + putc (~0, OutFptr); + TotalSize--; + } + +BailOut: + if (InFptr != NULL) { + fclose (InFptr); + } + + if (Buffer != NULL) { + free (Buffer); + } + // + // Print the file name if errors occurred + // + if (Status != STATUS_SUCCESS) { + fprintf (stdout, "Error processing binary file %s\n", InFile->FileName); + } + + return Status; +} + +static +int +ProcessEfiFile ( + FILE *OutFptr, + FILE_LIST *InFile, + UINT16 VendId, + UINT16 DevId, + UINT32 *Size + ) +/*++ + +Routine Description: + + Process a PE32 EFI file. + +Arguments: + + OutFptr - file pointer to output binary ROM image file we're creating + InFile - structure contains information on the PE32 file to process + VendId - vendor ID as required in the option ROM header + DevId - device ID as required in the option ROM header + Size - pointer to where to return the size added to the output file + +Returns: + + 0 - successful + +--*/ +{ + UINT32 Status; + FILE *InFptr; + EFI_PCI_EXPANSION_ROM_HEADER RomHdr; + PCI_DATA_STRUCTURE PciDs; + UINT32 FileSize; + UINT32 CompressedFileSize; + UINT8 *Buffer; + UINT8 *CompressedBuffer; + UINT8 *TempBufferPtr; + UINT32 TotalSize; + UINT32 HeaderSize; + UINT16 MachineType; + UINT16 SubSystem; + UINT32 HeaderPadBytes; + + // + // Try to open the input file + // + if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) { + fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName); + return STATUS_ERROR; + } + // + // Initialize our buffer pointers to null. + // + Buffer = NULL; + CompressedBuffer = NULL; + + // + // Double-check the file to make sure it's what we expect it to be + // + Status = CheckPE32File (InFptr, &MachineType, &SubSystem); + if (Status != STATUS_SUCCESS) { + goto BailOut; + } + // + // Seek to the end of the input file and get the file size + // + fseek (InFptr, 0, SEEK_END); + FileSize = ftell (InFptr); + + // + // Get the size of the headers we're going to put in front of the image. The + // EFI header must be aligned on a 4-byte boundary, so pad accordingly. + // + if (sizeof (RomHdr) & 0x03) { + HeaderPadBytes = 4 - (sizeof (RomHdr) & 0x03); + } else { + HeaderPadBytes = 0; + } + + HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER); + if (mOptions.Verbose) { + fprintf (stdout, " File size = 0x%X\n", FileSize); + } + // + // Allocate memory for the entire file (in case we have to compress), then + // seek back to the beginning of the file and read it into our buffer. + // + Buffer = (INT8 *) malloc (FileSize); + if (Buffer == NULL) { + fprintf (stdout, "ERROR: Memory allocation failed\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + fseek (InFptr, 0, SEEK_SET); + if (fread (Buffer, FileSize, 1, InFptr) != 1) { + fprintf (stdout, "ERROR: Failed to read all bytes from input file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + // + // Now determine the size of the final output file. It's either the header size + // plus the file's size, or the header size plus the compressed file size. + // + if (InFile->FileFlags & FILE_FLAG_COMPRESS) { + // + // Allocate a buffer into which we can compress the image, compress it, + // and use that size as the new size. + // + CompressedBuffer = (INT8 *) malloc (FileSize); + if (CompressedBuffer == NULL) { + fprintf (stdout, "ERROR: Memory allocation failed\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + CompressedFileSize = FileSize; + Status = EfiCompress (Buffer, FileSize, CompressedBuffer, &CompressedFileSize); + if (Status != STATUS_SUCCESS) { + fprintf (stdout, "ERROR: Compression failed\n"); + goto BailOut; + } + // + // Now compute the size, then swap buffer pointers. + // + if (mOptions.Verbose) { + fprintf (stdout, " Comp size = 0x%X\n", CompressedFileSize); + } + + TotalSize = CompressedFileSize + HeaderSize; + FileSize = CompressedFileSize; + TempBufferPtr = Buffer; + Buffer = CompressedBuffer; + CompressedBuffer = TempBufferPtr; + } else { + TotalSize = FileSize + HeaderSize; + } + // + // Total size must be an even multiple of 512 bytes + // + if (TotalSize & 0x1FF) { + TotalSize = (TotalSize + 0x200) &~0x1ff; + } + // + // Check size + // + if (TotalSize > MAX_OPTION_ROM_SIZE) { + fprintf ( + stdout, + "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n", + InFile->FileName, + MAX_OPTION_ROM_SIZE + ); + Status = STATUS_ERROR; + goto BailOut; + } + // + // Return the size to the caller so they can keep track of the running total. + // + *Size = TotalSize; + + // + // Now fill in the ROM header. These values come from chapter 18 of the + // EFI 1.02 specification. + // + memset (&RomHdr, 0, sizeof (RomHdr)); + RomHdr.Signature = PCI_EXPANSION_ROM_HEADER_SIGNATURE; + RomHdr.InitializationSize = (UINT16) (TotalSize / 512); + RomHdr.EfiSignature = EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE; + RomHdr.EfiSubsystem = SubSystem; + RomHdr.EfiMachineType = MachineType; + RomHdr.EfiImageHeaderOffset = (UINT16) HeaderSize; + RomHdr.PcirOffset = (UINT16) (sizeof (RomHdr) + HeaderPadBytes); + // + // Set image as compressed or not + // + if (InFile->FileFlags & FILE_FLAG_COMPRESS) { + RomHdr.CompressionType = EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED; + } + // + // Fill in the PCI data structure + // + memset (&PciDs, 0, sizeof (PCI_DATA_STRUCTURE)); + + PciDs.Signature = PCI_DATA_STRUCTURE_SIGNATURE; + PciDs.VendorId = VendId; + PciDs.DeviceId = DevId; + PciDs.Length = (UINT16) sizeof (PCI_DATA_STRUCTURE); + PciDs.Revision = 0; + // + // Class code and code revision from the command line (optional) + // + PciDs.ClassCode[0] = (UINT8) InFile->ClassCode; + PciDs.ClassCode[1] = (UINT8) (InFile->ClassCode >> 8); + PciDs.ClassCode[2] = (UINT8) (InFile->ClassCode >> 16); + PciDs.ImageLength = RomHdr.InitializationSize; + PciDs.CodeRevision = InFile->CodeRevision; + PciDs.CodeType = PCI_CODE_TYPE_EFI_IMAGE; + + // + // If this is the last image, then set the LAST bit unless requested not + // to via the command-line -l argument. + // + if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) { + PciDs.Indicator = INDICATOR_LAST; + } + // + // Write the ROM header to the output file + // + if (fwrite (&RomHdr, sizeof (RomHdr), 1, OutFptr) != 1) { + fprintf (stdout, "ERROR: Failed to write ROM header to output file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + // + // Write pad bytes to align the PciDs + // + while (HeaderPadBytes > 0) { + if (putc (0, OutFptr) == EOF) { + fprintf (stdout, "ERROR: Failed to write ROM header pad bytes to output file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + HeaderPadBytes--; + } + // + // Write the PCI data structure header to the output file + // + if (fwrite (&PciDs, sizeof (PciDs), 1, OutFptr) != 1) { + fprintf (stdout, "ERROR: Failed to write PCI ROM header to output file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + // + // Keep track of how many bytes left to write + // + TotalSize -= HeaderSize; + + // + // Now dump the input file's contents to the output file + // + if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) { + fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + TotalSize -= FileSize; + // + // Pad the rest of the image to make it a multiple of 512 bytes + // + while (TotalSize > 0) { + if (putc (~0, OutFptr) == EOF) { + fprintf (stdout, "ERROR: Failed to write trailing pad bytes output file\n"); + Status = STATUS_ERROR; + goto BailOut; + } + + TotalSize--; + } + +BailOut: + if (InFptr != NULL) { + fclose (InFptr); + } + + // + // Free up our buffers + // + if (Buffer != NULL) { + free (Buffer); + } + + if (CompressedBuffer != NULL) { + free (CompressedBuffer); + } + // + // Print the file name if errors occurred + // + if (Status != STATUS_SUCCESS) { + fprintf (stdout, "Error processing EFI file %s\n", InFile->FileName); + } + + return Status; +} + +static +int +CheckPE32File ( + FILE *Fptr, + UINT16 *MachineType, + UINT16 *SubSystem + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + Fptr - GC_TODO: add argument description + MachineType - GC_TODO: add argument description + SubSystem - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + /*++ + +Routine Description: + + Given a file pointer to a supposed PE32 image file, verify that it is indeed a + PE32 image file, and then return the machine type in the supplied pointer. + +Arguments: + + Fptr File pointer to the already-opened PE32 file + MachineType Location to stuff the machine type of the PE32 file. This is needed + because the image may be Itanium-based, IA32, or EBC. + +Returns: + + 0 success + non-zero otherwise + +--*/ + EFI_IMAGE_DOS_HEADER DosHeader; + EFI_IMAGE_FILE_HEADER FileHdr; + EFI_IMAGE_OPTIONAL_HEADER OptionalHdr; + UINT32 PESig; + + // + // Position to the start of the file + // + fseek (Fptr, 0, SEEK_SET); + + // + // Read the DOS header + // + if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) { + fprintf (stdout, "ERROR: Failed to read the DOS stub from the input file\n"); + return STATUS_ERROR; + } + // + // Check the magic number (0x5A4D) + // + if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) { + fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (magic number)\n"); + return STATUS_ERROR; + } + // + // Position into the file and check the PE signature + // + fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET); + if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) { + fprintf (stdout, "ERROR: Failed to read PE signature bytes from input file\n"); + return STATUS_ERROR; + } + // + // Check the PE signature in the header "PE\0\0" + // + if (PESig != EFI_IMAGE_NT_SIGNATURE) { + fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (signature)\n"); + return STATUS_ERROR; + } + // + // Read the file header and stuff their MachineType + // + if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) { + fprintf (stdout, "ERROR: Failed to read PE file header from input file\n"); + return STATUS_ERROR; + } + + memcpy ((char *) MachineType, &FileHdr.Machine, 2); + + // + // Read the optional header so we can get the subsystem + // + if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) { + fprintf (stdout, "ERROR: Failed to read COFF optional header from input file\n"); + return STATUS_ERROR; + } + + *SubSystem = OptionalHdr.Subsystem; + if (mOptions.Verbose) { + fprintf (stdout, " Got subsystem = 0x%X from image\n", (int) *SubSystem); + } + // + // Good to go + // + return STATUS_SUCCESS; +} + +static +int +ParseCommandLine ( + int Argc, + char *Argv[], + OPTIONS *Options + ) +/*++ + +Routine Description: + + Given the Argc/Argv program arguments, and a pointer to an options structure, + parse the command-line options and check their validity. + + +Arguments: + + Argc - standard C main() argument count + Argv[] - standard C main() argument list + Options - pointer to a structure to store the options in + +Returns: + + STATUS_SUCCESS success + non-zero otherwise + +--*/ +// +{ + FILE_LIST *FileList; + + FILE_LIST *PrevFileList; + UINT32 FileFlags; + UINT32 ClassCode; + UINT32 CodeRevision; + + FileFlags = 0; + + // + // Clear out the options + // + memset ((char *) Options, 0, sizeof (OPTIONS)); + + // + // To avoid compile warnings + // + FileList = PrevFileList = NULL; + + ClassCode = 0; + CodeRevision = 0; + // + // Skip over the program name + // + Argc--; + Argv++; + + // + // If no arguments, assume they want usage info + // + if (Argc == 0) { + Usage (); + return STATUS_ERROR; + } + // + // Process until no more arguments + // + while (Argc > 0) { + if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) { + // + // To simplify string comparisons, replace slashes with dashes + // + Argv[0][0] = '-'; + + // + // Vendor ID specified with -v + // + if (_stricmp (Argv[0], "-v") == 0) { + // + // Make sure there's another parameter + // + if (Argc > 1) { + Options->VendId = (UINT16) strtol (Argv[1], NULL, 16); + Options->VendIdValid = 1; + } else { + fprintf ( + stdout, + "ERROR: Missing Vendor ID with %s\n\n", + Argv[0] + ); + Usage (); + return STATUS_ERROR; + } + + Argv++; + Argc--; + } else if (_stricmp (Argv[0], "-d") == 0) { + // + // Device ID specified with -d + // Make sure there's another parameter + // + if (Argc > 1) { + Options->DevId = (UINT16) strtol (Argv[1], NULL, 16); + Options->DevIdValid = 1; + } else { + fprintf ( + stdout, + "ERROR: Missing Device ID with %s\n\n", + Argv[0] + ); + Usage (); + return STATUS_ERROR; + } + + Argv++; + Argc--; + } else if (_stricmp (Argv[0], "-o") == 0) { + // + // Output filename specified with -o + // Make sure there's another parameter + // + if (Argc > 1) { + strcpy (Options->OutFileName, Argv[1]); + } else { + fprintf ( + stdout, + "ERROR: Missing output file name with %s\n\n", + Argv[0] + ); + Usage (); + return STATUS_ERROR; + } + + Argv++; + Argc--; + } else if ((_stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) { + // + // Help option + // + Usage (); + return STATUS_ERROR; + } else if (_stricmp (Argv[0], "-b") == 0) { + // + // Specify binary files with -b + // + FileFlags = (FileFlags &~FILE_FLAG_EFI) | FILE_FLAG_BINARY; + } else if ((_stricmp (Argv[0], "-e") == 0) || (_stricmp (Argv[0], "-ec") == 0)) { + // + // Specify EFI files with -e. Specify EFI-compressed with -ec. + // + FileFlags = (FileFlags &~FILE_FLAG_BINARY) | FILE_FLAG_EFI; + if ((Argv[0][2] == 'c') || (Argv[0][2] == 'C')) { + FileFlags |= FILE_FLAG_COMPRESS; + } + // + // Specify not to set the LAST bit in the last file with -l + // + } else if (_stricmp (Argv[0], "-l") == 0) { + Options->NoLast = 1; + } else if (_stricmp (Argv[0], "-p") == 0) { + // + // -v for verbose would have been nicer, but it's already used. Let's use + // -p for prolix (wordy) output + // + Options->Verbose = 1; + } else if (_stricmp (Argv[0], "-dump") == 0) { + // + // -dump for dumping a ROM image. In this case, say that the device id + // and vendor id are valid so we don't have to specify bogus ones on the + // command line. + // + Options->DumpOption = 1; + + Options->VendIdValid = 1; + Options->DevIdValid = 1; + FileFlags = FILE_FLAG_BINARY; + } else if (_stricmp (Argv[0], "-cc") == 0) { + // + // Class code value for the next file in the list. + // Make sure there's another parameter + // + if (Argc > 1) { + // + // No error checking on the return value. Could check for LONG_MAX, + // LONG_MIN, or 0 class code value if desired. Check range (3 bytes) + // at least. + // + ClassCode = (UINT32) strtol (Argv[1], NULL, 16); + if (ClassCode & 0xFF000000) { + fprintf (stdout, "ERROR: Class code %s out of range\n", Argv[1]); + return STATUS_ERROR; + } + } else { + fprintf ( + stdout, + "ERROR: Missing class code value with %s\n\n", + Argv[0] + ); + Usage (); + return STATUS_ERROR; + } + + Argv++; + Argc--; + } else if (_stricmp (Argv[0], "-rev") == 0) { + // + // Code revision in the PCI data structure. The value is for the next + // file in the list. + // Make sure there's another parameter + // + if (Argc > 1) { + // + // No error checking on the return value. Could check for LONG_MAX, + // LONG_MIN, or 0 value if desired. Check range (2 bytes) + // at least. + // + CodeRevision = (UINT32) strtol (Argv[1], NULL, 16); + if (CodeRevision & 0xFFFF0000) { + fprintf (stdout, "ERROR: Code revision %s out of range\n", Argv[1]); + return STATUS_ERROR; + } + } else { + fprintf ( + stdout, + "ERROR: Missing code revision value with %s\n\n", + Argv[0] + ); + Usage (); + return STATUS_ERROR; + } + + Argv++; + Argc--; + } else { + fprintf (stdout, "ERROR: Invalid option specified: %s\n\n", Argv[0]); + Usage (); + return STATUS_ERROR; + } + } else { + // + // Not a slash-option argument. Must be a file name. Make sure they've specified + // -e or -b already. + // + if ((FileFlags & (FILE_FLAG_BINARY | FILE_FLAG_EFI)) == 0) { + fprintf (stdout, "ERROR: Missing -e or -b with input file %s\n", Argv[0]); + return STATUS_ERROR; + } + // + // Create a new file structure + // + FileList = (FILE_LIST *) malloc (sizeof (FILE_LIST)); + if (FileList == NULL) { + fprintf (stdout, "ERROR: Memory allocation failure\n"); + return STATUS_ERROR; + } + + memset ((char *) FileList, 0, sizeof (FILE_LIST)); + FileList->FileName = Argv[0]; + FileList->FileFlags = FileFlags; + if (Options->FileList == NULL) { + Options->FileList = FileList; + } else { + if (PrevFileList == NULL) { + PrevFileList = FileList; + } else { + PrevFileList->Next = FileList; + } + } + + PrevFileList = FileList; + // + // Set the class code and code revision for this file, then reset the values. + // + FileList->ClassCode = ClassCode; + FileList->CodeRevision = (UINT16) CodeRevision; + ClassCode = 0; + CodeRevision = 0; + } + // + // Next argument + // + Argv++; + Argc--; + } + // + // Make sure they specified a device ID and vendor ID + // + if (!Options->VendIdValid) { + fprintf (stdout, "ERROR: Missing Vendor ID on command line\n\n"); + Usage (); + return STATUS_ERROR; + } + + if (!Options->DevIdValid) { + fprintf (stdout, "ERROR: Missing Device ID on command line\n\n"); + Usage (); + return STATUS_ERROR; + } + // + // Must have specified some files + // + if (Options->FileList == NULL) { + fprintf (stdout, "ERROR: Missing input file name\n"); + Usage (); + return STATUS_ERROR; + } + + return 0; +} + +static +void +Usage ( + VOID + ) +/*++ + +Routine Description: + + Print usage information for this utility. + +Arguments: + + None. + +Returns: + + Nothing. + +--*/ +{ + int Index; + static const char *Msg[] = { + "EfiRom "UTILITY_VERSION" - Intel EFI Make Option ROM utility", + " Copyright (C), 1999 - 2002 Intel Coproration\n", + " Create an option ROM image from a list of input files", + " Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ", + " [-e|-b] [FileName(s)]", + " where:", + " VendorId - required hex PCI Vendor ID for the device", + " DeviceId - required hex PCI Device ID for the device", + " OutFileName - optional output file name. Default is the first input", + " file name with a "DEFAULT_OUTPUT_EXTENSION" file extension", + " FileNames - input PE32 or binary file name(s)", + " BinFileName - input binary file name(s)", + " -p - for verbose output", + " -l - to not automatically set the LAST bit on the last file", + " -b - following FileNames are binary files", + " -e - following FileNames are EFI PE32 image files", + " -ec - following FileNames are EFI PE32 image files, and should", + " be compressed by this utility", + " -cc ClassCode - to use hex ClassCode in the PCI data structure header for", + " the following FileName", + " -rev Revision - to use hex Revision in the PCI data structure header for", + " the following FileName", + " -dump - to dump the headers of an existing option ROM image", + "", + "Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi ", + "", + NULL + }; + + for (Index = 0; Msg[Index] != NULL; Index++) { + fprintf (stdout, "%s\n", Msg[Index]); + } +} + +static +void +DumpImage ( + FILE_LIST *InFile + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + InFile - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + PCI_EXPANSION_ROM_HEADER PciRomHdr; + FILE *InFptr; + UINT32 ImageStart; + UINT32 ImageCount; + EFI_PCI_EXPANSION_ROM_HEADER EfiRomHdr; + PCI_DATA_STRUCTURE PciDs; + + // + // Open the input file + // + if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) { + fprintf ( + stdout, + "ERROR: Could not open input file %s\n", + InFile->FileName + ); + return ; + } + // + // Go through the image and dump the header stuff for each + // + ImageCount = 0; + for (;;) { + // + // Save our postition in the file, since offsets in the headers + // are relative to the particular image. + // + ImageStart = ftell (InFptr); + ImageCount++; + + // + // Read the option ROM header. Have to assume a raw binary image for now. + // + if (fread (&PciRomHdr, sizeof (PciRomHdr), 1, InFptr) != 1) { + fprintf (stdout, "ERROR: Failed to read PCI ROM header from file\n"); + goto BailOut; + } + + // + // Dump the contents of the header + // + fprintf (stdout, "Image %d -- Offset 0x%X\n", ImageCount, ImageStart); + fprintf (stdout, " ROM header contents\n"); + fprintf (stdout, " Signature 0x%04X\n", (UINT32) PciRomHdr.Signature); + fprintf (stdout, " PCIR offset 0x%04X\n", (UINT32) PciRomHdr.PcirOffset); + // + // Find PCI data structure + // + if (fseek (InFptr, ImageStart + PciRomHdr.PcirOffset, SEEK_SET)) { + fprintf (stdout, "ERROR: Failed to seek to PCI data structure\n"); + goto BailOut; + } + // + // Read and dump the PCI data structure + // + if (fread (&PciDs, sizeof (PciDs), 1, InFptr) != 1) { + fprintf (stdout, "ERROR: Failed to read PCI data structure from file\n"); + goto BailOut; + } + + fprintf (stdout, " PCI Data Structure\n"); + fprintf ( + stdout, + " Signature %c%c%c%c\n", + (char) PciDs.Signature, + (char) (PciDs.Signature >> 8), + (char) (PciDs.Signature >> 16), + (char) (PciDs.Signature >> 24) + ); + fprintf (stdout, " Vendor ID 0x%04X\n", PciDs.VendorId); + fprintf (stdout, " Device ID 0x%04X\n", PciDs.DeviceId); + fprintf ( + stdout, + " Class Code 0x%06X\n", + (UINT32) (PciDs.ClassCode[0] | (PciDs.ClassCode[1] << 8) | (PciDs.ClassCode[2] << 16)) + ); + fprintf (stdout, " Image size 0x%X\n", PciDs.ImageLength * 512); + fprintf (stdout, " Code revision: 0x%04X\n", PciDs.CodeRevision); + fprintf (stdout, " Indicator 0x%02X", (UINT32) PciDs.Indicator); + // + // Print the indicator, used to flag the last image + // + if (PciDs.Indicator == INDICATOR_LAST) { + fprintf (stdout, " (last image)\n"); + } else { + fprintf (stdout, "\n"); + } + // + // Print the code type. If EFI code, then we can provide more info. + // + fprintf (stdout, " Code type 0x%02X", (UINT32) PciDs.CodeType); + if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) { + fprintf (stdout, " (EFI image)\n"); + // + // Re-read the header as an EFI ROM header, then dump more info + // + fprintf (stdout, " EFI ROM header contents\n"); + if (fseek (InFptr, ImageStart, SEEK_SET)) { + fprintf (stdout, "ERROR: Failed to re-seek to ROM header structure\n"); + goto BailOut; + } + + if (fread (&EfiRomHdr, sizeof (EfiRomHdr), 1, InFptr) != 1) { + fprintf (stdout, "ERROR: Failed to read EFI PCI ROM header from file\n"); + goto BailOut; + } + // + // Now dump more info + // + fprintf (stdout, " EFI Signature 0x%04X\n", EfiRomHdr.EfiSignature); + fprintf ( + stdout, + " Compression Type 0x%04X ", + (UINT32) EfiRomHdr.CompressionType + ); + if (EfiRomHdr.CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) { + fprintf (stdout, "(compressed)\n"); + } else { + fprintf (stdout, "(not compressed)\n"); + } + + fprintf ( + stdout, + " Machine type 0x%04X (%s)\n", + EfiRomHdr.EfiMachineType, + GetMachineTypeStr (EfiRomHdr.EfiMachineType) + ); + fprintf ( + stdout, + " Subsystem 0x%04X (%s)\n", + EfiRomHdr.EfiSubsystem, + GetSubsystemTypeStr (EfiRomHdr.EfiSubsystem) + ); + fprintf ( + stdout, + " EFI image offset 0x%04X (@0x%X)\n", + (UINT32) EfiRomHdr.EfiImageHeaderOffset, + (UINT32) (EfiRomHdr.EfiImageHeaderOffset + ImageStart) + ); + + } else { + // + // Not an EFI image + // + fprintf (stdout, "\n"); + } + // + // If code type is EFI image, then dump it as well? + // + // if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) { + // } + // + // If last image, then we're done + // + if (PciDs.Indicator == INDICATOR_LAST) { + goto BailOut; + } + // + // Seek to the start of the next image + // + if (fseek (InFptr, ImageStart + (PciDs.ImageLength * 512), SEEK_SET)) { + fprintf (stdout, "ERROR: Failed to seek to next image\n"); + goto BailOut; + } + } + +BailOut: + fclose (InFptr); +} + +char * +GetMachineTypeStr ( + UINT16 MachineType + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + MachineType - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + int Index; + + for (Index = 0; mMachineTypes[Index].Name != NULL; Index++) { + if (mMachineTypes[Index].Value == MachineType) { + return mMachineTypes[Index].Name; + } + } + + return "unknown"; +} + +static +char * +GetSubsystemTypeStr ( + UINT16 SubsystemType + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + SubsystemType - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + int Index; + + for (Index = 0; mSubsystemTypes[Index].Name != NULL; Index++) { + if (mSubsystemTypes[Index].Value == SubsystemType) { + return mSubsystemTypes[Index].Name; + } + } + + return "unknown"; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/Makefile new file mode 100644 index 0000000000..2832154763 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/Makefile @@ -0,0 +1,85 @@ +#/*++ +# +# Copyright (c) 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the EfiRom utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Target specific information +# + +TARGET_NAME = EfiRom +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe +# +# Build targets +# + +all: $(TARGET_EXE) + +OBJECTS = $(EDK_TOOLS_OUTPUT)\EfiRom.obj \ + $(EDK_TOOLS_OUTPUT)\EfiCompress.obj + +# +# Build the EXE by compiling the source files, then linking the resultant +# object files together. +# + +$(EDK_TOOLS_OUTPUT)\EfiRom.obj : $(TARGET_SOURCE_DIR)\EfiRom.c + $(CC) $(C_FLAGS) $(TARGET_SOURCE_DIR)\EfiRom.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\EfiCompress.obj : $(EDK_TOOLS_SOURCE)\Common\EfiCompress.c + $(CC) $(C_FLAGS) $(EDK_TOOLS_SOURCE)\Common\EfiCompress.c /Fo$@ + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(OBJECTS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/Makefile new file mode 100644 index 0000000000..155680107d --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/Makefile @@ -0,0 +1,96 @@ +#/*++ +# +# Copyright (c) 2006 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the EfildrImage utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=EfildrImage +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\EfildrImage.c" +TARGET_EXE_INCLUDE = + + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/efildrimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/efildrimage.c new file mode 100644 index 0000000000..c072dd73ac --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfildrImage/efildrimage.c @@ -0,0 +1,188 @@ +/*++ + +Copyright 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + efildrimage.c + +Abstract: + + Creates and EFILDR image. + This tool combines several PE Image files together using following format denoted as EBNF: + FILE := EFILDR_HEADER + EFILDR_IMAGE + + + + The order of EFILDR_IMAGE is same as the order of placing PeImageFileContent. + +Revision History + +--*/ + + +#include +#include +#include "Tiano.h" + +#define MAX_PE_IMAGES 63 +#define FILE_TYPE_FIXED_LOADER 0 +#define FILE_TYPE_RELOCATABLE_PE_IMAGE 1 + +typedef struct { + UINT32 CheckSum; + UINT32 Offset; + UINT32 Length; + UINT8 FileName[52]; +} EFILDR_IMAGE; + +typedef struct { + UINT32 Signature; + UINT32 HeaderCheckSum; + UINT32 FileLength; + UINT32 NumberOfImages; +} EFILDR_HEADER; + + + +VOID +Usage ( + VOID + ) +{ + printf ("Usage: EfiLdrImage OutImage LoaderImage PeImage1 PeImage2 ... PeImageN"); + exit (1); +} + +ULONG +FCopyFile ( + FILE *in, + FILE *out + ) +/*++ +Routine Description: + Write all the content of input file to output file. + +Arguments: + in - input file pointer + out - output file pointer + +Return: + ULONG : file size of input file +--*/ +{ + ULONG filesize, offset, length; + UCHAR Buffer[8*1024]; + + fseek (in, 0, SEEK_END); + filesize = ftell(in); + + fseek (in, 0, SEEK_SET); + + offset = 0; + while (offset < filesize) { + length = sizeof(Buffer); + if (filesize-offset < length) { + length = filesize-offset; + } + + fread (Buffer, length, 1, in); + fwrite (Buffer, length, 1, out); + offset += length; + } + + return filesize; +} + + +int +main ( + int argc, + char *argv[] + ) +/*++ + +Routine Description: + + +Arguments: + + +Returns: + + +--*/ +{ + ULONG i; + ULONG filesize; + FILE *fpIn, *fpOut; + EFILDR_HEADER EfiLdrHeader; + EFILDR_IMAGE EfiLdrImage[MAX_PE_IMAGES]; + + if (argc < 4) { + Usage(); + } + + // + // Open output file for write + // + fpOut = fopen(argv[1], "w+b"); + if (!fpOut) { + printf ("efildrimage: Could not open output file %s\n", argv[1]); + exit(1); + } + + memset (&EfiLdrHeader, 0, sizeof (EfiLdrHeader)); + memset (&EfiLdrImage, 0, sizeof (EFILDR_IMAGE) * (argc - 2)); + + memcpy (&EfiLdrHeader.Signature, "EFIL", 4); + EfiLdrHeader.FileLength = sizeof(EFILDR_HEADER) + sizeof(EFILDR_IMAGE)*(argc-2); + + // + // Skip the file header first + // + fseek (fpOut, EfiLdrHeader.FileLength, SEEK_SET); + + // + // copy all the input files to the output file + // + for(i=2;i<(ULONG)argc;i++) { + // + // Copy the content of PeImage file to output file + // + fpIn = fopen (argv[i], "rb"); + if (!fpIn) { + printf ("efildrimage: Could not open input file %s\n", argv[i-2]); + exit(1); + } + filesize = FCopyFile (fpIn, fpOut); + fclose(fpIn); + + // + // And in the same time update the EfiLdrHeader and EfiLdrImage array + // + EfiLdrImage[i-2].Offset = EfiLdrHeader.FileLength; + EfiLdrImage[i-2].Length = filesize; + strncpy (EfiLdrImage[i-2].FileName, argv[i], sizeof (EfiLdrImage[i-2].FileName) - 1); + EfiLdrHeader.FileLength += filesize; + EfiLdrHeader.NumberOfImages++; + } + + // + // Write the image header to the output file finally + // + fseek (fpOut, 0, SEEK_SET); + fwrite (&EfiLdrHeader, sizeof(EFILDR_HEADER) , 1, fpOut); + fwrite (&EfiLdrImage , sizeof(EFILDR_IMAGE)*(argc-2), 1, fpOut); + + fclose (fpOut); + printf ("Created %s\n", argv[1]); + return 0; +} + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/Makefile new file mode 100644 index 0000000000..216ac9782b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/Makefile @@ -0,0 +1,86 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=FwImage +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\FwImage.c" +TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \ + "$(EDK_SOURCE)\Foundation\Efi\Include\EfiImage.h" +OBJECTS = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c new file mode 100644 index 0000000000..8a9274d5c0 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c @@ -0,0 +1,587 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + fwimage.c + +Abstract: + + Converts a pe32/pe32+ image to an FW image type + +--*/ + +#include +#include +#include +#include +#include + +#include "TianoCommon.h" +#include "EfiImage.h" +#include "EfiUtilityMsgs.c" + +#define UTILITY_NAME "FwImage" + +typedef union { + IMAGE_NT_HEADERS32 PeHeader32; + IMAGE_NT_HEADERS64 PeHeader64; +} PE_HEADER; + +VOID +Usage ( + VOID + ) +{ + printf ("Usage: " UTILITY_NAME " {-t time-date} {-e} {-r} [APPLICATION|BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|COMBINED_PEIM_DRIVER|SECURITY_CORE|PEI_CORE|PE32_PEIM|RELOCATABLE_PEIM] peimage [outimage]\n"); + printf (" -t: Add Time Stamp for output image\n"); + printf (" -e: Not clear ExceptionTable for output image\n"); + printf (" -r: Not strip zero pending of .reloc for output image\n"); +} + +static +STATUS +FReadFile ( + FILE *in, + VOID **Buffer, + UINTN *Length + ) +{ + fseek (in, 0, SEEK_END); + *Length = ftell (in); + *Buffer = malloc (*Length); + fseek (in, 0, SEEK_SET); + fread (*Buffer, *Length, 1, in); + return STATUS_SUCCESS; +} + +static +STATUS +FWriteFile ( + FILE *out, + VOID *Buffer, + UINTN Length + ) +{ + fseek (out, 0, SEEK_SET); + fwrite (Buffer, Length, 1, out); + if ((ULONG) ftell (out) != Length) { + Error (NULL, 0, 0, "write error", NULL); + return STATUS_ERROR; + } + free (Buffer); + return STATUS_SUCCESS; +} + +VOID +ZeroExceptionTable ( + IN UINT8 *FileBuffer, + IN EFI_IMAGE_DOS_HEADER *DosHdr, + IN PE_HEADER *PeHdr + ) +{ + UINT32 PdataSize; + UINT32 PdataOffset; + UINT32 PdataRVASize; + UINT32 PdataRVA; + UINT32 SectionOffset; + UINT16 SectionNumber; + UINT32 SectionNameSize; + EFI_IMAGE_SECTION_HEADER *Section; + + PdataSize = 0; + PdataOffset = 0; + PdataRVASize = 0; + PdataRVA = 0; + SectionOffset = 0; + + // + // Search .pdata section + // + if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if ((PeHdr->PeHeader32.OptionalHeader.NumberOfRvaAndSizes > IMAGE_DIRECTORY_ENTRY_EXCEPTION) && + (PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress != 0) && + (PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size != 0)) { + + PdataRVA = PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress; + PdataRVASize = PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size; + + PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress = 0; + PeHdr->PeHeader32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size = 0; + + SectionOffset = sizeof(PeHdr->PeHeader32); + } + } else { + if ((PeHdr->PeHeader64.OptionalHeader.NumberOfRvaAndSizes > IMAGE_DIRECTORY_ENTRY_EXCEPTION) && + (PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress != 0) && + (PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size != 0)) { + + PdataRVA = PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress; + PdataRVASize = PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size; + + PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress = 0; + PeHdr->PeHeader64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size = 0; + + SectionOffset = sizeof(PeHdr->PeHeader64); + } + } + + if ((PdataRVASize != 0) && (PdataRVA != 0)) { + + SectionNumber = PeHdr->PeHeader32.FileHeader.NumberOfSections; + SectionNameSize = sizeof(Section->Name); + while (SectionNumber > 0) { + Section = (EFI_IMAGE_SECTION_HEADER *) &FileBuffer[DosHdr->e_lfanew + SectionOffset]; + if (strcmp (Section->Name, ".pdata") == 0) { + // + // Zero .pdata Section Header Name + // + memset ( + FileBuffer + DosHdr->e_lfanew + SectionOffset, + 0, + SectionNameSize); + + // + // Zero .pdata Secton raw data + // + PdataOffset = Section->PointerToRawData; + PdataSize = Section->SizeOfRawData; + memset (FileBuffer + PdataOffset, 0, PdataSize); + break; + } + SectionNumber--; + SectionOffset += sizeof(EFI_IMAGE_SECTION_HEADER); + } + } + + return ; +} + +VOID +StripZeroPendingReloc ( + IN UINT8 *FileBuffer, + IN OUT UINTN *FileLength, + IN EFI_IMAGE_DOS_HEADER *DosHdr, + IN PE_HEADER *PeHdr + ) +{ + EFI_IMAGE_OPTIONAL_HEADER32 *Optional32; + EFI_IMAGE_OPTIONAL_HEADER64 *Optional64; + EFI_IMAGE_SECTION_HEADER *SectionHeader; + UINTN AllignedRelocSize; + UINTN Index; + + if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->PeHeader32.OptionalHeader; + if ((Optional32->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) && + (Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size != 0)) { + SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->PeHeader32.FileHeader.SizeOfOptionalHeader); + for (Index = 0; Index < PeHdr->PeHeader32.FileHeader.NumberOfSections; Index++, SectionHeader++) { + // + // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory + // + if (strcmp (SectionHeader->Name, ".reloc") == 0) { + SectionHeader->Misc.VirtualSize = Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size; + + AllignedRelocSize = (Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size + + Optional32->FileAlignment - 1) & (~(Optional32->FileAlignment - 1)); + // + // Check to see if there is zero padding at the end of the base relocations + // + if (AllignedRelocSize < SectionHeader->SizeOfRawData) { + // + // Check to see if the base relocations are at the end of the file + // + if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional32->SizeOfImage) { + // + // All the required conditions are met to strip the zero padding of the end of the base relocations section + // + Optional32->SizeOfImage -= (SectionHeader->SizeOfRawData - AllignedRelocSize); + Optional32->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize); + SectionHeader->SizeOfRawData = AllignedRelocSize; + *FileLength = Optional32->SizeOfImage; + } + } + } + } + } + } else { + Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->PeHeader64.OptionalHeader; + if ((Optional64->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) && + (Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size != 0)) { + SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->PeHeader64.FileHeader.SizeOfOptionalHeader); + for (Index = 0; Index < PeHdr->PeHeader64.FileHeader.NumberOfSections; Index++, SectionHeader++) { + // + // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory + // + if (strcmp (SectionHeader->Name, ".reloc") == 0) { + SectionHeader->Misc.VirtualSize = Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size; + + AllignedRelocSize = (Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size + + Optional64->FileAlignment - 1) & (~(Optional64->FileAlignment - 1)); + // + // Check to see if there is zero padding at the end of the base relocations + // + if (AllignedRelocSize < SectionHeader->SizeOfRawData) { + // + // Check to see if the base relocations are at the end of the file + // + if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional64->SizeOfImage) { + // + // All the required conditions are met to strip the zero padding of the end of the base relocations section + // + Optional64->SizeOfImage -= (SectionHeader->SizeOfRawData - AllignedRelocSize); + Optional64->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize); + SectionHeader->SizeOfRawData = AllignedRelocSize; + *FileLength = Optional64->SizeOfImage; + } + } + } + } + } + } +} + +int +main ( + int argc, + char *argv[] + ) +/*++ + +Routine Description: + + Main function. + +Arguments: + + argc - Number of command line parameters. + argv - Array of pointers to command line parameter strings. + +Returns: + + STATUS_SUCCESS - Utility exits successfully. + STATUS_ERROR - Some error occurred during execution. + +--*/ +{ + ULONG Type; + PUCHAR Ext; + PUCHAR p; + PUCHAR pe; + PUCHAR OutImageName; + UCHAR outname[500]; + FILE *fpIn; + FILE *fpOut; + EFI_IMAGE_DOS_HEADER *DosHdr; + PE_HEADER *PeHdr; + time_t TimeStamp; + struct tm TimeStruct; + EFI_IMAGE_DOS_HEADER BackupDosHdr; + ULONG Index; + BOOLEAN TimeStampPresent; + BOOLEAN NeedClearExceptionTable; + BOOLEAN NeedStripZeroPendingReloc; + UINT8 *FileBuffer; + UINTN FileLength; + EFI_IMAGE_OPTIONAL_HEADER32 *Optional32; + EFI_IMAGE_OPTIONAL_HEADER64 *Optional64; + + SetUtilityName (UTILITY_NAME); + // + // Assign to fix compile warning + // + OutImageName = NULL; + Type = 0; + Ext = 0; + TimeStamp = 0; + TimeStampPresent = FALSE; + + NeedClearExceptionTable = TRUE; + NeedStripZeroPendingReloc = TRUE; + + // + // Look for -t time-date option first. If the time is "0", then + // skip it. + // + if ((argc > 2) && !strcmp (argv[1], "-t")) { + TimeStampPresent = TRUE; + if (strcmp (argv[2], "0") != 0) { + // + // Convert the string to a value + // + memset ((char *) &TimeStruct, 0, sizeof (TimeStruct)); + if (sscanf( + argv[2], "%d/%d/%d,%d:%d:%d", + &TimeStruct.tm_mon, /* months since January - [0,11] */ + &TimeStruct.tm_mday, /* day of the month - [1,31] */ + &TimeStruct.tm_year, /* years since 1900 */ + &TimeStruct.tm_hour, /* hours since midnight - [0,23] */ + &TimeStruct.tm_min, /* minutes after the hour - [0,59] */ + &TimeStruct.tm_sec /* seconds after the minute - [0,59] */ + ) != 6) { + Error (NULL, 0, 0, argv[2], "failed to convert to mm/dd/yyyy,hh:mm:ss format"); + return STATUS_ERROR; + } + // + // Now fixup some of the fields + // + TimeStruct.tm_mon--; + TimeStruct.tm_year -= 1900; + // + // Sanity-check values? + // Convert + // + TimeStamp = mktime (&TimeStruct); + if (TimeStamp == (time_t) - 1) { + Error (NULL, 0, 0, argv[2], "failed to convert time"); + return STATUS_ERROR; + } + } + // + // Skip over the args + // + argc -= 2; + argv += 2; + } + + // + // Look for -e option. + // + if ((argc > 1) && !strcmp (argv[1], "-e")) { + NeedClearExceptionTable = FALSE; + // + // Skip over the args + // + argc -= 1; + argv += 1; + } + + // + // Look for -r option + // + if ((argc > 1) && !strcmp (argv[1], "-r")) { + NeedStripZeroPendingReloc = FALSE; + // + // Skip over the args + // + argc -= 1; + argv += 1; + } + + // + // Check for enough args + // + if (argc < 3) { + Usage (); + return STATUS_ERROR; + } + + if (argc == 4) { + OutImageName = argv[3]; + } + // + // Get new image type + // + p = argv[1]; + if (*p == '/' || *p == '\\') { + p += 1; + } + + if (_stricmp (p, "app") == 0 || _stricmp (p, "APPLICATION") == 0) { + Type = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION; + Ext = ".efi"; + + } else if (_stricmp (p, "bsdrv") == 0 || _stricmp (p, "BS_DRIVER") == 0) { + Type = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER; + Ext = ".efi"; + + } else if (_stricmp (p, "rtdrv") == 0 || _stricmp (p, "RT_DRIVER") == 0) { + Type = EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER; + Ext = ".efi"; + + } else if (_stricmp (p, "rtdrv") == 0 || _stricmp (p, "SAL_RT_DRIVER") == 0) { + Type = EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER; + Ext = ".efi"; + } else if (_stricmp (p, "SECURITY_CORE") == 0) { + Type = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER; + Ext = ".sec"; + } else if (_stricmp (p, "peim") == 0 || + _stricmp (p, "PEI_CORE") == 0 || + _stricmp (p, "PE32_PEIM") == 0 || + _stricmp (p, "RELOCATABLE_PEIM") == 0 || + _stricmp (p, "combined_peim_driver") == 0 + ) { + Type = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER; + Ext = ".pei"; + } else { + Usage (); + return STATUS_ERROR; + } + // + // open source file + // + fpIn = fopen (argv[2], "rb"); + if (!fpIn) { + Error (NULL, 0, 0, argv[2], "failed to open input file for reading"); + return STATUS_ERROR; + } + FReadFile (fpIn, (VOID **)&FileBuffer, &FileLength); + // + // Read the dos & pe hdrs of the image + // + DosHdr = (EFI_IMAGE_DOS_HEADER *) FileBuffer; + if (DosHdr->e_magic != IMAGE_DOS_SIGNATURE) { + Error (NULL, 0, 0, argv[2], "DOS header signature not found in source image"); + fclose (fpIn); + return STATUS_ERROR; + } + + PeHdr = (PE_HEADER *)(FileBuffer + DosHdr->e_lfanew); + if (PeHdr->PeHeader32.Signature != IMAGE_NT_SIGNATURE) { + Error (NULL, 0, 0, argv[2], "PE header signature not found in source image"); + fclose (fpIn); + return STATUS_ERROR; + } + // + // open output file + // + strcpy (outname, argv[2]); + pe = NULL; + for (p = outname; *p; p++) { + if (*p == '.') { + pe = p; + } + } + + if (!pe) { + pe = p; + } + + strcpy (pe, Ext); + + if (!OutImageName) { + OutImageName = outname; + } + + fpOut = fopen (OutImageName, "w+b"); + if (!fpOut) { + Error (NULL, 0, 0, OutImageName, "could not open output file for writing"); + fclose (fpIn); + return STATUS_ERROR; + } + // + // Zero all unused fields of the DOS header + // + memcpy (&BackupDosHdr, DosHdr, sizeof (EFI_IMAGE_DOS_HEADER)); + memset (DosHdr, 0, sizeof (EFI_IMAGE_DOS_HEADER)); + DosHdr->e_magic = BackupDosHdr.e_magic; + DosHdr->e_lfanew = BackupDosHdr.e_lfanew; + + for (Index = sizeof (EFI_IMAGE_DOS_HEADER); Index < (ULONG) DosHdr->e_lfanew; Index++) { + FileBuffer[Index] = (UINT8) DosHdr->e_cp; + } + + // + // Modify some fields in the PE header + // + + // + // TimeDateStamp's offset is fixed for PE32/32+ + // + if (TimeStampPresent) { + PeHdr->PeHeader32.FileHeader.TimeDateStamp = (UINT32) TimeStamp; + } + + // + // PE32/32+ has different optional header layout + // Determine format is PE32 or PE32+ before modification + // + if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + // + // PE32 image + // + Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->PeHeader32.OptionalHeader; + + Optional32->MajorLinkerVersion = 0; + Optional32->MinorLinkerVersion = 0; + Optional32->MajorOperatingSystemVersion = 0; + Optional32->MinorOperatingSystemVersion = 0; + Optional32->MajorImageVersion = 0; + Optional32->MinorImageVersion = 0; + Optional32->MajorSubsystemVersion = 0; + Optional32->MinorSubsystemVersion = 0; + Optional32->Win32VersionValue = 0; + Optional32->CheckSum = 0; + Optional32->SizeOfStackReserve = 0; + Optional32->SizeOfStackCommit = 0; + Optional32->SizeOfHeapReserve = 0; + Optional32->SizeOfHeapCommit = 0; + Optional32->Subsystem = (USHORT) Type; + + // + // Strip zero padding at the end of the .reloc section + // + if (NeedStripZeroPendingReloc) { + StripZeroPendingReloc (FileBuffer, &FileLength, DosHdr, PeHdr); + } + } else if (PeHdr->PeHeader32.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + // + // PE32+ image + // + Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->PeHeader64.OptionalHeader; + + Optional64->MajorLinkerVersion = 0; + Optional64->MinorLinkerVersion = 0; + Optional64->MajorOperatingSystemVersion = 0; + Optional64->MinorOperatingSystemVersion = 0; + Optional64->MajorImageVersion = 0; + Optional64->MinorImageVersion = 0; + Optional64->MajorSubsystemVersion = 0; + Optional64->MinorSubsystemVersion = 0; + Optional64->Win32VersionValue = 0; + Optional64->CheckSum = 0; + Optional64->SizeOfStackReserve = 0; + Optional64->SizeOfStackCommit = 0; + Optional64->SizeOfHeapReserve = 0; + Optional64->SizeOfHeapCommit = 0; + Optional64->Subsystem = (USHORT) Type; + + // + // Strip zero padding at the end of the .reloc section + // + if (NeedStripZeroPendingReloc) { + StripZeroPendingReloc (FileBuffer, &FileLength, DosHdr, PeHdr); + } + } else { + Error (NULL, 0, 0, argv[2], "Unsupported PE image"); + fclose (fpIn); + fclose (fpOut); + return STATUS_ERROR; + } + + // + // Zero PDATA section for smaller binary size after compression + // + if (NeedClearExceptionTable) { + ZeroExceptionTable (FileBuffer, DosHdr, PeHdr); + } + + FWriteFile (fpOut, FileBuffer, FileLength); + + // + // Done + // + fclose (fpIn); + fclose (fpOut); + + return STATUS_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c new file mode 100644 index 0000000000..98cbb072de --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c @@ -0,0 +1,467 @@ +/*++ + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + GenAprioriFile.c + +Abstract: + + Given an input file containing a list of GUIDs (or Guided file names), + convert the file to an Apriori file consumable by the dispatcher. + +--*/ + +#include +#include +#include + +#include "EfiCommon.h" +#include "ParseInf.h" +#include "CommonLib.h" // for compare guid +#include "EfiUtilityMsgs.h" + +#define MAX_LINE_LEN 200 +#define MAX_PATH 200 + +// +// typedef unsigned int STATUS; +// #define STATUS_SUCCESS 0 +// #define STATUS_WARNING 1 +// #define STATUS_ERROR 2 +// +#define UTILITY_NAME "GenAprioriFile" +// +// Here's all our globals. +// +static struct { + FILE *BinFptr; // output dependencies to this file + INT8 *AprioriFileName; + INT8 *OutputFileName; + BOOLEAN Intelligent; + BOOLEAN Verbose; + BOOLEAN NullTerminate; +} mGlobals; + +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ); + +static +BOOLEAN +IsCommentLine ( + INT8 *Line + ); + +static +void +Usage ( + VOID + ); + +int +main ( + int Argc, + char *Argv[] + ) +/*++ + +Routine Description: + + Call the routine to parse the command-line options, then process the + Apriori list file and generate the GUID file. + +Arguments: + + Standard C main() argc and argv. + +Returns: + + 0 if successful + nonzero otherwise + +--*/ +// GC_TODO: Argc - add argument and description to function comment +// GC_TODO: ] - add argument and description to function comment +{ + STATUS Status; + FILE *AprioriFptr; + FILE *BinFptr; + INT8 Line[MAX_LINE_LEN]; + EFI_GUID Guid; + EFI_GUID GuidIn; + EFI_GUID ZeroGuid; + UINT32 LineCounter; + // + // Initialize the error printing routines + // + SetUtilityName (UTILITY_NAME); + // + // Clear our globals + // + memset ((char *) &mGlobals, 0, sizeof (mGlobals)); + memset ((char *) &ZeroGuid, 0, sizeof (ZeroGuid)); + AprioriFptr = NULL; + BinFptr = NULL; + + // + // Process the command-line arguments + // + Status = ProcessArgs (Argc, Argv); + if (Status != STATUS_SUCCESS) { + return Status; + } + // + // If arguments were ok, then open the Apriori file and process it. + // + if ((AprioriFptr = fopen (mGlobals.AprioriFileName, "r")) == NULL) { + Error (NULL, 0, 0, mGlobals.AprioriFileName, "failed to open file for reading"); + goto FinishUp; + } + // + // If -i intelligent option specified, then attempt to read and + // existing output file and see if we'd be creating an identical file. + // + if (mGlobals.Intelligent) { + if ((BinFptr = fopen (mGlobals.OutputFileName, "rb")) == NULL) { + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "Creating new apriori file -- no existing file", NULL); + } + + goto CreateFile; + } + // + // Read lines from the input file until done. Convert each to a guid, then + // read a guid from the input file and compare them. + // + while (fgets (Line, sizeof (Line), AprioriFptr) != NULL) { + + if (IsCommentLine (Line)) { + continue; + } + // + // Convert to a guid + // + if (StringToGuid (Line, &Guid) != EFI_SUCCESS) { + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "failed to read GUID from input text file -- creating new file", NULL); + } + + goto CreateFile; + } + // + // Read guid from input file, then compare + // + if (fread (&GuidIn, sizeof (GuidIn), 1, BinFptr) != 1) { + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "failed to read GUID from input binary file -- creating new file", NULL); + } + + goto CreateFile; + } + + if (CompareGuid (&Guid, &GuidIn) != 0) { + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "GUID comparison failed -- creating new file", NULL); + } + + goto CreateFile; + } + } + // + // May be one more NULL guid in the binary file + // + if (mGlobals.NullTerminate) { + if (fread (&GuidIn, sizeof (GuidIn), 1, BinFptr) != 1) { + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "failed to read NULL GUID from input binary file -- creating new file", NULL); + } + + goto CreateFile; + } + + if (CompareGuid (&GuidIn, &ZeroGuid) != 0) { + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "NULL GUID comparison failed -- creating new file", NULL); + } + + goto CreateFile; + } + } + // + // Make sure we're at the end of both files. + // + if ((fgets (Line, sizeof (Line), AprioriFptr) != NULL) || (fread (&GuidIn, 1, 1, BinFptr) != 0)) { + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "file sizes different, -i test failed -- creating new file", NULL); + } + + goto CreateFile; + } + + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, "existing file would be unchanged -- keeping existing apriori file", NULL); + } + + goto FinishUp; + } + +CreateFile: + // + // Rewind the Apriori file in case -i was specified. Also + // try to close the output file for the case where we prescanned + // it (again, because of -i). + // + rewind (AprioriFptr); + if (BinFptr != NULL) { + fclose (BinFptr); + } + // + // Open the output file + // + if ((BinFptr = fopen (mGlobals.OutputFileName, "wb")) == NULL) { + Error (NULL, 0, 0, mGlobals.OutputFileName, "could not open input file"); + goto FinishUp; + } + // + // Read lines until we're done + // + LineCounter = 0; + while (fgets (Line, sizeof (Line), AprioriFptr) != NULL) { + LineCounter++; + if (IsCommentLine (Line)) { + continue; + } + // + // Convert to a GUID + // + if (StringToGuid (Line, &Guid) != EFI_SUCCESS) { + Error (mGlobals.AprioriFileName, LineCounter, 0, "failed to convert GUID", NULL); + goto FinishUp; + } + // + // Write the guid to the output file + // + if (fwrite (&Guid, sizeof (Guid), 1, BinFptr) != 1) { + Error (NULL, 0, 0, mGlobals.OutputFileName, "failed to write GUID to output file"); + goto FinishUp; + } + } + // + // Write a null guid out to terminate the list + // + if (mGlobals.NullTerminate) { + memset ((void *) &Guid, 0, sizeof (Guid)); + if (fwrite (&Guid, sizeof (Guid), 1, BinFptr) != 1) { + Error (NULL, 0, 0, mGlobals.OutputFileName, "failed to write NULL termination GUID to output file"); + } + } + +FinishUp: + + if (AprioriFptr != NULL) { + fclose (AprioriFptr); + } + + if (BinFptr != NULL) { + fclose (BinFptr); + } + + return GetUtilityStatus (); +} + +static +BOOLEAN +IsCommentLine ( + INT8 *Line + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + Line - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + for (; isspace (*Line) && *Line; Line++) + ; + + // + // Allow # or // comments + // + if ((*Line == '#') || ((*Line == '/') && (*(Line + 1) == '/')) || (*Line == '\n') || (*Line == 0)) { + return TRUE; + } + + return FALSE; +} +// +// Process the command-line arguments +// +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + Argc - GC_TODO: add argument description + ] - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + // + // Skip program name + // + Argc--; + Argv++; + + // + // Process until no more args + // + while (Argc) { + // + // -f AprioriFile + // + if (_stricmp (Argv[0], "-f") == 0) { + // + // check for one more arg + // + if (Argc > 1) { + mGlobals.AprioriFileName = Argv[1]; + } else { + Error (NULL, 0, 0, NULL, "missing filename with %s", Argv[0]); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-i") == 0) { + // + // intelligent creation of output file. That is to say, if + // there's already a file there, and it's the same as what + // we'd create, then don't re-create. This is to support + // incremental builds (that is to say, running nmake a second time + // does nothing). + // + mGlobals.Intelligent = TRUE; + } else if (_stricmp (Argv[0], "-v") == 0) { + mGlobals.Verbose = TRUE; + } else if (_stricmp (Argv[0], "-null") == 0) { + mGlobals.NullTerminate = TRUE; + } else if (_stricmp (Argv[0], "-o") == 0) { + // + // -o OutputFileName + // check for one more arg + // + if (Argc > 1) { + mGlobals.OutputFileName = Argv[1]; + } else { + Error (NULL, 0, 0, NULL, "missing filename argument with %s", Argv[0]); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if ((_stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) { + Usage (); + return STATUS_ERROR; + } else { + Error (NULL, 0, 0, Argv[0], "unrecognized option"); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } + // + // Had to specify the apriori input file and output file names + // + if (mGlobals.AprioriFileName == NULL) { + Error (NULL, 0, 0, "must specify -f AprioriFile", NULL); + Usage (); + return STATUS_ERROR; + } + + if (mGlobals.OutputFileName == NULL) { + Error (NULL, 0, 0, "must specify -o OutputFile", NULL); + Usage (); + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} + +static +void +Usage ( + VOID + ) +/*++ + +Routine Description: + + Print usage information for this utility. + +Arguments: + + None. + +Returns: + + Nothing. + +--*/ +{ + int Index; + static const char *Str[] = { + UTILITY_NAME " -- create an Apriori file consumable by the DXE dispatcher", + " Usage: "UTILITY_NAME " [Options]", + " Options include:", + " -h or -? for this help information", + " -f AprioriFile parse the GUID'ed files in AprioriFile (required)", + " -o OutputFile write output to OutputFile (required)", + " -i for intelligent re-creation of OutputFile", + " -null to terminate the output file with a NULL GUID", + " -v verbose option", + "", + NULL + }; + for (Index = 0; Str[Index] != NULL; Index++) { + fprintf (stdout, "%s\n", Str[Index]); + } +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/Makefile new file mode 100644 index 0000000000..887da4fc8e --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/Makefile @@ -0,0 +1,78 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# makefile +# +# Abstract: +# +# makefile for building the GenAproriFile utility. +# +# Revision History +# +#--*/ + + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Target specific information +# + +TARGET_NAME = GenAprioriFile +TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\GenAprioriFile.exe +LIBS = $(EDK_TOOLS_OUTPUT)\Common.lib + +# +# Build targets +# + +all: $(TARGET_EXE) + +OBJECTS = $(EDK_TOOLS_OUTPUT)\GenAprioriFile.obj + +# +# Compile each source file +# +$(EDK_TOOLS_OUTPUT)\GenAprioriFile.obj : $(TARGET_SRC_DIR)\GenAprioriFile.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\GenAprioriFile.c /Fo$@ + +# +# Add Binary Build description for this tools. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(OBJECTS) $(LIBS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* del /q $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del /q $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/GetDrvNumOffset.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/GetDrvNumOffset.c new file mode 100644 index 0000000000..d16358b4e7 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/GetDrvNumOffset.c @@ -0,0 +1,58 @@ +#include "fat.h" +#include + +INTN +GetDrvNumOffset ( + IN VOID *BootSector + ) +{ + FAT_BPB_STRUCT *FatBpb; + UINTN RootDirSectors; + UINTN FATSz; + UINTN TotSec; + UINTN DataSec; + UINTN CountOfClusters; + + FatBpb = (FAT_BPB_STRUCT *) BootSector; + + // + // Check FAT type algorithm from FAT spec + // + RootDirSectors = ((FatBpb->Fat12_16.BPB_RootEntCnt * sizeof(FAT_DIRECTORY_ENTRY)) + + (FatBpb->Fat12_16.BPB_BytsPerSec - 1)) / FatBpb->Fat12_16.BPB_BytsPerSec; + + if (FatBpb->Fat12_16.BPB_FATSz16 != 0) { + FATSz = FatBpb->Fat12_16.BPB_FATSz16; + } else { + FATSz = FatBpb->Fat32.BPB_FATSz32; + } + if (FATSz == 0) { + fprintf (stderr, "ERROR: FAT: BPB_FATSz16, BPB_FATSz32 - 0, expected - Non-Zero\n"); + return -1; + } + + if (FatBpb->Fat12_16.BPB_TotSec16 != 0) { + TotSec = FatBpb->Fat12_16.BPB_TotSec16; + } else { + TotSec = FatBpb->Fat12_16.BPB_TotSec32; + } + if (TotSec == 0) { + fprintf (stderr, "ERROR: FAT: BPB_TotSec16, BPB_TotSec32 - 0, expected - Non-Zero\n"); + return -1; + } + + DataSec = TotSec - ( + FatBpb->Fat12_16.BPB_RsvdSecCnt + + FatBpb->Fat12_16.BPB_NumFATs * FATSz + + RootDirSectors + ); + + CountOfClusters = DataSec / FatBpb->Fat12_16.BPB_SecPerClus; + + if (CountOfClusters < FAT_MAX_FAT16_CLUSTER) { + return (INTN) ((UINTN) &FatBpb->Fat12_16.BS_DrvNum - (UINTN) FatBpb); + } else { + return (INTN) ((UINTN) &FatBpb->Fat32.BS_DrvNum - (UINTN) FatBpb); + } +} + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/fat.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/fat.h new file mode 100644 index 0000000000..330312688b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/fat.h @@ -0,0 +1,158 @@ +/*++ + +Copyright 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + fat.h + +Abstract: + +Revision History + +--*/ + +#ifndef _FAT_BPB_H_ +#define _FAT_BPB_H_ + +#include "Tiano.h" + +#pragma pack(1) + +typedef struct { + // + // Fat common field + // + UINT8 BS_jmpBoot[3]; + CHAR8 BS_OEMName[8]; + UINT16 BPB_BytsPerSec; + UINT8 BPB_SecPerClus; + UINT16 BPB_RsvdSecCnt; + UINT8 BPB_NumFATs; + UINT16 BPB_RootEntCnt; + UINT16 BPB_TotSec16; + UINT8 BPB_Media; + UINT16 BPB_FATSz16; + UINT16 BPB_SecPerTrk; + UINT16 BPB_NumHeads; + UINT32 BPB_HiddSec; + UINT32 BPB_TotSec32; + + // + // Fat12/16 specific field + // + UINT8 BS_DrvNum; + UINT8 BS_Reserved1; + UINT8 BS_BootSig; + UINT32 BS_VolID; + CHAR8 BS_VolLab[11]; + CHAR8 BS_FilSysType[8]; + + // + // Boot Code and Data + // + UINT8 Reserved[448]; + + // + // Fat common signature - 0xAA55 + // + UINT16 Signature; +} FAT12_16_BPB_STRUCT; + +typedef struct { + // + // Fat common field + // + UINT8 BS_jmpBoot[3]; + CHAR8 BS_OEMName[8]; + UINT16 BPB_BytsPerSec; + UINT8 BPB_SecPerClus; + UINT16 BPB_RsvdSecCnt; + UINT8 BPB_NumFATs; + UINT16 BPB_RootEntCnt; + UINT16 BPB_TotSec16; + UINT8 BPB_Media; + UINT16 BPB_FATSz16; + UINT16 BPB_SecPerTrk; + UINT16 BPB_NumHeads; + UINT32 BPB_HiddSec; + UINT32 BPB_TotSec32; + + // + // Fat32 specific field + // + UINT32 BPB_FATSz32; + UINT16 BPB_ExtFlags; + UINT16 BPB_FSVer; + UINT32 BPB_RootClus; + UINT16 BPB_FSInfo; + UINT16 BPB_BkBootSec; + UINT8 BPB_Reserved[12]; + UINT8 BS_DrvNum; + UINT8 BS_Reserved1; + UINT8 BS_BootSig; + UINT32 BS_VolID; + CHAR8 BS_VolLab[11]; + CHAR8 BS_FilSysType[8]; + + // + // Boot Code and Data + // + UINT8 Reserved[420]; + + // + // Fat common signature - 0xAA55 + // + UINT16 Signature; +} FAT32_BPB_STRUCT; + +typedef union { + FAT12_16_BPB_STRUCT Fat12_16; + FAT32_BPB_STRUCT Fat32; +} FAT_BPB_STRUCT; + +typedef enum { + FatTypeUnknown, + FatTypeFat12, + FatTypeFat16, + FatTypeFat32, + FatTypeMax +} FAT_TYPE; + +typedef struct { + CHAR8 DIR_Name[11]; + UINT8 DIR_Attr; + UINT8 DIR_NTRes; + UINT8 DIR_CrtTimeTenth; + UINT16 DIR_CrtTime; + UINT16 DIR_CrtDate; + UINT16 DIR_LstAccDate; + UINT16 DIR_FstClusHI; + UINT16 DIR_WrtTime; + UINT16 DIR_WrtDate; + UINT16 DIR_FstClusLO; + UINT32 DIR_FileSize; +} FAT_DIRECTORY_ENTRY; + +#pragma pack() + +#define FAT_MAX_FAT12_CLUSTER 0xFF5 +#define FAT_MAX_FAT16_CLUSTER 0xFFF5 + +#define FAT_BS_SIGNATURE 0xAA55 +#define FAT_BS_BOOTSIG 0x29 +#define FAT_BS_JMP1 0xEB +#define FAT_BS_JMP2 0xE9 +#define FAT_FILSYSTYPE "FAT " +#define FAT12_FILSYSTYPE "FAT12 " +#define FAT16_FILSYSTYPE "FAT16 " +#define FAT32_FILSYSTYPE "FAT32 " + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/genbootsector.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/genbootsector.c new file mode 100644 index 0000000000..8438502b7c --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/genbootsector.c @@ -0,0 +1,652 @@ +/*++ + +Copyright 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + genbootsector.c + +Abstract: + Reading/writing MBR/DBR. + NOTE: + If we write MBR to disk, we just update the MBR code and the partition table wouldn't be over written. + If we process DBR, we will patch MBR to set first partition active if no active partition exists. + +--*/ + +#include +#include +#include + +#define MAX_DRIVE 26 +#define PARTITION_TABLE_OFFSET 0x1BE + +#define SIZE_OF_PARTITION_ENTRY 0x10 + +#define PARTITION_ENTRY_STARTLBA_OFFSET 8 + +#define PARTITION_ENTRY_NUM 4 + +INT +GetDrvNumOffset ( + IN VOID *BootSector + ); + +typedef enum { + PatchTypeUnknown, + PatchTypeFloppy, + PatchTypeIde, + PatchTypeUsb, +} PATCH_TYPE; + +typedef enum { + ErrorSuccess, + ErrorFileCreate, + ErrorFileReadWrite, + ErrorNoMbr, + ErrorFatType +} ERROR_STATUS; + +CHAR *ErrorStatusDesc[] = { + "Success", + "Failed to create files", + "Failed to read/write files", + "No MBR exists", + "Failed to detect Fat type" +}; + +typedef struct _DRIVE_TYPE_DESC { + UINT Type; + CHAR *Description; +} DRIVE_TYPE_DESC; + +#define DRIVE_TYPE_ITEM(x) {x, #x} +DRIVE_TYPE_DESC DriveTypeDesc[] = { + DRIVE_TYPE_ITEM (DRIVE_UNKNOWN), + DRIVE_TYPE_ITEM (DRIVE_NO_ROOT_DIR), + DRIVE_TYPE_ITEM (DRIVE_REMOVABLE), + DRIVE_TYPE_ITEM (DRIVE_FIXED), + DRIVE_TYPE_ITEM (DRIVE_REMOTE), + DRIVE_TYPE_ITEM (DRIVE_CDROM), + DRIVE_TYPE_ITEM (DRIVE_RAMDISK), + (UINT) -1, NULL +}; + +typedef struct _DRIVE_INFO { + CHAR VolumeLetter; + DRIVE_TYPE_DESC *DriveType; + UINT DiskNumber; +} DRIVE_INFO; + +#define BOOT_SECTOR_LBA_OFFSET 0x1FA + +#define IsLetter(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z')) + +BOOL +GetDriveInfo ( + CHAR VolumeLetter, + DRIVE_INFO *DriveInfo + ) +/*++ +Routine Description: + Get drive information including disk number and drive type, + where disknumber is useful for reading/writing disk raw data. + NOTE: Floppy disk doesn't have disk number but it doesn't matter because + we can reading/writing floppy disk without disk number. + +Arguments: + VolumeLetter : volume letter, e.g.: C for C:, A for A: + DriveInfo : pointer to DRIVE_INFO structure receiving drive information. + +Return: + TRUE : successful + FALSE : failed +--*/ +{ + HANDLE VolumeHandle; + STORAGE_DEVICE_NUMBER StorageDeviceNumber; + DWORD BytesReturned; + BOOL Success; + UINT DriveType; + UINT Index; + + CHAR RootPath[] = "X:\\"; // "X:\" -> for GetDriveType + CHAR VolumeAccessPath[] = "\\\\.\\X:"; // "\\.\X:" -> to open the volume + + RootPath[0] = VolumeAccessPath[4] = VolumeLetter; + DriveType = GetDriveType(RootPath); + if (DriveType != DRIVE_REMOVABLE && DriveType != DRIVE_FIXED) { + return FALSE; + } + + DriveInfo->VolumeLetter = VolumeLetter; + VolumeHandle = CreateFile ( + VolumeAccessPath, + 0, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, + NULL + ); + if (VolumeHandle == INVALID_HANDLE_VALUE) { + fprintf ( + stderr, + "ERROR: CreateFile failed: Volume = %s, LastError = 0x%x\n", + VolumeAccessPath, + GetLastError () + ); + return FALSE; + } + + // + // Get Disk Number. It should fail when operating on floppy. That's ok + // because Disk Number is only needed when operating on Hard or USB disk. + // + // To direct write to disk: + // for USB and HD: use path = \\.\PHYSICALDRIVEx, where x is Disk Number + // for floppy: use path = \\.\X:, where X can be A or B + // + Success = DeviceIoControl( + VolumeHandle, + IOCTL_STORAGE_GET_DEVICE_NUMBER, + NULL, + 0, + &StorageDeviceNumber, + sizeof(StorageDeviceNumber), + &BytesReturned, + NULL + ); + // + // DeviceIoControl should fail if Volume is floppy or network drive. + // + if (!Success) { + DriveInfo->DiskNumber = (UINT) -1; + } else if (StorageDeviceNumber.DeviceType != FILE_DEVICE_DISK) { + // + // Only care about the disk. + // + return FALSE; + } else{ + DriveInfo->DiskNumber = StorageDeviceNumber.DeviceNumber; + } + CloseHandle(VolumeHandle); + + // + // Fill in the type string + // + DriveInfo->DriveType = NULL; + for (Index = 0; DriveTypeDesc[Index].Description != NULL; Index ++) { + if (DriveType == DriveTypeDesc[Index].Type) { + DriveInfo->DriveType = &DriveTypeDesc[Index]; + break; + } + } + + if (DriveInfo->DriveType == NULL) { + // + // Should have a type. + // + fprintf (stderr, "ERROR: fetal error!!!\n"); + return FALSE; + } + return TRUE; +} + +VOID +ListDrive ( + VOID + ) +/*++ +Routine Description: + List every drive in current system and their information. + +--*/ +{ + UINT Index; + DRIVE_INFO DriveInfo; + + UINT Mask = GetLogicalDrives(); + + for (Index = 0; Index < MAX_DRIVE; Index++) { + if (((Mask >> Index) & 0x1) == 1) { + if (GetDriveInfo ('A' + (CHAR) Index, &DriveInfo)) { + if (Index < 2) { + // Floppy will occupy 'A' and 'B' + fprintf ( + stdout, + "%c: - Type: %s\n", + DriveInfo.VolumeLetter, + DriveInfo.DriveType->Description + ); + } + else { + fprintf ( + stdout, + "%c: - DiskNum: %d, Type: %s\n", + DriveInfo.VolumeLetter, + DriveInfo.DiskNumber, + DriveInfo.DriveType->Description + ); + } + } + } + } + +} + +INT +GetBootSectorOffset ( + HANDLE DiskHandle, + BOOL WriteToDisk, + PATCH_TYPE PatchType + ) +/*++ +Description: + Get the offset of boot sector. + For non-MBR disk, offset is just 0 + for disk with MBR, offset needs to be caculated by parsing MBR + + NOTE: if no one is active, we will patch MBR to select first partition as active. + +Arguments: + DiskHandle : HANDLE of disk + WriteToDisk : TRUE indicates writing + PatchType : PatchTypeFloppy, PatchTypeIde, PatchTypeUsb + +Return: + -1 : failed + o.w. : Offset to boot sector +--*/ +{ + BYTE DiskPartition[0x200]; + DWORD BytesReturn; + DWORD DbrOffset; + DWORD Index; + BOOL HasMbr; + + DbrOffset = 0; + HasMbr = FALSE; + + SetFilePointer(DiskHandle, 0, NULL, FILE_BEGIN); + if (!ReadFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) { + return -1; + } + + // + // Check Signature, Jmp, and Boot Indicator. + // if all pass, we assume MBR found. + // + + // Check Signature: 55AA + if ((DiskPartition[0x1FE] == 0x55) && (DiskPartition[0x1FF] == 0xAA)) { + // Check Jmp: (EB ?? 90) or (E9 ?? ??) + if (((DiskPartition[0] != 0xEB) || (DiskPartition[2] != 0x90)) && + (DiskPartition[0] != 0xE9)) { + // Check Boot Indicator: 0x00 or 0x80 + // Boot Indicator is the first byte of Partition Entry + HasMbr = TRUE; + for (Index = 0; Index < PARTITION_ENTRY_NUM; ++Index) { + if ((DiskPartition[PARTITION_TABLE_OFFSET + Index * SIZE_OF_PARTITION_ENTRY] & 0x7F) != 0) { + HasMbr = FALSE; + break; + } + } + } + } + + if (HasMbr) { + // + // Skip MBR + // + for (Index = 0; Index < PARTITION_ENTRY_NUM; Index++) { + // + // Found Boot Indicator. + // + if (DiskPartition[PARTITION_TABLE_OFFSET + (Index * SIZE_OF_PARTITION_ENTRY)] == 0x80) { + DbrOffset = *(DWORD *)&DiskPartition[PARTITION_TABLE_OFFSET + (Index * SIZE_OF_PARTITION_ENTRY) + PARTITION_ENTRY_STARTLBA_OFFSET]; + break; + } + } + // + // If no boot indicator, we manually select 1st partition, and patch MBR. + // + if (Index == PARTITION_ENTRY_NUM) { + DbrOffset = *(DWORD *)&DiskPartition[PARTITION_TABLE_OFFSET + PARTITION_ENTRY_STARTLBA_OFFSET]; + if (WriteToDisk && (PatchType == PatchTypeUsb)) { + SetFilePointer(DiskHandle, 0, NULL, FILE_BEGIN); + DiskPartition[PARTITION_TABLE_OFFSET] = 0x80; + WriteFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL); + } + } + } + + return DbrOffset; +} + +ERROR_STATUS +ProcessBsOrMbr ( + CHAR *DiskName, + CHAR *FileName, + BOOL WriteToDisk, + PATCH_TYPE PatchType, + BOOL ProcessMbr + ) +/*++ +Routine Description: + Writing or reading boot sector or MBR according to the argument. + +Arguments: + DiskName : Win32 API recognized string name of disk + FileName : file name + WriteToDisk : TRUE is to write content of file to disk, otherwise, reading content of disk to file + PatchType : PatchTypeFloppy, PatchTypeIde, PatchTypeUsb + ProcessMbr : TRUE is to process MBR, otherwise, processing boot sector + +Return: + ErrorSuccess + ErrorFileCreate + ErrorFileReadWrite + ErrorNoMbr + ErrorFatType +--*/ +{ + BYTE DiskPartition[0x200]; + BYTE DiskPartitionBackup[0x200]; + HANDLE DiskHandle; + HANDLE FileHandle; + DWORD BytesReturn; + DWORD DbrOffset; + INT DrvNumOffset; + + DiskHandle = CreateFile ( + DiskName, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL + ); + if (DiskHandle == INVALID_HANDLE_VALUE) { + return ErrorFileCreate; + } + + FileHandle = CreateFile ( + FileName, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL + ); + if (FileHandle == INVALID_HANDLE_VALUE) { + return ErrorFileCreate; + } + + DbrOffset = 0; + // + // Skip potential MBR for Ide & USB disk + // + if ((PatchType == PatchTypeIde) || (PatchType == PatchTypeUsb)) { + // + // Even user just wants to process MBR, we get offset of boot sector here to validate the disk + // if disk have MBR, DbrOffset should be greater than 0 + // + DbrOffset = GetBootSectorOffset (DiskHandle, WriteToDisk, PatchType); + + if (!ProcessMbr) { + // + // 1. Process boot sector, set file pointer to the beginning of boot sector + // + SetFilePointer (DiskHandle, DbrOffset * 0x200, NULL, FILE_BEGIN); + } else if(DbrOffset == 0) { + // + // If user want to process Mbr, but no Mbr exists, simply return FALSE + // + return ErrorNoMbr; + } else { + // + // 2. Process MBR, set file pointer to 0 + // + SetFilePointer (DiskHandle, 0, NULL, FILE_BEGIN); + } + } + + // + // [File Pointer is pointed to beginning of Mbr or Dbr] + // + if (WriteToDisk) { + // + // Write + // + if (!ReadFile (FileHandle, DiskPartition, 0x200, &BytesReturn, NULL)) { + return ErrorFileReadWrite; + } + if (ProcessMbr) { + // + // Use original partition table + // + if (!ReadFile (DiskHandle, DiskPartitionBackup, 0x200, &BytesReturn, NULL)) { + return ErrorFileReadWrite; + } + memcpy (DiskPartition + 0x1BE, DiskPartitionBackup + 0x1BE, 0x40); + SetFilePointer (DiskHandle, 0, NULL, FILE_BEGIN); + } + + if (!WriteFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) { + return ErrorFileReadWrite; + } + + } else { + // + // Read + // + if (!ReadFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) { + return ErrorFileReadWrite; + } + + if (PatchType == PatchTypeUsb) { + // Manually set BS_DrvNum to 0x80 as window's format.exe has a bug which will clear this field discarding USB disk's MBR. + // offset of BS_DrvNum is 0x24 for FAT12/16 + // 0x40 for FAT32 + // + DrvNumOffset = GetDrvNumOffset (DiskPartition); + if (DrvNumOffset == -1) { + return ErrorFatType; + } + // + // Some legacy BIOS require 0x80 discarding MBR. + // Question left here: is it needed to check Mbr before set 0x80? + // + DiskPartition[DrvNumOffset] = ((DbrOffset > 0) ? 0x80 : 0); + } + + + if (PatchType == PatchTypeIde) { + // + // Patch LBAOffsetForBootSector + // + *(DWORD *)&DiskPartition [BOOT_SECTOR_LBA_OFFSET] = DbrOffset; + } + if (!WriteFile (FileHandle, DiskPartition, 0x200, &BytesReturn, NULL)) { + return ErrorFileReadWrite; + } + } + CloseHandle (FileHandle); + CloseHandle (DiskHandle); + return ErrorSuccess; +} + +VOID +PrintUsage ( + CHAR* AppName + ) +{ + fprintf ( + stdout, + "Usage: %s [OPTIONS]...\n" + "Copy file content from/to bootsector.\n" + "\n" + " -l list disks\n" + " -if=FILE specified an input, can be files or disks\n" + " -of=FILE specified an output, can be files or disks\n" + " -mbr process MBR also\n" + " -h print this message\n" + "\n" + "FILE providing a volume plus a colon (X:), indicates a disk\n" + "FILE providing other format, indicates a file\n", + AppName + ); +} + +INT +main ( + INT argc, + CHAR *argv[] + ) +{ + CHAR *AppName; + INT Index; + BOOL ProcessMbr; + CHAR VolumeLetter; + CHAR *FilePath; + BOOL WriteToDisk; + DRIVE_INFO DriveInfo; + PATCH_TYPE PatchType; + ERROR_STATUS Status; + + CHAR FloppyPathTemplate[] = "\\\\.\\%c:"; + CHAR DiskPathTemplate[] = "\\\\.\\PHYSICALDRIVE%u"; + CHAR DiskPath[MAX_PATH]; + + AppName = *argv; + argv ++; + argc --; + + ProcessMbr = FALSE; + WriteToDisk = TRUE; + FilePath = NULL; + VolumeLetter = 0; + + // + // Parse command line + // + for (Index = 0; Index < argc; Index ++) { + if (_stricmp (argv[Index], "-l") == 0) { + ListDrive (); + return 0; + } + else if (_stricmp (argv[Index], "-mbr") == 0) { + ProcessMbr = TRUE; + } + else if ((_strnicmp (argv[Index], "-if=", 4) == 0) || + (_strnicmp (argv[Index], "-of=", 4) == 0) + ) { + if (argv[Index][6] == '\0' && argv[Index][5] == ':' && IsLetter (argv[Index][4])) { + VolumeLetter = argv[Index][4]; + if (_strnicmp (argv[Index], "-if=", 4) == 0) { + WriteToDisk = FALSE; + } + } + else { + FilePath = &argv[Index][4]; + } + } + else { + PrintUsage (AppName); + return 1; + } + } + + // + // Check parameter + // + if (VolumeLetter == 0) { + fprintf (stderr, "ERROR: Volume isn't provided!\n"); + PrintUsage (AppName); + return 1; + } + + if (FilePath == NULL) { + fprintf (stderr, "ERROR: File isn't pvovided!\n"); + PrintUsage (AppName); + return 1; + } + + PatchType = PatchTypeUnknown; + + if ((VolumeLetter == 'A') || (VolumeLetter == 'a') || + (VolumeLetter == 'B') || (VolumeLetter == 'b') + ) { + // + // Floppy + // + sprintf (DiskPath, FloppyPathTemplate, VolumeLetter); + PatchType = PatchTypeFloppy; + } + else { + // + // Hard/USB disk + // + if (!GetDriveInfo (VolumeLetter, &DriveInfo)) { + fprintf (stderr, "ERROR: GetDriveInfo - 0x%x\n", GetLastError ()); + return 1; + } + + // + // Shouldn't patch my own hard disk, but can read it. + // very safe then:) + // + if (DriveInfo.DriveType->Type == DRIVE_FIXED && WriteToDisk) { + fprintf (stderr, "ERROR: Write to local harddisk - permission denied!\n"); + return 1; + } + + sprintf (DiskPath, DiskPathTemplate, DriveInfo.DiskNumber); + if (DriveInfo.DriveType->Type == DRIVE_REMOVABLE) { + PatchType = PatchTypeUsb; + } + else if (DriveInfo.DriveType->Type == DRIVE_FIXED) { + PatchType = PatchTypeIde; + } + } + + if (PatchType == PatchTypeUnknown) { + fprintf (stderr, "ERROR: PatchType unknown!\n"); + return 1; + } + + // + // Process DBR (Patch or Read) + // + Status = ProcessBsOrMbr (DiskPath, FilePath, WriteToDisk, PatchType, ProcessMbr); + if (Status == ErrorSuccess) { + fprintf ( + stdout, + "%s %s: successfully!\n", + WriteToDisk ? "Write" : "Read", + ProcessMbr ? "MBR" : "DBR" + ); + return 0; + } else { + fprintf ( + stderr, + "%s: %s %s: failed - %s (LastError: 0x%x)!\n", + (Status == ErrorNoMbr) ? "WARNING" : "ERROR", + WriteToDisk ? "Write" : "Read", + ProcessMbr ? "MBR" : "DBR", + ErrorStatusDesc[Status], + GetLastError () + ); + return 1; + } +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/makefile new file mode 100644 index 0000000000..359f126111 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenBootsector/makefile @@ -0,0 +1,99 @@ +#/*++ +# +# Copyright (c) 2006 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the GenBootsector utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=GenBootsector +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenBootsector.c" +TARGET_EXE_INCLUDE = + + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# +$(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj: $(TARGET_SOURCE_DIR)\GenBootsector.c $(TARGET_SOURCE_DIR)\fat.h + $(CC) $(C_FLAGS) $(INC) $(TARGET_SOURCE_DIR)\GetDrvNumOffset.c /Fo$(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) user32.lib advapi32.lib /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.obj + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.* del $(EDK_TOOLS_OUTPUT)\GetDrvNumOffset.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c new file mode 100644 index 0000000000..27a02a4da9 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c @@ -0,0 +1,299 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenCRC32Section.c + +Abstract: + + This file contains functions required to generate a Firmware File System + file. The code is compliant with the Tiano C Coding standards. + +--*/ + +#include "TianoCommon.h" +#include "EfiFirmwareFileSystem.h" +#include "EfiFirmwareVolumeHeader.h" +#include "ParseInf.h" +#include "crc32.h" +#include "EfiUtilityMsgs.h" +#include "GenCRC32Section.h" +#include +#include +#include +#include +#include "CommonLib.h" + +#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction) + +#define TOOLVERSION "0.2" + +#define UTILITY_NAME "GenCrc32Section" + +EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID; + +EFI_STATUS +SignSectionWithCrc32 ( + IN OUT UINT8 *FileBuffer, + IN OUT UINT32 *BufferSize, + IN UINT32 DataSize + ) +/*++ + +Routine Description: + + Signs the section with CRC32 and add GUIDed section header for the + signed data. data stays in same location (overwrites source data). + +Arguments: + + FileBuffer - Buffer containing data to sign + + BufferSize - On input, the size of FileBuffer. On output, the size of + actual section data (including added section header). + + DataSize - Length of data to Sign + + Key - Key to use when signing. Currently only CRC32 is supported. + +Returns: + + EFI_SUCCESS - Successful + EFI_OUT_OF_RESOURCES - Not enough resource to complete the operation. + +--*/ +{ + + UINT32 Crc32Checksum; + EFI_STATUS Status; + UINT32 TotalSize; + CRC32_SECTION_HEADER Crc32Header; + UINT8 *SwapBuffer; + + Crc32Checksum = 0; + SwapBuffer = NULL; + + if (DataSize == 0) { + *BufferSize = 0; + + return EFI_SUCCESS; + } + + Status = CalculateCrc32 (FileBuffer, DataSize, &Crc32Checksum); + if (EFI_ERROR (Status)) { + return Status; + } + + TotalSize = DataSize + CRC32_SECTION_HEADER_SIZE; + Crc32Header.GuidSectionHeader.CommonHeader.Type = EFI_SECTION_GUID_DEFINED; + Crc32Header.GuidSectionHeader.CommonHeader.Size[0] = (UINT8) (TotalSize & 0xff); + Crc32Header.GuidSectionHeader.CommonHeader.Size[1] = (UINT8) ((TotalSize & 0xff00) >> 8); + Crc32Header.GuidSectionHeader.CommonHeader.Size[2] = (UINT8) ((TotalSize & 0xff0000) >> 16); + memcpy (&(Crc32Header.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID)); + Crc32Header.GuidSectionHeader.Attributes = EFI_GUIDED_SECTION_AUTH_STATUS_VALID; + Crc32Header.GuidSectionHeader.DataOffset = CRC32_SECTION_HEADER_SIZE; + Crc32Header.CRC32Checksum = Crc32Checksum; + + SwapBuffer = (UINT8 *) malloc (DataSize); + if (SwapBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + memcpy (SwapBuffer, FileBuffer, DataSize); + memcpy (FileBuffer, &Crc32Header, CRC32_SECTION_HEADER_SIZE); + memcpy (FileBuffer + CRC32_SECTION_HEADER_SIZE, SwapBuffer, DataSize); + + // + // Make sure section ends on a DWORD boundary + // + while ((TotalSize & 0x03) != 0) { + FileBuffer[TotalSize] = 0; + TotalSize++; + } + + *BufferSize = TotalSize; + + if (SwapBuffer != NULL) { + free (SwapBuffer); + } + + return EFI_SUCCESS; +} + +VOID +PrintUsage ( + VOID + ) +{ + printf ("Usage:\n"); + printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n"); + printf (" -i \"inputfile\":\n "); + printf (" specifies the input files that would be signed to CRC32 Guided section.\n"); + printf (" -o \"outputfile\":\n"); + printf (" specifies the output file that is a CRC32 Guided section.\n"); +} + +INT32 +ReadFilesContentsIntoBuffer ( + IN CHAR8 *argv[], + IN INT32 Start, + IN OUT UINT8 **FileBuffer, + IN OUT UINT32 *BufferSize, + OUT UINT32 *ContentSize, + IN INT32 MaximumArguments + ) +{ + INT32 Index; + CHAR8 *FileName; + FILE *InputFile; + UINT8 Temp; + UINT32 Size; + + FileName = NULL; + InputFile = NULL; + Size = 0; + Index = 0; + + // + // read all input files into one file buffer + // + while (argv[Start + Index][0] != '-') { + + FileName = argv[Start + Index]; + InputFile = fopen (FileName, "rb"); + if (InputFile == NULL) { + Error (NULL, 0, 0, FileName, "failed to open input binary file"); + return -1; + } + + fread (&Temp, sizeof (UINT8), 1, InputFile); + while (!feof (InputFile)) { + (*FileBuffer)[Size++] = Temp; + fread (&Temp, sizeof (UINT8), 1, InputFile); + } + + fclose (InputFile); + InputFile = NULL; + + // + // Make sure section ends on a DWORD boundary + // + while ((Size & 0x03) != 0) { + (*FileBuffer)[Size] = 0; + Size++; + } + + Index++; + if (Index == MaximumArguments) { + break; + } + } + + *ContentSize = Size; + return Index; +} + +INT32 +main ( + INT32 argc, + CHAR8 *argv[] + ) +{ + FILE *OutputFile; + UINT8 *FileBuffer; + UINT32 BufferSize; + EFI_STATUS Status; + UINT32 ContentSize; + CHAR8 *OutputFileName; + INT32 ReturnValue; + INT32 Index; + + OutputFile = NULL; + FileBuffer = NULL; + ContentSize = 0; + OutputFileName = NULL; + + SetUtilityName (UTILITY_NAME); + + if (argc == 1) { + PrintUsage (); + return -1; + } + + BufferSize = 1024 * 1024 * 16; + FileBuffer = (UINT8 *) malloc (BufferSize * sizeof (UINT8)); + if (FileBuffer == NULL) { + Error (NULL, 0, 0, "memory allocation failed", NULL); + return -1; + } + + ZeroMem (FileBuffer, BufferSize); + + for (Index = 0; Index < argc; Index++) { + if (_strcmpi (argv[Index], "-i") == 0) { + ReturnValue = ReadFilesContentsIntoBuffer ( + argv, + (Index + 1), + &FileBuffer, + &BufferSize, + &ContentSize, + (argc - (Index + 1)) + ); + if (ReturnValue == -1) { + Error (NULL, 0, 0, "failed to read file contents", NULL); + return -1; + } + + Index += ReturnValue; + } + + if (_strcmpi (argv[Index], "-o") == 0) { + OutputFileName = argv[Index + 1]; + } + } + + OutputFile = fopen (OutputFileName, "wb"); + if (OutputFile == NULL) { + Error (NULL, 0, 0, OutputFileName, "failed to open output binary file"); + free (FileBuffer); + return -1; + } + + /* + // + // make sure section ends on a DWORD boundary ?? + // + while ( (Size & 0x03) != 0 ) { + FileBuffer[Size] = 0; + Size ++; + } +*/ + Status = SignSectionWithCrc32 (FileBuffer, &BufferSize, ContentSize); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "failed to sign section", NULL); + free (FileBuffer); + fclose (OutputFile); + return -1; + } + + ContentSize = fwrite (FileBuffer, sizeof (UINT8), BufferSize, OutputFile); + if (ContentSize != BufferSize) { + Error (NULL, 0, 0, "failed to write output buffer", NULL); + ReturnValue = -1; + } else { + ReturnValue = 0; + } + + free (FileBuffer); + fclose (OutputFile); + return ReturnValue; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.h new file mode 100644 index 0000000000..7f88be2364 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.h @@ -0,0 +1,43 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenCRC32Section.h + +Abstract: + + Header file for GenFfsFile. Mainly defines the header of section + header for CRC32 GUID defined sections. Share with GenSection.c + +--*/ + +// +// Module Coded to Tiano Coding Conventions +// +#ifndef _EFI_GEN_CRC32_SECTION_H +#define _EFI_GEN_CRC32_SECTION_H + +// +// External Files Referenced +// +#include "TianoCommon.h" +#include "EfiImageFormat.h" + +typedef struct { + EFI_GUID_DEFINED_SECTION GuidSectionHeader; + UINT32 CRC32Checksum; +} CRC32_SECTION_HEADER; + +#define EFI_SECTION_CRC32_GUID_DEFINED 0 +#define CRC32_SECTION_HEADER_SIZE (sizeof (CRC32_SECTION_HEADER)) + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/makefile new file mode 100644 index 0000000000..f6c07f7340 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/makefile @@ -0,0 +1,85 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=GenCRC32Section + +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenCRC32Section.c" +TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \ + "$(EDK_TOOLS_COMMON)\ParseInf.h" +TARGET_EXE_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" + + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_EXE_LIBS) $(TARGET_DLL) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB) $(TARGET_EXE_LIBS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.c new file mode 100644 index 0000000000..5cd15331db --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.c @@ -0,0 +1,890 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DepexParser.c + +Abstract: + + Validate Dependency Expression syntax + recursive descent Algorithm + + The original BNF grammar(taken from "Pre EFI Initialization Core Interface Specification + draft review 0.9") is thus: + ::= BEFORE END + | AFTER END + | SOR END + | END + ::= AND + | OR + | + ::= NOT + | + ::= + | TRUE + | FALSE + | GUID + + ::= '{' ',' ',' ',' + ',' ',' ',' ',' + ',' ',' ',' '}' + ::= + ::= + ::= + ::= '0' 'x' + | '0' 'X' + ::= + | + ::= [0-9] + | [a-f] + | [A-F] + + After cleaning left recursive and parentheses supported, the BNF grammar used in this module is thus: + ::= BEFORE + | AFTER + | SOR + | + ::= + ::= AND + | OR + | '' + ::= NOT + | + ::= '('')' + | NOT + | TRUE + | FALSE + | END + | + ::=AND + | OR + | '' + ::= '{' ',' ',' ',' + ',' ',' ',' ',' + ',' ',' ',' '}' + ::= + ::= + ::= + ::= '0' 'x' + | '0' 'X' + ::= + | + ::= [0-9] + | [a-f] + | [A-F] + + Note: 1. There's no precedence in operators except parentheses; + 2. For hex32, less and equal than 8 bits is valid, more than 8 bits is invalid. + Same constraint for hex16 is 4, hex8 is 2. All hex should contains at least 1 bit. + 3. " ::= '('')'" is added to support parentheses; + 4. " ::= GUID" is changed to " ::= "; + 5. "DEPENDENCY_END" is the terminal of the expression. But it has been filtered by caller. + During parsing, "DEPENDENCY_END" will be treated as illegal factor; + + This code should build in any environment that supports a standard C-library w/ string + operations and File I/O services. + + As an example of usage, consider the following: + + The input string could be something like: + + NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, + 0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, + 0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, + 0x3f, 0xc1, 0x4d } AND + + It's invalid for an extra "AND" in the end. + + Complies with Tiano C Coding Standards Document, version 0.33, 16 Aug 2001. + +--*/ + +#include "DepexParser.h" + +BOOLEAN +ParseBool ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ); + +BOOLEAN +ParseTerm ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ); + +BOOLEAN +ParseRightBool ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ); + +BOOLEAN +ParseFactor ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ); + +VOID +LeftTrim ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Left trim the space, '\n' and '\r' character in string. + The space at the end does not need trim. + + +Arguments: + + Pbegin The pointer to the string + length length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + None + + +--*/ +{ + while + ( + ((*Pindex) < (Pbegin + length)) && + ((strncmp (*Pindex, " ", 1) == 0) || (strncmp (*Pindex, "\n", 1) == 0) || (strncmp (*Pindex, "\r", 1) == 0)) + ) { + (*Pindex)++; + } +} + +BOOLEAN +ParseHexdigit ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse Hex bit in dependency expression. + +Arguments: + + Pbegin The pointer to the string + length Length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If parses a valid hex bit, return TRUE, otherwise FALSE + + +--*/ +{ + // + // ::= [0-9] | [a-f] | [A-F] + // + if (((**Pindex) >= '0' && (**Pindex) <= '9') || + ((**Pindex) >= 'a' && (**Pindex) <= 'f') || + ((**Pindex) >= 'A' && (**Pindex) <= 'F') + ) { + (*Pindex)++; + return TRUE; + } else { + return FALSE; + } +} + +BOOLEAN +ParseHex32 ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse Hex32 in dependency expression. + +Arguments: + + Pbegin The pointer to the string + length Length of the string + Pindex The pointer of point to the next parse character in the string + +Returns: + + BOOLEAN If parses a valid hex32, return TRUE, otherwise FALSE + + +--*/ +{ + INT32 Index; + INT8 *Pin; + + Index = 0; + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) { + return FALSE; + } + (*Pindex) += 2; + + while (ParseHexdigit (Pbegin, length, Pindex)) { + Index++; + } + + if (Index > 0 && Index <= 8) { + return TRUE; + } else { + *Pindex = Pin; + return FALSE; + } +} + +BOOLEAN +ParseHex16 ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse Hex16 in dependency expression. + +Arguments: + + Pbegin The pointer to the string + length Length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If parses a valid hex16, return TRUE, otherwise FALSE + + +--*/ +{ + int Index; + INT8 *Pin; + + Index = 0; + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) { + return FALSE; + } + (*Pindex) += 2; + + while (ParseHexdigit (Pbegin, length, Pindex)) { + Index++; + } + + if (Index > 0 && Index <= 4) { + return TRUE; + } else { + *Pindex = Pin; + return FALSE; + } +} + +BOOLEAN +ParseHex8 ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse Hex8 in dependency expression. + +Arguments: + + Pbegin The pointer to the string + length Length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If parses a valid hex8, return TRUE, otherwise FALSE + + +--*/ +{ + int Index; + INT8 *Pin; + + Index = 0; + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) { + return FALSE; + } + (*Pindex) += 2; + + while (ParseHexdigit (Pbegin, length, Pindex)) { + Index++; + } + + if (Index > 0 && Index <= 2) { + return TRUE; + } else { + *Pindex = Pin; + return FALSE; + } +} + +BOOLEAN +ParseGuid ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse guid in dependency expression. + There can be any number of spaces between '{' and hexword, ',' and hexword, + hexword and ',', hexword and '}'. The hexword include hex32, hex16 and hex8. + +Arguments: + + Pbegin The pointer to the string + length length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If parses a valid guid, return TRUE, otherwise FALSE + + +--*/ +{ + INT32 Index; + INT8 *Pin; + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + if (strncmp (*Pindex, "{", 1) != 0) { + return FALSE; + } + (*Pindex)++; + + LeftTrim (Pbegin, length, Pindex); + if (!ParseHex32 (Pbegin, length, Pindex)) { + *Pindex = Pin; + return FALSE; + } + + LeftTrim (Pbegin, length, Pindex); + if (strncmp (*Pindex, ",", 1) != 0) { + return FALSE; + } else { + (*Pindex)++; + } + + for (Index = 0; Index < 2; Index++) { + LeftTrim (Pbegin, length, Pindex); + if (!ParseHex16 (Pbegin, length, Pindex)) { + *Pindex = Pin; + return FALSE; + } + + LeftTrim (Pbegin, length, Pindex); + if (strncmp (*Pindex, ",", 1) != 0) { + return FALSE; + } else { + (*Pindex)++; + } + } + + for (Index = 0; Index < 7; Index++) { + LeftTrim (Pbegin, length, Pindex); + if (!ParseHex8 (Pbegin, length, Pindex)) { + *Pindex = Pin; + return FALSE; + } + + LeftTrim (Pbegin, length, Pindex); + if (strncmp (*Pindex, ",", 1) != 0) { + return FALSE; + } else { + (*Pindex)++; + } + } + + LeftTrim (Pbegin, length, Pindex); + if (!ParseHex8 (Pbegin, length, Pindex)) { + *Pindex = Pin; + return FALSE; + } + + LeftTrim (Pbegin, length, Pindex); + if (strncmp (*Pindex, "}", 1) != 0) { + return FALSE; + } else { + (*Pindex)++; + } + + return TRUE; +} + +BOOLEAN +ParseRightFactor ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse rightfactor in bool expression. + +Arguments: + + Pbegin The pointer to the string + length length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If string is a valid rightfactor expression, return TRUE, otherwise FALSE + + +--*/ +{ + INT8 *Pin; + + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + // + // ::=AND + // + if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) { + *Pindex += strlen (OPERATOR_AND); + LeftTrim (Pbegin, length, Pindex); + + if (ParseTerm (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightBool (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + if (ParseRightFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } + // + // ::=OR + // + if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) { + *Pindex += strlen (OPERATOR_OR); + LeftTrim (Pbegin, length, Pindex); + + if (ParseTerm (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightBool (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + if (ParseRightFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } + // + // ::= '' + // + *Pindex = Pin; + return TRUE; +} + +BOOLEAN +ParseRightBool ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse rightbool in bool expression. + +Arguments: + + Pbegin The pointer to the string + length length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If string is a valid rightbool expression, return TRUE, otherwise FALSE + + +--*/ +{ + INT8 *Pin; + + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + // + // ::= AND + // + if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) { + *Pindex += strlen (OPERATOR_AND); + LeftTrim (Pbegin, length, Pindex); + + if (ParseTerm (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightBool (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } + // + // ::= OR + // + if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) { + *Pindex += strlen (OPERATOR_OR); + LeftTrim (Pbegin, length, Pindex); + + if (ParseTerm (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightBool (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } + // + // ::= '' + // + *Pindex = Pin; + return TRUE; +} + +BOOLEAN +ParseFactor ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse factor in bool expression. + +Arguments: + + Pbegin The pointer to the string + length length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If string is a valid factor, return TRUE, otherwise FALSE + + +--*/ +{ + INT8 *Pin; + + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + // + // ::= '('')' + // + if (strncmp (*Pindex, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) { + *Pindex += strlen (OPERATOR_LEFT_PARENTHESIS); + LeftTrim (Pbegin, length, Pindex); + + if (!ParseBool (Pbegin, length, Pindex)) { + *Pindex = Pin; + } else { + LeftTrim (Pbegin, length, Pindex); + + if (strncmp (*Pindex, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) { + *Pindex += strlen (OPERATOR_RIGHT_PARENTHESIS); + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } + } + } + // + // ::= NOT + // + if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) { + *Pindex += strlen (OPERATOR_NOT); + LeftTrim (Pbegin, length, Pindex); + + if (ParseFactor (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightBool (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } else { + *Pindex = Pin; + } + } + // + // ::= TRUE + // + if (strncmp (*Pindex, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) { + *Pindex += strlen (OPERATOR_TRUE); + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } + // + // ::= FALSE + // + if (strncmp (*Pindex, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) { + *Pindex += strlen (OPERATOR_FALSE); + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + } + } + // + // ::= + // + if (ParseGuid (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (ParseRightFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + return FALSE; + } + } else { + *Pindex = Pin; + return FALSE; + } +} + +BOOLEAN +ParseTerm ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse term in bool expression. + +Arguments: + + Pbegin The pointer to the string + length length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If string is a valid term, return TRUE, otherwise FALSE + + +--*/ +{ + INT8 *Pin; + + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + // + // ::= NOT + // + if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) { + *Pindex += strlen (OPERATOR_NOT); + LeftTrim (Pbegin, length, Pindex); + + if (!ParseFactor (Pbegin, length, Pindex)) { + *Pindex = Pin; + } else { + return TRUE; + } + } + // + // ::= + // + if (ParseFactor (Pbegin, length, Pindex)) { + return TRUE; + } else { + *Pindex = Pin; + return FALSE; + } +} + +BOOLEAN +ParseBool ( + IN INT8 *Pbegin, + IN UINT32 length, + IN OUT INT8 **Pindex + ) +/*++ + +Routine Description: + + Parse bool expression. + +Arguments: + + Pbegin The pointer to the string + length length of the string + Pindex The pointer of pointer to the next parse character in the string + +Returns: + + BOOLEAN If string is a valid bool expression, return TRUE, otherwise FALSE + + +--*/ +{ + INT8 *Pin; + Pin = *Pindex; + LeftTrim (Pbegin, length, Pindex); + + if (ParseTerm (Pbegin, length, Pindex)) { + LeftTrim (Pbegin, length, Pindex); + + if (!ParseRightBool (Pbegin, length, Pindex)) { + *Pindex = Pin; + return FALSE; + } else { + return TRUE; + } + } else { + *Pindex = Pin; + return FALSE; + } +} + +BOOLEAN +ParseDepex ( + IN INT8 *Pbegin, + IN UINT32 length + ) +/*++ + +Routine Description: + + Parse whole dependency expression. + +Arguments: + + Pbegin The pointer to the string + length length of the string + +Returns: + + BOOLEAN If string is a valid dependency expression, return TRUE, otherwise FALSE + + +--*/ +{ + BOOLEAN Result; + INT8 **Pindex; + INT8 *temp; + + Result = FALSE; + temp = Pbegin; + Pindex = &temp; + + LeftTrim (Pbegin, length, Pindex); + if (strncmp (*Pindex, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) { + (*Pindex) += strlen (OPERATOR_BEFORE); + Result = ParseGuid (Pbegin, length, Pindex); + + } else if (strncmp (*Pindex, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) { + (*Pindex) += strlen (OPERATOR_AFTER); + Result = ParseGuid (Pbegin, length, Pindex); + + } else if (strncmp (*Pindex, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) { + (*Pindex) += strlen (OPERATOR_SOR); + Result = ParseBool (Pbegin, length, Pindex); + + } else { + Result = ParseBool (Pbegin, length, Pindex); + + } + + LeftTrim (Pbegin, length, Pindex); + return (BOOLEAN) (Result && (*Pindex) >= (Pbegin + length)); +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.h new file mode 100644 index 0000000000..29e0884a3e --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/DepexParser.h @@ -0,0 +1,26 @@ +/*++ +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: + GenDepex.h + + Abstract: + This file contains the relevant declarations required + to generate a binary Dependency File + + Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000. + +--*/ + +// TODO: fix comment to set correct module name: DepexParser.h +#ifndef _EFI_DEPEX_PARSER_H_ +#define _EFI_DEPEX_PARSER_H_ +#include "GenDepex.h" +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c new file mode 100644 index 0000000000..cebcc01f9b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c @@ -0,0 +1,912 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenDepex.c + +Abstract: + + Generate Dependency Expression ("GenDepex") + + Infix to Postfix Algorithm + + This code has been scrubbed to be free of having any EFI core tree dependencies. + It should build in any environment that supports a standard C-library w/ string + operations and File I/O services. + + As an example of usage, consider the following: + + The input user file could be something like "Sample.DXS" whose contents are + + #include "Tiano.h" + + DEPENDENCY_START + NOT (DISK_IO_PROTOCOL AND SIMPLE_FILE_SYSTEM_PROTOCOL) + OR EFI_PXE_BASE_CODE_PROTOCOL + DEPENDENCY_END + + This file is then washed through the C-preprocessor, viz., + + cl /EP Sample.DXS > Sample.TMP1 + + This yields the following file "Sample.TMP1" whose contents are + + DEPENDENCY_START + NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, + 0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, + 0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, + 0x3f, 0xc1, 0x4d } + DEPENDENCY_END + + This file, in turn, will be fed into the utility, viz., + + GenDepex Sample.TMP1 Sample.TMP2 + + With a file that is 55 bytes long: + + 55 bytes for the grammar binary + PUSH opcode - 1 byte + GUID Instance - 16 bytes + PUSH opcode - 1 byte + GUID Instance - 16 bytes + AND opcode - 1 byte + NOT opcode - 1 byte + PUSH opcode - 1 byte + GUID Instance - 16 bytes + OR opcode - 1 byte + END opcode - 1 byte + + The file "Sample.TMP2" could be fed via a Section-builder utility + (GenSection) that would be used for the creation of a dependency + section file (.DPX) which in turn would be used by a generate FFS + utility (GenFfsFile) to produce a DXE driver/core (.DXE) or + a DXE application (.APP) file. + + Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000. + +--*/ + +#include "GenDepex.h" + +#define TOOL_NAME "GenDepex" + +extern +BOOLEAN +ParseDepex ( + IN INT8 *Pbegin, + IN UINT32 length + ); + +VOID +PrintGenDepexUtilityInfo ( + VOID + ) +/*++ + +Routine Description: + + Displays the standard utility information to SDTOUT. + +Arguments: + + None + +Returns: + + None + +--*/ +{ + printf ( + "%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n", + UTILITY_NAME, + UTILITY_MAJOR_VERSION, + UTILITY_MINOR_VERSION + ); + printf ("Copyright (C) 1996-2002 Intel Corporation. All rights reserved.\n\n"); +} + +VOID +PrintGenDepexUsageInfo ( + VOID + ) +/*++ + +Routine Description: + + Displays the utility usage syntax to STDOUT. + +Arguments: + + None + +Returns: + + None + +--*/ +{ + printf ( + "Usage: %s -I -O [-P ] \n", + UTILITY_NAME + ); + printf (" Where:\n"); + printf (" is the input pre-processed dependency text files name.\n"); + printf (" is the output binary dependency files name.\n"); + printf (" is the padding integer value.\n"); + printf (" This is the boundary to align the output file size to.\n"); +} + +DEPENDENCY_OPCODE +PopOpCode ( + IN OUT VOID **Stack + ) +/*++ + +Routine Description: + + Pop an element from the Opcode stack. + +Arguments: + + Stack Current top of the OpCode stack location + +Returns: + + DEPENDENCY_OPCODE OpCode at the top of the OpCode stack. + Stack New top of the OpCode stack location + + +--*/ +{ + DEPENDENCY_OPCODE *OpCodePtr; + + OpCodePtr = *Stack; + OpCodePtr--; + *Stack = OpCodePtr; + return *OpCodePtr; +} + +VOID +PushOpCode ( + IN OUT VOID **Stack, + IN DEPENDENCY_OPCODE OpCode + ) +/*++ + +Routine Description: + + Push an element onto the Opcode Stack + +Arguments: + + Stack Current top of the OpCode stack location + OpCode OpCode to push onto the stack + +Returns: + + Stack New top of the OpCode stack location + +--*/ +{ + DEPENDENCY_OPCODE *OpCodePtr; + + OpCodePtr = *Stack; + *OpCodePtr = OpCode; + OpCodePtr++; + *Stack = OpCodePtr; +} + +EFI_STATUS +GenerateDependencyExpression ( + IN FILE *InFile, + IN OUT FILE *OutFile, + IN UINT8 Padding OPTIONAL + ) +/*++ + +Routine Description: + + This takes the pre-compiled dependency text file and + converts it into a binary dependency file. + + The BNF for the dependency expression is as follows + (from the DXE 1.0 Draft specification). + + The inputted BNF grammar is thus: + ::= sor | + before GUID | + after GUID | + + + ::= | + + ::= and | + or | + + + ::= not | + + + ::= ( ) | + | + GUID | + + + ::= true | + false + + The outputed binary grammer is thus: + ::= sor | + before | + after | + + + ::= | + + ::= and | + or | + + ::= not | + + + ::= ( ) | + | + | + | + + + ::= true | + false + + ::= push GUID + + ::= end + + BugBug: A correct grammer is parsed correctly. A file that violates the + grammer may parse when it should generate an error. There is some + error checking and it covers most of the case when it's an include + of definition issue. An ill formed expresion may not be detected. + +Arguments: + + InFile - Input pre-compiled text file of the dependency expression. + This needs to be in ASCII. + The file pointer can not be NULL. + + OutFile - Binary dependency file. + The file pointer can not be NULL. + + Padding - OPTIONAL integer value to pad the output file to. + + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the parameters in the text file was invalid. + EFI_OUT_OF_RESOURCES Unable to allocate memory. + EFI_ABORTED An misc error occurred. + +--*/ +{ + INT8 *Ptrx; + INT8 *Pend; + INT8 *EvaluationStack; + INT8 *StackPtr; + INT8 *Buffer; + INT8 Line[LINESIZE]; + UINTN Index; + UINTN OutFileSize; + UINTN FileSize; + UINTN Results; + BOOLEAN NotDone; + BOOLEAN Before_Flag; + BOOLEAN After_Flag; + BOOLEAN Dep_Flag; + BOOLEAN SOR_Flag; + EFI_GUID Guid; + UINTN ArgCountParsed; + DEPENDENCY_OPCODE Opcode; + + Before_Flag = FALSE; + After_Flag = FALSE; + Dep_Flag = FALSE; + SOR_Flag = FALSE; + + memset (Line, 0, LINESIZE); + + OutFileSize = 0; + + EvaluationStack = (INT8 *) malloc (EVAL_STACK_SIZE); + + if (EvaluationStack != NULL) { + StackPtr = EvaluationStack; + } else { + printf ("Unable to allocate memory to EvaluationStack - Out of resources\n"); + return EFI_OUT_OF_RESOURCES; + } + + Results = (UINTN) fseek (InFile, 0, SEEK_END); + + if (Results != 0) { + printf ("FSEEK failed - Aborted\n"); + return EFI_ABORTED; + } + + FileSize = ftell (InFile); + + if (FileSize == -1L) { + printf ("FTELL failed - Aborted\n"); + return EFI_ABORTED; + } + + Buffer = (INT8 *) malloc (FileSize + BUFFER_SIZE); + + if (Buffer == NULL) { + printf ("Unable to allocate memory to Buffer - Out of resources\n"); + free (EvaluationStack); + + Results = (UINTN) fclose (InFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + Results = (UINTN) fclose (OutFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + return EFI_OUT_OF_RESOURCES; + } + + Results = (UINTN) fseek (InFile, 0, SEEK_SET); + + if (Results != 0) { + printf ("FSEEK failed - Aborted\n"); + return EFI_ABORTED; + } + + fread (Buffer, FileSize, 1, InFile); + + Ptrx = Buffer; + Pend = Ptrx + FileSize - strlen (DEPENDENCY_END); + Index = FileSize; + + NotDone = TRUE; + while ((Index--) && NotDone) { + + if (strncmp (Pend, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) { + NotDone = FALSE; + } else { + Pend--; + } + } + + if (NotDone) { + printf ("Couldn't find end string %s\n", DEPENDENCY_END); + + Results = (UINTN) fclose (InFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + Results = (UINTN) fclose (OutFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + free (Buffer); + free (EvaluationStack); + + return EFI_INVALID_PARAMETER; + } + + Index = FileSize; + + NotDone = TRUE; + while ((Index--) && NotDone) { + + if (strncmp (Ptrx, DEPENDENCY_START, strlen (DEPENDENCY_START)) == 0) { + Ptrx += strlen (DEPENDENCY_START); + NotDone = FALSE; + // + // BUGBUG -- should Index be decremented by sizeof(DEPENDENCY_START)? + // + } else { + Ptrx++; + } + } + + if (NotDone) { + printf ("Couldn't find start string %s\n", DEPENDENCY_START); + + Results = (UINTN) fclose (InFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + Results = (UINTN) fclose (OutFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + free (Buffer); + free (EvaluationStack); + + return EFI_INVALID_PARAMETER; + } + // + // validate the syntax of expression + // + if (!ParseDepex (Ptrx, Pend - Ptrx - 1)) { + printf ("The syntax of expression is wrong\n"); + + Results = (UINTN) fclose (InFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + Results = (UINTN) fclose (OutFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + free (Buffer); + free (EvaluationStack); + + return EFI_INVALID_PARAMETER; + } + + NotDone = TRUE; + + while ((Index--) && NotDone) { + + if (*Ptrx == ' ') { + Ptrx++; + } else if (*Ptrx == '\n' || *Ptrx == '\r') { + Ptrx++; + } else if (strncmp (Ptrx, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) { + // + // Checks for some invalid dependencies + // + if (Before_Flag) { + + printf ("A BEFORE operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (After_Flag) { + + printf ("An AFTER operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (SOR_Flag) { + + printf ("Another SOR operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (Dep_Flag) { + + printf ("The Schedule On Request - SOR operator must be the first operator following DEPENDENCY_START\n"); + return EFI_INVALID_PARAMETER; + + } else { + // + // BUGBUG - This was not in the spec but is in the CORE code + // An OPERATOR_SOR has to be first - following the DEPENDENCY_START + // + fputc (EFI_DEP_SOR, OutFile); + OutFileSize++; + Ptrx += strlen (OPERATOR_SOR); + SOR_Flag = TRUE; + + } + } else if (strncmp (Ptrx, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) { + // + // Checks for some invalid dependencies + // + if (Before_Flag) { + + printf ("Another BEFORE operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (After_Flag) { + + printf ("An AFTER operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (SOR_Flag) { + + printf ("A SOR operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (Dep_Flag) { + + printf ("The BEFORE operator must be the first operator following DEPENDENCY_START\n"); + return EFI_INVALID_PARAMETER; + + } else { + fputc (EFI_DEP_BEFORE, OutFile); + OutFileSize++; + Ptrx += strlen (OPERATOR_BEFORE); + Before_Flag = TRUE; + } + } else if (strncmp (Ptrx, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) { + // + // Checks for some invalid dependencies + // + if (Before_Flag) { + + printf ("A BEFORE operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (After_Flag) { + + printf ("Another AFTER operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (SOR_Flag) { + + printf ("A SOR operator was detected.\n"); + printf ("There can only be one SOR or one AFTER or one BEFORE operator\n"); + return EFI_INVALID_PARAMETER; + + } else if (Dep_Flag) { + + printf ("The AFTER operator must be the first operator following DEPENDENCY_START\n"); + return EFI_INVALID_PARAMETER; + + } else { + fputc (EFI_DEP_AFTER, OutFile); + OutFileSize++; + Ptrx += strlen (OPERATOR_AFTER); + Dep_Flag = TRUE; + After_Flag = TRUE; + } + } else if (strncmp (Ptrx, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) { + while (StackPtr != EvaluationStack) { + Opcode = PopOpCode ((VOID **) &StackPtr); + if (Opcode != DXE_DEP_LEFT_PARENTHESIS) { + fputc (Opcode, OutFile); + OutFileSize++; + } else { + PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS); + break; + } + } + + PushOpCode ((VOID **) &StackPtr, EFI_DEP_AND); + Ptrx += strlen (OPERATOR_AND); + Dep_Flag = TRUE; + + } else if (strncmp (Ptrx, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) { + while (StackPtr != EvaluationStack) { + Opcode = PopOpCode ((VOID **) &StackPtr); + if (Opcode != DXE_DEP_LEFT_PARENTHESIS) { + fputc (Opcode, OutFile); + OutFileSize++; + } else { + PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS); + break; + } + } + + PushOpCode ((VOID **) &StackPtr, EFI_DEP_OR); + Ptrx += strlen (OPERATOR_OR); + Dep_Flag = TRUE; + + } else if (strncmp (Ptrx, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) { + while (StackPtr != EvaluationStack) { + Opcode = PopOpCode ((VOID **) &StackPtr); + if (Opcode != DXE_DEP_LEFT_PARENTHESIS) { + fputc (Opcode, OutFile); + OutFileSize++; + } else { + PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS); + break; + } + } + + PushOpCode ((VOID **) &StackPtr, EFI_DEP_NOT); + Ptrx += strlen (OPERATOR_NOT); + Dep_Flag = TRUE; + + } else if (*Ptrx == '\t') { + + printf ("File contains tabs. This violates the coding standard\n"); + return EFI_INVALID_PARAMETER; + + } else if (*Ptrx == '\n') { + // + // Skip the newline character in the file + // + Ptrx++; + + } else if (strncmp (Ptrx, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) { + PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS); + + Ptrx += strlen (OPERATOR_LEFT_PARENTHESIS); + Dep_Flag = TRUE; + + } else if (strncmp (Ptrx, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) { + while (StackPtr != EvaluationStack) { + Opcode = PopOpCode ((VOID **) &StackPtr); + if (Opcode != DXE_DEP_LEFT_PARENTHESIS) { + fputc (Opcode, OutFile); + OutFileSize++; + } else { + break; + } + } + + Ptrx += strlen (OPERATOR_RIGHT_PARENTHESIS); + Dep_Flag = TRUE; + + } else if (strncmp (Ptrx, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) { + + fputc (EFI_DEP_TRUE, OutFile); + + OutFileSize++; + + // + // OutFileSize += sizeof (EFI_DEP_TRUE); + // + Dep_Flag = TRUE; + + Ptrx += strlen (OPERATOR_TRUE); + + } else if (strncmp (Ptrx, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) { + + fputc (EFI_DEP_FALSE, OutFile); + + OutFileSize++; + + // + // OutFileSize += sizeof (EFI_DEP_FALSE); + // + Dep_Flag = TRUE; + + Ptrx += strlen (OPERATOR_FALSE); + + } else if (*Ptrx == '{') { + Ptrx++; + + if (*Ptrx == ' ') { + Ptrx++; + } + + ArgCountParsed = sscanf ( + Ptrx, + "%x, %x, %x, %x, %x, %x, %x, %x, %x, %x, %x", + &Guid.Data1, + &Guid.Data2, + &Guid.Data3, + &Guid.Data4[0], + &Guid.Data4[1], + &Guid.Data4[2], + &Guid.Data4[3], + &Guid.Data4[4], + &Guid.Data4[5], + &Guid.Data4[6], + &Guid.Data4[7] + ); + + if (ArgCountParsed != 11) { + printf ("We have found an illegal GUID\n"); + printf ("Fix your depex\n"); + exit (-1); + } + + while (*Ptrx != '}') { + Ptrx++; + } + // + // Absorb the closing } + // + Ptrx++; + + // + // Don't provide a PUSH Opcode for the Before and After case + // + if ((!Before_Flag) && (!After_Flag)) { + fputc (EFI_DEP_PUSH, OutFile); + OutFileSize++; + } + + fwrite (&Guid, sizeof (EFI_GUID), 1, OutFile); + + OutFileSize += sizeof (EFI_GUID); + Dep_Flag = TRUE; + + } else if (strncmp (Ptrx, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) { + NotDone = FALSE; + } else { + // + // Not a valid construct. Null terminate somewhere out there and + // print an error message. + // + *(Ptrx + 20) = 0; + printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx); + return EFI_INVALID_PARAMETER; + } + } + // + // DRAIN(); + // + while (StackPtr != EvaluationStack) { + fputc (PopOpCode ((VOID **) &StackPtr), OutFile); + OutFileSize++; + } + + if (OutFileSize == 0) { + printf ("Grammer contains no operators or constants\n"); + return EFI_INVALID_PARAMETER; + } + + fputc (EFI_DEP_END, OutFile); + + OutFileSize++; + + // + // Checks for invalid padding values + // + if (Padding < 0) { + + printf ("The inputted padding value was %d\n", Padding); + printf ("The optional padding value can not be less than ZERO\n"); + return EFI_INVALID_PARAMETER; + + } else if (Padding > 0) { + + while ((OutFileSize % Padding) != 0) { + + fputc (' ', OutFile); + OutFileSize++; + } + } + + Results = (UINTN) fclose (InFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + Results = (UINTN) fclose (OutFile); + if (Results != 0) { + printf ("FCLOSE failed\n"); + } + + free (Buffer); + free (EvaluationStack); + + return EFI_SUCCESS; +} // End GenerateDependencyExpression function + +EFI_STATUS +main ( + IN UINTN argc, + IN CHAR8 *argv[] + ) +/*++ + +Routine Description: + + Parse user entries. Print some rudimentary help + +Arguments: + + argc The count of input arguments + argv The input arguments string array + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid or one of the parameters in the text file was invalid. + EFI_OUT_OF_RESOURCES Unable to allocate memory. + EFI_ABORTED Unable to open/create a file or a misc error. + +--*/ +// TODO: ] - add argument and description to function comment +{ + FILE *OutFile; + FILE *InFile; + UINT8 Padding; + UINTN Index; + BOOLEAN Input_Flag; + BOOLEAN Output_Flag; + BOOLEAN Pad_Flag; + + InFile = NULL; + OutFile = NULL; + Padding = 0; + Input_Flag = FALSE; + Output_Flag = FALSE; + Pad_Flag = FALSE; + + // + // Output the calling arguments + // + printf ("\n\n"); + for (Index = 0; Index < argc; Index++) { + printf ("%s ", argv[Index]); + } + + printf ("\n\n"); + + if (argc < 5) { + printf ("Not enough arguments\n"); + PrintGenDepexUsageInfo (); + return EFI_INVALID_PARAMETER; + } + + for (Index = 1; Index < argc - 1; Index++) { + + if ((strcmp (argv[Index], "-I") == 0) || (strcmp (argv[Index], "-i") == 0)) { + + if (!Input_Flag) { + + InFile = fopen (argv[Index + 1], "rb"); + Input_Flag = TRUE; + + } else { + printf ("GenDepex only allows one INPUT (-I) argument\n"); + return EFI_INVALID_PARAMETER; + } + + } else if ((strcmp (argv[Index], "-O") == 0) || (strcmp (argv[Index], "-o") == 0)) { + + if (!Output_Flag) { + + OutFile = fopen (argv[Index + 1], "wb"); + Output_Flag = TRUE; + + } else { + printf ("GenDepex only allows one OUTPUT (-O) argument\n"); + return EFI_INVALID_PARAMETER; + } + + } else if ((strcmp (argv[Index], "-P") == 0) || (strcmp (argv[Index], "-p") == 0)) { + + if (!Pad_Flag) { + + Padding = (UINT8) atoi (argv[Index + 1]); + Pad_Flag = TRUE; + + } else { + printf ("GenDepex only allows one PADDING (-P) argument\n"); + return EFI_INVALID_PARAMETER; + } + } + } + + PrintGenDepexUtilityInfo (); + + if (InFile == NULL) { + printf ("Can not open for reading.\n"); + PrintGenDepexUsageInfo (); + return EFI_ABORTED; + } + + if (OutFile == NULL) { + printf ("Can not open for writting.\n"); + PrintGenDepexUsageInfo (); + return EFI_ABORTED; + } + + return GenerateDependencyExpression (InFile, OutFile, Padding); +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h new file mode 100644 index 0000000000..d9df5faa69 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h @@ -0,0 +1,67 @@ +/*++ +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: + GenDepex.h + + Abstract: + This file contains the relevant declarations required + to generate a binary Dependency File + + Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000. + +--*/ + +#ifndef _EFI_GEN_DEPEX_H +#define _EFI_GEN_DEPEX_H + +#include "TianoCommon.h" +#include "EfiDependency.h" +#include +#include +#include +#include +#include + +#define DEPENDENCY_START "DEPENDENCY_START" +#define OPERATOR_BEFORE "BEFORE" +#define OPERATOR_AFTER "AFTER" +#define OPERATOR_AND "AND" +#define OPERATOR_OR "OR" +#define OPERATOR_NOT "NOT" +#define OPERATOR_TRUE "TRUE" +#define OPERATOR_FALSE "FALSE" +#define OPERATOR_SOR "SOR" +#define OPERATOR_END "END" +#define OPERATOR_LEFT_PARENTHESIS "(" +#define OPERATOR_RIGHT_PARENTHESIS ")" +#define DEPENDENCY_END "DEPENDENCY_END" + +#define DXE_DEP_LEFT_PARENTHESIS 0x0a +#define DXE_DEP_RIGHT_PARENTHESIS 0x0b + +#define LINESIZE 320 +#define SIZE_A_SYMBOL 60 +#define DEPENDENCY_OPCODE UINT8 +#define EVAL_STACK_SIZE 0x1024 +#define BUFFER_SIZE 0x100 + +// +// Utility Name +// +#define UTILITY_NAME "GenDepex" + +// +// Utility version information +// +#define UTILITY_MAJOR_VERSION 0 +#define UTILITY_MINOR_VERSION 4 + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/makefile new file mode 100644 index 0000000000..4faceb1802 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/makefile @@ -0,0 +1,100 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=GenDepex +TARGET_LIB_NAME=DepexParser +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_LIB = $(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).lib +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_LIB_SOURCE = "$(TARGET_SOURCE_DIR)\DepexParser.c" +TARGET_LIB_INCLUDE = "$(TARGET_SOURCE_DIR)\DepexParser.h" + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenDepex.c" +TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +# +# Build LIB +# + +$(TARGET_LIB): $(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj + $(LIB_EXE) $(LIB_FLAGS) $(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj /OUT:$(TARGET_LIB) + +$(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj: $(TARGET_LIB_SOURCE) $(TARGET_LIB_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_LIB_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_LIB_NAME).obj + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c new file mode 100644 index 0000000000..188ca77945 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c @@ -0,0 +1,2681 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenFfsFile.c + +Abstract: + + This file contains functions required to generate a Firmware File System + file. + +--*/ + +#include "TianoCommon.h" +#include "EfiFirmwareFileSystem.h" +#include "EfiFirmwareVolumeHeader.h" +#include "EfiImageFormat.h" +#include "ParseInf.h" +#include "Compress.h" +#include "EfiCustomizedCompress.h" +#include "crc32.h" +#include "GenFfsFile.h" +#include +#include // for isalpha() +// +// include file for _spawnv +// +#include +#include +#include +#include "CommonLib.h" +#include "EfiUtilityMsgs.h" +#include "SimpleFileParsing.h" + +#define UTILITY_NAME "GenFfsFile" +#define TOOLVERSION "0.32" +#define MAX_ARRAY_SIZE 100 + +static +INT32 +GetNextLine ( + OUT CHAR8 *Destination, + IN FILE *Package, + IN OUT UINT32 *LineNumber + ); + +static +void +CheckSlash ( + IN OUT CHAR8 *String, + IN FILE *In, + IN OUT UINT32 *LineNumber + ); + +static +INT32 +FindSectionInPackage ( + IN CHAR8 *BuildDirectory, + IN FILE *OverridePackage, + IN OUT UINT32 *LineNumber + ); + +static +STATUS +ProcessCommandLineArgs ( + int Argc, + char *Argv[] + ); + +static +void +PrintUsage ( + void + ); + +// +// Keep globals in this structure +// +static struct { + UINT8 BuildDirectory[_MAX_PATH]; + UINT8 PrimaryPackagePath[_MAX_PATH]; + UINT8 OverridePackagePath[_MAX_PATH]; + BOOLEAN Verbose; +} mGlobals; + +static EFI_GUID mZeroGuid = { 0 }; + +static +void +StripQuotes ( + IN OUT CHAR8 *String + ) +/*++ + +Routine Description: + + Removes quotes and/or whitespace from around a string + +Arguments: + + String - String to remove quotes from + +Returns: + + None + +--*/ +{ + UINTN Index; + UINTN Index2; + UINTN StrLen; + + Index2 = strspn (String, "\" \t\n"); + StrLen = strlen (String); + + for (Index = Index2; String[Index] != '\"', Index < StrLen; Index++) { + String[Index - Index2] = String[Index]; + } + + String[Index - Index2] = 0; +} + +static +void +PrintUsage ( + void + ) +/*++ + +Routine Description: + + Print Error / Help message. + +Arguments: + + void + +Returns: + + None + +--*/ +{ + printf ("Usage:\n"); + printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\" -v\n"); + printf (" -b \"build directory\":\n "); + printf (" specifies the full path to the component build directory.\n"); + printf (" -p1 \"P1_path\":\n"); + printf (" specifies fully qualified file name to the primary package file.\n"); + printf (" This file will normally exist in the same directory as the makefile\n"); + printf (" for the component. Required.\n"); + printf (" -p2 \"P2_path\":\n"); + printf (" specifies fully qualified file name to the override package file.\n"); + printf (" This file will normally exist in the build tip. Optional.\n"); +} + +static +INT32 +TestComment ( + IN CHAR8 *String, + IN FILE *In + ) +/*++ + +Routine Description: + + Tests input string to see if it is a comment, and if so goes to the next line in the file that is not a comment + +Arguments: + + String - String to test + + In - Open file to move pointer within + +Returns: + + -1 - End of file reached + 0 - Not a comment + 1 - Comment bypassed + +--*/ +{ + CHAR8 CharBuffer; + + CharBuffer = 0; + if ((String[0] == '/') && (String[1] == '/')) { + while (CharBuffer != '\n') { + fscanf (In, "%c", &CharBuffer); + if (feof (In)) { + return -1; + } + } + } else { + return 0; + } + + return 1; +} + +static +void +BreakString ( + IN CONST CHAR8 *Source, + OUT CHAR8 *Destination, + IN INTN Direction + ) +/*++ + +Routine Description: + + Takes an input string and returns either the part before the =, or the part after the =, depending on direction + +Arguments: + + Source - String to break + + Destination - Buffer to place new string in + + Direction - 0 to return all of source string before = + 1 to return all of source string after = + +Returns: + + None + +--*/ +{ + UINTN Index; + UINTN Index2; + + Index = 0; + Index2 = 0; + + if (strchr (Source, '=') == NULL) { + strcpy (Destination, Source); + + return ; + } + + if (Direction == 0) { + // + // return part of string before = + // + while (Source[Index] != '=') { + Destination[Index] = Source[Index++]; + } + + Destination[Index] = 0; + } else { + // + // return part of string after = + // + strcpy (Destination, strchr (Source, '=') + 1); + } +} + +static +INT32 +GetNextLine ( + OUT CHAR8 *Destination, + IN FILE *Package, + IN OUT UINT32 *LineNumber + ) +/*++ + +Routine Description: + + Gets the next non-commented line from the file + +Arguments: + + Destination - Where to put string + + Package - Package to get string from + + LineNumber - The actual line number. + +Returns: + + -1 - End of file reached + 0 - Success + +--*/ +{ + CHAR8 String[_MAX_PATH]; + fscanf (Package, "%s", &String); + if (feof (Package)) { + return -1; + } + + while (TestComment (String, Package) == 1) { + fscanf (Package, "%s", &String); + if (feof (Package)) { + return -1; + } + } + + strcpy (Destination, String); + return 0; +} + +static +VOID +CheckSlash ( + IN OUT CHAR8 *String, + IN FILE *In, + IN OUT UINT32 *LineNumber + ) +/*++ + +Routine Description: + + Checks to see if string is line continuation character, if so goes to next valid line + +Arguments: + + String - String to test + + In - Open file to move pointer within + + LineNumber - The line number. + +Returns: + + None + +--*/ +{ + CHAR8 ByteBuffer; + ByteBuffer = 0; + + switch (String[0]) { + + case '\\': + while (String[0] == '\\') { + while (ByteBuffer != '\n') { + fscanf (In, "%c", &ByteBuffer); + } + (*LineNumber)++; + if (GetNextLine (String, In, LineNumber) == -1) { + return ; + } + } + break; + + case '\n': + (*LineNumber)++; + while (String[0] == '\n') { + if (GetNextLine (String, In, LineNumber) == -1) { + return ; + } + } + break; + + default: + break; + + } + +} + +static +INT32 +FindSectionInPackage ( + IN CHAR8 *BuildDirectory, + IN FILE *OverridePackage, + IN OUT UINT32 *LineNumber + ) +/*++ + +Routine Description: + + Finds the matching section within the package + +Arguments: + + BuildDirectory - name of section to find + + OverridePackage - Package file to search within + + LineNumber - The line number. + +Returns: + + -1 - End of file reached + 0 - Success + +--*/ +{ + CHAR8 String[_MAX_PATH]; + CHAR8 NewString[_MAX_PATH]; + String[0] = 0; + + while (strcmp (BuildDirectory, String) != 0) { + if (GetNextLine (NewString, OverridePackage, LineNumber) != 0) { + return -1; + } + + if (NewString[0] == '[') { + if (NewString[strlen (NewString) - 1] != ']') { + // + // have to construct string. + // + strcpy (String, NewString + 1); + + while (1) { + fscanf (OverridePackage, "%s", &NewString); + if (feof (OverridePackage)) { + return -1; + } + + if (NewString[0] != ']') { + if (strlen (String) != 0) { + strcat (String, " "); + } + + strcat (String, NewString); + if (String[strlen (String) - 1] == ']') { + String[strlen (String) - 1] = 0; + break; + } + } else { + break; + } + } + } else { + NewString[strlen (NewString) - 1] = 0; + strcpy (String, NewString + 1); + } + } + } + + return 0; +} + +static +EFI_STATUS +GenSimpleGuidSection ( + IN OUT UINT8 *FileBuffer, + IN OUT UINT32 *BufferSize, + IN UINT32 DataSize, + IN EFI_GUID SignGuid, + IN UINT16 GuidedSectionAttributes + ) +/*++ + +Routine Description: + + add GUIDed section header for the data buffer. + data stays in same location (overwrites source data). + +Arguments: + + FileBuffer - Buffer containing data to sign + + BufferSize - On input, the size of FileBuffer. On output, the size of + actual section data (including added section header). + + DataSize - Length of data to Sign + + SignGuid - Guid to be add. + + GuidedSectionAttributes - The section attribute. + +Returns: + + EFI_SUCCESS - Successful + EFI_OUT_OF_RESOURCES - Not enough resource. + +--*/ +{ + UINT32 TotalSize; + + EFI_GUID_DEFINED_SECTION GuidSectionHeader; + UINT8 *SwapBuffer; + + SwapBuffer = NULL; + + if (DataSize == 0) { + *BufferSize = 0; + + return EFI_SUCCESS; + } + + TotalSize = DataSize + sizeof (EFI_GUID_DEFINED_SECTION); + GuidSectionHeader.CommonHeader.Type = EFI_SECTION_GUID_DEFINED; + GuidSectionHeader.CommonHeader.Size[0] = (UINT8) (TotalSize & 0xff); + GuidSectionHeader.CommonHeader.Size[1] = (UINT8) ((TotalSize & 0xff00) >> 8); + GuidSectionHeader.CommonHeader.Size[2] = (UINT8) ((TotalSize & 0xff0000) >> 16); + memcpy (&(GuidSectionHeader.SectionDefinitionGuid), &SignGuid, sizeof (EFI_GUID)); + GuidSectionHeader.Attributes = GuidedSectionAttributes; + GuidSectionHeader.DataOffset = sizeof (EFI_GUID_DEFINED_SECTION); + + SwapBuffer = (UINT8 *) malloc (DataSize); + if (SwapBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + memcpy (SwapBuffer, FileBuffer, DataSize); + memcpy (FileBuffer, &GuidSectionHeader, sizeof (EFI_GUID_DEFINED_SECTION)); + memcpy (FileBuffer + sizeof (EFI_GUID_DEFINED_SECTION), SwapBuffer, DataSize); + + // + // Make sure section ends on a DWORD boundary + // + while ((TotalSize & 0x03) != 0) { + FileBuffer[TotalSize] = 0; + TotalSize++; + } + + *BufferSize = TotalSize; + + if (SwapBuffer != NULL) { + free (SwapBuffer); + } + + return EFI_SUCCESS; +} + +static +EFI_STATUS +CompressSection ( + UINT8 *FileBuffer, + UINT32 *BufferSize, + UINT32 DataSize, + CHAR8 *Type + ) +/*++ + +Routine Description: + + Compress the data and add section header for the compressed data. + Compressed data (with section header) stays in same location as the source + (overwrites source data). + +Arguments: + + FileBuffer - Buffer containing data to Compress + + BufferSize - On input, the size of FileBuffer. On output, the size of + actual compressed data (including added section header). + When buffer is too small, this value indicates the size needed. + + DataSize - The size of data to compress + + Type - The compression type (not used currently). + Assume EFI_HEAVY_COMPRESSION. + +Returns: + + EFI_BUFFER_TOO_SMALL - Buffer size is too small. + EFI_UNSUPPORTED - Compress type can not be supported. + EFI_SUCCESS - Successful + EFI_OUT_OF_RESOURCES - Not enough resource. + +--*/ +{ + EFI_STATUS Status; + UINT8 *CompData; + UINT32 CompSize; + UINT32 TotalSize; + EFI_COMPRESSION_SECTION CompressionSet; + UINT8 CompressionType; + COMPRESS_FUNCTION CompressFunction; + + Status = EFI_SUCCESS; + CompData = NULL; + CompSize = 0; + TotalSize = 0; + CompressFunction = NULL; + + // + // Get the compress type + // + if (_strcmpi (Type, "Dummy") == 0) { + // + // Added "Dummy" to keep backward compatibility. + // + CompressionType = EFI_STANDARD_COMPRESSION; + CompressFunction = (COMPRESS_FUNCTION) TianoCompress; + + } else if (_strcmpi (Type, "LZH") == 0) { + // + // EFI stardard compression (LZH) + // + CompressionType = EFI_STANDARD_COMPRESSION; + CompressFunction = (COMPRESS_FUNCTION) TianoCompress; + + } else { + // + // Customized compression + // + Status = SetCustomizedCompressionType (Type); + if (EFI_ERROR (Status)) { + return Status; + } + + CompressionType = EFI_CUSTOMIZED_COMPRESSION; + CompressFunction = (COMPRESS_FUNCTION) CustomizedCompress; + } + // + // Compress the raw data + // + Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize); + if (Status == EFI_BUFFER_TOO_SMALL) { + CompData = malloc (CompSize); + if (!CompData) { + return EFI_OUT_OF_RESOURCES; + } + + Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize); + } + + if (EFI_ERROR (Status)) { + if (CompData != NULL) { + free (CompData); + } + + return Status; + } + + TotalSize = CompSize + sizeof (EFI_COMPRESSION_SECTION); + + // + // Buffer too small? + // + if (TotalSize > *BufferSize) { + *BufferSize = TotalSize; + if (CompData != NULL) { + free (CompData); + } + + return EFI_BUFFER_TOO_SMALL; + } + // + // Add the section header for the compressed data + // + CompressionSet.CommonHeader.Type = EFI_SECTION_COMPRESSION; + CompressionSet.CommonHeader.Size[0] = (UINT8) (TotalSize & 0xff); + CompressionSet.CommonHeader.Size[1] = (UINT8) ((TotalSize & 0xff00) >> 8); + CompressionSet.CommonHeader.Size[2] = (UINT8) ((TotalSize & 0xff0000) >> 16); + CompressionSet.CompressionType = CompressionType; + CompressionSet.UncompressedLength = DataSize; + + // + // Copy header and data to the buffer + // + memcpy (FileBuffer, &CompressionSet, sizeof (EFI_COMPRESSION_SECTION)); + memcpy (FileBuffer + sizeof (CompressionSet), CompData, CompSize); + + // + // Make sure section ends on a DWORD boundary + // + while ((TotalSize & 0x03) != 0) { + FileBuffer[TotalSize] = 0; + TotalSize++; + } + + *BufferSize = TotalSize; + + if (CompData != NULL) { + free (CompData); + } + + return EFI_SUCCESS; +} + +static +void +StripParens ( + IN OUT CHAR8 *String + ) +/*++ + +Routine Description: + + Removes Parenthesis from around a string + +Arguments: + + String - String to remove parens from + +Returns: + + None + +--*/ +{ + INT32 Index; + + if (String[0] != '(') { + return ; + } + + for (Index = 1; String[Index] != ')'; Index++) { + String[Index - 1] = String[Index]; + if (String[Index] == 0) { + return ; + } + } + + String[Index - 1] = 0; + + return ; +} + +static +void +StripEqualMark ( + IN OUT CHAR8 *String + ) +/*++ + +Routine Description: + + Removes Equal Mark from around a string + +Arguments: + + String - String to remove equal mark from + +Returns: + + None + +--*/ +{ + INT32 Index; + + if (String[0] != '=' && String[strlen (String) - 1] != '=') { + return ; + } + + if (String[0] == '=') { + + for (Index = 1; String[Index] != 0; Index++) { + String[Index - 1] = String[Index]; + } + + String[Index - 1] = 0; + } + + if (String[strlen (String) - 1] == '=') { + String[strlen (String) - 1] = 0; + } + + return ; +} + +static +INT32 +ProcessEnvironmentVariable ( + IN CHAR8 *Buffer, + OUT CHAR8 *NewBuffer + ) +/*++ + +Routine Description: + + Converts environment variables to values + +Arguments: + + Buffer - Buffer containing Environment Variable String + + NewBuffer - Buffer containing value of environment variable + + +Returns: + + Number of characters from Buffer used + +--*/ +{ + INT32 Index; + INT32 Index2; + CHAR8 VariableBuffer[_MAX_PATH]; + + Index = 2; + Index2 = 0; + + while (Buffer[Index] != ')') { + VariableBuffer[Index - 2] = Buffer[Index++]; + } + + VariableBuffer[Index - 2] = 0; + Index++; + + if (getenv (VariableBuffer) != NULL) { + strcpy (NewBuffer, getenv (VariableBuffer)); + } else { + printf ("Environment variable %s not found!\n", VariableBuffer); + } + + return Index; +} + +static +void +SplitAttributesField ( + IN CHAR8 *Buffer, + IN CHAR8 *AttributesArray[], + IN OUT UINT32 *NumberOfAttributes + ) +/* + NumberOfAttributes: on input, it specifies the current number of attributes + stored in AttributeArray. + on output, it is updated to the latest number of attributes + stored in AttributesArray. +*/ +{ + UINT32 Index; + UINT32 Index2; + UINT32 z; + CHAR8 *CharBuffer; + + CharBuffer = NULL; + CharBuffer = (CHAR8 *) malloc (_MAX_PATH); + ZeroMem (CharBuffer, _MAX_PATH); + + for (Index = 0, z = 0, Index2 = 0; Index < strlen (Buffer); Index++) { + + if (Buffer[Index] != '|') { + CharBuffer[z] = Buffer[Index]; + z++; + } else { + + CharBuffer[z] = 0; + AttributesArray[*NumberOfAttributes + Index2] = CharBuffer; + Index2++; + + // + // allocate new char buffer for the next attributes string + // + CharBuffer = (CHAR8 *) malloc (_MAX_PATH); + ZeroMem (CharBuffer, _MAX_PATH); + z = 0; + } + } + + CharBuffer[z] = 0; + // + // record the last attributes string in the Buffer + // + AttributesArray[*NumberOfAttributes + Index2] = CharBuffer; + Index2++; + + *NumberOfAttributes += Index2; + + return ; +} + +static +INT32 +GetToolArguments ( + CHAR8 *ToolArgumentsArray[], + FILE *Package, + CHAR8 **PtrInputFileName, + CHAR8 **PtrOutputFileName, + EFI_GUID *Guid, + UINT16 *GuidedSectionAttributes + ) +{ + CHAR8 Buffer[_MAX_PATH]; + BOOLEAN ArgumentsFlag; + BOOLEAN InputFlag; + BOOLEAN OutputFlag; + BOOLEAN GuidFlag; + BOOLEAN AttributesFlag; + UINT32 argc; + UINT32 Index2; + UINT32 z; + CHAR8 *CharBuffer; + INT32 Index; + INT32 ReturnValue; + EFI_STATUS Status; + + CHAR8 *AttributesArray[MAX_ARRAY_SIZE]; + UINT32 NumberOfAttributes; + CHAR8 *InputFileName; + CHAR8 *OutputFileName; + UINT32 LineNumber; + Buffer[_MAX_PATH]; + + ArgumentsFlag = FALSE; + InputFlag = FALSE; + OutputFlag = FALSE; + GuidFlag = FALSE; + AttributesFlag = FALSE; + // + // Start at 1, since ToolArgumentsArray[0] + // is the program name. + // + argc = 1; + Index2 = 0; + + z = 0; + ReturnValue = 0; + NumberOfAttributes = 0; + InputFileName = NULL; + OutputFileName = NULL; + + ZeroMem (Buffer, _MAX_PATH); + ZeroMem (AttributesArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE); + LineNumber = 0; + while (Buffer[0] != ')') { + + if (GetNextLine (Buffer, Package, &LineNumber) != -1) { + CheckSlash (Buffer, Package, &LineNumber); + StripEqualMark (Buffer); + } else { + Error (NULL, 0, 0, "failed to get next line from package file", NULL); + return -1; + } + + if (Buffer[0] == ')') { + break; + } else if (_strcmpi (Buffer, "ARGS") == 0) { + + ArgumentsFlag = TRUE; + AttributesFlag = FALSE; + continue; + + } else if (_strcmpi (Buffer, "INPUT") == 0) { + + InputFlag = TRUE; + ArgumentsFlag = FALSE; + AttributesFlag = FALSE; + continue; + + } else if (_strcmpi (Buffer, "OUTPUT") == 0) { + + OutputFlag = TRUE; + ArgumentsFlag = FALSE; + AttributesFlag = FALSE; + continue; + + } else if (_strcmpi (Buffer, "GUID") == 0) { + + GuidFlag = TRUE; + ArgumentsFlag = FALSE; + AttributesFlag = FALSE; + // + // fetch the GUID for the section + // + continue; + + } else if (_strcmpi (Buffer, "ATTRIBUTES") == 0) { + + AttributesFlag = TRUE; + ArgumentsFlag = FALSE; + // + // fetch the GUIDed Section's Attributes + // + continue; + + } else if (_strcmpi (Buffer, "") == 0) { + continue; + } + // + // get all command arguments into ToolArgumentsArray + // + if (ArgumentsFlag) { + + StripEqualMark (Buffer); + + CharBuffer = (CHAR8 *) malloc (_MAX_PATH); + if (CharBuffer == NULL) { + goto ErrorExit; + } + + ZeroMem (CharBuffer, sizeof (_MAX_PATH)); + + ToolArgumentsArray[argc] = CharBuffer; + + if (Buffer[0] == '$') { + Index = ProcessEnvironmentVariable (&Buffer[0], ToolArgumentsArray[argc]); + // + // if there is string after the environment variable, cat it. + // + if ((UINT32) Index < strlen (Buffer)) { + strcat (ToolArgumentsArray[argc], &Buffer[Index]); + } + } else { + strcpy (ToolArgumentsArray[argc], Buffer); + } + + argc += 1; + ToolArgumentsArray[argc] = NULL; + continue; + } + + if (InputFlag) { + + StripEqualMark (Buffer); + + InputFileName = (CHAR8 *) malloc (_MAX_PATH); + if (InputFileName == NULL) { + goto ErrorExit; + } + + ZeroMem (InputFileName, sizeof (_MAX_PATH)); + + if (Buffer[0] == '$') { + Index = ProcessEnvironmentVariable (&Buffer[0], InputFileName); + // + // if there is string after the environment variable, cat it. + // + if ((UINT32) Index < strlen (Buffer)) { + strcat (InputFileName, &Buffer[Index]); + } + } else { + strcpy (InputFileName, Buffer); + } + + InputFlag = FALSE; + continue; + } + + if (OutputFlag) { + + StripEqualMark (Buffer); + + OutputFileName = (CHAR8 *) malloc (_MAX_PATH); + if (OutputFileName == NULL) { + goto ErrorExit; + } + + ZeroMem (OutputFileName, sizeof (_MAX_PATH)); + + if (Buffer[0] == '$') { + Index = ProcessEnvironmentVariable (&Buffer[0], OutputFileName); + // + // if there is string after the environment variable, cat it. + // + if ((UINT32) Index < strlen (Buffer)) { + strcat (OutputFileName, &Buffer[Index]); + } + } else { + strcpy (OutputFileName, Buffer); + } + + OutputFlag = FALSE; + continue; + } + + if (GuidFlag) { + + StripEqualMark (Buffer); + + Status = StringToGuid (Buffer, Guid); + if (EFI_ERROR (Status)) { + ReturnValue = -1; + goto ErrorExit; + } + + GuidFlag = FALSE; + } + + if (AttributesFlag) { + + StripEqualMark (Buffer); + + // + // there might be no space between each attribute in the statement, + // split them aside and return each attribute string + // in the AttributesArray + // + SplitAttributesField (Buffer, AttributesArray, &NumberOfAttributes); + } + } + // + // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"INPUT",InputVariable,j); + // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"OUTPUT",&TargetFileName,1); + // + for (z = 0; z < NumberOfAttributes; z++) { + if (_strcmpi (AttributesArray[z], "PROCESSING_REQUIRED") == 0) { + *GuidedSectionAttributes |= EFI_GUIDED_SECTION_PROCESSING_REQUIRED; + } else if (_strcmpi (AttributesArray[z], "AUTH_STATUS_VALID") == 0) { + *GuidedSectionAttributes |= EFI_GUIDED_SECTION_AUTH_STATUS_VALID; + } + } + +ErrorExit: + + for (Index2 = 0; Index2 < MAX_ARRAY_SIZE; Index2++) { + if (AttributesArray[Index2] == NULL) { + break; + } + + free (AttributesArray[Index2]); + } + + *PtrInputFileName = InputFileName; + *PtrOutputFileName = OutputFileName; + + return ReturnValue; +} + +static +INT32 +ProcessScript ( + IN OUT UINT8 *FileBuffer, + IN FILE *Package, + IN CHAR8 *BuildDirectory, + IN BOOLEAN ForceUncompress + ) +/*++ + +Routine Description: + + Signs the section, data stays in same location + +Arguments: + + FileBuffer - Data Buffer + + Package - Points to curly brace in Image Script + + BuildDirectory - Name of the source directory parameter + + ForceUncompress - Whether to force uncompress. + +Returns: + + Number of bytes added to file buffer + -1 on error + +--*/ +{ + EFI_STATUS Status; + UINT32 Size; + CHAR8 Buffer[_MAX_PATH]; + CHAR8 Type[_MAX_PATH]; + CHAR8 FileName[_MAX_PATH]; + CHAR8 NewBuffer[_MAX_PATH]; + INT32 Index3; + INT32 Index2; + UINT32 ReturnValue; + UINT8 ByteBuffer; + FILE *InFile; + UINT32 SourceDataSize; + CHAR8 *ToolArgumentsArray[MAX_ARRAY_SIZE]; + CHAR8 *OutputFileName; + CHAR8 *InputFileName; + CHAR8 ToolName[_MAX_PATH]; + FILE *OutputFile; + FILE *InputFile; + UINT8 Temp; + int returnint; + INT32 Index; + UINT32 LineNumber; + BOOLEAN IsError; + EFI_GUID SignGuid; + UINT16 GuidedSectionAttributes; + UINT8 *TargetFileBuffer; + + OutputFileName = NULL; + InputFileName = NULL; + OutputFile = NULL; + InputFile = NULL; + IsError = FALSE; + GuidedSectionAttributes = 0; + TargetFileBuffer = NULL; + + Size = 0; + LineNumber = 0; + Buffer[0] = 0; + for (Index3 = 0; Index3 < MAX_ARRAY_SIZE; ++Index3) { + ToolArgumentsArray[Index3] = NULL; + } + + while (Buffer[0] != '}') { + if (GetNextLine (Buffer, Package, &LineNumber) != -1) { + CheckSlash (Buffer, Package, &LineNumber); + } else { + printf ("ERROR in IMAGE SCRIPT!\n"); + IsError = TRUE; + goto Done; + } + + if (_strcmpi (Buffer, "Compress") == 0) { + // + // Handle compress + // + // + // read compression type + // + if (GetNextLine (Buffer, Package, &LineNumber) != -1) { + CheckSlash (Buffer, Package, &LineNumber); + } + + StripParens (Buffer); + if (Buffer[0] == '$') { + ProcessEnvironmentVariable (&Buffer[0], Type); + } else { + strcpy (Type, Buffer); + } + // + // build buffer + // + while (Buffer[0] != '{') { + if (GetNextLine (Buffer, Package, &LineNumber) != -1) { + CheckSlash (Buffer, Package, &LineNumber); + } + } + + ReturnValue = ProcessScript (&FileBuffer[Size], Package, BuildDirectory, ForceUncompress); + if (ReturnValue == -1) { + IsError = TRUE; + goto Done; + } + // + // Call compress routine on buffer. + // Occasionally, compressed data + section header would + // be largere than the source and EFI_BUFFER_TOO_SMALL is + // returned from CompressSection() + // + SourceDataSize = ReturnValue; + + if (!ForceUncompress) { + + Status = CompressSection ( + &FileBuffer[Size], + &ReturnValue, + SourceDataSize, + Type + ); + + if (Status == EFI_BUFFER_TOO_SMALL) { + Status = CompressSection ( + &FileBuffer[Size], + &ReturnValue, + SourceDataSize, + Type + ); + } + + if (EFI_ERROR (Status)) { + IsError = TRUE; + goto Done; + } + } + + Size += ReturnValue; + + } else if (_strcmpi (Buffer, "Tool") == 0) { + + ZeroMem (ToolName, _MAX_PATH); + ZeroMem (ToolArgumentsArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE); + ZeroMem (&SignGuid, sizeof (EFI_GUID)); + + // + // handle signing Tool + // + while (Buffer[0] != '(') { + if (GetNextLine (Buffer, Package, &LineNumber) != -1) { + CheckSlash (Buffer, Package, &LineNumber); + } + } + + if (_strcmpi (Buffer, "(") == 0) { + if (GetNextLine (Buffer, Package, &LineNumber) != -1) { + CheckSlash (Buffer, Package, &LineNumber); + } + } + + StripParens (Buffer); + + if (Buffer[0] == '$') { + Index = ProcessEnvironmentVariable (&Buffer[0], ToolName); + // + // if there is string after the environment variable, cat it. + // + if ((UINT32) Index < strlen (Buffer)) { + strcat (ToolName, &Buffer[Index]); + } + } else { + strcpy (ToolName, Buffer); + } + + ToolArgumentsArray[0] = ToolName; + + // + // read ARGS + // + if (GetToolArguments ( + ToolArgumentsArray, + Package, + &InputFileName, + &OutputFileName, + &SignGuid, + &GuidedSectionAttributes + ) == -1) { + IsError = TRUE; + goto Done; + } + // + // if the tool need input file, + // dump the file buffer to the specified input file. + // + if (InputFileName != NULL) { + InputFile = fopen (InputFileName, "wb"); + if (InputFile == NULL) { + Error (NULL, 0, 0, InputFileName, "failed to open output file for writing"); + IsError = TRUE; + goto Done; + } + + fwrite (FileBuffer, sizeof (UINT8), Size, InputFile); + fclose (InputFile); + InputFile = NULL; + free (InputFileName); + InputFileName = NULL; + } + // + // dispatch signing tool + // + returnint = _spawnv (_P_WAIT, ToolName, ToolArgumentsArray); + if (returnint != 0) { + Error (NULL, 0, 0, ToolName, "external tool failed"); + IsError = TRUE; + goto Done; + } + // + // if the tool has output file, + // dump the output file to the file buffer + // + if (OutputFileName != NULL) { + + OutputFile = fopen (OutputFileName, "rb"); + if (OutputFile == NULL) { + Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing"); + IsError = TRUE; + goto Done; + } + + TargetFileBuffer = &FileBuffer[Size]; + SourceDataSize = Size; + + fread (&Temp, sizeof (UINT8), 1, OutputFile); + while (!feof (OutputFile)) { + FileBuffer[Size++] = Temp; + fread (&Temp, sizeof (UINT8), 1, OutputFile); + } + + while ((Size & 0x03) != 0) { + FileBuffer[Size] = 0; + Size++; + } + + SourceDataSize = Size - SourceDataSize; + + fclose (OutputFile); + OutputFile = NULL; + free (OutputFileName); + OutputFileName = NULL; + + if (CompareGuid (&SignGuid, &mZeroGuid) != 0) { + ReturnValue = SourceDataSize; + Status = GenSimpleGuidSection ( + TargetFileBuffer, + &ReturnValue, + SourceDataSize, + SignGuid, + GuidedSectionAttributes + ); + if (EFI_ERROR (Status)) { + IsError = TRUE; + goto Done; + } + + Size = ReturnValue; + } + } + + } else if (Buffer[0] != '}') { + // + // if we are here, we should see either a file name, + // or a }. + // + Index3 = 0; + FileName[0] = 0; + // + // Prepend the build directory to the file name if the + // file name does not already contain a full path. + // + if (!isalpha (Buffer[0]) || (Buffer[1] != ':')) { + sprintf (FileName, "%s\\", BuildDirectory); + } + + while (Buffer[Index3] != '\n') { + if (Buffer[Index3] == '$') { + Index3 += ProcessEnvironmentVariable (&Buffer[Index3], NewBuffer); + strcat (FileName, NewBuffer); + } + + if (Buffer[Index3] == 0) { + break; + } else { + Index2 = strlen (FileName); + FileName[Index2++] = Buffer[Index3++]; + FileName[Index2] = 0; + } + } + + InFile = fopen (FileName, "rb"); + if (InFile == NULL) { + Error (NULL, 0, 0, FileName, "failed to open file for reading"); + IsError = TRUE; + goto Done; + } + + fread (&ByteBuffer, sizeof (UINT8), 1, InFile); + while (!feof (InFile)) { + FileBuffer[Size++] = ByteBuffer; + fread (&ByteBuffer, sizeof (UINT8), 1, InFile); + } + + fclose (InFile); + InFile = NULL; + + // + // Make sure section ends on a DWORD boundary + // + while ((Size & 0x03) != 0) { + FileBuffer[Size] = 0; + Size++; + } + + } + } + +Done: + for (Index3 = 1; Index3 < MAX_ARRAY_SIZE; Index3++) { + if (ToolArgumentsArray[Index3] == NULL) { + break; + } + + free (ToolArgumentsArray[Index3]); + } + + if (IsError) { + return -1; + } + + return Size; + +} + +static +UINT8 +StringToType ( + IN CHAR8 *String + ) +/*++ + +Routine Description: + + Converts File Type String to value. EFI_FV_FILETYPE_ALL indicates that an + unrecognized file type was specified. + +Arguments: + + String - File type string + +Returns: + + File Type Value + +--*/ +{ + if (_strcmpi (String, "EFI_FV_FILETYPE_RAW") == 0) { + return EFI_FV_FILETYPE_RAW; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_FREEFORM") == 0) { + return EFI_FV_FILETYPE_FREEFORM; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_SECURITY_CORE") == 0) { + return EFI_FV_FILETYPE_SECURITY_CORE; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_PEI_CORE") == 0) { + return EFI_FV_FILETYPE_PEI_CORE; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_DXE_CORE") == 0) { + return EFI_FV_FILETYPE_DXE_CORE; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_PEIM") == 0) { + return EFI_FV_FILETYPE_PEIM; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_DRIVER") == 0) { + return EFI_FV_FILETYPE_DRIVER; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER") == 0) { + return EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_APPLICATION") == 0) { + return EFI_FV_FILETYPE_APPLICATION; + } + + if (_strcmpi (String, "EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE") == 0) { + return EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE; + } + + return EFI_FV_FILETYPE_ALL; +} + +static +UINT32 +AdjustFileSize ( + IN UINT8 *FileBuffer, + IN UINT32 FileSize + ) +/*++ + +Routine Description: + Adjusts file size to insure sectioned file is exactly the right length such + that it ends on exactly the last byte of the last section. ProcessScript() + may have padded beyond the end of the last section out to a 4 byte boundary. + This padding is stripped. + +Arguments: + FileBuffer - Data Buffer - contains a section stream + FileSize - Size of FileBuffer as returned from ProcessScript() + +Returns: + Corrected size of file. + +--*/ +{ + UINT32 TotalLength; + UINT32 CurrentLength; + UINT32 SectionLength; + UINT32 SectionStreamLength; + EFI_COMMON_SECTION_HEADER *SectionHeader; + EFI_COMMON_SECTION_HEADER *NextSectionHeader; + + TotalLength = 0; + CurrentLength = 0; + SectionStreamLength = FileSize; + + SectionHeader = (EFI_COMMON_SECTION_HEADER *) FileBuffer; + + while (TotalLength < SectionStreamLength) { + SectionLength = *((UINT32 *) SectionHeader->Size) & 0x00ffffff; + TotalLength += SectionLength; + + if (TotalLength == SectionStreamLength) { + return TotalLength; + } + // + // Move to the next byte following the section... + // + SectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + SectionLength); + CurrentLength = (UINTN) SectionHeader - (UINTN) FileBuffer; + + // + // Figure out where the next section begins + // + NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + 3); + NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) NextSectionHeader &~ (UINTN) 3); + TotalLength += (UINTN) NextSectionHeader - (UINTN) SectionHeader; + SectionHeader = NextSectionHeader; + } + + return CurrentLength; +} + +static +INT32 +MainEntry ( + INT32 argc, + CHAR8 *argv[], + BOOLEAN ForceUncompress + ) +/*++ + +Routine Description: + + MainEntry function. + +Arguments: + + argc - Number of command line parameters. + argv - Array of pointers to command line parameter strings. + ForceUncompress - If TRUE, force to do not compress the sections even if compression + is specified in the script. Otherwise, FALSE. + +Returns: + STATUS_SUCCESS - Function exits successfully. + STATUS_ERROR - Some error occurred during execution. + +--*/ +{ + FILE *PrimaryPackage; + FILE *OverridePackage; + FILE *Out; + CHAR8 BaseName[_MAX_PATH]; + EFI_GUID FfsGuid; + CHAR8 GuidString[_MAX_PATH]; + EFI_FFS_FILE_HEADER FileHeader; + CHAR8 FileType[_MAX_PATH]; + EFI_FFS_FILE_ATTRIBUTES FfsAttrib; + EFI_FFS_FILE_ATTRIBUTES FfsAttribDefined; + UINT64 FfsAlignment; + UINT32 FfsAlignment32; + CHAR8 InputString[_MAX_PATH]; + BOOLEAN ImageScriptInOveride; + UINT32 FileSize; + UINT8 *FileBuffer; + EFI_STATUS Status; + UINT32 LineNumber; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_FFS_FILE_TAIL TailValue; +#endif + BaseName[0] = 0; + FileType[0] = 0; + FfsAttrib = 0; + FfsAttribDefined = 0; + FfsAlignment = 0; + FfsAlignment32 = 0; + PrimaryPackage = NULL; + Out = NULL; + OverridePackage = NULL; + FileBuffer = NULL; + + strcpy (GuidString, "00000000-0000-0000-0000-000000000000"); + Status = StringToGuid (GuidString, &FfsGuid); + if (Status != 0) { + Error (NULL, 0, 0, GuidString, "error parsing GUID string"); + return STATUS_ERROR; + } + + GuidString[0] = 0; + ImageScriptInOveride = FALSE; + // + // Initialize the simple file parsing routines. Then open + // the primary package file for parsing. + // + SFPInit (); + if (SFPOpenFile (mGlobals.PrimaryPackagePath) != STATUS_SUCCESS) { + Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file"); + goto Done; + } + // + // First token in the file must be "PACKAGE.INF" + // + if (!SFPIsToken ("PACKAGE.INF")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'PACKAGE.INF'", NULL); + goto Done; + } + // + // Find the [.] section + // + if (!SFPSkipToToken ("[.]")) { + Error (mGlobals.PrimaryPackagePath, 1, 0, "could not locate [.] section in package file", NULL); + goto Done; + } + // + // Start parsing the data. The algorithm is essentially the same for each keyword: + // 1. Identify the keyword + // 2. Verify that the keyword/value pair has not already been defined + // 3. Set some flag indicating that the keyword/value pair has been defined + // 4. Skip over the "=" + // 5. Get the value, which may be a number, TRUE, FALSE, or a string. + // + while (1) { + if (SFPIsToken ("BASE_NAME")) { + // + // Found BASE_NAME, format: + // BASE_NAME = MyBaseName + // + if (BaseName[0] != 0) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "BASE_NAME already defined", NULL); + goto Done; + } + + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (!SFPGetNextToken (BaseName, sizeof (BaseName))) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid base name", NULL); + goto Done; + } + } else if (SFPIsToken ("IMAGE_SCRIPT")) { + // + // Found IMAGE_SCRIPT. Break out and process below. + // + break; + } else if (SFPIsToken ("FFS_FILEGUID")) { + // + // found FILEGUID, format: + // FFS_FILEGUID = F7845C4F-EDF5-42C5-BD8F-A02AF63DD93A + // + if (GuidString[0] != 0) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILEGUID already defined", NULL); + goto Done; + } + + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (SFPGetGuidToken (GuidString, sizeof (GuidString)) != TRUE) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected file GUID", NULL); + goto Done; + } + + Status = StringToGuid (GuidString, &FfsGuid); + if (Status != 0) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid file GUID", NULL); + goto Done; + } + } else if (SFPIsToken ("FFS_FILETYPE")) { + // + // *********************************************************************** + // + // Found FFS_FILETYPE, format: + // FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION + // + if (FileType[0] != 0) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILETYPE previously defined", NULL); + goto Done; + } + + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (!SFPGetNextToken (FileType, sizeof (FileType))) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid FFS_FILETYPE", NULL); + goto Done; + } + } +#if (PI_SPECIFICATION_VERSION < 0x00010000) + else if (SFPIsToken ("FFS_ATTRIB_HEADER_EXTENSION")) { + // + // *********************************************************************** + // + // Found: FFS_ATTRIB_HEADER_EXTENSION = FALSE + // Spec says the bit is for future expansion, and must be false. + // + if (FfsAttribDefined & FFS_ATTRIB_HEADER_EXTENSION) { + Error ( + mGlobals.PrimaryPackagePath, + SFPGetLineNumber (), + 0, + "FFS_ATTRIB_HEADER_EXTENSION previously defined", + NULL + ); + goto Done; + } + + FfsAttribDefined |= FFS_ATTRIB_HEADER_EXTENSION; + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (SFPIsToken ("TRUE")) { + Error ( + mGlobals.PrimaryPackagePath, + SFPGetLineNumber (), + 0, + "only FFS_ATTRIB_HEADER_EXTENSION = FALSE is supported", + NULL + ); + goto Done; + } else if (SFPIsToken ("FALSE")) { + // + // Default is FALSE + // + } else { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'FALSE'", NULL); + goto Done; + } + } +#else + else if (SFPIsToken ("FFS_ATTRIB_FIXED")) { + // + // *********************************************************************** + // + // Found: FFS_ATTRIB_FIXED = TRUE | FALSE + // + if (FfsAttribDefined & FFS_ATTRIB_FIXED) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_FIXED previously defined", NULL); + goto Done; + } + + FfsAttribDefined |= FFS_ATTRIB_FIXED; + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (SFPIsToken ("TRUE")) { + FfsAttrib |= FFS_ATTRIB_FIXED; + } else if (SFPIsToken ("FALSE")) { + // + // Default is FALSE + // + } else { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL); + goto Done; + } + } +#endif + else if (SFPIsToken ("FFS_ATTRIB_TAIL_PRESENT")) { + // + // *********************************************************************** + // + // Found: FFS_ATTRIB_TAIL_PRESENT = TRUE | FALSE + // + if (FfsAttribDefined & FFS_ATTRIB_TAIL_PRESENT) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_TAIL_PRESENT previously defined", NULL); + goto Done; + } + + FfsAttribDefined |= FFS_ATTRIB_TAIL_PRESENT; + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (SFPIsToken ("TRUE")) { + FfsAttrib |= FFS_ATTRIB_TAIL_PRESENT; + } else if (SFPIsToken ("FALSE")) { + // + // Default is FALSE + // + } else { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL); + goto Done; + } + } else if (SFPIsToken ("FFS_ATTRIB_RECOVERY")) { + // + // *********************************************************************** + // + // Found: FFS_ATTRIB_RECOVERY = TRUE | FALSE + // + if (FfsAttribDefined & FFS_ATTRIB_RECOVERY) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_RECOVERY previously defined", NULL); + goto Done; + } + + FfsAttribDefined |= FFS_ATTRIB_RECOVERY; + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (SFPIsToken ("TRUE")) { + FfsAttrib |= FFS_ATTRIB_RECOVERY; + } else if (SFPIsToken ("FALSE")) { + // + // Default is FALSE + // + } else { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL); + goto Done; + } + } else if (SFPIsToken ("FFS_ATTRIB_CHECKSUM")) { + // + // *********************************************************************** + // + // Found: FFS_ATTRIB_CHECKSUM = TRUE | FALSE + // + if (FfsAttribDefined & FFS_ATTRIB_CHECKSUM) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_CHECKSUM previously defined", NULL); + goto Done; + } + + FfsAttribDefined |= FFS_ATTRIB_CHECKSUM; + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (SFPIsToken ("TRUE")) { + FfsAttrib |= FFS_ATTRIB_CHECKSUM; + } else if (SFPIsToken ("FALSE")) { + // + // Default is FALSE + // + } else { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL); + goto Done; + } + } else if (SFPIsToken ("FFS_ALIGNMENT") || SFPIsToken ("FFS_ATTRIB_DATA_ALIGNMENT")) { + // + // *********************************************************************** + // + // Found FFS_ALIGNMENT, formats: + // FFS_ALIGNMENT = 0-7 + // FFS_ATTRIB_DATA_ALIGNMENT = 0-7 + // + if (FfsAttribDefined & FFS_ATTRIB_DATA_ALIGNMENT) { + Error ( + mGlobals.PrimaryPackagePath, + SFPGetLineNumber (), + 0, + "FFS_ALIGNMENT/FFS_ATTRIB_DATA_ALIGNMENT previously defined", + NULL + ); + goto Done; + } + + FfsAttribDefined |= FFS_ATTRIB_DATA_ALIGNMENT; + if (!SFPIsToken ("=")) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL); + goto Done; + } + + if (!SFPGetNumber (&FfsAlignment32)) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected numeric value for alignment", NULL); + goto Done; + } + + if (FfsAlignment32 > 7) { + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 0 <= alignment <= 7", NULL); + goto Done; + } + + FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment32) << 3); + } else { + SFPGetNextToken (InputString, sizeof (InputString)); + Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, InputString, "unrecognized/unexpected token"); + goto Done; + } + } + // + // Close the primary package file + // + SFPCloseFile (); + // + // TODO: replace code below with basically a copy of the code above. Don't + // forget to reset the FfsAttribDefined variable first. Also, you'll need + // to somehow keep track of whether or not the basename is defined multiple + // times in the override package. Ditto on the file GUID. + // + if (mGlobals.OverridePackagePath[0] != 0) { + OverridePackage = fopen (mGlobals.OverridePackagePath, "r"); + // + // NOTE: For package override to work correctly, the code below must be modified to + // SET or CLEAR bits properly. For example, if the primary package set + // FFS_ATTRIB_CHECKSUM = TRUE, and the override set FFS_ATTRIB_CHECKSUM = FALSE, then + // we'd need to clear the bit below. Since this is not happening, I'm guessing that + // the override functionality is not being used, so should be made obsolete. If I'm + // wrong, and it is being used, then it needs to be fixed. Thus emit an error if it is + // used, and we'll address it then. 4/10/2003 + // + Error (__FILE__, __LINE__, 0, "package override functionality is not implemented correctly", NULL); + goto Done; + } else { + OverridePackage = NULL; + } + +#ifdef OVERRIDE_SUPPORTED + if (OverridePackage != NULL) { + // + // Parse override package file + // + fscanf (OverridePackage, "%s", &InputString); + if (_strcmpi (InputString, "PACKAGE.INF") != 0) { + Error (mGlobals.OverridePackagePath, 1, 0, "invalid package file", "expected 'PACKAGE.INF'"); + goto Done; + } + // + // Match [dir] to Build Directory + // + if (FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber) != 0) { + Error (mGlobals.OverridePackagePath, 1, 0, mGlobals.BuildDirectory, "section not found in package file"); + goto Done; + } + + InputString[0] = 0; + while ((InputString[0] != '[') && (!feof (OverridePackage))) { + if (GetNextLine (InputString, OverridePackage, &LineNumber) != -1) { + if (InputString[0] != '[') { +here: + if (_strcmpi (InputString, "BASE_NAME") == 0) { + // + // found BASE_NAME, next is = and string. + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (strlen (InputString) == 1) { + // + // string is just = + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + strcpy (BaseName, InputString); + } else { + BreakString (InputString, InputString, 1); + strcpy (BaseName, InputString); + } + } else if (_strcmpi (InputString, "IMAGE_SCRIPT") == 0) { + // + // found IMAGE_SCRIPT, come back later to process it + // + ImageScriptInOveride = TRUE; + fscanf (OverridePackage, "%s", &InputString); + } else if (_strcmpi (InputString, "FFS_FILEGUID") == 0) { + // + // found FILEGUID, next is = and string. + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (strlen (InputString) == 1) { + // + // string is just = + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + Status = StringToGuid (InputString, &FfsGuid); + if (Status != 0) { + Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format"); + goto Done; + } + } else { + BreakString (InputString, InputString, 1); + Status = StringToGuid (InputString, &FfsGuid); + if (Status != 0) { + Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format"); + goto Done; + } + } + } else if (_strcmpi (InputString, "FFS_FILETYPE") == 0) { + // + // found FILETYPE, next is = and string. + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (strlen (InputString) == 1) { + // + // string is just = + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + strcpy (FileType, InputString); + } else { + BreakString (InputString, InputString, 1); + strcpy (FileType, InputString); + } + + } else if (_strcmpi (InputString, "FFS_ATTRIB_RECOVERY") == 0) { + // + // found FFS_ATTRIB_RECOVERY, next is = and string. + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (strlen (InputString) == 1) { + // + // string is just = + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (_strcmpi (InputString, "TRUE") == 0) { + FfsAttrib |= FFS_ATTRIB_RECOVERY; + } + } else { + BreakString (InputString, InputString, 1); + if (_strcmpi (InputString, "TRUE") == 0) { + FfsAttrib |= FFS_ATTRIB_RECOVERY; + } + } + } else if (_strcmpi (InputString, "FFS_ATTRIB_CHECKSUM") == 0) { + // + // found FFS_ATTRIB_CHECKSUM, next is = and string. + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (strlen (InputString) == 1) { + // + // string is just = + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (_strcmpi (InputString, "TRUE") == 0) { + FfsAttrib |= FFS_ATTRIB_CHECKSUM; + } + } else { + BreakString (InputString, InputString, 1); + if (_strcmpi (InputString, "TRUE") == 0) { + FfsAttrib |= FFS_ATTRIB_CHECKSUM; + } + } + } else if (_strcmpi (InputString, "FFS_ALIGNMENT") == 0) { + // + // found FFS_ALIGNMENT, next is = and string. + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (strlen (InputString) == 1) { + // + // string is just = + // + fscanf (OverridePackage, "%s", &InputString); + CheckSlash (InputString, OverridePackage, &LineNumber); + } else { + BreakString (InputString, InputString, 1); + } + + AsciiStringToUint64 (InputString, FALSE, &FfsAlignment); + if (FfsAlignment > 7) { + Error (mGlobals.OverridePackagePath, 1, 0, InputString, "invalid FFS_ALIGNMENT value"); + goto Done; + } + + FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment) << 3); + } else if (strchr (InputString, '=') != NULL) { + BreakString (InputString, String, 1); + fseek (OverridePackage, (-1 * (strlen (String) + 1)), SEEK_CUR); + BreakString (InputString, InputString, 0); + goto here; + } + } + } + } + } +#endif // #ifdef OVERRIDE_SUPPORTED + // + // Require that they specified a file GUID at least, since that's how we're + // naming the file. + // + if (GuidString[0] == 0) { + Error (mGlobals.PrimaryPackagePath, 1, 0, "FFS_FILEGUID must be specified", NULL); + return STATUS_ERROR; + } + // + // Build Header and process image script + // + FileBuffer = (UINT8 *) malloc ((1024 * 1024 * 16) * sizeof (UINT8)); + if (FileBuffer == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL); + goto Done; + } + + FileSize = 0; + if (ImageScriptInOveride) { +#ifdef OVERRIDE_SUPPORTED + rewind (OverridePackage); + LineNumber = 0; + FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber); + while (_strcmpi (InputString, "IMAGE_SCRIPT") != 0) { + GetNextLine (InputString, OverridePackage, &LineNumber); + CheckSlash (InputString, OverridePackage, &LineNumber); + if (strchr (InputString, '=') != NULL) { + BreakString (InputString, InputString, 0); + } + } + + while (InputString[0] != '{') { + GetNextLine (InputString, OverridePackage, &LineNumber); + CheckSlash (InputString, OverridePackage, &LineNumber); + } + // + // Found start of image script, process it + // + FileSize += ProcessScript (FileBuffer, OverridePackage, mGlobals.BuildDirectory, ForceUncompress); + if (FileSize == -1) { + Error (NULL, 0, 0, "failed to process script", NULL); + goto Done; + } + + if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) { + FileSize = AdjustFileSize (FileBuffer, FileSize); + } + + if (BaseName[0] == '\"') { + StripQuotes (BaseName); + } + + if (BaseName[0] != 0) { + sprintf (InputString, "%s-%s", GuidString, BaseName); + } else { + strcpy (InputString, GuidString); + } + + switch (StringToType (FileType)) { + + case EFI_FV_FILETYPE_SECURITY_CORE: + strcat (InputString, ".SEC"); + break; + + case EFI_FV_FILETYPE_PEIM: + case EFI_FV_FILETYPE_PEI_CORE: + case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER: + strcat (InputString, ".PEI"); + break; + + case EFI_FV_FILETYPE_DRIVER: + case EFI_FV_FILETYPE_DXE_CORE: + strcat (InputString, ".DXE"); + break; + + case EFI_FV_FILETYPE_APPLICATION: + strcat (InputString, ".APP"); + break; + + case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE: + strcat (InputString, ".FVI"); + break; + + case EFI_FV_FILETYPE_RAW: + strcat (InputString, ".RAW"); + break; + + case EFI_FV_FILETYPE_ALL: + Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL); + goto Done; + + default: + strcat (InputString, ".FFS"); + break; + } + + if (ForceUncompress) { + strcat (InputString, ".ORG"); + } + + Out = fopen (InputString, "wb"); + if (Out == NULL) { + Error (NULL, 0, 0, InputString, "could not open output file for writing"); + goto Done; + } + // + // create ffs header + // + memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER)); + memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID)); + FileHeader.Type = StringToType (FileType); + FileHeader.Attributes = FfsAttrib; + // + // Now FileSize includes the EFI_FFS_FILE_HEADER + // + FileSize += sizeof (EFI_FFS_FILE_HEADER); + FileHeader.Size[0] = (UINT8) (FileSize & 0xFF); + FileHeader.Size[1] = (UINT8) ((FileSize & 0xFF00) >> 8); + FileHeader.Size[2] = (UINT8) ((FileSize & 0xFF0000) >> 16); + // + // Fill in checksums and state, these must be zero for checksumming + // + // FileHeader.IntegrityCheck.Checksum.Header = 0; + // FileHeader.IntegrityCheck.Checksum.File = 0; + // FileHeader.State = 0; + // + FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 ( + (UINT8 *) &FileHeader, + sizeof (EFI_FFS_FILE_HEADER) + ); + if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) { + FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize); + } else { + FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM; + } + + FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID; + // + // write header + // + if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) { + Error (NULL, 0, 0, "failed to write file header to output file", NULL); + goto Done; + } + // + // write data + // + if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) { + Error (NULL, 0, 0, "failed to write all bytes to output file", NULL); + goto Done; + } + + fclose (Out); + Out = NULL; +#endif // #ifdef OVERRIDE_SUPPORTED + } else { + // + // Open primary package file and process the IMAGE_SCRIPT section + // + PrimaryPackage = fopen (mGlobals.PrimaryPackagePath, "r"); + if (PrimaryPackage == NULL) { + Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file"); + goto Done; + } + + LineNumber = 1; + FindSectionInPackage (".", PrimaryPackage, &LineNumber); + while (_strcmpi (InputString, "IMAGE_SCRIPT") != 0) { + GetNextLine (InputString, PrimaryPackage, &LineNumber); + CheckSlash (InputString, PrimaryPackage, &LineNumber); + if (strchr (InputString, '=') != NULL) { + BreakString (InputString, InputString, 0); + } + } + + while (InputString[0] != '{') { + GetNextLine (InputString, PrimaryPackage, &LineNumber); + CheckSlash (InputString, PrimaryPackage, &LineNumber); + } + // + // Found start of image script, process it + // + FileSize += ProcessScript (FileBuffer, PrimaryPackage, mGlobals.BuildDirectory, ForceUncompress); + if (FileSize == -1) { + Error (NULL, 0, 0, "failed to process script", NULL); + goto Done; + } + + if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) { + FileSize = AdjustFileSize (FileBuffer, FileSize); + } + + if (BaseName[0] == '\"') { + StripQuotes (BaseName); + } + + if (BaseName[0] != 0) { + sprintf (InputString, "%s-%s", GuidString, BaseName); + } else { + strcpy (InputString, GuidString); + } + + switch (StringToType (FileType)) { + + case EFI_FV_FILETYPE_SECURITY_CORE: + strcat (InputString, ".SEC"); + break; + + case EFI_FV_FILETYPE_PEIM: + case EFI_FV_FILETYPE_PEI_CORE: + case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER: + strcat (InputString, ".PEI"); + break; + + case EFI_FV_FILETYPE_DRIVER: + case EFI_FV_FILETYPE_DXE_CORE: + strcat (InputString, ".DXE"); + break; + + case EFI_FV_FILETYPE_APPLICATION: + strcat (InputString, ".APP"); + break; + + case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE: + strcat (InputString, ".FVI"); + break; + + case EFI_FV_FILETYPE_RAW: + strcat (InputString, ".RAW"); + break; + + case EFI_FV_FILETYPE_ALL: + Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL); + goto Done; + + default: + strcat (InputString, ".FFS"); + break; + } + + if (ForceUncompress) { + strcat (InputString, ".ORG"); + } + + Out = fopen (InputString, "wb"); + if (Out == NULL) { + Error (NULL, 0, 0, InputString, "failed to open output file for writing"); + goto Done; + } + // + // Initialize the FFS file header + // + memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER)); + memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID)); + FileHeader.Type = StringToType (FileType); + FileHeader.Attributes = FfsAttrib; + // + // From this point on FileSize includes the size of the EFI_FFS_FILE_HEADER + // + FileSize += sizeof (EFI_FFS_FILE_HEADER); + // + // If using a tail, then it adds two bytes + // + if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) { + // + // Tail is not allowed for pad and 0-length files + // + if ((FileHeader.Type == EFI_FV_FILETYPE_FFS_PAD) || (FileSize == sizeof (EFI_FFS_FILE_HEADER))) { + Error ( + mGlobals.PrimaryPackagePath, + 1, + 0, + "FFS_ATTRIB_TAIL_PRESENT=TRUE is invalid for PAD or 0-length files", + NULL + ); + goto Done; + } + + FileSize += sizeof (EFI_FFS_FILE_TAIL); + } + + FileHeader.Size[0] = (UINT8) (FileSize & 0xFF); + FileHeader.Size[1] = (UINT8) ((FileSize & 0xFF00) >> 8); + FileHeader.Size[2] = (UINT8) ((FileSize & 0xFF0000) >> 16); + // + // Fill in checksums and state, they must be 0 for checksumming. + // + // FileHeader.IntegrityCheck.Checksum.Header = 0; + // FileHeader.IntegrityCheck.Checksum.File = 0; + // FileHeader.State = 0; + // + FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 ( + (UINT8 *) &FileHeader, + sizeof (EFI_FFS_FILE_HEADER) + ); + if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) { + // + // Cheating here. Since the header checksums, just calculate the checksum of the body. + // Checksum does not include the tail + // + if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) { + FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ( + FileBuffer, + FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL) + ); + } else { + FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ( + FileBuffer, + FileSize - sizeof (EFI_FFS_FILE_HEADER) + ); + } + } else { + FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM; + } + // + // Set the state now. Spec says the checksum assumes the state is 0 + // + FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID; + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + + // + // If there is a tail, then set it + // + if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) { + TailValue = FileHeader.IntegrityCheck.TailReference; + TailValue = (UINT16) (~TailValue); + memcpy ( + (UINT8 *) FileBuffer + FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL), + &TailValue, + sizeof (TailValue) + ); + } +#endif + // + // Write the FFS file header + // + if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) { + Error (NULL, 0, 0, "failed to write file header contents", NULL); + goto Done; + } + // + // Write data + // + if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) { + Error (NULL, 0, 0, "failed to write file contents", NULL); + goto Done; + } + } + +Done: + SFPCloseFile (); + if (Out != NULL) { + fclose (Out); + } + + if (PrimaryPackage != NULL) { + fclose (PrimaryPackage); + } + + if (FileBuffer != NULL) { + free (FileBuffer); + } + + if (OverridePackage != NULL) { + fclose (OverridePackage); + } + + return GetUtilityStatus (); +} + +int +main ( + INT32 argc, + CHAR8 *argv[] + ) +/*++ + +Routine Description: + + Main function. + +Arguments: + + argc - Number of command line parameters. + argv - Array of pointers to parameter strings. + +Returns: + STATUS_SUCCESS - Utility exits successfully. + STATUS_ERROR - Some error occurred during execution. + +--*/ +{ + STATUS Status; + // + // Set the name of our utility for error reporting purposes. + // + SetUtilityName (UTILITY_NAME); + Status = ProcessCommandLineArgs (argc, argv); + if (Status != STATUS_SUCCESS) { + return Status; + } + + Status = MainEntry (argc, argv, TRUE); + if (Status == STATUS_SUCCESS) { + MainEntry (argc, argv, FALSE); + } + // + // If any errors were reported via the standard error reporting + // routines, then the status has been saved. Get the value and + // return it to the caller. + // + return GetUtilityStatus (); +} + +static +STATUS +ProcessCommandLineArgs ( + int Argc, + char *Argv[] + ) +/*++ + +Routine Description: + Process the command line arguments. + +Arguments: + Argc - as passed in to main() + Argv - as passed in to main() + +Returns: + STATUS_SUCCESS - arguments all ok + STATUS_ERROR - problem with args, so caller should exit + +--*/ +{ + // + // If no args, then print usage instructions and return an error + // + if (Argc == 1) { + PrintUsage (); + return STATUS_ERROR; + } + + memset (&mGlobals, 0, sizeof (mGlobals)); + Argc--; + Argv++; + while (Argc > 0) { + if (_strcmpi (Argv[0], "-b") == 0) { + // + // OPTION: -b BuildDirectory + // Make sure there is another argument, then save it to our globals. + // + if (Argc < 2) { + Error (NULL, 0, 0, "-b option requires the build directory name", NULL); + return STATUS_ERROR; + } + + if (mGlobals.BuildDirectory[0]) { + Error (NULL, 0, 0, Argv[0], "option can only be specified once"); + return STATUS_ERROR; + } + + strcpy (mGlobals.BuildDirectory, Argv[1]); + Argc--; + Argv++; + } else if (_strcmpi (Argv[0], "-p1") == 0) { + // + // OPTION: -p1 PrimaryPackageFile + // Make sure there is another argument, then save it to our globals. + // + if (Argc < 2) { + Error (NULL, 0, 0, Argv[0], "option requires the primary package file name"); + return STATUS_ERROR; + } + + if (mGlobals.PrimaryPackagePath[0]) { + Error (NULL, 0, 0, Argv[0], "option can only be specified once"); + return STATUS_ERROR; + } + + strcpy (mGlobals.PrimaryPackagePath, Argv[1]); + Argc--; + Argv++; + } else if (_strcmpi (Argv[0], "-p2") == 0) { + // + // OPTION: -p2 OverridePackageFile + // Make sure there is another argument, then save it to our globals. + // + if (Argc < 2) { + Error (NULL, 0, 0, Argv[0], "option requires the override package file name"); + return STATUS_ERROR; + } + + if (mGlobals.OverridePackagePath[0]) { + Error (NULL, 0, 0, Argv[0], "option can only be specified once"); + return STATUS_ERROR; + } + + strcpy (mGlobals.OverridePackagePath, Argv[1]); + Argc--; + Argv++; + } else if (_strcmpi (Argv[0], "-v") == 0) { + // + // OPTION: -v verbose + // + mGlobals.Verbose = TRUE; + } else if (_strcmpi (Argv[0], "-h") == 0) { + // + // OPTION: -h help + // + PrintUsage (); + return STATUS_ERROR; + } else if (_strcmpi (Argv[0], "-?") == 0) { + // + // OPTION: -? help + // + PrintUsage (); + return STATUS_ERROR; + } else { + Error (NULL, 0, 0, Argv[0], "unrecognized option"); + PrintUsage (); + return STATUS_ERROR; + } + + Argv++; + Argc--; + } + // + // Must have at least specified the package file name + // + if (mGlobals.PrimaryPackagePath[0] == 0) { + Error (NULL, 0, 0, "must specify primary package file", NULL); + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.h new file mode 100644 index 0000000000..d3bcdbb90c --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.h @@ -0,0 +1,35 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenFfsFile.h + +Abstract: + + Header file for GenFfsFile. + +--*/ + +// +// Module Coded to Tiano Coding Conventions +// +#ifndef _EFI_GEN_FFSFILE_H +#define _EFI_GEN_FFSFILE_H + +// +// External Files Referenced +// +#include "TianoCommon.h" +#include "EfiImageFormat.h" +#include "MyAlloc.h" + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/makefile new file mode 100644 index 0000000000..85f9cfde9a --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/makefile @@ -0,0 +1,88 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# makefile +# +# Abstract: +# +# This file is used to build the EFI GenFfsFile utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Common information +# + +INC=$(INC) + +LIBS = $(LIBS) $(EDK_TOOLS_OUTPUT)\CustomizedCompress.lib + +# +# Target specific information +# + +TARGET_NAME = GenFfsFile +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenFfsFile.c" +TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \ + "$(EDK_TOOLS_COMMON)\ParseInf.h" \ + "$(EDK_TOOLS_COMMON)\MyAlloc.h" + +TARGET_EXE_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" +C_FLAGS = $(C_FLAGS) -W4 +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(LIBS) $(TARGET_EXE_LIBS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj \ + $(TARGET_LIB) $(TARGET_EXE_LIBS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c new file mode 100644 index 0000000000..ccd1199435 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c @@ -0,0 +1,299 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenFvImageExe.c + +Abstract: + + This contains all code necessary to build the GenFvImage.exe utility. + This utility relies heavily on the GenFvImage Lib. Definitions for both + can be found in the Tiano Firmware Volume Generation Utility + Specification, review draft. + +--*/ + +// +// File included in build +// +#include "GenFvImageExe.h" +#include "CommonLib.h" +#include "EfiUtilityMsgs.h" + +VOID +PrintUtilityInfo ( + VOID + ) +/*++ + +Routine Description: + + Displays the standard utility information to SDTOUT + +Arguments: + + None + +Returns: + + None + +--*/ +{ + printf ( + "%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n", + UTILITY_NAME, + UTILITY_MAJOR_VERSION, + UTILITY_MINOR_VERSION + ); +} + +VOID +PrintUsage ( + VOID + ) +/*++ + +Routine Description: + + Displays the utility usage syntax to STDOUT + +Arguments: + + None + +Returns: + + None + +--*/ +{ + printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME); + printf (" Where:\n"); + printf ("\tFvInfFileName is the name of the image description file.\n\n"); +} + +EFI_STATUS +main ( + IN INTN argc, + IN CHAR8 **argv + ) +/*++ + +Routine Description: + + This utility uses GenFvImage.Lib to build a firmware volume image. + +Arguments: + + FvInfFileName The name of an FV image description file. + + Arguments come in pair in any order. + -I FvInfFileName + +Returns: + + EFI_SUCCESS No error conditions detected. + EFI_INVALID_PARAMETER One or more of the input parameters is invalid. + EFI_OUT_OF_RESOURCES A resource required by the utility was unavailable. + Most commonly this will be memory allocation + or file creation. + EFI_LOAD_ERROR GenFvImage.lib could not be loaded. + EFI_ABORTED Error executing the GenFvImage lib. + +--*/ +{ + EFI_STATUS Status; + CHAR8 InfFileName[_MAX_PATH]; + CHAR8 *InfFileImage; + UINTN InfFileSize; + UINT8 *FvImage; + UINTN FvImageSize; + UINT8 Index; + CHAR8 FvFileNameBuffer[_MAX_PATH]; + CHAR8 *FvFileName; + FILE *FvFile; + FILE *SymFile; + CHAR8 SymFileNameBuffer[_MAX_PATH]; + CHAR8 *SymFileName; + UINT8 *SymImage; + UINTN SymImageSize; + CHAR8 *CurrentSymString; + + FvFileName = FvFileNameBuffer; + SymFileName = SymFileNameBuffer; + + SetUtilityName (UTILITY_NAME); + // + // Display utility information + // + PrintUtilityInfo (); + + // + // Verify the correct number of arguments + // + if (argc != MAX_ARGS) { + Error (NULL, 0, 0, "invalid number of input parameters specified", NULL); + PrintUsage (); + return GetUtilityStatus (); + } + // + // Initialize variables + // + strcpy (InfFileName, ""); + + // + // Parse the command line arguments + // + for (Index = 1; Index < MAX_ARGS; Index += 2) { + // + // Make sure argument pair begin with - or / + // + if (argv[Index][0] != '-' && argv[Index][0] != '/') { + Error (NULL, 0, 0, argv[Index], "argument pair must begin with \"-\" or \"/\""); + PrintUsage (); + return GetUtilityStatus (); + } + // + // Make sure argument specifier is only one letter + // + if (argv[Index][2] != 0) { + Error (NULL, 0, 0, argv[Index], "unrecognized argument"); + PrintUsage (); + return GetUtilityStatus (); + } + // + // Determine argument to read + // + switch (argv[Index][1]) { + + case 'I': + case 'i': + if (strlen (InfFileName) == 0) { + strcpy (InfFileName, argv[Index + 1]); + } else { + Error (NULL, 0, 0, argv[Index + 1], "FvInfFileName may only be specified once"); + PrintUsage (); + return GetUtilityStatus (); + } + break; + + default: + Error (NULL, 0, 0, argv[Index], "unrecognized argument"); + PrintUsage (); + return GetUtilityStatus (); + break; + } + } + // + // Read the INF file image + // + Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize); + if (EFI_ERROR (Status)) { + return STATUS_ERROR; + } + // + // Call the GenFvImage lib + // + Status = GenerateFvImage ( + InfFileImage, + InfFileSize, + &FvImage, + &FvImageSize, + &FvFileName, + &SymImage, + &SymImageSize, + &SymFileName + ); + + if (EFI_ERROR (Status)) { + switch (Status) { + + case EFI_INVALID_PARAMETER: + Error (NULL, 0, 0, "invalid parameter passed to GenFvImage Lib", NULL); + return GetUtilityStatus (); + break; + + case EFI_ABORTED: + Error (NULL, 0, 0, "error detected while creating the file image", NULL); + return GetUtilityStatus (); + break; + + case EFI_OUT_OF_RESOURCES: + Error (NULL, 0, 0, "GenFvImage Lib could not allocate required resources", NULL); + return GetUtilityStatus (); + break; + + case EFI_VOLUME_CORRUPTED: + Error (NULL, 0, 0, "no base address was specified, but the FV.INF included a PEI or BSF file", NULL); + return GetUtilityStatus (); + break; + + case EFI_LOAD_ERROR: + Error (NULL, 0, 0, "could not load FV image generation library", NULL); + return GetUtilityStatus (); + break; + + default: + Error (NULL, 0, 0, "GenFvImage Lib returned unknown status", "status returned = 0x%X", Status); + return GetUtilityStatus (); + break; + } + } + // + // Write file + // + FvFile = fopen (FvFileName, "wb"); + if (FvFile == NULL) { + Error (NULL, 0, 0, FvFileName, "could not open output file"); + free (FvImage); + free (SymImage); + return GetUtilityStatus (); + } + + if (fwrite (FvImage, 1, FvImageSize, FvFile) != FvImageSize) { + Error (NULL, 0, 0, FvFileName, "failed to write to output file"); + free (FvImage); + free (SymImage); + fclose (FvFile); + return GetUtilityStatus (); + } + + fclose (FvFile); + free (FvImage); + + // + // Write symbol file + // + if (strcmp (SymFileName, "")) { + SymFile = fopen (SymFileName, "wt"); + if (SymFile == NULL) { + Error (NULL, 0, 0, SymFileName, "could not open output symbol file"); + free (SymImage); + return GetUtilityStatus (); + } + + fprintf (SymFile, "TEXTSYM format | V1.0\n"); + + CurrentSymString = SymImage; + while (((UINTN) CurrentSymString - (UINTN) SymImage) < SymImageSize) { + fprintf (SymFile, "%s", CurrentSymString); + CurrentSymString = (CHAR8 *) (((UINTN) CurrentSymString) + strlen (CurrentSymString) + 1); + } + + fclose (SymFile); + } + + free (SymImage); + + return GetUtilityStatus (); +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h new file mode 100644 index 0000000000..9b97935656 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h @@ -0,0 +1,98 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenFvImageExe.h + +Abstract: + + Definitions for the PeimFixup exe utility. + +--*/ + +// +// Coded to Tiano Coding Standards +// +#ifndef _EFI_GEN_FV_IMAGE_EXE_H +#define _EFI_GEN_FV_IMAGE_EXE_H + +#include +#include +#include +#include "GenFvImageLib.h" + +// +// Utility Name +// +#define UTILITY_NAME "GenFvImage" + +// +// Utility version information +// +#define UTILITY_MAJOR_VERSION 0 +#define UTILITY_MINOR_VERSION 1 +#define UTILITY_DATE __DATE__ + +// +// The maximum number of arguments accepted from the command line. +// +#define MAX_ARGS 3 + +// +// The function that displays general utility information +// +VOID +PrintUtilityInfo ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +// +// The function that displays the utility usage message. +// +VOID +PrintUsage ( + VOID + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + None + +Returns: + + TODO: add return values + +--*/ +; + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c new file mode 100644 index 0000000000..3c591841ed --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c @@ -0,0 +1,3054 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenFvImageLib.c + +Abstract: + + This file contains functions required to generate a Firmware Volume. + +--*/ + +// +// Include files +// +#include "GenFvImageLib.h" +#include "GenFvImageLibInternal.h" +#include +#include EFI_GUID_DEFINITION (PeiPeCoffLoader) +#include "EfiFirmwareFileSystem.h" +#include "EfiWorkingBlockHeader.h" +#include "EfiVariable.h" +#include +#include +#include "CommonLib.h" +#include "FvLib.h" +#include "EfiImage.h" +#include "crc32.h" +#include "EfiUtilityMsgs.h" +#include EFI_GUID_DEFINITION (FirmwareFileSystem) +#include EFI_GUID_DEFINITION (FirmwareFileSystem2) + +// +// Define the PE/COFF loader +// +extern EFI_PEI_PE_COFF_LOADER_PROTOCOL mPeCoffLoader; + +// +// Local function prototypes +// +EFI_STATUS +GetPe32Info ( + IN UINT8 *Pe32, + OUT UINT32 *EntryPoint, + OUT UINT32 *BaseOfCode, + OUT UINT16 *MachineType + ); + +// +// Local function implementations. +// +#if (PI_SPECIFICATION_VERSION < 0x00010000) +EFI_GUID FfsGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID; +#else +EFI_GUID FfsGuid = EFI_FIRMWARE_FILE_SYSTEM2_GUID; +#endif + +EFI_GUID DefaultFvPadFileNameGuid = { 0x78f54d4, 0xcc22, 0x4048, 0x9e, 0x94, 0x87, 0x9c, 0x21, 0x4d, 0x56, 0x2f }; + +// +// This data array will be located at the base of the Firmware Volume Header (FVH) +// in the boot block. It must not exceed 14 bytes of code. The last 2 bytes +// will be used to keep the FVH checksum consistent. +// This code will be run in response to a starutp IPI for HT-enabled systems. +// +#define SIZEOF_STARTUP_DATA_ARRAY 0x10 + +UINT8 m128kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = { + // + // EA D0 FF 00 F0 ; far jmp F000:FFD0 + // 0, 0, 0, 0, 0, 0, 0, 0, 0, ; Reserved bytes + // 0, 0 ; Checksum Padding + // + 0xEA, + 0xD0, + 0xFF, + 0x0, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00 +}; + +UINT8 m64kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = { + // + // EB CE ; jmp short ($-0x30) + // ; (from offset 0x0 to offset 0xFFD0) + // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ; Reserved bytes + // 0, 0 ; Checksum Padding + // + 0xEB, + 0xCE, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00 +}; + +EFI_STATUS +ParseFvInf ( + IN MEMORY_FILE *InfFile, + IN FV_INFO *FvInfo + ) +/*++ + +Routine Description: + + This function parses a FV.INF file and copies info into a FV_INFO structure. + +Arguments: + + InfFile Memory file image. + FvInfo Information read from INF file. + +Returns: + + EFI_SUCCESS INF file information successfully retrieved. + EFI_ABORTED INF file has an invalid format. + EFI_NOT_FOUND A required string was not found in the INF file. +--*/ +{ + CHAR8 Value[_MAX_PATH]; + UINT64 Value64; + UINTN Index; + EFI_STATUS Status; + + // + // Initialize FV info + // + memset (FvInfo, 0, sizeof (FV_INFO)); + + // + // Read the FV base address + // + Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_BASE_ADDRESS_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Get the base address + // + Status = AsciiStringToUint64 (Value, FALSE, &Value64); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "invalid value"); + return EFI_ABORTED; + } + + FvInfo->BaseAddress = Value64; + } else { + Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "could not find value"); + return EFI_ABORTED; + } + // + // Read the FV Guid + // + Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_GUID_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Get the guid value + // + Status = StringToGuid (Value, &FvInfo->FvGuid); + if (EFI_ERROR (Status)) { + memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID)); + } + } else { + memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID)); + } + // + // Read the FV file name + // + Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_FILE_NAME_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // copy the file name + // + strcpy (FvInfo->FvName, Value); + } else { + Error (NULL, 0, 0, EFI_FV_FILE_NAME_STRING, "value not specified"); + return EFI_ABORTED; + } + // + // Read the Sym file name + // + Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_SYM_FILE_NAME_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // copy the file name + // + strcpy (FvInfo->SymName, Value); + } else { + // + // Symbols not required, so init to NULL. + // + strcpy (FvInfo->SymName, ""); + } + // + // Read the read disabled capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_DISABLED_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the read disabled flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_READ_DISABLED_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "value not specified"); + return Status; + } + // + // Read the read enabled capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_ENABLED_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the read disabled flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_READ_ENABLED_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "value not specified"); + return Status; + } + // + // Read the read status attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_STATUS_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the read disabled flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_READ_STATUS; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "value not specified"); + return Status; + } + // + // Read the write disabled capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_DISABLED_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the write disabled flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_WRITE_DISABLED_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "value not specified"); + return Status; + } + // + // Read the write enabled capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_ENABLED_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the write disabled flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_WRITE_ENABLED_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "value not specified"); + return Status; + } + // + // Read the write status attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_STATUS_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the write disabled flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_WRITE_STATUS; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "value not specified"); + return Status; + } + // + // Read the lock capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the attribute flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_LOCK_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "value not specified"); + return Status; + } + // + // Read the lock status attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_STATUS_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the attribute flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_LOCK_STATUS; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "value not specified"); + return Status; + } + // + // Read the sticky write attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_STICKY_WRITE_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the attribute flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_STICKY_WRITE; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "value not specified"); + return Status; + } + // + // Read the memory mapped attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_MEMORY_MAPPED_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the attribute flag + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_MEMORY_MAPPED; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "value not specified"); + return Status; + } + // + // Read the erase polarity attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ERASE_POLARITY_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the attribute flag + // + if (strcmp (Value, ONE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ERASE_POLARITY; + } else if (strcmp (Value, ZERO_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "value not specified"); + return Status; + } + +#if (PI_SPECIFICATION_VERSION >= 0x00010000) + // + // Read the read lock capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_LOCK_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_READ_LOCK_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_READ_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_READ_LOCK_CAP_STRING, "value not specified"); + return Status; + } + + // + // Read the read lock status attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_LOCK_STATUS_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_READ_LOCK_STATUS; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_READ_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_READ_LOCK_STATUS_STRING, "value not specified"); + return Status; + } + + // + // Read the write lock capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_LOCK_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_WRITE_LOCK_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_CAP_STRING, "value not specified"); + return Status; + } + + // + // Read the write lock status attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_LOCK_STATUS_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_WRITE_LOCK_STATUS; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_WRITE_LOCK_STATUS_STRING, "value not specified"); + return Status; + } +#endif + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + // + // Read the alignment capabilities attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_CAP_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_CAP; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "value not specified"); + return Status; + } + + // + // Read the word alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "value not specified"); + return Status; + } + + + // + // Read the dword alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "value not specified"); + return Status; + } + // + // Read the word alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "value not specified"); + return Status; + } + // + // Read the qword alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "value not specified"); + return Status; + } + // + // Read the 32 byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "value not specified"); + return Status; + } + // + // Read the 64 byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "value not specified"); + return Status; + } + // + // Read the 128 byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_128_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_128; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "value not specified"); + return Status; + } + // + // Read the 256 byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_256_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_256; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "value not specified"); + return Status; + } + // + // Read the 512 byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_512_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_512; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "value not specified"); + return Status; + } + // + // Read the 1K byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_1K_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_1K; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "value not specified"); + return Status; + } + // + // Read the 2K byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2K_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2K; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "value not specified"); + return Status; + } + // + // Read the 4K byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4K_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4K; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "value not specified"); + return Status; + } + // + // Read the 8K byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8K_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8K; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "value not specified"); + return Status; + } + // + // Read the 16K byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16K_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16K; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "value not specified"); + return Status; + } + // + // Read the 32K byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32K_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32K; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "value not specified"); + return Status; + } + // + // Read the 64K byte alignment capability attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64K_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, TRUE_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64K; + } else if (strcmp (Value, FALSE_STRING) != 0) { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "value not specified"); + return Status; + } + + if (!(FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_CAP) && + ( + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_128) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_256) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_512) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_1K) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2K) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4K) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8K) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16K) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32K) || + (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64K) + ) + ){ + Error ( + NULL, + 0, + 0, + "illegal combination of alignment attributes", + "if %s is not %s, no individual alignments can be %s", + EFI_FVB_ALIGNMENT_CAP_STRING, + TRUE_STRING, + TRUE_STRING + ); + return EFI_ABORTED; + } +#else + // + // Read the PI1.0 FVB2 Alignment Capabilities Attribute + // + Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB2_ALIGNMENT_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Update attribute + // + if (strcmp (Value, EFI_FVB2_ALIGNMENT_1_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_4_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_4; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_8_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_8; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_16_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_16; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_32_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_32; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_64_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_64; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_128_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_128; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_256_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_256; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_512_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_512; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_1K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_4K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_4K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_8K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_8K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_16K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_16K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_32K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_32K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_64K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_64K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_128K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_128K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_256K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_256K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_512K_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMNET_512K; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_1M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_4M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_4M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_8M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_8M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_16M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_16M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_32M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_32M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_64M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_64M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_128M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_128M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_256M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_256M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_512M_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_512M; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_1G_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_1G; + } else if (strcmp (Value, EFI_FVB2_ALIGNMENT_2G_STRING) == 0) { + FvInfo->FvAttributes |= EFI_FVB2_ALIGNMENT_2G; + } else { + Error (NULL, 0, 0, EFI_FVB2_ALIGNMENT_STRING, "value not correct!"); + return EFI_ABORTED; + } + } else { + Error (NULL, 0, 0, EFI_FVB2_ALIGNMENT_STRING, "value not specified"); + return Status; + } + +#endif + // + // Read block maps + // + for (Index = 0; Index < MAX_NUMBER_OF_FV_BLOCKS; Index++) { + // + // Read the number of blocks + // + Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the number of blocks + // + Status = AsciiStringToUint64 (Value, FALSE, &Value64); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING); + return EFI_ABORTED; + } + + FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64; + } else { + // + // If there is no number of blocks, but there is a size, then we have a mismatched pair + // and should return an error. + // + Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value); + if (!EFI_ERROR (Status)) { + Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING); + return EFI_ABORTED; + } else { + // + // We are done + // + break; + } + } + // + // Read the size of blocks + // + Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value); + + if (Status == EFI_SUCCESS) { + // + // Update the number of blocks + // + Status = AsciiStringToUint64 (Value, FALSE, &Value64); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, Value, "invalid value specified for %s", EFI_BLOCK_SIZE_STRING); + return EFI_ABORTED; + } + + FvInfo->FvBlocks[Index].BlockLength = (UINT32) Value64; + } else { + // + // There is a number of blocks, but there is no size, so we have a mismatched pair + // and should return an error. + // + Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING); + return EFI_ABORTED; + } + } + // + // Read files + // + for (Index = 0; Index < MAX_NUMBER_OF_FILES_IN_FV; Index++) { + // + // Read the number of blocks + // + Status = FindToken (InfFile, FILES_SECTION_STRING, EFI_FILE_NAME_STRING, Index, Value); + + if (Status == EFI_SUCCESS) { + // + // Add the file + // + strcpy (FvInfo->FvFiles[Index], Value); + } else { + break; + } + } + + if (FindSection (InfFile, COMPONENT_SECTION_STRING)) { + Index = 0; + // + // Read component FV_VARIABLE + // + Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Add the component + // + strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING); + Status = AsciiStringToUint64 (Value, FALSE, &Value64); + if (EFI_ERROR (Status)) { + printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING); + return EFI_ABORTED; + } + + FvInfo->FvComponents[Index].Size = (UINTN) Value64; + } else { + printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING); + } + + Index++; + // + // Read component FV_EVENT_LOG + // + Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Add the component + // + strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING); + Status = AsciiStringToUint64 (Value, FALSE, &Value64); + if (EFI_ERROR (Status)) { + printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING); + return EFI_ABORTED; + } + + FvInfo->FvComponents[Index].Size = (UINTN) Value64; + } else { + printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING); + } + + Index++; + // + // Read component FV_FTW_WORKING + // + Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Add the component + // + strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING); + Status = AsciiStringToUint64 (Value, FALSE, &Value64); + if (EFI_ERROR (Status)) { + printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING); + return EFI_ABORTED; + } + + FvInfo->FvComponents[Index].Size = (UINTN) Value64; + } else { + printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING); + } + + Index++; + // + // Read component FV_FTW_SPARE + // + Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value); + + if (Status == EFI_SUCCESS) { + // + // Add the component + // + strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING); + Status = AsciiStringToUint64 (Value, FALSE, &Value64); + if (EFI_ERROR (Status)) { + printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING); + return EFI_ABORTED; + } + + FvInfo->FvComponents[Index].Size = (UINTN) Value64; + } else { + printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING); + } + } + // + // Compute size for easy access later + // + FvInfo->Size = 0; + for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) { + FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength; + } + + return EFI_SUCCESS; +} + +VOID +UpdateFfsFileState ( + IN EFI_FFS_FILE_HEADER *FfsFile, + IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader + ) +/*++ + +Routine Description: + + This function changes the FFS file attributes based on the erase polarity + of the FV. + +Arguments: + + FfsFile File header. + FvHeader FV header. + +Returns: + + None + +--*/ +{ + if (FvHeader->Attributes & EFI_FVB_ERASE_POLARITY) { + FfsFile->State = (UINT8)~(FfsFile->State); + } +} + +EFI_STATUS +ReadFfsAlignment ( + IN EFI_FFS_FILE_HEADER *FfsFile, + IN OUT UINT32 *Alignment + ) +/*++ + +Routine Description: + + This function determines the alignment of the FFS input file from the file + attributes. + +Arguments: + + FfsFile FFS file to parse + Alignment The minimum required alignment of the FFS file, in bytes + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + EFI_ABORTED An error occurred. + +--*/ +{ + // + // Verify input parameters. + // + if (FfsFile == NULL || Alignment == NULL) { + return EFI_INVALID_PARAMETER; + } + + switch ((FfsFile->Attributes >> 3) & 0x07) { + + case 0: + // + // 1 byte alignment + // + *Alignment = (1 << 0); + break; + + case 1: + // + // 16 byte alignment + // + *Alignment = (1 << 4); + break; + + case 2: + // + // 128 byte alignment + // + *Alignment = (1 << 7); + break; + + case 3: + // + // 512 byte alignment + // + *Alignment = (1 << 9); + break; + + case 4: + // + // 1K byte alignment + // + *Alignment = (1 << 10); + break; + + case 5: + // + // 4K byte alignment + // + *Alignment = (1 << 12); + break; + + case 6: + // + // 32K byte alignment + // + *Alignment = (1 << 15); + break; + + case 7: + // + // 64K byte alignment + // + *Alignment = (1 << 16); + break; + + default: + Error (NULL, 0, 0, "nvalid file attribute calculated, this is most likely a utility error", NULL); + return EFI_ABORTED; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +AddPadFile ( + IN OUT MEMORY_FILE *FvImage, + IN UINT32 DataAlignment + ) +/*++ + +Routine Description: + + This function adds a pad file to the FV image if it required to align the + data of the next file. + +Arguments: + + FvImage The memory image of the FV to add it to. The current offset + must be valid. + DataAlignment The data alignment of the next FFS file. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + EFI_OUT_OF_RESOURCES Insufficient resources exist in the FV to complete + the pad file add. + +--*/ +{ + EFI_FFS_FILE_HEADER *PadFile; + UUID PadFileGuid; + UINTN PadFileSize; + + // + // Verify input parameters. + // + if (FvImage == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Basic assumption is we start from an 8 byte aligned address + // and our file header is a multiple of 8 bytes + // + assert ((UINTN) FvImage->CurrentFilePointer % 8 == 0); + assert (sizeof (EFI_FFS_FILE_HEADER) % 8 == 0); + + // + // Check if a pad file is necessary + // + if (((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + sizeof (EFI_FFS_FILE_HEADER)) % DataAlignment == 0) { + return EFI_SUCCESS; + } + // + // Write pad file header + // + PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer; + + // + // Verify that we have enough space for the file header + // + if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) { + return EFI_OUT_OF_RESOURCES; + } + + UuidCreate (&PadFileGuid); + memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER)); + memcpy (&PadFile->Name, &PadFileGuid, sizeof (EFI_GUID)); + PadFile->Type = EFI_FV_FILETYPE_FFS_PAD; + PadFile->Attributes = 0; + + // + // Calculate the pad file size + // + // + // This is the earliest possible valid offset (current plus pad file header + // plus the next file header) + // + PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2); + + // + // Add whatever it takes to get to the next aligned address + // + while ((PadFileSize % DataAlignment) != 0) { + PadFileSize++; + } + // + // Subtract the next file header size + // + PadFileSize -= sizeof (EFI_FFS_FILE_HEADER); + + // + // Subtract the starting offset to get size + // + PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage; + + // + // Write pad file size (calculated size minus next file header size) + // + PadFile->Size[0] = (UINT8) (PadFileSize & 0xFF); + PadFile->Size[1] = (UINT8) ((PadFileSize >> 8) & 0xFF); + PadFile->Size[2] = (UINT8) ((PadFileSize >> 16) & 0xFF); + + // + // Fill in checksums and state, they must be 0 for checksumming. + // + PadFile->IntegrityCheck.Checksum.Header = 0; + PadFile->IntegrityCheck.Checksum.File = 0; + PadFile->State = 0; + PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER)); + if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) { + PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize); + } else { + PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM; + } + + PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID; + UpdateFfsFileState ( + (EFI_FFS_FILE_HEADER *) PadFile, + (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage + ); + + // + // Verify that we have enough space (including the padding + // + if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) { + return EFI_OUT_OF_RESOURCES; + } + // + // Update the current FV pointer + // + FvImage->CurrentFilePointer += PadFileSize; + + return EFI_SUCCESS; +} + +BOOLEAN +IsVtfFile ( + IN EFI_FFS_FILE_HEADER *FileBuffer + ) +/*++ + +Routine Description: + + This function checks the header to validate if it is a VTF file + +Arguments: + + FileBuffer Buffer in which content of a file has been read. + +Returns: + + TRUE If this is a VTF file + FALSE If this is not a VTF file + +--*/ +{ + EFI_GUID VtfGuid = EFI_FFS_VOLUME_TOP_FILE_GUID; + if (!memcmp (&FileBuffer->Name, &VtfGuid, sizeof (EFI_GUID))) { + return TRUE; + } else { + return FALSE; + } +} + +EFI_STATUS +FfsRebaseImageRead ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINT32 *ReadSize, + OUT VOID *Buffer + ) +/*++ + +Routine Description: + + Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file + +Arguments: + + FileHandle - The handle to the PE/COFF file + + FileOffset - The offset, in bytes, into the file to read + + ReadSize - The number of bytes to read from the file starting at FileOffset + + Buffer - A pointer to the buffer to read the data into. + +Returns: + + EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset + +--*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + UINT32 Length; + + Destination8 = Buffer; + Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset); + Length = *ReadSize; + while (Length--) { + *(Destination8++) = *(Source8++); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +RebaseFfsFile ( + IN OUT EFI_FFS_FILE_HEADER *FfsFile, + IN EFI_PHYSICAL_ADDRESS BaseAddress + ) +/*++ + +Routine Description: + + This function determines if a file is XIP and should be rebased. It will + rebase any PE32 sections found in the file using the base address. + +Arguments: + + FfsFile A pointer to Ffs file image. + BaseAddress The base address to use for rebasing the file image. + +Returns: + + EFI_SUCCESS The image was properly rebased. + EFI_INVALID_PARAMETER An input parameter is invalid. + EFI_ABORTED An error occurred while rebasing the input file image. + EFI_OUT_OF_RESOURCES Could not allocate a required resource. + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + UINTN MemoryImagePointer; + UINTN MemoryImagePointerAligned; + + EFI_PHYSICAL_ADDRESS ImageAddress; + UINT64 ImageSize; + EFI_PHYSICAL_ADDRESS EntryPoint; + + UINT32 Pe32FileSize; + UINT32 NewPe32BaseAddress; + + UINTN Index; + EFI_FILE_SECTION_POINTER CurrentPe32Section; + UINT8 FileGuidString[80]; + + // + // Verify input parameters + // + if (FfsFile == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Convert the GUID to a string so we can at least report which file + // if we find an error. + // + PrintGuidToBuffer (&FfsFile->Name, FileGuidString, sizeof (FileGuidString), TRUE); + + // + // Do some nominal checks on the file, then check for XIP. + // + Status = VerifyFfsFile (FfsFile); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "invalid FFS file", FileGuidString); + return EFI_INVALID_PARAMETER; + } + + if (FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE && + FfsFile->Type != EFI_FV_FILETYPE_PEI_CORE && + FfsFile->Type != EFI_FV_FILETYPE_PEIM + ) { + // + // File is not XIP, so don't rebase + // + return EFI_SUCCESS; + } + // + // Rebase each PE32 section + // + for (Index = 1;; Index++) { + Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, Index, &CurrentPe32Section); + if (EFI_ERROR (Status)) { + break; + } + // + // Calculate the PE32 base address, the FFS file base plus the offset of the PE32 section + // + NewPe32BaseAddress = ((UINT32) BaseAddress) + ((UINTN) CurrentPe32Section.Pe32Section - (UINTN) FfsFile); + + // + // Initialize context + // + memset (&ImageContext, 0, sizeof (ImageContext)); + ImageContext.Handle = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION)); + ImageContext.ImageRead = (EFI_PEI_PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead; + + Status = mPeCoffLoader.GetImageInfo (&mPeCoffLoader, &ImageContext); + + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "GetImageInfo() failed", FileGuidString); + return Status; + } + // + // Allocate a buffer for the image to be loaded into. + // + Pe32FileSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size); + MemoryImagePointer = (UINTN) (malloc (Pe32FileSize + 0x1000)); + MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12); + if (MemoryImagePointerAligned == 0) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return EFI_OUT_OF_RESOURCES; + } + + // + // bugbug + // + ImageContext.ImageAddress = MemoryImagePointerAligned; + Status = mPeCoffLoader.LoadImage (&mPeCoffLoader, &ImageContext); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "LoadImage() failure", FileGuidString); + free ((VOID *) MemoryImagePointer); + return Status; + } + + Status = mPeCoffLoader.RelocateImage (&mPeCoffLoader, &ImageContext); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "RelocateImage() failure", FileGuidString); + free ((VOID *) MemoryImagePointer); + return Status; + } + + ImageAddress = ImageContext.ImageAddress; + ImageSize = ImageContext.ImageSize; + EntryPoint = ImageContext.EntryPoint; + + if (ImageSize > Pe32FileSize) { + Error ( + NULL, + 0, + 0, + "rebased PE32 is larger than original PE32 image", + "0x%X > 0x%X on file %s", + ImageSize, + Pe32FileSize, + FileGuidString + ); + free ((VOID *) MemoryImagePointer); + return EFI_ABORTED; + } + + memcpy (CurrentPe32Section.Pe32Section, (VOID *) MemoryImagePointerAligned, Pe32FileSize); + + free ((VOID *) MemoryImagePointer); + } + // + // the above for loop will always exit with EFI_NOT_FOUND if it completes + // normally. If Index == 1 at exit, then no PE32 sections were found. If it + // exits with any other error code, then something broke... + // + if (Status != EFI_NOT_FOUND) { + Error (NULL, 0, 0, "failed to parse PE32 section", FileGuidString); + return Status; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +AddSymFile ( + IN UINT64 BaseAddress, + IN EFI_FFS_FILE_HEADER *FfsFile, + IN OUT MEMORY_FILE *SymImage, + IN CHAR8 *SourceFileName + ) +/*++ + +Routine Description: + + This function adds the SYM tokens in the source file to the destination file. + The SYM tokens are updated to reflect the base address. + +Arguments: + + BaseAddress The base address for the new SYM tokens. + FfsFile Pointer to the beginning of the FFS file in question. + SymImage The memory file to update with symbol information. + SourceFileName The source file. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + EFI_ABORTED An error occurred. + +--*/ +{ + FILE *SourceFile; + + CHAR8 Buffer[_MAX_PATH]; + CHAR8 Type[_MAX_PATH]; + CHAR8 Address[_MAX_PATH]; + CHAR8 Section[_MAX_PATH]; + CHAR8 Token[_MAX_PATH]; + CHAR8 SymFileName[_MAX_PATH]; + CHAR8 CodeModuleName[_MAX_PATH]; + CHAR8 *Ptr; + + UINT64 TokenAddress; + + EFI_STATUS Status; + EFI_FILE_SECTION_POINTER Pe32Section; + UINT32 EntryPoint; + UINT32 BaseOfCode; + UINT16 MachineType; + + // + // Verify input parameters. + // + if (BaseAddress == 0 || FfsFile == NULL || SymImage == NULL || SourceFileName == NULL) { + Error (NULL, 0, 0, "invalid parameter passed to AddSymFile()", NULL); + return EFI_INVALID_PARAMETER; + } + // + // Check if we want to add this file + // + // + // Get the file name + // + strcpy (Buffer, SourceFileName); + + // + // Copy the file name for the path of the sym file and truncate the name portion. + // + strcpy (SymFileName, Buffer); + Ptr = strrchr (SymFileName, '\\'); + assert (Ptr); + Ptr[0] = 0; + + // + // Find the file extension and make it lower case + // + Ptr = strrchr (SymFileName, '.'); + if (Ptr != NULL) { + _strlwr (Ptr); + } + // + // Check if it is PEI file + // + if (strstr (Buffer, ".pei") != NULL) { + // + // Find the human readable portion + // + if (!strtok (Buffer, "-") || + !strtok (NULL, "-") || + !strtok (NULL, "-") || + !strtok (NULL, "-") || + !strtok (NULL, "-") || + !strcpy (Buffer, strtok (NULL, ".")) + ) { + Error (NULL, 0, 0, "failed to find human readable portion of the file name in AddSymFile()", NULL); + return EFI_ABORTED; + } + // + // Save code module name + // + strcpy (CodeModuleName, Buffer); + + // + // Add the symbol file name and extension to the file path. + // + strcat (Buffer, ".sym"); + strcat (SymFileName, "\\"); + strcat (SymFileName, Buffer); + } else { + // + // Only handle PEIM files. + // + return EFI_SUCCESS; + } + // + // Find PE32 section + // + Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, 1, &Pe32Section); + + // + // BUGBUG: Assume if no PE32 section it is PIC and hardcode base address + // + if (Status == EFI_NOT_FOUND) { + Status = GetSectionByType (FfsFile, EFI_SECTION_TE, 1, &Pe32Section); + } + + if (Status == EFI_SUCCESS) { + Status = GetPe32Info ( + (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)), + &EntryPoint, + &BaseOfCode, + &MachineType + ); + } else { + if (Status == EFI_NOT_FOUND) { + BaseOfCode = 0x60; + Status = EFI_SUCCESS; + } else { + Error (NULL, 0, 0, "could not parse a PE32 section from the PEI file", NULL); + return Status; + } + } + + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "GetPe32Info() could not get PE32 entry point for PEI file", NULL); + return Status; + } + + // + // Open the source file + // + SourceFile = fopen (SymFileName, "r"); + if (SourceFile == NULL) { + // + // SYM files are not required. + // + return EFI_SUCCESS; + } + // + // Read the first line + // + if (fgets (Buffer, _MAX_PATH, SourceFile) == NULL) { + Buffer[0] = 0; + } + // + // Make sure it matches the expected sym format + // + if (strcmp (Buffer, "TEXTSYM format | V1.0\n")) { + fclose (SourceFile); + Error (NULL, 0, 0, "AddSymFile() found unexpected sym format in input file", NULL); + return EFI_ABORTED; + } + // + // Read in the file + // + while (feof (SourceFile) == 0) { + // + // Read a line + // + if (fscanf ( + SourceFile, + "%s | %s | %s | %s\n", + Type, + Address, + Section, + Token + ) == 4) { + // + // If the token starts with "??" ignore it + // + if (Token[0] == '?' && Token[1] == '?') { + continue; + } + // + // Get the token address + // + AsciiStringToUint64 (Address, TRUE, &TokenAddress); + + // + // Add the base address + // + TokenAddress += BaseAddress; + + // + // If PE32 or TE section then find the start of code. For PIC it is hardcoded. + // + if (Pe32Section.Pe32Section) { + // + // Add the offset of the PE32 section + // + TokenAddress += (UINTN) Pe32Section.Pe32Section - (UINTN) FfsFile; + + // + // Add the size of the PE32 section header + // + TokenAddress += sizeof (EFI_PE32_SECTION); + } else { + // + // BUGBUG: Don't know why this is 0x28 bytes. + // + TokenAddress += 0x28; + } + // + // Add the beginning of the code + // + TokenAddress += BaseOfCode; + + sprintf ( + Buffer, + "%s | %016I64X | %s | _%s%s\n", + Type, + TokenAddress, + Section, + CodeModuleName, + Token + ); + memcpy (SymImage->CurrentFilePointer, Buffer, strlen (Buffer) + 1); + SymImage->CurrentFilePointer = (UINT8 *) (((UINTN) SymImage->CurrentFilePointer) + strlen (Buffer) + 1); + } + } + + fclose (SourceFile); + return EFI_SUCCESS; +} + +EFI_STATUS +AddFile ( + IN OUT MEMORY_FILE *FvImage, + IN FV_INFO *FvInfo, + IN UINTN Index, + IN OUT EFI_FFS_FILE_HEADER **VtfFileImage, + IN OUT MEMORY_FILE *SymImage + ) +/*++ + +Routine Description: + + This function adds a file to the FV image. The file will pad to the + appropriate alignment if required. + +Arguments: + + FvImage The memory image of the FV to add it to. The current offset + must be valid. + FvInfo Pointer to information about the FV. + Index The file in the FvInfo file list to add. + VtfFileImage A pointer to the VTF file within the FvImage. If this is equal + to the end of the FvImage then no VTF previously found. + SymImage The memory image of the Sym file to update if symbols are present. + The current offset must be valid. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + EFI_ABORTED An error occurred. + EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the add. + +--*/ +{ + FILE *NewFile; + UINTN FileSize; + UINT8 *FileBuffer; + UINTN NumBytesRead; + UINT32 CurrentFileAlignment; + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS CurrentFileBaseAddress; + UINT8 VtfHeaderChecksum; + UINT8 VtfFileChecksum; + UINT8 FileState; + UINT32 TailSize; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_FFS_FILE_TAIL TailValue; +#endif + // + // Verify input parameters. + // + if (FvImage == NULL || FvInfo == NULL || FvInfo->FvFiles[Index][0] == 0 || VtfFileImage == NULL || SymImage == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Read the file to add + // + NewFile = fopen (FvInfo->FvFiles[Index], "rb"); + + if (NewFile == NULL) { + Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to open file for reading"); + return EFI_ABORTED; + } + // + // Get the file size + // + FileSize = _filelength (_fileno (NewFile)); + + // + // Read the file into a buffer + // + FileBuffer = malloc (FileSize); + if (FileBuffer == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return EFI_OUT_OF_RESOURCES; + } + + NumBytesRead = fread (FileBuffer, sizeof (UINT8), FileSize, NewFile); + + // + // Done with the file, from this point on we will just use the buffer read. + // + fclose (NewFile); + + // + // Verify read successful + // + if (NumBytesRead != sizeof (UINT8) * FileSize) { + free (FileBuffer); + Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents"); + return EFI_ABORTED; + } + // + // Verify space exists to add the file + // + if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) { + Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file"); + return EFI_OUT_OF_RESOURCES; + } + // + // Update the file state based on polarity of the FV. + // + UpdateFfsFileState ( + (EFI_FFS_FILE_HEADER *) FileBuffer, + (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage + ); + + // + // If we have a VTF file, add it at the top. + // + if (IsVtfFile ((EFI_FFS_FILE_HEADER *) FileBuffer)) { + if ((UINTN) *VtfFileImage == (UINTN) FvImage->Eof) { + // + // No previous VTF, add this one. + // + *VtfFileImage = (EFI_FFS_FILE_HEADER *) (UINTN) ((UINTN) FvImage->FileImage + FvInfo->Size - FileSize); + // + // Sanity check. The file MUST align appropriately + // + if ((((UINTN) *VtfFileImage) & 0x07) != 0) { + Error (NULL, 0, 0, "VTF file does not align on 8-byte boundary", NULL); + } + // + // copy VTF File Header + // + memcpy (*VtfFileImage, FileBuffer, sizeof (EFI_FFS_FILE_HEADER)); + + // + // Copy VTF body + // + memcpy ( + (UINT8 *) *VtfFileImage + sizeof (EFI_FFS_FILE_HEADER), + FileBuffer + sizeof (EFI_FFS_FILE_HEADER), + FileSize - sizeof (EFI_FFS_FILE_HEADER) + ); + + // + // re-calculate the VTF File Header + // + FileState = (*VtfFileImage)->State; + (*VtfFileImage)->State = 0; + *(UINT32 *) ((*VtfFileImage)->Size) = FileSize; + (*VtfFileImage)->IntegrityCheck.Checksum.Header = 0; + (*VtfFileImage)->IntegrityCheck.Checksum.File = 0; + + VtfHeaderChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, sizeof (EFI_FFS_FILE_HEADER)); + (*VtfFileImage)->IntegrityCheck.Checksum.Header = VtfHeaderChecksum; + // + // Determine if it has a tail + // + if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) { + TailSize = sizeof (EFI_FFS_FILE_TAIL); + } else { + TailSize = 0; + } + + if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) { + VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize); + (*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum; + } else { + (*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM; + } + #if (PI_SPECIFICATION_VERSION < 0x00010000) + // + // If it has a file tail, update it + // + if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) { + TailValue = (EFI_FFS_FILE_TAIL) (~((*VtfFileImage)->IntegrityCheck.TailReference)); + *(EFI_FFS_FILE_TAIL *) (((UINTN) (*VtfFileImage) + GetLength ((*VtfFileImage)->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue; + } + #endif + (*VtfFileImage)->State = FileState; + free (FileBuffer); + return EFI_SUCCESS; + } else { + // + // Already found a VTF file. + // + Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL); + free (FileBuffer); + return EFI_ABORTED; + } + } + // + // Check if alignment is required + // + Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment); + if (EFI_ERROR (Status)) { + printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]); + free (FileBuffer); + return EFI_ABORTED; + } + // + // Add pad file if necessary + // + Status = AddPadFile (FvImage, CurrentFileAlignment); + if (EFI_ERROR (Status)) { + printf ("ERROR: Could not align the file data properly.\n"); + free (FileBuffer); + return EFI_ABORTED; + } + // + // Add file + // + if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) { + // + // Copy the file + // + memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize); + + // + // If the file is XIP, rebase + // + CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage); + // + // Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress); + // if (EFI_ERROR(Status)) { + // printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]); + // return EFI_ABORTED; + // } + // + // Update Symbol file + // + Status = AddSymFile ( + CurrentFileBaseAddress, + (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer, + SymImage, + FvInfo->FvFiles[Index] + ); + assert (!EFI_ERROR (Status)); + + // + // Update the current pointer in the FV image + // + FvImage->CurrentFilePointer += FileSize; + } else { + printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]); + return EFI_ABORTED; + } + // + // Make next file start at QWord Boundry + // + while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) { + FvImage->CurrentFilePointer++; + } + // + // Free allocated memory. + // + free (FileBuffer); + + return EFI_SUCCESS; +} + +EFI_STATUS +AddVariableBlock ( + IN UINT8 *FvImage, + IN UINTN Size, + IN FV_INFO *FvInfo + ) +{ + EFI_FIRMWARE_VOLUME_HEADER *FvHeader; + VARIABLE_STORE_HEADER *VarStoreHeader; + // + // Variable block should exclude FvHeader. Since the length of + // FvHeader depends on the block map, which is variable length, + // we could only decide the actual variable block length here. + // + FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage; + FvImage = FvImage + FvHeader->HeaderLength; + + VarStoreHeader = (VARIABLE_STORE_HEADER *) FvImage; + + VarStoreHeader->Signature = VARIABLE_STORE_SIGNATURE; + VarStoreHeader->Size = Size - FvHeader->HeaderLength; + VarStoreHeader->Format = VARIABLE_STORE_FORMATTED; + VarStoreHeader->State = VARIABLE_STORE_HEALTHY; + VarStoreHeader->Reserved = 0; + VarStoreHeader->Reserved1 = 0; + + return EFI_SUCCESS; +} + +EFI_STATUS +AddEventLogBlock ( + IN UINT8 *FvImage, + IN UINTN Size, + IN FV_INFO *FvInfo + ) +{ + return EFI_SUCCESS; +} + +EFI_STATUS +AddFTWWorkingBlock ( + IN UINT8 *FvImage, + IN UINTN Size, + IN FV_INFO *FvInfo + ) +{ + EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FTWHeader; + UINT32 Crc32; + + Crc32 = 0; + FTWHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) FvImage; + memcpy (&FTWHeader->Signature, &(FvInfo->FvGuid), sizeof (EFI_GUID)); + FTWHeader->WriteQueueSize = Size - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER); + CalculateCrc32 (FvImage, sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER), &Crc32); + FTWHeader->Crc = Crc32; + if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) { + FTWHeader->WorkingBlockValid = 0; + FTWHeader->WorkingBlockInvalid = 1; + } else { + FTWHeader->WorkingBlockValid = 1; + FTWHeader->WorkingBlockInvalid = 0; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +AddFTWSpareBlock ( + IN UINT8 *FvImage, + IN UINTN Size, + IN FV_INFO *FvInfo + ) +{ + return EFI_SUCCESS; +} + +EFI_STATUS +GenNonFFSFv ( + IN UINT8 *FvImage, + IN FV_INFO *FvInfo + ) +/*++ + +Routine Description: + + This function generate the non FFS FV image, such as the working block + and spare block. How each component of the FV is built is component + specific. + +Arguments: + + FvImage The memory image of the FV to add it to. The current offset + must be valid. + FvInfo Pointer to information about the FV. + +Returns: + + EFI_SUCCESS The function completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was invalid. + EFI_ABORTED An error occurred. + EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the add. + +--*/ +{ + UINTN Index; + EFI_FIRMWARE_VOLUME_HEADER *FvHeader; + UINT64 TotalSize; + + FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage; + TotalSize = 0; + + for (Index = 0; FvInfo->FvComponents[Index].Size != 0; Index++) { + if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING) == 0) { + AddVariableBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo); + } else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING) == 0) { + AddEventLogBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo); + } else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING) == 0) { + AddFTWWorkingBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo); + } else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) { + AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo); + } else { + printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName); + return EFI_ABORTED; + } + + FvImage = FvImage + FvInfo->FvComponents[Index].Size; + TotalSize = TotalSize + FvInfo->FvComponents[Index].Size; + } + // + // Index and TotalSize is zero mean there's no component, so this is an empty fv + // + if ((Index != 0 || TotalSize != 0) && TotalSize != FvInfo->Size) { + printf ("Error. Component size does not sum up to FV size.\n"); + return EFI_ABORTED; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +PadFvImage ( + IN MEMORY_FILE *FvImage, + IN EFI_FFS_FILE_HEADER *VtfFileImage + ) +/*++ + +Routine Description: + + This function places a pad file between the last file in the FV and the VTF + file if the VTF file exists. + +Arguments: + + FvImage Memory file for the FV memory image + VtfFileImage The address of the VTF file. If this is the end of the FV + image, no VTF exists and no pad file is needed. + +Returns: + + EFI_SUCCESS Completed successfully. + EFI_INVALID_PARAMETER One of the input parameters was NULL. + +--*/ +{ + EFI_FFS_FILE_HEADER *PadFile; + UINTN FileSize; + + // + // If there is no VTF or the VTF naturally follows the previous file without a + // pad file, then there's nothing to do + // + if ((UINTN) VtfFileImage == (UINTN) FvImage->Eof || (void *) FvImage->CurrentFilePointer == (void *) VtfFileImage) { + return EFI_SUCCESS; + } + // + // Pad file starts at beginning of free space + // + PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer; + + // + // write header + // + memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER)); + memcpy (&PadFile->Name, &DefaultFvPadFileNameGuid, sizeof (EFI_GUID)); + PadFile->Type = EFI_FV_FILETYPE_FFS_PAD; + PadFile->Attributes = 0; + + // + // FileSize includes the EFI_FFS_FILE_HEADER + // + FileSize = (UINTN) VtfFileImage - (UINTN) FvImage->CurrentFilePointer; + PadFile->Size[0] = (UINT8) (FileSize & 0x000000FF); + PadFile->Size[1] = (UINT8) ((FileSize & 0x0000FF00) >> 8); + PadFile->Size[2] = (UINT8) ((FileSize & 0x00FF0000) >> 16); + + // + // Fill in checksums and state, must be zero during checksum calculation. + // + PadFile->IntegrityCheck.Checksum.Header = 0; + PadFile->IntegrityCheck.Checksum.File = 0; + PadFile->State = 0; + PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER)); + if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) { + PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize); + } else { + PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM; + } + + PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID; + + UpdateFfsFileState ( + (EFI_FFS_FILE_HEADER *) PadFile, + (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage + ); + // + // Update the current FV pointer + // + FvImage->CurrentFilePointer = FvImage->Eof; + + return EFI_SUCCESS; +} + +EFI_STATUS +UpdateResetVector ( + IN MEMORY_FILE *FvImage, + IN FV_INFO *FvInfo, + IN EFI_FFS_FILE_HEADER *VtfFile + ) +/*++ + +Routine Description: + + This parses the FV looking for the PEI core and then plugs the address into + the SALE_ENTRY point of the BSF/VTF for IPF and does BUGBUG TBD action to + complete an IA32 Bootstrap FV. + +Arguments: + + FvImage Memory file for the FV memory image + FvInfo Information read from INF file. + VtfFile Pointer to the VTF file in the FV image. + +Returns: + + EFI_SUCCESS Function Completed successfully. + EFI_ABORTED Error encountered. + EFI_INVALID_PARAMETER A required parameter was NULL. + EFI_NOT_FOUND PEI Core file not found. + +--*/ +{ + EFI_FFS_FILE_HEADER *PeiCoreFile; + EFI_FFS_FILE_HEADER *SecCoreFile; + EFI_STATUS Status; + EFI_FILE_SECTION_POINTER Pe32Section; + UINT32 EntryPoint; + UINT32 BaseOfCode; + UINT16 MachineType; + EFI_PHYSICAL_ADDRESS PeiCorePhysicalAddress; + EFI_PHYSICAL_ADDRESS SecCorePhysicalAddress; + EFI_PHYSICAL_ADDRESS *SecCoreEntryAddressPtr; + UINT32 *Ia32ResetAddressPtr; + UINT8 *BytePointer; + UINT8 *BytePointer2; + UINT16 *WordPointer; + UINT16 CheckSum; + UINTN Index; + EFI_FFS_FILE_STATE SavedState; + UINT32 TailSize; + UINT64 FitAddress; + FIT_TABLE *FitTablePtr; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_FFS_FILE_TAIL TailValue; +#endif + // + // Verify input parameters + // + if (FvImage == NULL || FvInfo == NULL || VtfFile == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Initialize FV library + // + InitializeFvLib (FvImage->FileImage, (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage); + + // + // Verify VTF file + // + Status = VerifyFfsFile (VtfFile); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + // + // Find the PEI Core + // + Status = GetFileByType (EFI_FV_FILETYPE_PEI_CORE, 1, &PeiCoreFile); + if (EFI_ERROR (Status) || PeiCoreFile == NULL) { + Error (NULL, 0, 0, "could not find the PEI core in the FV", NULL); + return EFI_ABORTED; + } + // + // PEI Core found, now find PE32 or TE section + // + Status = GetSectionByType (PeiCoreFile, EFI_SECTION_PE32, 1, &Pe32Section); + if (Status == EFI_NOT_FOUND) { + Status = GetSectionByType (PeiCoreFile, EFI_SECTION_TE, 1, &Pe32Section); + } + + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "could not find PE32 or TE section in PEI core file", NULL); + return EFI_ABORTED; + } + + Status = GetPe32Info ( + (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)), + &EntryPoint, + &BaseOfCode, + &MachineType + ); + + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "could not get PE32 entry point for PEI core", NULL); + return EFI_ABORTED; + } + // + // Physical address is FV base + offset of PE32 + offset of the entry point + // + PeiCorePhysicalAddress = FvInfo->BaseAddress; + PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage; + PeiCorePhysicalAddress += EntryPoint; + + if (MachineType == EFI_IMAGE_MACHINE_IA64) { + // + // Update PEI_CORE address + // + // + // Set the uncached attribute bit in the physical address + // + PeiCorePhysicalAddress |= 0x8000000000000000; + + // + // Check if address is aligned on a 16 byte boundary + // + if (PeiCorePhysicalAddress & 0xF) { + printf ( + "ERROR: PEI_CORE entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n", + PeiCorePhysicalAddress + ); + return EFI_ABORTED; + } + // + // First Get the FIT table address + // + FitAddress = (*(UINT64 *) (FvImage->Eof - IPF_FIT_ADDRESS_OFFSET)) & 0xFFFFFFFF; + + FitTablePtr = (FIT_TABLE *) (FvImage->FileImage + (FitAddress - FvInfo->BaseAddress)); + + Status = UpdatePeiCoreEntryInFit (FitTablePtr, PeiCorePhysicalAddress); + + if (!EFI_ERROR (Status)) { + UpdateFitCheckSum (FitTablePtr); + } + // + // Find the Sec Core + // + Status = GetFileByType (EFI_FV_FILETYPE_SECURITY_CORE, 1, &SecCoreFile); + if (EFI_ERROR (Status) || SecCoreFile == NULL) { + Error (NULL, 0, 0, "could not find the Sec core in the FV", NULL); + return EFI_ABORTED; + } + // + // Sec Core found, now find PE32 section + // + Status = GetSectionByType (SecCoreFile, EFI_SECTION_PE32, 1, &Pe32Section); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "could not find PE32 section in SEC core file", NULL); + return EFI_ABORTED; + } + + Status = GetPe32Info ( + (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)), + &EntryPoint, + &BaseOfCode, + &MachineType + ); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 0, "could not get PE32 entry point for SEC core", NULL); + return EFI_ABORTED; + } + // + // Physical address is FV base + offset of PE32 + offset of the entry point + // + SecCorePhysicalAddress = FvInfo->BaseAddress; + SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage; + SecCorePhysicalAddress += EntryPoint; + + // + // Update SEC_CORE address + // + // + // Set the uncached attribute bit in the physical address + // + SecCorePhysicalAddress |= 0x8000000000000000; + + // + // Update the address + // + SecCoreEntryAddressPtr = (EFI_PHYSICAL_ADDRESS *) ((UINTN) FvImage->Eof - IPF_SALE_ENTRY_ADDRESS_OFFSET); + *SecCoreEntryAddressPtr = SecCorePhysicalAddress; + + // + // Check if address is aligned on a 16 byte boundary + // + if (SecCorePhysicalAddress & 0xF) { + printf ( + "ERROR: SALE_ENTRY entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n", + SecCorePhysicalAddress + ); + return EFI_ABORTED; + } + } else if ((MachineType == EFI_IMAGE_MACHINE_IA32) || + (MachineType == EFI_IMAGE_MACHINE_X64)) { + // + // Get the location to update + // + Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - IA32_PEI_CORE_ENTRY_OFFSET); + + // + // Write lower 32 bits of physical address + // + *Ia32ResetAddressPtr = (UINT32) PeiCorePhysicalAddress; + + // + // Update the BFV base address + // + Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - 4); + *Ia32ResetAddressPtr = (UINT32) (FvInfo->BaseAddress); + + CheckSum = 0x0000; + + // + // Update the Startup AP in the FVH header block ZeroVector region. + // + BytePointer = (UINT8 *) ((UINTN) FvImage->FileImage); + BytePointer2 = (FvInfo->Size == 0x10000) ? m64kRecoveryStartupApDataArray : m128kRecoveryStartupApDataArray; + for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY; Index++) { + *BytePointer++ = *BytePointer2++; + } + // + // Calculate the checksum + // + WordPointer = (UINT16 *) ((UINTN) FvImage->FileImage); + for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY / 2; Index++) { + CheckSum = (UINT16) (CheckSum + ((UINT16) *WordPointer)); + WordPointer++; + } + // + // Update the checksum field + // + BytePointer = (UINT8 *) ((UINTN) FvImage->FileImage); + BytePointer += (SIZEOF_STARTUP_DATA_ARRAY - 2); + WordPointer = (UINT16 *) BytePointer; + *WordPointer = (UINT16) (0x10000 - (UINT32) CheckSum); + } else { + Error (NULL, 0, 0, "invalid machine type in PEI core", "machine type=0x%X", (UINT32) MachineType); + return EFI_ABORTED; + } + // + // Determine if it has an FFS file tail. + // + if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) { + TailSize = sizeof (EFI_FFS_FILE_TAIL); + } else { + TailSize = 0; + } + // + // Now update file checksum + // + SavedState = VtfFile->State; + VtfFile->IntegrityCheck.Checksum.File = 0; + VtfFile->State = 0; + if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) { + VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ( + (UINT8 *) VtfFile, + GetLength (VtfFile->Size) - TailSize + ); + } else { + VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM; + } + + VtfFile->State = SavedState; + +#if (PI_SPECIFICATION_VERSION < 0x00010000) + // + // Update tail if present + // + if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) { + TailValue = (EFI_FFS_FILE_TAIL) (~(VtfFile->IntegrityCheck.TailReference)); + *(EFI_FFS_FILE_TAIL *) (((UINTN) (VtfFile) + GetLength (VtfFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue; + } +#endif + return EFI_SUCCESS; +} + +EFI_STATUS +GetPe32Info ( + IN UINT8 *Pe32, + OUT UINT32 *EntryPoint, + OUT UINT32 *BaseOfCode, + OUT UINT16 *MachineType + ) +/*++ + +Routine Description: + + Retrieves the PE32 entry point offset and machine type from PE image or TE image. + See EfiImage.h for machine types. The entry point offset is from the beginning + of the PE32 buffer passed in. + +Arguments: + + Pe32 Beginning of the PE32. + EntryPoint Offset from the beginning of the PE32 to the image entry point. + BaseOfCode Base address of code. + MachineType Magic number for the machine type. + +Returns: + + EFI_SUCCESS Function completed successfully. + EFI_ABORTED Error encountered. + EFI_INVALID_PARAMETER A required parameter was NULL. + EFI_UNSUPPORTED The operation is unsupported. + +--*/ +{ + EFI_IMAGE_DOS_HEADER *DosHeader; + EFI_IMAGE_NT_HEADERS *NtHeader; + EFI_TE_IMAGE_HEADER *TeHeader; + + // + // Verify input parameters + // + if (Pe32 == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // First check whether it is one TE Image. + // + TeHeader = (EFI_TE_IMAGE_HEADER *) Pe32; + if (TeHeader->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) { + // + // By TeImage Header to get output + // + *EntryPoint = TeHeader->AddressOfEntryPoint + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize; + *BaseOfCode = TeHeader->BaseOfCode + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize; + *MachineType = TeHeader->Machine; + } else { + // + // Then check whether + // is the DOS header + // + DosHeader = (EFI_IMAGE_DOS_HEADER *) Pe32; + + // + // Verify DOS header is expected + // + if (DosHeader->e_magic != EFI_IMAGE_DOS_SIGNATURE) { + printf ("ERROR: Unknown magic number in the DOS header, 0x%04X.\n", DosHeader->e_magic); + return EFI_UNSUPPORTED; + } + // + // Immediately following is the NT header. + // + NtHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32 + DosHeader->e_lfanew); + + // + // Verify NT header is expected + // + if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) { + printf ("ERROR: Unrecognized image signature 0x%08X.\n", NtHeader->Signature); + return EFI_UNSUPPORTED; + } + // + // Get output + // + *EntryPoint = NtHeader->OptionalHeader.AddressOfEntryPoint; + *BaseOfCode = NtHeader->OptionalHeader.BaseOfCode; + *MachineType = NtHeader->FileHeader.Machine; + } + + // + // Verify machine type is supported + // + if (*MachineType != EFI_IMAGE_MACHINE_IA32 && + *MachineType != EFI_IMAGE_MACHINE_IA64 && + *MachineType != EFI_IMAGE_MACHINE_X64) { + printf ("ERROR: Unrecognized machine type in the PE32 file.\n"); + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} +// +// Exposed function implementations (prototypes are defined in GenFvImageLib.h) +// +EFI_STATUS +GenerateFvImage ( + IN CHAR8 *InfFileImage, + IN UINTN InfFileSize, + OUT UINT8 **FvImage, + OUT UINTN *FvImageSize, + OUT CHAR8 **FvFileName, + OUT UINT8 **SymImage, + OUT UINTN *SymImageSize, + OUT CHAR8 **SymFileName + ) +/*++ + +Routine Description: + + This is the main function which will be called from application. + +Arguments: + + InfFileImage Buffer containing the INF file contents. + InfFileSize Size of the contents of the InfFileImage buffer. + FvImage Pointer to the FV image created. + FvImageSize Size of the FV image created and pointed to by FvImage. + FvFileName Requested name for the FV file. + SymImage Pointer to the Sym image created. + SymImageSize Size of the Sym image created and pointed to by SymImage. + SymFileName Requested name for the Sym file. + +Returns: + + EFI_SUCCESS Function completed successfully. + EFI_OUT_OF_RESOURCES Could not allocate required resources. + EFI_ABORTED Error encountered. + EFI_INVALID_PARAMETER A required parameter was NULL. + +--*/ +{ + EFI_STATUS Status; + MEMORY_FILE InfMemoryFile; + MEMORY_FILE FvImageMemoryFile; + MEMORY_FILE SymImageMemoryFile; + FV_INFO FvInfo; + UINTN Index; + EFI_FIRMWARE_VOLUME_HEADER *FvHeader; + EFI_FFS_FILE_HEADER *VtfFileImage; + + // + // Check for invalid parameter + // + if (InfFileImage == NULL || FvImage == NULL || FvImageSize == NULL || FvFileName == NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Initialize file structures + // + InfMemoryFile.FileImage = InfFileImage; + InfMemoryFile.CurrentFilePointer = InfFileImage; + InfMemoryFile.Eof = InfFileImage + InfFileSize; + + // + // Parse the FV inf file for header information + // + Status = ParseFvInf (&InfMemoryFile, &FvInfo); + if (EFI_ERROR (Status)) { + printf ("ERROR: Could not parse the input INF file.\n"); + return EFI_ABORTED; + } + // + // Update the file name return values + // + strcpy (*FvFileName, FvInfo.FvName); + strcpy (*SymFileName, FvInfo.SymName); + + // + // Calculate the FV size + // + *FvImageSize = FvInfo.Size; + + // + // Allocate the FV + // + *FvImage = malloc (*FvImageSize); + if (*FvImage == NULL) { + return EFI_OUT_OF_RESOURCES; + } + // + // Allocate space for symbol file storage + // + *SymImage = malloc (SYMBOL_FILE_SIZE); + if (*SymImage == NULL) { + return EFI_OUT_OF_RESOURCES; + } + // + // Initialize the FV to the erase polarity + // + if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) { + memset (*FvImage, -1, *FvImageSize); + } else { + memset (*FvImage, 0, *FvImageSize); + } + // + // Initialize FV header + // + FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) *FvImage; + + // + // Initialize the zero vector to all zeros. + // + memset (FvHeader->ZeroVector, 0, 16); + + // + // Copy the FFS GUID + // + memcpy (&FvHeader->FileSystemGuid, &FvInfo.FvGuid, sizeof (EFI_GUID)); + + FvHeader->FvLength = *FvImageSize; + FvHeader->Signature = EFI_FVH_SIGNATURE; + FvHeader->Attributes = FvInfo.FvAttributes; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + FvHeader->Revision = EFI_FVH_REVISION; + FvHeader->Reserved[0] = 0; + FvHeader->Reserved[1] = 0; + FvHeader->Reserved[2] = 0; +#else + FvHeader->Revision = EFI_FVH_PI_REVISION; + FvHeader->ExtHeaderOffset = 0; + FvHeader->Reserved[0] = 0; +#endif + // + // Copy firmware block map + // + for (Index = 0; FvInfo.FvBlocks[Index].NumBlocks != 0; Index++) { + FvHeader->FvBlockMap[Index].NumBlocks = FvInfo.FvBlocks[Index].NumBlocks; + FvHeader->FvBlockMap[Index].BlockLength = FvInfo.FvBlocks[Index].BlockLength; + } + // + // Add block map terminator + // + FvHeader->FvBlockMap[Index].NumBlocks = 0; + FvHeader->FvBlockMap[Index].BlockLength = 0; + + // + // Complete the header + // + FvHeader->HeaderLength = (UINT16) (((UINTN) &(FvHeader->FvBlockMap[Index + 1])) - (UINTN) *FvImage); + FvHeader->Checksum = 0; + FvHeader->Checksum = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16)); + + // + // If there is no FFS file, find and generate each components of the FV + // + if (FvInfo.FvFiles[0][0] == 0) { + Status = GenNonFFSFv (*FvImage, &FvInfo); + if (EFI_ERROR (Status)) { + printf ("ERROR: Could not generate NonFFS FV.\n"); + free (*FvImage); + return EFI_ABORTED; + } + + return EFI_SUCCESS; + } + // + // Initialize our "file" view of the buffer + // + FvImageMemoryFile.FileImage = *FvImage; + FvImageMemoryFile.CurrentFilePointer = *FvImage + FvHeader->HeaderLength; + FvImageMemoryFile.Eof = *FvImage +*FvImageSize; + + // + // Initialize our "file" view of the symbol file. + // + SymImageMemoryFile.FileImage = *SymImage; + SymImageMemoryFile.CurrentFilePointer = *SymImage; + SymImageMemoryFile.Eof = *FvImage + SYMBOL_FILE_SIZE; + + // + // Initialize the FV library. + // + InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size); + + // + // Files start on 8 byte alignments, so move to the next 8 byte aligned + // address. For now, just assert if it isn't. Currently FV header is + // always a multiple of 8 bytes. + // BUGBUG: Handle this better + // + assert ((((UINTN) FvImageMemoryFile.CurrentFilePointer) % 8) == 0); + + // + // Initialize the VTF file address. + // + VtfFileImage = (EFI_FFS_FILE_HEADER *) FvImageMemoryFile.Eof; + + // + // Add files to FV + // + for (Index = 0; FvInfo.FvFiles[Index][0] != 0; Index++) { + // + // Add the file + // + Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile); + + // + // Exit if error detected while adding the file + // + if (EFI_ERROR (Status)) { + printf ("ERROR: Could not add file %s.\n", FvInfo.FvFiles[Index]); + free (*FvImage); + return EFI_ABORTED; + } + } + // + // If there is a VTF file, some special actions need to occur. + // + if ((UINTN) VtfFileImage != (UINTN) FvImageMemoryFile.Eof) { + // + // Pad from the end of the last file to the beginning of the VTF file. + // + Status = PadFvImage (&FvImageMemoryFile, VtfFileImage); + if (EFI_ERROR (Status)) { + printf ("ERROR: Could not create the pad file between the last file and the VTF file.\n"); + free (*FvImage); + return EFI_ABORTED; + } + // + // Update reset vector (SALE_ENTRY for IPF) + // Now for IA32 and IA64 platform, the fv which has bsf file must have the + // EndAddress of 0xFFFFFFFF. Thus, only this type fv needs to update the + // reset vector. If the PEI Core is found, the VTF file will probably get + // corrupted by updating the entry point. + // + if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) { + Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage); + if (EFI_ERROR(Status)) { + printf ("ERROR: Could not update the reset vector.\n"); + free (*FvImage); + return EFI_ABORTED; + } + } + } + // + // Determine final Sym file size + // + *SymImageSize = SymImageMemoryFile.CurrentFilePointer - SymImageMemoryFile.FileImage; + + return EFI_SUCCESS; +} + +EFI_STATUS +UpdatePeiCoreEntryInFit ( + IN FIT_TABLE *FitTablePtr, + IN UINT64 PeiCorePhysicalAddress + ) +/*++ + +Routine Description: + + This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from + Sec to Pei Core + +Arguments: + + FitTablePtr - The pointer of FIT_TABLE. + PeiCorePhysicalAddress - The address of Pei Core entry. + +Returns: + + EFI_SUCCESS - The PEI_CORE FIT entry was updated successfully. + EFI_NOT_FOUND - Not found the PEI_CORE FIT entry. + +--*/ +{ + FIT_TABLE *TmpFitPtr; + UINTN Index; + UINTN NumFitComponents; + + TmpFitPtr = FitTablePtr; + NumFitComponents = TmpFitPtr->CompSize; + + for (Index = 0; Index < NumFitComponents; Index++) { + if ((TmpFitPtr->CvAndType & FIT_TYPE_MASK) == COMP_TYPE_FIT_PEICORE) { + TmpFitPtr->CompAddress = PeiCorePhysicalAddress; + return EFI_SUCCESS; + } + + TmpFitPtr++; + } + + return EFI_NOT_FOUND; +} + +VOID +UpdateFitCheckSum ( + IN FIT_TABLE *FitTablePtr + ) +/*++ + +Routine Description: + + This function is used to update the checksum for FIT. + + +Arguments: + + FitTablePtr - The pointer of FIT_TABLE. + +Returns: + + None. + +--*/ +{ + if ((FitTablePtr->CvAndType & CHECKSUM_BIT_MASK) >> 7) { + FitTablePtr->CheckSum = 0; + FitTablePtr->CheckSum = CalculateChecksum8 ((UINT8 *) FitTablePtr, FitTablePtr->CompSize * 16); + } +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.h new file mode 100644 index 0000000000..e1db1b1468 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.h @@ -0,0 +1,140 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenFvImageLib.h + +Abstract: + + This file contains describes the public interfaces to the GenFvImage Library. + The basic purpose of the library is to create Firmware Volume images. + +--*/ + +#ifndef _EFI_GEN_FV_IMAGE_LIB_H +#define _EFI_GEN_FV_IMAGE_LIB_H + +// +// Include files +// +#include "Efi2WinNT.h" +#include "ParseInf.h" + +// +// Following definition is used for FIT in IPF +// +#define COMP_TYPE_FIT_PEICORE 0x10 +#define COMP_TYPE_FIT_UNUSED 0x7F + +#define FIT_TYPE_MASK 0x7F +#define CHECKSUM_BIT_MASK 0x80 + +#pragma pack(1) + +typedef struct { + UINT64 CompAddress; + UINT32 CompSize; + UINT16 CompVersion; + UINT8 CvAndType; + UINT8 CheckSum; +} FIT_TABLE; + +#pragma pack() +// +// Exported function prototypes +// +EFI_STATUS +GenerateFvImage ( + IN CHAR8 *InfFileImage, + IN UINTN InfFileSize, + OUT UINT8 **FvImage, + OUT UINTN *FvImageSize, + OUT CHAR8 **FvFileName, + OUT UINT8 **SymImage, + OUT UINTN *SymImageSize, + OUT CHAR8 **SymFileName + ) +; + +/*++ + +Routine Description: + + This is the main function which will be called from application. + +Arguments: + + InfFileImage Buffer containing the INF file contents. + InfFileSize Size of the contents of the InfFileImage buffer. + FvImage Pointer to the FV image created. + FvImageSize Size of the FV image created and pointed to by FvImage. + FvFileName Requested name for the FV file. + SymImage Pointer to the Sym image created. + SymImageSize Size of the Sym image created and pointed to by SymImage. + SymFileName Requested name for the Sym file. + +Returns: + + EFI_SUCCESS Function completed successfully. + EFI_OUT_OF_RESOURCES Could not allocate required resources. + EFI_ABORTED Error encountered. + EFI_INVALID_PARAMETER A required parameter was NULL. + +--*/ +EFI_STATUS +UpdatePeiCoreEntryInFit ( + IN FIT_TABLE *FitTablePtr, + IN UINT64 PeiCorePhysicalAddress + ) +; + +/*++ + +Routine Description: + + This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from + Sec to Pei Core + +Arguments: + + FitTablePtr - The pointer of FIT_TABLE. + PeiCorePhysicalAddress - The address of Pei Core entry. + +Returns: + + EFI_SUCCESS - The PEI_CORE FIT entry was updated successfully. + EFI_NOT_FOUND - Not found the PEI_CORE FIT entry. + +--*/ +VOID +UpdateFitCheckSum ( + IN FIT_TABLE *FitTablePtr + ) +; + +/*++ + +Routine Description: + + This function is used to update the checksum for FIT. + + +Arguments: + + FitTablePtr - The pointer of FIT_TABLE. + +Returns: + + None. + +--*/ +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h new file mode 100644 index 0000000000..505188b495 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h @@ -0,0 +1,212 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenFvImageLibInternal.h + +Abstract: + + This file contains describes the private declarations for the GenFvImage Library. + The basic purpose of the library is to create Firmware Volume images. + +--*/ + +#ifndef _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H +#define _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H + +// +// Include files +// +#include "GenFvImageLib.h" +#include +#include "EfiFirmwareVolumeHeader.h" + +// +// Private data declarations +// +// +// The maximum number of block map entries supported by the library +// +#define MAX_NUMBER_OF_FV_BLOCKS 100 + +// +// The maximum number of files in the FV supported by the library +// +#define MAX_NUMBER_OF_FILES_IN_FV 1000 +#define MAX_NUMBER_OF_COMPONENTS_IN_FV 10 + +// +// INF file strings +// +#define OPTIONS_SECTION_STRING "[options]" +#define ATTRIBUTES_SECTION_STRING "[attributes]" +#define FILES_SECTION_STRING "[files]" +#define COMPONENT_SECTION_STRING "[components]" + +#define EFI_FV_BASE_ADDRESS_STRING "EFI_BASE_ADDRESS" +#define EFI_FV_FILE_NAME_STRING "EFI_FILE_NAME" +#define EFI_SYM_FILE_NAME_STRING "EFI_SYM_FILE_NAME" +#define EFI_NUM_BLOCKS_STRING "EFI_NUM_BLOCKS" +#define EFI_BLOCK_SIZE_STRING "EFI_BLOCK_SIZE" +#define EFI_FV_GUID_STRING "EFI_FV_GUID" + +#define EFI_FVB_READ_DISABLED_CAP_STRING "EFI_READ_DISABLED_CAP" +#define EFI_FVB_READ_ENABLED_CAP_STRING "EFI_READ_ENABLED_CAP" +#define EFI_FVB_READ_STATUS_STRING "EFI_READ_STATUS" + +#define EFI_FVB_WRITE_DISABLED_CAP_STRING "EFI_WRITE_DISABLED_CAP" +#define EFI_FVB_WRITE_ENABLED_CAP_STRING "EFI_WRITE_ENABLED_CAP" +#define EFI_FVB_WRITE_STATUS_STRING "EFI_WRITE_STATUS" + +#define EFI_FVB_LOCK_CAP_STRING "EFI_LOCK_CAP" +#define EFI_FVB_LOCK_STATUS_STRING "EFI_LOCK_STATUS" + +#define EFI_FVB_STICKY_WRITE_STRING "EFI_STICKY_WRITE" +#define EFI_FVB_MEMORY_MAPPED_STRING "EFI_MEMORY_MAPPED" +#define EFI_FVB_ERASE_POLARITY_STRING "EFI_ERASE_POLARITY" + +#define EFI_FVB_ALIGNMENT_CAP_STRING "EFI_ALIGNMENT_CAP" +#define EFI_FVB_ALIGNMENT_2_STRING "EFI_ALIGNMENT_2" +#define EFI_FVB_ALIGNMENT_4_STRING "EFI_ALIGNMENT_4" +#define EFI_FVB_ALIGNMENT_8_STRING "EFI_ALIGNMENT_8" +#define EFI_FVB_ALIGNMENT_16_STRING "EFI_ALIGNMENT_16" +#define EFI_FVB_ALIGNMENT_32_STRING "EFI_ALIGNMENT_32" +#define EFI_FVB_ALIGNMENT_64_STRING "EFI_ALIGNMENT_64" +#define EFI_FVB_ALIGNMENT_128_STRING "EFI_ALIGNMENT_128" +#define EFI_FVB_ALIGNMENT_256_STRING "EFI_ALIGNMENT_256" +#define EFI_FVB_ALIGNMENT_512_STRING "EFI_ALIGNMENT_512" +#define EFI_FVB_ALIGNMENT_1K_STRING "EFI_ALIGNMENT_1K" +#define EFI_FVB_ALIGNMENT_2K_STRING "EFI_ALIGNMENT_2K" +#define EFI_FVB_ALIGNMENT_4K_STRING "EFI_ALIGNMENT_4K" +#define EFI_FVB_ALIGNMENT_8K_STRING "EFI_ALIGNMENT_8K" +#define EFI_FVB_ALIGNMENT_16K_STRING "EFI_ALIGNMENT_16K" +#define EFI_FVB_ALIGNMENT_32K_STRING "EFI_ALIGNMENT_32K" +#define EFI_FVB_ALIGNMENT_64K_STRING "EFI_ALIGNMENT_64K" + +// +// Add these for PI1.0 new Attributes. +// +#define EFI_FVB_READ_LOCK_CAP_STRING "EFI_READ_LOCK_CAP" +#define EFI_FVB_READ_LOCK_STATUS_STRING "EFI_READ_LOCK_STATUS" +#define EFI_FVB_WRITE_LOCK_CAP_STRING "EFI_WRITE_LOCK_CAP" +#define EFI_FVB_WRITE_LOCK_STATUS_STRING "EFI_WRITE_LOCK_STATUS" +#define EFI_FVB2_ALIGNMENT_STRING "EFI_FVB2_ALIGNMENT" + +#define EFI_FVB2_ALIGNMENT_1_STRING "1" +#define EFI_FVB2_ALIGNMENT_2_STRING "2" +#define EFI_FVB2_ALIGNMENT_4_STRING "4" +#define EFI_FVB2_ALIGNMENT_8_STRING "8" +#define EFI_FVB2_ALIGNMENT_16_STRING "16" +#define EFI_FVB2_ALIGNMENT_32_STRING "32" +#define EFI_FVB2_ALIGNMENT_64_STRING "64" +#define EFI_FVB2_ALIGNMENT_128_STRING "128" +#define EFI_FVB2_ALIGNMENT_256_STRING "256" +#define EFI_FVB2_ALIGNMENT_512_STRING "512" +#define EFI_FVB2_ALIGNMENT_1K_STRING "1K" +#define EFI_FVB2_ALIGNMENT_2K_STRING "2K" +#define EFI_FVB2_ALIGNMENT_4K_STRING "4K" +#define EFI_FVB2_ALIGNMENT_8K_STRING "8K" +#define EFI_FVB2_ALIGNMENT_16K_STRING "16K" +#define EFI_FVB2_ALIGNMENT_32K_STRING "32K" +#define EFI_FVB2_ALIGNMENT_64K_STRING "64K" +#define EFI_FVB2_ALIGNMENT_128K_STRING "128K" +#define EFI_FVB2_ALIGNMENT_256K_STRING "256K" +#define EFI_FVB2_ALIGNMENT_512K_STRING "512K" +#define EFI_FVB2_ALIGNMENT_1M_STRING "1M" +#define EFI_FVB2_ALIGNMENT_2M_STRING "2M" +#define EFI_FVB2_ALIGNMENT_4M_STRING "4M" +#define EFI_FVB2_ALIGNMENT_8M_STRING "8M" +#define EFI_FVB2_ALIGNMENT_16M_STRING "16M" +#define EFI_FVB2_ALIGNMENT_32M_STRING "32M" +#define EFI_FVB2_ALIGNMENT_64M_STRING "64M" +#define EFI_FVB2_ALIGNMENT_128M_STRING "128M" +#define EFI_FVB2_ALIGNMENT_256M_STRING "256M" +#define EFI_FVB2_ALIGNMENT_512M_STRING "512M" +#define EFI_FVB2_ALIGNMENT_1G_STRING "1G" +#define EFI_FVB2_ALIGNMENT_2G_STRING "2G" + + +// +// Component sections +// +#define EFI_NV_VARIABLE_STRING "EFI_NV_VARIABLE" +#define EFI_NV_EVENT_LOG_STRING "EFI_NV_EVENT_LOG" +#define EFI_NV_FTW_WORKING_STRING "EFI_NV_FTW_WORKING" +#define EFI_NV_FTW_SPARE_STRING "EFI_NV_FTW_SPARE" + +#define EFI_FILE_NAME_STRING "EFI_FILE_NAME" + +#define ONE_STRING "1" +#define ZERO_STRING "0" +#define TRUE_STRING "TRUE" +#define FALSE_STRING "FALSE" +#define NULL_STRING "NULL" + +// +// Defines to calculate the offset for PEI CORE entry points +// +#define IA32_PEI_CORE_ENTRY_OFFSET 0x20 + +// +// Defines to calculate the FIT table +// +#define IPF_FIT_ADDRESS_OFFSET 0x20 + +// +// Defines to calculate the offset for SALE_ENTRY +// +#define IPF_SALE_ENTRY_ADDRESS_OFFSET 0x18 + +// +// Symbol file definitions, current max size if 512K +// +#define SYMBOL_FILE_SIZE 0x80000 + +#define FV_IMAGES_TOP_ADDRESS 0x100000000 + +// +// Private data types +// +// +// Component information +// +typedef struct { + UINTN Size; + CHAR8 ComponentName[_MAX_PATH]; +} COMPONENT_INFO; + +// +// FV information holder +// +typedef struct { + EFI_PHYSICAL_ADDRESS BaseAddress; + EFI_GUID FvGuid; + UINTN Size; + CHAR8 FvName[_MAX_PATH]; + CHAR8 SymName[_MAX_PATH]; + EFI_FV_BLOCK_MAP_ENTRY FvBlocks[MAX_NUMBER_OF_FV_BLOCKS]; + EFI_FVB_ATTRIBUTES FvAttributes; + CHAR8 FvFiles[MAX_NUMBER_OF_FILES_IN_FV][_MAX_PATH]; + COMPONENT_INFO FvComponents[MAX_NUMBER_OF_COMPONENTS_IN_FV]; +} FV_INFO; + +// +// Private function prototypes +// +EFI_STATUS +ParseFvInf ( + IN MEMORY_FILE *InfFile, + IN FV_INFO *FvInfo + ) +; + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/Makefile new file mode 100644 index 0000000000..d3b43c0ab7 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/Makefile @@ -0,0 +1,109 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Common information +# + +INC=$(INC) \ + -I "$(EDK_TOOLS_COMMON)" + + + +# +# Target specific information +# + +TARGET_NAME=GenFvImage + +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_LIB = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).lib +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenFvImageExe.c" + +TARGET_EXE_INCLUDE = "$(TARGET_SOURCE_DIR)\GenFvImageExe.h" \ + "$(TARGET_SOURCE_DIR)\GenFvImageLib.h" \ + "$(EDK_TOOLS_COMMON)\ParseInf.h" \ + "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" + +TARGET_EXE_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" +TARGET_LIB_SOURCE = "$(TARGET_SOURCE_DIR)\GenFvImageLib.c" + +TARGET_LIB_INCLUDE = "$(TARGET_SOURCE_DIR)\GenFvImageLib.h" \ + "$(TARGET_SOURCE_DIR)\GenFvImageLibInternal.h" \ + "$(EDK_TOOLS_COMMON)\ParseInf.h" \ + "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Guid\FirmwareFileSystem\FirmwareFileSystem.h" + +TARGET_LIB_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_EXE_LIBS) $(TARGET_LIB) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_LIB) $(TARGET_EXE_LIBS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +# +# Build LIB +# + +$(TARGET_LIB): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj $(TARGET_LIB_LIBS) + $(LIB_EXE) $(LIB_FLAGS) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj $(MSVS_LINK_LIBPATHS) $(TARGET_LIB_LIBS) RPCRT4.lib /OUT:$(TARGET_LIB) + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj: $(TARGET_LIB_SOURCE) $(TARGET_LIB_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_LIB_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.obj + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Lib.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/Makefile new file mode 100644 index 0000000000..8c4addb43d --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/Makefile @@ -0,0 +1,95 @@ +#/*++ +# +# Copyright (c) 2006 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the GenPage utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=GenPage +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenPage.c" +TARGET_EXE_INCLUDE = "$(TARGET_SOURCE_DIR)\VirtualMemory.h" + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/VirtualMemory.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/VirtualMemory.h new file mode 100644 index 0000000000..d9d928f4e4 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/VirtualMemory.h @@ -0,0 +1,127 @@ +/*++ + +Copyright 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + VirtualMemory.h + +Abstract: + + x64 Long Mode Virtual Memory Management Definitions + + References: + 1) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 1:Basic Architecture, Intel + 2) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 2:Instruction Set Reference, Intel + 3) IA-32 Intel(R) Atchitecture Software Developer's Manual Volume 3:System Programmer's Guide, Intel + 4) AMD64 Architecture Programmer's Manual Volume 2: System Programming +--*/ + +#ifndef _VIRTUAL_MEMORY_H_ +#define _VIRTUAL_MEMORY_H_ + +#include "Tiano.h" + +#pragma pack(1) + +// +// Page-Map Level-4 Offset (PML4) and +// Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB +// + +typedef union { + struct { + UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User + UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Reserved:1; // Reserved + UINT64 MustBeZero:2; // Must Be Zero + UINT64 Available:3; // Available for use by system software + UINT64 PageTableBaseAddress:40; // Page Table Base Address + UINT64 AvabilableHigh:11; // Available for use by system software + UINT64 Nx:1; // No Execute bit + } Bits; + UINT64 Uint64; +} X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K; + +// +// Page-Directory Offset 4K +// +typedef union { + struct { + UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User + UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Reserved:1; // Reserved + UINT64 MustBeZero:1; // Must Be Zero + UINT64 Reserved2:1; // Reserved + UINT64 Available:3; // Available for use by system software + UINT64 PageTableBaseAddress:40; // Page Table Base Address + UINT64 AvabilableHigh:11; // Available for use by system software + UINT64 Nx:1; // No Execute bit + } Bits; + UINT64 Uint64; +} X64_PAGE_DIRECTORY_ENTRY_4K; + +// +// Page Table Entry 4K +// +typedef union { + struct { + UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User + UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page + UINT64 PAT:1; // 0 = Ignore Page Attribute Table + UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write + UINT64 Available:3; // Available for use by system software + UINT64 PageTableBaseAddress:40; // Page Table Base Address + UINT64 AvabilableHigh:11; // Available for use by system software + UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution + } Bits; + UINT64 Uint64; +} X64_PAGE_TABLE_ENTRY_4K; + + +// +// Page Table Entry 2MB +// +typedef union { + struct { + UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory + UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write + UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User + UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching + UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached + UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU) + UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page + UINT64 MustBe1:1; // Must be 1 + UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write + UINT64 Available:3; // Available for use by system software + UINT64 PAT:1; // + UINT64 MustBeZero:8; // Must be zero; + UINT64 PageTableBaseAddress:31; // Page Table Base Address + UINT64 AvabilableHigh:11; // Available for use by system software + UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution + } Bits; + UINT64 Uint64; +} X64_PAGE_TABLE_ENTRY_2M; + +#pragma pack() + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/genpage.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/genpage.c new file mode 100644 index 0000000000..7085f198aa --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenPage/genpage.c @@ -0,0 +1,344 @@ +/*++ + +Copyright 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + GenPage.c + +Abstract: + Pre-Create a 4G page table (2M pages). + It's used in DUET x64 build needed to enter LongMode. + + Create 4G page table (2M pages) + + Linear Address + 63 48 47 39 38 30 29 21 20 0 + +--------+-------+---------------+-----------+-----------------------------+ + PML4 Directory-Ptr Directory Offset + + Paging-Structures := + PML4 + ( + Directory-Ptr Directory {512} + ) {4} +--*/ + +#include +#include +#include "VirtualMemory.h" + +void +memset (void *, char, long); + +unsigned int +xtoi (char *); + +#define EFI_PAGE_BASE_OFFSET_IN_LDR 0x70000 +#define EFI_PAGE_BASE_ADDRESS (EFI_PAGE_BASE_OFFSET_IN_LDR + 0x20000) + +unsigned int gPageTableBaseAddress = EFI_PAGE_BASE_ADDRESS; +unsigned int gPageTableOffsetInFile = EFI_PAGE_BASE_OFFSET_IN_LDR; + +#define EFI_MAX_ENTRY_NUM 512 + +#define EFI_PML4_ENTRY_NUM 1 +#define EFI_PDPTE_ENTRY_NUM 4 +#define EFI_PDE_ENTRY_NUM EFI_MAX_ENTRY_NUM + +#define EFI_PML4_PAGE_NUM 1 +#define EFI_PDPTE_PAGE_NUM EFI_PML4_ENTRY_NUM +#define EFI_PDE_PAGE_NUM (EFI_PML4_ENTRY_NUM * EFI_PDPTE_ENTRY_NUM) + +#define EFI_PAGE_NUMBER (EFI_PML4_PAGE_NUM + EFI_PDPTE_PAGE_NUM + EFI_PDE_PAGE_NUM) + +#define EFI_SIZE_OF_PAGE 0x1000 +#define EFI_PAGE_SIZE_2M 0x200000 + +#define CONVERT_BIN_PAGE_ADDRESS(a) ((UINT8 *) a - PageTable + gPageTableBaseAddress) + + +void * +CreateIdentityMappingPageTables ( + void + ) +/*++ + +Routine Description: + To create 4G PAE 2M pagetable + +Return: + void * - buffer containing created pagetable + +--*/ +{ + UINT64 PageAddress; + UINT8 *PageTable; + UINT8 *PageTablePtr; + int PML4Index; + int PDPTEIndex; + int PDEIndex; + X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *PageMapLevel4Entry; + X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *PageDirectoryPointerEntry; + X64_PAGE_TABLE_ENTRY_2M *PageDirectoryEntry2MB; + + PageTable = (void *)malloc (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE); + memset (PageTable, 0, (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE)); + PageTablePtr = PageTable; + + PageAddress = 0; + + // + // Page Table structure 3 level 2MB. + // + // Page-Map-Level-4-Table : bits 47-39 + // Page-Directory-Pointer-Table : bits 38-30 + // + // Page Table 2MB : Page-Directory(2M) : bits 29-21 + // + // + + PageMapLevel4Entry = (X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *)PageTablePtr; + + for (PML4Index = 0; PML4Index < EFI_PML4_ENTRY_NUM; PML4Index++, PageMapLevel4Entry++) { + // + // Each Page-Map-Level-4-Table Entry points to the base address of a Page-Directory-Pointer-Table Entry + // + PageTablePtr += EFI_SIZE_OF_PAGE; + PageDirectoryPointerEntry = (X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *)PageTablePtr; + + // + // Make a Page-Map-Level-4-Table Entry + // + PageMapLevel4Entry->Uint64 = (UINT64)(UINT32)(CONVERT_BIN_PAGE_ADDRESS (PageDirectoryPointerEntry)); + PageMapLevel4Entry->Bits.ReadWrite = 1; + PageMapLevel4Entry->Bits.Present = 1; + + for (PDPTEIndex = 0; PDPTEIndex < EFI_PDPTE_ENTRY_NUM; PDPTEIndex++, PageDirectoryPointerEntry++) { + // + // Each Page-Directory-Pointer-Table Entry points to the base address of a Page-Directory Entry + // + PageTablePtr += EFI_SIZE_OF_PAGE; + PageDirectoryEntry2MB = (X64_PAGE_TABLE_ENTRY_2M *)PageTablePtr; + + // + // Make a Page-Directory-Pointer-Table Entry + // + PageDirectoryPointerEntry->Uint64 = (UINT64)(UINT32)(CONVERT_BIN_PAGE_ADDRESS (PageDirectoryEntry2MB)); + PageDirectoryPointerEntry->Bits.ReadWrite = 1; + PageDirectoryPointerEntry->Bits.Present = 1; + + for (PDEIndex = 0; PDEIndex < EFI_PDE_ENTRY_NUM; PDEIndex++, PageDirectoryEntry2MB++) { + // + // Make a Page-Directory Entry + // + PageDirectoryEntry2MB->Uint64 = (UINT64)PageAddress; + PageDirectoryEntry2MB->Bits.ReadWrite = 1; + PageDirectoryEntry2MB->Bits.Present = 1; + PageDirectoryEntry2MB->Bits.MustBe1 = 1; + + PageAddress += EFI_PAGE_SIZE_2M; + } + } + } + + return PageTable; +} + +int +GenBinPage ( + void *BaseMemory, + char *NoPageFileName, + char *PageFileName + ) +/*++ + +Routine Description: + Write the buffer containing page table to file at a specified offset. + Here the offset is defined as EFI_PAGE_BASE_OFFSET_IN_LDR. + +Arguments: + BaseMemory - buffer containing page table + NoPageFileName - file to write page table + PageFileName - file save to after writing + +return: + 0 : successful + -1 : failed + +--*/ +{ + FILE *PageFile; + FILE *NoPageFile; + UINT8 Data; + unsigned long FileSize; + + // + // Open files + // + PageFile = fopen (PageFileName, "w+b"); + if (PageFile == NULL) { + fprintf (stderr, "GenBinPage: Could not open file %s\n", PageFileName); + return -1; + } + + NoPageFile = fopen (NoPageFileName, "r+b"); + if (NoPageFile == NULL) { + fprintf (stderr, "GenBinPage: Could not open file %s\n", NoPageFileName); + fclose (PageFile); + return -1; + } + + // + // Check size - should not be great than EFI_PAGE_BASE_OFFSET_IN_LDR + // + fseek (NoPageFile, 0, SEEK_END); + FileSize = ftell (NoPageFile); + fseek (NoPageFile, 0, SEEK_SET); + if (FileSize > gPageTableOffsetInFile) { + fprintf (stderr, "GenBinPage: file size too large - 0x%x\n", FileSize); + fclose (PageFile); + fclose (NoPageFile); + return -1; + } + + // + // Write data + // + while (fread (&Data, sizeof(UINT8), 1, NoPageFile)) { + fwrite (&Data, sizeof(UINT8), 1, PageFile); + } + + // + // Write PageTable + // + fseek (PageFile, gPageTableOffsetInFile, SEEK_SET); + fwrite (BaseMemory, (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE), 1, PageFile); + + // + // Close files + // + fclose (PageFile); + fclose (NoPageFile); + + return 0; +} + +int +main ( + int argc, + char **argv + ) +{ + void *BaseMemory; + int result; + + // + // Check parameter + // + if ((argc != 3) && (argc != 5)) { + printf ("Usage: GenPage.exe NoPageFile PageFile [ ]\n"); + return 1; + } + + // + // Get PageTable parameter, if have + // + if (argc == 5) { + gPageTableBaseAddress = xtoi (argv[3]); + gPageTableOffsetInFile = xtoi (argv[4]); + } + + // + // Create X64 page table + // + BaseMemory = CreateIdentityMappingPageTables (); + + // + // Add page table to binary file + // + result = GenBinPage (BaseMemory, argv[1], argv[2]); + if (result < 0) { + return 1; + } + + return 0; +} + +unsigned int +xtoi ( + char *str + ) +/*++ + +Routine Description: + + Convert hex string to uint + +Arguments: + + Str - The string + +Returns: + +--*/ +{ + unsigned int u; + char c; + unsigned int m; + + if (str == NULL) { + return 0; + } + + m = (unsigned int) -1 >> 4; + // + // skip preceeding white space + // + while (*str && *str == ' ') { + str += 1; + } + // + // skip preceeding zeros + // + while (*str && *str == '0') { + str += 1; + } + // + // skip preceeding white space + // + if (*str && (*str == 'x' || *str == 'X')) { + str += 1; + } + // + // convert hex digits + // + u = 0; + c = *(str++); + while (c) { + if (c >= 'a' && c <= 'f') { + c -= 'a' - 'A'; + } + + if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) { + if (u > m) { + return (unsigned int) -1; + } + + u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0'); + } else { + break; + } + + c = *(str++); + } + + return u; +} + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c new file mode 100644 index 0000000000..61ce9caafa --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c @@ -0,0 +1,1000 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenSection.c + +Abstract: + + Creates output file that is a properly formed section per the FV spec. + +--*/ + +#include "TianoCommon.h" +#include "EfiImageFormat.h" +#include "Compress.h" +#include "EfiCustomizedCompress.h" +#include "Crc32.h" +#include "EfiUtilityMsgs.h" + +#include +#include +#include + +#include "GenSection.h" + +#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction) + +#define UTILITY_NAME "GenSection" + +#define PARAMETER_NOT_SPECIFIED "Parameter not specified" +#define MAXIMUM_INPUT_FILE_NUM 10 +#define MAX_SECTION_SIZE 0x1000000 + +char *SectionTypeName[] = { + NULL, // 0x00 - reserved + "EFI_SECTION_COMPRESSION", // 0x01 + "EFI_SECTION_GUID_DEFINED", // 0x02 + NULL, // 0x03 - reserved + NULL, // 0x04 - reserved + NULL, // 0x05 - reserved + NULL, // 0x06 - reserved + NULL, // 0x07 - reserved + NULL, // 0x08 - reserved + NULL, // 0x09 - reserved + NULL, // 0x0A - reserved + NULL, // 0x0B - reserved + NULL, // 0x0C - reserved + NULL, // 0x0D - reserved + NULL, // 0x0E - reserved + NULL, // 0x0F - reserved + "EFI_SECTION_PE32", // 0x10 + "EFI_SECTION_PIC", // 0x11 + "EFI_SECTION_TE", // 0x12 + "EFI_SECTION_DXE_DEPEX", // 0x13 + "EFI_SECTION_VERSION", // 0x14 + "EFI_SECTION_USER_INTERFACE", // 0x15 + "EFI_SECTION_COMPATIBILITY16", // 0x16 + "EFI_SECTION_FIRMWARE_VOLUME_IMAGE", // 0x17 + "EFI_SECTION_FREEFORM_SUBTYPE_GUID", // 0x18 + "EFI_SECTION_RAW", // 0x19 + NULL, // 0x1A + "EFI_SECTION_PEI_DEPEX" // 0x1B +}; + +char *CompressionTypeName[] = { "NONE", "STANDARD" }; +char *GUIDedSectionTypeName[] = { "CRC32" }; +EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID; + +static +VOID +PrintUsageMessage ( + VOID + ) +{ + UINTN SectionType; + UINTN DisplayCount; + + printf ("Usage: "UTILITY_NAME " -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n"); + printf (" Where SectionType is one of the following section types:\n\n"); + + DisplayCount = 0; + for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) { + if (SectionTypeName[SectionType] != NULL) { + printf (" %s\n", SectionTypeName[SectionType]); + } + } + + printf ("\n and SectionType dependent parameters are as follows:\n\n"); + printf ( + " %s: -t < %s | %s >\n", + SectionTypeName[EFI_SECTION_COMPRESSION], + CompressionTypeName[EFI_NOT_COMPRESSED], + CompressionTypeName[EFI_STANDARD_COMPRESSION] + ); + printf ( + " %s: -t < %s >\n"" // Currently only CRC32 is supported\n\n", + SectionTypeName[EFI_SECTION_GUID_DEFINED], + GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED] + ); + printf ( + " %s: -v VersionNumber\n"" [-a \"Version string\"]\n\n", + SectionTypeName[EFI_SECTION_VERSION] + ); + printf ( + " %s: -a \"Human readable name\"\n\n", + SectionTypeName[EFI_SECTION_USER_INTERFACE] + ); +} + +VOID +Ascii2UnicodeWriteString ( + char *String, + FILE *OutFile, + BOOLEAN WriteLangCode + ) +{ + UINTN Index; + UINT8 AsciiNull; + // + // BUGBUG need to get correct language code... + // + char *EnglishLangCode = "eng"; + AsciiNull = 0; + // + // first write the language code (english only) + // + if (WriteLangCode) { + fwrite (EnglishLangCode, 1, 4, OutFile); + } + // + // Next, write out the string... Convert ASCII to Unicode in the process. + // + Index = 0; + do { + fwrite (&String[Index], 1, 1, OutFile); + fwrite (&AsciiNull, 1, 1, OutFile); + } while (String[Index++] != 0); +} + +STATUS +GenSectionCommonLeafSection ( + char **InputFileName, + int InputFileNum, + UINTN SectionType, + FILE *OutFile + ) +/*++ + +Routine Description: + + Generate a leaf section of type other than EFI_SECTION_VERSION + and EFI_SECTION_USER_INTERFACE. Input file must be well formed. + The function won't validate the input file's contents. For + common leaf sections, the input file may be a binary file. + The utility will add section header to the file. + +Arguments: + + InputFileName - Name of the input file. + + InputFileNum - Number of input files. Should be 1 for leaf section. + + SectionType - A valid section type string + + OutFile - Output file handle + +Returns: + + STATUS_ERROR - can't continue + STATUS_SUCCESS - successful return + +--*/ +{ + UINT64 InputFileLength; + FILE *InFile; + UINT8 *Buffer; + INTN TotalLength; + EFI_COMMON_SECTION_HEADER CommonSect; + STATUS Status; + + if (InputFileNum > 1) { + Error (NULL, 0, 0, "invalid parameter", "more than one input file specified"); + return STATUS_ERROR; + } else if (InputFileNum < 1) { + Error (NULL, 0, 0, "no input file specified", NULL); + return STATUS_ERROR; + } + // + // Open the input file + // + InFile = fopen (InputFileName[0], "rb"); + if (InFile == NULL) { + Error (NULL, 0, 0, InputFileName[0], "failed to open input file"); + return STATUS_ERROR; + } + + Status = STATUS_ERROR; + Buffer = NULL; + // + // Seek to the end of the input file so we can determine its size + // + fseek (InFile, 0, SEEK_END); + fgetpos (InFile, &InputFileLength); + fseek (InFile, 0, SEEK_SET); + // + // Fill in the fields in the local section header structure + // + CommonSect.Type = (EFI_SECTION_TYPE) SectionType; + TotalLength = sizeof (CommonSect) + (INTN) InputFileLength; + // + // Size must fit in 3 bytes + // + if (TotalLength >= MAX_SECTION_SIZE) { + Error (NULL, 0, 0, InputFileName[0], "file size (0x%X) exceeds section size limit(%dM).", TotalLength, MAX_SECTION_SIZE>>20); + goto Done; + } + // + // Now copy the size into the section header and write out the section header + // + memcpy (&CommonSect.Size, &TotalLength, 3); + fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile); + // + // Allocate a buffer to read in the contents of the input file. Then + // read it in as one block and write it to the output file. + // + if (InputFileLength != 0) { + Buffer = (UINT8 *) malloc ((size_t) InputFileLength); + if (Buffer == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + goto Done; + } + + if (fread (Buffer, (size_t) InputFileLength, 1, InFile) != 1) { + Error (NULL, 0, 0, InputFileName[0], "failed to read contents of file"); + goto Done; + } + + if (fwrite (Buffer, (size_t) InputFileLength, 1, OutFile) != 1) { + Error (NULL, 0, 0, "failed to write to output file", NULL); + goto Done; + } + } + + Status = STATUS_SUCCESS; +Done: + fclose (InFile); + if (Buffer != NULL) { + free (Buffer); + } + + return Status; +} + +EFI_STATUS +GetSectionContents ( + char **InputFileName, + int InputFileNum, + UINT8 *FileBuffer, + UINTN *BufferLength + ) +/*++ + +Routine Description: + + Get the contents of all section files specified in InputFileName + into FileBuffer. + +Arguments: + + InputFileName - Name of the input file. + + InputFileNum - Number of input files. Should be at least 1. + + FileBuffer - Output buffer to contain data + + BufferLength - On input, this is size of the FileBuffer. + On output, this is the actual length of the data. + +Returns: + + EFI_SUCCESS on successful return + EFI_INVALID_PARAMETER if InputFileNum is less than 1 or BufferLength point is NULL. + EFI_ABORTED if unable to open input file. + EFI_BUFFER_TOO_SMALL FileBuffer is not enough to contain all file data. +--*/ +{ + UINTN Size; + fpos_t FileSize; + INTN Index; + FILE *InFile; + + if (InputFileNum < 1) { + Error (NULL, 0, 0, "must specify at least one input file", NULL); + return EFI_INVALID_PARAMETER; + } + + if (BufferLength == NULL) { + Error (NULL, 0, 0, "BufferLength can't be NULL", NULL); + return EFI_INVALID_PARAMETER; + } + + Size = 0; + // + // Go through our array of file names and copy their contents + // to the output buffer. + // + for (Index = 0; Index < InputFileNum; Index++) { + InFile = fopen (InputFileName[Index], "rb"); + if (InFile == NULL) { + Error (NULL, 0, 0, InputFileName[Index], "failed to open input file"); + return EFI_ABORTED; + } + + fseek (InFile, 0, SEEK_END); + fgetpos (InFile, &FileSize); + fseek (InFile, 0, SEEK_SET); + // + // Now read the contents of the file into the buffer + // Buffer must be enough to contain the file content. + // + if (FileSize > 0 && FileBuffer != NULL && (Size + (UINTN) FileSize) <= *BufferLength) { + if (fread (FileBuffer + Size, (size_t) FileSize, 1, InFile) != 1) { + Error (NULL, 0, 0, InputFileName[Index], "failed to read contents of input file"); + fclose (InFile); + return EFI_ABORTED; + } + } + + fclose (InFile); + Size += (UINTN) FileSize; + // + // make sure section ends on a DWORD boundary + // + while ((Size & 0x03) != 0) { + if (FileBuffer != NULL && Size < *BufferLength) { + FileBuffer[Size] = 0; + } + Size++; + } + } + + if (Size > *BufferLength) { + *BufferLength = Size; + return EFI_BUFFER_TOO_SMALL; + } else { + *BufferLength = Size; + return EFI_SUCCESS; + } +} + +EFI_STATUS +GenSectionCompressionSection ( + char **InputFileName, + int InputFileNum, + UINTN SectionType, + UINTN SectionSubType, + FILE *OutFile + ) +/*++ + +Routine Description: + + Generate an encapsulating section of type EFI_SECTION_COMPRESSION + Input file must be already sectioned. The function won't validate + the input files' contents. Caller should hand in files already + with section header. + +Arguments: + + InputFileName - Name of the input file. + + InputFileNum - Number of input files. Should be at least 1. + + SectionType - Section type to generate. Should be + EFI_SECTION_COMPRESSION + + SectionSubType - Specify the compression algorithm requested. + + OutFile - Output file handle + +Returns: + + EFI_SUCCESS on successful return + EFI_INVALID_PARAMETER if InputFileNum is less than 1 + EFI_ABORTED if unable to open input file. + EFI_OUT_OF_RESOURCES No resource to complete the operation. +--*/ +{ + UINTN TotalLength; + UINTN InputLength; + UINTN CompressedLength; + UINT8 *FileBuffer; + UINT8 *OutputBuffer; + EFI_STATUS Status; + EFI_COMPRESSION_SECTION CompressionSect; + COMPRESS_FUNCTION CompressFunction; + + if (SectionType != EFI_SECTION_COMPRESSION) { + Error (NULL, 0, 0, "parameter must be EFI_SECTION_COMPRESSION", NULL); + return EFI_INVALID_PARAMETER; + } + + InputLength = 0; + FileBuffer = NULL; + OutputBuffer = NULL; + CompressedLength = 0; + // + // read all input file contents into a buffer + // first get the size of all file contents + // + Status = GetSectionContents ( + InputFileName, + InputFileNum, + FileBuffer, + &InputLength + ); + + if (Status == EFI_BUFFER_TOO_SMALL) { + FileBuffer = (UINT8 *) malloc (InputLength); + if (FileBuffer == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory"); + return EFI_OUT_OF_RESOURCES; + } + // + // read all input file contents into a buffer + // + Status = GetSectionContents ( + InputFileName, + InputFileNum, + FileBuffer, + &InputLength + ); + } + + if (EFI_ERROR (Status)) { + if (FileBuffer != NULL) { + free (FileBuffer); + } + return Status; + } + + CompressFunction = NULL; + + // + // Now data is in FileBuffer, compress the data + // + switch (SectionSubType) { + case EFI_NOT_COMPRESSED: + CompressedLength = InputLength; + break; + + case EFI_STANDARD_COMPRESSION: + CompressFunction = (COMPRESS_FUNCTION) TianoCompress; + break; + + case EFI_CUSTOMIZED_COMPRESSION: + CompressFunction = (COMPRESS_FUNCTION) CustomizedCompress; + break; + + default: + Error (NULL, 0, 0, "unknown compression type", NULL); + free (FileBuffer); + return EFI_ABORTED; + } + + if (CompressFunction != NULL) { + + Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength); + if (Status == EFI_BUFFER_TOO_SMALL) { + OutputBuffer = malloc (CompressedLength); + if (!OutputBuffer) { + free (FileBuffer); + return EFI_OUT_OF_RESOURCES; + } + + Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength); + } + + free (FileBuffer); + FileBuffer = OutputBuffer; + + if (EFI_ERROR (Status)) { + if (FileBuffer != NULL) { + free (FileBuffer); + } + + return Status; + } + } + + TotalLength = CompressedLength + sizeof (EFI_COMPRESSION_SECTION); + if (TotalLength >= MAX_SECTION_SIZE) { + Error (__FILE__, __LINE__, 0, "input error", "The size of all files exceeds section size limit(%dM).", MAX_SECTION_SIZE>>20); + if (FileBuffer != NULL) { + free (FileBuffer); + } + if (OutputBuffer != NULL) { + free (OutputBuffer); + } + return STATUS_ERROR; + } + // + // Add the section header for the compressed data + // + CompressionSect.CommonHeader.Type = (EFI_SECTION_TYPE) SectionType; + CompressionSect.CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff); + CompressionSect.CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8); + CompressionSect.CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16); + CompressionSect.CompressionType = (UINT8) SectionSubType; + CompressionSect.UncompressedLength = InputLength; + + fwrite (&CompressionSect, sizeof (CompressionSect), 1, OutFile); + fwrite (FileBuffer, CompressedLength, 1, OutFile); + free (FileBuffer); + return EFI_SUCCESS; +} + +EFI_STATUS +GenSectionGuidDefinedSection ( + char **InputFileName, + int InputFileNum, + UINTN SectionType, + UINTN SectionSubType, + FILE *OutFile + ) +/*++ + +Routine Description: + + Generate an encapsulating section of type EFI_SECTION_GUID_DEFINED + Input file must be already sectioned. The function won't validate + the input files' contents. Caller should hand in files already + with section header. + +Arguments: + + InputFileName - Name of the input file. + + InputFileNum - Number of input files. Should be at least 1. + + SectionType - Section type to generate. Should be + EFI_SECTION_GUID_DEFINED + + SectionSubType - Specify the authentication algorithm requested. + + OutFile - Output file handle + +Returns: + + EFI_SUCCESS on successful return + EFI_INVALID_PARAMETER if InputFileNum is less than 1 + EFI_ABORTED if unable to open input file. + EFI_OUT_OF_RESOURCES No resource to complete the operation. + +--*/ +{ + INTN TotalLength; + INTN InputLength; + UINT8 *FileBuffer; + UINT32 Crc32Checksum; + EFI_STATUS Status; + CRC32_SECTION_HEADER Crc32GuidSect; + + if (SectionType != EFI_SECTION_GUID_DEFINED) { + Error (NULL, 0, 0, "parameter must be EFI_SECTION_GUID_DEFINED", NULL); + return EFI_INVALID_PARAMETER; + } + + InputLength = 0; + FileBuffer = NULL; + // + // read all input file contents into a buffer + // first get the size of all file contents + // + Status = GetSectionContents ( + InputFileName, + InputFileNum, + FileBuffer, + &InputLength + ); + + if (Status == EFI_BUFFER_TOO_SMALL) { + FileBuffer = (UINT8 *) malloc (InputLength); + if (FileBuffer == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory"); + return EFI_OUT_OF_RESOURCES; + } + // + // read all input file contents into a buffer + // + Status = GetSectionContents ( + InputFileName, + InputFileNum, + FileBuffer, + &InputLength + ); + } + + if (EFI_ERROR (Status)) { + if (FileBuffer != NULL) { + free (FileBuffer); + } + return Status; + } + // + // Now data is in FileBuffer + // + switch (SectionSubType) { + case EFI_SECTION_CRC32_GUID_DEFINED: + Crc32Checksum = 0; + CalculateCrc32 (FileBuffer, InputLength, &Crc32Checksum); + if (EFI_ERROR (Status)) { + free (FileBuffer); + return Status; + } + + TotalLength = InputLength + CRC32_SECTION_HEADER_SIZE; + if (TotalLength >= MAX_SECTION_SIZE) { + Error (__FILE__, __LINE__, 0, "input error", "The size of all files exceeds section size limit(%dM).", MAX_SECTION_SIZE>>20); + free (FileBuffer); + return STATUS_ERROR; + } + + Crc32GuidSect.GuidSectionHeader.CommonHeader.Type = (EFI_SECTION_TYPE) SectionType; + Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff); + Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8); + Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16); + memcpy (&(Crc32GuidSect.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID)); + Crc32GuidSect.GuidSectionHeader.Attributes = EFI_GUIDED_SECTION_AUTH_STATUS_VALID; + Crc32GuidSect.GuidSectionHeader.DataOffset = CRC32_SECTION_HEADER_SIZE; + Crc32GuidSect.CRC32Checksum = Crc32Checksum; + + break; + + default: + Error (NULL, 0, 0, "invalid parameter", "unknown GUID defined type"); + free (FileBuffer); + return EFI_ABORTED; + } + + fwrite (&Crc32GuidSect, sizeof (Crc32GuidSect), 1, OutFile); + fwrite (FileBuffer, InputLength, 1, OutFile); + + free (FileBuffer); + + return EFI_SUCCESS; +} + +int +main ( + int argc, + char *argv[] + ) +/*++ + +Routine Description: + + Main + +Arguments: + + command line parameters + +Returns: + + EFI_SUCCESS Section header successfully generated and section concatenated. + EFI_ABORTED Could not generate the section + EFI_OUT_OF_RESOURCES No resource to complete the operation. + +--*/ +{ + INTN Index; + INTN VersionNumber; + UINTN SectionType; + UINTN SectionSubType; + BOOLEAN InputFileRequired; + BOOLEAN SubTypeRequired; + FILE *InFile; + FILE *OutFile; + INTN InputFileNum; + + char **InputFileName; + char *OutputFileName; + char AuxString[500] = { 0 }; + + char *ParamSectionType; + char *ParamSectionSubType; + char *ParamLength; + char *ParamVersion; + char *ParamDigitalSignature; + + EFI_STATUS Status; + EFI_COMMON_SECTION_HEADER CommonSect; + + InputFileName = NULL; + OutputFileName = PARAMETER_NOT_SPECIFIED; + ParamSectionType = PARAMETER_NOT_SPECIFIED; + ParamSectionSubType = PARAMETER_NOT_SPECIFIED; + ParamLength = PARAMETER_NOT_SPECIFIED; + ParamVersion = PARAMETER_NOT_SPECIFIED; + ParamDigitalSignature = PARAMETER_NOT_SPECIFIED; + Status = EFI_SUCCESS; + + VersionNumber = 0; + SectionType = 0; + SectionSubType = 0; + InputFileRequired = TRUE; + SubTypeRequired = FALSE; + InFile = NULL; + OutFile = NULL; + InputFileNum = 0; + Status = EFI_SUCCESS; + + SetUtilityName (UTILITY_NAME); + if (argc == 1) { + PrintUsageMessage (); + return STATUS_ERROR; + } + // + // Parse command line + // + Index = 1; + while (Index < argc) { + if (_strcmpi (argv[Index], "-i") == 0) { + // + // Input File found + // + Index++; + InputFileName = (char **) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof (char *)); + if (InputFileName == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory"); + return EFI_OUT_OF_RESOURCES; + } + + memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *))); + InputFileName[InputFileNum] = argv[Index]; + InputFileNum++; + Index++; + // + // Parse subsequent parameters until another switch is encountered + // + while ((Index < argc) && (argv[Index][0] != '-')) { + if ((InputFileNum % MAXIMUM_INPUT_FILE_NUM) == 0) { + // + // InputFileName buffer too small, need to realloc + // + InputFileName = (char **) realloc ( + InputFileName, + (InputFileNum + MAXIMUM_INPUT_FILE_NUM) * sizeof (char *) + ); + if (InputFileName == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory"); + return EFI_OUT_OF_RESOURCES; + } + + memset (&(InputFileName[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *))); + } + + InputFileName[InputFileNum] = argv[Index]; + InputFileNum++; + Index++; + } + + } + + if (_strcmpi (argv[Index], "-o") == 0) { + // + // Output file found + // + Index++; + OutputFileName = argv[Index]; + } else if (_strcmpi (argv[Index], "-s") == 0) { + // + // Section Type found + // + Index++; + ParamSectionType = argv[Index]; + } else if (_strcmpi (argv[Index], "-t") == 0) { + // + // Compression or Authentication type + // + Index++; + ParamSectionSubType = argv[Index]; + } else if (_strcmpi (argv[Index], "-l") == 0) { + // + // Length + // + Index++; + ParamLength = argv[Index]; + } else if (_strcmpi (argv[Index], "-v") == 0) { + // + // VersionNumber + // + Index++; + ParamVersion = argv[Index]; + } else if (_strcmpi (argv[Index], "-a") == 0) { + // + // Aux string + // + Index++; + // + // Note, the MSVC C-Start parses out and consolidates quoted strings from the command + // line. Quote characters are stripped. If this tool is ported to other environments + // this will need to be taken into account + // + strncpy (AuxString, argv[Index], 499); + } else if (_strcmpi (argv[Index], "-d") == 0) { + // + // Digital signature for EFI_TEST_AUTHENTICAION (must be 0 or 1) + // + Index++; + ParamDigitalSignature = argv[Index]; + } else if (_strcmpi (argv[Index], "-?") == 0) { + PrintUsageMessage (); + return STATUS_ERROR; + } else { + Error (NULL, 0, 0, argv[Index], "unknown option"); + return GetUtilityStatus (); + } + + Index++; + } + // + // At this point, all command line parameters are verified as not being totally + // bogus. Next verify the command line parameters are complete and make + // sense... + // + if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPRESSION]) == 0) { + SectionType = EFI_SECTION_COMPRESSION; + SubTypeRequired = TRUE; + if (_stricmp (ParamSectionSubType, CompressionTypeName[EFI_NOT_COMPRESSED]) == 0) { + SectionSubType = EFI_NOT_COMPRESSED; + } else if (_stricmp (ParamSectionSubType, CompressionTypeName[EFI_STANDARD_COMPRESSION]) == 0) { + SectionSubType = EFI_STANDARD_COMPRESSION; + } else { + Error (NULL, 0, 0, ParamSectionSubType, "unknown compression type"); + PrintUsageMessage (); + return GetUtilityStatus (); + } + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_GUID_DEFINED]) == 0) { + SectionType = EFI_SECTION_GUID_DEFINED; + SubTypeRequired = TRUE; + if (_stricmp (ParamSectionSubType, GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]) == 0) { + SectionSubType = EFI_SECTION_CRC32_GUID_DEFINED; + } else { + Error (NULL, 0, 0, ParamSectionSubType, "unknown GUID defined section type", ParamSectionSubType); + PrintUsageMessage (); + return GetUtilityStatus (); + } + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PE32]) == 0) { + SectionType = EFI_SECTION_PE32; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PIC]) == 0) { + SectionType = EFI_SECTION_PIC; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_TE]) == 0) { + SectionType = EFI_SECTION_TE; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_DXE_DEPEX]) == 0) { + SectionType = EFI_SECTION_DXE_DEPEX; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_VERSION]) == 0) { + SectionType = EFI_SECTION_VERSION; + InputFileRequired = FALSE; + Index = sscanf (ParamVersion, "%d", &VersionNumber); + if (Index != 1 || VersionNumber < 0 || VersionNumber > 65565) { + Error (NULL, 0, 0, ParamVersion, "illegal version number"); + PrintUsageMessage (); + return GetUtilityStatus (); + } + + if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) { + AuxString[0] = 0; + } + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_USER_INTERFACE]) == 0) { + SectionType = EFI_SECTION_USER_INTERFACE; + InputFileRequired = FALSE; + if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) { + Error (NULL, 0, 0, "user interface string not specified", NULL); + PrintUsageMessage (); + return GetUtilityStatus (); + } + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPATIBILITY16]) == 0) { + SectionType = EFI_SECTION_COMPATIBILITY16; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FIRMWARE_VOLUME_IMAGE]) == 0) { + SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FREEFORM_SUBTYPE_GUID]) == 0) { + SectionType = EFI_SECTION_FREEFORM_SUBTYPE_GUID; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_RAW]) == 0) { + SectionType = EFI_SECTION_RAW; + } else if (_stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PEI_DEPEX]) == 0) { + SectionType = EFI_SECTION_PEI_DEPEX; + } else { + Error (NULL, 0, 0, ParamSectionType, "unknown section type"); + PrintUsageMessage (); + return GetUtilityStatus (); + } + // + // Open output file + // + OutFile = fopen (OutputFileName, "wb"); + if (OutFile == NULL) { + Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing"); + if (InFile != NULL) { + fclose (InFile); + } + + return GetUtilityStatus (); + } + // + // At this point, we've fully validated the command line, and opened appropriate + // files, so let's go and do what we've been asked to do... + // + // + // Within this switch, build and write out the section header including any + // section type specific pieces. If there's an input file, it's tacked on later + // + switch (SectionType) { + case EFI_SECTION_COMPRESSION: + Status = GenSectionCompressionSection ( + InputFileName, + InputFileNum, + SectionType, + SectionSubType, + OutFile + ); + break; + + case EFI_SECTION_GUID_DEFINED: + Status = GenSectionGuidDefinedSection ( + InputFileName, + InputFileNum, + SectionType, + SectionSubType, + OutFile + ); + break; + + case EFI_SECTION_VERSION: + CommonSect.Type = (EFI_SECTION_TYPE) SectionType; + + Index = sizeof (CommonSect); + // + // 2 characters for the build number + // + Index += 2; + // + // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null. + // + Index += (strlen (AuxString) * 2) + 2; + memcpy (&CommonSect.Size, &Index, 3); + fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile); + fwrite (&VersionNumber, 2, 1, OutFile); + Ascii2UnicodeWriteString (AuxString, OutFile, FALSE); + break; + + case EFI_SECTION_USER_INTERFACE: + CommonSect.Type = (EFI_SECTION_TYPE) SectionType; + Index = sizeof (CommonSect); + // + // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null. + // + Index += (strlen (AuxString) * 2) + 2; + memcpy (&CommonSect.Size, &Index, 3); + fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile); + Ascii2UnicodeWriteString (AuxString, OutFile, FALSE); + break; + + default: + // + // All other section types are caught by default (they're all the same) + // + Status = GenSectionCommonLeafSection ( + InputFileName, + InputFileNum, + SectionType, + OutFile + ); + break; + } + + if (InputFileName != NULL) { + free (InputFileName); + } + + fclose (OutFile); + // + // If we had errors, then delete the output file + // + if (GetUtilityStatus () == STATUS_ERROR) { + remove (OutputFileName); + } + + return GetUtilityStatus (); +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.h new file mode 100644 index 0000000000..24c1c4e34d --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.h @@ -0,0 +1,42 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GenSection.h + +Abstract: + + Header file for GenSection. + +--*/ + +// +// Module Coded to Tiano Coding Conventions +// +#ifndef _EFI_GEN_SECTION_H +#define _EFI_GEN_SECTION_H + +// +// External Files Referenced +// +#include "TianoCommon.h" +#include "EfiImageFormat.h" + +typedef struct { + EFI_GUID_DEFINED_SECTION GuidSectionHeader; + UINT32 CRC32Checksum; +} CRC32_SECTION_HEADER; + +#define EFI_SECTION_CRC32_GUID_DEFINED 0 +#define CRC32_SECTION_HEADER_SIZE (sizeof (CRC32_SECTION_HEADER)) + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/makefile new file mode 100644 index 0000000000..053d2376a0 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/makefile @@ -0,0 +1,82 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Common information +# +INC = $(INC) -I $(EDK_TOOLS_SOURCE)\Common + +LIBS = $(LIBS) $(EDK_TOOLS_OUTPUT)\CustomizedCompress.lib + +# +# Target specific information +# + +TARGET_NAME = GenSection +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\GenSection.c" +TARGET_EXE_LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" +TARGET_EXE_INCLUDE = "$(EDK_SOURCE)\Foundation\Include\TianoCommon.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareFileSystem.h" \ + "$(EDK_SOURCE)\Foundation\Framework\Include\EfiFirmwareVolumeHeader.h" \ + "$(EDK_TOOLS_COMMON)\ParseInf.h" + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(LIBS) $(TARGET_EXE_LIBS) + $(LINK) /DEBUG $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj $(TARGET_EXE_LIBS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/CommonUtils.h b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/CommonUtils.h new file mode 100644 index 0000000000..f7a331e5d7 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/CommonUtils.h @@ -0,0 +1,57 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + CommonUtils.h + +Abstract: + + Common utility defines and structure definitions. + +--*/ + +#ifndef _COMMON_UTILS_H_ +#define _COMMON_UTILS_H_ + +// +// Basic types +// +typedef unsigned char UINT8; +typedef char INT8; +typedef unsigned short UINT16; +typedef unsigned int UINT32; + +typedef UINT8 BOOLEAN; +typedef UINT32 STATUS; + +#define TRUE 1 +#define FALSE 0 + +#define STATUS_SUCCESS 0 +#define STATUS_WARNING 1 +#define STATUS_ERROR 2 + +// +// Linked list of strings +// +typedef struct _STRING_LIST { + struct _STRING_LIST *Next; + char *Str; +} STRING_LIST; + +int +CreateGuidList ( + INT8 *OutFileName + ) +; + +#endif // #ifndef _COMMON_UTILS_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.c new file mode 100644 index 0000000000..dc7c7c58a9 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.c @@ -0,0 +1,285 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileSearch.c + +Abstract: + + Module used to support file searches on the system. + +--*/ + +#include + +#include "CommonUtils.h" +#include "FileSearch.h" +#include "UtilsMsgs.h" + +// +// Internal file search flag for sanity checks +// +#define FILE_SEARCH_STARTED 0x8000 +#define FILE_SEARCH_INITED 0x4000 + +static +BOOLEAN +FileSearchMeetsCriteria ( + FILE_SEARCH_DATA *FSData + ); + +/*****************************************************************************/ +STATUS +FileSearchInit ( + FILE_SEARCH_DATA *FSData + ) +{ + memset ((char *) FSData, 0, sizeof (FILE_SEARCH_DATA)); + FSData->Handle = INVALID_HANDLE_VALUE; + FSData->FileSearchFlags = FILE_SEARCH_INITED; + FSData->FileName[0] = 0; + return STATUS_SUCCESS; +} + +STATUS +FileSearchStart ( + FILE_SEARCH_DATA *FSData, + char *FileMask, + UINT32 SearchFlags + ) +{ + BOOLEAN Done; + + // + // Save their flags, and set a flag to indicate that they called this + // start function so we can perform extended checking in the other + // routines we have in this module. + // + FSData->FileSearchFlags |= (SearchFlags | FILE_SEARCH_STARTED); + FSData->FileName[0] = 0; + + // + // Begin the search + // + FSData->Handle = FindFirstFile (FileMask, &(FSData->FindData)); + if (FSData->Handle == INVALID_HANDLE_VALUE) { + return STATUS_ERROR; + } + // + // Keep looping through until we find a file meeting the caller's + // criteria per the search flags + // + Done = FALSE; + while (!Done) { + // + // If we're done (we found a match) copy the file name found and return + // + Done = FileSearchMeetsCriteria (FSData); + if (Done) { + return STATUS_SUCCESS; + } + // + // Go on to next file + // + if (!FindNextFile (FSData->Handle, &(FSData->FindData))) { + return STATUS_NOT_FOUND; + } + } + // + // Not reached + // + return STATUS_NOT_FOUND; +} + +// +// Find the next file meeting their criteria and return it. +// +STATUS +FileSearchFindNext ( + FILE_SEARCH_DATA *FSData + ) +{ + BOOLEAN Done; + + Done = FALSE; + while (!Done) { + if (!FindNextFile (FSData->Handle, &(FSData->FindData))) { + return STATUS_NOT_FOUND; + } + // + // See if it matches their criteria + // + Done = FileSearchMeetsCriteria (FSData); + if (Done) { + return STATUS_SUCCESS; + } + } + // + // Not reached + // + return STATUS_NOT_FOUND; +} +// +// Perform any cleanup necessary to close down a search +// +STATUS +FileSearchDestroy ( + FILE_SEARCH_DATA *FSData + ) +{ + if (FSData->Handle != INVALID_HANDLE_VALUE) { + FindClose (FSData->Handle); + FSData->Handle = INVALID_HANDLE_VALUE; + } + + FSData->FileName[0] = 0; + FSData->FileSearchFlags = 0; + return STATUS_SUCCESS; +} + +static +BOOLEAN +FileSearchMeetsCriteria ( + FILE_SEARCH_DATA *FSData + ) +{ + BOOLEAN Status; + STRING_LIST *StrList; + UINT32 ExtLen; + UINT32 FileNameLen; + + Status = FALSE; + + // + // First clear the flag indicating this is neither a file or a + // directory. + // + FSData->FileFlags &= ~(FILE_SEARCH_DIR | FILE_SEARCH_FILE); + + // + // We found a file. See if it matches the user's search criteria. First + // check for this being a directory, and they want directories, and + // it's not "." and it's not ".." + // + if ((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && + (FSData->FileSearchFlags & FILE_SEARCH_DIR) && + (strcmp (FSData->FindData.cFileName, ".")) && + (strcmp (FSData->FindData.cFileName, "..")) + ) { + // + // Assume we'll make it past this check + // + Status = TRUE; + // + // If they have a list of exclude directories, then check for those + // + StrList = FSData->ExcludeDirs; + while (StrList != NULL) { + if (_stricmp (FSData->FindData.cFileName, StrList->Str) == 0) { + Status = FALSE; + break; + } + + StrList = StrList->Next; + } + // + // If we didn't fail due to excluded directories, then set the dir flag + // + if (Status) { + FSData->FileFlags |= FILE_SEARCH_DIR; + } + // + // Else check for a file, and they want files.... + // + } else if (((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) && + (FSData->FileSearchFlags & FILE_SEARCH_FILE) + ) { + // + // See if it's in our list of excluded files + // + Status = TRUE; + StrList = FSData->ExcludeFiles; + while (StrList != NULL) { + if (_stricmp (FSData->FindData.cFileName, StrList->Str) == 0) { + Status = FALSE; + break; + } + + StrList = StrList->Next; + } + + if (Status) { + // + // See if it's in our list of excluded file extensions + // + FileNameLen = strlen (FSData->FindData.cFileName); + StrList = FSData->ExcludeExtensions; + while (StrList != NULL) { + ExtLen = strlen (StrList->Str); + if (_stricmp ( + FSData->FindData.cFileName + FileNameLen - ExtLen, + StrList->Str + ) == 0) { + Status = FALSE; + break; + } + + StrList = StrList->Next; + } + } + + if (Status) { + FSData->FileFlags |= FILE_SEARCH_FILE; + } + } + // + // If it's a match, copy the filename into another field of the structure + // for portability. + // + if (Status) { + strcpy (FSData->FileName, FSData->FindData.cFileName); + } + + return Status; +} +// +// Exclude a list of subdirectories. +// +STATUS +FileSearchExcludeDirs ( + FILE_SEARCH_DATA *FSData, + STRING_LIST *StrList + ) +{ + FSData->ExcludeDirs = StrList; + return STATUS_SUCCESS; +} + +STATUS +FileSearchExcludeFiles ( + FILE_SEARCH_DATA *FSData, + STRING_LIST *StrList + ) +{ + FSData->ExcludeFiles = StrList; + return STATUS_SUCCESS; +} + +STATUS +FileSearchExcludeExtensions ( + FILE_SEARCH_DATA *FSData, + STRING_LIST *StrList + ) +{ + FSData->ExcludeExtensions = StrList; + return STATUS_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.h b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.h new file mode 100644 index 0000000000..bc40265366 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/FileSearch.h @@ -0,0 +1,108 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FileSearch.h + +Abstract: + + Header file to support file searching. + +--*/ + +#ifndef _FILE_SEARCH_H_ +#define _FILE_SEARCH_H_ + +// +// Since the file searching routines are OS dependent, put the +// necessary include paths in this header file so that the non-OS-dependent +// files don't need to include these windows-specific header files. +// +#include +#include +#include +#include +#include + +// +// Return codes of some of the file search routines +// +#define STATUS_NOT_FOUND 0x1000 + +// +// Flags for what to search for. Also used in the FileFlags return field. +// +#define FILE_SEARCH_DIR 0x0001 +#define FILE_SEARCH_FILE 0x0002 + +// +// Here's our class definition +// +typedef struct { + HANDLE Handle; + WIN32_FIND_DATA FindData; + UINT32 FileSearchFlags; // DIRS, FILES, etc + UINT32 FileFlags; + INT8 FileName[MAX_PATH]; // for portability + STRING_LIST *ExcludeDirs; + STRING_LIST *ExcludeFiles; + STRING_LIST *ExcludeExtensions; +} FILE_SEARCH_DATA; + +// +// Here's our member functions +// +STATUS +FileSearchInit ( + FILE_SEARCH_DATA *FSData + ) +; + +STATUS +FileSearchDestroy ( + FILE_SEARCH_DATA *FSData + ) +; + +STATUS +FileSearchStart ( + FILE_SEARCH_DATA *FSData, + char *FileMask, + UINT32 SearchFlags + ) +; + +STATUS +FileSearchFindNext ( + FILE_SEARCH_DATA *FSData + ) +; + +STATUS +FileSearchExcludeDirs ( + FILE_SEARCH_DATA *FSData, + STRING_LIST *StrList + ) +; +STATUS +FileSearchExcludeExtensions ( + FILE_SEARCH_DATA *FSData, + STRING_LIST *StrList + ) +; +STATUS +FileSearchExcludeFiles ( + FILE_SEARCH_DATA *FSData, + STRING_LIST *StrList + ) +; +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c new file mode 100644 index 0000000000..97d58925b4 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c @@ -0,0 +1,2417 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidChk.c + +Abstract: + + Parse files in a directory and subdirectories to find all guid definitions. + Then check them against each other to make sure there are no duplicates. + +--*/ + +#include +#include +#include +#include + +#include "CommonUtils.h" +#include "FileSearch.h" +#include "UtilsMsgs.h" + +#define MAX_LINE_LEN 1024 // we concatenate lines sometimes +// Define a structure that correlates filename extensions to an enumerated +// type. +// +#ifdef MAX_PATH +#undef MAX_PATH +#define MAX_PATH 1024 +#endif + +typedef struct { + INT8 *Extension; + INT8 ExtensionCode; +} FILE_TYPE_TABLE_ENTRY; + +#define FILE_EXTENSION_UNKNOWN 0 +#define FILE_EXTENSION_C 1 +#define FILE_EXTENSION_H 2 +#define FILE_EXTENSION_IA32_ASM 3 +#define FILE_EXTENSION_IA32_INC 4 +#define FILE_EXTENSION_IA64_ASM 5 +#define FILE_EXTENSION_IA64_INC 6 +#define FILE_EXTENSION_PKG 7 +#define FILE_EXTENSION_INF 8 + +FILE_TYPE_TABLE_ENTRY FileTypeTable[] = { + ".c", + FILE_EXTENSION_C, + ".h", + FILE_EXTENSION_H, + ".inc", + FILE_EXTENSION_IA32_INC, + ".asm", + FILE_EXTENSION_IA32_ASM, + ".s", + FILE_EXTENSION_IA64_ASM, + ".pkg", + FILE_EXTENSION_PKG, + ".inf", + FILE_EXTENSION_INF, + ".i", + FILE_EXTENSION_IA64_INC, + NULL, + 0 +}; + +typedef struct EFI_GUID { + UINT32 Data1; + UINT16 Data2; + UINT16 Data3; + UINT8 Data4[8]; +} EFI_GUID; + +typedef struct { + INT8 Data[8]; + INT8 DataLen; +} EFI_SIGNATURE; + +typedef struct _GUID_RECORD { + struct _GUID_RECORD *Next; + BOOLEAN Reported; + INT8 *FileName; + INT8 *SymName; + EFI_GUID Guid; +} GUID_RECORD; + +typedef struct _SIGNATURE_RECORD { + struct _SIGNATURE_RECORD *Next; + BOOLEAN Reported; + INT8 *FileName; + EFI_SIGNATURE Signature; +} SIGNATURE_RECORD; + +// +// Utility options +// +typedef struct { + INT8 DatabaseOutputFileName[MAX_PATH]; // with -b option + STRING_LIST *ExcludeDirs; // list of directory names not to process + STRING_LIST *ExcludeSubDirs; // list of directory names to not process subdirectories (build) + STRING_LIST *ExcludeFiles; // list of files to exclude (make.inf) + STRING_LIST *ExcludeExtensions; // list of filename extensions to exclude (.inf, .pkg) + BOOLEAN Verbose; + BOOLEAN PrintFound; + BOOLEAN CheckGuids; + BOOLEAN CheckSignatures; + BOOLEAN GuidXReference; +} OPTIONS; + +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ); + +static +VOID +Usage ( + VOID + ); + +static +STATUS +ProcessDirectory ( + INT8 *Path, + INT8 *DirectoryName + ); + +static +STATUS +ProcessFile ( + INT8 *DirectoryName, + INT8 *FileName + ); + +static +UINT32 +GetFileExtension ( + INT8 *FileName + ); + +static +UINT32 +SkipWhiteSpace ( + INT8 *Str + ); + +static +UINT32 +ValidSymbolName ( + INT8 *Name + ); + +static +STATUS +ProcessCFileGuids ( + INT8 *FileName + ); + +static +STATUS +AddSignature ( + INT8 *FileName, + INT8 *StrDef, + UINT32 SigSize + ); + +static +STATUS +ProcessCFileSigs ( + INT8 *FileName + ); + +static +STATUS +ProcessINFFileGuids ( + INT8 *FileName + ); + +static +STATUS +ProcessPkgFileGuids ( + INT8 *FileName + ); + +static +STATUS +ProcessIA32FileGuids ( + INT8 *FileName + ); + +static +STATUS +ProcessIA64FileGuids ( + INT8 *FileName + ); + +static +BOOLEAN +IsIA64GuidLine ( + INT8 *Line, + UINT32 *GuidHigh, + UINT32 *GuidLow, + BOOLEAN *Low, + INT8 *SymName + ); + +static +STATUS +AddGuid11 ( + INT8 *FileName, + UINT32 *Data, + INT8 *SymName + ); + +static +STATUS +AddPkgGuid ( + INT8 *FileName, + UINT32 *Data, + UINT64 *Data64 + ); + +static +STATUS +AddGuid16 ( + INT8 *FileName, + UINT32 *Data + ); + +static +STATUS +AddGuid64x2 ( + INT8 *FileName, + UINT32 DataHH, // Upper 32-bits of upper 64 bits of guid + UINT32 DataHL, // Lower 32-bits of upper 64 bits + UINT32 DataLH, + UINT32 DataLL, + INT8 *SymName + ); + +static +VOID +FreeGuids ( + VOID + ); + +static +VOID +FreeSigs ( + VOID + ); + +static +STATUS +CheckDuplicates ( + VOID + ); + +// +// static +// VOID +// ReportGuid ( +// INT8 *FileName, +// GUID_RECORD *FileRecord +// ); +// +static +VOID +FreeOptions ( + VOID + ); + +static +BOOLEAN +CheckGuidData ( + UINT32 *GuidData, + UINT32 DataCount + ); + +static +VOID +ConcatenateLines ( + FILE *Fptr, + INT8 *Line, + UINT32 Len + ); + +/**************************** GLOBALS ****************************************/ +static GUID_RECORD *gGuidList = NULL; +static SIGNATURE_RECORD *gSignatureList = NULL; +static OPTIONS gOptions; + +/*****************************************************************************/ +int +main ( + int Argc, + char *Argv[] + ) +{ + INT8 *Cwd; + STATUS Status; + + SetUtilityName ("GuidChk"); + // + // Get the current working directory and then process the command line + // arguments. + // + Cwd = _getcwd (NULL, 0); + Status = ProcessArgs (Argc, Argv); + if (Status != STATUS_SUCCESS) { + return Status; + } + + if (gOptions.CheckGuids || gOptions.CheckSignatures) { + Status = ProcessDirectory (Cwd, NULL); + if (Status == STATUS_SUCCESS) { + // + // Check for duplicates + // + Status = CheckDuplicates (); + } + } + + if (gOptions.DatabaseOutputFileName[0] != 0) { + CreateGuidList (gOptions.DatabaseOutputFileName); + } + // + // Free up the memory + // + free (Cwd); + FreeGuids (); + FreeSigs (); + FreeOptions (); + return GetUtilityStatus (); +} + +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ) +{ + STRING_LIST *StrList; + + memset ((char *) &gOptions, 0, sizeof (gOptions)); + // + // skip over program name + // + Argc--; + Argv++; + + if (Argc == 0) { + Usage (); + return STATUS_ERROR; + } + + while (Argc > 0) { + // + // Look for options + // + if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) { + switch (Argv[0][1]) { + // + // Help option + // + case 'h': + case 'H': + case '?': + Usage (); + return STATUS_ERROR; + break; + + // + // Check guids option + // + case 'g': + case 'G': + gOptions.CheckGuids = TRUE; + break; + + // + // Check signatures option + // + case 's': + case 'S': + gOptions.CheckSignatures = TRUE; + break; + + // + // Print guids found option + // + case 'p': + case 'P': + gOptions.PrintFound = TRUE; + break; + + // + // Exclude files option + // + case 'f': + case 'F': + // + // Check for another arg + // + if (Argc < 2) { + Error (NULL, 0, 0, Argv[0], "missing argument with option"); + Usage (); + return STATUS_ERROR; + } + + StrList = malloc (sizeof (STRING_LIST)); + if (StrList == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) StrList, 0, sizeof (STRING_LIST)); + StrList->Str = Argv[1]; + StrList->Next = gOptions.ExcludeFiles; + gOptions.ExcludeFiles = StrList; + Argc--; + Argv++; + break; + + // + // Exclude directories option + // + case 'd': + case 'D': + // + // Check for another arg + // + if (Argc < 2) { + Error (NULL, 0, 0, Argv[0], "missing argument with option"); + Usage (); + return STATUS_ERROR; + } + + StrList = malloc (sizeof (STRING_LIST)); + if (StrList == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) StrList, 0, sizeof (STRING_LIST)); + StrList->Str = Argv[1]; + StrList->Next = gOptions.ExcludeDirs; + gOptions.ExcludeDirs = StrList; + Argc--; + Argv++; + break; + + // + // -u exclude all subdirectories of a given directory option + // + case 'u': + case 'U': + // + // Check for another arg + // + if (Argc < 2) { + Error (NULL, 0, 0, Argv[0], "missing argument with option"); + Usage (); + return STATUS_ERROR; + } + + StrList = malloc (sizeof (STRING_LIST)); + if (StrList == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) StrList, 0, sizeof (STRING_LIST)); + StrList->Str = Argv[1]; + StrList->Next = gOptions.ExcludeSubDirs; + gOptions.ExcludeSubDirs = StrList; + Argc--; + Argv++; + break; + + // + // -e exclude by filename extension option + // + case 'e': + case 'E': + // + // Check for another arg + // + if (Argc < 2) { + Error (NULL, 0, 0, Argv[0], "missing argument with option"); + Usage (); + return STATUS_ERROR; + } + + StrList = malloc (sizeof (STRING_LIST)); + if (StrList == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) StrList, 0, sizeof (STRING_LIST)); + // + // Let them put a * in front of the filename extension + // + StrList->Str = Argv[1]; + if (StrList->Str[0] == '*') { + StrList->Str++; + } + + StrList->Next = gOptions.ExcludeExtensions; + gOptions.ExcludeExtensions = StrList; + Argc--; + Argv++; + break; + + // + // Print guid with matching symbol name for guid definitions found + // + case 'x': + case 'X': + gOptions.GuidXReference = TRUE; + break; + + // + // -b Print the internal database list to a file + // + case 'b': + case 'B': + // + // Check for one more arg + // + if (Argc < 2) { + Error (NULL, 0, 0, Argv[0], "must specify file name with option"); + Usage (); + return STATUS_ERROR; + } + + strcpy (gOptions.DatabaseOutputFileName, Argv[1]); + Argc--; + Argv++; + break; + + default: + Error (NULL, 0, 0, Argv[0], "invalid option"); + Usage (); + return STATUS_ERROR; + } + } else { + break; + } + // + // Next arg + // + Argc--; + Argv++; + } + + if (Argc > 0) { + Error (NULL, 0, 0, Argv[0], "invalid argument"); + Usage (); + return STATUS_ERROR; + } + // + // Have to check signatures, GUIDs, or dump the GUID database. + // + if ((!gOptions.CheckGuids) && (!gOptions.CheckSignatures) && (gOptions.DatabaseOutputFileName[0] == 0)) { + Error (NULL, 0, 0, "nothing to do", "must specify -g, -s, and/or -b"); + Usage (); + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} +// +// Print usage instructions +// +static +VOID +Usage ( + VOID + ) +{ + int Index; + char *Str[] = { + "GuidChk - scan files for duplicate GUID or signature definitions", + "", + "Usage: GuidChk {options}\n", + " Options: ", + " -d dirname exclude searching of a directory", + " -f filename exclude searching of a file", + " -e extension exclude searching of files by extension", + " -p print all GUIDS found", + " -g check for duplicate guids", + " -s check for duplicate signatures", + " -x print guid+defined symbol name", + " -b outfile write internal GUID+basename list to outfile", + " -u dirname exclude searching all subdirectories of a directory", + " -h -? print this help text", + " ", + " Example: GuidChk -g -u build -d fv -f make.inf -e .pkg", + "", + NULL + }; + for (Index = 0; Str[Index] != NULL; Index++) { + fprintf (stdout, "%s\n", Str[Index]); + } +} +// +// Process an entire directory by name +// +static +STATUS +ProcessDirectory ( + INT8 *Path, + INT8 *DirectoryName + ) +{ + FILE_SEARCH_DATA FSData; + char *FileMask; + BOOLEAN Done; + UINT32 Len; + BOOLEAN NoSubdirs; + STRING_LIST *SLPtr; + + // + // Root directory may be null + // + if (DirectoryName != NULL) { + // + // printf ("Processing directory: %s\n", DirectoryName); + // + } + // + // Initialize our file searching + // + FileSearchInit (&FSData); + + // + // Exclude some directories, files, and extensions + // + FileSearchExcludeDirs (&FSData, gOptions.ExcludeDirs); + FileSearchExcludeExtensions (&FSData, gOptions.ExcludeExtensions); + FileSearchExcludeFiles (&FSData, gOptions.ExcludeFiles); + // + // See if this directory is in the list of directories that they + // don't want to process subdirectories of + // + NoSubdirs = FALSE; + if (DirectoryName != NULL) { + for (SLPtr = gOptions.ExcludeSubDirs; SLPtr != NULL; SLPtr = SLPtr->Next) { + if (_stricmp (SLPtr->Str, DirectoryName) == 0) { + // + // printf ("not processing subdirectories of %s\n", DirectoryName); + // + NoSubdirs = TRUE; + break; + } + } + } + // + // Create a filemask of files to search for. We'll append "\*.*" on the + // end, so allocate some extra bytes. + // + Len = strlen (Path) + 10; + if (DirectoryName != NULL) { + Len += strlen (DirectoryName); + } + + FileMask = malloc (Len); + if (FileMask == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + // + // Now put it all together + // + strcpy (FileMask, Path); + if ((DirectoryName != NULL) && (strlen (DirectoryName) > 0)) { + strcat (FileMask, "\\"); + strcat (FileMask, DirectoryName); + } + + strcat (FileMask, "\\*.*"); + + // + // Start file searching for files and directories + // + if (FileSearchStart (&FSData, FileMask, FILE_SEARCH_FILE | FILE_SEARCH_DIR) == STATUS_SUCCESS) { + Done = FALSE; + } else { + Done = TRUE; + } + + // + // Now hack the "\*.*" off the end of the filemask so we can use it to pass + // the full directory path on recursive calls to process directories. + // + FileMask[strlen (FileMask) - 4] = 0; + + // + // Loop until no more files + // + while (!Done) { + // + // printf ("Found %s...", FSData.FileName); + // + if (FSData.FileFlags & FILE_SEARCH_DIR) { + // + // printf ("directory\n"); + // + if (!NoSubdirs) { + ProcessDirectory (FileMask, FSData.FileName); + } + } else if (FSData.FileFlags & FILE_SEARCH_FILE) { + // + // printf ("file\n"); + // + ProcessFile (FileMask, FSData.FileName); + } else { + // + // printf ("unknown\n"); + // + } + + if (FileSearchFindNext (&FSData) != STATUS_SUCCESS) { + Done = TRUE; + } + } + // + // Free up allocated memory + // + free (FileMask); + + // + // Free up our file searching + // + FileSearchDestroy (&FSData); + + return STATUS_SUCCESS; +} +// +// Process a single file. +// +static +STATUS +ProcessFile ( + INT8 *DirectoryName, + INT8 *FileName + ) +{ + STATUS Status; + UINT32 FileExtension; + INT8 FullFileName[MAX_PATH]; + + Status = STATUS_SUCCESS; + + sprintf (FullFileName, "%s\\%s", DirectoryName, FileName); + // + // printf ("Found file: %s\n", FullFileName); + // + FileExtension = GetFileExtension (FileName); + + // + // Process these for GUID checks + // + if (gOptions.CheckGuids) { + switch (FileExtension) { + case FILE_EXTENSION_C: + case FILE_EXTENSION_H: + Status = ProcessCFileGuids (FullFileName); + break; + + case FILE_EXTENSION_PKG: + Status = ProcessPkgFileGuids (FullFileName); + break; + + case FILE_EXTENSION_IA32_INC: + case FILE_EXTENSION_IA32_ASM: + Status = ProcessIA32FileGuids (FullFileName); + break; + + case FILE_EXTENSION_INF: + Status = ProcessINFFileGuids (FullFileName); + break; + + case FILE_EXTENSION_IA64_INC: + case FILE_EXTENSION_IA64_ASM: + Status = ProcessIA64FileGuids (FullFileName); + break; + + default: + // + // No errors anyway + // + Status = STATUS_SUCCESS; + break; + } + } + + if (gOptions.CheckSignatures) { + switch (FileExtension) { + case FILE_EXTENSION_C: + case FILE_EXTENSION_H: + Status = ProcessCFileSigs (FullFileName); + break; + + default: + // + // No errors anyway + // + Status = STATUS_SUCCESS; + break; + } + } + + return Status; +} +// +// Return a code indicating the file name extension. +// +static +UINT32 +GetFileExtension ( + INT8 *FileName + ) +{ + INT8 *Extension; + int Index; + + // + // Look back for a filename extension + // + for (Extension = FileName + strlen (FileName) - 1; Extension >= FileName; Extension--) { + if (*Extension == '.') { + for (Index = 0; FileTypeTable[Index].Extension != NULL; Index++) { + if (_stricmp (FileTypeTable[Index].Extension, Extension) == 0) { + return FileTypeTable[Index].ExtensionCode; + } + } + } + } + + return FILE_TYPE_UNKNOWN; +} +// +// Process a .pkg file. +// +// Look for FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7 +// +static +STATUS +ProcessPkgFileGuids ( + INT8 *FileName + ) +{ + FILE *Fptr; + INT8 Line[MAX_LINE_LEN * 2]; + INT8 *Cptr; + INT8 *Cptr2; + UINT32 GuidScan[11]; + UINT64 Guid64; + + if ((Fptr = fopen (FileName, "r")) == NULL) { + Error (NULL, 0, 0, FileName, "could not open input file for reading"); + return STATUS_ERROR; + } + // + // Read lines from the file until done + // + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + Cptr = Line; + Cptr += SkipWhiteSpace (Line); + if (strncmp (Cptr, "FFS_FILEGUID", 12) == 0) { + Cptr += 12; + Cptr += SkipWhiteSpace (Cptr); + if (*Cptr == '=') { + Cptr++; + Cptr += SkipWhiteSpace (Cptr + 1); + // + // Blank out dashes on the line. + // + for (Cptr2 = Cptr; *Cptr2; Cptr2++) { + if (*Cptr2 == '-') { + *Cptr2 = ' '; + } + } + + if (sscanf ( + Cptr, + "%X %X %X %X %I64X", + &GuidScan[0], + &GuidScan[1], + &GuidScan[2], + &GuidScan[3], + &Guid64 + ) == 5) { + AddPkgGuid (FileName, GuidScan, &Guid64); + } else { + DebugMsg (NULL, 0, 0, FileName, "GUID scan failed"); + } + } + } + } + + fclose (Fptr); + return STATUS_SUCCESS; +} +// +// Process an IA32 assembly file. +// +// Look for: +// FIND_FD_GUID_VAL equ 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h +// PEI_GUID_FileNameGuid_Gmch815 equ 081818181h, 08181h, 08181h, 081h, 081h, 081h, 081h, 081h, 081h, 081h, 081h +// +static +STATUS +ProcessIA32FileGuids ( + INT8 *FileName + ) +{ + FILE *Fptr; + INT8 Line[MAX_LINE_LEN]; + INT8 *Cptr; + INT8 CSave; + INT8 *CSavePtr; + UINT32 Len; + UINT32 GuidData[16]; + UINT32 Index; + + if ((Fptr = fopen (FileName, "r")) == NULL) { + Error (NULL, 0, 0, FileName, "could not open input file for reading"); + return STATUS_ERROR; + } + // + // Read lines from the file until done + // + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + Cptr = Line; + Cptr += SkipWhiteSpace (Line); + // + // Look for xxxGUIDyyy equ 01h, 02h, 03h, ... + // + Len = ValidSymbolName (Cptr); + if (Len) { + // + // Terminate the line after the symbol name, then look for "guid" in + // the name. + // + CSavePtr = Cptr + Len; + CSave = *CSavePtr; + *CSavePtr = 0; + while (*Cptr) { + if (_strnicmp (Cptr, "guid", 4) == 0) { + break; + } + + Cptr++; + } + // + // If we found the string "guid", continue + // + if (*Cptr) { + // + // Restore the character on the line where we null-terminated the symbol + // + *CSavePtr = CSave; + Cptr = CSavePtr; + Len = SkipWhiteSpace (Cptr); + // + // Had to be some white space + // + if (Len) { + Cptr += Len; + // + // now look for "equ" + // + if (_strnicmp (Cptr, "equ", 3) == 0) { + Cptr += 3; + Cptr += SkipWhiteSpace (Cptr); + // + // Now scan all the data + // + for (Index = 0; Index < 16; Index++) { + if (sscanf (Cptr, "%X", &GuidData[Index]) != 1) { + break; + } + // + // Skip to next + // + while (isxdigit (*Cptr)) { + Cptr++; + } + + if ((*Cptr != 'h') && (*Cptr != 'H')) { + break; + } else { + Cptr++; + while (*Cptr && (isspace (*Cptr) || (*Cptr == ','))) { + Cptr++; + } + } + } + // + // Now see which form we had + // + if (Index == 16) { + AddGuid16 (FileName, GuidData); + } else if (Index == 11) { + AddGuid11 (FileName, GuidData, NULL); + } + } + } + } + } + } + + fclose (Fptr); + return STATUS_SUCCESS; +} +// +// Found and parsed an IA32 assembly code guid. Save the 16 bytes off in the list +// of guids. +// +static +STATUS +AddGuid16 ( + INT8 *FileName, + UINT32 *Data + ) +{ + GUID_RECORD *NewRec; + int Index; + + // + // Sanity check the data + // + if (!CheckGuidData (Data, 16)) { + return STATUS_ERROR; + } + // + // Allocate memory for a new guid structure + // + NewRec = malloc (sizeof (GUID_RECORD)); + if (NewRec == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) NewRec, 0, sizeof (GUID_RECORD)); + NewRec->FileName = malloc (strlen (FileName) + 1); + if (NewRec->FileName == NULL) { + free (NewRec); + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewRec->FileName, FileName); + NewRec->Guid.Data1 = (UINT32) (Data[0] | (Data[1] << 8) | (Data[2] << 16) | (Data[3] << 24)); + NewRec->Guid.Data2 = (UINT16) (Data[4] | (Data[5] << 8)); + NewRec->Guid.Data3 = (UINT16) (Data[6] | (Data[7] << 8)); + for (Index = 0; Index < 8; Index++) { + NewRec->Guid.Data4[Index] = (UINT8) Data[Index + 8]; + } + // + // Add it to the list + // + NewRec->Next = gGuidList; + gGuidList = NewRec; + + // + // Report it + // ReportGuid (FileName, NewRec); + // + return STATUS_SUCCESS; +} +// +// Add a GUID defined as GuidLow: 0x1122334455667788 +// GuidHi: 0x99AABBCCDDEEFF00 +// +// These are equivalent: +// { 0x11223344, 0x5566, 0x7788, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 } +// and: +// Low: 00FFEEDDCCBBAA99 +// Hi: 7788556611223344 +// +static +STATUS +AddGuid64x2 ( + INT8 *FileName, + UINT32 DataHH, // Upper 32-bits of upper 64 bits of guid + UINT32 DataHL, // Lower 32-bits of upper 64 bits + UINT32 DataLH, + UINT32 DataLL, + INT8 *SymName + ) +{ + GUID_RECORD *NewRec; + int Index; + + // + // Allocate memory for a new guid structure + // + NewRec = malloc (sizeof (GUID_RECORD)); + if (NewRec == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) NewRec, 0, sizeof (GUID_RECORD)); + NewRec->FileName = malloc (strlen (FileName) + 1); + if (NewRec->FileName == NULL) { + free (NewRec); + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewRec->FileName, FileName); + NewRec->Guid.Data1 = DataHL; + NewRec->Guid.Data2 = (UINT16) DataHH; + NewRec->Guid.Data3 = (UINT16) (DataHH >> 16); + for (Index = 0; Index < 4; Index++) { + NewRec->Guid.Data4[Index] = (UINT8) DataLL; + DataLL >>= 8; + } + + for (Index = 0; Index < 4; Index++) { + NewRec->Guid.Data4[Index + 4] = (UINT8) DataLH; + DataLH >>= 8; + } + + if (SymName != NULL) { + NewRec->SymName = malloc (strlen (SymName) + 1); + if (NewRec->SymName == NULL) { + free (NewRec); + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + strcpy (NewRec->SymName, SymName); + } + + // + // Add it to the list + // + NewRec->Next = gGuidList; + gGuidList = NewRec; + + // + // Report it + // ReportGuid (FileName, NewRec); + // + return STATUS_SUCCESS; +} +// +// Process INF files. Look for: +// FILE_GUID = 240612B6-A063-11d4-9A3A-0090273FC14D +// +static +STATUS +ProcessINFFileGuids ( + INT8 *FileName + ) +{ + FILE *Fptr; + INT8 Line[MAX_LINE_LEN * 2]; + INT8 *Cptr; + INT8 *Cptr2; + UINT32 GuidScan[11]; + UINT64 Guid64; + + if ((Fptr = fopen (FileName, "r")) == NULL) { + Error (NULL, 0, 0, FileName, "could not open input file for reading"); + return STATUS_ERROR; + } + // + // Read lines from the file until done + // + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + Cptr = Line; + Cptr += SkipWhiteSpace (Line); + if (strncmp (Cptr, "FILE_GUID", 9) == 0) { + Cptr += 9; + Cptr += SkipWhiteSpace (Cptr); + if (*Cptr == '=') { + Cptr++; + Cptr += SkipWhiteSpace (Cptr + 1); + // + // Blank out dashes on the line. + // + for (Cptr2 = Cptr; *Cptr2; Cptr2++) { + if (*Cptr2 == '-') { + *Cptr2 = ' '; + } + } + + if (sscanf ( + Cptr, + "%X %X %X %X %I64X", + &GuidScan[0], + &GuidScan[1], + &GuidScan[2], + &GuidScan[3], + &Guid64 + ) == 5) { + AddPkgGuid (FileName, GuidScan, &Guid64); + } else { + DebugMsg (NULL, 0, 0, FileName, "GUID scan failed"); + } + } + } + } + + fclose (Fptr); + return STATUS_SUCCESS; +} +// +// Parse ('g','m','a','p','a','b','c','d') +// +static +STATUS +AddSignature ( + INT8 *FileName, + INT8 *StrDef, + UINT32 SigSize + ) +{ + SIGNATURE_RECORD *NewRec; + INT8 *Cptr; + UINT32 Index; + BOOLEAN Fail; + + // + // Allocate memory for the new record + // + Fail = FALSE; + NewRec = malloc (sizeof (SIGNATURE_RECORD)); + + if (NewRec == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + memset ((char *) NewRec, 0, sizeof (SIGNATURE_RECORD)); + + // + // Allocate memory to save the file name + // + NewRec->FileName = malloc (strlen (FileName) + 1); + if (NewRec->FileName == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + free (NewRec); + return STATUS_ERROR; + } + // + // Fill in the fields + // + strcpy (NewRec->FileName, FileName); + NewRec->Signature.DataLen = (UINT8) SigSize; + // + // Skip to open parenthesis + // + Cptr = StrDef; + Cptr += SkipWhiteSpace (Cptr); + if (*Cptr != '(') { + Fail = TRUE; + goto Done; + } + + Cptr++; + // + // Skip to first ' and start processing + // + while (*Cptr && (*Cptr != '\'')) { + Cptr++; + } + + for (Index = 0; Index < SigSize; Index++) { + if (*Cptr == '\'') { + Cptr++; + NewRec->Signature.Data[Index] = (INT8) *Cptr; + // + // Skip to closing quote + // + Cptr++; + if (*Cptr != '\'') { + Fail = TRUE; + break; + } + // + // Skip over closing quote, go to next one + // + Cptr++; + while (*Cptr && (*Cptr != '\'')) { + Cptr++; + } + } else { + Fail = TRUE; + DebugMsg (NULL, 0, 0, FileName, "failed to parse signature"); + break; + } + } + +Done: + if (Fail) { + free (NewRec->FileName); + free (NewRec); + return STATUS_ERROR; + } + + NewRec->Next = gSignatureList; + gSignatureList = NewRec; + return STATUS_SUCCESS; +} +// +// Look for: +// #define POOL_HEAD_SIGNATURE EFI_SIGNATURE_16('p','h') +// #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('g','m','a','p') +// #define GCD_MEMORY_MAP_SIGNATURE EFI_SIGNATURE_64('g','m','a','p','a','b','c','d') +// +static +STATUS +ProcessCFileSigs ( + INT8 *FileName + ) +{ + FILE *Fptr; + INT8 Line[MAX_LINE_LEN * 2]; + INT8 *Cptr; + UINT32 Len; + + if ((Fptr = fopen (FileName, "r")) == NULL) { + Error (NULL, 0, 0, FileName, "could not open input file for reading"); + return STATUS_ERROR; + } + // + // Read lines from the file until done + // + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + Cptr = Line; + Cptr += SkipWhiteSpace (Line); + // + // look for #define EFI_SIGNATURE_xx value + // + if (*Cptr == '#') { + Cptr++; + Cptr += SkipWhiteSpace (Cptr); + // + // Look for "define" + // + if (!strncmp (Cptr, "define", 6)) { + Cptr += 6; + // + // Better be whitespace + // + Len = SkipWhiteSpace (Cptr); + if (Len) { + Cptr += Len; + // + // See if it's a valid symbol name + // + Len = ValidSymbolName (Cptr); + if (Len) { + // + // It is a valid symbol name. See if there's line continuation, + // and if so, read more lines. + // Skip over the symbol name and look for the string "EFI_SIGNATURE_xx" + // + ConcatenateLines (Fptr, Line, sizeof(Line)); + + Cptr += Len; + Cptr += SkipWhiteSpace (Cptr); + if (strncmp (Cptr, "EFI_SIGNATURE_16", 16) == 0) { + AddSignature (FileName, Cptr + 16, 2); + } else if (strncmp (Cptr, "EFI_SIGNATURE_32", 16) == 0) { + AddSignature (FileName, Cptr + 16, 4); + } else if (strncmp (Cptr, "EFI_SIGNATURE_64", 16) == 0) { + AddSignature (FileName, Cptr + 16, 8); + } + } + } + } + } + } + + fclose (Fptr); + return STATUS_SUCCESS; +} +// +// look for #define xxxGUIDyyy { 0x...} +// xxx EFI_GUID GuidName = { 0x... }; +// +static +STATUS +ProcessCFileGuids ( + INT8 *FileName + ) +{ + FILE *Fptr; + INT8 Line[MAX_LINE_LEN * 2]; + INT8 *Cptr; + INT8 *CSavePtr; + INT8 *TempCptr; + INT8 *SymName; + UINT32 Len; + UINT32 LineLen; + UINT32 GuidScan[11]; + + if ((Fptr = fopen (FileName, "r")) == NULL) { + Error (NULL, 0, 0, FileName, "could not open input file for reading"); + return STATUS_ERROR; + } + // + // Read lines from the file until done + // + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + Cptr = Line; + Cptr += SkipWhiteSpace (Line); + // + // look for #define xxxGUIDxxx value + // + if (*Cptr == '#') { + Cptr++; + Cptr += SkipWhiteSpace (Cptr); + // + // Look for "define" + // + if (!strncmp (Cptr, "define", 6)) { +DefineLine: + Cptr += 6; + // + // Better be whitespace + // + Len = SkipWhiteSpace (Cptr); + if (Len) { + Cptr += Len; + // + // See if it's a valid symbol name + // + Len = ValidSymbolName (Cptr); + if (Len) { + // + // It is a valid symbol name. See if there's line continuation, + // and if so, read more lines. + // Then truncate after the symbol name, look for the string "GUID", + // and continue. + // + SymName = Cptr; + ConcatenateLines (Fptr, Line, sizeof(Line)); + + // + // Now look for { 0x....... } + // + CSavePtr = Cptr + Len; + Cptr += Len; + Cptr += SkipWhiteSpace (Cptr); + if (*Cptr == '{') { + Cptr++; + // + // Blank out 'L', 'l', '{', '}', ',' on the line. + // + for (TempCptr = Cptr; *TempCptr; TempCptr++) { + if ((*TempCptr == 'L') || (*TempCptr == 'l') || (*TempCptr == '{') || + (*TempCptr == '}') || (*TempCptr == ',')) { + *TempCptr = ' '; + } + } + + if (sscanf ( + Cptr, + "%X %X %X %X %X %X %X %X %X %X %X", + &GuidScan[0], + &GuidScan[1], + &GuidScan[2], + &GuidScan[3], + &GuidScan[4], + &GuidScan[5], + &GuidScan[6], + &GuidScan[7], + &GuidScan[8], + &GuidScan[9], + &GuidScan[10] + ) == 11) { + *CSavePtr = '\0'; + AddGuid11 (FileName, GuidScan, SymName); + } + } + } + } + } + // + // Else look for "static EFI_GUID xxxGUIDxxx = { 0x.... }; + // + } else if ((CSavePtr = strstr (Line, "EFI_GUID")) != NULL) { + // + // Read more lines until met ';' + // + ConcatenateLines (Fptr, Line, sizeof(Line)); + while (strstr (Line, ";") == NULL) { + LineLen = strlen (Line); + Len = sizeof(Line) - LineLen; + if (Len <= 1) { + break; + } + if (Line[LineLen - 1] == '\n') { + Cptr = Line + LineLen - 1; + *Cptr = '\0'; + if (fgets (Cptr, Len, Fptr) == NULL){ + break; + } + ConcatenateLines (Fptr, Line, sizeof(Line)); + } else { + Cptr = Line + LineLen; + *Cptr = '\0'; + if (fgets (Cptr, Len, Fptr) == NULL) { + break; + } + ConcatenateLines (Fptr, Line, sizeof(Line)); + } + + // + // EFI_GUID may appear in comments wihout end of ';' which may cause + // ignoring of new #define, so handle it here. + // + Cptr += SkipWhiteSpace (Cptr); + if (*Cptr == '#') { + Cptr++; + Cptr += SkipWhiteSpace (Cptr); + if (!strncmp (Cptr, "define", 6)) { + goto DefineLine; + } + } + } + + Cptr = CSavePtr + 8; + Cptr += SkipWhiteSpace (Cptr); + // + // Should be variable name next + // + Len = ValidSymbolName (Cptr); + SymName = Cptr; + Cptr += Len; + CSavePtr = Cptr; + Cptr += SkipWhiteSpace (Cptr); + if (*Cptr == '=') { + *CSavePtr = '\0'; + Cptr++; + Cptr += SkipWhiteSpace (Cptr); + // + // Should be open-brace next to define guid + // + if (*Cptr == '{') { + Cptr++; + // + // Blank out 'L', 'l', '{', '}', ',' on the line. + // + for (TempCptr = Cptr; *TempCptr; TempCptr++) { + if ((*TempCptr == 'L') || (*TempCptr == 'l') || (*TempCptr == '{') || + (*TempCptr == '}') || (*TempCptr == ',')) { + *TempCptr = ' '; + } + } + + if (sscanf ( + Cptr, + "%X %X %X %X %X %X %X %X %X %X %X", + &GuidScan[0], + &GuidScan[1], + &GuidScan[2], + &GuidScan[3], + &GuidScan[4], + &GuidScan[5], + &GuidScan[6], + &GuidScan[7], + &GuidScan[8], + &GuidScan[9], + &GuidScan[10] + ) == 11) { + AddGuid11 (FileName, GuidScan, SymName); + } + } + } + } + } + + fclose (Fptr); + return STATUS_SUCCESS; +} +// +// Process Intel Itanium(TM) GUID definitions. Look for: +// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA +// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0 +// in either order. +// This function assumes no blank lines between definitions. +// +static +STATUS +ProcessIA64FileGuids ( + INT8 *FileName + ) +{ + FILE *Fptr; + INT8 Line[MAX_LINE_LEN]; + UINT32 Guid1H; + UINT32 Guid1L; + UINT32 Guid2H; + UINT32 Guid2L; + INT8 SymName1[MAX_LINE_LEN]; + INT8 SymName2[MAX_LINE_LEN]; + BOOLEAN Done; + BOOLEAN LowFirst; + BOOLEAN FoundLow; + + if ((Fptr = fopen (FileName, "r")) == NULL) { + Error (NULL, 0, 0, FileName, "could not open input file for reading"); + return STATUS_ERROR; + } + + Done = FALSE; + if (fgets (Line, sizeof (Line), Fptr) == NULL) { + Done = 1; + } + // + // Read lines from the file until done. Since the guid definition takes + // two lines, we read lines in different places to recover gracefully + // from mismatches. For example, if you thought you found the first half, + // but the next line had a symbol mismatch, then you have to process the + // line again in case it's the start of a new definition. + // + while (!Done) { + // + // Check current line for GUID definition. Assume low define first. + // + if (IsIA64GuidLine (Line, &Guid1H, &Guid1L, &FoundLow, SymName1)) { + // + // Might have to swap guids later. Save off if we found the LOW first + // + if (FoundLow) { + LowFirst = TRUE; + } else { + LowFirst = FALSE; + } + // + // Read the next line and try for the rest of the guid definition + // + if (fgets (Line, sizeof (Line), Fptr) == NULL) { + Done = 1; + } else { + if (IsIA64GuidLine (Line, &Guid2H, &Guid2L, &FoundLow, SymName2)) { + // + // Found another. If the symbol names match, then save it off. + // + if (strcmp (SymName1, SymName2) == 0) { + // + // Yea, found one. Save it off. + // + if (LowFirst) { + AddGuid64x2 (FileName, Guid2H, Guid2L, Guid1H, Guid1L, SymName1); + } else { + AddGuid64x2 (FileName, Guid1H, Guid1L, Guid2H, Guid2L, SymName1); + } + // + // Read the next line for processing + // + if (fgets (Line, sizeof (Line), Fptr) == NULL) { + Done = 1; + } + } else { + // + // Don't get another line so that we reprocess this line in case it + // contains the start of a new definition. + // fprintf (stdout, "Symbol name mismatch: %s: %s != %s\n", + // FileName, SymName1, SymName2); + // + } + } else { + // + // Second line was not a guid definition. Get the next line from the + // file. + // + if (fgets (Line, sizeof (Line), Fptr) == NULL) { + Done = 1; + } + } + } + } else { + // + // Not a guid define line. Next. + // + if (fgets (Line, sizeof (Line), Fptr) == NULL) { + Done = 1; + } + } + } + + fclose (Fptr); + return STATUS_SUCCESS; +} +// +// Given a line from an Itanium-based assembly file, check the line for a guid +// defininition. One of either: +// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA +// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0 +// Return the defined value as two 32-bit values, and whether it's a high +// or low guid. +// +static +BOOLEAN +IsIA64GuidLine ( + INT8 *Line, + UINT32 *GuidHigh, + UINT32 *GuidLow, + BOOLEAN *FoundLow, + INT8 *SymName + ) +{ + INT8 *Cptr; + INT8 CSave; + INT8 *CSavePtr; + INT8 *SymStart; + UINT32 Len; + + Cptr = Line; + Cptr += SkipWhiteSpace (Cptr); + // + // look for #define xxxGUID[L|H] 0xHexValue + // + if (*Cptr == '#') { + Cptr++; + Cptr += SkipWhiteSpace (Cptr); + // + // Look for "define" + // + if (!strncmp (Cptr, "define", 6)) { + Cptr += 6; + // + // Better be whitespace + // + Len = SkipWhiteSpace (Cptr); + if (Len) { + Cptr += Len; + // + // See if it's a valid symbol name + // + Len = ValidSymbolName (Cptr); + if (Len) { + // + // Save the start so we can copy it to their string if later checks are ok + // + SymStart = Cptr; + // + // It is a valid symbol name, look for the string GuidL or GuidH + // + CSavePtr = Cptr + Len; + CSave = *CSavePtr; + *CSavePtr = 0; + while (*Cptr) { + if (strncmp (Cptr, "GuidL", 5) == 0) { + *FoundLow = 1; + break; + } else if (strncmp (Cptr, "GuidH", 5) == 0) { + *FoundLow = 0; + break; + } + + Cptr++; + } + // + // If we didn't run out of string, then we found the GUID string. + // Restore the null character we inserted above and continue. + // Now look for 0x....... + // + if (*Cptr) { + // + // Return symbol name less the "L" or "H" + // + strcpy (SymName, SymStart); + SymName[strlen (SymName) - 1] = 0; + Cptr = CSavePtr; + *CSavePtr = CSave; + Cptr += SkipWhiteSpace (Cptr); + if ((*Cptr == '0') && (*(Cptr + 1) == 'x')) { + // + // skip over "0x" + // + Cptr += 2; + // + // 0x0123456789ABCDEF -- null terminate after 8 characters, + // scan, replace the character and scan at that point. + // + CSave = *(Cptr + 8); + *(Cptr + 8) = 0; + if (sscanf (Cptr, "%X", GuidHigh) == 1) { + *(Cptr + 8) = CSave; + if (sscanf (Cptr + 8, "%X", GuidLow) == 1) { + return TRUE; + } + } + } + } + } + } + } + } + + return FALSE; +} +// +// Look at the characters in the string and determine if it's a valid +// symbol name. Basically [a-zA-Z_][a-zA-Z_0-9]* +// +static +UINT32 +ValidSymbolName ( + INT8 *Name + ) +{ + int Len; + + Len = 0; + + // + // Test first character + // + if (((*Name >= 'a') && (*Name <= 'z')) || ((*Name >= 'A') && (*Name <= 'Z')) || (*Name == '_')) { + Name++; + Len = 1; + while (*Name) { + if (((*Name >= 'a') && (*Name <= 'z')) || + ((*Name >= 'A') && (*Name <= 'Z')) || + ((*Name >= '0') && (*Name <= '9')) || + (*Name == '_') + ) { + Name++; + Len++; + } else { + break; + } + } + } + + return Len; +} + +static +UINT32 +SkipWhiteSpace ( + INT8 *Str + ) +{ + UINT32 Len; + Len = 0; + while (isspace (*Str) && *Str) { + Len++; + Str++; + } + + return Len; +} +// +// found FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7 +// +static +STATUS +AddPkgGuid ( + INT8 *FileName, + UINT32 *Data, + UINT64 *Data64 + ) +{ + GUID_RECORD *NewRec; + int Index; + + // + // Sanity check the data + // + if ((Data[1] | Data[2] | Data[3]) & 0xFFFF0000) { + Error (NULL, 0, 0, "out of range value for GUID data word(s) [1] - [3]", NULL); + return STATUS_ERROR; + } + // + // More checks for Data64? + // Allocate memory for a new one guid structure + // + NewRec = malloc (sizeof (GUID_RECORD)); + if (NewRec == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) NewRec, 0, sizeof (GUID_RECORD)); + NewRec->FileName = malloc (strlen (FileName) + 1); + if (NewRec->FileName == NULL) { + free (NewRec); + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewRec->FileName, FileName); + NewRec->Guid.Data1 = Data[0]; + NewRec->Guid.Data2 = (UINT16) Data[1]; + NewRec->Guid.Data3 = (UINT16) Data[2]; + NewRec->Guid.Data4[0] = (UINT8) (Data[3] >> 8); + NewRec->Guid.Data4[1] = (UINT8) Data[3]; + for (Index = 2; Index < 8; Index++) { + NewRec->Guid.Data4[Index] = ((UINT8*)Data64)[7-Index]; + } + // + // Add it to the list + // + NewRec->Next = gGuidList; + gGuidList = NewRec; + + // + // Report it + // ReportGuid (FileName, NewRec); + // + return STATUS_SUCCESS; +} +// +// Add a guid consisting of 11 fields to our list of guids +// +static +STATUS +AddGuid11 ( + INT8 *FileName, + UINT32 *Data, + INT8 *SymName + ) +{ + GUID_RECORD *NewRec; + int Index; + + // + // Sanity check the data + // + if (!CheckGuidData (Data, 11)) { + return STATUS_ERROR; + } + // + // Allocate memory for a new one guid structure + // + NewRec = malloc (sizeof (GUID_RECORD)); + if (NewRec == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset ((char *) NewRec, 0, sizeof (GUID_RECORD)); + NewRec->FileName = malloc (strlen (FileName) + 1); + if (NewRec->FileName == NULL) { + free (NewRec); + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewRec->FileName, FileName); + if (SymName != NULL) { + NewRec->SymName = malloc (strlen (SymName) + 1); + if (NewRec->SymName == NULL) { + free (NewRec); + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + strcpy (NewRec->SymName, SymName); + } + + NewRec->Guid.Data1 = Data[0]; + NewRec->Guid.Data2 = (UINT16) Data[1]; + NewRec->Guid.Data3 = (UINT16) Data[2]; + for (Index = 0; Index < 8; Index++) { + NewRec->Guid.Data4[Index] = (UINT8) Data[3 + Index]; + } + // + // Add it to the list + // + NewRec->Next = gGuidList; + gGuidList = NewRec; + + // + // Report it + // ReportGuid (FileName, NewRec); + // + return STATUS_SUCCESS; +} +// +// For debug purposes, print each guid found +// +// static +// VOID +// ReportGuid ( +// INT8 *FileName, +// GUID_RECORD *NewGuid +// ) +// { +// //fprintf (stdout, "%s: 0x%08X\n", FileName, NewGuid->Guid.Data1); +// } +// +// Free up memory we allocated to keep track of guids defined. +// +static +VOID +FreeGuids ( + VOID + ) +{ + GUID_RECORD *NextRec; + while (gGuidList != NULL) { + NextRec = gGuidList->Next; + if (gGuidList->FileName != NULL) { + free (gGuidList->FileName); + } + + if (gGuidList->SymName != NULL) { + free (gGuidList->SymName); + } + + free (gGuidList); + gGuidList = NextRec; + } +} + +static +VOID +FreeSigs ( + VOID + ) +{ + SIGNATURE_RECORD *NextRec; + while (gSignatureList != NULL) { + NextRec = gSignatureList->Next; + if (gSignatureList->FileName != NULL) { + free (gSignatureList->FileName); + } + + free (gSignatureList); + gSignatureList = NextRec; + } +} +// +// Scan through all guids defined and compare each for duplicates. +// +static +STATUS +CheckDuplicates ( + VOID + ) +{ + GUID_RECORD *CurrentFile; + + GUID_RECORD *TempFile; + SIGNATURE_RECORD *CurrentSig; + SIGNATURE_RECORD *TempSig; + STATUS Status; + int Index; + int DupCount; + int Len; + BOOLEAN Same; + UINT32 GuidSum; + INT8 *SymName; + + Status = STATUS_SUCCESS; + + // + // If we're checking guids..... + // + if (gOptions.CheckGuids) { + // + // If -p option, print all guids found + // + if (gOptions.PrintFound) { + CurrentFile = gGuidList; + while (CurrentFile != NULL) { + fprintf ( + stdout, + "GUID: 0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X %s\n", + (UINT32) CurrentFile->Guid.Data1, + (UINT32) CurrentFile->Guid.Data2, + (UINT32) CurrentFile->Guid.Data3, + (UINT32) CurrentFile->Guid.Data4[0], + (UINT32) CurrentFile->Guid.Data4[1], + (UINT32) CurrentFile->Guid.Data4[2], + (UINT32) CurrentFile->Guid.Data4[3], + (UINT32) CurrentFile->Guid.Data4[4], + (UINT32) CurrentFile->Guid.Data4[5], + (UINT32) CurrentFile->Guid.Data4[6], + (UINT32) CurrentFile->Guid.Data4[7], + CurrentFile->FileName + ); + CurrentFile = CurrentFile->Next; + } + } + + if (gOptions.GuidXReference) { + CurrentFile = gGuidList; + while (CurrentFile != NULL) { + // + // If no symbol name, print FileName + // + SymName = CurrentFile->SymName; + if (SymName == NULL) { + // + // Assume file name will not be NULL and strlen > 0 + // + SymName = CurrentFile->FileName + strlen (CurrentFile->FileName) - 1; + while ((*SymName != '\\') && (SymName > CurrentFile->FileName)) SymName --; + if (*SymName == '\\') SymName ++; + } + + fprintf ( + stdout, + "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s\n", + (UINT32) CurrentFile->Guid.Data1, + (UINT32) CurrentFile->Guid.Data2, + (UINT32) CurrentFile->Guid.Data3, + (UINT32) CurrentFile->Guid.Data4[0], + (UINT32) CurrentFile->Guid.Data4[1], + (UINT32) CurrentFile->Guid.Data4[2], + (UINT32) CurrentFile->Guid.Data4[3], + (UINT32) CurrentFile->Guid.Data4[4], + (UINT32) CurrentFile->Guid.Data4[5], + (UINT32) CurrentFile->Guid.Data4[6], + (UINT32) CurrentFile->Guid.Data4[7], + SymName + ); + CurrentFile = CurrentFile->Next; + } + } + // + // Now go through all guids and report duplicates. + // + CurrentFile = gGuidList; + while (CurrentFile != NULL) { + DupCount = 0; + TempFile = CurrentFile->Next; + while (TempFile) { + // + // Compare the guids + // + if ((CurrentFile->Guid.Data1 == TempFile->Guid.Data1) && + (CurrentFile->Guid.Data2 == TempFile->Guid.Data2) && + (CurrentFile->Guid.Data3 == TempFile->Guid.Data3) + ) { + // + // OR in all the guid bytes so we can ignore NULL-guid definitions. + // + GuidSum = CurrentFile->Guid.Data1 | CurrentFile->Guid.Data2 | CurrentFile->Guid.Data3; + Same = TRUE; + for (Index = 0; Index < 8; Index++) { + GuidSum |= CurrentFile->Guid.Data4[Index]; + if (CurrentFile->Guid.Data4[Index] != TempFile->Guid.Data4[Index]) { + Same = FALSE; + break; + } + } + // + // If they're the same, and the guid was non-zero, print a message. + // + if (Same && GuidSum) { + if (DupCount == 0) { + Error (NULL, 0, 0, "duplicate GUIDS found", NULL); + fprintf (stdout, " FILE1: %s\n", CurrentFile->FileName); + } + + DupCount++; + fprintf (stdout, " FILE%d: %s\n", DupCount + 1, TempFile->FileName); + // + // Flag it as reported so we don't report it again if there's three or more + // + TempFile->Reported = TRUE; + } + } + // + // Next one + // + TempFile = TempFile->Next; + } + // + // Print the guid if we found duplicates + // + if (DupCount) { + fprintf ( + stdout, + " GUID: 0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n", + (UINT32) CurrentFile->Guid.Data1, + (UINT32) CurrentFile->Guid.Data2, + (UINT32) CurrentFile->Guid.Data3, + (UINT32) CurrentFile->Guid.Data4[0], + (UINT32) CurrentFile->Guid.Data4[1], + (UINT32) CurrentFile->Guid.Data4[2], + (UINT32) CurrentFile->Guid.Data4[3], + (UINT32) CurrentFile->Guid.Data4[4], + (UINT32) CurrentFile->Guid.Data4[5], + (UINT32) CurrentFile->Guid.Data4[6], + (UINT32) CurrentFile->Guid.Data4[7] + ); + // + // return STATUS_ERROR; + // + } + // + // Find the next one that hasn't been reported + // + do { + CurrentFile = CurrentFile->Next; + } while ((CurrentFile != NULL) && (CurrentFile->Reported)); + } + } + + if (gOptions.CheckSignatures) { + // + // Print ones found if specified + // + if (gOptions.PrintFound) { + CurrentSig = gSignatureList; + while (CurrentSig != NULL) { + Len = CurrentSig->Signature.DataLen; + for (Index = 0; Index < Len; Index++) { + fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]); + } + + fprintf (stdout, " %s\n", CurrentSig->FileName); + CurrentSig = CurrentSig->Next; + } + } + + CurrentSig = gSignatureList; + while (CurrentSig != NULL) { + DupCount = 0; + TempSig = CurrentSig->Next; + Len = CurrentSig->Signature.DataLen; + while (TempSig) { + // + // Check for same length, then do string compare + // + if (Len == TempSig->Signature.DataLen) { + if (strncmp (CurrentSig->Signature.Data, TempSig->Signature.Data, Len) == 0) { + // + // Print header message if first failure for this sig + // + if (DupCount == 0) { + Error (NULL, 0, 0, "duplicate signatures found", NULL); + fprintf (stdout, " FILE1: %s\n", CurrentSig->FileName); + } + + DupCount++; + fprintf (stdout, " FILE%d: %s\n", DupCount + 1, TempSig->FileName); + TempSig->Reported = TRUE; + } + } + + TempSig = TempSig->Next; + } + + if (DupCount) { + fprintf (stdout, " SIG: "); + for (Index = 0; Index < Len; Index++) { + fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]); + } + + fprintf (stdout, "\n"); + } + // + // On to the next one that hasn't been reported + // + do { + CurrentSig = CurrentSig->Next; + } while ((CurrentSig != NULL) && (CurrentSig->Reported)); + } + } + + return Status; +} + +static +VOID +FreeOptions ( + VOID + ) +/*++ + +Routine Description: + Free up any memory we allocated when processing command-line options. + +Arguments: + None. + +Returns: + NA + +Notes: + We don't free up the ->Str fields because we did not allocate them. + Instead, we just set the pointer to point to the actual parameter + from the command line. + +--*/ +{ + STRING_LIST *Ptr; + while (gOptions.ExcludeDirs != NULL) { + Ptr = gOptions.ExcludeDirs->Next; + // + // free (gOptions.ExcludeDirs->Str); + // + free (gOptions.ExcludeDirs); + gOptions.ExcludeDirs = Ptr; + } + + while (gOptions.ExcludeSubDirs != NULL) { + Ptr = gOptions.ExcludeSubDirs->Next; + // + // free (gOptions.ExcludeSubDirs->Str); + // + free (gOptions.ExcludeSubDirs); + gOptions.ExcludeSubDirs = Ptr; + } + + while (gOptions.ExcludeExtensions != NULL) { + Ptr = gOptions.ExcludeExtensions->Next; + // + // free (gOptions.ExcludeExtensions->Str); + // + free (gOptions.ExcludeExtensions); + gOptions.ExcludeExtensions = Ptr; + } + + while (gOptions.ExcludeFiles != NULL) { + Ptr = gOptions.ExcludeFiles->Next; + // + // free (gOptions.ExcludeFiles->Str); + // + free (gOptions.ExcludeFiles); + gOptions.ExcludeFiles = Ptr; + } +} +// +// Given an array of 32-bit data, validate the data for the given number of +// guid data. For example, it might have been scanned as 16 bytes of data, or +// 11 fields of data. +// +static +BOOLEAN +CheckGuidData ( + UINT32 *Data, + UINT32 DataCount + ) +{ + UINT32 Index; + + if (DataCount == 16) { + for (Index = 0; Index < 16; Index++) { + if (Data[Index] &~0xFF) { + return FALSE; + } + } + + return TRUE; + } else if (DataCount == 11) { + // + // Data[0] never out of range (32-bit) + // + if ((Data[1] | Data[2]) &~0xFFFF) { + // + // Error ("Out of range value for GUID data word(s) [1] and/or [2]"); + // + return FALSE; + } + + for (Index = 0; Index < 8; Index++) { + if (Data[Index + 3] &~0xFF) { + // + // Error ("Out of range value for GUID data byte(s) [4] - [11]"); + // + return FALSE; + } + } + + return TRUE; + } + + return FALSE; +} + +static +VOID +ConcatenateLines ( + FILE *Fptr, + INT8 *Line, + UINT32 Len + ) +{ + UINT32 LineLen; + BOOLEAN NeedCheck; + + NeedCheck = TRUE; + while (NeedCheck) { + LineLen = strlen (Line); + if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) { + Line[LineLen - 2] = '\0'; + fgets (Line + LineLen - 2, Len - LineLen, Fptr); + } else if (Line[LineLen - 1] == '\\') { + Line[LineLen - 1] = '\0'; + fgets (Line + LineLen - 1, Len - LineLen, Fptr); + } else { + NeedCheck = FALSE; + } + } +} \ No newline at end of file diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidList.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidList.c new file mode 100644 index 0000000000..83ca51d353 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidList.c @@ -0,0 +1,188 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidList.c + +Abstract: + + Utility to create a GUID-to-name listing file that can + be used by other utilities. Basic operation is to take the + table of name+GUIDs that we have compiled into this utility, + and create a text file that can be parsed by other utilities + to do replacement of "name" with "GUID". + +Notes: + To add a new GUID to this database: + 1. Add a "#include EFI_GUID_DEFINITION(name)" statement below + 2. Modify the mGuidList[] array below to add the new GUID name + + The only issue that may come up is that, if the source GUID file + is not in the standard GUID directory, then this utility won't + compile because the #include fails. In this case you'd need + to define a new macro (if it's in a standard place) or modify + this utility's makefile to add the path to your new .h file. + +--*/ + +#include +#include +#include +#include + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" + +#include EFI_GUID_DEFINITION (Apriori) +#include EFI_GUID_DEFINITION (AcpiTableStorage) +#include EFI_GUID_DEFINITION (Bmp) +#include EFI_GUID_DEFINITION (AcpiTableStorage) +#include EFI_GUID_DEFINITION (PeiApriori) + + +#define GUID_XREF(varname, guid) { \ + #varname, #guid, guid \ + } + +#define NULL_GUID \ + { \ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 \ + } + +typedef struct { + INT8 *VariableName; + INT8 *DefineName; + EFI_GUID Guid; +} GUID_LIST; + +// +// This is our table of all GUIDs we want to print out to create +// a GUID-to-name cross reference. +// Use the #defined name from the GUID definition's source .h file. +// +static GUID_LIST mGuidList[] = { + GUID_XREF(gEfiPeiAprioriGuid, EFI_PEI_APRIORI_FILE_NAME_GUID), + GUID_XREF(gAprioriGuid, EFI_APRIORI_GUID), + GUID_XREF(gEfiDefaultBmpLogoGuid, EFI_DEFAULT_BMP_LOGO_GUID), + GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID), + // + // Terminator + // + { + NULL, + NULL, + NULL_GUID + } +}; + +void +PrintGuidText ( + FILE *OutFptr, + INT8 *VariableName, + INT8 *DefineName, + EFI_GUID *Guid + ); + +int +CreateGuidList ( + INT8 *OutFileName + ) +/*++ + +Routine Description: + Print our GUID/name list to the specified output file. + +Arguments: + OutFileName - name of the output file to write our results to. + +Returns: + 0 if successful + nonzero otherwise + +--*/ +{ + FILE *OutFptr; + int Index; + + // + // Open output file for writing. If the name is NULL, then write to stdout + // + if (OutFileName != NULL) { + OutFptr = fopen (OutFileName, "w"); + if (OutFptr == NULL) { + Error (NULL, 0, 0, OutFileName, "failed to open output file for writing"); + return STATUS_ERROR; + } + } else { + OutFptr = stdout; + } + + for (Index = 0; mGuidList[Index].VariableName != NULL; Index++) { + PrintGuidText (OutFptr, mGuidList[Index].VariableName, mGuidList[Index].DefineName, &mGuidList[Index].Guid); + } + // + // Close the output file if they specified one. + // + if (OutFileName != NULL) { + fclose (OutFptr); + } + + return STATUS_SUCCESS; +} + +void +PrintGuidText ( + FILE *OutFptr, + INT8 *VariableName, + INT8 *DefineName, + EFI_GUID *Guid + ) +/*++ + +Routine Description: + Print a GUID/name combo in INF-style format + + guid-guid-guid-guid DEFINE_NAME gName + +Arguments: + OutFptr - file pointer to which to write the output + VariableName - the GUID variable's name + DefineName - the name used in the #define + Guid - pointer to the GUID value + +Returns: + NA + +--*/ +{ + if (OutFptr == NULL) { + OutFptr = stdout; + } + + fprintf ( + OutFptr, + "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s %s\n", + Guid->Data1, + Guid->Data2, + Guid->Data3, + Guid->Data4[0], + Guid->Data4[1], + Guid->Data4[2], + Guid->Data4[3], + Guid->Data4[4], + Guid->Data4[5], + Guid->Data4[6], + Guid->Data4[7], + DefineName, + VariableName + ); +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/Makefile new file mode 100644 index 0000000000..5aeddd8cad --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/Makefile @@ -0,0 +1,96 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the GUID check utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Target specific information +# + +TARGET_NAME = GuidChk +TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\GuidChk.exe + +#LIBS = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib" + +# +# Build targets +# +all: $(TARGET_EXE) + +INC_DEPS = $(TARGET_SRC_DIR)\FileSearch.h $(INC_DEPS) +#INC_DEPS = $(TARGET_SRC_DIR)\CommonUtils.h $(INC_DEPS) +#INC_DEPS = $(TARGET_SRC_DIR)\UtilsMsgs.h $(INC_DEPS) + +OBJECTS = $(EDK_TOOLS_OUTPUT)\GuidChk.obj \ + $(EDK_TOOLS_OUTPUT)\FileSearch.obj \ + $(EDK_TOOLS_OUTPUT)\GuidList.obj \ + $(EDK_TOOLS_OUTPUT)\UtilsMsgs.obj +# +# Compile each source file +# +$(EDK_TOOLS_OUTPUT)\GuidChk.obj : $(TARGET_SRC_DIR)\GuidChk.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\GuidChk.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\FileSearch.obj : $(TARGET_SRC_DIR)\FileSearch.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\FileSearch.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\GuidList.obj : $(TARGET_SRC_DIR)\GuidList.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\GuidList.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\UtilsMsgs.obj : $(TARGET_SRC_DIR)\UtilsMsgs.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\UtilsMsgs.c /Fo$@ + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\FileSearch.* del $(EDK_TOOLS_OUTPUT)\FileSearch.* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.c new file mode 100644 index 0000000000..2abe621536 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.c @@ -0,0 +1,489 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UtilsMsgs.c + +Abstract: + + EFI tools utility functions to display warning, error, and informational + messages. + +--*/ + +#include +#include +#include +#include + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" + +#define MAX_LINE_LEN 200 + +// +// Declare module globals for keeping track of the the utility's +// name and other settings. +// +static STATUS mStatus = STATUS_SUCCESS; +static INT8 mUtilityName[50] = { 0 }; +static INT8 *mSourceFileName = NULL; +static UINT32 mSourceFileLineNum = 0; +static UINT32 mErrorCount = 0; +static UINT32 mWarningCount = 0; +static UINT32 mDebugMsgMask = 0; + +static +void +PrintMessage ( + INT8 *Type, + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + va_list List + ); + +void +Error ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Prints an error message. + +Arguments: + All arguments are optional, though the printed message may be useless if + at least something valid is not specified. + + FileName - name of the file or application. If not specified, then the + utilty name (as set by the utility calling SetUtilityName() + earlier) is used. Otherwise "Unknown utility" is used. + + LineNumber - the line number of error, typically used by parsers. If the + utility is not a parser, then 0 should be specified. Otherwise + the FileName and LineNumber info can be used to cause + MS Visual Studio to jump to the error. + + MessageCode - an application-specific error code that can be referenced in + other documentation. + + Text - the text in question, typically used by parsers. + + MsgFmt - the format string for the error message. Can contain formatting + controls for use with the varargs. + +Returns: + None. + +Notes: + We print the following (similar to the Warn() and Debug() + W + Typical error/warning message format: + + bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters + + BUGBUG -- these three utility functions are almost identical, and + should be modified to share code. + + Visual Studio does not find error messages with: + + " error :" + " error 1:" + " error c1:" + " error 1000:" + " error c100:" + + It does find: + " error c1000:" +--*/ +{ + va_list List; + mErrorCount++; + va_start (List, MsgFmt); + PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_ERROR) { + mStatus = STATUS_ERROR; + } +} + +void +ParserError ( + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a parser error, using the source file name and line number + set by a previous call to SetParserPosition(). + +Arguments: + MessageCode - application-specific error code + Text - text to print in the error message + MsgFmt - format string to print at the end of the error message + ... + +Returns: + NA + +--*/ +{ + va_list List; + mErrorCount++; + va_start (List, MsgFmt); + PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_ERROR) { + mStatus = STATUS_ERROR; + } +} + +void +ParserWarning ( + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a parser warning, using the source file name and line number + set by a previous call to SetParserPosition(). + +Arguments: + ErrorCode - application-specific error code + OffendingText - text to print in the warning message + MsgFmt - format string to print at the end of the warning message + ... + +Returns: + NA + +--*/ +{ + va_list List; + mWarningCount++; + va_start (List, MsgFmt); + PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_WARNING) { + mStatus = STATUS_WARNING; + } +} + +void +Warning ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a warning message. + +Arguments: + FileName - name of the file where the warning was detected, or the name + of the application that detected the warning + + LineNumber - the line number where the warning was detected (parsers). + 0 should be specified if the utility is not a parser. + + MessageCode - an application-specific warning code that can be referenced in + other documentation. + + Text - the text in question (parsers) + + MsgFmt - the format string for the warning message. Can contain formatting + controls for use with varargs. + + ... + +Returns: + None. + +--*/ +{ + va_list List; + mWarningCount++; + va_start (List, MsgFmt); + PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List); + va_end (List); + // + // Set status accordingly + // + if (mStatus < STATUS_WARNING) { + mStatus = STATUS_WARNING; + } +} + +void +DebugMsg ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MsgMask, + INT8 *Text, + INT8 *MsgFmt, + ... + ) +/*++ + +Routine Description: + Print a warning message. + +Arguments: + FileName - typically the name of the utility printing the debug message, but + can be the name of a file being parsed. + + LineNumber - the line number in FileName (parsers) + + MsgMask - an application-specific bitmask that, in combination with mDebugMsgMask, + determines if the debug message gets printed. + + Text - the text in question (parsers) + + MsgFmt - the format string for the debug message. Can contain formatting + controls for use with varargs. + + ... +Returns: + None. + +--*/ +{ + va_list List; + // + // If the debug mask is not applicable, then do nothing. + // + if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) { + return ; + } + + va_start (List, MsgFmt); + PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List); + va_end (List); +} + +static +void +PrintMessage ( + INT8 *Type, + INT8 *FileName, + UINT32 LineNumber, + UINT32 MessageCode, + INT8 *Text, + INT8 *MsgFmt, + va_list List + ) +/*++ + +Routine Description: + Worker routine for all the utility printing services. Prints the message in + a format that Visual Studio will find when scanning build outputs for + errors or warnings. + +Arguments: + Type - "warning" or "error" string to insert into the message to be + printed. The first character of this string (converted to uppercase) + is used to preceed the MessageCode value in the output string. + + FileName - name of the file where the warning was detected, or the name + of the application that detected the warning + + LineNumber - the line number where the warning was detected (parsers). + 0 should be specified if the utility is not a parser. + + MessageCode - an application-specific warning code that can be referenced in + other documentation. + + Text - part of the message to print + + MsgFmt - the format string for the message. Can contain formatting + controls for use with varargs. + + List - Variable function parameter list. +Returns: + None. + +Notes: + If FileName == NULL then this utility will use the string passed into SetUtilityName(). + + LineNumber is only used if the caller is a parser, in which case FileName refers to the + file being parsed. + + Text and MsgFmt are both optional, though it would be of little use calling this function with + them both NULL. + + Output will typically be of the form: + () : : : + + Parser (LineNumber != 0) + VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters + Generic utility (LineNumber == 0) + UtilityName : error E1234 : Text string : MsgFmt string and args + +--*/ +{ + INT8 Line[MAX_LINE_LEN]; + INT8 Line2[MAX_LINE_LEN]; + INT8 *Cptr; + // + // If given a filename, then add it (and the line number) to the string. + // If there's no filename, then use the program name if provided. + // + if (FileName != NULL) { + Cptr = FileName; + } else if (mUtilityName[0] != 0) { + Cptr = mUtilityName; + } else { + Cptr = "Unknown utility"; + } + + strcpy (Line, Cptr); + if (LineNumber != 0) { + sprintf (Line2, "(%d)", LineNumber); + strcat (Line, Line2); + } + // + // Have to print an error code or Visual Studio won't find the + // message for you. It has to be decimal digits too. + // + sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode); + strcat (Line, Line2); + fprintf (stdout, "%s", Line); + // + // If offending text was provided, then print it + // + if (Text != NULL) { + fprintf (stdout, ": %s ", Text); + } + // + // Print formatted message if provided + // + if (MsgFmt != NULL) { + vsprintf (Line2, MsgFmt, List); + fprintf (stdout, ": %s", Line2); + } + + fprintf (stdout, "\n"); +} + +void +ParserSetPosition ( + INT8 *SourceFileName, + UINT32 LineNum + ) +/*++ + +Routine Description: + Set the position in a file being parsed. This can be used to + print error messages deeper down in a parser. + +Arguments: + SourceFileName - name of the source file being parsed + LineNum - line number of the source file being parsed + +Returns: + NA + +--*/ +{ + mSourceFileName = SourceFileName; + mSourceFileLineNum = LineNum; +} + +void +SetUtilityName ( + INT8 *UtilityName + ) +/*++ + +Routine Description: + All printed error/warning/debug messages follow the same format, and + typically will print a filename or utility name followed by the error + text. However if a filename is not passed to the print routines, then + they'll print the utility name if you call this function early in your + app to set the utility name. + +Arguments: + UtilityName - name of the utility, which will be printed with all + error/warning/debug messags. + +Returns: + NA + +--*/ +{ + // + // Save the name of the utility in our local variable. Make sure its + // length does not exceed our buffer. + // + if (UtilityName != NULL) { + if (strlen (UtilityName) >= sizeof (mUtilityName)) { + Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size"); + strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1); + mUtilityName[sizeof (mUtilityName) - 1] = 0; + return ; + } else { + strcpy (mUtilityName, UtilityName); + } + } else { + Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name"); + } +} + +STATUS +GetUtilityStatus ( + VOID + ) +/*++ + +Routine Description: + When you call Error() or Warning(), this module keeps track of it and + sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility + exits, it can call this function to get the status and use it as a return + value. + +Arguments: + None. + +Returns: + Worst-case status reported, as defined by which print function was called. + +--*/ +{ + return mStatus; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.h b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.h new file mode 100644 index 0000000000..5f6c7010b4 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/UtilsMsgs.h @@ -0,0 +1,106 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + UtilsMsgs.h + +Abstract: + + Prototypes for the EFI tools utility functions. + +--*/ + +#ifndef _UTILS_MESSAGES_H_ +#define _UTILS_MESSAGES_H_ + +STATUS +GetUtilityStatus ( + VOID + ) +; + +// +// If someone prints an error message and didn't specify a source file name, +// then we print the utility name instead. However they must tell us the +// utility name early on via this function. +// +VOID +SetUtilityName ( + INT8 *ProgramName + ) +; + +void +Error ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +Warning ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +DebugMsg ( + INT8 *FileName, + UINT32 LineNumber, + UINT32 MsgLevel, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +SetDebugMsgMask ( + UINT32 MsgMask + ) +; + +void +ParserSetPosition ( + INT8 *SourceFileName, + UINT32 LineNum + ) +; + +void +ParserError ( + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +void +ParserWarning ( + UINT32 ErrorCode, + INT8 *OffendingText, + INT8 *MsgFmt, + ... + ) +; + +#endif diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c new file mode 100644 index 0000000000..bf086e64a4 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c @@ -0,0 +1,1316 @@ +/*++ + +Copyright (c) 2004 - 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + MakeDeps.c + +Abstract: + + Recursively scan source files to find include files and emit them to + create dependency lists. + +--*/ + +#include +#include +#include +#include + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" + +// +// Structure to maintain a linked list of strings +// +typedef struct _STRING_LIST { + struct _STRING_LIST *Next; + char *Str; +} STRING_LIST; + +#define UTILITY_NAME "MakeDeps" + +#define MAX_LINE_LEN 2048 +#define MAX_PATH 2048 +#define START_NEST_DEPTH 1 +#define MAX_NEST_DEPTH 1000 // just in case we get in an endless loop. +// +// Define the relative paths used by the special #include macros +// +#define PROTOCOL_DIR_PATH "Protocol\\" +#define GUID_DIR_PATH "Guid\\" +#define ARCH_PROTOCOL_DIR_PATH "ArchProtocol\\" +#define PPI_PROTOCOL_DIR_PATH "Ppi\\" + +// +// Use this structure to keep track of all the special #include forms +// +typedef struct { + INT8 *IncludeMacroName; + INT8 *PathName; +} INCLUDE_MACRO_CONVERSION; + +// +// This data is used to convert #include macros like: +// #include EFI_PROTOCOL_DEFINITION(xxx) +// into +// #include Protocol/xxx/xxx.h +// +static const INCLUDE_MACRO_CONVERSION mMacroConversion[] = { + "EFI_PROTOCOL_DEFINITION", + PROTOCOL_DIR_PATH, + "EFI_GUID_DEFINITION", + GUID_DIR_PATH, + "EFI_ARCH_PROTOCOL_DEFINITION", + ARCH_PROTOCOL_DIR_PATH, + "EFI_PROTOCOL_PRODUCER", + PROTOCOL_DIR_PATH, + "EFI_PROTOCOL_CONSUMER", + PROTOCOL_DIR_PATH, + "EFI_PROTOCOL_DEPENDENCY", + PROTOCOL_DIR_PATH, + "EFI_ARCH_PROTOCOL_PRODUCER", + ARCH_PROTOCOL_DIR_PATH, + "EFI_ARCH_PROTOCOL_CONSUMER", + ARCH_PROTOCOL_DIR_PATH, + "EFI_ARCH_PROTOCOL_DEPENDENCY", + ARCH_PROTOCOL_DIR_PATH, + "EFI_PPI_DEFINITION", + PPI_PROTOCOL_DIR_PATH, + "EFI_PPI_PRODUCER", + PPI_PROTOCOL_DIR_PATH, + "EFI_PPI_CONSUMER", + PPI_PROTOCOL_DIR_PATH, + "EFI_PPI_DEPENDENCY", + PPI_PROTOCOL_DIR_PATH, + NULL, + NULL +}; + +typedef struct _SYMBOL { + struct _SYMBOL *Next; + INT8 *Name; + INT8 *Value; +} SYMBOL; + +// +// Here's all our globals. We need a linked list of include paths, a linked +// list of source files, a linked list of subdirectories (appended to each +// include path when searching), and flags to keep track of command-line options. +// +static struct { + STRING_LIST *IncludePaths; // all include paths to search + STRING_LIST *SourceFiles; // all source files to parse + STRING_LIST *SubDirs; // appended to each include path when searching + SYMBOL *SymbolTable; // for replacement strings + FILE *OutFptr; // output dependencies to this file + BOOLEAN Verbose; // for more detailed output + BOOLEAN IgnoreNotFound; // no warnings if files not found + BOOLEAN QuietMode; // -q - don't print missing file warnings + BOOLEAN NoSystem; // don't process #include files + BOOLEAN NeverFail; // always return success + BOOLEAN NoDupes; // to not list duplicate dependency files (for timing purposes) + BOOLEAN UseSumDeps; // use summary dependency files if found + BOOLEAN IsAsm; // The SourceFiles are assembler files + INT8 TargetFileName[MAX_PATH]; // target object filename + INT8 SumDepsPath[MAX_PATH]; // path to summary files + INT8 *OutFileName; // -o option +} mGlobals; + +static +STATUS +ProcessFile ( + INT8 *TargetFileName, + INT8 *FileName, + UINT32 NestDepth, + STRING_LIST *ProcessedFiles + ); + +static +FILE * +FindFile ( + INT8 *FileName, + UINT32 FileNameLen + ); + +static +void +PrintDependency ( + INT8 *Target, + INT8 *DependentFile + ); + +static +void +ReplaceSymbols ( + INT8 *Str, + UINT32 StrSize + ); + +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ); + +static +void +Usage ( + VOID + ); + +static +void +FreeLists ( + VOID + ); + +int +main ( + int Argc, + char *Argv[] + ) +/*++ + +Routine Description: + + Call the routine to parse the command-line options, then process each file + to build dependencies. + +Arguments: + + Argc - Standard C main() argc. + Argv - Standard C main() argv. + +Returns: + + 0 if successful + nonzero otherwise + +--*/ +{ + STRING_LIST *File; + STRING_LIST ProcessedFiles; + STRING_LIST *TempList; + STATUS Status; + INT8 *Cptr; + INT8 TargetFileName[MAX_PATH]; + + SetUtilityName (UTILITY_NAME); + // + // Process the command-line arguments + // + Status = ProcessArgs (Argc, Argv); + if (Status != STATUS_SUCCESS) { + return STATUS_ERROR; + } + // + // Go through the list of source files and process each. + // + memset (&ProcessedFiles, 0, sizeof (STRING_LIST)); + File = mGlobals.SourceFiles; + while (File != NULL) { + // + // Clear out our list of processed files + // + TempList = ProcessedFiles.Next; + while (ProcessedFiles.Next != NULL) { + TempList = ProcessedFiles.Next->Next; + free (ProcessedFiles.Next->Str); + free (ProcessedFiles.Next); + ProcessedFiles.Next = TempList; + } + // + // Replace filename extension with ".obj" if they did not + // specifically specify the target file + // + if (mGlobals.TargetFileName[0] == 0) { + strcpy (TargetFileName, File->Str); + // + // Find the .extension + // + for (Cptr = TargetFileName + strlen (TargetFileName) - 1; + (*Cptr != '\\') && (Cptr > TargetFileName) && (*Cptr != '.'); + Cptr-- + ) + ; + if (Cptr == TargetFileName) { + Error (NULL, 0, 0, File->Str, "could not locate extension in filename"); + goto Finish; + } + // + // Tack on the ".obj" + // + strcpy (Cptr, ".obj"); + } else { + // + // Copy the target filename they specified + // + strcpy (TargetFileName, mGlobals.TargetFileName); + } + + Status = ProcessFile (TargetFileName, File->Str, START_NEST_DEPTH, &ProcessedFiles); + if (Status != STATUS_SUCCESS) { + goto Finish; + } + + File = File->Next; + } + +Finish: + // + // Free up memory + // + FreeLists (); + // + // Free up our processed files list + // + TempList = ProcessedFiles.Next; + while (ProcessedFiles.Next != NULL) { + TempList = ProcessedFiles.Next->Next; + free (ProcessedFiles.Next->Str); + free (ProcessedFiles.Next); + ProcessedFiles.Next = TempList; + } + // + // Close our output file + // + if ((mGlobals.OutFptr != stdout) && (mGlobals.OutFptr != NULL)) { + fclose (mGlobals.OutFptr); + } + + if (mGlobals.NeverFail) { + return STATUS_SUCCESS; + } + // + // If any errors, then delete our output so that it will get created + // again on a rebuild. + // + if ((GetUtilityStatus () == STATUS_ERROR) && (mGlobals.OutFileName != NULL)) { + remove (mGlobals.OutFileName); + } + + return GetUtilityStatus (); +} + +static +STATUS +ProcessFile ( + INT8 *TargetFileName, + INT8 *FileName, + UINT32 NestDepth, + STRING_LIST *ProcessedFiles + ) +/*++ + +Routine Description: + + Given a source file name, open the file and parse all #include lines. + +Arguments: + + TargetFileName - name of the usually .obj target + FileName - name of the file to process + NestDepth - how deep we're nested in includes + ProcessedFiles - list of processed files. + +Returns: + + standard status. + +--*/ +{ + FILE *Fptr; + INT8 Line[MAX_LINE_LEN]; + INT8 *Cptr; + INT8 *EndPtr; + INT8 *SaveCptr; + INT8 EndChar; + INT8 FileNameCopy[MAX_PATH]; + INT8 MacroIncludeFileName[MAX_LINE_LEN]; + INT8 SumDepsFile[MAX_PATH]; + STATUS Status; + UINT32 Index; + UINT32 LineNum; + STRING_LIST *ListPtr; + + Status = STATUS_SUCCESS; + Fptr = NULL; + // + // Print the file being processed. Indent so you can tell the include nesting + // depth. + // + if (mGlobals.Verbose) { + fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', FileName); + } + // + // If we're using summary dependency files, and a matching .dep file is + // found for this file, then just emit the summary dependency file as + // a dependency and return. + // + if (mGlobals.UseSumDeps) { + strcpy (SumDepsFile, mGlobals.SumDepsPath); + strcat (SumDepsFile, FileName); + for (Cptr = SumDepsFile + strlen (SumDepsFile) - 1; + (*Cptr != '\\') && (Cptr > SumDepsFile) && (*Cptr != '.'); + Cptr-- + ) + ; + if (*Cptr == '.') { + strcpy (Cptr, ".dep"); + } else { + strcat (SumDepsFile, ".dep"); + } + // + // See if the summary dep file exists. Could use _stat() function, but + // it's less portable. + // + if ((Fptr = fopen (SumDepsFile, "r")) != NULL) { + PrintDependency (TargetFileName, SumDepsFile); + fclose (Fptr); + return STATUS_SUCCESS; + } + } + // + // If we're not doing duplicates, and we've already seen this filename, + // then return + // + if (mGlobals.NoDupes) { + for (ListPtr = ProcessedFiles->Next; ListPtr != NULL; ListPtr = ListPtr->Next) { + if (_stricmp (FileName, ListPtr->Str) == 0) { + break; + } + } + // + // If we found a match, we're done. If we didn't, create a new element + // and add it to the list. + // + if (ListPtr != NULL) { + // + // Print a message if verbose mode + // + if (mGlobals.Verbose) { + DebugMsg (NULL, 0, 0, FileName, "duplicate include -- not processed again"); + } + + return STATUS_SUCCESS; + } + + ListPtr = malloc (sizeof (STRING_LIST)); + ListPtr->Str = malloc (strlen (FileName) + 1); + strcpy (ListPtr->Str, FileName); + ListPtr->Next = ProcessedFiles->Next; + ProcessedFiles->Next = ListPtr; + } + + // + // Make sure we didn't exceed our maximum nesting depth + // + if (NestDepth > MAX_NEST_DEPTH) { + Error (NULL, 0, 0, FileName, "max nesting depth exceeded on file"); + goto Finish; + } + // + // Make a local copy of the filename. Then we can manipulate it + // if we have to. + // + strcpy (FileNameCopy, FileName); + // + // Try to open the file locally + // + if ((Fptr = fopen (FileNameCopy, "r")) == NULL) { + // + // Try to find it among the paths. + // + Fptr = FindFile (FileNameCopy, sizeof (FileNameCopy)); + if (Fptr == NULL) { + // + // If this is not the top-level file, and the command-line argument + // said to ignore missing files, then return ok + // + if (NestDepth != START_NEST_DEPTH) { + if (mGlobals.IgnoreNotFound) { + if (!mGlobals.QuietMode) { + DebugMsg (NULL, 0, 0, FileNameCopy, "could not find file"); + } + + return STATUS_SUCCESS; + } else { + Error (NULL, 0, 0, FileNameCopy, "could not find file"); + return STATUS_ERROR; + } + } else { + // + // Top-level (first) file. Emit an error. + // + Error (NULL, 0, 0, FileNameCopy, "could not find file"); + return STATUS_ERROR; + } + } + } + // + // Print the dependency, with string substitution + // + PrintDependency (TargetFileName, FileNameCopy); + + // + // Now read in lines and find all #include lines. Allow them to indent, and + // to put spaces between the # and include. + // + LineNum = 0; + while ((fgets (Line, sizeof (Line), Fptr) != NULL) && (Status == STATUS_SUCCESS)) { + LineNum++; + Cptr = Line; + // + // Skip preceeding spaces on the line + // + while (*Cptr && (isspace (*Cptr))) { + Cptr++; + } + // + // Check for # character, there is no # for asm + // + if ((*Cptr == '#') || (mGlobals.IsAsm)) { + if (*Cptr == '#') { + Cptr++; + } + + // + // Check for "include", case insensitive for asm + // + while (*Cptr && (isspace (*Cptr))) { + Cptr++; + } + if (((!mGlobals.IsAsm) && (strncmp (Cptr, "include", 7) == 0)) || + (mGlobals.IsAsm && (_strnicmp (Cptr, "include", 7) == 0))) { + // + // Skip over "include" and move on to filename as "file" or or file for asm + // + Cptr += 7; + while (*Cptr && (isspace (*Cptr))) { + Cptr++; + } + + if (*Cptr == '<') { + EndChar = '>'; + } else if (*Cptr == '"') { + EndChar = '"'; + } else if (mGlobals.IsAsm) { + // + // Handle include file for asm + // Set EndChar to null so we fall through on processing below. + // + EndChar = 0; + + // + // Look for the end of include file name + // + EndPtr = Cptr; + while (*EndPtr && (!isspace (*EndPtr))) { + EndPtr++; + } + + // + // Null terminate the filename and try to process it. + // + *EndPtr = 0; + Status = ProcessFile (TargetFileName, Cptr, NestDepth + 1, ProcessedFiles); + } else { + // + // Handle special #include MACRO_NAME(file) + // Set EndChar to null so we fall through on processing below. + // + EndChar = 0; + // + // Look for all the special include macros and convert accordingly. + // + for (Index = 0; mMacroConversion[Index].IncludeMacroName != NULL; Index++) { + // + // Save the start of the string in case some macros are substrings + // of others. + // + SaveCptr = Cptr; + if (strncmp ( + Cptr, + mMacroConversion[Index].IncludeMacroName, + strlen (mMacroConversion[Index].IncludeMacroName) + ) == 0) { + // + // Skip over the macro name + // + Cptr += strlen (mMacroConversion[Index].IncludeMacroName); + // + // Skip over open parenthesis, blank spaces, then find closing + // parenthesis or blank space + // + while (*Cptr && (isspace (*Cptr))) { + Cptr++; + } + + if (*Cptr == '(') { + Cptr++; + while (*Cptr && (isspace (*Cptr))) { + Cptr++; + } + + EndPtr = Cptr; + while (*EndPtr && !isspace (*EndPtr) && (*EndPtr != ')')) { + EndPtr++; + } + + *EndPtr = 0; + // + // Create the path + // + strcpy (MacroIncludeFileName, mMacroConversion[Index].PathName); + strcat (MacroIncludeFileName, Cptr); + strcat (MacroIncludeFileName, "\\"); + strcat (MacroIncludeFileName, Cptr); + strcat (MacroIncludeFileName, ".h"); + // + // Process immediately, then break out of the outside FOR loop. + // + Status = ProcessFile (TargetFileName, MacroIncludeFileName, NestDepth + 1, ProcessedFiles); + break; + } + } + // + // Restore the start + // + Cptr = SaveCptr; + } + // + // Don't recognize the include line? Ignore it. We assume that the + // file compiles anyway. + // + if (mMacroConversion[Index].IncludeMacroName == NULL) { + // + // Warning (FileNameCopy, LineNum, 0, "could not parse line", NULL); + // Status = STATUS_WARNING; + // + } + } + // + // Process "normal" includes. If the endchar is 0, then the + // file has already been processed. Otherwise look for the + // endchar > or ", and process the include file. + // + if (EndChar != 0) { + Cptr++; + EndPtr = Cptr; + while (*EndPtr && (*EndPtr != EndChar)) { + EndPtr++; + } + + if (*EndPtr == EndChar) { + // + // If we're processing it, do it + // + if ((EndChar != '>') || (!mGlobals.NoSystem)) { + // + // Null terminate the filename and try to process it. + // + *EndPtr = 0; + Status = ProcessFile (TargetFileName, Cptr, NestDepth + 1, ProcessedFiles); + } + } else { + Warning (FileNameCopy, LineNum, 0, "malformed include", "missing closing %c", EndChar); + Status = STATUS_WARNING; + goto Finish; + } + } + } + } + } + +Finish: + // + // Close open files and return status + // + if (Fptr != NULL) { + fclose (Fptr); + } + + return Status; +} + +static +void +PrintDependency ( + INT8 *TargetFileName, + INT8 *DependentFile + ) +/*++ + +Routine Description: + + Given a target (.obj) file name, and a dependent file name, do any string + substitutions (per the command line options) on the file names, then + print the dependency line of form: + + TargetFileName : DependentFile + +Arguments: + + TargetFileName - build target file name + DependentFile - file on which TargetFileName depends + +Returns: + + None + +--*/ +{ + INT8 Str[MAX_PATH]; + + // + // Go through the symbols and do replacements + // + strcpy (Str, TargetFileName); + ReplaceSymbols (Str, sizeof (Str)); + fprintf (mGlobals.OutFptr, "%s : ", Str); + strcpy (Str, DependentFile); + ReplaceSymbols (Str, sizeof (Str)); + fprintf (mGlobals.OutFptr, "%s\n", Str); + // + // Add pseudo target to avoid incremental build failure when the file is deleted + // + fprintf (mGlobals.OutFptr, "%s : \n", Str); +} + +static +void +ReplaceSymbols ( + INT8 *Str, + UINT32 StrSize + ) +{ + SYMBOL *Sym; + INT8 StrCopy[MAX_LINE_LEN]; + INT8 *From; + INT8 *To; + BOOLEAN Replaced; + + // + // Go through the entire string to look for replacement strings at + // every position. + // + From = Str; + To = StrCopy; + while (*From) { + // + // Copy the character + // + *To = *From; + Replaced = FALSE; + // + // Go through each symbol and try to find a string substitution + // + Sym = mGlobals.SymbolTable; + while (Sym != NULL) { + if (_strnicmp (From, Sym->Value, strlen (Sym->Value)) == 0) { + // + // Replace the string, then advance the pointers past the + // replaced strings + // + strcpy (To, Sym->Name); + To += strlen (Sym->Name); + From += strlen (Sym->Value); + Replaced = TRUE; + // + // Break from the while() + // + break; + } else { + Sym = Sym->Next; + } + } + + if (!Replaced) { + From++; + To++; + } + } + // + // Null terminate, and return it + // + *To = 0; + if (strlen (StrCopy) < StrSize) { + strcpy (Str, StrCopy); + } +} +// +// Given a filename, try to find it along the include paths. +// +static +FILE * +FindFile ( + INT8 *FileName, + UINT32 FileNameLen + ) +{ + FILE *Fptr; + STRING_LIST *List; + STRING_LIST *SubDir; + INT8 FullFileName[MAX_PATH * 2]; + + // + // Traverse the list of paths and try to find the file + // + List = mGlobals.IncludePaths; + while (List != NULL) { + // + // Put the path and filename together + // + if (strlen (List->Str) + strlen (FileName) + 1 > sizeof (FullFileName)) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "cannot concatenate '%s' + '%s'", + List->Str, + FileName + ); + return NULL; + } + // + // Append the filename to this include path and try to open the file. + // + strcpy (FullFileName, List->Str); + strcat (FullFileName, FileName); + if ((Fptr = fopen (FullFileName, "r")) != NULL) { + // + // Return the file name + // + if (FileNameLen <= strlen (FullFileName)) { + Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length"); + // + // fprintf (stdout, "File length > %d: %s\n", FileNameLen, FullFileName); + // + return NULL; + } + + strcpy (FileName, FullFileName); + return Fptr; + } + // + // Didn't find it there. Now try this directory with every subdirectory + // the user specified on the command line + // + for (SubDir = mGlobals.SubDirs; SubDir != NULL; SubDir = SubDir->Next) { + strcpy (FullFileName, List->Str); + strcat (FullFileName, SubDir->Str); + strcat (FullFileName, FileName); + if ((Fptr = fopen (FullFileName, "r")) != NULL) { + // + // Return the file name + // + if (FileNameLen <= strlen (FullFileName)) { + Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length"); + return NULL; + } + + strcpy (FileName, FullFileName); + return Fptr; + } + } + + List = List->Next; + } + // + // Not found + // + return NULL; +} +// +// Process the command-line arguments +// +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ) +{ + STRING_LIST *NewList; + STRING_LIST *LastIncludePath; + STRING_LIST *LastSourceFile; + SYMBOL *Symbol; + int Index; + // + // Clear our globals + // + memset ((char *) &mGlobals, 0, sizeof (mGlobals)); + mGlobals.NoDupes = TRUE; + // + // Skip program name + // + Argc--; + Argv++; + // + // Initialize locals + // + LastIncludePath = NULL; + LastSourceFile = NULL; + // + // Process until no more args + // + while (Argc) { + // + // -i path add include search path + // + if (_stricmp (Argv[0], "-i") == 0) { + // + // check for one more arg + // + if (Argc > 1) { + // + // Allocate memory for a new list element, fill it in, and + // add it to our list of include paths. Always make sure it + // has a "\" on the end of it. + // + NewList = malloc (sizeof (STRING_LIST)); + if (NewList == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + NewList->Next = NULL; + NewList->Str = malloc (strlen (Argv[1]) + 2); + if (NewList->Str == NULL) { + free (NewList); + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[1]); + if (NewList->Str[strlen (NewList->Str) - 1] != '\\') { + strcat (NewList->Str, "\\"); + } + // + // Add it to the end of the our list of include paths + // + if (mGlobals.IncludePaths == NULL) { + mGlobals.IncludePaths = NewList; + } else { + LastIncludePath->Next = NewList; + } + + LastIncludePath = NewList; + // + // fprintf (stdout, "Added path: %s\n", NewList->Str); + // + } else { + Error (NULL, 0, 0, Argv[0], "option requires an include path"); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-f") == 0) { + // + // Check for one more arg + // + if (Argc > 1) { + // + // Allocate memory for a new list element, fill it in, and + // add it to our list of source files. + // + NewList = malloc (sizeof (STRING_LIST)); + if (NewList == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + NewList->Next = NULL; + // + // Allocate space to replace ".c" with ".obj", plus null termination + // + NewList->Str = malloc (strlen (Argv[1]) + 5); + if (NewList->Str == NULL) { + free (NewList); + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[1]); + if (mGlobals.SourceFiles == NULL) { + mGlobals.SourceFiles = NewList; + } else { + LastSourceFile->Next = NewList; + } + + LastSourceFile = NewList; + } else { + Error (NULL, 0, 0, Argv[0], "option requires a file name"); + Usage (); + return STATUS_ERROR; + } + // + // The C compiler first looks for #include files in the directory where + // the source file came from. Add the file's source directory to the + // list of include paths. + // + NewList = malloc (sizeof (STRING_LIST)); + if (NewList == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + NewList->Next = NULL; + NewList->Str = malloc (strlen (Argv[1]) + 3); + if (NewList->Str == NULL) { + free (NewList); + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[1]); + // + // Back up in the source file name to the last backslash and terminate after it. + // + for (Index = strlen (NewList->Str) - 1; (Index > 0) && (NewList->Str[Index] != '\\'); Index--) + ; + if (Index < 0) { + strcpy (NewList->Str, ".\\"); + } else { + NewList->Str[Index + 1] = 0; + } + // + // Add it to the end of the our list of include paths + // + if (mGlobals.IncludePaths == NULL) { + mGlobals.IncludePaths = NewList; + } else { + LastIncludePath->Next = NewList; + } + + if (mGlobals.Verbose) { + fprintf (stdout, "Adding include path: %s\n", NewList->Str); + } + + LastIncludePath = NewList; + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-s") == 0) { + // + // -s subdir add subdirectory subdir to list of subdirecties to scan. + // Check for one more arg first. + // + if (Argc > 1) { + // + // Allocate memory for a new list element, fill it in, and + // add it to our list of subdirectory include paths. Always + // make sure it has a "\" on the end of it. + // + NewList = malloc (sizeof (STRING_LIST)); + if (NewList == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + NewList->Str = malloc (strlen (Argv[1]) + 2); + if (NewList->Str == NULL) { + free (NewList); + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[1]); + if (NewList->Str[strlen (NewList->Str) - 1] != '\\') { + strcat (NewList->Str, "\\"); + } + + NewList->Next = mGlobals.SubDirs; + mGlobals.SubDirs = NewList; + } else { + Error (NULL, 0, 0, Argv[0], "option requires a subdirectory name"); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-sub") == 0) { + // + // -sub symname symvalue to do string substitution in the output + // + if (Argc > 2) { + // + // Allocate memory for the symbol object + // + Symbol = malloc (sizeof (SYMBOL)); + if (Symbol == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + // + // Allocate memory for the symbol name and value, then save copies + // + Symbol->Name = malloc (strlen (Argv[1]) + 1); + if (Symbol->Name == NULL) { + free (Symbol); + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (Symbol->Name, Argv[1]); + Symbol->Value = malloc (strlen (Argv[2]) + 1); + if (Symbol->Value == NULL) { + free (Symbol->Name); + free (Symbol); + Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (Symbol->Value, Argv[2]); + // + // Add it to the list + // + Symbol->Next = mGlobals.SymbolTable; + mGlobals.SymbolTable = Symbol; + } else { + Error (NULL, 0, 0, Argv[0], "option requires a symbol name and value"); + Usage (); + return STATUS_ERROR; + } + // + // Skip over args + // + Argc -= 2; + Argv += 2; + } else if (_stricmp (Argv[0], "-nosystem") == 0) { + mGlobals.NoSystem = TRUE; + } else if (_stricmp (Argv[0], "-nodupes") == 0) { + mGlobals.NoDupes = TRUE; + } else if (_stricmp (Argv[0], "-nodups") == 0) { + mGlobals.NoDupes = TRUE; + } else if (_stricmp (Argv[0], "-target") == 0) { + // + // -target TargetFileName - Target object file (only one allowed right + // now) is TargetFileName rather than SourceFile.obj + // + if (Argc > 1) { + strcpy (mGlobals.TargetFileName, Argv[1]); + } else { + Error (NULL, 0, 0, Argv[0], "option requires a target file name"); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-usesumdeps") == 0) { + // + // -usesumdeps Path - if we find an included file xxx.h, and file + // Path/xxx.dep exists, list Path/xxx.dep as a dependency rather than + // xxx.h and don't parse xxx.h. This allows you to create a dependency + // file for a commonly included file, and have its dependency file updated + // only if its included files are updated. Then anyone else including this + // common include file can simply have a dependency on that file's .dep file + // rather than on all the files included by it. Confusing enough? + // + mGlobals.UseSumDeps = 1; + if (Argc > 1) { + strcpy (mGlobals.SumDepsPath, Argv[1]); + // + // Add slash on end if not there + // + if (mGlobals.SumDepsPath[strlen (mGlobals.SumDepsPath) - 1] != '\\') { + strcat (mGlobals.SumDepsPath, "\\"); + } + } else { + Error (NULL, 0, 0, Argv[0], "option requires path to summary dependency files"); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + + } else if (_stricmp (Argv[0], "-o") == 0) { + // + // -o OutputFileName - specify an output filename for dependency list + // check for one more arg + // + if (Argc > 1) { + // + // Try to open the file + // + if ((mGlobals.OutFptr = fopen (Argv[1], "w")) == NULL) { + Error (NULL, 0, 0, Argv[1], "could not open file for writing"); + return STATUS_ERROR; + } + + mGlobals.OutFileName = Argv[1]; + } else { + Error (NULL, 0, 0, Argv[0], "option requires output file name"); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-v") == 0) { + mGlobals.Verbose = TRUE; + } else if (_stricmp (Argv[0], "-neverfail") == 0) { + mGlobals.NeverFail = TRUE; + } else if (_stricmp (Argv[0], "-q") == 0) { + mGlobals.QuietMode = TRUE; + } else if (_stricmp (Argv[0], "-ignorenotfound") == 0) { + mGlobals.IgnoreNotFound = TRUE; + } else if (_stricmp (Argv[0], "-asm") == 0) { + mGlobals.IsAsm = TRUE; + } else if ((_stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) { + Usage (); + return STATUS_ERROR; + } else { + Error (NULL, 0, 0, Argv[0], "unrecognized option"); + Usage (); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } + // + // Had to specify at least one source file + // + if (mGlobals.SourceFiles == NULL) { + Error (NULL, 0, 0, "must specify one source file name", NULL); + Usage (); + return STATUS_ERROR; + } + // + // Assume output to stdout if not specified + // + if (mGlobals.OutFptr == NULL) { + mGlobals.OutFptr = stdout; + } + + return STATUS_SUCCESS; +} +// +// Free the global string lists we allocated memory for +// +static +void +FreeLists ( + VOID + ) +{ + STRING_LIST *Temp; + SYMBOL *NextSym; + + // + // printf ("Free lists....."); + // + // Traverse the include paths, freeing each + // printf ("freeing include paths\n"); + // + while (mGlobals.IncludePaths != NULL) { + Temp = mGlobals.IncludePaths->Next; + // + // printf ("Freeing include path string '%s' at 0x%X\n", + // mGlobals.IncludePaths->Str, (int)(mGlobals.IncludePaths->Str)); + // + free (mGlobals.IncludePaths->Str); + // + // printf ("Freeing include path object at 0x%X\n", (int)(mGlobals.IncludePaths)); + // + free (mGlobals.IncludePaths); + mGlobals.IncludePaths = Temp; + } + // + // Traverse the source files, freeing each + // + while (mGlobals.SourceFiles != NULL) { + Temp = mGlobals.SourceFiles->Next; + free (mGlobals.SourceFiles->Str); + free (mGlobals.SourceFiles); + mGlobals.SourceFiles = Temp; + } + // + // Traverse the subdirectory list, freeing each + // + while (mGlobals.SubDirs != NULL) { + Temp = mGlobals.SubDirs->Next; + free (mGlobals.SubDirs->Str); + free (mGlobals.SubDirs); + mGlobals.SubDirs = Temp; + } + // + // Free the symbol table + // + while (mGlobals.SymbolTable != NULL) { + NextSym = mGlobals.SymbolTable->Next; + free (mGlobals.SymbolTable->Name); + free (mGlobals.SymbolTable->Value); + mGlobals.SymbolTable = NextSym; + } + // + // printf ("done\n"); + // +} + +static +void +Usage ( + VOID + ) +/*++ + +Routine Description: + + Print usage information for this utility. + +Arguments: + + None. + +Returns: + + Nothing. + +--*/ +{ + int Index; + static const char *Str[] = { + UTILITY_NAME " -- make dependencies", + " Usage: MakeDeps [options]", + " Options include:", + " -h or -? for this help information", + " -f SourceFile add SourceFile to list of files to scan", + " -i IncludePath add IncludePath to list of search paths", + " -o OutputFile write output dependencies to OutputFile", + " -s SubDir for each IncludePath, also search IncludePath\\SubDir", + " -v for verbose output", + " -ignorenotfound don't warn for files not found", + " -target Target for single SourceFile, target is Target, not SourceFile.obj", + " -q quiet mode to not report files not found if ignored", + " -sub sym str replace all occurrances of 'str' with 'sym' in the output", + " -nosystem not process system files", + " -neverfail always return a success return code", + // + // " -nodupes keep track of include files, don't rescan duplicates", + // + " -usesumdeps path use summary dependency files in 'path' directory.", + " -asm The SourceFile is assembler file", + "", + NULL + }; + for (Index = 0; Str[Index] != NULL; Index++) { + fprintf (stdout, "%s\n", Str[Index]); + } +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/Makefile new file mode 100644 index 0000000000..4cd9084f8e --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/Makefile @@ -0,0 +1,69 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the MakeDeps utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Target specific information +# +TARGET_NAME = MakeDeps +TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\MakeDeps +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\MakeDeps.exe + +OBJECTS = $(EDK_TOOLS_OUTPUT)\MakeDeps.obj +LIBS = $(LIBS) $(EDK_TOOLS_OUTPUT)\Common.lib + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Compile each tool source file +# +$(OBJECTS) : $(TARGET_SRC_DIR)\MakeDeps.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\MakeDeps.c /Fo$@ + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) $(LIBS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/Makefile new file mode 100644 index 0000000000..974c9b4aa9 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/Makefile @@ -0,0 +1,79 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI build tools. +# +#--*/ + +# +# Everything depends on EDK_SOURCE. Make sure it's defined +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Define our toolchain before we include the master settings file +# +TOOLCHAIN = TOOLCHAIN_MSVC + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define all the makefiles we want to call +# + +MAKEFILES = $(EDK_TOOLS_SOURCE)\Common\Makefile \ + $(CUSTOMIZEDCOMPRESS_MAKEFILE) \ + $(EDK_TOOLS_SOURCE)\GenCRC32Section\Makefile \ + $(EDK_TOOLS_SOURCE)\GenSection\Makefile \ + $(EDK_TOOLS_SOURCE)\GenDepex\Makefile \ + $(EDK_TOOLS_SOURCE)\GenFfsFile\Makefile \ + $(EDK_TOOLS_SOURCE)\GenFvImage\Makefile \ + $(EDK_TOOLS_SOURCE)\FwImage\Makefile \ + $(EDK_TOOLS_SOURCE)\ProcessDsc\makefile \ + $(EDK_TOOLS_SOURCE)\GuidChk\makefile \ + $(EDK_TOOLS_SOURCE)\MakeDeps\makefile \ + $(EDK_TOOLS_SOURCE)\SetStamp\makefile \ + $(EDK_TOOLS_SOURCE)\VfrCompile\makefile \ + $(EDK_TOOLS_SOURCE)\StrGather\makefile \ + $(EDK_TOOLS_SOURCE)\BootsectImage\Makefile \ + $(EDK_TOOLS_SOURCE)\GenBootsector\Makefile \ + $(EDK_TOOLS_SOURCE)\GenPage\Makefile \ + $(EDK_TOOLS_SOURCE)\SplitFile\Makefile \ + $(EDK_TOOLS_SOURCE)\EfiCompress\Makefile \ + $(EDK_TOOLS_SOURCE)\EfildrImage\Makefile \ + $(EDK_TOOLS_SOURCE)\EfiRom\Makefile \ + $(EDK_TOOLS_SOURCE)\GenAprioriFile\Makefile \ + $(EDK_TOOLS_SOURCE)\ModifyInf\Makefile + + + +# +# Define default all target which calls all our makefiles. The special +# bang (!) tells nmake to do the command for each out-of-date dependent. +# +# Create the BIN directory, which will only exist if you pull the source tree +# from version control. +# +all : $(MAKEFILES) + -if not exist $(EDK_TOOLS_OUTPUT) mkdir $(EDK_TOOLS_OUTPUT) + !$(MAKE) -f $? TOOLCHAIN=$(TOOLCHAIN) BUILD_DIR=$(BUILD_DIR) all + +# +# Call all the tools makefiles with a clean target. +# +clean : $(MAKEFILES) + !$(MAKE) -f $? TOOLCHAIN=$(TOOLCHAIN) clean diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/Makefile new file mode 100644 index 0000000000..f303a54d10 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/Makefile @@ -0,0 +1,82 @@ +#/*++ +# +# Copyright (c) 2001 - 2006 Intel Corporation. +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Target specific information +# + +TARGET_NAME = ModifyInf +TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SRC_DIR)\ModifyInf.c" +TARGET_EXE_INCLUDE = +OBJECTS = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c new file mode 100644 index 0000000000..edfcba00a9 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c @@ -0,0 +1,322 @@ +/*++ + +Copyright (c) 1999 - 2002 Intel Corporation. +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ModifyInf.c + +Abstract: + + It is a simple tool to modify some fields in a FV inf file + and output a new FV inf file. + +--*/ + +#include "stdio.h" +#include "string.h" + +// +// Read a line into buffer including '\r\n' +// +int +ReadLine ( + char *LineBuffer, + FILE *fp + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + LineBuffer - GC_TODO: add argument description + fp - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + int CharC; + char *Line; + + Line = LineBuffer; + + while ((CharC = fgetc (fp)) != EOF) { + *Line++ = (char) CharC; + if (CharC == 0x0a) { + break; + } + } + + *Line = 0; + + if (CharC == EOF) { + return 0; + } else { + return 1; + } + +} +// +// Write a line into output file +// +int +WriteLine ( + char *Line, + FILE *fp + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + Line - GC_TODO: add argument description + fp - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + fwrite (Line, strlen (Line), 1, fp); + return 0; +} +// +// Apply patterns to a line +// Currently there are 2 patterns to support +// '==' replace a field value with a new value +// '+=' append a string at the end of original line +// '-' prevent the line from applying any patterns +// it has the highest priority +// +int +ApplyPattern ( + char *Line, + char *argv[], + int argc + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + Line - GC_TODO: add argument description + ] - GC_TODO: add argument description + argc - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + static char Section[256]; + int SectionLength; + char PatternBuffer[256]; + char *Pattern; + char *Pattern1; + char *Pattern2; + int PatternNum; + char *Ptr; + + Pattern = PatternBuffer; + + PatternNum = argc; + + // + // For section field + // record current scope section into static buffer + // + Ptr = Line; + if (*Ptr == '[') { + while (*Ptr != ']') { + if (!(*Ptr++)) { + return -1; + } + } + SectionLength = Ptr - Line + 1; + SectionLength = SectionLength > 255 ? 255 : SectionLength; + strncpy (Section, Line, SectionLength); + Section[SectionLength] = 0; + } + // + // Apply each pattern on the line + // + while (PatternNum-- > 3) { + + strcpy (Pattern, argv[PatternNum]); + + // + // For pattern '-' + // keep it unmodified by other patterns + // + if (*Pattern == '-') { + if (strstr (Line, Pattern + 1)) { + return 0; + } else { + continue; + } + } + // + // For other patterns + // get its section at first if it has + // + if (*Pattern == '[') { + if (strncmp (Section, Pattern, strlen (Section))) { + // + // This pattern can't be appied for current section + // + continue; + } + // + // Strip the section field + // + while (*Pattern != ']') { + if (!(*Pattern++)) { + return -1; + } + } + + Pattern++; + } + // + // Apply patterns + // + Pattern1 = strstr (Pattern, "=="); + Pattern2 = strstr (Pattern, "+="); + if (Pattern1) { + // + // For pattern '==' + // replace the field value with a new string + // + if (!strncmp (Line, Pattern, Pattern1 - Pattern)) { + Pattern1 += 2; + Ptr = strstr (Line, "="); + if (!Ptr) { + return -1; + } + + while (*(++Ptr) == ' ') + ; + *Ptr = 0; + strcat (Line, Pattern1); + strcat (Line, "\r\n"); + } + } else if (Pattern2) { + // + // For pattern '+=' + // append a string at end of the original string + // + if (!strncmp (Line, Pattern, Pattern2 - Pattern)) { + Pattern2 += 2; + Ptr = Line; + while (*Ptr != 0x0D && *Ptr != 0x0A) { + Ptr++; + } + + *Ptr = 0; + strcat (Line, Pattern2); + strcat (Line, "\r\n"); + } + } + } + + return 0; +} + +void +Usage ( + void + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + None + +Returns: + + GC_TODO: add return values + +--*/ +{ + printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n"); +} + +int +main ( + int argc, + char*argv[] + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + argc - GC_TODO: add argument description + ] - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + char LineBuffer[256]; + FILE *fpin; + FILE *fpout; + + if (argc < 3) { + Usage (); + return -1; + } + + fpin = fopen (argv[1], "rb"); + if (!fpin) { + printf ("Can't open input file!\r\n"); + return -1; + } + + fpout = fopen (argv[2], "wb"); + if (!fpout) { + fclose (fpin); + printf ("Can't create output file!\r\n"); + return -1; + } + + while (ReadLine (LineBuffer, fpin)) { + ApplyPattern (LineBuffer, argv, argc); + WriteLine (LineBuffer, fpout); + } + + fclose (fpin); + fclose (fpout); + + return 0; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Common.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Common.h new file mode 100644 index 0000000000..b642d092cb --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Common.h @@ -0,0 +1,123 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Common.h + +Abstract: + + Common include file for the ProcessDsc utility. + +--*/ + +#ifndef _COMMON_H_ +#define _COMMON_H_ + +typedef char INT8; +typedef unsigned int UINT32; + +#include "EfiUtilityMsgs.h" + +#define MAX_LINE_LEN 1024 + +#ifdef MAX_PATH +#undef MAX_PATH +#define MAX_PATH 1024 +#endif + +// +// Defines for how to expand symbols +// +#define EXPANDMODE_NO_UNDEFS 0x01 +#define EXPANDMODE_NO_DESTDIR 0x02 +#define EXPANDMODE_NO_SOURCEDIR 0x04 +#define EXPANDMODE_RECURSIVE 0x08 + +// +// Defines for adding symbols +// +#define SYM_OVERWRITE 0x01 // overwrite existing assignments +#define SYM_GLOBAL 0x02 // global symbol (persistent) +#define SYM_LOCAL 0x04 // symbols at component level +#define SYM_FILE 0x08 // symbols at file level +#define SYM_FILEPATH 0x10 // symbol is a file path +#define SYM_FILENAME 0x20 // symbol is a file name +#define FV_DIR "FV_DIR" // symbol for base dir where FV files are +#define DSC_FILENAME "DSC_FILENAME" + +// +// Smart file for better incremental build support. +// Only re-create .pkg .inf or .apr files when it's content is changed. +// +// +typedef struct _SMART_FILE { + char *FileName; + char *FileContent; // Previous file content + int FileLength; // Previous file string length + int FilePosition; // The offset from FileContent for next comparison + FILE *FilePtr; // New file pointer if the file need to be re-created +} SMART_FILE; + +SMART_FILE * +SmartOpen ( + char *FileName + ); + +int +SmartWrite ( + SMART_FILE *SmartFile, + char *String + ); + +void +SmartClose ( + SMART_FILE *SmartFile + ); + +INT8 * +GetSymbolValue ( + INT8 *SymbolName + ); + +int +AddSymbol ( + INT8 *Name, + INT8 *Value, + int Mode + ); + +int +ExpandSymbols ( + INT8 *SourceLine, + INT8 *DestLine, + int LineLen, + int ExpandMode + ); + +void +Message ( + UINT32 PrintMask, + INT8 *Fmt, + ... + ); + +int +MakeFilePath ( + INT8 *FileName + ); + +int +IsAbsolutePath ( + INT8 *FileName + ); + +#endif // ifndef _COMMON_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.c new file mode 100644 index 0000000000..345e1a9e4a --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.c @@ -0,0 +1,534 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: + + DscFile.c + + Abstract: + + This module is used to process description files at a high level. For the + most part, it pre-parses the file to find and save off positions of all + the sections ([section.subsection.subsection]) in a linked list, then + provides services to find the sections by name, and read the lines from + the section until you run into the next section. + + NOTE: DSC file is synonomous with section file. A DSC file is simply a file + containing bracketed section names [section.subsection.subsection...] + +--*/ + +#include // for file ops +#include +#include +#include // for malloc +#include "Common.h" +#include "DSCFile.h" + +#define MAX_INCLUDE_NEST_LEVEL 20 + +static +void +DSCFileFree ( + DSC_FILE *DSC + ); + +static +STATUS +DSCParseInclude ( + DSC_FILE *DSC, + char *FileName, + int NestLevel + ); + +// +// Constructor for a DSC file +// +int +DSCFileInit ( + DSC_FILE *DSC + ) +{ + memset ((char *) DSC, 0, sizeof (DSC_FILE)); + DSC->SavedPositionIndex = -1; + return STATUS_SUCCESS; +} +// +// Destructor for a DSC file +// +int +DSCFileDestroy ( + DSC_FILE *DSC + ) +{ + DSC->SavedPositionIndex = -1; + DSCFileFree (DSC); + return STATUS_SUCCESS; +} +// +// Get the next line from a DSC file. +// +char * +DSCFileGetLine ( + DSC_FILE *DSC, + char *Line, + int LineLen + ) +{ + char *Cptr; + + if (DSC->CurrentLine == NULL) { + return NULL; + } + // + // Check for running into next section + // + if (DSC->CurrentLine->Line[0] == '[') { + return NULL; + } + // + // Allow special case where the line starts with backslash-bracket. If we + // see this, then shift everything left one character. + // + if ((DSC->CurrentLine->Line[0] == '\\') && (DSC->CurrentLine->Line[1] == '[')) { + Cptr = DSC->CurrentLine->Line + 1; + } else { + Cptr = DSC->CurrentLine->Line; + } + + strncpy (Line, Cptr, LineLen); + ParserSetPosition (DSC->CurrentLine->FileName, DSC->CurrentLine->LineNum); + DSC->CurrentLine = DSC->CurrentLine->Next; + return Line; +} + +int +DSCFileSetFile ( + DSC_FILE *DSC, + char *FileName + ) +/*++ + +Routine Description: + + Pre-scan a section file to find all the sections. Then we can speed up + searching for the different sections. + +Arguments: + + DSC - pointer to a DSC structure (this pointer) + FileName - name of the file to process + +Returns: + + STATUS_SUCCESS if everything went well. + +--*/ +{ + STATUS Status; + + // + // Called to open a new sectioned file. + // + Status = DSCParseInclude (DSC, FileName, 1); + return Status; +} + +static +STATUS +DSCParseInclude ( + DSC_FILE *DSC, + char *FileName, + int NestLevel + ) +{ + SECTION *NewSect; + SECTION_LINE *NewLine; + DSC_FILE_NAME *NewDscFileName; + char Line[MAX_LINE_LEN]; + char *Start; + char *End; + char SaveChar; + char *TempCptr; + char ShortHandSectionName[MAX_LINE_LEN]; + char ThisSectionName[MAX_LINE_LEN]; + SECTION *CurrSect; + SECTION *TempSect; + FILE *FilePtr; + STATUS Status; + UINT32 LineNum; + + // + // Make sure we haven't exceeded our maximum nesting level + // + if (NestLevel > MAX_INCLUDE_NEST_LEVEL) { + Error (NULL, 0, 0, "application error", "maximum !include nesting level exceeded"); + return STATUS_ERROR; + } + // + // Try to open the file + // + if ((FilePtr = fopen (FileName, "r")) == NULL) { + // + // This function is called to handle the DSC file from the command line too, + // so differentiate whether this file is an include file or the main file + // by examining the nest level. + // + if (NestLevel == 1) { + Error (NULL, 0, 0, FileName, "could not open DSC file for reading"); + } else { + Error (NULL, 0, 0, FileName, "could not open !include DSC file for reading"); + } + + return STATUS_ERROR; + } + // + // We keep a linked list of files we parse for error reporting purposes. + // + NewDscFileName = malloc (sizeof (DSC_FILE_NAME)); + if (NewDscFileName == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL); + return STATUS_ERROR; + } + + memset (NewDscFileName, 0, sizeof (DSC_FILE_NAME)); + NewDscFileName->FileName = (INT8 *) malloc (strlen (FileName) + 1); + if (NewDscFileName->FileName == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL); + return STATUS_ERROR; + } + + strcpy (NewDscFileName->FileName, FileName); + if (DSC->FileName == NULL) { + DSC->FileName = NewDscFileName; + } else { + DSC->LastFileName->Next = NewDscFileName; + } + + DSC->LastFileName = NewDscFileName; + // + // Read lines and process until done + // + Status = STATUS_SUCCESS; + LineNum = 0; + for (;;) { + if (fgets (Line, sizeof (Line), FilePtr) == NULL) { + break; + } + + LineNum++; + ParserSetPosition (FileName, LineNum); + // + // Add the line to our list if it's not a !include line + // + if ((strncmp (Line, "!include", 8) == 0) && (isspace (Line[8]))) { + Start = Line + 9; + while (*Start && (*Start != '"')) { + Start++; + } + + if (*Start != '"') { + Error (FileName, LineNum, 0, NULL, "invalid format for !include"); + Status = STATUS_ERROR; + goto Done; + } + + Start++; + for (End = Start; *End && (*End != '"'); End++) + ; + if (*End != '"') { + Error (FileName, LineNum, 0, NULL, "invalid format for !include"); + Status = STATUS_ERROR; + goto Done; + } + + *End = 0; + // + // Expand symbols. Use 'ThisSectionName' as scratchpad + // + ExpandSymbols (Start, ThisSectionName, sizeof (ThisSectionName), EXPANDMODE_NO_UNDEFS); + Status = DSCParseInclude (DSC, ThisSectionName, NestLevel + 1); + if (Status != STATUS_SUCCESS) { + Error (FileName, LineNum, 0, NULL, "failed to parse !include file"); + goto Done; + } + } else { + NewLine = (SECTION_LINE *) malloc (sizeof (SECTION_LINE)); + if (NewLine == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + Status = STATUS_ERROR; + goto Done; + } + + memset ((char *) NewLine, 0, sizeof (SECTION_LINE)); + NewLine->LineNum = LineNum; + NewLine->FileName = NewDscFileName->FileName; + NewLine->Line = (char *) malloc (strlen (Line) + 1); + if (NewLine->Line == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + Status = STATUS_ERROR; + goto Done; + } + + strcpy (NewLine->Line, Line); + if (DSC->Lines == NULL) { + DSC->Lines = NewLine; + } else { + DSC->LastLine->Next = NewLine; + } + + DSC->LastLine = NewLine; + // + // Parse the line for []. Ignore [] and [----] delimiters. The + // line may have multiple definitions separated by commas, so + // take each separately + // + Start = Line; + if ((Line[0] == '[') && ((Line[1] != ']') && (Line[1] != '-'))) { + // + // Skip over open bracket and preceeding spaces + // + Start++; + ShortHandSectionName[0] = 0; + + while (*Start && (*Start != ']')) { + while (isspace (*Start)) { + Start++; + } + // + // Hack off closing bracket or trailing spaces or comma separator. + // Also allow things like [section.subsection1|subsection2], which + // is shorthand for [section.subsection1,section.subsection2] + // + End = Start; + while (*End && (*End != ']') && !isspace (*End) && (*End != ',') && (*End != '|')) { + End++; + } + // + // Save the character and null-terminate the string + // + SaveChar = *End; + *End = 0; + // + // Now allocate space for a new section and add it to the linked list. + // If the previous section ended with the shorthand indicator, then + // the section name was saved off. Append this section name to it. + // + strcpy (ThisSectionName, ShortHandSectionName); + if (*Start == '.') { + strcat (ThisSectionName, Start + 1); + } else { + strcat (ThisSectionName, Start); + } + // + // Allocate memory for the section. Then clear it out. + // + NewSect = (SECTION *) malloc (sizeof (SECTION)); + if (NewSect == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocation memory for sections"); + Status = STATUS_ERROR; + goto Done; + } + + memset ((char *) NewSect, 0, sizeof (SECTION)); + NewSect->FirstLine = NewLine; + NewSect->Name = (char *) malloc (strlen (ThisSectionName) + 1); + if (NewSect->Name == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocation memory for sections"); + Status = STATUS_ERROR; + goto Done; + } + + strcpy (NewSect->Name, ThisSectionName); + if (DSC->Sections == NULL) { + DSC->Sections = NewSect; + } else { + DSC->LastSection->Next = NewSect; + } + + DSC->LastSection = NewSect; + *End = SaveChar; + // + // If the name ended in a shorthand indicator, then save the + // section name and truncate it at the last dot. + // + if (SaveChar == '|') { + strcpy (ShortHandSectionName, ThisSectionName); + for (TempCptr = ShortHandSectionName + strlen (ShortHandSectionName) - 1; + (TempCptr != ShortHandSectionName) && (*TempCptr != '.'); + TempCptr-- + ) + ; + // + // If we didn't find a dot, then hopefully they have [name1|name2] + // instead of [name1,name2]. + // + if (TempCptr == ShortHandSectionName) { + ShortHandSectionName[0] = 0; + } else { + // + // Truncate after the dot + // + *(TempCptr + 1) = 0; + } + } else { + // + // Kill the shorthand string + // + ShortHandSectionName[0] = 0; + } + // + // Skip to next section name or closing bracket + // + while (*End && ((*End == ',') || isspace (*End) || (*End == '|'))) { + End++; + } + + Start = End; + } + } + } + } + // + // Look through all the sections to make sure we don't have any duplicates. + // Allow [----] and [====] section separators + // + CurrSect = DSC->Sections; + while (CurrSect != NULL) { + TempSect = CurrSect->Next; + while (TempSect != NULL) { + if (isalpha (CurrSect->Name[0]) && (_stricmp (CurrSect->Name, TempSect->Name) == 0)) { + Error ( + TempSect->FirstLine->FileName, + TempSect->FirstLine->LineNum, + 0, + TempSect->Name, + "duplicate section found" + ); + Error ( + CurrSect->FirstLine->FileName, + CurrSect->FirstLine->LineNum, + 0, + TempSect->Name, + "first definition of duplicate section" + ); + Status = STATUS_ERROR; + goto Done; + } + + TempSect = TempSect->Next; + } + + CurrSect = CurrSect->Next; + } + +Done: + fclose (FilePtr); + return Status; +} +// +// Free up memory allocated for DSC file handling. +// +static +void +DSCFileFree ( + DSC_FILE *DSC + ) +{ + SECTION *NextSection; + SECTION_LINE *NextLine; + DSC_FILE_NAME *NextName; + + while (DSC->Sections != NULL) { + NextSection = DSC->Sections->Next; + if (DSC->Sections->Name != NULL) { + free (DSC->Sections->Name); + } + + free (DSC->Sections); + DSC->Sections = NextSection; + } + + while (DSC->Lines != NULL) { + NextLine = DSC->Lines->Next; + free (DSC->Lines->Line); + free (DSC->Lines); + DSC->Lines = NextLine; + } + + while (DSC->FileName != NULL) { + NextName = DSC->FileName->Next; + free (DSC->FileName->FileName); + free (DSC->FileName); + DSC->FileName = NextName; + } +} + +SECTION * +DSCFileFindSection ( + DSC_FILE *DSC, + char *Name + ) +{ + SECTION *Sect; + + // + // Look through all the sections to find one with this name (case insensitive) + // + Sect = DSC->Sections; + while (Sect != NULL) { + if (_stricmp (Name, Sect->Name) == 0) { + // + // Position within file + // + DSC->CurrentLine = Sect->FirstLine->Next; + return Sect; + } + + Sect = Sect->Next; + } + + return NULL; +} + +int +DSCFileSavePosition ( + DSC_FILE *DSC + ) +{ + // + // Advance to next slot + // + DSC->SavedPositionIndex++; + if (DSC->SavedPositionIndex >= MAX_SAVES) { + DSC->SavedPositionIndex--; + Error (NULL, 0, 0, "APP ERROR", "max nesting of saved section file positions exceeded"); + return STATUS_ERROR; + } + + DSC->SavedPosition[DSC->SavedPositionIndex] = DSC->CurrentLine; + return STATUS_SUCCESS; +} + +int +DSCFileRestorePosition ( + DSC_FILE *DSC + ) +{ + if (DSC->SavedPositionIndex < 0) { + Error (NULL, 0, 0, "APP ERROR", "underflow of saved positions in section file"); + return STATUS_ERROR; + } + + DSC->CurrentLine = DSC->SavedPosition[DSC->SavedPositionIndex]; + DSC->SavedPositionIndex--; + return STATUS_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.h new file mode 100644 index 0000000000..4dcad547ec --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/DscFile.h @@ -0,0 +1,109 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DscFile.h + +Abstract: + + Defines and function prototypes for the ProcessDsc utility. + +--*/ + +#ifndef _DSC_FILE_H_ +#define _DSC_FILE_H_ + +typedef struct _SECTION_LINE { + struct _SECTION_LINE *Next; + char *Line; + char *FileName; + UINT32 LineNum; +} SECTION_LINE; + +// +// Use this structure to keep track of parsed file names. Then +// if we get a parse error we can figure out the file/line of +// the error and print a useful message. +// +typedef struct _DSC_FILE_NAME { + struct _DSC_FILE_NAME *Next; + char *FileName; +} DSC_FILE_NAME; + +// +// We create a list of section names when we pre-parse a description file. +// Use this structure. +// +typedef struct _SECTION { + struct _SECTION *Next; + char *Name; + SECTION_LINE *FirstLine; +} SECTION; + +#define MAX_SAVES 4 + +typedef struct { + SECTION_LINE *SavedPosition[MAX_SAVES]; + int SavedPositionIndex; + SECTION *Sections; + SECTION_LINE *Lines; + SECTION *LastSection; + SECTION_LINE *LastLine; + SECTION_LINE *CurrentLine; + DSC_FILE_NAME *FileName; + DSC_FILE_NAME *LastFileName; +} DSC_FILE; + +// +// Function prototypes +// +int +DSCFileSetFile ( + DSC_FILE *DSC, + char *FileName + ) +; +SECTION * +DSCFileFindSection ( + DSC_FILE *DSC, + char *Name + ) +; +int +DSCFileSavePosition ( + DSC_FILE *DSC + ) +; +int +DSCFileRestorePosition ( + DSC_FILE *DSC + ) +; +char * +DSCFileGetLine ( + DSC_FILE *DSC, + char *Line, + int LineLen + ) +; +int +DSCFileInit ( + DSC_FILE *DSC + ) +; +int +DSCFileDestroy ( + DSC_FILE *DSC + ) +; + +#endif // ifndef _DSC_FILE_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.c new file mode 100644 index 0000000000..bc50183ac3 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.c @@ -0,0 +1,141 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Exceptions.c + +Abstract: + + Exception logging routines. + +--*/ + +#include +#include +#include // for memset() +#include "Exceptions.h" + +// +// Max length of a saved exception message +// +#define MAX_EXCEPTION_MSG 200 + +// +// We use this structure to track exceptions thrown. We nest deeper on +// TryException() calls, and come back out on CatchException() calls. +// We save off the first exception message for a given exception level, +// but we save the count of how many were thrown. +// +typedef struct { + int ExceptionCount; + char ExceptionMsg[MAX_EXCEPTION_MSG]; +} EXCEPTION_LOG; + +static EXCEPTION_LOG ExceptionLog[MAX_EXCEPTION_NESTING + 1]; +static int ExceptionLevel; + +// +// Initialize our data and structures for tracking exceptions. +// +int +InitExceptions ( + VOID + ) +{ + ExceptionLevel = -1; + memset ((char *) &ExceptionLog, 0, sizeof (ExceptionLog)); + return 0; +} +// +// This function replaces the _try() exception macro. It sets the +// nesting level. +// +int +TryException ( + VOID + ) +{ + // + // Boost our exception level if we would not go out of range + // + ExceptionLevel++; + if (ExceptionLevel >= MAX_EXCEPTION_NESTING) { + fprintf (stderr, "ERROR: Max exception nesting level exceeded\n"); + ExceptionLevel--; + return 1; + } + + return 0; +} +// +// This function replaces the _catch() exception macro. It's used to decrement +// the nesting level and return any exeption error messages that were +// thrown at the current nesting level. +// +char * +CatchException ( + VOID + ) +{ + // + // Return a pointer to exception message. NULL if no exceptions at this level + // + if (ExceptionLevel >= 0) { + ExceptionLevel--; + if (ExceptionLog[ExceptionLevel + 1].ExceptionMsg[0]) { + return ExceptionLog[ExceptionLevel + 1].ExceptionMsg; + } else { + return NULL; + } + } else { + fprintf (stderr, "ERROR: Invalid nesting level call to CatchException()\n"); + return NULL; + } +} +// +// This function can be used to test for exceptions between the TryException() +// and CatchException() calls in a given function. +// +int +ExceptionThrown ( + VOID + ) +{ + return ExceptionLog[ExceptionLevel].ExceptionCount; +} +// +// This function replaces the _throw() exception macro. It saves off the +// given error message at the current exeption level nesting. +// +int +ThrowException ( + char *Msg + ) +{ + if (ExceptionLevel < 0) { + // + // fprintf (stderr, "ERROR: Exception thrown out of scope"); + // Haven't yet enabled handling of exceptions, so just emit the message. + // + fprintf (stderr, Msg); + return 1; + } + // + // Only log the first + // + if (ExceptionLog[ExceptionLevel].ExceptionMsg[0] == 0) { + strncpy (ExceptionLog[ExceptionLevel].ExceptionMsg, Msg, MAX_EXCEPTION_MSG); + } + + ExceptionLog[ExceptionLevel].ExceptionCount++; + return 0; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.h new file mode 100644 index 0000000000..1425d4387a --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Exceptions.h @@ -0,0 +1,57 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Exceptions.h + +Abstract: + + Defines and function prototypes for the ProcessDsc utility. + +--*/ + +#ifndef _EXCEPTIONS_H_ +#define _EXCEPTIONS_H_ + +#define VOID void +#define MAX_EXCEPTION_NESTING 4 + +// +// Function prototypes +// +int +InitExceptions ( + VOID + ) +; +int +TryException ( + VOID + ) +; +char * +CatchException ( + VOID + ) +; +int +ExceptionThrown ( + VOID + ) +; +int +ThrowException ( + char *EMsg + ) +; + +#endif // ifndef _EXCEPTIONS_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c new file mode 100644 index 0000000000..28baf5551b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c @@ -0,0 +1,1566 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FWVolume.c + +Abstract: + + This module contains functionality to keep track of files destined for + multiple firmware volues. It saves them up, and when told to, dumps the + file names out to some files used as input to other utilities that + actually generate the FVs. + +--*/ + +#include // for max_path definition +#include +#include +#include // for malloc() +#include "Common.h" +#include "DSCFile.h" +#include "FWVolume.h" + +#define FV_INF_DIR "FV_INF_DIR" // symbol for where we create the FV INF file +#define FV_FILENAME "FV_FILENAME" // symbol for the current FV.INF filename +#define EFI_BASE_ADDRESS "EFI_BASE_ADDRESS" +#define DEFAULT_FV_INF_DIR "FV" // default dir for where we create the FV INF file +#define DEFAULT_FV_DIR "$(BUILD_DIR)" // where the FV file comes from +#define MALLOC(size) malloc (size) +#define FREE(ptr) free (ptr) + +// +// Disable warning for unused function arguments +// +#pragma warning(disable : 4100) +// +// Disable warning for while(1) code +// +// #pragma warning (disable : 4127) +// +typedef struct { + char *ComponentType; + char *Extension; +} COMP_TYPE_EXTENSION; + +// +// Use a linked list of these to keep track of all the FV names used +// +typedef struct _FV_LIST { + struct _FV_LIST *Next; + char FVFileName[MAX_PATH]; + char BaseAddress[MAX_LINE_LEN]; + SMART_FILE *FVFilePtr; + SMART_FILE *AprioriFilePtr; + char *Processor; + int ComponentsInstance; // highest [components.n] section with a file for this FV +} FV_LIST; + +// +// Use a linked list of these to keep track of all FFS files built. When +// we're done, we turn the info into the FV INF files used to build the +// firmware volumes. +// +typedef struct _FILE_LIST { + struct _FILE_LIST *Next; + char *FileName; + char *BaseFileName; + char *FVs; // from FV=x,y,z + char *BaseName; // only needed for duplicate basename check + char *Processor; // only needed for duplicate basename check + char Apriori[100]; // of format "FVRecovery:1,FVMain:2" from APRIORI define + char *Guid; // guid string + int ComponentsInstance; // which [components.n] section it's in +} FILE_LIST; + +typedef struct _LINKED_LIST { + struct _LINKED_LIST *Next; + void *Data; +} LINKED_LIST; + +static FILE_LIST *mFileList; +static FILE_LIST *mLastFile; +static char *mXRefFileName = NULL; +static FV_LIST *mNonFfsFVList = NULL; + +// +// Whenever an FV name is referenced, then add it to our list of known +// FV's using these. +// +static FV_LIST *mFVList = NULL; +static FV_LIST *mFVListLast = NULL; + +// +// We use this list so that from a given component type, we can determine +// the name of the file on disk. For example, if we're given a file's +// guid and base name, and we know it's a "bs_driver", then we can look +// up "bs_driver" in this array and know that the file (after it's built) +// name is GUID-BASENAME.DXE +// +static const COMP_TYPE_EXTENSION mCompTypeExtension[] = { + { + "bs_driver", + ".dxe" + }, + { + "rt_driver", + ".dxe" + }, + { + "sal_rt_driver", + ".dxe" + }, + { + "security_core", + ".sec" + }, + { + "pei_core", + ".pei" + }, + { + "pic_peim", + ".pei" + }, + { + "pe32_peim", + ".pei" + }, + { + "relocatable_peim", + ".pei" + }, + { + "binary", + ".ffs" + }, + { + "application", + ".app" + }, + { + "file", + ".ffs" + }, + { + "fvimagefile", + ".fvi" + }, + { + "rawfile", + ".raw" + }, + { + "apriori", + ".ffs" + }, + { + "combined_peim_driver", + ".pei" + }, + { + NULL, + NULL + } +}; + +static +void +CFVFreeFileList ( + VOID + ); + +static +char * +UpperCaseString ( + char *Str + ); + +static +BOOLEAN +InSameFv ( + char *FVs1, + char *FVs2 +); + +static +void +AddFirmwareVolumes ( + char *FVs, + int ComponentsInstance, + FILE_LIST *FileListPtr + ); + +static +BOOLEAN +OrderInFvList ( + char *FvList, + char *FvName, + int *Order + ); + +int +GetBaseAddress ( + char *Name, + char *BaseAddress + ) +{ + char *Start; + char *Cptr; + char CSave; + char *Value; + + Start = Name; + while (*Name && isspace (*Name)) { + Name++; + } + + if (!*Name) { + return STATUS_ERROR; + } + // + // Find the end of the name. Either space or a '='. + // + for (Value = Name; *Value && !isspace (*Value) && (*Value != '='); Value++) + ; + if (!*Value) { + return STATUS_ERROR; + } + // + // Look for the '=' + // + Cptr = Value; + while (*Value && (*Value != '=')) { + Value++; + } + + if (!*Value) { + return STATUS_ERROR; + } + // + // Now truncate the name + // + CSave = *Cptr; + *Cptr = 0; + if (_stricmp (Name, EFI_BASE_ADDRESS) != 0) { + return STATUS_ERROR; + } + + *Cptr = CSave; + // + // Skip over the = and then any spaces + // + Value++; + while (*Value && isspace (*Value)) { + Value++; + } + // + // Find end of string, checking for quoted string + // + if (*Value == '\"') { + Value++; + for (Cptr = Value; *Cptr && *Cptr != '\"'; Cptr++) + ; + } else { + for (Cptr = Value; *Cptr && !isspace (*Cptr); Cptr++) + ; + } + // + // Null terminate the value string + // + CSave = *Cptr; + *Cptr = 0; + strcpy (BaseAddress, Value); + *Cptr = CSave; + + return STATUS_SUCCESS; +} + +int +CFVAddFVFile ( + char *Name, + char *ComponentType, + char *FVs, + int ComponentsInstance, + char *FFSExt, + char *Processor, + char *Apriori, + char *BaseName, + char *Guid + ) +/*++ + +Routine Description: + + Add a file to the list of files in one or more firmware volumes. + +Arguments: + + Name - $(FILE_GUID)-$(BASE_NAME), or filename + ComponentType - type of component being added. Required so we know the + resultant file name after it has been built + FVs - string of commma-separated FVs that the given file is + to be added to. For example, FVs="FV0001,FV0002" + FFSExt - FFS filename extension of the file after it has been built. + This is passed in to us in case we don't know the default + filename extension based on the component type. + Processor - the target processor which the FV is being built for + Apriori - pointer to the definition of APRIORI. For example APRIORI="FvRecovery:1,FvMain:4" + +Returns: + + STATUS_SUCCESS if successful + +--*/ +{ + FILE_LIST *Ptr; + char FileName[MAX_PATH]; + char Str[MAX_PATH]; + int i; + char *Sym; + + // If they provided a filename extension for this type of file, then use it. + // If they did not provide a filename extension, search our list for a + // matching component type and use the extension appropriate for this + // component type. + // + if (FFSExt == NULL) { + // + // They didn't give us a filename extension. Figure it out from the + // component type. + // + for (i = 0; mCompTypeExtension[i].ComponentType != NULL; i++) { + if (_stricmp (ComponentType, mCompTypeExtension[i].ComponentType) == 0) { + FFSExt = mCompTypeExtension[i].Extension; + break; + } + } + // + // If we don't know the file extension, then error out. Just means + // the need to define "FFS_EXT = raw" in the component INF file. + // + if (mCompTypeExtension[i].ComponentType == NULL) { + Error ( + NULL, + 0, + 0, + ComponentType, + "unknown component type - must define FFS_EXT for built filename extension in component INF file" + ); + return STATUS_ERROR; + } + } + // + // We now have all the parts to the FFS filename. Prepend the path to it if + // it's not a full pathname. + // See if they overrode the default base directory for the FV files. + // + if (!IsAbsolutePath (Name)) { + Sym = GetSymbolValue (FV_DIR); + if (Sym == NULL) { + Sym = DEFAULT_FV_DIR; + } + // + // Create the file path. Something like $(BUILD_DIR)\$(PROCESSOR)\$(GUID)-$(BASE_NAME).ext + // If the extension is non-zero length, then make sure there's a dot in it. + // + if ((strlen (FFSExt) > 0) && (FFSExt[0] != '.')) { + sprintf (Str, "%s\\%s\\%s.%s", Sym, Processor, Name, FFSExt); + } else { + sprintf (Str, "%s\\%s\\%s%s", Sym, Processor, Name, FFSExt); + } + + ExpandSymbols (Str, FileName, sizeof (FileName), EXPANDMODE_NO_UNDEFS); + } else { + strcpy (FileName, Name); + } + // + // Traverse the list of files we have so far and make sure we don't have + // any duplicate basenames. If the base name and processor match, then we'll + // have build issues, so don't allow it. We also don't allow the same file GUID + // in the same FV which will cause boot time error if we allow this. + // + Ptr = mFileList; + while (Ptr != NULL) { + if ((Ptr->BaseName != NULL) && (BaseName != NULL) && (_stricmp (BaseName, Ptr->BaseName) == 0)) { + if ((Ptr->Processor != NULL) && (Processor != NULL) && (_stricmp (Processor, Ptr->Processor) == 0)) { + Error (NULL, 0, 0, BaseName, "duplicate base name specified"); + return STATUS_ERROR; + } + } + + if ((Ptr->Guid != NULL) && (Guid != NULL) && (_stricmp (Guid, Ptr->Guid) == 0)) { + if ((Ptr->FVs != NULL) && (FVs != NULL) && (InSameFv (FVs, Ptr->FVs))) { + Error (NULL, 0, 0, Guid, "duplicate Guid specified in the same FV for %s and %s", + (Ptr->BaseName==NULL)?"Unknown":Ptr->BaseName, + (BaseName==NULL)?"Unknown":BaseName); + return STATUS_ERROR; + } + } + + Ptr = Ptr->Next; + } + // + // Allocate a new structure so we can add this file to the list of + // files. + // + Ptr = (FILE_LIST *) malloc (sizeof (FILE_LIST)); + if (Ptr == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + memset ((char *) Ptr, 0, sizeof (FILE_LIST)); + Ptr->FileName = (char *) malloc (strlen (FileName) + 1); + if (Ptr->FileName == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (Ptr->FileName, FileName); + Ptr->ComponentsInstance = ComponentsInstance; + // + // Allocate memory to save the FV list if it's going into an FV. + // + if ((FVs != NULL) && (FVs[0] != 0)) { + Ptr->FVs = (char *) malloc (strlen (FVs) + 1); + if (Ptr->FVs == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (Ptr->FVs, FVs); + } + + Ptr->BaseFileName = (char *) malloc (strlen (Name) + 1); + if (Ptr->BaseFileName == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (Ptr->BaseFileName, Name); + // + // Allocate memory for the basename if they gave us one. May not have one + // if the user is simply adding pre-existing binary files to the image. + // + if (BaseName != NULL) { + Ptr->BaseName = (char *) malloc (strlen (BaseName) + 1); + if (Ptr->BaseName == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (Ptr->BaseName, BaseName); + } + // + // Allocate memory for the processor name + // + if (Processor != NULL) { + Ptr->Processor = (char *) malloc (strlen (Processor) + 1); + if (Ptr->Processor == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (Ptr->Processor, Processor); + } + // + // Allocate memory for the guid name + // + if (Guid != NULL) { + Ptr->Guid = (char *) malloc (strlen (Guid) + 1); + if (Ptr->Guid == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (Ptr->Guid, Guid); + } + // + // If non-null apriori symbol, then save the apriori list for this file + // + if (Apriori != NULL) { + strcpy (Ptr->Apriori, Apriori); + } + + if (mFileList == NULL) { + mFileList = Ptr; + } else { + mLastFile->Next = Ptr; + } + + mLastFile = Ptr; + // + // Add these firmware volumes to the list of known firmware + // volume names. + // + AddFirmwareVolumes (FVs, ComponentsInstance, Ptr); + + return STATUS_SUCCESS; +} + +void +CFVConstructor ( + VOID + ) +{ + mFileList = NULL; + mLastFile = NULL; +} + +void +CFVDestructor ( + VOID + ) +{ + CFVFreeFileList (); + // + // Free up our firmware volume list + // + while (mFVList != NULL) { + mFVListLast = mFVList->Next; + FREE (mFVList); + mFVList = mFVListLast; + } +} + +static +void +CFVFreeFileList ( + VOID + ) +{ + FILE_LIST *Next; + while (mFileList != NULL) { + if (mFileList->FileName != NULL) { + free (mFileList->FileName); + } + + if (mFileList->FVs != NULL) { + free (mFileList->FVs); + } + + free (mFileList->BaseFileName); + if (mFileList->BaseName != NULL) { + free (mFileList->BaseName); + } + + if (mFileList->Processor != NULL) { + free (mFileList->Processor); + } + + if (mFileList->Guid != NULL) { + free (mFileList->Guid); + } + + Next = mFileList->Next; + free (mFileList); + mFileList = Next; + } + + mFileList = NULL; +} + +int +CFVWriteInfFiles ( + DSC_FILE *DSC, + FILE *MakeFptr + ) +/*++ + +Routine Description: + + After processing all components in a DSC file, create the firmware + volume INF files. We actually do a lot more here. + + * Create the FVxxx.inf file that is used by GenFvImage + * Create the Apriori files for each firmware volume that requires one + * Create makefile.out macros for FVxxx_FILES = FVxxx_FILES AnotherFile + so you can do incremental builds of firmware volumes. + * For each FV, emit its build commands to makefile.out + +Arguments: + + DSC - pointer to a DSC_FILE object to extract info from + MakeFptr - pointer to the output makefile + +Returns: + + 0 if successful + non-zero otherwise + +--*/ +{ + FILE_LIST *FileListPtr; + FV_LIST *FVList; + FV_LIST *LastFVList; + FV_LIST *FVPtr; + SECTION *Section; + char *StartCptr; + char *EndCptr; + char CSave; + char Str[MAX_PATH]; + char Line[MAX_LINE_LEN]; + char ExpandedLine[MAX_LINE_LEN]; + char FVDir[MAX_PATH]; + FILE *XRefFptr; + int AprioriCounter; + int AprioriCount; + int AprioriPosition; + BOOLEAN AprioriFound; + int ComponentsInstance; + int ComponentCount; + + // + // Use this to keep track of all the firmware volume names + // + FVList = NULL; + LastFVList = NULL; + // + // See if they specified a FV directory to dump the FV files out to. If not, + // then use the default. Then create the output directory. + // + StartCptr = GetSymbolValue (FV_INF_DIR); + if (StartCptr == NULL) { + ExpandSymbols (DEFAULT_FV_INF_DIR, FVDir, sizeof (FVDir), EXPANDMODE_NO_UNDEFS); + } else { + strcpy (FVDir, StartCptr); + } + // + // Make sure the fv directory path ends in / + // + CSave = FVDir[strlen (FVDir) - 1]; + if ((CSave != '\\') && (CSave != '/')) { + strcat (FVDir, "\\"); + } + // + // Traverse the list of all files, determine which FV each is in, then + // write out the file's name to the output FVxxx.inf file. + // + for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) { + // + // Parse all the "FV1,FV2..." in the FVs + // + if (FileListPtr->FVs != NULL) { + // + // Process each fv this file is in + // + StartCptr = FileListPtr->FVs; + while (*StartCptr) { + EndCptr = StartCptr; + while (*EndCptr && (*EndCptr != ',')) { + EndCptr++; + } + + CSave = *EndCptr; + *EndCptr = 0; + // + // Ok, we have a fv name, now see if we've already opened + // an fv output file of this name. + // + for (FVPtr = FVList; FVPtr != NULL; FVPtr = FVPtr->Next) { + if (_stricmp (FVPtr->FVFileName, StartCptr) == 0) { + break; + } + } + // + // If we didn't find one, then create a new one + // + if (FVPtr == NULL) { + // + // Create a new one, add it to the list + // + FVPtr = (FV_LIST *) malloc (sizeof (FV_LIST)); + if (FVPtr == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory for FV"); + return STATUS_ERROR; + } + + memset ((char *) FVPtr, 0, sizeof (FV_LIST)); + // + // Add it to the end of our list + // + if (FVList == NULL) { + FVList = FVPtr; + } else { + LastFVList->Next = FVPtr; + } + + LastFVList = FVPtr; + // + // Save the FV name in the FileName pointer so we can compare + // for any future FV names specified. + // + strcpy (FVPtr->FVFileName, StartCptr); + + // + // Add a symbol for the FV filename + // + UpperCaseString (FVPtr->FVFileName); + AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE); + // + // Now create the FVx.inf filename from the fv name and + // default filename extension. Dump it in the FV directory + // as well. + // + strcpy (Str, FVDir); + strcat (Str, FVPtr->FVFileName); + strcat (Str, ".inf"); + // + // Create the directory path for our new fv.inf output file. + // + MakeFilePath (Str); + if ((FVPtr->FVFilePtr = SmartOpen (Str)) == NULL) { + Error (NULL, 0, 0, Str, "could not open FV output file"); + return STATUS_ERROR; + } + // + // Now copy the [fv.$(FV).options] to the fv INF file + // + sprintf (Str, "fv.%s.options", StartCptr); + Section = DSCFileFindSection (DSC, Str); + if (Section != NULL) { + SmartWrite (FVPtr->FVFilePtr, "[options]\n"); + while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) { + ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0); + SmartWrite (FVPtr->FVFilePtr, ExpandedLine); + GetBaseAddress (ExpandedLine, FVPtr->BaseAddress); + } + } else { + Error (NULL, 0, 0, Str, "could not find FV section in description file"); + } + // + // Copy the [fv.$(FV).attributes] to the fv INF file + // + sprintf (Str, "fv.%s.attributes", StartCptr); + Section = DSCFileFindSection (DSC, Str); + if (Section != NULL) { + SmartWrite (FVPtr->FVFilePtr, "[attributes]\n"); + while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) { + ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0); + SmartWrite (FVPtr->FVFilePtr, ExpandedLine); + } + } else { + Error (NULL, 0, 0, Str, "Could not find FV section in description file"); + } + // + // Start the files section + // + SmartWrite (FVPtr->FVFilePtr, "\n[files]\n"); + } + // + // Now write the FV filename to the FV.inf file. Prepend $(PROCESSOR) on + // it. + // + sprintf (ExpandedLine, "EFI_FILE_NAME = %s\n", FileListPtr->FileName); + SmartWrite (FVPtr->FVFilePtr, ExpandedLine); + + // + // Next FV on the FV list + // + *EndCptr = CSave; + StartCptr = EndCptr; + if (*StartCptr) { + StartCptr++; + } + } + } + } + // + // Now we walk the list of firmware volumes and create the APRIORI list + // file for it . + // + for (FVPtr = FVList; FVPtr != NULL; FVPtr = FVPtr->Next) { + // + // Run through all the files and count up how many are to be + // added to the apriori list for this FV. Then when we're done + // we'll make sure we processed them all. We do this in case they + // skipped an apriori index for a given FV. + // + AprioriCount = 0; + for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) { + if (OrderInFvList (FileListPtr->Apriori, FVPtr->FVFileName, &AprioriPosition)) { + // + // Emit an error if the index was 0, or they didn't give one. + // + if (AprioriPosition == 0) { + Error ( + GetSymbolValue (DSC_FILENAME), + 1, + 0, + "apriori indexes are 1-based", + "component %s:APRIORI=%s", + FileListPtr->BaseName, + FileListPtr->Apriori + ); + } else { + AprioriCount++; + } + + } + } + // + // Now scan the files as we increment our apriori index + // + AprioriCounter = 0; + do { + AprioriFound = 0; + AprioriCounter++; + for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) { + // + // If in the apriori list for this fv, print the name. Open the + // file first if we have to. + // + if ((FileListPtr->Apriori[0] != 0) && + (OrderInFvList (FileListPtr->Apriori, FVPtr->FVFileName, &AprioriPosition)) + ) { + if (AprioriPosition == AprioriCounter) { + // + // If we've already found one for this index, emit an error. Decrement the + // count of how files we are to process so we don't emit another error for + // a miscount below. + // + if (AprioriFound) { + Error ( + GetSymbolValue (DSC_FILENAME), + 1, + 0, + "duplicate apriori index found", + "%s:%d", + FVPtr->FVFileName, + AprioriCounter + ); + AprioriCount--; + } + + AprioriFound = 1; + // + // Open the apriori output file if we haven't already + // + if (FVPtr->AprioriFilePtr == NULL) { + strcpy (Str, FVDir); + strcat (Str, FVPtr->FVFileName); + strcat (Str, ".apr"); + if ((FVPtr->AprioriFilePtr = SmartOpen (Str)) == NULL) { + Error (NULL, 0, 0, Str, "could not open output Apriori file for writing"); + return STATUS_ERROR; + } + } + + sprintf (ExpandedLine, "%s\n", FileListPtr->BaseFileName); + SmartWrite (FVPtr->AprioriFilePtr, ExpandedLine); + } + } + } + } while (AprioriFound); + // + // See if they skipped an apriori position for this FV + // + if (AprioriCount != (AprioriCounter - 1)) { + Error ( + GetSymbolValue (DSC_FILENAME), + 1, + 0, + "apriori index skipped", + "%s:%d", + FVPtr->FVFileName, + AprioriCounter + ); + } + } + // + // Traverse the list of all files again, and create a macro in the output makefile + // that defines all the files in each fv. For example, for each FV file, create a line: + // FV0001_FILES = $(FV_0001_FILES) xxxx-yyy.dxe. + // This can then be used as a dependency in their makefile. + // Also if they wanted us to dump a cross-reference, do that now. + // + if (mXRefFileName != NULL) { + if ((XRefFptr = fopen (mXRefFileName, "w")) == NULL) { + Message ( + 0, + "Failed to open cross-reference file '%s' for writing\n", + mXRefFileName + ); + } + } else { + XRefFptr = NULL; + } + + for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) { + // + // Parse all the "FV1,FV2..." in the FV field that came from FV=FVa,FVb,... on the + // component line in the DSC file. + // + if (FileListPtr->FVs != NULL) { + // + // If generating a cross-reference file, dump the data + // + if (XRefFptr != NULL) { + if ((FileListPtr->Guid != NULL) && (FileListPtr->BaseName != NULL) && (FileListPtr->Processor)) { + fprintf ( + XRefFptr, + "%s %s %s\n", + FileListPtr->Guid, + FileListPtr->BaseName, + FileListPtr->Processor + ); + } + } + // + // Convert to uppercase since we're going to use the name as a macro variable name + // in the makefile. + // + UpperCaseString (FileListPtr->FVs); + // + // Process each FV this file is in to write fvxxx_FILES = $(fvxxx_FILES) Guid-BaseName.ffs + // + StartCptr = FileListPtr->FVs; + while (*StartCptr) { + EndCptr = StartCptr; + while (*EndCptr && (*EndCptr != ',')) { + EndCptr++; + } + + CSave = *EndCptr; + *EndCptr = 0; + fprintf ( + MakeFptr, + "%s_FILES = $(%s_FILES) %s\n", + StartCptr, + StartCptr, + FileListPtr->FileName + ); + // + // Next FV on the FV list + // + *EndCptr = CSave; + StartCptr = EndCptr; + if (*StartCptr) { + StartCptr++; + } + } + } + } + + fprintf (MakeFptr, "\n"); + + // + // Now go through the list of all NonFFS FVs they specified and search for + // a [build.fv.$(FV)] or [build.fv] command and emit the commands to the + // output makefile. Add them to the "fvs" target as well. + // + if (mNonFfsFVList != NULL) { + fprintf (MakeFptr, "fvs ::"); + FVPtr = mNonFfsFVList; + while (FVPtr != NULL) { + fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName); + FVPtr = FVPtr->Next; + } + + fprintf (MakeFptr, "\n\n"); + FVPtr = mNonFfsFVList; + while (FVPtr != NULL) { + // + // Save the position in the file + // + DSCFileSavePosition (DSC); + // + // first try to find a build section specific for this fv. + // + sprintf (Str, "build.fv.%s", FVPtr->FVFileName); + Section = DSCFileFindSection (DSC, Str); + if (Section == NULL) { + sprintf (Str, "build.fv"); + Section = DSCFileFindSection (DSC, Str); + } + + if (Section == NULL) { + Warning ( + NULL, + 0, + 0, + NULL, + "No [build.fv.%s] nor [%s] section found in description file for building %s", + FVPtr->FVFileName, + Str, + FVPtr->FVFileName + ); + } else { + // + // Add a symbol for the FV filename + // + UpperCaseString (FVPtr->FVFileName); + AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE); + AddSymbol (EFI_BASE_ADDRESS, FVPtr->BaseAddress, SYM_LOCAL | SYM_OVERWRITE); + + // + // Now copy the build commands from the section to the makefile + // + while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) { + ExpandSymbols ( + Line, + ExpandedLine, + sizeof (ExpandedLine), + EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR + ); + + fprintf (MakeFptr, ExpandedLine); + } + } + + FVPtr = FVPtr->Next; + DSCFileRestorePosition (DSC); + } + } + // + // Go through our list of firmware volumes and create an "fvs" target that + // builds everything. It has to be a mix of components and FV's in order. + // For example: fvs : components_0 fv\fv001.fv fv\fv002.fv components_1 fv\fv003.fv + // + ComponentsInstance = 0; + ComponentCount = 0; + fprintf (MakeFptr, "fvs ::"); + for (;;) { + // + // First see if we have any components for this section. If we don't, + // then we're done + // + for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) { + if (FileListPtr->ComponentsInstance == ComponentsInstance) { + break; + } + } + + if (FileListPtr == NULL) { + break; + } + + fprintf (MakeFptr, " components_%d", ComponentsInstance); + ComponentCount++; + // + // Now print any firmware volumes that match this components instance + // + for (FVPtr = mFVList; FVPtr != NULL; FVPtr = FVPtr->Next) { + if (FVPtr->ComponentsInstance == ComponentsInstance) { + fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName); + } + } + + ComponentsInstance++; + } + + fprintf (MakeFptr, "\n\n"); + + // + // Create a "components" target for build convenience. It should + // look something like: + // components : components_0 components_1... + // + if (ComponentCount > 0) { + fprintf (MakeFptr, "components :"); + for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) { + fprintf (MakeFptr, " components_%d", ComponentsInstance); + } + + fprintf (MakeFptr, "\n\n"); + } + // + // Now go through the list of all FV's defined and search for + // a [build.fv.$(FV)] or [build.fv] command and emit the commands to the + // output makefile. + // + FVPtr = mFVList; + while (FVPtr != NULL) { + if (FVPtr->FVFileName[0]) { + // + // Save the position in the file + // + DSCFileSavePosition (DSC); + // + // First try to find a build section specific for this FV. + // + sprintf (Str, "build.fv.%s", FVPtr->FVFileName); + Section = DSCFileFindSection (DSC, Str); + if (Section == NULL) { + sprintf (Str, "build.fv"); + Section = DSCFileFindSection (DSC, Str); + } + + if (Section == NULL) { + Error ( + NULL, + 0, + 0, + NULL, + "no [build.fv.%s] nor [%s] section found in description file for building %s", + FVPtr->FVFileName, + Str, + FVPtr->FVFileName + ); + } else { + // + // Add a symbol for the FV filename + // + UpperCaseString (FVPtr->FVFileName); + AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE); + AddSymbol (EFI_BASE_ADDRESS, FVPtr->BaseAddress, SYM_LOCAL | SYM_OVERWRITE); + + // + // Now copy the build commands from the section to the makefile + // + while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) { + ExpandSymbols ( + Line, + ExpandedLine, + sizeof (ExpandedLine), + EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR + ); + fprintf (MakeFptr, ExpandedLine); + } + } + + DSCFileRestorePosition (DSC); + } + + FVPtr = FVPtr->Next; + } + // + // Close all the files and free up the memory + // + while (FVList != NULL) { + FVPtr = FVList->Next; + if (FVList->FVFilePtr != NULL) { + SmartClose (FVList->FVFilePtr); + } + + if (FVList->AprioriFilePtr != NULL) { + SmartClose (FVList->AprioriFilePtr); + } + + free (FVList); + FVList = FVPtr; + } + + while (mNonFfsFVList != NULL) { + FVPtr = mNonFfsFVList->Next; + free (mNonFfsFVList); + mNonFfsFVList = FVPtr; + } + + if (XRefFptr != NULL) { + fclose (XRefFptr); + } + + return STATUS_SUCCESS; +} + +int +NonFFSFVWriteInfFiles ( + DSC_FILE *DSC, + char *FileName + ) +/*++ + +Routine Description: + + Generate a Non FFS fv file. It can only some variables, + or simply contains nothing except header. + +Arguments: + + DSC - pointer to a DSC_FILE object to extract info from + FileName - pointer to the fv file + +Returns: + + STATUS_SUCCESS if successful + non-STATUS_SUCCESS otherwise + +--*/ +{ + FV_LIST *FVPtr; + SECTION *Section; + char *StartCptr; + char *EndCptr; + char CSave; + char Str[MAX_PATH]; + char Line[MAX_LINE_LEN]; + char ExpandedLine[MAX_LINE_LEN]; + char FVDir[MAX_PATH]; + + // + // See if they specified a FV directory to dump the FV files out to. If not, + // then use the default. Then create the output directory. + // + DSCFileSavePosition (DSC); + StartCptr = GetSymbolValue (FV_INF_DIR); + if (StartCptr == NULL) { + ExpandSymbols (DEFAULT_FV_INF_DIR, FVDir, sizeof (FVDir), EXPANDMODE_NO_UNDEFS); + } else { + strcpy (FVDir, StartCptr); + } + + // + // Make sure the fv directory path ends in / + // + CSave = FVDir[strlen (FVDir) - 1]; + if ((CSave != '\\') && (CSave != '/')) { + strcat (FVDir, "\\"); + } + + StartCptr = FileName; + while (*StartCptr) { + EndCptr = StartCptr; + while (*EndCptr && (*EndCptr != ',')) { + EndCptr++; + } + + CSave = *EndCptr; + *EndCptr = 0; + // + // Ok, we have a fv name, now see if we've already opened + // an fv output file of this name. + // + for (FVPtr = mNonFfsFVList; FVPtr != NULL; FVPtr = FVPtr->Next) { + if (_stricmp (FVPtr->FVFileName, StartCptr) == 0) { + break; + } + } + // + // If there is already one with the same name, wrong + // + if (FVPtr != NULL) { + DSCFileRestorePosition (DSC); + return STATUS_ERROR; + } + // + // Create a new one, add it to the list + // + FVPtr = (FV_LIST *) malloc (sizeof (FV_LIST)); + if (FVPtr == NULL) { + Error (__FILE__, __LINE__, 0, "failed to allocate memory", NULL); + DSCFileRestorePosition (DSC); + return STATUS_ERROR; + } + + memset ((char *) FVPtr, 0, sizeof (FV_LIST)); + FVPtr->Next = mNonFfsFVList; + mNonFfsFVList = FVPtr; + // + // Save the FV name in the FileName pointer so we can compare + // for any future FV names specified. + // + strcpy (FVPtr->FVFileName, StartCptr); + // + // Add a symbol for the FV filename + // + UpperCaseString (FVPtr->FVFileName); + AddSymbol (FV_FILENAME, FVPtr->FVFileName, SYM_LOCAL | SYM_OVERWRITE); + + // + // Now create the FVx.inf filename from the fv name and + // default filename extension. Dump it in the FV directory + // as well. + // + strcpy (Str, FVDir); + strcat (Str, FVPtr->FVFileName); + strcat (Str, ".inf"); + // + // Create the directory path for our new fv.inf output file. + // + MakeFilePath (Str); + if ((FVPtr->FVFilePtr = SmartOpen (Str)) == NULL) { + Error (NULL, 0, 0, Str, "could not open FV output file"); + DSCFileRestorePosition (DSC); + return STATUS_ERROR; + } + // + // Now copy the [fv.fvfile.options] to the fv file + // + sprintf (Str, "fv.%s.options", StartCptr); + Section = DSCFileFindSection (DSC, Str); + if (Section != NULL) { + SmartWrite (FVPtr->FVFilePtr, "[options]\n"); + while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) { + ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0); + SmartWrite (FVPtr->FVFilePtr, ExpandedLine); + GetBaseAddress (ExpandedLine, FVPtr->BaseAddress); + } + } else { + Warning (NULL, 0, 0, NULL, "Could not find FV section '%s' in description file", Str); + } + // + // Copy the [fv.fvfile.attributes] to the fv file + // + sprintf (Str, "fv.%s.attributes", StartCptr); + Section = DSCFileFindSection (DSC, Str); + if (Section != NULL) { + SmartWrite (FVPtr->FVFilePtr, "[attributes]\n"); + while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) { + ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0); + SmartWrite (FVPtr->FVFilePtr, ExpandedLine); + } + } else { + Warning (NULL, 0, 0, NULL, "Could not find FV section '%s' in description file", Str); + } + // + // Copy the [fv.fvfile.components] to the fv file + // + sprintf (Str, "fv.%s.components", StartCptr); + Section = DSCFileFindSection (DSC, Str); + if (Section != NULL) { + SmartWrite (FVPtr->FVFilePtr, "[components]\n"); + while (DSCFileGetLine (DSC, Line, sizeof (Line)) != NULL) { + ExpandSymbols (Line, ExpandedLine, sizeof (ExpandedLine), 0); + SmartWrite (FVPtr->FVFilePtr, ExpandedLine); + } + } else { + // + // An empty FV is allowed to contain nothing + // + } + // + // Close the file + // + SmartClose (FVPtr->FVFilePtr); + // + // Next FV in FileName + // + *EndCptr = CSave; + StartCptr = EndCptr; + if (*StartCptr) { + StartCptr++; + } + } + + DSCFileRestorePosition (DSC); + return STATUS_SUCCESS; +} + +static +void +AddFirmwareVolumes ( + char *FVs, + int ComponentsInstance, + FILE_LIST *FileListPtr + ) +{ + FV_LIST *FvPtr; + char *StartPtr; + char *EndPtr; + char SaveChar; + + if ((FVs != NULL) && (FVs[0] != 0)) { + // + // Extract each FV name from the string. It's from the DSC file "FV=FvRecover,FvMain" + // + StartPtr = FVs; + while (*StartPtr != 0) { + EndPtr = StartPtr; + while (*EndPtr && (*EndPtr != ',')) { + EndPtr++; + } + + SaveChar = *EndPtr; + *EndPtr = 0; + // + // Look through our list of known firmware volumes and see if we've + // already added it. + // + for (FvPtr = mFVList; FvPtr != NULL; FvPtr = FvPtr->Next) { + if (_stricmp (FvPtr->FVFileName, StartPtr) == 0) { + break; + } + } + // + // If we didn't find a match, then create a new one + // + if (FvPtr == NULL) { + FvPtr = MALLOC (sizeof (FV_LIST)); + if (FvPtr == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed"); + return ; + } + + memset (FvPtr, 0, sizeof (FV_LIST)); + strcpy (FvPtr->FVFileName, StartPtr); + if (mFVList == NULL) { + mFVList = FvPtr; + } else { + mFVListLast->Next = FvPtr; + } + + mFVListLast = FvPtr; + } + // + // If this component's section number is higher than that of this + // FV, then set the FV's to it. + // + if (FvPtr->ComponentsInstance < ComponentsInstance) { + FvPtr->ComponentsInstance = ComponentsInstance; + } + // + // If we found then end of the FVs in the string, then we're done. + // Always restore the original string's contents. + // + if (SaveChar != 0) { + *EndPtr = SaveChar; + StartPtr = EndPtr + 1; + } else { + StartPtr = EndPtr; + } + } + } +} + +static +BOOLEAN +OrderInFvList ( + char *FvList, + char *FvName, + int *Order + ) +{ + // + // Given FvList of format "FV_a,FV_b,FV_c" or "FV_a:1,FV_b:2" and + // FvName of format "FV_c", determine if FvName is in FvList. If + // FV_a:1 format, then return the value after the colon. + // + while (*FvList) { + // + // If it matches for the length of FvName... + // + if (_strnicmp (FvList, FvName, strlen (FvName)) == 0) { + // + // Then see if the match string in FvList is terminated at the + // same length. + // + if ((FvList[strlen (FvName)] == ',') || (FvList[strlen (FvName)] == 0)) { + *Order = 0; + return TRUE; + } else if (FvList[strlen (FvName)] == ':') { + *Order = atoi (FvList + strlen (FvName) + 1); + return TRUE; + } + } + // + // Skip to next FV in the comma-separated list + // + while ((*FvList != ',') && (*FvList != 0)) { + FvList++; + } + // + // Skip over comma + // + if (*FvList == ',') { + FvList++; + } + } + + return FALSE; +} + +static +char * +UpperCaseString ( + char *Str + ) +{ + char *Cptr; + + for (Cptr = Str; *Cptr; Cptr++) { + *Cptr = (char) toupper (*Cptr); + } + + return Str; +} + +static +BOOLEAN +InSameFv ( + char *FVs1, + char *FVs2 +) +{ + char *StartCptr1; + char *StartCptr2; + char *EndCptr1; + char *EndCptr2; + char CSave1; + char CSave2; + + // + // Process each FV in first FV list + // + StartCptr1 = FVs1; + while (*StartCptr1) { + EndCptr1 = StartCptr1; + while (*EndCptr1 && (*EndCptr1 != ',')) { + EndCptr1++; + } + + CSave1 = *EndCptr1; + *EndCptr1 = 0; + + if (*StartCptr1) { + // + // Process each FV in second FV list + // + StartCptr2 = FVs2; + while (*StartCptr2) { + EndCptr2 = StartCptr2; + while (*EndCptr2 && (*EndCptr2 != ',')) { + EndCptr2++; + } + + CSave2 = *EndCptr2; + *EndCptr2 = 0; + + if (_stricmp (StartCptr1, StartCptr2) == 0) { + *EndCptr1 = CSave1; + *EndCptr2 = CSave2; + return TRUE; + } + + // + // Next FV on the second FV list + // + *EndCptr2 = CSave2; + StartCptr2 = EndCptr2; + if (*StartCptr2) { + StartCptr2++; + } + } + } + + // + // Next FV on the first FV list + // + *EndCptr1 = CSave1; + StartCptr1 = EndCptr1; + if (*StartCptr1) { + StartCptr1++; + } + } + + return FALSE; +} + +int +CFVSetXRefFileName ( + char *FileName + ) +{ + mXRefFileName = FileName; + return 0; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.h new file mode 100644 index 0000000000..4a7af36e73 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.h @@ -0,0 +1,76 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + FWVolume.h + +Abstract: + + Include file for the module that keeps track of files for the firmware + volumes. + +--*/ + +#ifndef _FW_VOLUME_H_ +#define _FW_VOLUME_H_ + +// +// class CFirmwareVolume +// { +// public: +// +void +CFVConstructor ( + VOID + ) +; +void +CFVDestructor ( + VOID + ) +; + +int +CFVAddFVFile ( + char *Name, + char *ComponentType, + char *FVs, + int ComponentsInstance, + char *FFSExt, + char *Processor, + char *Apriori, + char *BaseName, + char *Guid + ) +; + +int +CFVSetXRefFileName ( + char *FileName + ) +; + +int +CFVWriteInfFiles ( + DSC_FILE *DSC, + FILE *MakeFptr + ) +; + +int +NonFFSFVWriteInfFiles ( + DSC_FILE *DSC, + char *FileName + ) +; + +#endif // ifndef _FW_VOLUME_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile new file mode 100644 index 0000000000..c835a80025 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile @@ -0,0 +1,102 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the ProcessDsc utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Target specific information +# + +TARGET_NAME = ProcessDsc +TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\ProcessDsc.exe + +# +# Build targets +# + +all: $(TARGET_EXE) + +INC_DEPS = $(TARGET_SRC_DIR)\DSCFile.h $(INC_DEPS) +INC_DEPS = $(TARGET_SRC_DIR)\FWVolume.h $(INC_DEPS) +INC_DEPS = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS) +INC_DEPS = $(TARGET_SRC_DIR)\Common.h $(INC_DEPS) + +LIBS = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib" + +OBJECTS = $(EDK_TOOLS_OUTPUT)\DSCFile.obj \ + $(EDK_TOOLS_OUTPUT)\FWVolume.obj \ + $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \ + $(EDK_TOOLS_OUTPUT)\Exceptions.obj + +# +# Compile each source file +# + +$(EDK_TOOLS_OUTPUT)\DSCFile.obj : $(TARGET_SRC_DIR)\DSCFile.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\DSCFile.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\FWVolume.obj : $(TARGET_SRC_DIR)\FWVolume.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\FWVolume.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\ProcessDsc.obj : $(TARGET_SRC_DIR)\ProcessDsc.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\ProcessDsc.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\Exceptions.obj : $(TARGET_SRC_DIR)\Exceptions.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\Exceptions.c /Fo$@ + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) $(LIBS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\DscFile.* del $(EDK_TOOLS_OUTPUT)\DscFile.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\Exceptions* del $(EDK_TOOLS_OUTPUT)\Exceptions.* > NUL + @if exist $(EDK_TOOLS_OUTPUT)\FwVolume.* del $(EDK_TOOLS_OUTPUT)\FwVolume.* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c new file mode 100644 index 0000000000..4833b78e0d --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c @@ -0,0 +1,4726 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + ProcessDsc.c + +Abstract: + + Main module for the ProcessDsc utility. + +--*/ + +#include // for GetShortPathName() +#include +#include +#include +#include +#include // for _mkdir() +#include +#include // for getenv() +#include "DSCFile.h" +#include "FWVolume.h" +#include "Exceptions.h" +#include "Common.h" + +#include "EfiUtilityMsgs.h" +#include "TianoBind.h" +// +// Disable warning for while(1) code +// +#pragma warning(disable : 4127) +// +// Disable warning for unreferenced function parameters +// +#pragma warning(disable : 4100) + +extern int errno; + +#define PROGRAM_NAME "ProcessDsc" + +// +// Common symbol name definitions. For example, the user can reference +// $(BUILD_DIR) in their DSC file and we will expand it for them (usually). +// I've defined the equivalents here in case we want to change the name the +// user references, in which case we just change the string value here and +// our code still works. +// +#define BUILD_DIR "BUILD_DIR" +#define EFI_SOURCE "EFI_SOURCE" +#define DEST_DIR "DEST_DIR" +#define SOURCE_DIR "SOURCE_DIR" +#define LIB_DIR "LIB_DIR" +#define BIN_DIR "BIN_DIR" +#define OUT_DIR "OUT_DIR" +#define INF_FILENAME "INF_FILENAME" +#define SOURCE_RELATIVE_PATH "SOURCE_RELATIVE_PATH" +#define SOURCE_BASE_NAME "SOURCE_BASE_NAME" +#define SOURCE_FILE_NAME "SOURCE_FILE_NAME" // c:\FullPath\File.c +#define PROCESSOR "PROCESSOR" +#define FV "FV" +#define BASE_NAME "BASE_NAME" +#define GUID "GUID" +#define FILE_GUID "FILE_GUID" +#define COMPONENT_TYPE_FILE "FILE" +#define BUILD_TYPE "BUILD_TYPE" +#define FFS_EXT "FFS_EXT" // FV_EXT is deprecated -- extension of FFS file +#define MAKEFILE_NAME "MAKEFILE_NAME" // name of component's output makefile +#define PLATFORM "PLATFORM" // for more granularity +#define PACKAGE_FILENAME "PACKAGE_FILENAME" +#define PACKAGE "PACKAGE" +#define PACKAGE_TAG "PACKAGE_TAG" // alternate name to PACKAGE +#define SHORT_NAMES "SHORT_NAMES" // for 8.3 names of symbols +#define APRIORI "APRIORI" // to add to apriori list +#define OPTIONAL_COMPONENT "OPTIONAL" // define as non-zero for optional INF files +#define SOURCE_SELECT "SOURCE_SELECT" // say SOURCE_SELECT=smm,common to select INF sources +#define NONFFS_FV "NONFFS_FV" // for non-FFS FV such as working & spare block FV +#define SKIP_FV_NULL "SKIP_FV_NULL" // define as nonzero to not build components with FV=NULL +#define SOURCE_COMPILE_TYPE "SOURCE_COMPILE_TYPE" // to build a source using a custom build section in the DSC file +#define SOURCE_FILE_EXTENSION "SOURCE_FILE_EXTENSION" +#define COMPILE_SELECT "COMPILE_SELECT" +#define SOURCE_OVERRIDE_PATH "SOURCE_OVERRIDE_PATH" // get source files from here first +#define MAKEFILE_OUT_SECTION_NAME "makefile.out" +#define COMMON_SECTION_NAME "common" // shared files or functionality +#define NMAKE_SECTION_NAME "nmake" +#define SOURCES_SECTION_NAME "sources" +#define COMPONENTS_SECTION_NAME "components" +#define INCLUDE_SECTION_NAME "includes" +#define DEFINES_SECTION_NAME "defines" +#define LIBRARIES_SECTION_NAME "libraries" +#define LIBRARIES_PLATFORM_SECTION_NAME "libraries.platform" +#define MAKEFILE_SECTION_NAME "makefile" +#define COMPONENT_TYPE "component_type" +#define PLATFORM_STR "\\platform\\" // to determine EFI_SOURCE +#define MAKEFILE_OUT_NAME "makefile.out" // if not specified on command line +#define MODULE_MAKEFILE_NAME "module.mak" // record all module makefile targets +#define MODULE_NAME_FILE "module.list" // record all module names defined in the dsc file +#define GLOBAL_LINK_LIB_NAME "CompilerStub" // Lib added in link option, maybe removed in the future +#define MODULE_BASE_NAME_WIDTH 25 // Width for module name output + +// +// When a symbol is defined as "NULL", it gets saved in the symbol table as a 0-length +// string. Use this macro to detect if a symbol has been defined this way. +// +#define IS_NULL_SYMBOL_VALUE(var) ((var != NULL) && (strlen (var) == 0)) + +// +// Defines for file types +// +#define FILETYPE_UNKNOWN 0 +#define FILETYPE_C 1 +#define FILETYPE_ASM 2 +#define FILETYPE_S 3 +#define FILETYPE_VFR 4 +#define FILETYPE_INC 5 +#define FILETYPE_H 6 +#define FILETYPE_I 7 + + +typedef struct { + INT8 *Extension; // file extension + INT8 *BuiltExtension; + INT8 FileFlags; + int FileType; +} FILETYPE; + +// +// Define masks for the FileFlags field +// +#define FILE_FLAG_INCLUDE 0x01 +#define FILE_FLAG_SOURCE 0x02 + +// +// This table describes a from-to list of files. For +// example, when a ".c" is built, it results in a ".obj" file. +// +static const FILETYPE mFileTypes[] = { + { + ".c", + ".obj", + FILE_FLAG_SOURCE, + FILETYPE_C + }, + { + ".asm", + ".obj", + FILE_FLAG_SOURCE, + FILETYPE_ASM + }, + { + ".s", + ".obj", + FILE_FLAG_SOURCE, + FILETYPE_S + }, + { + ".vfr", + ".obj", + FILE_FLAG_SOURCE, + FILETYPE_VFR + }, // actually *.vfr -> *.c -> *.obj + { + ".h", + NULL, + FILE_FLAG_INCLUDE, + FILETYPE_H + }, + { + ".inc", + NULL, + FILE_FLAG_INCLUDE, + FILETYPE_INC + }, + { + ".i", + NULL, + FILE_FLAG_INCLUDE, + FILETYPE_I + }, + { + NULL, + NULL, + 0, + 0 + } +}; + +// +// Structure to split up a file into its different parts. +// +typedef struct { + INT8 Drive[3]; + INT8 *Path; + INT8 *BaseName; + INT8 *Extension; + int ExtensionCode; +} FILE_NAME_PARTS; + +// +// Maximum length for any line in any file after symbol expansion +// +#define MAX_EXP_LINE_LEN (MAX_LINE_LEN * 2) + +// +// Linked list to keep track of all symbols +// +typedef struct _SYMBOL { + struct _SYMBOL *Next; + int Type; // local or global symbol + INT8 *Name; + INT8 *Value; +} SYMBOL; + +// +// Define new SYMBOL list to record all module name used in the platform.dsc file. +// +SYMBOL *gModuleList = NULL; + +// +// This structure is used to save globals +// +struct { + INT8 *DscFilename; + SYMBOL *Symbol; + INT8 MakefileName[MAX_PATH]; // output makefile name + INT8 XRefFileName[MAX_PATH]; + INT8 GuidDatabaseFileName[MAX_PATH]; + INT8 ModuleMakefileName[MAX_PATH]; + FILE *MakefileFptr; + FILE *ModuleMakefileFptr; + SYMBOL *ModuleList; + SYMBOL *OutdirList; + UINT32 Verbose; +} gGlobals; + +// +// This gets dumped to the head of makefile.out +// +static const INT8 *MakefileHeader[] = { + "#/*++", + "#", + "# DO NOT EDIT", + "# File auto-generated by build utility", + "#", + "# Module Name:", + "#", + "# makefile", + "#", + "# Abstract:", + "#", + "# Auto-generated makefile for building of EFI components/libraries", + "#", + "#--*/", + "", + NULL +}; + +// +// Function prototypes +// +static +int +ProcessOptions ( + int Argc, + INT8 *Argv[] + ); + +static +void +Usage ( + VOID + ); + +static +INT8 * +StripLine ( + INT8 *Line + ); + +static +STATUS +ParseGuidDatabaseFile ( + INT8 *FileName + ); + +#define DSC_SECTION_TYPE_COMPONENTS 0 +#define DSC_SECTION_TYPE_LIBRARIES 1 +#define DSC_SECTION_TYPE_PLATFORM_LIBRARIES 2 + +static +int +ProcessSectionComponents ( + DSC_FILE *DscFile, + int DscSectionType, + int Instance + ); +static +int +ProcessComponentFile ( + DSC_FILE *DscFile, + INT8 *Line, + int DscSectionType, + int Instance + ); +static +int +ProcessIncludeFiles ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ); +static + +int +ProcessIncludeFilesSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ); + +// +// Mode flags for processing source files +// +#define SOURCE_MODE_BUILD_COMMANDS 0x01 +#define SOURCE_MODE_SOURCE_FILES 0x02 + +static +int +ProcessSourceFiles ( + DSC_FILE *DSCFile, + DSC_FILE *ComponentFile, + FILE *MakeFptr, + UINT32 Mode + ); + +static +int +ProcessSourceFilesSection ( + DSC_FILE *DSCFile, + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName, + UINT32 Mode + ); + +static +int +ProcessObjects ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ); + +static +int +ProcessObjectsSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ); + +static +int +ProcessLibs ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ); + +static +int +ProcessLibsSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ); + +static +int +ProcessIncludesSection ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ); + +static +int +ProcessIncludesSectionSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ); + +static +int +ProcessINFNMakeSection ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ); + +static +int +ProcessINFDefinesSection ( + DSC_FILE *ComponentFile + ); + +static +int +ProcessINFDefinesSectionSingle ( + DSC_FILE *ComponentFile, + INT8 *SectionName + ); + +static +int +ProcessSectionLibraries ( + DSC_FILE *DscFile, + long Offset + ); + +static +int +ProcessDSCDefinesSection ( + DSC_FILE *DscFile + ); + +static +int +SetSymbolType ( + INT8 *SymbolName, + INT8 Type + ); + +static +int +RemoveLocalSymbols ( + VOID + ); + +static +int +RemoveFileSymbols ( + VOID + ); + +static +int +RemoveSymbol ( + INT8 *Name, + INT8 SymbolType + ); + +static +int +SetFileExtension ( + INT8 *FileName, + INT8 *Extension + ); + +static +int +GetSourceFileType ( + INT8 *FileName + ); + +static +int +IsIncludeFile ( + INT8 *FileName + ); + +static +int +WriteCompileCommands ( + DSC_FILE *DscFile, + FILE *MakeFptr, + INT8 *FileName, + INT8 *Processor + ); + +static +int +WriteCommonMakefile ( + DSC_FILE *DscFile, + FILE *MakeFptr, + INT8 *Processor + ); + +static +int +WriteComponentTypeBuildCommands ( + DSC_FILE *DscFile, + FILE *MakeFptr, + INT8 *SectionName + ); + +static +void +StripTrailingSpaces ( + INT8 *Str + ); + +static +void +FreeFileParts ( + FILE_NAME_PARTS *FP + ); + +static +FILE_NAME_PARTS * +GetFileParts ( + INT8 *FileName + ); + +static +SYMBOL * +FreeSymbols ( + SYMBOL *Syms + ); + +static +int +GetEfiSource ( + VOID + ); + +static +int +CreatePackageFile ( + DSC_FILE *DSCFile + ); + +static +INT8 * +BuiltFileExtension ( + INT8 *SourceFileName + ); + +static +void +SmartFree ( + SMART_FILE *SmartFile + ); + +static +int +AddModuleName ( + SYMBOL **SymbolList, + INT8 *ModuleName, + INT8 *InfName + ); + +/*****************************************************************************/ +int +main ( + int Argc, + INT8 *Argv[] + ) +/*++ + +Routine Description: + + Main utility entry point. + +Arguments: + + Argc - Standard app entry point args. + Argv - Standard app entry point args. + +Returns: + + 0 if successful + non-zero otherwise + +--*/ +{ + int i; + DSC_FILE DSCFile; + SECTION *Sect; + INT8 Line[MAX_LINE_LEN]; + INT8 ExpLine[MAX_LINE_LEN]; + INT8 *EMsg; + FILE *FpModule; + SYMBOL *TempSymbol; + + SetUtilityName (PROGRAM_NAME); + + InitExceptions (); + + DSCFileInit (&DSCFile); + // + // Initialize the firmware volume data + // + CFVConstructor (); + // + // Exception handling for this block of code. + // + TryException (); + // + // Process command-line options. + // + if (ProcessOptions (Argc, Argv)) { + EMsg = CatchException (); + if (EMsg != NULL) { + fprintf (stderr, "%s\n", EMsg); + } + + return STATUS_ERROR; + } + // + // Parse the GUID database file if specified + // + if (gGlobals.GuidDatabaseFileName[0] != 0) { + ParseGuidDatabaseFile (gGlobals.GuidDatabaseFileName); + } + // + // Set the output cross-reference file if applicable + // + if (gGlobals.XRefFileName[0]) { + CFVSetXRefFileName (gGlobals.XRefFileName); + } + + // + // Now get the EFI_SOURCE directory which we use everywhere. + // + if (GetEfiSource ()) { + return STATUS_ERROR; + } + + // + // Pre-process the DSC file to get section info. + // + if (DSCFileSetFile (&DSCFile, gGlobals.DscFilename) != 0) { + goto ProcessingError; + } + + // + // Set output makefile name for single module build + // + strcpy (gGlobals.ModuleMakefileName, MODULE_MAKEFILE_NAME); + + // + // Try to open all final output makefiles + // + if ((gGlobals.MakefileFptr = fopen (gGlobals.MakefileName, "w")) == NULL) { + Error (NULL, 0, 0, gGlobals.MakefileName, "failed to open output makefile for writing"); + goto ProcessingError; + } + if ((gGlobals.ModuleMakefileFptr = fopen (gGlobals.ModuleMakefileName, "w")) == NULL) { + Error (NULL, 0, 0, gGlobals.ModuleMakefileName, "failed to open output makefile for writing"); + goto ProcessingError; + } + + // + // Write the header out to the makefiles + // + for (i = 0; MakefileHeader[i] != NULL; i++) { + fprintf (gGlobals.MakefileFptr, "%s\n", MakefileHeader[i]); + fprintf (gGlobals.ModuleMakefileFptr, "%s\n", MakefileHeader[i]); + } + + // + // Init global potint = NULL + // + gGlobals.ModuleList = NULL; + gGlobals.OutdirList = NULL; + + // + // Process the [defines] section in the DSC file to get any defines we need + // elsewhere + // + ProcessDSCDefinesSection (&DSCFile); + if (ExceptionThrown ()) { + goto ProcessingError; + } + // + // Write out the [makefile.out] section data to the output makefiles + // + Sect = DSCFileFindSection (&DSCFile, MAKEFILE_OUT_SECTION_NAME); + if (Sect != NULL) { + while (DSCFileGetLine (&DSCFile, Line, sizeof (Line)) != NULL) { + ExpandSymbols (Line, ExpLine, sizeof (ExpLine), 0); + // + // Write the line to the output makefiles + // + fprintf (gGlobals.MakefileFptr, ExpLine); + fprintf (gGlobals.ModuleMakefileFptr, ExpLine); + } + } + + // + // Add a pseudo target for GLOBAL_LINK_LIB_NAME to avoid single module build + // failure when this lib is not used. + // + fprintf (gGlobals.ModuleMakefileFptr, "%sbuild ::\n\n", GLOBAL_LINK_LIB_NAME); + + fprintf (gGlobals.MakefileFptr, "libraries : \n"); + // + // Process [libraries] section in the DSC file + // + Sect = DSCFileFindSection (&DSCFile, LIBRARIES_SECTION_NAME); + if (Sect != NULL) { + ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_LIBRARIES, 0); + } + + if (ExceptionThrown ()) { + goto ProcessingError; + } + // + // Process [libraries.platform] section in the DSC file + // + Sect = DSCFileFindSection (&DSCFile, LIBRARIES_PLATFORM_SECTION_NAME); + if (Sect != NULL) { + ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_PLATFORM_LIBRARIES, 0); + } + + fprintf (gGlobals.MakefileFptr, "\n"); + if (ExceptionThrown ()) { + goto ProcessingError; + } + + // + // Process [components] section in the DSC file + // + Sect = DSCFileFindSection (&DSCFile, COMPONENTS_SECTION_NAME); + if (Sect != NULL) { + fprintf (gGlobals.MakefileFptr, "components_0 : \n"); + ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, 0); + fprintf (gGlobals.MakefileFptr, "\n"); + } + + if (ExceptionThrown ()) { + goto ProcessingError; + } + // + // Now cycle through all [components.1], [components.2], ....[components.n]. + // This is necessary to support building of firmware volumes that may contain + // other encapsulated firmware volumes (ala capsules). + // + i = 1; + while (1) { + RemoveSymbol (FV, SYM_GLOBAL); + sprintf (Line, "%s.%d", COMPONENTS_SECTION_NAME, i); + Sect = DSCFileFindSection (&DSCFile, Line); + if (Sect != NULL) { + fprintf (gGlobals.MakefileFptr, "components_%d : \n", i); + ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, i); + fprintf (gGlobals.MakefileFptr, "\n"); + } else { + break; + } + + if (ExceptionThrown ()) { + goto ProcessingError; + } + + i++; + } + +ProcessingError: + EMsg = CatchException (); + if (EMsg != NULL) { + fprintf (stderr, "%s\n", EMsg); + fprintf (stderr, "Processing aborted\n"); + } + + TryException (); + // + // Create the FV files if no fatal errors or errors + // + if (GetUtilityStatus () < STATUS_ERROR) { + CFVWriteInfFiles (&DSCFile, gGlobals.MakefileFptr); + } + + // + // Write all module name into MODULE_NAME_FILE file. + // + if ((FpModule = fopen (MODULE_NAME_FILE, "w")) != NULL) { + TempSymbol = gGlobals.ModuleList; + while (TempSymbol != NULL) { + fprintf (FpModule, " %-*s %s \n", MODULE_BASE_NAME_WIDTH, TempSymbol->Name, TempSymbol->Value); + TempSymbol = TempSymbol->Next; + } + fclose (FpModule); + FpModule = NULL; + } + + // + // Close the all the output makefiles + // + if (gGlobals.MakefileFptr != NULL) { + fclose (gGlobals.MakefileFptr); + gGlobals.MakefileFptr = NULL; + } + + if (gGlobals.ModuleMakefileFptr != NULL) { + fclose (gGlobals.ModuleMakefileFptr); + gGlobals.ModuleMakefileFptr = NULL; + } + + // + // Clean up + // + FreeSymbols (gGlobals.ModuleList); + FreeSymbols (gGlobals.OutdirList); + FreeSymbols (gGlobals.Symbol); + gGlobals.Symbol = NULL; + CFVDestructor (); + DSCFileDestroy (&DSCFile); + + EMsg = CatchException (); + if (EMsg != NULL) { + fprintf (stderr, "%s\n", EMsg); + fprintf (stderr, "Processing aborted\n"); + } + + return GetUtilityStatus (); +} + +static +int +ProcessSectionComponents ( + DSC_FILE *DSCFile, + int DscSectionType, + int Instance + ) +/*++ + +Routine Description: + + Process the [components] or [libraries] section in the description file. We + use this function for both since they're very similar. Here we just + read each line from the section, and if it's valid, call a function to + do the actual processing of the component description file. + +Arguments: + + DSCFile - structure containing section info on the description file + DscSectionType - type of description section + +Returns: + + 0 if successful + +--*/ +{ + INT8 Line[MAX_LINE_LEN]; + INT8 Line2[MAX_EXP_LINE_LEN]; + INT8 *Cptr; + + // + // Read lines while they're valid + // + while (DSCFileGetLine (DSCFile, Line, sizeof (Line)) != NULL) { + // + // Expand symbols on the line + // + if (ExpandSymbols (Line, Line2, sizeof (Line2), 0)) { + return STATUS_ERROR; + } + // + // Strip the line + // + Cptr = StripLine (Line2); + if (*Cptr) { + Message (2, "Processing component line: %s", Line2); + if (ProcessComponentFile (DSCFile, Line2, DscSectionType, Instance) != 0) { + return STATUS_ERROR; + } + } + } + + return 0; +} + +static +int +ProcessComponentFile ( + DSC_FILE *DSCFile, + INT8 *ArgLine, + int DscSectionType, + int Instance + ) +/*++ + +Routine Description: + + Given a line from the [components] or [libraries] section of the description + file, process the line to extract the component's INF filename and + parameters. Then open the INF file and process it to create a corresponding + makefile. + +Arguments: + + DSCFile The project DSC file info structure. + Libs Indicates whether we're processing the [components] + section or the [libraries] section. + ArgLine The actual line from the DSC file. Looks something like + one of the following: + + dxe\drivers\vm\vm.dsc PROCESSOR=IA32 DEST_DIR=$(DEST_DIR)\xxx FV=FV1,FV2 + $(BUILD_DIR).\FvVariable.ffs COMPONENT_TYPE=FILE + .\FvVariable.ffs COMPONENT_TYPE=FILE + define VAR1=value1 VAR2=value2 + +Returns: + + 0 if successful + +--*/ +{ + FILE *MakeFptr; + FILE *TempFptr; + INT8 *Cptr; + INT8 *name; + INT8 *End; + INT8 *TempCptr; + INT8 FileName[MAX_PATH]; + INT8 ComponentFilePath[MAX_PATH]; + INT8 InLine[MAX_LINE_LEN]; + INT8 Line[MAX_LINE_LEN]; + INT8 *Processor; + INT8 SymType; + int Len; + int ComponentCreated; + int ComponentFilePathAbsolute; + int DefineLine; + DSC_FILE ComponentFile; + INT8 ComponentMakefileName[MAX_PATH]; + BOOLEAN IsForFv; + + // + // Now remove all local symbols + // + RemoveLocalSymbols (); + // + // Null out the file pointer in case we take an exception somewhere + // and we need to close it only if we opened it. + // + MakeFptr = NULL; + ComponentFilePathAbsolute = 0; + ComponentCreated = 0; + // + // Skip preceeding spaces on the line + // + while (isspace (*ArgLine) && (*ArgLine)) { + ArgLine++; + } + // + // Find the end of the component's filename and truncate the line at that + // point. From here on out ArgLine is the name of the component filename. + // + Cptr = ArgLine; + while (!isspace (*Cptr) && *Cptr) { + Cptr++; + } + + End = Cptr; + if (*Cptr) { + End++; + *Cptr = 0; + } + // + // Exception-handle processing of this component description file + // + TryException (); + + // + // We also allow a component line format for defines of global symbols + // instead of a component filename. In this case, the line looks like: + // defines x=abc y=yyy. Be nice and accept "define" and "defines" in a + // case-insensitive manner. If it's defines, then make the symbols global. + // + if ((_stricmp (ArgLine, "define") == 0) || (_stricmp (ArgLine, "defines") == 0)) { + SymType = SYM_OVERWRITE | SYM_GLOBAL; + DefineLine = 1; + } else { + SymType = SYM_OVERWRITE | SYM_LOCAL; + DefineLine = 0; + } + // + // The rest of the component line from the DSC file should be defines + // + while (*End) { + End = StripLine (End); + if (*End) { + // + // If we're processing a "define abc=1 xyz=2" line, then set symbols + // as globals per the SymType set above. + // + Len = AddSymbol (End, NULL, SymType); + if (Len > 0) { + End += Len; + } else { + Warning (NULL, 0, 0, ArgLine, "unrecognized option in description file"); + break; + } + } + } + + // + // If DEBUG_BREAK or EFI_BREAKPOINT is defined, then do a debug breakpoint. + // + if ((GetSymbolValue ("DEBUG_BREAK") != NULL) || (GetSymbolValue ("EFI_BREAKPOINT") != NULL)) { + EFI_BREAKPOINT (); + } + + // + // If it's a define line, then we're done + // + if (DefineLine) { + // + // If there is NonFFS_FV, create the FVxxx.inf file + // and include it in makefile.out. Remove the symbol + // in order not to process it again next time + // + Cptr = GetSymbolValue (NONFFS_FV); + if (Cptr != NULL) { + NonFFSFVWriteInfFiles (DSCFile, Cptr); + RemoveSymbol (NONFFS_FV, SYM_GLOBAL); + } + + goto ComponentDone; + } + + // + // Expand symbols in the component description filename to expand the newly + // added local symbols + // + ExpandSymbols (ArgLine, Line, sizeof (Line), EXPANDMODE_NO_UNDEFS); + + // + // If we have "c:\path\filename" + // + if (IsAbsolutePath (Line)) { + ComponentFilePathAbsolute = 1; + } else if (Line[0] == '.') { + // + // or if the path starts with ".", then it's build-dir relative. + // Prepend $(BUILD_DIR) on the file name + // + sprintf (InLine, "%s\\%s", GetSymbolValue (BUILD_DIR), Line); + strcpy (Line, InLine); + ComponentFilePathAbsolute = 1; + } + + // + // Save the path from the component name for later. It may be relative or + // absolute. + // + strcpy (ComponentFilePath, Line); + Cptr = ComponentFilePath + strlen (ComponentFilePath) - 1; + while ((*Cptr != '\\') && (*Cptr != '/') && (Cptr != ComponentFilePath)) { + Cptr--; + } + // + // Terminate the path. + // + *Cptr = 0; + + // + // Typically the given line is a component description filename. However we + // also allow a FV filename (fvvariable.ffs COMPONENT_TYPE=FILE). If the + // component type is "FILE", then add it to the FV list, create a package + // file, and we're done. + // + Cptr = GetSymbolValue (COMPONENT_TYPE); + if ((Cptr != NULL) && (strncmp ( + Cptr, + COMPONENT_TYPE_FILE, + strlen (COMPONENT_TYPE_FILE) + ) == 0)) { + if (ComponentFilePathAbsolute) { + strcpy (InLine, Line); + } else { + sprintf (InLine, "%s\\%s", GetSymbolValue (EFI_SOURCE), Line); + } + CFVAddFVFile ( + InLine, + Cptr, + GetSymbolValue (FV), + Instance, + NULL, + NULL, + GetSymbolValue (APRIORI), + NULL, + NULL + ); + goto ComponentDone; + } + + // + // Better have defined processor by this point. + // + Processor = GetSymbolValue (PROCESSOR); + if (Processor == NULL) { + Error (NULL, 0, 0, NULL, "PROCESSOR not defined for component %s", Line); + return STATUS_ERROR; + } + + // + // The bin, out, and lib dirs are now = $(BUILD_DIR)/$(PROCESSOR). Set them. + // Don't flag them as file paths (required for short 8.3 filenames) since + // they're defined using the BUILD_DIR macro. + // + sprintf (InLine, "$(BUILD_DIR)\\%s", Processor); + AddSymbol (BIN_DIR, InLine, SYM_LOCAL); + AddSymbol (OUT_DIR, InLine, SYM_LOCAL); + AddSymbol (LIB_DIR, InLine, SYM_LOCAL); + // + // See if it's been destined for an FV. It's possible to not be in an + // FV if they just want to build it. + // + Cptr = GetSymbolValue (FV); + if ((Cptr != NULL) && !IS_NULL_SYMBOL_VALUE (Cptr)) { + IsForFv = TRUE; + } else { + IsForFv = FALSE; + } + // + // As an optimization, if they've defined SKIP_FV_NULL as non-zero, and + // the component is not destined for an FV, then skip it. + // Since libraries are never intended for firmware volumes, we have to + // build all of them. + // + if ((DscSectionType == DSC_SECTION_TYPE_COMPONENTS) && (IsForFv == FALSE)) { + if ((GetSymbolValue (SKIP_FV_NULL) != NULL) && (atoi (GetSymbolValue (SKIP_FV_NULL)) != 0)) { + Message (0, "%s not being built (FV=NULL)", FileName); + goto ComponentDone; + } + } + // + // Prepend EFI_SOURCE to the component description file to get the + // full path. Only do this if the path is not a full path already. + // + if (ComponentFilePathAbsolute == 0) { + name = GetSymbolValue (EFI_SOURCE); + sprintf (FileName, "%s\\%s", name, Line); + } else { + strcpy (FileName, Line); + } + // + // Print a message, depending on verbose level. + // + if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) { + Message (1, "Processing component %s", FileName); + } else { + Message (1, "Processing library %s", FileName); + } + // + // Open the component's description file and get the sections. If we fail + // to open it, see if they defined "OPTIONAL=1, in which case we'll just + // ignore the component. + // + TempFptr = fopen (FileName, "r"); + if (TempFptr == NULL) { + // + // Better have defined OPTIONAL + // + if (GetSymbolValue (OPTIONAL_COMPONENT) != NULL) { + if (atoi (GetSymbolValue (OPTIONAL_COMPONENT)) != 0) { + Message (0, "Optional component '%s' not found", FileName); + goto ComponentDone; + } + } + + ParserError (0, FileName, "failed to open component file"); + return STATUS_ERROR; + } else { + fclose (TempFptr); + } + + DSCFileInit (&ComponentFile); + ComponentCreated = 1; + if (DSCFileSetFile (&ComponentFile, FileName)) { + Error (NULL, 0, 0, NULL, "failed to preprocess component file '%s'", FileName); + return STATUS_ERROR; + } + // + // Add a symbol for the INF filename so users can create dependencies + // in makefiles. + // + AddSymbol (INF_FILENAME, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILENAME); + // + // Process the [defines], [defines.$(PROCESSOR)], and [defines.$(PROCESSOR).$(PLATFORM)] + // sections in the INF file + // + ProcessINFDefinesSection (&ComponentFile); + // + // Better have defined FILE_GUID if not a library + // + if ((GetSymbolValue (GUID) == NULL) && + (GetSymbolValue (FILE_GUID) == NULL) && + (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) + ) { + Error (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "missing FILE_GUID definition in component file"); + DSCFileDestroy (&ComponentFile); + return STATUS_ERROR; + } + // + // Better have defined base name + // + if (GetSymbolValue (BASE_NAME) == NULL) { + Error (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "missing BASE_NAME definition in INF file"); + DSCFileDestroy (&ComponentFile); + return STATUS_ERROR; + } + // + // Better have defined COMPONENT_TYPE, since it's used to find named sections. + // + if (GetSymbolValue (COMPONENT_TYPE) == NULL) { + Error (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "missing COMPONENT_TYPE definition in INF file"); + DSCFileDestroy (&ComponentFile); + return STATUS_ERROR; + } + + // + // Create the source directory path from the component file's path. If the component + // file's path is absolute, we may have problems here. Try to account for it though. + // + if (ComponentFilePathAbsolute == 0) { + sprintf ( + FileName, + "%s\\%s", + GetSymbolValue (EFI_SOURCE), + ComponentFilePath + ); + } else { + strcpy (FileName, ComponentFilePath); + } + AddSymbol (SOURCE_DIR, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILEPATH); + + // + // Create the destination path. + // They may have defined DEST_DIR on the component INF line, so it's already + // been defined, If that's the case, then don't set it to the path of this file. + // + if (GetSymbolValue (DEST_DIR) == NULL) { + if (ComponentFilePathAbsolute == 0) { + // + // The destination path is $(BUILD_DIR)\$(PROCESSOR)\component_path + // + sprintf ( + FileName, + "%s\\%s\\%s", + GetSymbolValue (BUILD_DIR), + Processor, + ComponentFilePath + ); + } else { + // + // The destination path is $(BUILD_DIR)\$(PROCESSOR)\$(BASE_NAME) + // + sprintf ( + FileName, + "%s\\%s\\%s", + GetSymbolValue (BUILD_DIR), + Processor, + GetSymbolValue (BASE_NAME) + ); + } + AddSymbol (DEST_DIR, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILEPATH); + } + + // + // Create the output directory, then open the output component's makefile + // we're going to create. Allow them to override the makefile name. + // + TempCptr = GetSymbolValue (MAKEFILE_NAME); + if (TempCptr != NULL) { + ExpandSymbols (TempCptr, ComponentMakefileName, sizeof (ComponentMakefileName), EXPANDMODE_NO_UNDEFS); + TempCptr = ComponentMakefileName; + } else { + TempCptr = "makefile"; + } + + sprintf (FileName, "%s\\%s", GetSymbolValue (DEST_DIR), TempCptr); + // + // Save it now with path info + // + AddSymbol (MAKEFILE_NAME, FileName, SYM_OVERWRITE | SYM_LOCAL | SYM_FILENAME); + + if (MakeFilePath (FileName)) { + return STATUS_ERROR; + } + + if ((MakeFptr = fopen (FileName, "w")) == NULL) { + Error (NULL, 0, 0, FileName, "could not create makefile"); + return STATUS_ERROR; + } + // + // At this point we should have all the info we need to create a package + // file if setup to do so. Libraries don't use package files, so + // don't do this for libs. + // + if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) { + CreatePackageFile (DSCFile); + } + + // + // Add Module name to the global module list + // + AddModuleName (&gGlobals.ModuleList, GetSymbolValue (BASE_NAME), GetSymbolValue (INF_FILENAME)); + // + // Write an nmake line to makefile.out + // + fprintf (gGlobals.MakefileFptr, " @cd %s\n", Processor); + fprintf (gGlobals.MakefileFptr, " $(MAKE) -f %s all\n", FileName); + fprintf (gGlobals.MakefileFptr, " @cd ..\n"); + + // + // Copy the common makefile section from the description file to + // the component's makefile + // + WriteCommonMakefile (DSCFile, MakeFptr, Processor); + // + // Process the component's [nmake.common] and [nmake.$(PROCESSOR)] sections + // + ProcessINFNMakeSection (&ComponentFile, MakeFptr); + // + // Create the SOURCE_FILES macro that includes the names of all source + // files in this component. This macro can then be used elsewhere to + // process all the files making up the component. Required for scanning + // files for string localization. + // + ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_SOURCE_FILES); + // + // Create the include paths. Process [includes.common] and + // [includes.$(PROCESSOR)] and [includes.$(PROCESSOR).$(PLATFORM)] sections. + // + ProcessIncludesSection (&ComponentFile, MakeFptr); + // + // Process all include source files to create a dependency list that can + // be used in the makefile. + // + ProcessIncludeFiles (&ComponentFile, MakeFptr); + // + // Process the [sources.common], [sources.$(PROCESSOR)], and + // [sources.$(PROCESSOR).$(PLATFORM)] files and emit their build commands + // + ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_BUILD_COMMANDS); + // + // Process sources again to create an OBJECTS macro + // + ProcessObjects (&ComponentFile, MakeFptr); + + // + // Add Single Module target : build and clean in top level makefile + // + fprintf (gGlobals.ModuleMakefileFptr, "%sbuild ::", GetSymbolValue (BASE_NAME)); + if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) { + fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", GLOBAL_LINK_LIB_NAME); + } + + // + // Process all the libraries to define "LIBS = x.lib y.lib..." + // Be generous and append ".lib" if they forgot. + // Make a macro definition: LIBS = $(LIBS) xlib.lib ylib.lib... + // Also add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ... + // + ProcessLibs (&ComponentFile, MakeFptr); + + fprintf (gGlobals.ModuleMakefileFptr, "\n"); + + fprintf (gGlobals.ModuleMakefileFptr, " @cd %s\n", Processor); + fprintf (gGlobals.ModuleMakefileFptr, " $(MAKE) -f %s all\n", FileName); + fprintf (gGlobals.ModuleMakefileFptr, " @cd ..\n\n"); + + fprintf (gGlobals.ModuleMakefileFptr, "%sclean ::\n", GetSymbolValue (BASE_NAME)); + fprintf (gGlobals.ModuleMakefileFptr, " $(MAKE) -f %s clean\n\n", FileName); + + // + // Emit commands to create the component. These are simply copied from + // the description file to the component's makefile. First look for + // [build.$(PROCESSOR).$(BUILD_TYPE)]. If not found, then look for if + // find a [build.$(PROCESSOR).$(COMPONENT_TYPE)] line. + // + Cptr = GetSymbolValue (BUILD_TYPE); + if (Cptr != NULL) { + sprintf (InLine, "build.%s.%s", Processor, Cptr); + WriteComponentTypeBuildCommands (DSCFile, MakeFptr, InLine); + } else { + sprintf (InLine, "build.%s.%s", Processor, GetSymbolValue (COMPONENT_TYPE)); + WriteComponentTypeBuildCommands (DSCFile, MakeFptr, InLine); + } + // + // Add it to the FV if not a library + // + if (DscSectionType == DSC_SECTION_TYPE_COMPONENTS) { + // + // Create the FV filename and add it to the FV. + // By this point we know it's in FV. + // + Cptr = GetSymbolValue (FILE_GUID); + if (Cptr == NULL) { + Cptr = GetSymbolValue (GUID); + } + + sprintf (InLine, "%s-%s", Cptr, GetSymbolValue (BASE_NAME)); + // + // We've deprecated FV_EXT, which should be FFS_EXT, the extension + // of the FFS file generated by GenFFSFile. + // + TempCptr = GetSymbolValue (FFS_EXT); + if (TempCptr == NULL) { + TempCptr = GetSymbolValue ("FV_EXT"); + } + + CFVAddFVFile ( + InLine, + GetSymbolValue (COMPONENT_TYPE), + GetSymbolValue (FV), + Instance, + TempCptr, + Processor, + GetSymbolValue (APRIORI), + GetSymbolValue (BASE_NAME), + Cptr + ); + } + // + // Catch any failures and print the name of the component file + // being processed to assist debugging. + // +ComponentDone: + + Cptr = CatchException (); + if (Cptr != NULL) { + fprintf (stderr, "%s\n", Cptr); + sprintf (InLine, "Processing of component %s failed", ArgLine); + ThrowException (InLine); + } + + if (MakeFptr != NULL) { + fclose (MakeFptr); + } + + if (ComponentCreated) { + DSCFileDestroy (&ComponentFile); + } + + return STATUS_SUCCESS; +} + +static +int +CreatePackageFile ( + DSC_FILE *DSCFile + ) +{ + INT8 *Package; + SECTION *TempSect; + INT8 Str[MAX_LINE_LEN]; + INT8 StrExpanded[MAX_LINE_LEN]; + SMART_FILE *PkgFptr; + int Status; + + PkgFptr = NULL; + + // + // First find out if PACKAGE_FILENAME or PACKAGE is defined. PACKAGE_FILENAME + // is used to specify the exact package file to use. PACKAGE is used to + // specify the package section name. + // + Package = GetSymbolValue (PACKAGE_FILENAME); + if (Package != NULL) { + // + // Use existing file. We're done. + // + return STATUS_SUCCESS; + } + // + // See if PACKAGE or PACKAGE_TAG is defined + // + Package = GetSymbolValue (PACKAGE); + if (Package == NULL) { + Package = GetSymbolValue (PACKAGE_TAG); + } + + if (Package == NULL) { + // + // Not defined either. Assume they are not using the package functionality + // of this utility. However define the PACKAGE_FILENAME macro to the + // best-guess value. + // + sprintf ( + Str, + "%s\\%s.pkg", + GetSymbolValue (SOURCE_DIR), + GetSymbolValue (BASE_NAME) + ); + + // + // Expand symbols in the package filename + // + ExpandSymbols (Str, StrExpanded, sizeof (StrExpanded), EXPANDMODE_NO_UNDEFS); + + AddSymbol (PACKAGE_FILENAME, StrExpanded, SYM_LOCAL | SYM_FILENAME); + return STATUS_SUCCESS; + } + // + // Save the position in the DSC file. + // Find the [package.$(COMPONENT_TYPE).$(PACKAGE)] section in the DSC file + // + Status = STATUS_SUCCESS; + DSCFileSavePosition (DSCFile); + sprintf (Str, "%s.%s.%s", PACKAGE, GetSymbolValue (COMPONENT_TYPE), Package); + TempSect = DSCFileFindSection (DSCFile, Str); + if (TempSect != NULL) { + // + // So far so good. Create the name of the package file, then open it up + // for writing. File name is c:\...\oem\platform\nt32\ia32\...\BaseName.pkg. + // + sprintf ( + Str, + "%s\\%s.pkg", + GetSymbolValue (DEST_DIR), + GetSymbolValue (BASE_NAME) + ); + + // + // Expand symbols in the package filename + // + ExpandSymbols (Str, StrExpanded, sizeof (StrExpanded), EXPANDMODE_NO_UNDEFS); + + // + // Try to open the file, then save the file name as the PACKAGE_FILENAME + // symbol for use elsewhere. + // + if ((PkgFptr = SmartOpen (StrExpanded)) == NULL) { + Error (NULL, 0, 0, Str, "could not open package file for writing"); + Status = STATUS_ERROR; + goto Finish; + } + + AddSymbol (PACKAGE_FILENAME, StrExpanded, SYM_LOCAL | SYM_FILENAME); + // + // Now read lines in from the DSC file and write them back out to the + // package file (with string substitution). + // + while (DSCFileGetLine (DSCFile, Str, sizeof (Str)) != NULL) { + // + // Expand symbols, then write the line out to the package file + // + ExpandSymbols (Str, StrExpanded, sizeof (StrExpanded), EXPANDMODE_RECURSIVE); + SmartWrite (PkgFptr, StrExpanded); + } + } else { + Warning ( + NULL, + 0, + 0, + NULL, + "cannot locate package section [%s] in DSC file for %s", + Str, + GetSymbolValue (INF_FILENAME) + ); + Status = STATUS_WARNING; + goto Finish; + } + + if (PkgFptr != NULL) { + SmartClose (PkgFptr); + } + +Finish: + // + // Restore the position in the DSC file + // + DSCFileRestorePosition (DSCFile); + + return STATUS_SUCCESS; +} + +static +int +ProcessINFDefinesSection ( + DSC_FILE *ComponentFile + ) +/*++ + +Routine Description: + + Process the [defines.xxx] sections of the component description file. Process + platform first, then processor. In this way, if a platform wants and override, + that one gets parsed first, and later assignments do not overwrite the value. + +Arguments: + + ComponentFile - section info on the component file being processed + +Returns: + + +--*/ +{ + INT8 *Cptr; + INT8 Str[MAX_LINE_LEN]; + + // + // Find a [defines.$(PROCESSOR).$(PLATFORM)] section and process it + // + Cptr = GetSymbolValue (PLATFORM); + if (Cptr != NULL) { + sprintf ( + Str, + "%s.%s.%s", + DEFINES_SECTION_NAME, + GetSymbolValue (PROCESSOR), + Cptr + ); + ProcessINFDefinesSectionSingle (ComponentFile, Str); + } + // + // Find a [defines.$(PROCESSOR)] section and process it + // + sprintf (Str, "%s.%s", DEFINES_SECTION_NAME, GetSymbolValue (PROCESSOR)); + ProcessINFDefinesSectionSingle (ComponentFile, Str); + + // + // Find a [defines] section and process it + // + if (ProcessINFDefinesSectionSingle (ComponentFile, DEFINES_SECTION_NAME) != STATUS_SUCCESS) { + Error (NULL, 0, 0, NULL, "missing [defines] section in component file %s", GetSymbolValue (INF_FILENAME)); + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} + +static +int +ProcessINFDefinesSectionSingle ( + DSC_FILE *ComponentFile, + INT8 *SectionName + ) +{ + INT8 *Cptr; + INT8 Str[MAX_LINE_LEN]; + INT8 ExpandedLine[MAX_LINE_LEN]; + SECTION *TempSect; + + TempSect = DSCFileFindSection (ComponentFile, SectionName); + if (TempSect != NULL) { + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + ExpandSymbols (Str, ExpandedLine, sizeof (ExpandedLine), 0); + Cptr = StripLine (ExpandedLine); + // + // Don't process blank lines. + // + if (*Cptr) { + // + // Add without overwriting macros specified on the component line + // in the description file + // + AddSymbol (Cptr, NULL, SYM_LOCAL); + } + } + } else { + return STATUS_WARNING; + } + + return STATUS_SUCCESS; +} + +static +int +ProcessINFNMakeSection ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ) +/*++ + +Routine Description: + + Process the [nmake.common] and [nmake.$(PROCESSOR)] sections of the component + description file and write and copy them to the component's makefile. + +Arguments: + + ComponentFile - section info on the component file being processed + MakeFptr - file pointer to the component' makefile we're creating + +Returns: + + Always STATUS_SUCCESS right now, since the sections are optional. + +--*/ +{ + INT8 *Cptr; + INT8 Str[MAX_LINE_LEN]; + INT8 ExpandedLine[MAX_LINE_LEN]; + SECTION *TempSect; + + // + // Copy the [nmake.common] and [nmake.$(PROCESSOR)] sections from the + // component file directly to the output file. + // The line will be stripped and don't print blank lines + // + sprintf (Str, "%s.%s", NMAKE_SECTION_NAME, COMMON_SECTION_NAME); + TempSect = DSCFileFindSection (ComponentFile, Str); + if (TempSect != NULL) { + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + ExpandSymbols ( + Str, + ExpandedLine, + sizeof (ExpandedLine), + EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR + ); + Cptr = StripLine (ExpandedLine); + if (*Cptr) { + fprintf (MakeFptr, "%s\n", Cptr); + } + } + + fprintf (MakeFptr, "\n"); + } else { + Error (GetSymbolValue (INF_FILENAME), 1, 0, Str, "section not found in component INF file"); + } + + sprintf (Str, "%s.%s", NMAKE_SECTION_NAME, GetSymbolValue (PROCESSOR)); + TempSect = DSCFileFindSection (ComponentFile, Str); + if (TempSect != NULL) { + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + ExpandSymbols ( + Str, + ExpandedLine, + sizeof (ExpandedLine), + EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR + ); + Cptr = StripLine (ExpandedLine); + if (*Cptr) { + fprintf (MakeFptr, "%s\n", Cptr); + } + } + + fprintf (MakeFptr, "\n"); + } + // + // Do the same for [nmake.$(PROCESSOR).$(PLATFORM)] + // + Cptr = GetSymbolValue (PLATFORM); + if (Cptr != NULL) { + sprintf (Str, "%s.%s.%s", NMAKE_SECTION_NAME, GetSymbolValue (PROCESSOR), Cptr); + TempSect = DSCFileFindSection (ComponentFile, Str); + if (TempSect != NULL) { + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + ExpandSymbols ( + Str, + ExpandedLine, + sizeof (ExpandedLine), + EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR + ); + Cptr = StripLine (ExpandedLine); + if (*Cptr) { + fprintf (MakeFptr, "%s\n", Cptr); + } + } + + fprintf (MakeFptr, "\n"); + } + } + + return STATUS_SUCCESS; +} + +static +int +ProcessIncludesSection ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ) +/*++ + +Routine Description: + + Process the [includes.common], [includes.processor], and + [includes.processor.platform] section of the component description file + and write the appropriate macros to the component's makefile. + + Process in reverse order to allow overrides on platform basis. + +Arguments: + + ComponentFile - section info on the component file being processed + MakeFptr - file pointer to the component' makefile we're creating + +Returns: + + Always STATUS_SUCCESS right now, since the sections are optional. + +--*/ +{ + INT8 *Cptr; + INT8 Str[MAX_LINE_LEN]; + INT8 *Processor; + INT8 *OverridePath; + + // + // Write a useful comment to the output makefile so the user knows where + // the data came from. + // + fprintf (MakeFptr, "#\n# Tool-generated list of include paths that are created\n"); + fprintf (MakeFptr, "# from the list of include paths in the [includes.*] sections\n"); + fprintf (MakeFptr, "# of the component INF file.\n#\n"); + + // + // We use this a lot here, so get the value only once. + // + Processor = GetSymbolValue (PROCESSOR); + // + // If they're using an override source path, then add OverridePath and + // OverridePath\$(PROCESSOR) to the list of include paths. + // + OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH); + if (OverridePath != NULL) { + fprintf (MakeFptr, "INC = $(INC) -I %s\n", OverridePath); + fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", OverridePath, Processor); + } + // + // Try for an [includes.$(PROCESSOR).$(PLATFORM)] + // + Cptr = GetSymbolValue (PLATFORM); + if (Cptr != NULL) { + sprintf (Str, "%s.%s.%s", INCLUDE_SECTION_NAME, Processor, Cptr); + ProcessIncludesSectionSingle (ComponentFile, MakeFptr, Str); + } + // + // Now the [includes.$(PROCESSOR)] section + // + sprintf (Str, "%s.%s", INCLUDE_SECTION_NAME, Processor); + ProcessIncludesSectionSingle (ComponentFile, MakeFptr, Str); + + // + // Now the [includes.common] section + // + sprintf (Str, "%s.%s", INCLUDE_SECTION_NAME, COMMON_SECTION_NAME); + ProcessIncludesSectionSingle (ComponentFile, MakeFptr, Str); + + // + // Done + // + fprintf (MakeFptr, "\n"); + return STATUS_SUCCESS; +} +// +// Process one of the [includes.xxx] sections to create a list of all +// the include paths. +// +static +int +ProcessIncludesSectionSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ) +{ + INT8 *Cptr; + SECTION *TempSect; + INT8 Str[MAX_LINE_LEN]; + INT8 ExpandedLine[MAX_LINE_LEN]; + INT8 *Processor; + + TempSect = DSCFileFindSection (ComponentFile, SectionName); + if (TempSect != NULL) { + // + // Add processor subdirectory on every include path + // + Processor = GetSymbolValue (PROCESSOR); + // + // Copy lines directly + // + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + ExpandSymbols (Str, ExpandedLine, sizeof (ExpandedLine), 0); + Cptr = StripLine (ExpandedLine); + // + // Don't process blank lines + // + if (*Cptr) { + // + // Strip off trailing slash + // + if (Cptr[strlen (Cptr) - 1] == '\\') { + Cptr[strlen (Cptr) - 1] = 0; + } + // + // Special case of ".". Replace it with source path + // and the rest of the line (for .\$(PROCESSOR)) + // + if (*Cptr == '.') { + // + // Handle case of just a "." + // + if (Cptr[1] == 0) { + fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\n"); + fprintf ( + MakeFptr, + "INC = $(INC) -I $(SOURCE_DIR)\\%s \n", + Processor + ); + } else { + // + // Handle case of ".\path\path\path" or "..\path\path\path" + // + fprintf ( + MakeFptr, + "INC = $(INC) -I $(SOURCE_DIR)\\%s \n", + Cptr + ); + fprintf ( + MakeFptr, + "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s \n", + Cptr, + Processor + ); + } + } else if ((Cptr[1] != ':') && isalpha (*Cptr)) { + fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s \n", Cptr); + fprintf ( + MakeFptr, + "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s \n", + Cptr, + Processor + ); + } else { + // + // The line is something like: $(EFI_SOURCE)\dxe\include. Add it to + // the existing $(INC) definition. Add user includes before any + // other existing paths. + // + fprintf (MakeFptr, "INC = $(INC) -I %s \n", Cptr); + fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", Cptr, Processor); + } + } + } + } + + return STATUS_SUCCESS; +} + +static +int +ProcessSourceFiles ( + DSC_FILE *DSCFile, + DSC_FILE *ComponentFile, + FILE *MakeFptr, + UINT32 Mode + ) +/*++ + +Routine Description: + + Process the [sources.common], [sources.$(PROCESSOR)], and + [sources.$(PROCESSOR).$(PLATFORM] sections of the component + description file and write the appropriate build commands out to the + component's makefile. If $(SOURCE_SELECT) is defined, then it overrides + the source selections. We use this functionality for SMM. + +Arguments: + + ComponentFile - section info on the component file being processed + MakeFptr - file pointer to the component' makefile we're creating + DSCFile - section info on the description file we're processing + Mode - to write build commands, or just create a list + of sources. + +Returns: + + Always STATUS_SUCCESS right now, since the sections are optional. + +--*/ +{ + INT8 Str[MAX_LINE_LEN]; + INT8 *Processor; + INT8 *Platform; + INT8 *SourceSelect; + INT8 *CStart; + INT8 *CEnd; + INT8 CSave; + INT8 *CopySourceSelect; + + if (Mode & SOURCE_MODE_SOURCE_FILES) { + // + // Write a useful comment to the output makefile so the user knows where + // the data came from. + // + fprintf (MakeFptr, "#\n# Tool-generated list of source files that are created\n"); + fprintf (MakeFptr, "# from the list of source files in the [sources.*] sections\n"); + fprintf (MakeFptr, "# of the component INF file.\n#\n"); + } + + // + // We use this a lot here, so get the value only once. + // + Processor = GetSymbolValue (PROCESSOR); + // + // See if they defined SOURCE_SELECT=xxx,yyy in which case we'll + // select each [sources.xxx] and [sources.yyy] files and process + // them. + // + SourceSelect = GetSymbolValue (SOURCE_SELECT); + + if (SourceSelect != NULL) { + // + // Make a copy of the string and break it up (comma-separated) and + // select each [sources.*] file from the INF. + // + CopySourceSelect = (INT8 *) malloc (strlen (SourceSelect) + 1); + if (CopySourceSelect == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (CopySourceSelect, SourceSelect); + CStart = CopySourceSelect; + CEnd = CStart; + while (*CStart) { + CEnd = CStart + 1; + while (*CEnd && *CEnd != ',') { + CEnd++; + } + + CSave = *CEnd; + *CEnd = 0; + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, CStart); + ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode); + // + // Restore the terminator and advance + // + *CEnd = CSave; + CStart = CEnd; + if (*CStart) { + CStart++; + } + } + + free (CopySourceSelect); + + } else { + // + // Process all the [sources.common] source files to make them build + // + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, COMMON_SECTION_NAME); + ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode); + // + // Now process the [sources.$(PROCESSOR)] files. + // + sprintf (Str, "sources.%s", Processor); + ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode); + // + // Now process the [sources.$(PROCESSOR).$(PLATFORM)] files. + // + Platform = GetSymbolValue (PLATFORM); + if (Platform != NULL) { + sprintf (Str, "sources.%s.%s", Processor, Platform); + ProcessSourceFilesSection (DSCFile, ComponentFile, MakeFptr, Str, Mode); + } + } + + fprintf (MakeFptr, "\n"); + return STATUS_SUCCESS; +} + +/*++ + +Routine Description: + Given a source file line from an INF file, parse it to see if there are + any defines on it. If so, then add them to the symbol table. + Also, terminate the line after the file name. + +Arguments: + SourceFileLine - a line from a [sources.?] section of the INF file. Likely + something like: + + MySourceFile.c BUILT_NAME=$(BUILD_DIR)\MySourceFile.obj + +Returns: + Nothing. + +--*/ +static +void +AddFileSymbols ( + INT8 *SourceFileLine + ) +{ + int Len; + // + // Skip spaces + // + for (; *SourceFileLine && isspace (*SourceFileLine); SourceFileLine++) + ; + for (; *SourceFileLine && !isspace (*SourceFileLine); SourceFileLine++) + ; + if (*SourceFileLine) { + *SourceFileLine = 0; + SourceFileLine++; + // + // AddSymbol() will parse it for us, and return the length. Keep calling + // it until it reports an error or is done. + // + do { + Len = AddSymbol (SourceFileLine, NULL, SYM_FILE); + SourceFileLine += Len; + } while (Len > 0); + } +} +// +// Process a single section of source files in the component INF file +// +static +int +ProcessSourceFilesSection ( + DSC_FILE *DSCFile, + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName, + UINT32 Mode + ) +{ + INT8 *Cptr; + INT8 FileName[MAX_EXP_LINE_LEN]; + INT8 FilePath[MAX_PATH]; + INT8 TempFileName[MAX_PATH]; + SECTION *TempSect; + INT8 Str[MAX_LINE_LEN]; + INT8 *Processor; + INT8 *OverridePath; + FILE *FPtr; + + TempSect = DSCFileFindSection (ComponentFile, SectionName); + if (TempSect != NULL) { + Processor = GetSymbolValue (PROCESSOR); + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + Cptr = StripLine (Str); + // + // Don't process blank lines + // + if (*Cptr) { + // + // Expand symbols in the filename, then parse the line for symbol + // definitions. AddFileSymbols() will null-terminate the line + // after the file name. Save a copy for override purposes, in which + // case we'll need to know the file name and path (in case it's in + // a subdirectory). + // + ExpandSymbols (Cptr, FileName, sizeof (FileName), 0); + AddFileSymbols (FileName); + // + // Set the SOURCE_FILE_NAME symbol. What we have now is the name of + // the file, relative to the location of the INF file. So prepend + // $(SOURCE_DIR) to it first. + // + if (IsAbsolutePath (FileName)) { + strcpy (TempFileName, FileName); + } else { + strcpy (TempFileName, "$(SOURCE_DIR)\\"); + strcat (TempFileName, FileName); + } + AddSymbol (SOURCE_FILE_NAME, TempFileName, SYM_FILE | SYM_OVERWRITE); + // + // Extract path information from the source file and set internal + // variable SOURCE_RELATIVE_PATH. Only do this if the path + // contains a backslash. + // + strcpy (FilePath, FileName); + for (Cptr = FilePath + strlen (FilePath) - 1; (Cptr > FilePath) && (*Cptr != '\\'); Cptr--) + ; + if (*Cptr == '\\') { + *(Cptr + 1) = 0; + AddSymbol (SOURCE_RELATIVE_PATH, FilePath, SYM_FILE); + } + // + // Define another internal symbol for the name of the file without + // the path and extension. + // + for (Cptr = FileName + strlen (FileName) - 1; (Cptr > FileName) && (*Cptr != '\\'); Cptr--) + ; + if (*Cptr == '\\') { + Cptr++; + } + + strcpy (FilePath, Cptr); + // + // We now have a file name with no path information. Before we do anything else, + // see if OVERRIDE_PATH is set, and if so, see if file $(OVERRIDE_PATH)FileName + // exists. If it does, then recursive call this function to use the override file + // instead of the one from the INF file. + // + if (IsAbsolutePath (FileName)) { + OverridePath = NULL; + } else { + OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH); + } + if (OverridePath != NULL) { + // + // See if the file exists. If it does, reset the SOURCE_FILE_NAME symbol. + // + strcpy (TempFileName, OverridePath); + strcat (TempFileName, "\\"); + strcat (TempFileName, FileName); + if ((FPtr = fopen (TempFileName, "rb")) != NULL) { + fclose (FPtr); + AddSymbol (SOURCE_FILE_NAME, TempFileName, SYM_FILE | SYM_OVERWRITE); + // + // Print a message. This function is called to create build commands + // for source files, and to create a macro of all source files. Therefore + // do this check so we don't print the override message multiple times. + // + if (Mode & SOURCE_MODE_BUILD_COMMANDS) { + fprintf (stdout, "Override: %s\n", TempFileName); + } + } else { + // + // Set override path to null to use as a flag below + // + OverridePath = NULL; + } + } + + // + // Start at the end and work back + // + for (Cptr = FilePath + strlen (FilePath) - 1; (Cptr > FilePath) && (*Cptr != '\\') && (*Cptr != '.'); Cptr--) + ; + if (*Cptr == '.') { + *Cptr = 0; + AddSymbol (SOURCE_FILE_EXTENSION, Cptr + 1, SYM_FILE); + } + + AddSymbol (SOURCE_BASE_NAME, FilePath, SYM_FILE); + // + // If we're just creating the SOURCE_FILES macro, then write the + // file name out to the makefile. + // + if (Mode & SOURCE_MODE_SOURCE_FILES) { + // + // If we're processing an override file, then use the file name as-is + // + if (OverridePath != NULL) { + // + // SOURCE_FILES = $(SOURCE_FILES) c:\Path\ThisFile.c + // + fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", TempFileName); + } else if (IsAbsolutePath (FileName)) { + // + // For Absolute path, don't print $(SOURCE_FILE) directory. + // + fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", FileName); + } else { + // + // SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\ThisFile.c + // + fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\\%s\n", FileName); + } + } else if (Mode & SOURCE_MODE_BUILD_COMMANDS) { + // + // Write the build commands for this file per the build commands + // for this file type as defined in the description file. + // Also create the directory for it in the build path. + // + WriteCompileCommands (DSCFile, MakeFptr, FileName, Processor); + if (!IsAbsolutePath (FileName)) { + sprintf (Str, "%s\\%s", GetSymbolValue (DEST_DIR), FileName); + MakeFilePath (Str); + // + // Get all output directory for build output files. + // + Cptr = FileName + strlen (FileName) - 1; + for (; (Cptr > FileName) && (*Cptr != '\\'); Cptr--); + if (*Cptr == '\\') { + *Cptr = '\0'; + AddModuleName (&gGlobals.OutdirList, FileName, NULL); + } + } + } + // + // Remove file-level symbols + // + RemoveFileSymbols (); + } + } + } + + return STATUS_SUCCESS; +} +// +// Process the INF [sources.*] sections and emit the OBJECTS = ..... +// lines to the component's makefile. +// +static +int +ProcessObjects ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ) +{ + INT8 Str[MAX_LINE_LEN]; + INT8 *Processor; + INT8 *Platform; + INT8 *SourceSelect; + INT8 *CStart; + INT8 *CEnd; + INT8 CSave; + INT8 *CopySourceSelect; + SYMBOL *TempSymbol; + + // + // Write a useful comment to the output makefile so the user knows where + // the data came from. + // + fprintf (MakeFptr, "#\n# Tool-generated list of object files that are created\n"); + fprintf (MakeFptr, "# from the list of source files in the [sources.*] sections\n"); + fprintf (MakeFptr, "# of the component INF file.\n#\n"); + // + // We use this a lot here, so get the value only once. + // + Processor = GetSymbolValue (PROCESSOR); + // + // Now define the OBJECTS variable and assign it to be all the object files we're going + // to create. Afterwards create a pseudo-target objects to let the user quickly just compile + // the source files. This means we need to process all the common objects and + // processor-specific objects again. + // + fprintf (MakeFptr, "OBJECTS = $(OBJECTS) "); + // + // See if they defined SOURCE_SELECT=xxx,yyy in which case well + // select each [sources.xxx] and [sources.yyy] files and process + // them. + // + SourceSelect = GetSymbolValue (SOURCE_SELECT); + + if (SourceSelect != NULL) { + // + // Make a copy of the string and break it up (comma-separated) and + // select each [sources.*] file from the INF. + // + CopySourceSelect = (INT8 *) malloc (strlen (SourceSelect) + 1); + if (CopySourceSelect == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (CopySourceSelect, SourceSelect); + CStart = CopySourceSelect; + CEnd = CStart; + while (*CStart) { + CEnd = CStart + 1; + while (*CEnd && *CEnd != ',') { + CEnd++; + } + + CSave = *CEnd; + *CEnd = 0; + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, CStart); + ProcessObjectsSingle (ComponentFile, MakeFptr, Str); + // + // Restore the terminator and advance + // + *CEnd = CSave; + CStart = CEnd; + if (*CStart) { + CStart++; + } + } + + free (CopySourceSelect); + + } else { + // + // Now process all the [sources.common] files and emit build commands for them + // + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, COMMON_SECTION_NAME); + if (ProcessObjectsSingle (ComponentFile, MakeFptr, Str) != STATUS_SUCCESS) { + Warning (GetSymbolValue (INF_FILENAME), 1, 0, NULL, "no [%s] section found in component description", Str); + } + // + // Now process any processor-specific source files in [sources.$(PROCESSOR)] + // + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, Processor); + ProcessObjectsSingle (ComponentFile, MakeFptr, Str); + + // + // Now process any [sources.$(PROCESSOR).$(PLATFORM)] files + // + Platform = GetSymbolValue (PLATFORM); + if (Platform != NULL) { + sprintf (Str, "sources.%s.%s", Processor, Platform); + ProcessObjectsSingle (ComponentFile, MakeFptr, Str); + } + } + + fprintf (MakeFptr, "\n\n"); + + // + // Write a useful comment to the output makefile so the user knows where + // the data came from. + // + fprintf (MakeFptr, "#\n# Tool-generated list of dest output dirs that are created\n"); + fprintf (MakeFptr, "# from the list of source files in the [sources.*] sections\n"); + fprintf (MakeFptr, "# of the component INF file.\n#\n"); + // + // Create output directory list + // for clean target to delete all build output files. + // + fprintf (MakeFptr, "DEST_OUTPUT_DIRS = $(%s) ", DEST_DIR); + + TempSymbol = gGlobals.OutdirList; + while (TempSymbol != NULL) { + fprintf (MakeFptr, "\\\n $(%s)\\%s ", + DEST_DIR, TempSymbol->Name); + TempSymbol = TempSymbol->Next; + } + fprintf (MakeFptr, "\n\n"); + + // + // clean up for the next module + // + FreeSymbols (gGlobals.OutdirList); + gGlobals.OutdirList = NULL; + + return STATUS_SUCCESS; +} + +static +INT8 * +BuiltFileExtension ( + INT8 *SourceFileName + ) +{ + int i; + INT8 *Cptr; + // + // Find the dot in the filename extension + // + for (Cptr = SourceFileName + strlen (SourceFileName) - 1; + (Cptr > SourceFileName) && (*Cptr != '\\') && (*Cptr != '.'); + Cptr-- + ) { + // + // Do nothing + // + } + + if (*Cptr != '.') { + return NULL; + } + // + // Look through our list of known file types and return a pointer to + // its built file extension. + // + for (i = 0; mFileTypes[i].Extension != NULL; i++) { + if (_stricmp (Cptr, mFileTypes[i].Extension) == 0) { + return mFileTypes[i].BuiltExtension; + } + } + + return NULL; +} + +int +ProcessObjectsSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ) +{ + INT8 *Cptr; + INT8 *Cptr2; + INT8 Str[MAX_LINE_LEN]; + INT8 FileName[MAX_EXP_LINE_LEN]; + SECTION *TempSect; + + TempSect = DSCFileFindSection (ComponentFile, SectionName); + if (TempSect != NULL) { + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + Cptr = StripLine (Str); + // + // Don't process blank lines + // + if (*Cptr) { + // + // Expand symbols then create the output filename. We'll do a lookup + // on the source file's extension to determine what the extension of + // the built version of the file is. For example, .c -> .obj. + // + if (!IsIncludeFile (Cptr)) { + ExpandSymbols (Cptr, FileName, sizeof (FileName), 0); + Cptr2 = BuiltFileExtension (FileName); + if (Cptr2 != NULL) { + SetFileExtension (FileName, Cptr2); + if (!IsAbsolutePath (FileName)) { + fprintf (MakeFptr, "\\\n $(%s)\\%s ", DEST_DIR, FileName); + } else { + fprintf (MakeFptr, "\\\n %s ", FileName); + } + } + } + } + } + } else { + return STATUS_WARNING; + } + + return STATUS_SUCCESS; +} +// +// Process all [libraries.*] sections in the component INF file to create a +// macro to the component's output makefile: LIBS = Lib1 Lib2, ... +// +static +int +ProcessLibs ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ) +{ + INT8 Str[MAX_LINE_LEN]; + INT8 *Processor; + INT8 *Platform; + + // + // Print a useful comment to the component's makefile so the user knows + // where the data came from. + // + fprintf (MakeFptr, "#\n# Tool-generated list of libraries that are generated\n"); + fprintf (MakeFptr, "# from the list of libraries listed in the [libraries.*] sections\n"); + fprintf (MakeFptr, "# of the component INF file.\n#\n"); + + fprintf (MakeFptr, "LIBS = $(LIBS) "); + + Processor = GetSymbolValue (PROCESSOR); + // + // Process [libraries.common] files + // + sprintf (Str, "%s.%s", LIBRARIES_SECTION_NAME, COMMON_SECTION_NAME); + ProcessLibsSingle (ComponentFile, MakeFptr, Str); + // + // Process the [libraries.$(PROCESSOR)] libraries to define "LIBS = x.lib y.lib..." + // + sprintf (Str, "%s.%s", LIBRARIES_SECTION_NAME, Processor); + ProcessLibsSingle (ComponentFile, MakeFptr, Str); + // + // Now process any [libraries.$(PROCESSOR).$(PLATFORM)] files + // + Platform = GetSymbolValue (PLATFORM); + if (Platform != NULL) { + sprintf (Str, "%s.%s.%s", LIBRARIES_SECTION_NAME, Processor, Platform); + ProcessLibsSingle (ComponentFile, MakeFptr, Str); + } + // + // Process any [libraries.platform] files + // + ProcessLibsSingle (ComponentFile, MakeFptr, LIBRARIES_PLATFORM_SECTION_NAME); + + fprintf (MakeFptr, "\n\n"); + return STATUS_SUCCESS; +} + +static +int +ProcessLibsSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ) +{ + INT8 *Cptr; + INT8 Str[MAX_LINE_LEN]; + INT8 ExpandedLine[MAX_LINE_LEN]; + SECTION *TempSect; + + TempSect = DSCFileFindSection (ComponentFile, SectionName); + if (TempSect != NULL) { + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + ExpandSymbols (Str, ExpandedLine, sizeof (ExpandedLine), 0); + Cptr = StripLine (ExpandedLine); + // + // Don't process blank lines + // + if (*Cptr) { + if (Cptr[strlen (Cptr) - 4] != '.') { + fprintf (MakeFptr, " \\\n $(LIB_DIR)\\%s.lib", Cptr); + // + // Add lib dependency for single module build + // + fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr); + } else { + fprintf (MakeFptr, " \\\n $(LIB_DIR)\\%s", Cptr); + // + // Add lib dependency for single module build + // + Cptr[strlen (Cptr) - 4] = 0; + fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr); + } + } + } + } + + return STATUS_SUCCESS; +} + +static +int +ProcessIncludeFiles ( + DSC_FILE *ComponentFile, + FILE *MakeFptr + ) +{ + INT8 Str[MAX_LINE_LEN]; + INT8 *Processor; + INT8 *Platform; + INT8 *SourceSelect; + INT8 *CStart; + INT8 *CEnd; + INT8 CSave; + INT8 *CopySourceSelect; + + // + // Print a useful comment to the output makefile so the user knows where + // the info came from + // + //fprintf (MakeFptr, "#\n# Tool-generated include dependencies from any include files in the\n"); + //fprintf (MakeFptr, "# [sources.*] sections of the component INF file\n#\n"); + + Processor = GetSymbolValue (PROCESSOR); + + // + // See if they defined SOURCE_SELECT=xxx,yyy in which case we'll + // select each [sources.xxx] and [sources.yyy] files and process + // them. + // + SourceSelect = GetSymbolValue (SOURCE_SELECT); + + if (SourceSelect != NULL) { + // + // Make a copy of the string and break it up (comma-separated) and + // select each [sources.*] file from the INF. + // + CopySourceSelect = (INT8 *) malloc (strlen (SourceSelect) + 1); + if (CopySourceSelect == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return STATUS_ERROR; + } + + strcpy (CopySourceSelect, SourceSelect); + CStart = CopySourceSelect; + CEnd = CStart; + while (*CStart) { + CEnd = CStart + 1; + while (*CEnd && *CEnd != ',') { + CEnd++; + } + + CSave = *CEnd; + *CEnd = 0; + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, CStart); + ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str); + // + // Restore the terminator and advance + // + *CEnd = CSave; + CStart = CEnd; + if (*CStart) { + CStart++; + } + } + + free (CopySourceSelect); + + } else { + // + // Find all the include files in the [sources.common] sections. + // + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, COMMON_SECTION_NAME); + ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str); + // + // Now process the [sources.$(PROCESSOR)] files. + // + sprintf (Str, "%s.%s", SOURCES_SECTION_NAME, Processor); + ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str); + // + // Now process the [sources.$(PROCESSOR).$(PLATFORM)] files. + // + Platform = GetSymbolValue (PLATFORM); + if (Platform != NULL) { + sprintf (Str, "sources.%s.%s", Processor, Platform); + ProcessIncludeFilesSingle (ComponentFile, MakeFptr, Str); + } + } + + fprintf (MakeFptr, "\n"); + return STATUS_SUCCESS; +} + +int +ProcessIncludeFilesSingle ( + DSC_FILE *ComponentFile, + FILE *MakeFptr, + INT8 *SectionName + ) +{ + INT8 *Cptr; + INT8 FileName[MAX_EXP_LINE_LEN]; + INT8 TempFileName[MAX_PATH]; + SECTION *TempSect; + INT8 Str[MAX_LINE_LEN]; + INT8 *OverridePath; + FILE *FPtr; + + TempSect = DSCFileFindSection (ComponentFile, SectionName); + if (TempSect != NULL) { + // + // See if the SOURCE_OVERRIDE_PATH has been set. If it has, and + // they have an include file that is overridden, then add the path + // to it to the list of include paths (prepend). + // + OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH); + while (DSCFileGetLine (ComponentFile, Str, sizeof (Str)) != NULL) { + Cptr = StripLine (Str); + // + // Don't process blank lines + // + if (*Cptr) { + // + // Expand symbols in the filename, then get its parts + // + ExpandSymbols (Cptr, FileName, sizeof (FileName), 0); + AddFileSymbols (FileName); + if (IsIncludeFile (FileName)) { + if ((OverridePath != NULL) && (!IsAbsolutePath (FileName))) { + strcpy (TempFileName, OverridePath); + strcat (TempFileName, "\\"); + strcat (TempFileName, FileName); + if ((FPtr = fopen (TempFileName, "rb")) != NULL) { + fclose (FPtr); + // + // Null-terminate the file name at the last backslash and add that + // to the beginning of the list of include paths. + // + for (Cptr = TempFileName + strlen (TempFileName) - 1; + (Cptr >= TempFileName) && (*Cptr != '\\') && (*Cptr != '/'); + Cptr-- + ) + ; + if (Cptr >= TempFileName) { + *Cptr = 0; + } + + fprintf (MakeFptr, "INC = -I %s $(INC)\n", TempFileName); + } + } + // + // If absolute path already, don't prepend source directory + // + // if (IsAbsolutePath (FileName)) { + // fprintf (MakeFptr, "INC_DEPS = $(INC_DEPS) %s\n", FileName); + // } else { + // fprintf (MakeFptr, "INC_DEPS = $(INC_DEPS) $(SOURCE_DIR)\\%s\n", FileName); + // } + } + + RemoveFileSymbols (); + } + } + } + + return STATUS_SUCCESS; +} + +static +void +FreeFileParts ( + FILE_NAME_PARTS *FP + ) +{ + if (FP != NULL) { + if (FP->Path != NULL) { + free (FP->Path); + } + + if (FP->BaseName != NULL) { + free (FP->BaseName); + } + + if (FP->Extension != NULL) { + free (FP->Extension); + } + } +} + +static +FILE_NAME_PARTS * +GetFileParts ( + INT8 *FileName + ) +{ + FILE_NAME_PARTS *FP; + INT8 *Cptr; + INT8 CopyFileName[MAX_PATH]; + INT8 *FileNamePtr; + + strcpy (CopyFileName, FileName); + FP = (FILE_NAME_PARTS *) malloc (sizeof (FILE_NAME_PARTS)); + if (FP == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return NULL; + } + + memset ((INT8 *) FP, 0, sizeof (FILE_NAME_PARTS)); + // + // Get extension code + // + FP->ExtensionCode = GetSourceFileType (CopyFileName); + // + // Get drive if there + // + FileNamePtr = CopyFileName; + if (FileNamePtr[1] == ':') { + FP->Drive[0] = FileNamePtr[0]; + FP->Drive[1] = ':'; + FileNamePtr += 2; + } + // + // Start at the end and work back + // + for (Cptr = FileNamePtr + strlen (FileNamePtr) - 1; (Cptr > FileNamePtr) && (*Cptr != '.'); Cptr--) + ; + + if (*Cptr == '.') { + // + // Don't copy the dot + // + FP->Extension = (char *) malloc (strlen (Cptr)); + strcpy (FP->Extension, Cptr + 1); + *Cptr = 0; + Cptr--; + StripTrailingSpaces (FP->Extension); + } else { + // + // Create empty string for extension + // + FP->Extension = (char *) malloc (1); + FP->Extension[0] = 0; + } + // + // Now back up and get the base name (include the preceding '\' or '/') + // + for (; (Cptr > FileNamePtr) && (*Cptr != '\\') && (*Cptr != '/'); Cptr--) + ; + FP->BaseName = (char *) malloc (strlen (Cptr) + 1); + strcpy (FP->BaseName, Cptr); + *Cptr = 0; + Cptr--; + // + // Rest is path + // + if (Cptr >= FileNamePtr) { + Cptr = FileNamePtr; + FP->Path = (char *) malloc (strlen (Cptr) + 1); + strcpy (FP->Path, Cptr); + } else { + FP->Path = (char *) malloc (1); + FP->Path[0] = 0; + } + + return FP; +} + +/***************************************************************************** +******************************************************************************/ +static +int +WriteCommonMakefile ( + DSC_FILE *DSCFile, + FILE *MakeFptr, + INT8 *Processor + ) +{ + INT8 InLine[MAX_LINE_LEN]; + INT8 OutLine[MAX_EXP_LINE_LEN]; + SECTION *Sect; + INT8 *Sym; + int i; + // + // Don't mess up the original file pointer, since we're processing it at a higher + // level. + // + DSCFileSavePosition (DSCFile); + // + // Write the header to the file + // + for (i = 0; MakefileHeader[i] != NULL; i++) { + fprintf (MakeFptr, "%s\n", MakefileHeader[i]); + } + + fprintf (MakeFptr, "#\n# Hard-coded defines output by the tool\n#\n"); + // + // First write the basics to the component's makefile. These includes + // EFI_SOURCE, BIN_DIR, OUT_DIR, LIB_DIR, SOURCE_DIR, DEST_DIR. + // + Sym = GetSymbolValue (EFI_SOURCE); + fprintf (MakeFptr, "%s = %s\n", EFI_SOURCE, Sym); + Sym = GetSymbolValue (BUILD_DIR); + fprintf (MakeFptr, "%s = %s\n", BUILD_DIR, Sym); + Sym = GetSymbolValue (BIN_DIR); + fprintf (MakeFptr, "%s = %s\n", BIN_DIR, Sym); + Sym = GetSymbolValue (OUT_DIR); + fprintf (MakeFptr, "%s = %s\n", OUT_DIR, Sym); + Sym = GetSymbolValue (LIB_DIR); + fprintf (MakeFptr, "%s = %s\n", LIB_DIR, Sym); + Sym = GetSymbolValue (SOURCE_DIR); + fprintf (MakeFptr, "%s = %s\n", SOURCE_DIR, Sym); + Sym = GetSymbolValue (DEST_DIR); + fprintf (MakeFptr, "%s = %s\n", DEST_DIR, Sym); + fprintf (MakeFptr, "\n"); + // + // If there was a [makefile.common] section in the description file, + // copy it (after symbol expansion) to the output file. + // + sprintf (InLine, "%s.%s", MAKEFILE_SECTION_NAME, COMMON_SECTION_NAME); + Sect = DSCFileFindSection (DSCFile, InLine); + if (Sect != NULL) { + // + // fprintf (MakeFptr, "# From the [makefile.common] section of the DSC file\n"); + // Read lines, expand, then dump out + // + while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) { + // + // Replace symbols + // + ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE); + fprintf (MakeFptr, OutLine); + } + } + // + // If there was a [makefile.platform] section in the description file, + // copy it (after symbol expansion) to the output file. + // + sprintf (InLine, "%s.%s", MAKEFILE_SECTION_NAME, "Platform"); + Sect = DSCFileFindSection (DSCFile, InLine); + if (Sect != NULL) { + // + // Read lines, expand, then dump out + // + while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) { + // + // Replace symbols + // + ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE); + fprintf (MakeFptr, OutLine); + } + } + // + // Do the same for any [makefile.$(PROCESSOR)] + // + sprintf (InLine, "%s.%s", MAKEFILE_SECTION_NAME, Processor); + Sect = DSCFileFindSection (DSCFile, InLine); + if (Sect != NULL) { + // + // Read lines, expand, then dump out + // + while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) { + ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE); + fprintf (MakeFptr, OutLine); + } + } + // + // Same thing for [makefile.$(PROCESSOR).$(PLATFORM)] + // + Sym = GetSymbolValue (PLATFORM); + if (Sym != NULL) { + sprintf (InLine, "%s.%s.%s", MAKEFILE_SECTION_NAME, Processor, Sym); + Sect = DSCFileFindSection (DSCFile, InLine); + if (Sect != NULL) { + // + // Read lines, expand, then dump out + // + while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) { + ExpandSymbols (InLine, OutLine, sizeof (OutLine), EXPANDMODE_RECURSIVE); + fprintf (MakeFptr, OutLine); + } + } + } + + fprintf (MakeFptr, "\n"); + DSCFileRestorePosition (DSCFile); + return 0; +} + +static +int +WriteComponentTypeBuildCommands ( + DSC_FILE *DSCFile, + FILE *MakeFptr, + INT8 *SectionName + ) +/*++ + +Routine Description: + + Given a section name such as [build.ia32.library], find the section in + the description file and copy the build commands. + +Arguments: + + DSCFile - section information on the main description file + MakeFptr - file pointer to the makefile we're writing to + SectionName - name of the section we're to copy out to the makefile. + +Returns: + + Always successful, since the section may be optional. + +--*/ +{ + SECTION *Sect; + INT8 InLine[MAX_LINE_LEN]; + INT8 OutLine[MAX_EXP_LINE_LEN]; + + // + // Don't mess up the original file pointer, since we're processing it at a higher + // level. + // + DSCFileSavePosition (DSCFile); + Sect = DSCFileFindSection (DSCFile, SectionName); + if (Sect != NULL) { + // + // Read lines, expand, then dump out + // + while (DSCFileGetLine (DSCFile, InLine, sizeof (InLine)) != NULL) { + ExpandSymbols ( + InLine, + OutLine, + sizeof(OutLine), + EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR + ); + fprintf (MakeFptr, OutLine); + } + } else { + Warning ( + NULL, + 0, + 0, + GetSymbolValue (INF_FILENAME), + "no [%s] build commands found in DSC file for component", + SectionName + ); + } + + DSCFileRestorePosition (DSCFile); + return STATUS_SUCCESS; +} + +/***************************************************************************** + +******************************************************************************/ +static +int +WriteCompileCommands ( + DSC_FILE *DscFile, + FILE *MakeFptr, + INT8 *FileName, + INT8 *Processor + ) +{ + FILE_NAME_PARTS *File; + SECTION *Sect; + INT8 BuildSectionName[40]; + INT8 InLine[MAX_LINE_LEN]; + INT8 OutLine[MAX_EXP_LINE_LEN]; + INT8 *SourceCompileType; + char *CPtr; + char *CPtr2; + // + // Determine the filename, then chop it up into its parts + // + File = GetFileParts (FileName); + if (File != NULL) { + // + // Don't mess up the original file pointer, since we're processing it at a higher + // level. + // + DSCFileSavePosition (DscFile); + // + // Option 1: SOURCE_COMPILE_TYPE=MyCompileSection + // Find a section of that name from which to get the compile + // commands for this source file. + // Look for [compile.$(PROCESSOR).$(SOURCE_COMPILE_TYPE] + // Option 2: COMPILE_SELECT=.c=MyCCompile,.asm=MyAsm + // Find a [compile.$(PROCESSOR).MyCompile] section from which to + // get the compile commands for this source file. + // Look for [compile.$(PROCESSOR).MyCompile] + // Option 3: Look for standard section types to compile the file by extension. + // Look for [compile.$(PROCESSOR).] + // + Sect = NULL; + // + // Option 1 - use SOURCE_COMPILE_TYPE variable + // + SourceCompileType = GetSymbolValue (SOURCE_COMPILE_TYPE); + if (SourceCompileType != NULL) { + sprintf (BuildSectionName, "compile.%s.%s", Processor, SourceCompileType); + Sect = DSCFileFindSection (DscFile, BuildSectionName); + } + // + // Option 2 - use COMPILE_SELECT variable + // + if (Sect == NULL) { + SourceCompileType = GetSymbolValue (COMPILE_SELECT); + if (SourceCompileType != NULL) { + // + // Parse the variable, which looks like COMPILE_SELECT=.c=MyCCompiler;.asm=MyAsm; + // to find an entry with a matching file name extension. If you find one, + // then use that name to find the section name. + // + CPtr = SourceCompileType; + while (*CPtr && (Sect == NULL)) { + // + // See if we found a match with this source file name extension. File->Extension + // does not include the dot, so skip the dot in the COMPILE_SELECT variable if there + // is one. + // + if (*CPtr == '.') { + CPtr++; + } + + if (_strnicmp (CPtr, File->Extension, strlen (File->Extension)) == 0) { + // + // Found a file name extension match -- extract the name from the variable, for + // example "MyCCompiler" + // + while (*CPtr && (*CPtr != '=')) { + CPtr++; + } + + if ((*CPtr != '=') || (CPtr[1] == 0)) { + Error (NULL, 0, 0, SourceCompileType, "malformed COMPILE_SELECT variable"); + break; + } + + CPtr++; + sprintf (BuildSectionName, "compile.%s.", Processor); + for (CPtr2 = BuildSectionName + strlen (BuildSectionName); + *CPtr && (*CPtr != ',') && (*CPtr != ';'); + CPtr++ + ) { + *CPtr2 = *CPtr; + CPtr2++; + } + + *CPtr2 = 0; + Sect = DSCFileFindSection (DscFile, BuildSectionName); + if (Sect == NULL) { + ParserError ( + 0, + BuildSectionName, + "could not find section in DSC file - selected by COMPILE_SELECT variable" + ); + } + } + + // + // Skip to next file name extension in the COMPILE_SELECT variable + // + while (*CPtr && (*CPtr != ';') && (*CPtr != ',')) { + CPtr++; + } + + if (*CPtr) { + CPtr++; + } + } + } + } + // + // Option 3 - use "Compile.$(PROCESSOR)." section + // + if (Sect == NULL) { + sprintf (BuildSectionName, "compile.%s.%s", Processor, File->Extension); + Sect = DSCFileFindSection (DscFile, BuildSectionName); + } + // + // Should have found something by now unless it's an include (.h) file + // + if (Sect != NULL) { + // + // Temporarily add a FILE variable to the global symbol table. Omit the + // extension. + // + sprintf (InLine, "%s%s%s", File->Drive, File->Path, File->BaseName); + AddSymbol ("FILE", InLine, SYM_OVERWRITE | SYM_LOCAL | SYM_FILENAME); + // + // Read lines, expand (except SOURCE_DIR and DEST_DIR), then dump out + // + while (DSCFileGetLine (DscFile, InLine, sizeof (InLine)) != NULL) { + ExpandSymbols ( + InLine, + OutLine, + sizeof (OutLine), + EXPANDMODE_NO_DESTDIR | EXPANDMODE_NO_SOURCEDIR + ); + fprintf (MakeFptr, OutLine); + } + fprintf (MakeFptr, "\n"); + } else { + // + // Be nice and ignore include files + // + if (!IsIncludeFile (FileName)) { + Error ( + NULL, + 0, + 0, + NULL, + "no compile commands section [%s] found in DSC file for %s", + BuildSectionName, + FileName + ); + } + } + + DSCFileRestorePosition (DscFile); + FreeFileParts (File); + } + + return STATUS_SUCCESS; +} + +/***************************************************************************** +******************************************************************************/ +static +int +SetFileExtension ( + INT8 *FileName, + INT8 *Extension + ) +{ + INT8 *Cptr; + + Cptr = FileName + strlen (FileName) - 1; + while ((Cptr > FileName) && (*Cptr != '.')) { + Cptr--; + + } + // + // Better be a dot + // + if (*Cptr != '.') { + Message (2, "Missing filename extension: %s", FileName); + return STATUS_WARNING; + } + + Cptr++; + if (*Extension == '.') { + Extension++; + } + + strcpy (Cptr, Extension); + return STATUS_SUCCESS; +} + +/***************************************************************************** +******************************************************************************/ +int +MakeFilePath ( + INT8 *FileName + ) +{ + INT8 *Cptr; + INT8 SavedChar; + INT8 BuildDir[MAX_PATH]; + INT8 CopyFileName[MAX_PATH]; + + // + // Expand symbols in the filename + // + if (ExpandSymbols (FileName, CopyFileName, sizeof (CopyFileName), EXPANDMODE_NO_UNDEFS)) { + Error (NULL, 0, 0, NULL, "undefined symbols in file path: %s", FileName); + return STATUS_ERROR; + } + // + // Copy it back + // + strcpy (FileName, CopyFileName); + // + // To avoid creating $(BUILD_DIR) path, see if this path is the same as + // $(BUILD_DIR), and if it is, see if build dir exists and skip over that + // portion if it does + // + Cptr = GetSymbolValue (BUILD_DIR); + if (Cptr != NULL) { + if (_strnicmp (Cptr, FileName, strlen (Cptr)) == 0) { + // + // BUILD_DIR path. See if it exists + // + strcpy (BuildDir, FileName); + BuildDir[strlen (Cptr)] = 0; + if ((_mkdir (BuildDir) != 0) && (errno != EEXIST)) { + Cptr = FileName; + } else { + // + // Already done. Shortcut. Skip to next path so that we don't create + // the BUILD_DIR as well. + // + Cptr = FileName + strlen (Cptr); + if (*Cptr == '\\') { + Cptr++; + } + } + } else { + // + // Not build dir + // + Cptr = FileName; + } + } else { + Cptr = FileName; + } + // + // Create directories until done. Skip over "c:\" in the path if it exists + // + if (*Cptr && (*(Cptr + 1) == ':') && (*(Cptr + 2) == '\\')) { + Cptr += 3; + } + + for (;;) { + for (; *Cptr && (*Cptr != '/') && (*Cptr != '\\'); Cptr++) + ; + if (*Cptr) { + SavedChar = *Cptr; + *Cptr = 0; + if ((_mkdir (FileName) != 0)) { + // + // Error (NULL, 0, 0, FileName, "failed to create directory"); + // return 1; + // + } + + *Cptr = SavedChar; + Cptr++; + } else { + break; + } + } + + return STATUS_SUCCESS; +} + +/***************************************************************************** +******************************************************************************/ +int +ExpandSymbols ( + INT8 *SourceLine, + INT8 *DestLine, + int LineLen, + int ExpandMode + ) +{ + static int NestDepth = 0; + INT8 *FromPtr; + INT8 *ToPtr; + INT8 *SaveStart; + INT8 *Cptr; + INT8 *value; + int Expanded; + int ExpandedCount; + INT8 *LocalDestLine; + STATUS Status; + int LocalLineLen; + + NestDepth++; + Status = STATUS_SUCCESS; + LocalDestLine = (INT8 *) malloc (LineLen); + if (LocalDestLine == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed"); + NestDepth = 0; + return STATUS_ERROR; + } + + FromPtr = SourceLine; + ToPtr = LocalDestLine; + // + // Walk the entire line, replacing $(SYMBOL_NAME). + // + LocalLineLen = LineLen; + ExpandedCount = 0; + while (*FromPtr && (LocalLineLen > 0)) { + if ((*FromPtr == '$') && (*(FromPtr + 1) == '(')) { + // + // Save the start in case it's undefined, in which case we copy it as-is. + // + SaveStart = FromPtr; + Expanded = 0; + // + // Symbol expansion time. Find the end (no spaces allowed) + // + FromPtr += 2; + for (Cptr = FromPtr; *Cptr && (*Cptr != ')'); Cptr++) + ; + if (*Cptr) { + // + // Truncate the string at the closing parenthesis for ease-of-use. + // Then copy the string directly to the destination line in case we don't find + // a definition for it. + // + *Cptr = 0; + strcpy (ToPtr, SaveStart); + if ((_stricmp (SOURCE_DIR, FromPtr) == 0) && (ExpandMode & EXPANDMODE_NO_SOURCEDIR)) { + // + // excluded this expansion + // + } else if ((_stricmp (DEST_DIR, FromPtr) == 0) && (ExpandMode & EXPANDMODE_NO_DESTDIR)) { + // + // excluded this expansion + // + } else if ((value = GetSymbolValue (FromPtr)) != NULL) { + strcpy (ToPtr, value); + LocalLineLen -= strlen (value); + ToPtr += strlen (value); + Expanded = 1; + ExpandedCount++; + } else if (ExpandMode & EXPANDMODE_NO_UNDEFS) { + Error (NULL, 0, 0, "undefined symbol", "$(%s)", FromPtr); + Status = STATUS_ERROR; + goto Done; + } + + // + // Restore closing parenthesis, and advance to next character + // + *Cptr = ')'; + if (!Expanded) { + FromPtr = SaveStart + 1; + ToPtr++; + } else { + FromPtr = Cptr + 1; + } + } else { + Error (NULL, 0, 0, SourceLine, "missing closing parenthesis on symbol"); + strcpy (ToPtr, FromPtr); + Status = STATUS_WARNING; + goto Done; + } + } else { + *ToPtr = *FromPtr; + FromPtr++; + ToPtr++; + LocalLineLen--; + } + } + + if (*FromPtr == 0) { + *ToPtr = 0; + } + + // + // If we're in recursive mode, and we expanded at least one string successfully, + // then make a recursive call to try again. + // + if ((ExpandedCount != 0) && (Status == STATUS_SUCCESS) && (ExpandMode & EXPANDMODE_RECURSIVE) && (NestDepth < 2)) { + Status = ExpandSymbols (LocalDestLine, DestLine, LineLen, ExpandMode); + free (LocalDestLine); + NestDepth = 0; + return Status; + } + +Done: + if (Status != STATUS_ERROR) { + strcpy (DestLine, LocalDestLine); + } + + NestDepth = 0; + free (LocalDestLine); + return Status; +} + +INT8 * +GetSymbolValue ( + INT8 *SymbolName + ) +/*++ + +Routine Description: + + Look up a symbol in our symbol table. + +Arguments: + + SymbolName - The name of symbol. + +Returns: + + Pointer to the value of the symbol if found + NULL if the symbol is not found + +--*/ +{ + SYMBOL *Symbol; + + // + // Scan once for file-level symbols + // + Symbol = gGlobals.Symbol; + while (Symbol) { + if ((_stricmp (SymbolName, Symbol->Name) == 0) && (Symbol->Type & SYM_FILE)) { + return Symbol->Value; + } + + Symbol = Symbol->Next; + } + // + // Scan once for local symbols + // + Symbol = gGlobals.Symbol; + while (Symbol) { + if ((_stricmp (SymbolName, Symbol->Name) == 0) && (Symbol->Type & SYM_LOCAL)) { + return Symbol->Value; + } + + Symbol = Symbol->Next; + } + // + // No local value found. Scan for globals. + // + Symbol = gGlobals.Symbol; + while (Symbol) { + if ((_stricmp (SymbolName, Symbol->Name) == 0) && (Symbol->Type & SYM_GLOBAL)) { + return Symbol->Value; + } + + Symbol = Symbol->Next; + } + // + // For backwards-compatibility, if it's "GUID", return FILE_GUID value + // + if (_stricmp (SymbolName, GUID) == 0) { + return GetSymbolValue (FILE_GUID); + } + + return NULL; +} + +static +int +RemoveLocalSymbols ( + VOID + ) +/*++ + +Routine Description: + + Remove all local symbols from the symbol table. Local symbols are those + that are defined typically by the component's INF file. + +Arguments: + + None. + +Returns: + + Right now, never fails. + +--*/ +{ + SYMBOL *Sym; + int FoundOne; + + do { + FoundOne = 0; + Sym = gGlobals.Symbol; + while (Sym) { + if (Sym->Type & SYM_LOCAL) { + // + // Going to delete it out from under ourselves, so break and restart + // + FoundOne = 1; + RemoveSymbol (Sym->Name, SYM_LOCAL); + break; + } + + Sym = Sym->Next; + } + } while (FoundOne); + return STATUS_SUCCESS; +} + +static +int +RemoveFileSymbols ( + VOID + ) +/*++ + +Routine Description: + + Remove all file-level symbols from the symbol table. File-level symbols are + those that are defined on a source file line in an INF file. + +Arguments: + + None. + +Returns: + + Right now, never fails. + +--*/ +{ + SYMBOL *Sym; + int FoundOne; + + do { + FoundOne = 0; + Sym = gGlobals.Symbol; + while (Sym) { + if (Sym->Type & SYM_FILE) { + // + // Going to delete it out from under ourselves, so break and restart + // + FoundOne = 1; + RemoveSymbol (Sym->Name, SYM_FILE); + break; + } + + Sym = Sym->Next; + } + } while (FoundOne); + return STATUS_SUCCESS; +} + +static +STATUS +ParseGuidDatabaseFile ( + INT8 *FileName + ) +/*++ + +Routine Description: + This function parses a GUID-to-basename text file (perhaps output by + the GuidChk utility) to define additional symbols. The format of the + file should be: + + 7BB28B99-61BB-11D5-9A5D-0090273FC14D EFI_DEFAULT_BMP_LOGO_GUID gEfiDefaultBmpLogoGuid + + This function parses the line and defines global symbol: + + EFI_DEFAULT_BMP_LOGO_GUID=7BB28B99-61BB-11D5-9A5D-0090273FC14D + + This symbol (rather than the actual GUID) can then be used in INF files to + fix duplicate GUIDs + +Arguments: + FileName - the name of the file to parse. + +Returns: + STATUS_ERROR - could not open FileName + STATUS_SUCCESS - we opened the file + +--*/ +{ + FILE *Fptr; + INT8 Line[100]; + INT8 Guid[100]; + INT8 DefineName[80]; + + Fptr = fopen (FileName, "r"); + if (Fptr == NULL) { + Error (NULL, 0, 0, FileName, "failed to open input GUID database input file"); + return STATUS_ERROR; + } + + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + // + // Get the GUID string, skip the defined name (EFI_XXX_GUID), and get the + // variable name (gWhateverProtocolGuid) + // + if (sscanf (Line, "%s %s %*s", Guid, DefineName) == 2) { + AddSymbol (DefineName, Guid, SYM_GLOBAL); + } + } + + fclose (Fptr); + return STATUS_SUCCESS; +} + +/***************************************************************************** + + Returns: + 0 if successful standard add + length of the parsed string if passed in " name = value " + < 0 on error + +******************************************************************************/ +int +AddSymbol ( + INT8 *Name, + INT8 *Value, + int Mode + ) +{ + SYMBOL *Symbol; + SYMBOL *NewSymbol; + int Len; + INT8 *Start; + INT8 *Cptr; + INT8 CSave1; + INT8 *SaveCptr1; + INT8 CSave2; + INT8 *SaveCptr2; + INT8 ShortName[MAX_PATH]; + + Len = 0; + SaveCptr1 = NULL; + CSave1 = 0; + SaveCptr2 = NULL; + CSave2 = 0; + + ShortName[0] = 0; + // + // Mode better be local or global symbol + // + if ((Mode & (SYM_LOCAL | SYM_GLOBAL | SYM_FILE)) == 0) { + Error (NULL, 0, 0, "APP ERROR", "adding symbol '%s' that is not local, global, nor file level", Name); + return -1; + } + // + // If value pointer is null, then they passed us a line something like: + // varname = value, or simply var = + // + if (Value == NULL) { + Start = Name; + while (*Name && isspace (*Name)) { + Name++; + + } + + if (!*Name) { + return -1; + } + // + // Find the end of the name. Either space or a '='. + // + for (Value = Name; *Value && !isspace (*Value) && (*Value != '='); Value++) + ; + if (!*Value) { + return -1; + } + // + // Look for the '=' + // + Cptr = Value; + while (*Value && (*Value != '=')) { + Value++; + } + + if (!*Value) { + return -1; + } + + // + // Now truncate the name + // + CSave1 = *Cptr; + SaveCptr1 = Cptr; + *Cptr = 0; + + // + // Skip over the = and then any spaces + // + Value++; + while (*Value && isspace (*Value)) { + Value++; + + } + // + // Find end of string, checking for quoted string + // + if (*Value == '\"') { + Value++; + for (Cptr = Value; *Cptr && *Cptr != '\"'; Cptr++) + ; + } else { + for (Cptr = Value; *Cptr && !isspace (*Cptr); Cptr++) + ; + } + // + // Null terminate the value string + // + if (*Cptr) { + Len = (int) (Cptr - Start) + 1; + CSave2 = *Cptr; + SaveCptr2 = Cptr; + *Cptr = 0; + } else { + Len = (int) (Cptr - Start); + } + } + + // + // If file name or file path, and we're shortening, then print it + // + if ((Mode & (SYM_FILEPATH | SYM_FILENAME)) && (GetSymbolValue (SHORT_NAMES) != NULL)) { + if (GetShortPathName (Value, ShortName, sizeof (ShortName)) > 0) { + // + // fprintf (stdout, "String value '%s' shortened to '%s'\n", + // Value, ShortName); + // + Value = ShortName; + } else { + // + // fprintf (stdout, "WARNING: Failed to get short name for %s\n", Value); + // + } + } + // + // We now have a symbol name and a value. Look for an existing variable of + // the same type (global or local) and overwrite it. + // + Symbol = gGlobals.Symbol; + while (Symbol) { + // + // Check for symbol name match + // + if (_stricmp (Name, Symbol->Name) == 0) { + // + // See if this symbol is of the same type (global or local) as what + // they're requesting + // + if ((Symbol->Type & (SYM_LOCAL | SYM_GLOBAL)) == (Mode & (SYM_LOCAL | SYM_GLOBAL))) { + // + // Did they say we could overwrite it? + // + if (Mode & SYM_OVERWRITE) { + free (Symbol->Value); + Symbol->Value = (INT8 *) malloc (strlen (Value) + 1); + if (Symbol->Value == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return -1; + } + + strcpy (Symbol->Value, Value); + // + // If value == "NULL", then make it a 0-length string + // + if (_stricmp (Symbol->Value, "NULL") == 0) { + Symbol->Value[0] = 0; + } + + return Len; + } else { + return STATUS_ERROR; + } + } + } + + Symbol = Symbol->Next; + } + // + // Does not exist, create a new one + // + NewSymbol = (SYMBOL *) malloc (sizeof (SYMBOL)); + if (NewSymbol == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return -1; + } + + memset ((INT8 *) NewSymbol, 0, sizeof (SYMBOL)); + NewSymbol->Name = (INT8 *) malloc (strlen (Name) + 1); + NewSymbol->Value = (INT8 *) malloc (strlen (Value) + 1); + // + // Simply use the mode bits as the type. + // + NewSymbol->Type = Mode; + if ((NewSymbol->Name == NULL) || (NewSymbol->Value == NULL)) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return -1; + } + + strcpy (NewSymbol->Name, Name); + strcpy (NewSymbol->Value, Value); + // + // Remove trailing spaces + // + Cptr = NewSymbol->Value + strlen (NewSymbol->Value) - 1; + while (Cptr > NewSymbol->Value) { + if (isspace (*Cptr)) { + *Cptr = 0; + Cptr--; + } else { + break; + } + } + // + // Add it to the head of the list. + // + NewSymbol->Next = gGlobals.Symbol; + gGlobals.Symbol = NewSymbol; + // + // If value == "NULL", then make it a 0-length string + // + if (_stricmp (NewSymbol->Value, "NULL") == 0) { + NewSymbol->Value[0] = 0; + } + // + // Restore the terminator we inserted if they passed in var=value + // + if (SaveCptr1 != NULL) { + *SaveCptr1 = CSave1; + } + if (SaveCptr2 != NULL) { + *SaveCptr2 = CSave2; + } + + return Len; +} + +/***************************************************************************** +******************************************************************************/ +static +int +RemoveSymbol ( + INT8 *Name, + INT8 SymbolType + ) +{ + SYMBOL *Symbol; + SYMBOL *PrevSymbol; + + PrevSymbol = NULL; + Symbol = gGlobals.Symbol; + while (Symbol) { + if ((_stricmp (Name, Symbol->Name) == 0) && (Symbol->Type & SymbolType)) { + if (Symbol->Value) { + free (Symbol->Value); + } + + free (Symbol->Name); + if (PrevSymbol) { + PrevSymbol->Next = Symbol->Next; + } else { + gGlobals.Symbol = Symbol->Next; + } + + free (Symbol); + return STATUS_SUCCESS; + } + + PrevSymbol = Symbol; + Symbol = Symbol->Next; + } + + return STATUS_WARNING; +} + +#if 0 + +/***************************************************************************** +******************************************************************************/ +static +void +FreeSections ( + SECTION *Sect + ) +{ + SECTION *Next; + + while (Sect != NULL) { + Next = Sect->Next; + if (Sect->Name != NULL) { + delete[] Sect->Name; + } + + delete Sect; + Sect = Next; + } +} +#endif + +/***************************************************************************** +******************************************************************************/ +static +INT8 * +StripLine ( + INT8 *Line + ) +{ + INT8 *Cptr; + int Len; + + Cptr = Line; + // + // Look for '#' comments in first character of line + // + if (*Cptr == '#') { + *Cptr = 0; + return Cptr; + } + + while (isspace (*Cptr)) { + Cptr++; + } + // + // Hack off newlines + // + Len = strlen (Cptr); + if ((Len > 0) && (Cptr[Len - 1] == '\n')) { + Cptr[Len - 1] = 0; + } + // + // Hack off trailing spaces + // + StripTrailingSpaces (Cptr); + return Cptr; +} + +/***************************************************************************** + FUNCTION: ProcessOptions() + + DESCRIPTION: Process the command-line options. +******************************************************************************/ +static +int +ProcessOptions ( + int Argc, + INT8 *Argv[] + ) +/*++ + +Routine Description: + + Process the command line options to this utility. + +Arguments: + + Argc - Standard Argc. + Argv[] - Standard Argv. + +Returns: + +--*/ +{ + INT8 *Cptr; + int FreeCwd; + + // + // Clear out the options + // + memset ((INT8 *) &gGlobals, 0, sizeof (gGlobals)); + + Argc--; + Argv++; + + if (Argc == 0) { + Usage (); + return STATUS_ERROR; + } + // + // Now process the arguments + // + while (Argc > 0) { + + if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) { + switch (Argv[0][1]) { + // + // -? or -h help option + // + case '?': + case 'h': + case 'H': + Usage (); + return STATUS_ERROR; + + // + // /d symbol=name + // + case 'd': + case 'D': + // + // Skip to next arg + // + Argc--; + Argv++; + if (Argc == 0) { + Argv--; + Error (NULL, 0, 0, NULL, "missing symbol definition with %c%c", Argv[0][0], Argv[0][1]); + return STATUS_ERROR; + } else { + if (AddSymbol (Argv[0], NULL, SYM_OVERWRITE | SYM_GLOBAL) <= 0) { + Warning (NULL, 0, 0, Argv[0], "failed to add symbol: %s"); + } + } + break; + + // + // output makefile name + // + case 'm': + case 'M': + // + // Skip to next arg + // + Argc--; + Argv++; + if (Argc == 0) { + Argv--; + Error (NULL, 0, 0, Argv[0], "missing output makefile name with option"); + Usage (); + return STATUS_ERROR; + } else { + strcpy (gGlobals.MakefileName, Argv[0]); + } + break; + + // + // Print a cross-reference file containing guid/basename/processor + // + case 'x': + case 'X': + // + // Skip to next arg + // + Argc--; + Argv++; + if (Argc == 0) { + Argv--; + Error (NULL, 0, 0, Argv[0], "missing cross-reference output filename with option"); + Usage (); + return STATUS_ERROR; + } else { + strcpy (gGlobals.XRefFileName, Argv[0]); + } + break; + + // + // GUID database file to preparse + // + case 'g': + case 'G': + // + // Skip to next arg + // + Argc--; + Argv++; + if (Argc == 0) { + Argv--; + Error (NULL, 0, 0, Argv[0], "missing input GUID database filename with option"); + Usage (); + return STATUS_ERROR; + } else { + strcpy (gGlobals.GuidDatabaseFileName, Argv[0]); + } + break; + + case 'v': + case 'V': + gGlobals.Verbose = 1; + break; + + default: + Error (NULL, 0, 0, Argv[0], "unrecognized option"); + return STATUS_ERROR; + } + } else { + break; + } + + Argc--; + Argv++; + } + // + // Must be at least one arg left + // + if (Argc > 0) { + gGlobals.DscFilename = Argv[0]; + } + + if (gGlobals.DscFilename == NULL) { + Error (NULL, 0, 0, NULL, "must specify DSC filename on command line"); + return STATUS_ERROR; + } + // + // Make a global symbol for the DSC filename + // + AddSymbol (DSC_FILENAME, gGlobals.DscFilename, SYM_GLOBAL | SYM_FILENAME); + // + // If no output makefile specified, take the default + // + if (gGlobals.MakefileName[0] == 0) { + strcpy (gGlobals.MakefileName, MAKEFILE_OUT_NAME); + } + // + // Get the current working directory and use it for the build directory. + // Only do this if they have not defined it on the command line. Do the + // same for the bin dir, output dir, and library directory. + // + Cptr = GetSymbolValue (BUILD_DIR); + if (Cptr == NULL) { + Cptr = _getcwd (NULL, 0); + FreeCwd = 1; + AddSymbol (BUILD_DIR, Cptr, SYM_OVERWRITE | SYM_GLOBAL | SYM_FILEPATH); + } else { + FreeCwd = 0; + } + + if (FreeCwd) { + free (Cptr); + } + + return 0; +} + +/***************************************************************************** +******************************************************************************/ +static +SYMBOL * +FreeSymbols ( + SYMBOL *Syms + ) +{ + SYMBOL *Next; + while (Syms) { + + if (Syms->Name != NULL) { + free (Syms->Name); + } + + if (Syms->Value != NULL) { + free (Syms->Value); + } + + Next = Syms->Next; + free (Syms); + Syms = Next; + } + + return Syms; +} + +/***************************************************************************** +******************************************************************************/ +static +int +GetSourceFileType ( + INT8 *FileName + ) +{ + INT8 *Cptr; + int len; + int i; + + len = strlen (FileName); + if (len == 0) { + return FILETYPE_UNKNOWN; + + } + + Cptr = FileName + len - 1; + while ((*Cptr != '.') && (Cptr >= FileName)) { + Cptr--; + + } + + if (*Cptr == '.') { + + for (i = 0; mFileTypes[i].Extension != NULL; i++) { + len = strlen (mFileTypes[i].Extension); + if (_strnicmp (mFileTypes[i].Extension, Cptr, len) == 0) { + if ((*(Cptr + len) == 0) || isspace (*(Cptr + len))) { + return mFileTypes[i].FileType; + } + } + } + } + + return FILETYPE_UNKNOWN; +} +// +// Determine if a given file is a standard include file. If we don't know, +// then assume it's not. +// +static +int +IsIncludeFile ( + INT8 *FileName + ) +{ + INT8 *Cptr; + int len; + int i; + + len = strlen (FileName); + if (len == 0) { + return 0; + } + + Cptr = FileName + len - 1; + while ((*Cptr != '.') && (Cptr >= FileName)) { + Cptr--; + } + + if (*Cptr == '.') { + // + // Now go through the list of filename extensions and try to find + // a match for this file extension. + // + for (i = 0; mFileTypes[i].Extension != NULL; i++) { + len = strlen (mFileTypes[i].Extension); + if (_strnicmp (mFileTypes[i].Extension, Cptr, len) == 0) { + // + // Make sure that's all there is to the filename extension. + // + if ((*(Cptr + len) == 0) || isspace (*(Cptr + len))) { + return mFileTypes[i].FileFlags & FILE_FLAG_INCLUDE; + } + } + } + } + + return 0; +} + +/***************************************************************************** +******************************************************************************/ +static +void +StripTrailingSpaces ( + INT8 *Str + ) +{ + INT8 *Cptr; + Cptr = Str + strlen (Str) - 1; + while (Cptr > Str) { + if (isspace (*Cptr)) { + *Cptr = 0; + Cptr--; + } else { + break; + } + } +} + +/***************************************************************************** +******************************************************************************/ +static +int +GetEfiSource ( + VOID + ) +{ + INT8 *EfiSource; + + // + // Don't set it if the user specified it on the command line. + // + EfiSource = GetSymbolValue (EFI_SOURCE); + if ( EfiSource != NULL) { + if (EfiSource[strlen (EfiSource) - 1] == '\\') { + EfiSource[strlen (EfiSource) - 1] = 0; + } + return STATUS_SUCCESS; + } + + // + // Get the environmental variable setting of EFI_SOURCE. + // + EfiSource = getenv (EFI_SOURCE); + if (EfiSource != NULL) { + if (EfiSource[strlen (EfiSource) - 1] == '\\') { + EfiSource[strlen (EfiSource) - 1] = 0; + } + AddSymbol (EFI_SOURCE, EfiSource, SYM_GLOBAL | SYM_FILEPATH); + return STATUS_SUCCESS; + } + + Error (NULL, 0, 0, NULL, "could not determine EFI_SOURCE"); + return STATUS_ERROR; +} + +void +Message ( + UINT32 PrintMask, + INT8 *Fmt, + ... + ) +{ + INT8 Line[MAX_LINE_LEN]; + va_list List; + + va_start (List, Fmt); + vsprintf (Line, Fmt, List); + if (PrintMask & gGlobals.Verbose) { + fprintf (stdout, "%s\n", Line); + } + + va_end (List); +} + +static +void +Usage ( + VOID + ) +{ + int i; + static const INT8 *Help[] = { + "Usage: ProcessDsc {options} [Dsc Filename]", + " Options:", + " -d var=value to define symbol 'var' to 'value'", + " -v for verbose mode", + " -g filename to preparse GUID listing file", + " -x filename to create a cross-reference file", + NULL + }; + for (i = 0; Help[i] != NULL; i++) { + fprintf (stdout, "%s\n", Help[i]); + } +} + +/*++ + +Routine Description: + + Process the [defines] section in the DSC file. + +Arguments: + + DscFile - pointer to the DSCFile class that contains the relevant info. + +Returns: + + 0 if not necessarily an absolute path + 1 otherwise + +--*/ +static +int +ProcessDSCDefinesSection ( + DSC_FILE *DscFile + ) +{ + INT8 Line[MAX_LINE_LEN]; + INT8 Line2[MAX_EXP_LINE_LEN]; + INT8 *Cptr; + SECTION *Sect; + + // + // Look for a [defines] section and process it + // + Sect = DSCFileFindSection (DscFile, DEFINES_SECTION_NAME); + if (Sect == NULL) { + return STATUS_ERROR; + } + // + // Read lines while they're valid + // + while (DSCFileGetLine (DscFile, Line, sizeof (Line)) != NULL) { + // + // Expand symbols on the line + // + if (ExpandSymbols (Line, Line2, sizeof (Line2), 0)) { + return STATUS_ERROR; + } + // + // Strip the line + // + Cptr = StripLine (Line2); + if (*Cptr) { + // + // Make the assignment + // + AddSymbol (Line2, NULL, SYM_OVERWRITE | SYM_GLOBAL); + } + } + + return STATUS_SUCCESS; +} + +int +IsAbsolutePath ( + char *FileName + ) +/*++ + +Routine Description: + + Determine if a given filename contains the full path information. + +Arguments: + + FileName - the name of the file, with symbol expanded. + +Returns: + + 0 if not necessarily an absolute path + 1 otherwise + +--*/ +{ + // + // If the first character is a-z, and the second character is a colon, then + // it is an absolute path. + // + if (isalpha (FileName[0]) && (FileName[1] == ':')) { + return 1; + } + + return 0; +} + +SMART_FILE * +SmartOpen ( + char *FileName + ) +{ + SMART_FILE *SmartFile; + FILE *Fptr; + int FileSize; + + SmartFile = malloc (sizeof (SMART_FILE)); + if (SmartFile == NULL) { + return NULL; + } + memset (SmartFile, 0, sizeof (SMART_FILE)); + + SmartFile->FileName = malloc (strlen (FileName) + 1); + if (SmartFile->FileName == NULL){ + SmartFree (SmartFile); + return NULL; + } + strcpy (SmartFile->FileName, FileName); + + if ((Fptr = fopen (FileName, "r")) != NULL) { + fseek (Fptr, 0, SEEK_END); + FileSize = ftell (Fptr); + fseek (Fptr, 0, SEEK_SET); + SmartFile->FileContent = malloc (FileSize + 1); + if (SmartFile->FileContent != NULL) { + memset (SmartFile->FileContent, 0, FileSize + 1); + // + // Usually FileLength < FileSize, because in text mode, carriage return¨Clinefeed + // combinations are translated into single linefeeds on input + // + SmartFile->FileLength = fread (SmartFile->FileContent, sizeof(char), FileSize, Fptr); + } + fclose (Fptr); + } + + // + // No previous output file content, re-create the file + // + if (SmartFile->FileContent == NULL) { + if ((SmartFile->FilePtr = fopen (FileName, "w")) == NULL) { + SmartFree (SmartFile); + return NULL; + } + } + + return SmartFile; +} + +int +SmartWrite ( + SMART_FILE *SmartFile, + char *String + ) +{ + int StrLen; + + if (SmartFile->FilePtr != NULL) { + return fprintf (SmartFile->FilePtr, "%s", String); + } else { + StrLen = strlen (String); + if ((StrLen > SmartFile->FileLength - SmartFile->FilePosition) || + (_strnicmp (&SmartFile->FileContent[SmartFile->FilePosition], String, StrLen) != 0)) { + // + // file changed, need to re-create. + // + if ((SmartFile->FilePtr = fopen (SmartFile->FileName, "w")) == NULL) { + Error (NULL, 0, 0, SmartFile->FileName, "could not open file for writing when SmartWrite"); + return -1; + } else { + SmartFile->FileContent[SmartFile->FilePosition] = 0; + fprintf (SmartFile->FilePtr, "%s%s", SmartFile->FileContent, String); + return StrLen; + } + } else { + SmartFile->FilePosition += StrLen; + return StrLen; + } + } +} + +void +SmartClose ( + SMART_FILE *SmartFile + ) +{ + if ((SmartFile->FilePtr == NULL) && (SmartFile->FilePosition < SmartFile->FileLength)) { + // + // The new file is smaller than before, re-create it. + // + if ((SmartFile->FilePtr = fopen (SmartFile->FileName, "w")) == NULL) { + Error (NULL, 0, 0, SmartFile->FileName, "could not open file for writing when SmartClose"); + } else { + SmartFile->FileContent[SmartFile->FilePosition] = 0; + fprintf (SmartFile->FilePtr, "%s", SmartFile->FileContent); + } + } + + SmartFree(SmartFile); +} + +static +void +SmartFree ( + SMART_FILE *SmartFile + ) +{ + if (SmartFile == NULL) { + return; + } + + if (SmartFile->FileName != NULL ) { + free (SmartFile->FileName); + } + + if (SmartFile->FileContent != NULL ) { + free (SmartFile->FileContent); + } + + if (SmartFile->FilePtr != NULL ) { + fclose (SmartFile->FilePtr); + } + + free (SmartFile); + + return; +} + +static +int +AddModuleName ( + SYMBOL **SymbolList, + INT8 *ModuleName, + INT8 *InfName + ) +/*++ + +Routine Description: + + Add module name in the global module list. + For the same module names, it is only added once. + +Arguments: + SymbolList : add name into this list + ModuleName : point to one module name char string. + InfName : point to this module inf file name with path. + +Returns: + + 0 : Successfully add input name into the global list. + other value : allocate memory failed. + +--*/ +{ + SYMBOL *CurrentSymbol; + SYMBOL *LastSymbol; + + // + // Get the global module list. + // + CurrentSymbol = *SymbolList; + LastSymbol = *SymbolList; + + // + // Search whether this module name has been added into the global list. + // + while (CurrentSymbol != NULL) { + if (_stricmp (CurrentSymbol->Name, ModuleName) == 0) { + if ((CurrentSymbol->Value == NULL) && (InfName == NULL)) { + break; + } else if ((CurrentSymbol->Value != NULL) && (InfName != NULL) && \ + (_stricmp (CurrentSymbol->Value, InfName) == 0)) { + break; + } + } + LastSymbol = CurrentSymbol; + CurrentSymbol = CurrentSymbol->Next; + } + + // + // Add new module name in list. + // + if (CurrentSymbol == NULL) { + CurrentSymbol = (SYMBOL *) malloc (sizeof (SYMBOL)); + if (CurrentSymbol == NULL) { + Error (NULL, 0, 0, NULL, "failed to allocate memory"); + return -1; + } + memset ((INT8 *) CurrentSymbol, 0, sizeof (SYMBOL)); + + if (ModuleName != NULL) { + CurrentSymbol->Name = (INT8 *) malloc (strlen (ModuleName) + 1); + strcpy (CurrentSymbol->Name, ModuleName); + } + + if (InfName != NULL) { + CurrentSymbol->Value = (INT8 *) malloc (strlen (InfName) + 1); + strcpy (CurrentSymbol->Value, InfName); + } + + if (LastSymbol == NULL) { + *SymbolList = CurrentSymbol; + } else { + LastSymbol->Next = CurrentSymbol; + } + } + + return 0; +} + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/Makefile new file mode 100644 index 0000000000..39750fb441 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/Makefile @@ -0,0 +1,88 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=SetStamp +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\SetStamp.c" +TARGET_EXE_INCLUDE = +OBJECTS = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c new file mode 100644 index 0000000000..539aced1d9 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c @@ -0,0 +1,475 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + SetStamp.c + +Abstract: + Set Date/Time Stamp of Portable Executable (PE) format file + +--*/ + +#include +#include +#include + +#define LINE_MAXLEN 80 + +void +PrintUsage ( + void + ) +/*++ +Routine Description: + print usage of setstamp command + +Arguments: + void + +Returns: + None +--*/ +{ + // + // print usage of command + // + printf ("Usage: SetStamp \n"); +} + +int +GetDateTime ( + FILE *fp, + time_t *ltime + ) +/*++ +Routine Description: + Read the date and time from TIME file. If the date/time string is +"NOW NOW", write the current date and time to TIME file and set it to +ltime. Else, set the date and time of TIME file to ltime. + +Arguments: + fp - The pointer of TIME file + ltime - Date and time + +Returns: + = 0 - Success + = -1 - Failed +--*/ +{ + char buffer[LINE_MAXLEN]; + struct tm stime; + struct tm *now; + + if (fgets (buffer, LINE_MAXLEN, fp) == NULL) { + printf ("Error: Cannot read TIME file.\n"); + return -1; + } + // + // compare the value with "NOW NOW", write TIME file if equal + // + if (strncmp (buffer, "NOW NOW", 7) == 0) { + // + // get system current time and date + // + time (ltime); + + now = localtime (ltime); + if (now == NULL) { + printf ("Error: Cannot get local time.\n"); + return -1; + } + + if (strftime (buffer, LINE_MAXLEN, "%Y-%m-%d %H:%M:%S", now) == 0) { + printf ("Error: Cannot format time string.\n"); + return -1; + } + // + // write TIME file + // + if (fseek (fp, 0, SEEK_SET) != 0) { + printf ("Error: Cannot move location of TIME file.\n"); + return -1; + } + + if (fputs (buffer, fp) == EOF) { + printf ("Error: Cannot write time string to TIME file.\n"); + return -1; + } + // + // ltime has been set as current time and date, return + // + return 0; + } + // + // get the date and time from buffer + // + if (6 != sscanf ( + buffer, + "%d-%d-%d %d:%d:%d", + &stime.tm_year, + &stime.tm_mon, + &stime.tm_mday, + &stime.tm_hour, + &stime.tm_min, + &stime.tm_sec + )) { + printf ("Error: Invaild date or time!\n"); + return -1; + } + // + // in struct, Month (0 - 11; Jan = 0). So decrease 1 from it + // + stime.tm_mon -= 1; + + // + // in struct, Year (current year minus 1900) + // and only the dates can be handled from Jan 1, 1970 to Jan 18, 2038 + // + // + // convert 0 -> 100 (2000), 1 -> 101 (2001), ..., 38 -> 138 (2038) + // + if (stime.tm_year <= 38) { + stime.tm_year += 100; + } + // + // convert 1970 -> 70, 2000 -> 100, ... + // + else if (stime.tm_year >= 1970) { + stime.tm_year -= 1900; + } + // + // convert the date and time to time_t format + // + *ltime = mktime (&stime); + if (*ltime == (time_t) - 1) { + printf ("Error: Invalid date or time!\n"); + return -1; + } + + return 0; +} + +int +ReadFromFile ( + FILE *fp, + long offset, + void *buffer, + int size + ) +/*++ +Routine Description: + read data from a specified location of file + +Arguments: + fp - file pointer + offset - number of bytes from beginning of file + buffer - buffer used to store data + size - size of buffer + +Returns: + = 0 - Success + = -1 - Failed +--*/ +{ + // + // set file pointer to the specified location of file + // + if (fseek (fp, offset, SEEK_SET) != 0) { + printf ("Error: Cannot move the current location of the file.\n"); + return -1; + } + // + // read data from the file + // + if (fread (buffer, size, 1, fp) != 1) { + printf ("Error: Cannot read data from the file.\n"); + return -1; + } + + return 0; +} + +int +WriteToFile ( + FILE *fp, + long offset, + void *buffer, + int size + ) +/*++ +Routine Description: + write data to a specified location of file + +Arguments: + fp - file pointer + offset - number of bytes from beginning of file + buffer - buffer used to store data + size - size of buffer + +Returns: + = 0 - Success + = -1 - Failed +--*/ +{ + // + // set file pointer to the specified location of file + // + if (fseek (fp, offset, SEEK_SET) != 0) { + printf ("Error: Cannot move the current location of the file.\n"); + return -1; + } + // + // write data to the file + // + if (fwrite (buffer, size, 1, fp) != 1) { + perror ("Error: Cannot write data to the file.\n"); + return -1; + } + + return 0; +} + +int +SetStamp ( + FILE *fp, + time_t ltime + ) +/*++ +Routine Description: + set Date/Time Stamp of the file + +Arguments: + fp - file pointer + ltime - time and date + +Returns: + = 0 - Success + = -1 - Failed +--*/ +{ + unsigned char header[4]; + unsigned long offset; + unsigned long NumberOfRvaAndSizes; + unsigned int nvalue; + unsigned long lvalue; + + // + // read the header of file + // + if (ReadFromFile (fp, 0, header, 2) != 0) { + return -1; + } + // + // "MZ" -- the header of image file (PE) + // + if (strncmp ((char *) header, "MZ", 2) != 0) { + printf ("Error: Invalid Image file.\n"); + return -1; + } + // + // At location 0x3C, the stub has the file offset to the + // PE signature. + // + if (ReadFromFile (fp, 0x3C, &offset, 4) != 0) { + return -1; + } + // + // read the header of optional + // + if (ReadFromFile (fp, offset, header, 4) != 0) { + return -1; + } + // + // "PE\0\0" -- the signature of optional header + // + if (strncmp ((char *) header, "PE\0\0", 4) != 0) { + printf ("Error: Invalid PE format file.\n"); + return -1; + } + // + // Add 8 to skip PE signature (4-byte), Machine (2-byte) and + // NumberOfSection (2-byte) + // + offset += 8; + + if (WriteToFile (fp, offset, <ime, 4) != 0) { + return -1; + } + // + // Add 16 to skip COFF file header, and get to optional header. + // + offset += 16; + + // + // Check the magic field, 0x10B for PE32 and 0x20B for PE32+ + // + if (ReadFromFile (fp, offset, &nvalue, 2) != 0) { + return -1; + } + // + // If this is PE32 image file, offset of NumberOfRvaAndSizes is 92. + // Else it is 108. + // + switch (nvalue & 0xFFFF) { + case 0x10B: + offset += 92; + break; + + case 0x20B: + offset += 108; + break; + + default: + printf ("Error: Sorry! The Magic value is unknown.\n"); + return -1; + } + // + // get the value of NumberOfRvaAndSizes + // + if (ReadFromFile (fp, offset, &NumberOfRvaAndSizes, 4) != 0) { + return -1; + } + // + // Date/time stamp exists in Export Table, Import Table, Resource Table, + // Debug Table and Delay Import Table. And in Import Table and Delay Import + // Table, it will be set when bound. So here only set the date/time stamp + // of Export Table, Resource Table and Debug Table. + // + // + // change date/time stamp of Export Table, the offset of Export Table + // is 4 + 0 * 8 = 4. And the offset of stamp is 4. + // + if (NumberOfRvaAndSizes >= 1) { + if (ReadFromFile (fp, offset + 4, &lvalue, 4) != 0) { + return -1; + } + + if (lvalue != 0) { + if (WriteToFile (fp, lvalue + 4, <ime, 4) != 0) { + return -1; + } + } + } + // + // change date/time stamp of Resource Table, the offset of Resource Table + // is 4 + 2 * 8 = 20. And the offset of stamp is 4. + // + if (NumberOfRvaAndSizes >= 3) { + if (ReadFromFile (fp, offset + 20, &lvalue, 4) != 0) { + return -1; + } + + if (lvalue != 0) { + if (WriteToFile (fp, lvalue + 4, <ime, 4) != 0) { + return -1; + } + } + } + // + // change date/time stamp of Debug Table, offset of Debug Table + // is 4 + 6 * 8 = 52. And the offset of stamp is 4. + // + if (NumberOfRvaAndSizes >= 7) { + if (ReadFromFile (fp, offset + 52, &lvalue, 4) != 0) { + return -1; + } + + if (lvalue != 0) { + if (WriteToFile (fp, lvalue + 4, <ime, 4) != 0) { + return -1; + } + } + // + // change the date/time stamp of Debug Data + // + if (ReadFromFile (fp, lvalue + 24, &lvalue, 4) != 0) { + return -1; + } + // + // get the signature of debug data + // + if (ReadFromFile (fp, lvalue, header, 2) != 0) { + return -1; + } + // + // "NB" - the signature of Debug Data + // Need Review: (From Spec. is "NB05", From .dll is "NB10") + // + if (strncmp ((char *) header, "NB", 2) == 0) { + if (WriteToFile (fp, lvalue + 8, <ime, 4) != 0) { + return -1; + } + } + } + + return 0; +} + +int +main ( + int argc, + char *argv[] + ) +{ + FILE *fp; + time_t ltime; + + // + // check the number of parameters + // + if (argc != 3) { + PrintUsage (); + return -1; + } + // + // open the TIME file, if not exists, return + // + fp = fopen (argv[2], "r+"); + if (fp == NULL) { + return 0; + } + // + // get time and date from file + // + if (GetDateTime (fp, <ime) != 0) { + fclose (fp); + return -1; + } + // + // close the TIME file + // + fclose (fp); + + // + // open the PE file + // + fp = fopen (argv[1], "r+b"); + if (fp == NULL) { + printf ("Error: Cannot open the PE file!\n"); + return -1; + } + // + // set time and date stamp to the PE file + // + if (SetStamp (fp, ltime) != 0) { + fclose (fp); + return -1; + } + + printf ("Set Date/Time Stamp to %s", ctime (<ime)); + + // + // close the PE file + // + fclose (fp); + + return 0; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/Makefile new file mode 100644 index 0000000000..a90e133cec --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/Makefile @@ -0,0 +1,94 @@ +#/*++ +# +# Copyright (c) 2006 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the SplitFile utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=SplitFile +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\SplitFile.c" +TARGET_EXE_INCLUDE = + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tool. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE): $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) /out:$(TARGET_EXE) $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c new file mode 100644 index 0000000000..860093ca4f --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c @@ -0,0 +1,136 @@ +/*++ + +Copyright 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + splitfile.c + +Abstract: + +--*/ + +#include "stdio.h" +#include "string.h" +#include "stdlib.h" + +void +helpmsg ( + void + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + +Returns: + + GC_TODO: add return values + +--*/ +{ + printf ( + "SplitFile Filename Offset\n"" Filename = Input file to split\n"" Offset = offset at which to split file\n" + "\n\n""SplitFile will break a file in two pieces at the requested offset\n" + " outputting Filename1 and Filename2\n" + ); +} + +int +main ( + int argc, + char*argv[] + ) +/*++ + +Routine Description: + + GC_TODO: Add function description + +Arguments: + + argc - GC_TODO: add argument description + argv - GC_TODO: add argument description + +Returns: + + GC_TODO: add return values + +--*/ +{ + FILE *In; + + FILE *Out1; + + FILE *Out2; + char OutName1[512]; + char OutName2[512]; + unsigned long Index; + unsigned long splitpoint; + char CharC; + + if (argc != 3) { + helpmsg (); + return -1; + } + + In = fopen (argv[1], "rb"); + if (In == NULL) { + printf ("Unable to open file \"%s\"\n", argv[1]); + return -1; + } + + strncpy (OutName1, argv[1], 510); + strncpy (OutName2, argv[1], 510); + strcat (OutName1, "1"); + strcat (OutName2, "2"); + + Out1 = fopen (OutName1, "wb"); + if (Out1 == NULL) { + printf ("Unable to open file \"%s\"\n", OutName1); + return -1; + } + + Out2 = fopen (OutName2, "wb"); + if (Out2 == NULL) { + printf ("Unable to open file \"%s\"\n", OutName2); + return -1; + } + + splitpoint = atoi (argv[2]); + + for (Index = 0; Index < splitpoint; Index++) { + CharC = (char) fgetc (In); + if (feof (In)) { + break; + } + + fputc (CharC, Out1); + } + + for (;;) { + CharC = (char) fgetc (In); + if (feof (In)) { + break; + } + + fputc (CharC, Out2); + } + + fclose (In); + fclose (Out1); + fclose (Out2); + + return 0; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/Makefile new file mode 100644 index 0000000000..dce81b0e04 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/Makefile @@ -0,0 +1,89 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Makefile +# +# Abstract: +# +# makefile for building the StrGather utility. +# +#--*/ + +# +# Make sure environmental variable EDK_SOURCE is set +# +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Target specific information +# +TARGET_NAME = StrGather +TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\StrGather.exe + +# +# Build targets +# + +all: $(TARGET_EXE) + + +LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" + +OBJECTS = $(EDK_TOOLS_OUTPUT)\StrGather.obj \ + $(EDK_TOOLS_OUTPUT)\StringDB.obj + +INC_DEPS = $(TARGET_SRC_DIR)\StrGather.h $(TARGET_SRC_DIR)\StringDB.h + +C_FLAGS = $(C_FLAGS) /W4 + +# +# Compile each source file +# +$(EDK_TOOLS_OUTPUT)\StrGather.obj : $(TARGET_SRC_DIR)\StrGather.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(INC_PATHS) $(TARGET_SRC_DIR)\StrGather.c /Fo$@ + +$(EDK_TOOLS_OUTPUT)\StringDB.obj : $(TARGET_SRC_DIR)\StringDB.c $(INC_DEPS) + $(CC) $(C_FLAGS) $(INC_PATHS) $(TARGET_SRC_DIR)\StringDB.c /Fo$@ + +# +# Add Binary Build description for this tools. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) $(LIBS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c new file mode 100644 index 0000000000..107a46306b --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c @@ -0,0 +1,2574 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StrGather.c + +Abstract: + + Parse a strings file and create or add to a string database file. + +--*/ + +#include +#include +#include +#include + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" +#include "StrGather.h" +#include "StringDB.h" + +#define TOOL_VERSION "0.31" + +typedef UINT16 WCHAR; + +#define MAX_PATH 1024 +#define MAX_NEST_DEPTH 20 // just in case we get in an endless loop. +#define MAX_STRING_IDENTIFIER_NAME 100 // number of wchars +#define MAX_LINE_LEN 400 +#define STRING_TOKEN "STRING_TOKEN" +#define DEFAULT_BASE_NAME "BaseName" +// +// Operational modes for this utility +// +#define MODE_UNKNOWN 0 +#define MODE_PARSE 1 +#define MODE_SCAN 2 +#define MODE_DUMP 3 + +// +// We keep a linked list of these for the source files we process +// +typedef struct _SOURCE_FILE { + FILE *Fptr; + WCHAR *FileBuffer; + WCHAR *FileBufferPtr; + UINT32 FileSize; + INT8 FileName[MAX_PATH]; + UINT32 LineNum; + BOOLEAN EndOfFile; + BOOLEAN SkipToHash; + struct _SOURCE_FILE *Previous; + struct _SOURCE_FILE *Next; + WCHAR ControlCharacter; +} SOURCE_FILE; + +#define DEFAULT_CONTROL_CHARACTER UNICODE_SLASH + +// +// Here's all our globals. We need a linked list of include paths, a linked +// list of source files, a linked list of subdirectories (appended to each +// include path when searching), and a couple other fields. +// +static struct { + SOURCE_FILE SourceFiles; + TEXT_STRING_LIST *IncludePaths; // all include paths to search + TEXT_STRING_LIST *LastIncludePath; + TEXT_STRING_LIST *ScanFileName; + TEXT_STRING_LIST *LastScanFileName; + TEXT_STRING_LIST *SkipExt; // if -skipext .uni + TEXT_STRING_LIST *LastSkipExt; + TEXT_STRING_LIST *IndirectionFileName; + TEXT_STRING_LIST *LastIndirectionFileName; + TEXT_STRING_LIST *DatabaseFileName; + TEXT_STRING_LIST *LastDatabaseFileName; + WCHAR_STRING_LIST *Language; + WCHAR_STRING_LIST *LastLanguage; + WCHAR_MATCHING_STRING_LIST *IndirectionList; // from indirection file(s) + WCHAR_MATCHING_STRING_LIST *LastIndirectionList; + BOOLEAN Verbose; // for more detailed output + BOOLEAN VerboseDatabaseWrite; // for more detailed output when writing database + BOOLEAN VerboseDatabaseRead; // for more detailed output when reading database + BOOLEAN NewDatabase; // to start from scratch + BOOLEAN IgnoreNotFound; // when scanning + BOOLEAN VerboseScan; + BOOLEAN UnquotedStrings; // -uqs option + INT8 OutputDatabaseFileName[MAX_PATH]; + INT8 StringHFileName[MAX_PATH]; + INT8 StringCFileName[MAX_PATH]; // output .C filename + INT8 DumpUFileName[MAX_PATH]; // output unicode dump file name + INT8 HiiExportPackFileName[MAX_PATH]; // HII export pack file name + INT8 BaseName[MAX_PATH]; // base filename of the strings file + INT8 OutputDependencyFileName[MAX_PATH]; + FILE *OutputDependencyFptr; + UINT32 Mode; +} mGlobals; + +static +BOOLEAN +IsValidIdentifierChar ( + INT8 Char, + BOOLEAN FirstChar + ); + +static +void +RewindFile ( + SOURCE_FILE *SourceFile + ); + +static +BOOLEAN +SkipTo ( + SOURCE_FILE *SourceFile, + WCHAR WChar, + BOOLEAN StopAfterNewline + ); + +static +UINT32 +SkipWhiteSpace ( + SOURCE_FILE *SourceFile + ); + +static +BOOLEAN +IsWhiteSpace ( + SOURCE_FILE *SourceFile + ); + +static +BOOLEAN +EndOfFile ( + SOURCE_FILE *SourceFile + ); + +static +void +PreprocessFile ( + SOURCE_FILE *SourceFile + ); + +static +UINT32 +GetStringIdentifierName ( + IN SOURCE_FILE *SourceFile, + IN OUT WCHAR *StringIdentifierName, + IN UINT32 StringIdentifierNameLen + ); + +static +UINT32 +GetLanguageIdentifierName ( + IN SOURCE_FILE *SourceFile, + IN OUT WCHAR *LanguageIdentifierName, + IN UINT32 LanguageIdentifierNameLen, + IN BOOLEAN Optional + ); + +static +WCHAR * +GetPrintableLanguageName ( + IN SOURCE_FILE *SourceFile + ); + +static +STATUS +AddCommandLineLanguage ( + IN INT8 *Language + ); + +static +WCHAR * +GetQuotedString ( + SOURCE_FILE *SourceFile, + BOOLEAN Optional + ); + +static +STATUS +ProcessIncludeFile ( + SOURCE_FILE *SourceFile, + SOURCE_FILE *ParentSourceFile + ); + +static +STATUS +ParseFile ( + SOURCE_FILE *SourceFile + ); + +static +FILE * +FindFile ( + IN INT8 *FileName, + OUT INT8 *FoundFileName, + IN UINT32 FoundFileNameLen + ); + +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ); + +static +STATUS +ProcessFile ( + SOURCE_FILE *SourceFile + ); + +static +UINT32 +wstrcmp ( + WCHAR *Buffer, + WCHAR *Str + ); + +static +void +Usage ( + VOID + ); + +static +void +FreeLists ( + VOID + ); + +static +void +ProcessTokenString ( + SOURCE_FILE *SourceFile + ); + +static +void +ProcessTokenInclude ( + SOURCE_FILE *SourceFile + ); + +static +void +ProcessTokenScope ( + SOURCE_FILE *SourceFile + ); + +static +void +ProcessTokenLanguage ( + SOURCE_FILE *SourceFile + ); + +static +void +ProcessTokenLangDef ( + SOURCE_FILE *SourceFile + ); + +static +STATUS +ScanFiles ( + TEXT_STRING_LIST *ScanFiles + ); + +static +STATUS +ParseIndirectionFiles ( + TEXT_STRING_LIST *Files + ); + +STATUS +StringDBCreateHiiExportPack ( + INT8 *OutputFileName + ); + +int +main ( + int Argc, + char *Argv[] + ) +/*++ + +Routine Description: + + Call the routine to parse the command-line options, then process the file. + +Arguments: + + Argc - Standard C main() argc and argv. + Argv - Standard C main() argc and argv. + +Returns: + + 0 if successful + nonzero otherwise + +--*/ +{ + STATUS Status; + + SetUtilityName (PROGRAM_NAME); + // + // Process the command-line arguments + // + Status = ProcessArgs (Argc, Argv); + if (Status != STATUS_SUCCESS) { + return Status; + } + // + // Initialize the database manager + // + StringDBConstructor (); + // + // We always try to read in an existing database file. It may not + // exist, which is ok usually. + // + if (mGlobals.NewDatabase == 0) { + // + // Read all databases specified. + // + for (mGlobals.LastDatabaseFileName = mGlobals.DatabaseFileName; + mGlobals.LastDatabaseFileName != NULL; + mGlobals.LastDatabaseFileName = mGlobals.LastDatabaseFileName->Next + ) { + Status = StringDBReadDatabase (mGlobals.LastDatabaseFileName->Str, TRUE, mGlobals.VerboseDatabaseRead); + if (Status != STATUS_SUCCESS) { + return Status; + } + } + } + // + // Read indirection file(s) if specified + // + if (ParseIndirectionFiles (mGlobals.IndirectionFileName) != STATUS_SUCCESS) { + goto Finish; + } + // + // If scanning source files, do that now + // + if (mGlobals.Mode == MODE_SCAN) { + ScanFiles (mGlobals.ScanFileName); + } else if (mGlobals.Mode == MODE_PARSE) { + // + // Parsing a unicode strings file + // + mGlobals.SourceFiles.ControlCharacter = DEFAULT_CONTROL_CHARACTER; + if (mGlobals.OutputDependencyFileName[0] != 0) { + if ((mGlobals.OutputDependencyFptr = fopen (mGlobals.OutputDependencyFileName, "w")) == NULL) { + Error (NULL, 0, 0, mGlobals.OutputDependencyFileName, "failed to open output dependency file"); + goto Finish; + } + } + Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL); + if (mGlobals.OutputDependencyFptr != NULL) { + fclose (mGlobals.OutputDependencyFptr); + } + if (Status != STATUS_SUCCESS) { + goto Finish; + } + } + // + // Create the string defines header file if there have been no errors. + // + ParserSetPosition (NULL, 0); + if ((mGlobals.StringHFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) { + Status = StringDBDumpStringDefines (mGlobals.StringHFileName, mGlobals.BaseName); + if (Status != EFI_SUCCESS) { + goto Finish; + } + } + // + // Dump the strings to a .c file if there have still been no errors. + // + if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) { + Status = StringDBDumpCStrings ( + mGlobals.StringCFileName, + mGlobals.BaseName, + mGlobals.Language, + mGlobals.IndirectionList + ); + if (Status != EFI_SUCCESS) { + goto Finish; + } + } + // + // Dump the database if requested + // + if ((mGlobals.DumpUFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) { + StringDBDumpDatabase (NULL, mGlobals.DumpUFileName, FALSE); + } + // + // Dump the string data as HII binary string pack if requested + // + if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) { + StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName); + } + // + // Always update the database if no errors and not in dump mode. If they specified -od + // for an output database file name, then use that name. Otherwise use the name of + // the first database file specified with -db + // + if ((mGlobals.Mode != MODE_DUMP) && (GetUtilityStatus () < STATUS_ERROR)) { + if (mGlobals.OutputDatabaseFileName[0]) { + Status = StringDBWriteDatabase (mGlobals.OutputDatabaseFileName, mGlobals.VerboseDatabaseWrite); + } else { + Status = StringDBWriteDatabase (mGlobals.DatabaseFileName->Str, mGlobals.VerboseDatabaseWrite); + } + + if (Status != EFI_SUCCESS) { + goto Finish; + } + } + +Finish: + // + // Free up memory + // + FreeLists (); + StringDBDestructor (); + return GetUtilityStatus (); +} + +static +STATUS +ProcessIncludeFile ( + SOURCE_FILE *SourceFile, + SOURCE_FILE *ParentSourceFile + ) +/*++ + +Routine Description: + + Given a source file, open the file and parse it + +Arguments: + + SourceFile - name of file to parse + ParentSourceFile - for error reporting purposes, the file that #included SourceFile. + +Returns: + + Standard status. + +--*/ +{ + static UINT32 NestDepth = 0; + INT8 FoundFileName[MAX_PATH]; + STATUS Status; + + Status = STATUS_SUCCESS; + NestDepth++; + // + // Print the file being processed. Indent so you can tell the include nesting + // depth. + // + if (mGlobals.Verbose) { + fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName); + } + + // + // Make sure we didn't exceed our maximum nesting depth + // + if (NestDepth > MAX_NEST_DEPTH) { + Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth); + Status = STATUS_ERROR; + goto Finish; + } + // + // Try to open the file locally, and if that fails try along our include paths. + // + strcpy (FoundFileName, SourceFile->FileName); + if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) { + // + // Try to find it among the paths if it has a parent (that is, it is included + // by someone else). + // + if (ParentSourceFile == NULL) { + Error (NULL, 0, 0, SourceFile->FileName, "file not found"); + Status = STATUS_ERROR; + goto Finish; + } + + SourceFile->Fptr = FindFile (SourceFile->FileName, FoundFileName, sizeof (FoundFileName)); + if (SourceFile->Fptr == NULL) { + Error (ParentSourceFile->FileName, ParentSourceFile->LineNum, 0, SourceFile->FileName, "include file not found"); + Status = STATUS_ERROR; + goto Finish; + } + } + + // + // Output the dependency + // + if (mGlobals.OutputDependencyFptr != NULL) { + fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName); + // + // Add pseudo target to avoid incremental build failure when the file is deleted + // + fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName); + } + + // + // Process the file found + // + ProcessFile (SourceFile); + +Finish: + NestDepth--; + // + // Close open files and return status + // + if (SourceFile->Fptr != NULL) { + fclose (SourceFile->Fptr); + } + + return Status; +} + +static +STATUS +ProcessFile ( + SOURCE_FILE *SourceFile + ) +{ + // + // Get the file size, and then read the entire thing into memory. + // Allocate space for a terminator character. + // + fseek (SourceFile->Fptr, 0, SEEK_END); + SourceFile->FileSize = ftell (SourceFile->Fptr); + fseek (SourceFile->Fptr, 0, SEEK_SET); + SourceFile->FileBuffer = (WCHAR *) malloc (SourceFile->FileSize + sizeof (WCHAR)); + if (SourceFile->FileBuffer == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr); + SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (WCHAR))] = UNICODE_NULL; + // + // Pre-process the file to replace comments with spaces + // + PreprocessFile (SourceFile); + // + // Parse the file + // + ParseFile (SourceFile); + free (SourceFile->FileBuffer); + return STATUS_SUCCESS; +} + +static +STATUS +ParseFile ( + SOURCE_FILE *SourceFile + ) +{ + BOOLEAN InComment; + UINT32 Len; + + // + // First character of a unicode file is special. Make sure + // + if (SourceFile->FileBufferPtr[0] != UNICODE_FILE_START) { + Error (SourceFile->FileName, 1, 0, SourceFile->FileName, "file does not appear to be a unicode file"); + return STATUS_ERROR; + } + + SourceFile->FileBufferPtr++; + InComment = FALSE; + // + // Print the first line if in verbose mode + // + if (mGlobals.Verbose) { + printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr); + } + // + // Since the syntax is relatively straightforward, just switch on the next char + // + while (!EndOfFile (SourceFile)) { + // + // Check for whitespace + // + if (SourceFile->FileBufferPtr[0] == UNICODE_SPACE) { + SourceFile->FileBufferPtr++; + } else if (SourceFile->FileBufferPtr[0] == UNICODE_TAB) { + SourceFile->FileBufferPtr++; + } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) { + SourceFile->FileBufferPtr++; + } else if (SourceFile->FileBufferPtr[0] == UNICODE_LF) { + SourceFile->FileBufferPtr++; + SourceFile->LineNum++; + if (mGlobals.Verbose) { + printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr); + } + + InComment = FALSE; + } else if (SourceFile->FileBufferPtr[0] == 0) { + SourceFile->FileBufferPtr++; + } else if (InComment) { + SourceFile->FileBufferPtr++; + } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) { + SourceFile->FileBufferPtr += 2; + InComment = TRUE; + } else if (SourceFile->SkipToHash && (SourceFile->FileBufferPtr[0] != SourceFile->ControlCharacter)) { + SourceFile->FileBufferPtr++; + } else { + SourceFile->SkipToHash = FALSE; + if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) && + ((Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"include")) > 0) + ) { + SourceFile->FileBufferPtr += Len + 1; + ProcessTokenInclude (SourceFile); + } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) && + (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"scope")) > 0 + ) { + SourceFile->FileBufferPtr += Len + 1; + ProcessTokenScope (SourceFile); + } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) && + (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"language")) > 0 + ) { + SourceFile->FileBufferPtr += Len + 1; + ProcessTokenLanguage (SourceFile); + } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) && + (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"langdef")) > 0 + ) { + SourceFile->FileBufferPtr += Len + 1; + ProcessTokenLangDef (SourceFile); + } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) && + (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"string")) > 0 + ) { + SourceFile->FileBufferPtr += Len + 1; + ProcessTokenString (SourceFile); + } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) && + (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"EFI_BREAKPOINT()")) > 0 + ) { + SourceFile->FileBufferPtr += Len; + EFI_BREAKPOINT (); + } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) && + (SourceFile->FileBufferPtr[1] == UNICODE_EQUAL_SIGN) + ) { + SourceFile->ControlCharacter = SourceFile->FileBufferPtr[2]; + SourceFile->FileBufferPtr += 3; + } else { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "unrecognized token", "%S", SourceFile->FileBufferPtr); + // + // Treat rest of line as a comment. + // + InComment = TRUE; + } + } + } + + return STATUS_SUCCESS; +} + +static +void +PreprocessFile ( + SOURCE_FILE *SourceFile + ) +/*++ + +Routine Description: + Preprocess a file to replace all carriage returns with NULLs so + we can print lines from the file to the screen. + +Arguments: + SourceFile - structure that we use to keep track of an input file. + +Returns: + Nothing. + +--*/ +{ + BOOLEAN InComment; + + RewindFile (SourceFile); + InComment = FALSE; + while (!EndOfFile (SourceFile)) { + // + // If a line-feed, then no longer in a comment + // + if (SourceFile->FileBufferPtr[0] == UNICODE_LF) { + SourceFile->FileBufferPtr++; + SourceFile->LineNum++; + InComment = 0; + } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) { + // + // Replace all carriage returns with a NULL so we can print stuff + // + SourceFile->FileBufferPtr[0] = 0; + SourceFile->FileBufferPtr++; + } else if (InComment) { + SourceFile->FileBufferPtr[0] = UNICODE_SPACE; + SourceFile->FileBufferPtr++; + } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) { + SourceFile->FileBufferPtr += 2; + InComment = TRUE; + } else { + SourceFile->FileBufferPtr++; + } + } + // + // Could check for end-of-file and still in a comment, but + // should not be necessary. So just restore the file pointers. + // + RewindFile (SourceFile); +} + +static +WCHAR * +GetPrintableLanguageName ( + IN SOURCE_FILE *SourceFile + ) +{ + WCHAR *String; + WCHAR *Start; + WCHAR *Ptr; + UINT32 Len; + + SkipWhiteSpace (SourceFile); + if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) { + Error ( + SourceFile->FileName, + SourceFile->LineNum, + 0, + "expected quoted printable language name", + "%S", + SourceFile->FileBufferPtr + ); + SourceFile->SkipToHash = TRUE; + return NULL; + } + + Len = 0; + SourceFile->FileBufferPtr++; + Start = Ptr = SourceFile->FileBufferPtr; + while (!EndOfFile (SourceFile)) { + if (SourceFile->FileBufferPtr[0] == UNICODE_CR) { + Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start); + break; + } else if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) { + break; + } + + SourceFile->FileBufferPtr++; + Len++; + } + + if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) { + Warning ( + SourceFile->FileName, + SourceFile->LineNum, + 0, + "missing closing quote on printable language name string", + "%S", + Start + ); + } else { + SourceFile->FileBufferPtr++; + } + // + // Now allocate memory for the string and save it off + // + String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR)); + if (String == NULL) { + Error (NULL, 0, 0, "memory allocation failed", NULL); + return NULL; + } + // + // Copy the string from the file buffer to the local copy. + // We do no reformatting of it whatsoever at this point. + // + Ptr = String; + while (Len > 0) { + *Ptr = *Start; + Start++; + Ptr++; + Len--; + } + + *Ptr = 0; + // + // Now format the string to convert \wide and \narrow controls + // + StringDBFormatString (String); + return String; +} + +static +WCHAR * +GetQuotedString ( + SOURCE_FILE *SourceFile, + BOOLEAN Optional + ) +{ + WCHAR *String; + WCHAR *Start; + WCHAR *Ptr; + UINT32 Len; + BOOLEAN PreviousBackslash; + + if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) { + if (!Optional) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr); + } + + return NULL; + } + + Len = 0; + SourceFile->FileBufferPtr++; + Start = Ptr = SourceFile->FileBufferPtr; + PreviousBackslash = FALSE; + while (!EndOfFile (SourceFile)) { + if ((SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) && (!PreviousBackslash)) { + break; + } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) { + Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start); + PreviousBackslash = FALSE; + } else if (SourceFile->FileBufferPtr[0] == UNICODE_BACKSLASH) { + PreviousBackslash = TRUE; + } else { + PreviousBackslash = FALSE; + } + + SourceFile->FileBufferPtr++; + Len++; + } + + if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) { + Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start); + } else { + SourceFile->FileBufferPtr++; + } + // + // Now allocate memory for the string and save it off + // + String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR)); + if (String == NULL) { + Error (NULL, 0, 0, "memory allocation failed", NULL); + return NULL; + } + // + // Copy the string from the file buffer to the local copy. + // We do no reformatting of it whatsoever at this point. + // + Ptr = String; + while (Len > 0) { + *Ptr = *Start; + Start++; + Ptr++; + Len--; + } + + *Ptr = 0; + return String; +} +// +// Parse: +// #string STR_ID_NAME +// +// All we can do is call the string database to add the string identifier. Unfortunately +// he'll have to keep track of the last identifier we added. +// +static +void +ProcessTokenString ( + SOURCE_FILE *SourceFile + ) +{ + WCHAR StringIdentifier[MAX_STRING_IDENTIFIER_NAME]; + UINT16 StringId; + // + // Extract the string identifier name and add it to the database. + // + if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) { + StringId = STRING_ID_INVALID; + StringDBAddStringIdentifier (StringIdentifier, &StringId, 0); + } else { + // + // Error recovery -- skip to the next # + // + SourceFile->SkipToHash = TRUE; + } +} + +static +BOOLEAN +EndOfFile ( + SOURCE_FILE *SourceFile + ) +{ + // + // The file buffer pointer will typically get updated before the End-of-file flag in the + // source file structure, so check it first. + // + if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (WCHAR)) { + SourceFile->EndOfFile = TRUE; + return TRUE; + } + + if (SourceFile->EndOfFile) { + return TRUE; + } + + return FALSE; +} + +static +UINT32 +GetStringIdentifierName ( + IN SOURCE_FILE *SourceFile, + IN OUT WCHAR *StringIdentifierName, + IN UINT32 StringIdentifierNameLen + ) +{ + UINT32 Len; + WCHAR *From; + WCHAR *Start; + + // + // Skip whitespace + // + SkipWhiteSpace (SourceFile); + if (SourceFile->EndOfFile) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-file encountered", "expected string identifier"); + return 0; + } + // + // Verify first character of name is [A-Za-z] + // + Len = 0; + StringIdentifierNameLen /= 2; + From = SourceFile->FileBufferPtr; + Start = SourceFile->FileBufferPtr; + if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) || + ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z)) + ) { + // + // Do nothing + // + } else { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid character in string identifier name", "%S", Start); + return 0; + } + + while (!EndOfFile (SourceFile)) { + if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) || + ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z)) || + ((SourceFile->FileBufferPtr[0] >= UNICODE_0) && (SourceFile->FileBufferPtr[0] <= UNICODE_9)) || + (SourceFile->FileBufferPtr[0] == UNICODE_UNDERSCORE) + ) { + Len++; + if (Len >= StringIdentifierNameLen) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "string identifier name too long", "%S", Start); + return 0; + } + + *StringIdentifierName = SourceFile->FileBufferPtr[0]; + StringIdentifierName++; + SourceFile->FileBufferPtr++; + } else if (SkipWhiteSpace (SourceFile) == 0) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid string identifier name", "%S", Start); + return 0; + } else { + break; + } + } + // + // Terminate the copy of the string. + // + *StringIdentifierName = 0; + return Len; +} + +static +UINT32 +GetLanguageIdentifierName ( + IN SOURCE_FILE *SourceFile, + IN OUT WCHAR *LanguageIdentifierName, + IN UINT32 LanguageIdentifierNameLen, + IN BOOLEAN Optional + ) +{ + UINT32 Len; + WCHAR *From; + WCHAR *Start; + // + // Skip whitespace + // + SkipWhiteSpace (SourceFile); + if (SourceFile->EndOfFile) { + if (!Optional) { + Error ( + SourceFile->FileName, + SourceFile->LineNum, + 0, + "end-of-file encountered", + "expected language identifier" + ); + } + + return 0; + } + // + // This function is called to optionally get a language identifier name in: + // #string STR_ID eng "the string" + // If it's optional, and we find a double-quote, then return now. + // + if (Optional) { + if (*SourceFile->FileBufferPtr == UNICODE_DOUBLE_QUOTE) { + return 0; + } + } + + Len = 0; + LanguageIdentifierNameLen /= 2; + // + // Internal error if we weren't given at least 4 WCHAR's to work with. + // + if (LanguageIdentifierNameLen < LANGUAGE_IDENTIFIER_NAME_LEN + 1) { + Error ( + SourceFile->FileName, + SourceFile->LineNum, + 0, + "app error -- language identifier name length is invalid", + NULL + ); + } + + From = SourceFile->FileBufferPtr; + Start = SourceFile->FileBufferPtr; + while (!EndOfFile (SourceFile)) { + if (((SourceFile->FileBufferPtr[0] >= UNICODE_a) && (SourceFile->FileBufferPtr[0] <= UNICODE_z))) { + Len++; + if (Len > LANGUAGE_IDENTIFIER_NAME_LEN) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "language identifier name too long", "%S", Start); + return 0; + } + + *LanguageIdentifierName = SourceFile->FileBufferPtr[0]; + SourceFile->FileBufferPtr++; + LanguageIdentifierName++; + } else if (!IsWhiteSpace (SourceFile)) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid language identifier name", "%S", Start); + return 0; + } else { + break; + } + } + // + // Terminate the copy of the string. + // + *LanguageIdentifierName = 0; + return Len; +} + +static +void +ProcessTokenInclude ( + SOURCE_FILE *SourceFile + ) +{ + INT8 IncludeFileName[MAX_PATH]; + INT8 *To; + UINT32 Len; + BOOLEAN ReportedError; + SOURCE_FILE IncludedSourceFile; + + ReportedError = FALSE; + if (SkipWhiteSpace (SourceFile) == 0) { + Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL); + } + // + // Should be quoted file name + // + if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL); + goto FailDone; + } + + SourceFile->FileBufferPtr++; + // + // Copy the filename as ascii to our local string + // + To = IncludeFileName; + Len = 0; + while (!EndOfFile (SourceFile)) { + if ((SourceFile->FileBufferPtr[0] == UNICODE_CR) || (SourceFile->FileBufferPtr[0] == UNICODE_LF)) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL); + goto FailDone; + } + + if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) { + SourceFile->FileBufferPtr++; + break; + } + // + // If too long, then report the error once and process until the closing quote + // + Len++; + if (!ReportedError && (Len >= sizeof (IncludeFileName))) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL); + ReportedError = TRUE; + } + + if (!ReportedError) { + *To = UNICODE_TO_ASCII (SourceFile->FileBufferPtr[0]); + To++; + } + + SourceFile->FileBufferPtr++; + } + + if (!ReportedError) { + *To = 0; + memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE)); + strcpy (IncludedSourceFile.FileName, IncludeFileName); + IncludedSourceFile.ControlCharacter = DEFAULT_CONTROL_CHARACTER; + ProcessIncludeFile (&IncludedSourceFile, SourceFile); + // + // printf ("including file '%s'\n", IncludeFileName); + // + } + + return ; +FailDone: + // + // Error recovery -- skip to next # + // + SourceFile->SkipToHash = TRUE; +} + +static +void +ProcessTokenScope ( + SOURCE_FILE *SourceFile + ) +{ + WCHAR StringIdentifier[MAX_STRING_IDENTIFIER_NAME]; + // + // Extract the scope name + // + if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) { + StringDBSetScope (StringIdentifier); + } +} +// +// Parse: #langdef eng "English" +// #langdef chn "\wideChinese" +// +static +void +ProcessTokenLangDef ( + SOURCE_FILE *SourceFile + ) +{ + WCHAR LanguageIdentifier[MAX_STRING_IDENTIFIER_NAME]; + UINT32 Len; + WCHAR *PrintableName; + // + // Extract the 3-character language identifier + // + Len = GetLanguageIdentifierName (SourceFile, LanguageIdentifier, sizeof (LanguageIdentifier), FALSE); + if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", NULL); + } else { + // + // Extract the printable name + // + PrintableName = GetPrintableLanguageName (SourceFile); + if (PrintableName != NULL) { + ParserSetPosition (SourceFile->FileName, SourceFile->LineNum); + StringDBAddLanguage (LanguageIdentifier, PrintableName); + free (PrintableName); + return ; + } + } + // + // Error recovery -- skip to next # + // + SourceFile->SkipToHash = TRUE; +} + +static +BOOLEAN +ApparentQuotedString ( + SOURCE_FILE *SourceFile + ) +{ + WCHAR *Ptr; + // + // See if the first and last nonblank characters on the line are double quotes + // + for (Ptr = SourceFile->FileBufferPtr; *Ptr && (*Ptr == UNICODE_SPACE); Ptr++) + ; + if (*Ptr != UNICODE_DOUBLE_QUOTE) { + return FALSE; + } + + while (*Ptr) { + Ptr++; + } + + Ptr--; + for (; *Ptr && (*Ptr == UNICODE_SPACE); Ptr--) + ; + if (*Ptr != UNICODE_DOUBLE_QUOTE) { + return FALSE; + } + + return TRUE; +} +// +// Parse: +// #language eng "some string " "more string" +// +static +void +ProcessTokenLanguage ( + SOURCE_FILE *SourceFile + ) +{ + WCHAR *String; + WCHAR *SecondString; + WCHAR *TempString; + WCHAR *From; + WCHAR *To; + WCHAR Language[LANGUAGE_IDENTIFIER_NAME_LEN + 1]; + UINT32 Len; + BOOLEAN PreviousNewline; + // + // Get the language identifier + // + Language[0] = 0; + Len = GetLanguageIdentifierName (SourceFile, Language, sizeof (Language), TRUE); + if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", "%S", Language); + SourceFile->SkipToHash = TRUE; + return ; + } + // + // Extract the string value. It's either a quoted string that starts on the current line, or + // an unquoted string that starts on the following line and continues until the next control + // character in column 1. + // Look ahead to find a quote or a newline + // + if (SkipTo (SourceFile, UNICODE_DOUBLE_QUOTE, TRUE)) { + String = GetQuotedString (SourceFile, FALSE); + if (String != NULL) { + // + // Set the position in the file of where we are parsing for error + // reporting purposes. Then start looking ahead for additional + // quoted strings, and concatenate them until we get a failure + // back from the string parser. + // + Len = wcslen (String) + 1; + ParserSetPosition (SourceFile->FileName, SourceFile->LineNum); + do { + SkipWhiteSpace (SourceFile); + SecondString = GetQuotedString (SourceFile, TRUE); + if (SecondString != NULL) { + Len += wcslen (SecondString); + TempString = (WCHAR *) malloc (Len * sizeof (WCHAR)); + if (TempString == NULL) { + Error (NULL, 0, 0, "application error", "failed to allocate memory"); + return ; + } + + wcscpy (TempString, String); + wcscat (TempString, SecondString); + free (String); + free (SecondString); + String = TempString; + } + } while (SecondString != NULL); + StringDBAddString (Language, NULL, NULL, String, TRUE, 0); + free (String); + } else { + // + // Error was reported at lower level. Error recovery mode. + // + SourceFile->SkipToHash = TRUE; + } + } else { + if (!mGlobals.UnquotedStrings) { + // + // They're using unquoted strings. If the next non-blank character is a double quote, and the + // last non-blank character on the line is a double quote, then more than likely they're using + // quotes, so they need to put the quoted string on the end of the previous line + // + if (ApparentQuotedString (SourceFile)) { + Warning ( + SourceFile->FileName, + SourceFile->LineNum, + 0, + "unexpected quoted string on line", + "specify -uqs option if necessary" + ); + } + } + // + // Found end-of-line (hopefully). Skip over it and start taking in characters + // until we find a control character at the start of a line. + // + Len = 0; + From = SourceFile->FileBufferPtr; + PreviousNewline = FALSE; + while (!EndOfFile (SourceFile)) { + if (SourceFile->FileBufferPtr[0] == UNICODE_LF) { + PreviousNewline = TRUE; + SourceFile->LineNum++; + } else { + Len++; + if (PreviousNewline && (SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter)) { + break; + } + + PreviousNewline = FALSE; + } + + SourceFile->FileBufferPtr++; + } + + if ((Len == 0) && EndOfFile (SourceFile)) { + Error (SourceFile->FileName, SourceFile->LineNum, 0, "unexpected end of file", NULL); + SourceFile->SkipToHash = TRUE; + return ; + } + // + // Now allocate a buffer, copy the characters, and add the string. + // + String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR)); + if (String == NULL) { + Error (NULL, 0, 0, "application error", "failed to allocate memory"); + return ; + } + + To = String; + while (From < SourceFile->FileBufferPtr) { + switch (*From) { + case UNICODE_LF: + case 0: + break; + + default: + *To = *From; + To++; + break; + } + + From++; + } + + // + // String[Len] = 0; + // + *To = 0; + StringDBAddString (Language, NULL, NULL, String, TRUE, 0); + } +} + +static +BOOLEAN +IsWhiteSpace ( + SOURCE_FILE *SourceFile + ) +{ + switch (SourceFile->FileBufferPtr[0]) { + case UNICODE_NULL: + case UNICODE_CR: + case UNICODE_SPACE: + case UNICODE_TAB: + case UNICODE_LF: + return TRUE; + + default: + return FALSE; + } +} + +static +UINT32 +SkipWhiteSpace ( + SOURCE_FILE *SourceFile + ) +{ + UINT32 Count; + + Count = 0; + while (!EndOfFile (SourceFile)) { + Count++; + switch (*SourceFile->FileBufferPtr) { + case UNICODE_NULL: + case UNICODE_CR: + case UNICODE_SPACE: + case UNICODE_TAB: + SourceFile->FileBufferPtr++; + break; + + case UNICODE_LF: + SourceFile->FileBufferPtr++; + SourceFile->LineNum++; + if (mGlobals.Verbose) { + printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr); + } + break; + + default: + return Count - 1; + } + } + // + // Some tokens require trailing whitespace. If we're at the end of the + // file, then we count that as well. + // + if ((Count == 0) && (EndOfFile (SourceFile))) { + Count++; + } + + return Count; +} + +static +UINT32 +wstrcmp ( + WCHAR *Buffer, + WCHAR *Str + ) +{ + UINT32 Len; + + Len = 0; + while (*Str == *Buffer) { + Buffer++; + Str++; + Len++; + } + + if (*Str) { + return 0; + } + + return Len; +} +// +// Given a filename, try to find it along the include paths. +// +static +FILE * +FindFile ( + IN INT8 *FileName, + OUT INT8 *FoundFileName, + IN UINT32 FoundFileNameLen + ) +{ + FILE *Fptr; + TEXT_STRING_LIST *List; + + // + // Traverse the list of paths and try to find the file + // + List = mGlobals.IncludePaths; + while (List != NULL) { + // + // Put the path and filename together + // + if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) { + Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename"); + return NULL; + } + // + // Append the filename to this include path and try to open the file. + // + strcpy (FoundFileName, List->Str); + strcat (FoundFileName, FileName); + if ((Fptr = fopen (FoundFileName, "rb")) != NULL) { + // + // Return the file pointer + // + return Fptr; + } + + List = List->Next; + } + // + // Not found + // + FoundFileName[0] = 0; + return NULL; +} +// +// Process the command-line arguments +// +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ) +{ + TEXT_STRING_LIST *NewList; + // + // Clear our globals + // + memset ((char *) &mGlobals, 0, sizeof (mGlobals)); + strcpy (mGlobals.BaseName, DEFAULT_BASE_NAME); + // + // Skip program name + // + Argc--; + Argv++; + + if (Argc == 0) { + Usage (); + return STATUS_ERROR; + } + + mGlobals.Mode = MODE_UNKNOWN; + // + // Process until no more -args. + // + while ((Argc > 0) && (Argv[0][0] == '-')) { + // + // -parse option + // + if (_stricmp (Argv[0], "-parse") == 0) { + if (mGlobals.Mode != MODE_UNKNOWN) { + Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL); + return STATUS_ERROR; + } + + mGlobals.Mode = MODE_PARSE; + // + // -scan option + // + } else if (_stricmp (Argv[0], "-scan") == 0) { + if (mGlobals.Mode != MODE_UNKNOWN) { + Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL); + return STATUS_ERROR; + } + + mGlobals.Mode = MODE_SCAN; + // + // -vscan verbose scanning option + // + } else if (_stricmp (Argv[0], "-vscan") == 0) { + mGlobals.VerboseScan = TRUE; + // + // -dump option + // + } else if (_stricmp (Argv[0], "-dump") == 0) { + if (mGlobals.Mode != MODE_UNKNOWN) { + Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL); + return STATUS_ERROR; + } + + mGlobals.Mode = MODE_DUMP; + } else if (_stricmp (Argv[0], "-uqs") == 0) { + mGlobals.UnquotedStrings = TRUE; + // + // -i path add include search path when parsing + // + } else if (_stricmp (Argv[0], "-i") == 0) { + // + // check for one more arg + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path"); + return STATUS_ERROR; + } + // + // Allocate memory for a new list element, fill it in, and + // add it to our list of include paths. Always make sure it + // has a "\" on the end of it. + // + NewList = malloc (sizeof (TEXT_STRING_LIST)); + if (NewList == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST)); + NewList->Str = malloc (strlen (Argv[1]) + 2); + if (NewList->Str == NULL) { + free (NewList); + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[1]); + if (NewList->Str[strlen (NewList->Str) - 1] != '\\') { + strcat (NewList->Str, "\\"); + } + // + // Add it to our linked list + // + if (mGlobals.IncludePaths == NULL) { + mGlobals.IncludePaths = NewList; + } else { + mGlobals.LastIncludePath->Next = NewList; + } + + mGlobals.LastIncludePath = NewList; + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-if") == 0) { + // + // Indirection file -- check for one more arg + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name"); + return STATUS_ERROR; + } + // + // Allocate memory for a new list element, fill it in, and + // add it to our list of include paths. Always make sure it + // has a "\" on the end of it. + // + NewList = malloc (sizeof (TEXT_STRING_LIST)); + if (NewList == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST)); + NewList->Str = malloc (strlen (Argv[1]) + 1); + if (NewList->Str == NULL) { + free (NewList); + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[1]); + // + // Add it to our linked list + // + if (mGlobals.IndirectionFileName == NULL) { + mGlobals.IndirectionFileName = NewList; + } else { + mGlobals.LastIndirectionFileName->Next = NewList; + } + + mGlobals.LastIndirectionFileName = NewList; + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-db") == 0) { + // + // -db option to specify a database file. + // Check for one more arg (the database file name) + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name"); + return STATUS_ERROR; + } + + NewList = malloc (sizeof (TEXT_STRING_LIST)); + if (NewList == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST)); + NewList->Str = malloc (strlen (Argv[1]) + 1); + if (NewList->Str == NULL) { + free (NewList); + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[1]); + // + // Add it to our linked list + // + if (mGlobals.DatabaseFileName == NULL) { + mGlobals.DatabaseFileName = NewList; + } else { + mGlobals.LastDatabaseFileName->Next = NewList; + } + + mGlobals.LastDatabaseFileName = NewList; + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-ou") == 0) { + // + // -ou option to specify an output unicode file to + // which we can dump our database. + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name"); + return STATUS_ERROR; + } + + if (mGlobals.DumpUFileName[0] == 0) { + strcpy (mGlobals.DumpUFileName, Argv[1]); + } else { + Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-hpk") == 0) { + // + // -hpk option to create an HII export pack of the input database file + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name"); + return STATUS_ERROR; + } + + if (mGlobals.HiiExportPackFileName[0] == 0) { + strcpy (mGlobals.HiiExportPackFileName, Argv[1]); + } else { + Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName); + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if ((_stricmp (Argv[0], "-?") == 0) || (_stricmp (Argv[0], "-h") == 0)) { + Usage (); + return STATUS_ERROR; + } else if (_stricmp (Argv[0], "-v") == 0) { + mGlobals.Verbose = 1; + } else if (_stricmp (Argv[0], "-vdbw") == 0) { + mGlobals.VerboseDatabaseWrite = 1; + } else if (_stricmp (Argv[0], "-vdbr") == 0) { + mGlobals.VerboseDatabaseRead = 1; + } else if (_stricmp (Argv[0], "-newdb") == 0) { + mGlobals.NewDatabase = 1; + } else if (_stricmp (Argv[0], "-ignorenotfound") == 0) { + mGlobals.IgnoreNotFound = 1; + } else if (_stricmp (Argv[0], "-oc") == 0) { + // + // check for one more arg + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename"); + return STATUS_ERROR; + } + + strcpy (mGlobals.StringCFileName, Argv[1]); + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-bn") == 0) { + // + // check for one more arg + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name"); + Usage (); + return STATUS_ERROR; + } + + strcpy (mGlobals.BaseName, Argv[1]); + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-oh") == 0) { + // + // -oh to specify output .h defines file name + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename"); + return STATUS_ERROR; + } + + strcpy (mGlobals.StringHFileName, Argv[1]); + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-dep") == 0) { + // + // -dep to specify output dependency file name + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename"); + return STATUS_ERROR; + } + + strcpy (mGlobals.OutputDependencyFileName, Argv[1]); + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-skipext") == 0) { + // + // -skipext to skip scanning of files with certain filename extensions + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension"); + return STATUS_ERROR; + } + // + // Allocate memory for a new list element, fill it in, and + // add it to our list of excluded extensions. Always make sure it + // has a "." as the first character. + // + NewList = malloc (sizeof (TEXT_STRING_LIST)); + if (NewList == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST)); + NewList->Str = malloc (strlen (Argv[1]) + 2); + if (NewList->Str == NULL) { + free (NewList); + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + if (Argv[1][0] == '.') { + strcpy (NewList->Str, Argv[1]); + } else { + NewList->Str[0] = '.'; + strcpy (NewList->Str + 1, Argv[1]); + } + // + // Add it to our linked list + // + if (mGlobals.SkipExt == NULL) { + mGlobals.SkipExt = NewList; + } else { + mGlobals.LastSkipExt->Next = NewList; + } + + mGlobals.LastSkipExt = NewList; + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-lang") == 0) { + // + // "-lang eng" or "-lang spa+cat" to only output certain languages + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name"); + Usage (); + return STATUS_ERROR; + } + + if (AddCommandLineLanguage (Argv[1]) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + Argc--; + Argv++; + } else if (_stricmp (Argv[0], "-od") == 0) { + // + // Output database file name -- check for another arg + // + if ((Argc <= 1) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name"); + return STATUS_ERROR; + } + + strcpy (mGlobals.OutputDatabaseFileName, Argv[1]); + Argv++; + Argc--; + } else { + // + // Unrecognized arg + // + Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option"); + Usage (); + return STATUS_ERROR; + } + + Argv++; + Argc--; + } + // + // Make sure they specified the mode parse/scan/dump + // + if (mGlobals.Mode == MODE_UNKNOWN) { + Error (NULL, 0, 0, "must specify one of -parse/-scan/-dump", NULL); + return STATUS_ERROR; + } + // + // All modes require a database filename + // + if (mGlobals.DatabaseFileName == 0) { + Error (NULL, 0, 0, "must specify a database filename using -db DbFileName", NULL); + Usage (); + return STATUS_ERROR; + } + // + // If dumping the database file, then return immediately if all + // parameters check out. + // + if (mGlobals.Mode == MODE_DUMP) { + // + // Not much use if they didn't specify -oh or -oc or -ou or -hpk + // + if ((mGlobals.DumpUFileName[0] == 0) && + (mGlobals.StringHFileName[0] == 0) && + (mGlobals.StringCFileName[0] == 0) && + (mGlobals.HiiExportPackFileName[0] == 0) + ) { + Error (NULL, 0, 0, "-dump without -oc/-oh/-ou/-hpk is a NOP", NULL); + return STATUS_ERROR; + } + + return STATUS_SUCCESS; + } + // + // Had to specify source string file and output string defines header filename. + // + if (mGlobals.Mode == MODE_SCAN) { + if (Argc < 1) { + Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan"); + Usage (); + return STATUS_ERROR; + } + // + // Get the list of filenames + // + while (Argc > 0) { + NewList = malloc (sizeof (TEXT_STRING_LIST)); + if (NewList == NULL) { + Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + memset (NewList, 0, sizeof (TEXT_STRING_LIST)); + NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1); + if (NewList->Str == NULL) { + Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL); + return STATUS_ERROR; + } + + strcpy (NewList->Str, Argv[0]); + if (mGlobals.ScanFileName == NULL) { + mGlobals.ScanFileName = NewList; + } else { + mGlobals.LastScanFileName->Next = NewList; + } + + mGlobals.LastScanFileName = NewList; + Argc--; + Argv++; + } + } else { + // + // Parse mode -- must specify an input unicode file name + // + if (Argc < 1) { + Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse"); + Usage (); + return STATUS_ERROR; + } + + strcpy (mGlobals.SourceFiles.FileName, Argv[0]); + } + + return STATUS_SUCCESS; +} +// +// Found "-lang eng,spa+cat" on the command line. Parse the +// language list and save the setting for later processing. +// +static +STATUS +AddCommandLineLanguage ( + IN INT8 *Language + ) +{ + WCHAR_STRING_LIST *WNewList; + WCHAR *From; + WCHAR *To; + // + // Keep processing the input string until we find the end. + // + while (*Language) { + // + // Allocate memory for a new list element, fill it in, and + // add it to our list. + // + WNewList = MALLOC (sizeof (WCHAR_STRING_LIST)); + if (WNewList == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + + memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST)); + WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR)); + if (WNewList->Str == NULL) { + free (WNewList); + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + // + // Copy it as unicode to our new structure. Then remove the + // plus signs in it, and verify each language name is 3 characters + // long. If we find a comma, then we're done with this group, so + // break out. + // +#ifdef USE_VC8 + swprintf (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%S", Language); +#else + swprintf (WNewList->Str, L"%S", Language); +#endif + From = To = WNewList->Str; + while (*From) { + if (*From == L',') { + break; + } + + if ((wcslen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) || + ( + (From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) && + (From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) && + (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',') + ) + ) { + Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line"); + FREE (WNewList->Str); + FREE (WNewList); + return STATUS_ERROR; + } + + wcsncpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN); + To += LANGUAGE_IDENTIFIER_NAME_LEN; + From += LANGUAGE_IDENTIFIER_NAME_LEN; + if (*From == L'+') { + From++; + } + } + + *To = 0; + // + // Add it to our linked list + // + if (mGlobals.Language == NULL) { + mGlobals.Language = WNewList; + } else { + mGlobals.LastLanguage->Next = WNewList; + } + + mGlobals.LastLanguage = WNewList; + // + // Skip to next entry (comma-separated list) + // + while (*Language) { + if (*Language == L',') { + Language++; + break; + } + + Language++; + } + } + + return STATUS_SUCCESS; +} +// +// The contents of the text file are expected to be (one per line) +// STRING_IDENTIFIER_NAME ScopeName +// For example: +// STR_ID_MY_FAVORITE_STRING IBM +// +static +STATUS +ParseIndirectionFiles ( + TEXT_STRING_LIST *Files + ) +{ + FILE *Fptr; + INT8 Line[200]; + INT8 *StringName; + INT8 *ScopeName; + INT8 *End; + UINT32 LineCount; + WCHAR_MATCHING_STRING_LIST *NewList; + + Line[sizeof (Line) - 1] = 0; + Fptr = NULL; + while (Files != NULL) { + Fptr = fopen (Files->Str, "r"); + LineCount = 0; + if (Fptr == NULL) { + Error (NULL, 0, 0, Files->Str, "failed to open input indirection file for reading"); + return STATUS_ERROR; + } + + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + // + // remove terminating newline for error printing purposes. + // + if (Line[strlen (Line) - 1] == '\n') { + Line[strlen (Line) - 1] = 0; + } + + LineCount++; + if (Line[sizeof (Line) - 1] != 0) { + Error (Files->Str, LineCount, 0, "line length exceeds maximum supported", NULL); + goto Done; + } + + StringName = Line; + while (*StringName && (isspace (*StringName))) { + StringName++; + } + + if (*StringName) { + if ((*StringName == '_') || isalpha (*StringName)) { + End = StringName; + while ((*End) && (*End == '_') || (isalnum (*End))) { + End++; + } + + if (isspace (*End)) { + *End = 0; + End++; + while (isspace (*End)) { + End++; + } + + if (*End) { + ScopeName = End; + while (*End && !isspace (*End)) { + End++; + } + + *End = 0; + // + // Add the string name/scope pair + // + NewList = malloc (sizeof (WCHAR_MATCHING_STRING_LIST)); + if (NewList == NULL) { + Error (NULL, 0, 0, "memory allocation error", NULL); + goto Done; + } + + memset (NewList, 0, sizeof (WCHAR_MATCHING_STRING_LIST)); + NewList->Str1 = (WCHAR *) malloc ((strlen (StringName) + 1) * sizeof (WCHAR)); + NewList->Str2 = (WCHAR *) malloc ((strlen (ScopeName) + 1) * sizeof (WCHAR)); + if ((NewList->Str1 == NULL) || (NewList->Str2 == NULL)) { + Error (NULL, 0, 0, "memory allocation error", NULL); + goto Done; + } + +#ifdef USE_VC8 + swprintf (NewList->Str1, (strlen (StringName) + 1) * sizeof (WCHAR), L"%S", StringName); + swprintf (NewList->Str2, (strlen (ScopeName) + 1) * sizeof (WCHAR), L"%S", ScopeName); +#else + swprintf (NewList->Str1, L"%S", StringName); + swprintf (NewList->Str2, L"%S", ScopeName); +#endif + if (mGlobals.IndirectionList == NULL) { + mGlobals.IndirectionList = NewList; + } else { + mGlobals.LastIndirectionList->Next = NewList; + } + + mGlobals.LastIndirectionList = NewList; + } else { + Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'"); + goto Done; + } + } else { + Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'"); + goto Done; + } + } else { + Error (Files->Str, LineCount, 0, StringName, "invalid string identifier"); + goto Done; + } + } + } + + fclose (Fptr); + Fptr = NULL; + Files = Files->Next; + } + +Done: + if (Fptr != NULL) { + fclose (Fptr); + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} + +static +STATUS +ScanFiles ( + TEXT_STRING_LIST *ScanFiles + ) +{ + char Line[MAX_LINE_LEN]; + FILE *Fptr; + UINT32 LineNum; + char *Cptr; + char *SavePtr; + char *TermPtr; + char *StringTokenPos; + TEXT_STRING_LIST *SList; + BOOLEAN SkipIt; + + // + // Put a null-terminator at the end of the line. If we read in + // a line longer than we support, then we can catch it. + // + Line[MAX_LINE_LEN - 1] = 0; + // + // Process each file. If they gave us a skip extension list, then + // skip it if the extension matches. + // + while (ScanFiles != NULL) { + SkipIt = FALSE; + for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) { + if ((strlen (ScanFiles->Str) > strlen (SList->Str)) && + (strcmp (ScanFiles->Str + strlen (ScanFiles->Str) - strlen (SList->Str), SList->Str) == 0) + ) { + SkipIt = TRUE; + // + // printf ("Match: %s : %s\n", ScanFiles->Str, SList->Str); + // + break; + } + } + + if (!SkipIt) { + if (mGlobals.VerboseScan) { + printf ("Scanning %s\n", ScanFiles->Str); + } + + Fptr = fopen (ScanFiles->Str, "r"); + if (Fptr == NULL) { + Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning"); + return STATUS_ERROR; + } + + LineNum = 0; + while (fgets (Line, sizeof (Line), Fptr) != NULL) { + LineNum++; + if (Line[MAX_LINE_LEN - 1] != 0) { + Error (ScanFiles->Str, LineNum, 0, "line length exceeds maximum supported by tool", NULL); + fclose (Fptr); + return STATUS_ERROR; + } + // + // Remove the newline from the input line so we can print a warning message + // + if (Line[strlen (Line) - 1] == '\n') { + Line[strlen (Line) - 1] = 0; + } + // + // Terminate the line at // comments + // + Cptr = strstr (Line, "//"); + if (Cptr != NULL) { + *Cptr = 0; + } + + Cptr = Line; + while ((Cptr = strstr (Cptr, STRING_TOKEN)) != NULL) { + // + // Found "STRING_TOKEN". Make sure we don't have NUM_STRING_TOKENS or + // something like that. Then make sure it's followed by + // an open parenthesis, a string identifier, and then a closing + // parenthesis. + // + if (mGlobals.VerboseScan) { + printf (" %d: %s", LineNum, Cptr); + } + + if (((Cptr == Line) || (!IsValidIdentifierChar (*(Cptr - 1), FALSE))) && + (!IsValidIdentifierChar (*(Cptr + sizeof (STRING_TOKEN) - 1), FALSE)) + ) { + StringTokenPos = Cptr; + SavePtr = Cptr; + Cptr += strlen (STRING_TOKEN); + while (*Cptr && isspace (*Cptr) && (*Cptr != '(')) { + Cptr++; + } + + if (*Cptr != '(') { + Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)"); + } else { + // + // Skip over the open-parenthesis and find the next non-blank character + // + Cptr++; + while (isspace (*Cptr)) { + Cptr++; + } + + SavePtr = Cptr; + if ((*Cptr == '_') || isalpha (*Cptr)) { + while ((*Cptr == '_') || (isalnum (*Cptr))) { + Cptr++; + } + + TermPtr = Cptr; + while (*Cptr && isspace (*Cptr)) { + Cptr++; + } + + if (*Cptr != ')') { + Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)"); + } + + if (*TermPtr) { + *TermPtr = 0; + Cptr = TermPtr + 1; + } else { + Cptr = TermPtr; + } + // + // Add the string identifier to the list of used strings + // + ParserSetPosition (ScanFiles->Str, LineNum); + StringDBSetStringReferenced (SavePtr, mGlobals.IgnoreNotFound); + if (mGlobals.VerboseScan) { + printf ("...referenced %s", SavePtr); + } + } else { + Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected valid string identifier name"); + } + } + } else { + // + // Found it, but it's a substring of something else. Advance our pointer. + // + Cptr++; + } + + if (mGlobals.VerboseScan) { + printf ("\n"); + } + } + } + + fclose (Fptr); + } else { + // + // Skipping this file type + // + if (mGlobals.VerboseScan) { + printf ("Skip scanning of %s\n", ScanFiles->Str); + } + } + + ScanFiles = ScanFiles->Next; + } + + return STATUS_SUCCESS; +} +// +// Free the global string lists we allocated memory for +// +static +void +FreeLists ( + VOID + ) +{ + TEXT_STRING_LIST *Temp; + WCHAR_STRING_LIST *WTemp; + + // + // Traverse the include paths, freeing each + // + while (mGlobals.IncludePaths != NULL) { + Temp = mGlobals.IncludePaths->Next; + free (mGlobals.IncludePaths->Str); + free (mGlobals.IncludePaths); + mGlobals.IncludePaths = Temp; + } + // + // If we did a scan, then free up our + // list of files to scan. + // + while (mGlobals.ScanFileName != NULL) { + Temp = mGlobals.ScanFileName->Next; + free (mGlobals.ScanFileName->Str); + free (mGlobals.ScanFileName); + mGlobals.ScanFileName = Temp; + } + // + // If they gave us a list of filename extensions to + // skip on scan, then free them up. + // + while (mGlobals.SkipExt != NULL) { + Temp = mGlobals.SkipExt->Next; + free (mGlobals.SkipExt->Str); + free (mGlobals.SkipExt); + mGlobals.SkipExt = Temp; + } + // + // Free up any languages specified + // + while (mGlobals.Language != NULL) { + WTemp = mGlobals.Language->Next; + free (mGlobals.Language->Str); + free (mGlobals.Language); + mGlobals.Language = WTemp; + } + // + // Free up our indirection list + // + while (mGlobals.IndirectionList != NULL) { + mGlobals.LastIndirectionList = mGlobals.IndirectionList->Next; + free (mGlobals.IndirectionList->Str1); + free (mGlobals.IndirectionList->Str2); + free (mGlobals.IndirectionList); + mGlobals.IndirectionList = mGlobals.LastIndirectionList; + } + + while (mGlobals.IndirectionFileName != NULL) { + mGlobals.LastIndirectionFileName = mGlobals.IndirectionFileName->Next; + free (mGlobals.IndirectionFileName->Str); + free (mGlobals.IndirectionFileName); + mGlobals.IndirectionFileName = mGlobals.LastIndirectionFileName; + } +} + +static +BOOLEAN +IsValidIdentifierChar ( + INT8 Char, + BOOLEAN FirstChar + ) +{ + // + // If it's the first character of an identifier, then + // it must be one of [A-Za-z_]. + // + if (FirstChar) { + if (isalpha (Char) || (Char == '_')) { + return TRUE; + } + } else { + // + // If it's not the first character, then it can + // be one of [A-Za-z_0-9] + // + if (isalnum (Char) || (Char == '_')) { + return TRUE; + } + } + + return FALSE; +} + +static +void +RewindFile ( + SOURCE_FILE *SourceFile + ) +{ + SourceFile->LineNum = 1; + SourceFile->FileBufferPtr = SourceFile->FileBuffer; + SourceFile->EndOfFile = 0; +} + +static +BOOLEAN +SkipTo ( + SOURCE_FILE *SourceFile, + WCHAR WChar, + BOOLEAN StopAfterNewline + ) +{ + while (!EndOfFile (SourceFile)) { + // + // Check for the character of interest + // + if (SourceFile->FileBufferPtr[0] == WChar) { + return TRUE; + } else { + if (SourceFile->FileBufferPtr[0] == UNICODE_LF) { + SourceFile->LineNum++; + if (StopAfterNewline) { + SourceFile->FileBufferPtr++; + if (SourceFile->FileBufferPtr[0] == 0) { + SourceFile->FileBufferPtr++; + } + + return FALSE; + } + } + + SourceFile->FileBufferPtr++; + } + } + + return FALSE; +} + +static +void +Usage ( + VOID + ) +/*++ + +Routine Description: + + Print usage information for this utility. + +Arguments: + + None. + +Returns: + + Nothing. + +--*/ +{ + int Index; + static const char *Str[] = { + "", + PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file", + " Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]", + " "PROGRAM_NAME " -scan {scan options} [FileName]", + " "PROGRAM_NAME " -dump {dump options}", + " Common options include:", + " -h or -? for this help information", + " -db Database required name of output/input database file", + " -bn BaseName for use in the .h and .c output files", + " Default = "DEFAULT_BASE_NAME, + " -v for verbose output", + " -vdbw for verbose output when writing database", + " -vdbr for verbose output when reading database", + " -od FileName to specify an output database file name", + " Parse options include:", + " -i IncludePath add IncludePath to list of search paths", + " -dep FileName to specify an output dependency file name", + " -newdb to not read in existing database file", + " -uqs to indicate that unquoted strings are used", + " FileNames name of one or more unicode files to parse", + " Scan options include:", + " -scan scan text file(s) for STRING_TOKEN() usage", + " -skipext .ext to skip scan of files with .ext filename extension", + " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ", + " found in the database", + " FileNames one or more files to scan", + " Dump options include:", + " -oc FileName write string data to FileName", + " -oh FileName write string defines to FileName", + " -ou FileName dump database to unicode file FileName", + " -lang Lang only dump for the language 'Lang'", + " -if FileName to specify an indirection file", + " -hpk FileName to create an HII export pack of the strings", + "", + " The expected process is to parse a unicode string file to create an initial", + " database of string identifier names and string definitions. Then text files", + " should be scanned for STRING_TOKEN() usages, and the referenced", + " strings will be tagged as used in the database. After all files have been", + " scanned, then the database should be dumped to create the necessary output", + " files.", + "", + NULL + }; + for (Index = 0; Str[Index] != NULL; Index++) { + fprintf (stdout, "%s\n", Str[Index]); + } +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h new file mode 100644 index 0000000000..df175c2db6 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h @@ -0,0 +1,84 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StrGather.h + +Abstract: + + Common defines and prototypes for StrGather. + +--*/ + +#ifndef _STR_GATHER_H_ +#define _STR_GATHER_H_ + +#define MALLOC(size) malloc (size) +#define FREE(ptr) free (ptr) + +#define PROGRAM_NAME "StrGather" + +typedef CHAR16 WCHAR; + +#define UNICODE_TO_ASCII(w) (INT8) ((w) & 0xFF) +#define ASCII_TO_UNICODE(a) (WCHAR) ((UINT8) (a)) + +#define UNICODE_HASH L'#' +#define UNICODE_BACKSLASH L'\\' +#define UNICODE_SLASH L'/' +#define UNICODE_EQUAL_SIGN L'=' +#define UNICODE_PLUS_SIGN L'+' + +#define UNICODE_FILE_START 0xFEFF +#define UNICODE_CR 0x000D +#define UNICODE_LF 0x000A +#define UNICODE_NULL 0x0000 +#define UNICODE_SPACE L' ' +#define UNICODE_SLASH L'/' +#define UNICODE_DOUBLE_QUOTE L'"' +#define UNICODE_Z L'Z' +#define UNICODE_z L'z' +#define UNICODE_A L'A' +#define UNICODE_a L'a' +#define UNICODE_F L'F' +#define UNICODE_f L'f' +#define UNICODE_UNDERSCORE L'_' +#define UNICODE_0 L'0' +#define UNICODE_9 L'9' +#define UNICODE_TAB L'\t' +#define UNICODE_NBR_STRING L"\\nbr" +#define UNICODE_BR_STRING L"\\br" +#define UNICODE_WIDE_STRING L"\\wide" +#define UNICODE_NARROW_STRING L"\\narrow" + +// +// This is the length of a valid string identifier +// +#define LANGUAGE_IDENTIFIER_NAME_LEN 3 + +typedef struct _TEXT_STRING_LIST { + struct _TEXT_STRING_LIST *Next; + UINT8 *Str; +} TEXT_STRING_LIST; + +typedef struct _WCHAR_STRING_LIST { + struct _WCHAR_STRING_LIST *Next; + WCHAR *Str; +} WCHAR_STRING_LIST; + +typedef struct _WCHAR_MATCHING_STRING_LIST { + struct _WCHAR_MATCHING_STRING_LIST *Next; + WCHAR *Str1; + WCHAR *Str2; +} WCHAR_MATCHING_STRING_LIST; + +#endif // #ifndef _STR_GATHER_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c new file mode 100644 index 0000000000..8fa01e80ab --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c @@ -0,0 +1,2808 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StringDB.c + +Abstract: + + String database implementation + +--*/ + +#include +#include +#include +#include // for tolower() +#include "Tiano.h" +#include "EfiUtilityMsgs.h" +#include "StrGather.h" +#include "StringDb.h" +#include "EfiInternalFormRepresentation.h" + +#include EFI_PROTOCOL_DEFINITION (Hii) + +typedef CHAR16 WCHAR; +#define STRING_OFFSET RELOFST + +#define STRING_DB_KEY (('S' << 24) | ('D' << 16) | ('B' << 8) | 'K') +// +// Version supported by this tool +// +#define STRING_DB_VERSION 0x00010000 + +#define STRING_DB_MAJOR_VERSION_MASK 0xFFFF0000 +#define STRING_DB_MINOR_VERSION_MASK 0x0000FFFF + +#define DEFINE_STR L"// #define" + +#define LANGUAGE_CODE_WIDTH 4 +// +// This is the header that gets written to the top of the +// output binary database file. +// +typedef struct { + UINT32 Key; + UINT32 HeaderSize; + UINT32 Version; + UINT32 NumStringIdenfiers; + UINT32 StringIdentifiersSize; + UINT32 NumLanguages; +} STRING_DB_HEADER; + +// +// When we write out data to the database, we have a UINT16 identifier, which +// indicates what follows, followed by the data. Here's the structure. +// +typedef struct { + UINT16 DataType; + UINT16 Reserved; +} DB_DATA_ITEM_HEADER; + +#define DB_DATA_TYPE_INVALID 0x0000 +#define DB_DATA_TYPE_STRING_IDENTIFIER 0x0001 +#define DB_DATA_TYPE_LANGUAGE_DEFINITION 0x0002 +#define DB_DATA_TYPE_STRING_DEFINITION 0x0003 +#define DB_DATA_TYPE_LAST DB_DATA_TYPE_STRING_DEFINITION + +// +// We have to keep track of a list of languages, each of which has its own +// list of strings. Define a structure to keep track of all languages and +// their list of strings. +// +typedef struct _STRING_LIST { + struct _STRING_LIST *Next; + UINT32 Size; // number of bytes in string, including null terminator + WCHAR *LanguageName; + WCHAR *StringName; // for example STR_ID_TEXT1 + WCHAR *Scope; // + WCHAR *Str; // the actual string + UINT16 Flags; // properties of this string (used, undefined) +} STRING_LIST; + +typedef struct _LANGUAGE_LIST { + struct _LANGUAGE_LIST *Next; + WCHAR LanguageName[4]; + WCHAR *PrintableLanguageName; + STRING_LIST *String; + STRING_LIST *LastString; +} LANGUAGE_LIST; + +// +// We also keep track of all the string identifier names, which we assign unique +// values to. Create a structure to keep track of them all. +// +typedef struct _STRING_IDENTIFIER { + struct _STRING_IDENTIFIER *Next; + UINT32 Index; // only need 16 bits, but makes it easier with UINT32 + WCHAR *StringName; + UINT16 Flags; // if someone referenced it via STRING_TOKEN() +} STRING_IDENTIFIER; +// +// Keep our globals in this structure to be as modular as possible. +// +typedef struct { + FILE *StringDBFptr; + LANGUAGE_LIST *LanguageList; + LANGUAGE_LIST *LastLanguageList; + LANGUAGE_LIST *CurrentLanguage; // keep track of the last language they used + STRING_IDENTIFIER *StringIdentifier; + STRING_IDENTIFIER *LastStringIdentifier; + UINT8 *StringDBFileName; + UINT32 NumStringIdentifiers; + UINT32 NumStringIdentifiersReferenced; + STRING_IDENTIFIER *CurrentStringIdentifier; // keep track of the last string identifier they added + WCHAR *CurrentScope; +} STRING_DB_DATA; + +static STRING_DB_DATA mDBData; + +static const char *mSourceFileHeader[] = { + "//", + "// DO NOT EDIT -- auto-generated file", + "//", + "// This file is generated by the string gather utility", + "//", + NULL +}; + +static +STRING_LIST * +StringDBFindString ( + WCHAR *LanguageName, + WCHAR *StringName, + WCHAR *Scope, + WCHAR_STRING_LIST *LanguagesOfInterest, + WCHAR_MATCHING_STRING_LIST *IndirectionList + ); + +static +STRING_IDENTIFIER * +StringDBFindStringIdentifierByName ( + WCHAR *Name + ); + +static +STRING_IDENTIFIER * +StringDBFindStringIdentifierByIndex ( + UINT32 Index + ); + +static +LANGUAGE_LIST * +StringDBFindLanguageList ( + WCHAR *LanguageName + ); + +static +void +StringDBWriteStandardFileHeader ( + FILE *OutFptr + ); + +static +WCHAR * +AsciiToWchar ( + INT8 *Str + ); + +static +WCHAR * +DuplicateString ( + WCHAR *Str + ); + +static +STATUS +StringDBWriteStringIdentifier ( + FILE *DBFptr, + UINT16 StringId, + UINT16 Flags, + WCHAR *IdentifierName + ); + +static +STATUS +StringDBReadStringIdentifier ( + FILE *DBFptr + ); + +static +STATUS +StringDBWriteLanguageDefinition ( + FILE *DBFptr, + WCHAR *LanguageName, + WCHAR *PrintableLanguageName + ); + +static +STATUS +StringDBReadLanguageDefinition ( + FILE *DBFptr + ); + +static +STATUS +StringDBWriteString ( + FILE *DBFptr, + UINT16 Flags, + WCHAR *Language, + WCHAR *StringName, + WCHAR *Scope, + WCHAR *Str + ); + +static +STATUS +StringDBReadString ( + FILE *DBFptr + ); + +static +STATUS +StringDBReadGenericString ( + FILE *DBFptr, + UINT16 *Size, + WCHAR **Str + ); + +static +STATUS +StringDBWriteGenericString ( + FILE *DBFptr, + WCHAR *Str + ); + +static +void +StringDBAssignStringIndexes ( + VOID + ); + +/*****************************************************************************/ + +/*++ + +Routine Description: + Constructor function for the string database handler. + +Arguments: + None. + +Returns: + None. + +--*/ +void +StringDBConstructor ( + VOID + ) +{ + memset ((char *) &mDBData, 0, sizeof (STRING_DB_DATA)); + mDBData.CurrentScope = DuplicateString (L"NULL"); +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + Destructor function for the string database handler. + +Arguments: + None. + +Returns: + None. + +--*/ +void +StringDBDestructor ( + VOID + ) +{ + LANGUAGE_LIST *NextLang; + STRING_LIST *NextStr; + STRING_IDENTIFIER *NextIdentifier; + // + // Close the database file if it's open + // + if (mDBData.StringDBFptr != NULL) { + fclose (mDBData.StringDBFptr); + mDBData.StringDBFptr = NULL; + } + // + // If we've allocated any strings/languages, free them up + // + while (mDBData.LanguageList != NULL) { + NextLang = mDBData.LanguageList->Next; + // + // Free up all strings for this language + // + while (mDBData.LanguageList->String != NULL) { + NextStr = mDBData.LanguageList->String->Next; + FREE (mDBData.LanguageList->String->Str); + FREE (mDBData.LanguageList->String); + mDBData.LanguageList->String = NextStr; + } + + FREE (mDBData.LanguageList->PrintableLanguageName); + FREE (mDBData.LanguageList); + mDBData.LanguageList = NextLang; + } + // + // Free up string identifiers + // + while (mDBData.StringIdentifier != NULL) { + NextIdentifier = mDBData.StringIdentifier->Next; + FREE (mDBData.StringIdentifier->StringName); + FREE (mDBData.StringIdentifier); + mDBData.StringIdentifier = NextIdentifier; + } + // + // Free the filename + // + if (mDBData.StringDBFileName != NULL) { + FREE (mDBData.StringDBFileName); + mDBData.StringDBFileName = NULL; + } + // + // We save a copy of the scope, so free it up if we + // have one. + // + if (mDBData.CurrentScope != NULL) { + FREE (mDBData.CurrentScope); + mDBData.CurrentScope = NULL; + } +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Dump the contents of a database to an output C file. + +Arguments: + + FileName - name of the output file to write + BaseName - used for the name of the C array defined + Languages - list of languages of interest + +Returns: + + STATUS + +Notes: + + Languages is a pointer to a linked list of languages specified on + the command line. Format is "eng" and "spa+cat". For this, print + the strings for eng. Print the strings for spa too, but if one is + missing look for a cat string and print if it it exists. + +--*/ +STATUS +StringDBDumpCStrings ( + INT8 *FileName, + INT8 *BaseName, + WCHAR_STRING_LIST *LanguagesOfInterest, + WCHAR_MATCHING_STRING_LIST *IndirectionList + ) +{ + FILE *Fptr; + LANGUAGE_LIST *Lang; + STRING_LIST *CurrString; + STRING_LIST EmptyString; + UINT32 Offset; + UINT32 StringIndex; + UINT32 TempIndex; + UINT32 BytesThisLine; + EFI_HII_STRING_PACK_HEADER StringPack; + UINT8 *Ptr; + UINT32 Len; + WCHAR ZeroString[1]; + WCHAR_STRING_LIST *LOIPtr; + BOOLEAN LanguageOk; + WCHAR *TempStringPtr; + WCHAR *LangName; + STRING_IDENTIFIER *StringIdentifier; + + if ((Fptr = fopen (FileName, "w")) == NULL) { + Error (NULL, 0, 0, FileName, "failed to open output C string file"); + return STATUS_ERROR; + } + // + // Assign index values to the string identifiers + // + StringDBAssignStringIndexes (); + // + // Write the standard header to the output file, then the structure + // definition header. + // + StringDBWriteStandardFileHeader (Fptr); + fprintf (Fptr, "\nunsigned char %s[] = {\n", BaseName); + // + // If a given string is not defined, then we'll use this one. + // + memset (&EmptyString, 0, sizeof (EmptyString)); + EmptyString.Size = sizeof (ZeroString); + EmptyString.Str = ZeroString; + // + // Process each language, then each string for each langage + // + ZeroString[0] = 0; + for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) { + // + // If we have a language list, then make sure this language is in that + // list. + // + LanguageOk = TRUE; + LangName = Lang->LanguageName; + if (LanguagesOfInterest != NULL) { + LanguageOk = FALSE; + for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) { + if (wcsncmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) { + LangName = LOIPtr->Str; + LanguageOk = TRUE; + break; + } + } + } + + if (!LanguageOk) { + continue; + } + // + // Process each string for this language. We have to make 3 passes on the strings: + // Pass1: computes sizes and fill in the string pack header + // Pass2: write the array of offsets + // Pass3: write the strings + // + // + // PASS 1: Fill in and print the HII string pack header + // + // Compute the size for this language package and write + // the header out. Each string package contains: + // Header + // Offset[] -- an array of offsets to strings, of type RELOFST each + // String[] -- the actual strings themselves + // + fprintf ( + Fptr, + "\n//******************************************************************************" + "\n// Start of string definitions for %S/%S", + Lang->LanguageName, + Lang->PrintableLanguageName + ); + memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER)); + StringPack.Header.Type = EFI_HII_STRING; + StringPack.NumStringPointers = (UINT16) mDBData.NumStringIdentifiersReferenced; + // + // First string is the language name. If we're printing all languages, then + // it's just the "spa". If we were given a list of languages to print, then it's + // the "spacat" string. Compute its offset and fill in + // the info in the header. Since we know the language name string's length, + // and the printable language name follows it, use that info to fill in the + // entry for the printable language name as well. + // + StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK_HEADER) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET))); + StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (wcslen (LangName) + 1) * sizeof (WCHAR)); + // + // Add up the size of all strings so we can fill in our header. + // + Len = 0; + for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) { + // + // For the first string (language name), we print out the "spacat" if they + // requested it. We set LangName to point to the proper language name string above. + // + if (StringIndex == STRING_ID_LANGUAGE_NAME) { + Len += (wcslen (LangName) + 1) * sizeof (WCHAR); + } else { + // + // Find a string with this language.stringname + // + StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex); + if (StringIdentifier == NULL) { + Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex); + return STATUS_ERROR; + } + // + // Find a matching string if this string identifier was referenced + // + EmptyString.Flags = STRING_FLAGS_UNDEFINED; + CurrString = NULL; + if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) { + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, + LanguagesOfInterest, + IndirectionList + ); + if (NULL == CurrString) { + // + // If string for Lang->LanguageName is not found, try to get an English version + // + CurrString = StringDBFindString ( + L"eng", + StringIdentifier->StringName, + NULL, + LanguagesOfInterest, + IndirectionList + ); + } + } + + if (CurrString == NULL) { + CurrString = &EmptyString; + EmptyString.Flags |= StringIdentifier->Flags; + } + + Len += CurrString->Size; + } + } + StringPack.Header.Length = sizeof (EFI_HII_STRING_PACK_HEADER) + + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) + + Len; + // + // Write out the header one byte at a time + // + Ptr = (UINT8 *) &StringPack; + for (TempIndex = 0; TempIndex < sizeof (EFI_HII_STRING_PACK_HEADER); TempIndex++, Ptr++) { + if ((TempIndex & 0x07) == 0) { + fprintf (Fptr, "\n "); + } + + fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr); + } + + fprintf (Fptr, "\n // offset 0x%X\n", sizeof (StringPack)); + // + // PASS2 : write the offsets + // + // Traverse the list of strings again and write the array of offsets. The + // offset to the first string is the size of the string pack header + // plus the size of the offsets array. The other strings follow it. + // + StringIndex = 0; + Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET); + for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) { + // + // Write the offset, followed by a useful comment + // + fprintf (Fptr, " "); + Ptr = (UINT8 *) &Offset; + for (TempIndex = 0; TempIndex < sizeof (STRING_OFFSET); TempIndex++) { + fprintf (Fptr, "0x%02X, ", (UINT32) Ptr[TempIndex]); + } + // + // Find the string name + // + StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex); + if (StringIdentifier == NULL) { + Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex); + return STATUS_ERROR; + } + + fprintf (Fptr, " // offset to string %S (0x%04X)", StringIdentifier->StringName, StringIndex); + // + // For the first string (language name), we print out the "spacat" if they + // requested it. We set LangName to point to the proper language name string above. + // + if (StringIndex == STRING_ID_LANGUAGE_NAME) { + Offset += (wcslen (LangName) + 1) * sizeof (WCHAR); + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, // scope + NULL, + NULL + ); + } else { + // + // Find a matching string + // + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, // scope + LanguagesOfInterest, + IndirectionList + ); + + if (NULL == CurrString) { + CurrString = StringDBFindString ( + L"eng", + StringIdentifier->StringName, + NULL, // scope + LanguagesOfInterest, + IndirectionList + ); + } + + EmptyString.LanguageName = Lang->LanguageName; + if (CurrString == NULL) { + CurrString = &EmptyString; + EmptyString.Flags = STRING_FLAGS_UNDEFINED; + } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) { + CurrString = &EmptyString; + EmptyString.Flags = 0; + } + + Offset += CurrString->Size; + } + // + // Print useful info about this string + // + if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) { + fprintf (Fptr, " - not referenced"); + } + + if (CurrString->Flags & STRING_FLAGS_UNDEFINED) { + fprintf (Fptr, " - not defined for this language"); + } else if (wcscmp (CurrString->LanguageName, Lang->LanguageName) != 0) { + fprintf ( + Fptr, + " - not defined for this language -- using secondary language %S definition", + CurrString->LanguageName + ); + } + + fprintf (Fptr, "\n"); + } + // + // For unreferenced string identifiers, print a message that they are not referenced anywhere + // + while (StringIndex < mDBData.NumStringIdentifiers) { + StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex); + if (StringIdentifier != NULL) { + fprintf (Fptr, " // %S not referenced\n", StringIdentifier->StringName); + } + + StringIndex++; + } + + // + // PASS 3: write the strings themselves. + // Keep track of how many bytes we write per line because some editors + // (Visual Studio for instance) can't handle too long of lines. + // + Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET); + for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) { + StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex); + if (StringIdentifier == NULL) { + Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex); + return STATUS_ERROR; + } + + fprintf (Fptr, " // string %S offset 0x%08X\n ", StringIdentifier->StringName, Offset); + // + // For the first string (language name), we print out the "spacat" if they + // requested it. We set LangName to point to the proper language name string above. + // + if (StringIndex == STRING_ID_LANGUAGE_NAME) { + TempStringPtr = LangName; + } else { + // + // Find a matching string if this string identifier was referenced + // + CurrString = NULL; + if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) { + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, // scope + LanguagesOfInterest, + IndirectionList + ); + if (NULL == CurrString) { + CurrString = StringDBFindString ( + L"eng", + StringIdentifier->StringName, + NULL, // scope + LanguagesOfInterest, + IndirectionList + ); + } + } + + if (CurrString == NULL) { + CurrString = &EmptyString; + } + + TempStringPtr = CurrString->Str; + } + + BytesThisLine = 0; + for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) { + fprintf ( + Fptr, + "0x%02X, 0x%02X, ", + (UINT32) TempStringPtr[TempIndex] & 0xFF, + (UINT32) ((TempStringPtr[TempIndex] >> 8) & 0xFF) + ); + BytesThisLine += 2; + Offset += 2; + // + // Let's say we only allow 14 per line + // + if (BytesThisLine > 14) { + fprintf (Fptr, "\n "); + BytesThisLine = 0; + } + } + // + // Print NULL WCHAR at the end of this string. + // + fprintf (Fptr, "0x00, 0x00,\n"); + Offset += 2; + } + // + // Sanity check the offset. Make sure our running offset is what we put in the + // string pack header. + // + if (StringPack.Header.Length != Offset) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "stringpack size 0x%X does not match final size 0x%X", + StringPack.Header.Length, + Offset + ); + } + } + // + // Print terminator string pack, closing brace and close the file. + // The size of 0 triggers to the consumer that this is the end. + // + memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER)); + StringPack.Header.Type = EFI_HII_STRING; + Ptr = (UINT8 *) &StringPack; + fprintf (Fptr, "\n // strings terminator pack"); + for (TempIndex = 0; TempIndex < sizeof (StringPack); TempIndex++, Ptr++) { + if ((TempIndex & 0x0F) == 0) { + fprintf (Fptr, "\n "); + } + + fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr); + } + + fprintf (Fptr, "\n};\n"); + fclose (Fptr); + return STATUS_SUCCESS; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Dump the #define string names + +Arguments: + + FileName - name of the output file to write + BaseName - used for the protection #ifndef/#endif + +Returns: + + STATUS + +--*/ +STATUS +StringDBDumpStringDefines ( + INT8 *FileName, + INT8 *BaseName + ) +{ + FILE *Fptr; + STRING_IDENTIFIER *Identifier; + INT8 CopyBaseName[100]; + UINT32 Index; + const INT8 *StrDefHeader[] = { + "#ifndef _%s_STRINGS_DEFINE_H_\n", + "#define _%s_STRINGS_DEFINE_H_\n\n", + NULL + }; + + if ((Fptr = fopen (FileName, "w")) == NULL) { + Error (NULL, 0, 0, FileName, "failed to open output string defines file"); + return STATUS_ERROR; + } + // + // Get the base source filename and convert to uppercase. + // + if (sizeof (CopyBaseName) <= strlen (BaseName) + 1) { + Error (NULL, 0, 0, "application error", "StringDBDumpStringDefines() string length insufficient"); + return STATUS_ERROR; + } + + strcpy (CopyBaseName, BaseName); + for (Index = 0; CopyBaseName[Index] != 0; Index++) { + if (islower (CopyBaseName[Index])) { + CopyBaseName[Index] = (INT8) toupper (CopyBaseName[Index]); + } + } + // + // Assign index values to the string identifiers + // + StringDBAssignStringIndexes (); + // + // Write the standard header to the output file, and then the + // protective #ifndef. + // + StringDBWriteStandardFileHeader (Fptr); + for (Index = 0; StrDefHeader[Index] != NULL; Index++) { + fprintf (Fptr, StrDefHeader[Index], CopyBaseName); + } + // + // Print all the #defines for the string identifiers. Print identifiers + // whose names start with '$' as comments. Add comments for string + // identifiers not used as well. + // + Identifier = mDBData.StringIdentifier; + while (Identifier != NULL) { + if (Identifier->StringName[0] == L'$') { + fprintf (Fptr, "// "); + } + + if (Identifier->Flags & STRING_FLAGS_REFERENCED) { + fprintf (Fptr, "#define %-40S 0x%04X\n", Identifier->StringName, Identifier->Index); + } else { + fprintf (Fptr, "//#define %-40S 0x%04X // not referenced\n", Identifier->StringName, Identifier->Index); + } + + Identifier = Identifier->Next; + } + + fprintf (Fptr, "\n#endif\n"); + fclose (Fptr); + return STATUS_SUCCESS; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Add a string identifier to the database. + +Arguments: + + StringName - name of the string identifier. For example "STR_MY_STRING" + NewId - if an ID has been assigned + Flags - characteristics for the identifier + +Returns: + + STATUS + +--*/ +STATUS +StringDBAddStringIdentifier ( + WCHAR *StringName, + UINT16 *NewId, + UINT16 Flags + ) +{ + STRING_IDENTIFIER *StringIdentifier; + STATUS Status; + // + // If it was already used for some other language, then we don't + // need to add it. But set it to the current string identifier. + // The referenced bit is sticky. + // + Status = STATUS_SUCCESS; + StringIdentifier = StringDBFindStringIdentifierByName (StringName); + if (StringIdentifier != NULL) { + if (Flags & STRING_FLAGS_REFERENCED) { + StringIdentifier->Flags |= STRING_FLAGS_REFERENCED; + } + + mDBData.CurrentStringIdentifier = StringIdentifier; + *NewId = (UINT16) StringIdentifier->Index; + return Status; + } + + StringIdentifier = (STRING_IDENTIFIER *) MALLOC (sizeof (STRING_IDENTIFIER)); + if (StringIdentifier == NULL) { + Error (NULL, 0, 0, NULL, "memory allocation error"); + return STATUS_ERROR; + } + + memset ((char *) StringIdentifier, 0, sizeof (STRING_IDENTIFIER)); + StringIdentifier->StringName = (WCHAR *) malloc ((wcslen (StringName) + 1) * sizeof (WCHAR)); + if (StringIdentifier->StringName == NULL) { + Error (NULL, 0, 0, NULL, "memory allocation error"); + return STATUS_ERROR; + } + + wcscpy (StringIdentifier->StringName, StringName); + if (*NewId != STRING_ID_INVALID) { + StringIdentifier->Index = *NewId; + StringIdentifier->Flags |= STRING_FLAGS_INDEX_ASSIGNED; + if (mDBData.NumStringIdentifiers <= StringIdentifier->Index) { + mDBData.NumStringIdentifiers = StringIdentifier->Index + 1; + } + } else { + StringIdentifier->Index = mDBData.NumStringIdentifiers++; + } + + StringIdentifier->Flags |= Flags; + // + // Add it to our list of string identifiers + // + if (mDBData.StringIdentifier == NULL) { + mDBData.StringIdentifier = StringIdentifier; + } else { + mDBData.LastStringIdentifier->Next = StringIdentifier; + } + + mDBData.LastStringIdentifier = StringIdentifier; + mDBData.CurrentStringIdentifier = StringIdentifier; + *NewId = (UINT16) StringIdentifier->Index; + return Status; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Add a new string to the database. + +Arguments: + + LanguageName - "eng" or "spa" language name + StringName - "STR_MY_TEXT" string name + Scope - from the #scope statements in the string file + Format - if we should format the string + Flags - characteristic flags for the string + +Returns: + + STATUS + +Notes: + + Several of the fields can be "inherited" from the previous calls to + our database functions. For example, if scope is NULL here, then + we'll use the previous setting. + +--*/ +STATUS +StringDBAddString ( + WCHAR *LanguageName, + WCHAR *StringName, + WCHAR *Scope, + WCHAR *String, + BOOLEAN Format, + UINT16 Flags + ) +{ + LANGUAGE_LIST *Lang; + UINT32 Size; + STRING_LIST *Str; + UINT16 StringIndex; + WCHAR TempLangName[4]; + STRING_IDENTIFIER *StringIdentifier; + + // + // Check that language name is exactly 3 characters, or emit an error. + // Truncate at 3 if it's longer, or make it 3 if it's shorter. + // + if (LanguageName != NULL) { + Size = wcslen (LanguageName); + if (Size != 3) { + ParserError (0, "invalid length for language name", "%S", LanguageName); + if (Size > 3) { + LanguageName[3] = 0; + } else { + // + // Make a local copy of the language name string, and extend to + // 3 characters since we make assumptions elsewhere in this program + // on the length. + // + wcscpy (TempLangName, LanguageName); + for (; Size < 3; Size++) { + TempLangName[Size] = L'?'; + } + + TempLangName[3] = 0; + LanguageName = TempLangName; + } + } + } + // + // If they specified a language, make sure they've defined it already + // via a #langdef statement. Otherwise use the current default language. + // + if (LanguageName != NULL) { + Lang = StringDBFindLanguageList (LanguageName); + if (Lang == NULL) { + ParserError (0, "language not defined", "%S", LanguageName); + return STATUS_ERROR; + } else { + StringDBSetCurrentLanguage (LanguageName); + } + } else { + Lang = mDBData.CurrentLanguage; + if (Lang == NULL) { + // + // Have to call SetLanguage() first + // + ParserError (0, "no language defined", "%S", StringName); + return STATUS_ERROR; + } + } + // + // If they didn't define a string identifier, use the last string identifier + // added. + // + if (StringName == NULL) { + StringName = mDBData.CurrentStringIdentifier->StringName; + if (StringName == NULL) { + ParserError (0, "no string identifier previously specified", NULL); + return STATUS_ERROR; + } + } + // + // If scope was not specified, use the default setting + // + if (Scope != NULL) { + Scope = DuplicateString (Scope); + } else { + Scope = DuplicateString (mDBData.CurrentScope); + } + // + // printf ("Adding string: %S.%S.%S\n", Lang->LanguageName, StringName, Scope); + // + // Check for duplicates for this Language.StringName.Scope. Allow multiple + // definitions of the language name and printable language name, since the + // user does not specifically define them. + // + if (StringDBFindString (Lang->LanguageName, StringName, Scope, NULL, NULL) != NULL) { + if ((wcscmp (StringName, LANGUAGE_NAME_STRING_NAME) == 0) && + (wcscmp (StringName, PRINTABLE_LANGUAGE_NAME_STRING_NAME) == 0) + ) { + ParserError ( + 0, + "string multiply defined", + "Language.Name.Scope = %S.%S.%S", + Lang->LanguageName, + StringName, + Scope + ); + return STATUS_ERROR; + } + } + + StringIndex = STRING_ID_INVALID; + if (StringDBAddStringIdentifier (StringName, &StringIndex, Flags) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + StringIdentifier = StringDBFindStringIdentifierByName (StringName); + // + // Add this string to the end of the strings for this language. + // + Str = (STRING_LIST *) malloc (sizeof (STRING_LIST)); + if (Str == NULL) { + Error (NULL, 0, 0, NULL, "memory allocation error"); + return STATUS_ERROR; + } + + memset ((char *) Str, 0, sizeof (STRING_LIST)); + Size = (wcslen (String) + 1) * sizeof (WCHAR); + Str->Flags = Flags; + Str->Scope = Scope; + Str->StringName = StringIdentifier->StringName; + Str->LanguageName = DuplicateString (LanguageName); + Str->Str = (WCHAR *) MALLOC (Size); + if (Str->Str == NULL) { + Error (NULL, 0, 0, NULL, "memory allocation error"); + return STATUS_ERROR; + } + // + // If not formatting, just copy the string. + // + wcscpy (Str->Str, String); + if (Format) { + StringDBFormatString (Str->Str); + } + // + // Size may change after formatting. We set the size to + // the actual size of the string, including the null for + // easier processing later. + // + Str->Size = (wcslen (Str->Str) + 1) * sizeof (WCHAR); + if (Lang->String == NULL) { + Lang->String = Str; + } else { + Lang->LastString->Next = Str; + } + + Lang->LastString = Str; + return STATUS_SUCCESS; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Given a language name, see if a language list for it has been defined + +Arguments: + + LanguageName - like "eng" + +Returns: + + A pointer to the language list + +--*/ +static +LANGUAGE_LIST * +StringDBFindLanguageList ( + WCHAR *LanguageName + ) +{ + LANGUAGE_LIST *Lang; + + Lang = mDBData.LanguageList; + while (Lang != NULL) { + if (wcscmp (LanguageName, Lang->LanguageName) == 0) { + break; + } + + Lang = Lang->Next; + } + + return Lang; +} + +/*****************************************************************************/ +STATUS +StringDBSetCurrentLanguage ( + WCHAR *LanguageName + ) +{ + LANGUAGE_LIST *Lang; + + Lang = StringDBFindLanguageList (LanguageName); + if (Lang == NULL) { + ParserError (0, "language not previously defined", "%S", LanguageName); + return STATUS_ERROR; + } + + mDBData.CurrentLanguage = Lang; + return STATUS_SUCCESS; +} + +/*****************************************************************************/ +STATUS +StringDBAddLanguage ( + WCHAR *LanguageName, + WCHAR *PrintableLanguageName + ) +{ + LANGUAGE_LIST *Lang; + // + // Check for redefinitions + // + Lang = StringDBFindLanguageList (LanguageName); + if (Lang != NULL) { + // + // Better be the same printable name + // + if (wcscmp (PrintableLanguageName, Lang->PrintableLanguageName) != 0) { + ParserError ( + 0, + "language redefinition", + "%S:%S != %S:%S", + Lang->LanguageName, + Lang->PrintableLanguageName, + LanguageName, + PrintableLanguageName + ); + return STATUS_ERROR; + // + // } else { + // ParserWarning (0, "benign language redefinition", "%S", PrintableLanguageName); + // return STATUS_WARNING; + // + } + } else { + // + // Allocate memory to keep track of this new language + // + Lang = (LANGUAGE_LIST *) malloc (sizeof (LANGUAGE_LIST)); + if (Lang == NULL) { + Error (NULL, 0, 0, NULL, "memory allocation error"); + return STATUS_ERROR; + } + + memset ((char *) Lang, 0, sizeof (LANGUAGE_LIST)); + // + // Save the language name, then allocate memory to save the + // printable language name + // + Lang->LanguageName[3] = 0; + wcsncpy (Lang->LanguageName, LanguageName, 3); + Lang->PrintableLanguageName = (WCHAR *) malloc ((wcslen (PrintableLanguageName) + 1) * sizeof (WCHAR)); + if (Lang->PrintableLanguageName == NULL) { + Error (NULL, 0, 0, NULL, "memory allocation error"); + return STATUS_ERROR; + } + + wcscpy (Lang->PrintableLanguageName, PrintableLanguageName); + + if (mDBData.LanguageList == NULL) { + mDBData.LanguageList = Lang; + } else { + mDBData.LastLanguageList->Next = Lang; + } + + mDBData.LastLanguageList = Lang; + } + // + // Default is to make our active language this new one + // + StringDBSetCurrentLanguage (LanguageName); + // + // The first two strings for any language are the language name, + // followed by the printable language name. Add them and set them + // to referenced so they never get stripped out. + // + StringDBAddString ( + LanguageName, + LANGUAGE_NAME_STRING_NAME, + NULL, + LanguageName, + FALSE, + STRING_FLAGS_REFERENCED + ); + StringDBAddString ( + LanguageName, + PRINTABLE_LANGUAGE_NAME_STRING_NAME, + NULL, + PrintableLanguageName, + FALSE, + STRING_FLAGS_REFERENCED + ); + return STATUS_SUCCESS; +} + +/*****************************************************************************/ +static +STRING_IDENTIFIER * +StringDBFindStringIdentifierByName ( + WCHAR *StringName + ) +{ + STRING_IDENTIFIER *Identifier; + + Identifier = mDBData.StringIdentifier; + while (Identifier != NULL) { + if (wcscmp (StringName, Identifier->StringName) == 0) { + return Identifier; + } + + Identifier = Identifier->Next; + } + + return NULL; +} + +static +STRING_IDENTIFIER * +StringDBFindStringIdentifierByIndex ( + UINT32 StringIndex + ) +{ + STRING_IDENTIFIER *Identifier; + + Identifier = mDBData.StringIdentifier; + while (Identifier != NULL) { + if (Identifier->Index == StringIndex) { + return Identifier; + } + + Identifier = Identifier->Next; + } + + return NULL; +} + +/*****************************************************************************/ +static +void +StringDBWriteStandardFileHeader ( + FILE *OutFptr + ) +{ + UINT32 TempIndex; + for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) { + fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]); + } +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Given a Unicode string from an input file, reformat the string to replace + backslash control sequences with the appropriate encoding. + +Arguments: + + String - pointer to string to reformat + +Returns: + + Nothing + +--*/ +void +StringDBFormatString ( + WCHAR *String + ) +{ + WCHAR *From; + WCHAR *To; + int HexNibbles; + WCHAR HexValue; + // + // Go through the string and process any formatting characters + // + From = String; + To = String; + while (*From) { + if (*From == UNICODE_BACKSLASH) { + // + // First look for \wide and replace with the appropriate control character. Note that + // when you have "define STR L"ABC"", then sizeof(ABC) is 8 because the null char is + // counted. Make adjustments for this. We advance From below, so subtract 2 each time. + // + if (wcsncmp (From, UNICODE_WIDE_STRING, sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 1) == 0) { + *To = WIDE_CHAR; + From += sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 2; + } else if (wcsncmp (From, UNICODE_NARROW_STRING, sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 1) == 0) { + // + // Found: \narrow + // + *To = NARROW_CHAR; + From += sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 2; + } else if (wcsncmp (From, UNICODE_NBR_STRING, sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 1) == 0) { + // + // Found: \nbr + // + *To = NON_BREAKING_CHAR; + From += sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 2; + } else if (wcsncmp (From, UNICODE_BR_STRING, sizeof (UNICODE_BR_STRING) / sizeof (WCHAR) - 1) == 0) { + // + // Found: \br -- pass through untouched + // + *To = *From; + } else { + // + // Standard one-character control sequences such as \n, \r, \\, or \x + // + From++; + switch (*From) { + case ASCII_TO_UNICODE ('n'): + *To = UNICODE_CR; + To++; + *To = UNICODE_LF; + break; + + // + // carriage return + // + case ASCII_TO_UNICODE ('r'): + *To = UNICODE_CR; + break; + + // + // backslash + // + case UNICODE_BACKSLASH: + *To = UNICODE_BACKSLASH; + break; + + // + // Tab + // + case ASCII_TO_UNICODE ('t'): + *To = UNICODE_TAB; + break; + + // + // embedded double-quote + // + case UNICODE_DOUBLE_QUOTE: + *To = UNICODE_DOUBLE_QUOTE; + break; + + // + // Hex Unicode character \x1234. We'll process up to 4 hex characters + // + case ASCII_TO_UNICODE ('x'): + HexValue = 0; + for (HexNibbles = 0; HexNibbles < 4; HexNibbles++) { + if ((From[1] >= UNICODE_0) && (From[1] <= UNICODE_9)) { + HexValue = (HexValue << 4) | (From[1] - UNICODE_0); + } else if ((From[1] >= UNICODE_a) && (From[1] <= UNICODE_f)) { + HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_a); + } else if ((From[1] >= UNICODE_A) && (From[1] <= UNICODE_F)) { + HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_A); + } else { + break; + } + + From++; + } + + if (HexNibbles == 0) { + ParserWarning ( + 0, + "expected at least one valid hex digit with \\x escaped character in string", + "\\%C", + *From + ); + } else { + *To = HexValue; + } + break; + + default: + *To = UNICODE_SPACE; + ParserWarning (0, "invalid escaped character in string", "\\%C", *From); + break; + } + } + } else { + *To = *From; + } + + From++; + To++; + } + + *To = 0; +} + +/*****************************************************************************/ +STATUS +StringDBReadDatabase ( + INT8 *DBFileName, + BOOLEAN IgnoreIfNotExist, + BOOLEAN Verbose + ) +{ + STRING_DB_HEADER DbHeader; + STATUS Status; + FILE *DBFptr; + DB_DATA_ITEM_HEADER DataItemHeader; + + Status = STATUS_SUCCESS; + DBFptr = NULL; + // + // if (Verbose) { + // fprintf (stdout, "Reading database file %s\n", DBFileName); + // } + // + // Try to open the input file + // + if ((DBFptr = fopen (DBFileName, "rb")) == NULL) { + if (IgnoreIfNotExist) { + return STATUS_SUCCESS; + } + + Error (NULL, 0, 0, DBFileName, "failed to open input database file for reading"); + return STATUS_ERROR; + } + // + // Read and verify the database header + // + if (fread ((void *) &DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr) != 1) { + Error (NULL, 0, 0, DBFileName, "failed to read header from database file"); + Status = STATUS_ERROR; + goto Finish; + } + + if (DbHeader.Key != STRING_DB_KEY) { + Error (NULL, 0, 0, DBFileName, "invalid header in database file"); + Status = STATUS_ERROR; + goto Finish; + } + + if ((DbHeader.Version & STRING_DB_MAJOR_VERSION_MASK) != (STRING_DB_VERSION & STRING_DB_MAJOR_VERSION_MASK)) { + Error (NULL, 0, 0, DBFileName, "incompatible database file version -- rebuild clean"); + Status = STATUS_ERROR; + goto Finish; + } + // + // Read remaining items + // + while (fread (&DataItemHeader, sizeof (DataItemHeader), 1, DBFptr) == 1) { + switch (DataItemHeader.DataType) { + case DB_DATA_TYPE_STRING_IDENTIFIER: + StringDBReadStringIdentifier (DBFptr); + break; + + case DB_DATA_TYPE_LANGUAGE_DEFINITION: + StringDBReadLanguageDefinition (DBFptr); + break; + + case DB_DATA_TYPE_STRING_DEFINITION: + StringDBReadString (DBFptr); + break; + + default: + Error ( + NULL, + 0, + 0, + "database corrupted", + "invalid data item type 0x%X at offset 0x%X", + (UINT32) DataItemHeader.DataType, + ftell (DBFptr) - sizeof (DataItemHeader) + ); + Status = STATUS_ERROR; + goto Finish; + } + } + +Finish: + if (DBFptr != NULL) { + fclose (DBFptr); + } + + return Status; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Write everything we know to the output database file. Write: + + Database header + String identifiers[] + StringPacks[] + +Arguments: + + DBFileName - name of the file to write to + Verbose - for debug purposes, print info messages along the way. + +Returns: + + STATUS + +--*/ +STATUS +StringDBWriteDatabase ( + INT8 *DBFileName, + BOOLEAN Verbose + ) +{ + STRING_DB_HEADER DbHeader; + UINT32 Counter; + UINT32 StrLen; + LANGUAGE_LIST *Lang; + STRING_IDENTIFIER *StringIdentifier; + STRING_LIST *StrList; + FILE *DBFptr; + + if (Verbose) { + fprintf (stdout, "Writing database %s\n", DBFileName); + } + + if ((DBFptr = fopen (DBFileName, "wb")) == NULL) { + Error (NULL, 0, 0, DBFileName, "failed to open output database file for writing"); + return STATUS_ERROR; + } + // + // Fill in and write the database header + // + memset (&DbHeader, 0, sizeof (STRING_DB_HEADER)); + DbHeader.HeaderSize = sizeof (STRING_DB_HEADER); + DbHeader.Key = STRING_DB_KEY; + DbHeader.Version = STRING_DB_VERSION; + // + // Count the number of languages we have + // + for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) { + DbHeader.NumLanguages++; + } + // + // Count up how many string identifiers we have, and total up the + // size of the names plus the size of the flags field we will + // write out too. + // + DbHeader.NumStringIdenfiers = mDBData.NumStringIdentifiers; + StringIdentifier = mDBData.StringIdentifier; + for (Counter = 0; Counter < mDBData.NumStringIdentifiers; Counter++) { + StrLen = wcslen (StringIdentifier->StringName) + 1; + DbHeader.StringIdentifiersSize += StrLen * sizeof (WCHAR) + sizeof (StringIdentifier->Flags); + StringIdentifier = StringIdentifier->Next; + } + + // + // Write the header + // + fwrite (&DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr); + if (Verbose) { + fprintf (stdout, " Number of string identifiers 0x%04X\n", DbHeader.NumStringIdenfiers); + fprintf (stdout, " Number of languages %d\n", DbHeader.NumLanguages); + } + // + // Write the string identifiers + // + for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) { + StringDBWriteStringIdentifier ( + DBFptr, + (UINT16) StringIdentifier->Index, + StringIdentifier->Flags, + StringIdentifier->StringName + ); + } + // + // Now write all the strings for each language + // + for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) { + StringDBWriteLanguageDefinition (DBFptr, Lang->LanguageName, Lang->PrintableLanguageName); + for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) { + StringDBWriteString ( + DBFptr, + StrList->Flags, + Lang->LanguageName, + StrList->StringName, + StrList->Scope, + StrList->Str + ); + } + } + + fclose (DBFptr); + return STATUS_SUCCESS; +} + +STATUS +StringDBSetStringReferenced ( + INT8 *StringIdentifierName, + BOOLEAN IgnoreNotFound + ) +{ + STRING_IDENTIFIER *Id; + WCHAR *WName; + STATUS Status; + // + // See if it's already been defined. + // + Status = STATUS_SUCCESS; + WName = (WCHAR *) malloc ((strlen (StringIdentifierName) + 1) * sizeof (WCHAR)); +#ifdef USE_VC8 + swprintf (WName, (strlen (StringIdentifierName) + 1) * sizeof (WCHAR), L"%S", StringIdentifierName); +#else + swprintf (WName, L"%S", StringIdentifierName); +#endif + Id = StringDBFindStringIdentifierByName (WName); + if (Id != NULL) { + Id->Flags |= STRING_FLAGS_REFERENCED; + } else { + if (IgnoreNotFound == 0) { + ParserWarning (0, StringIdentifierName, "string identifier not found in database"); + Status = STATUS_WARNING; + } + } + + free (WName); + return Status; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Dump the contents of a database to an output unicode file. + +Arguments: + + DBFileName - name of the pre-existing database file to read + OutputFileName - name of the file to dump the database contents to + Verbose - for printing of additional info useful for debugging + +Returns: + + STATUS + +Notes: + + There's some issue with the unicode printing routines. Therefore to + write to the output file properly, open it as binary and use fwrite. + Ideally we could open it with just L"w" and use fwprintf(). + +--*/ +STATUS +StringDBDumpDatabase ( + INT8 *DBFileName, + INT8 *OutputFileName, + BOOLEAN Verbose + ) +{ + LANGUAGE_LIST *Lang; + STRING_IDENTIFIER *StringIdentifier; + STRING_LIST *StrList; + FILE *OutFptr; + WCHAR WChar; + WCHAR *WOutputFileName; + WCHAR CrLf[2]; + WCHAR Line[200]; + WCHAR *Scope; + // + // This function assumes the database has already been read, and + // we're just dumping our internal data structures to a unicode file. + // + if (Verbose) { + fprintf (stdout, "Dumping database file %s\n", DBFileName); + } + + WOutputFileName = AsciiToWchar (OutputFileName); + OutFptr = _wfopen (WOutputFileName, L"wb"); + free (WOutputFileName); + if (OutFptr == NULL) { + Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing"); + return STATUS_ERROR; + } + + WChar = UNICODE_FILE_START; + fwrite (&WChar, sizeof (WCHAR), 1, OutFptr); + CrLf[1] = UNICODE_LF; + CrLf[0] = UNICODE_CR; + // + // The default control character is '/'. Make it '#' by writing + // "/=#" to the output file. + // +#ifdef USE_VC8 + swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"/=#"); +#else + swprintf (Line, L"/=#"); +#endif + fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + // + // Dump all the string identifiers and their values + // + StringDBAssignStringIndexes (); + for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) { + // + // Write the "#define " string + // + if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) { +#ifdef USE_VC8 + swprintf ( + Line, + wcslen(Line) * sizeof (WCHAR), + L"%s %-60.60s 0x%04X", + DEFINE_STR, + StringIdentifier->StringName, + StringIdentifier->Index + ); +#else + swprintf ( + Line, + L"%s %-60.60s 0x%04X", + DEFINE_STR, + StringIdentifier->StringName, + StringIdentifier->Index + ); +#endif + } else { +#ifdef USE_VC8 + swprintf ( + Line, + wcslen(Line) * sizeof (WCHAR), + L"%s %-60.60s 0x%04X // NOT REFERENCED", + DEFINE_STR, + StringIdentifier->StringName, + StringIdentifier->Index + ); +#else + swprintf ( + Line, + L"%s %-60.60s 0x%04X // NOT REFERENCED", + DEFINE_STR, + StringIdentifier->StringName, + StringIdentifier->Index + ); +#endif + } + + fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + } + + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + // + // Now write all the strings for each language. + // + WChar = UNICODE_DOUBLE_QUOTE; + Scope = NULL; + for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) { + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); +#ifdef USE_VC8 + swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"#langdef %s \"%s\"", Lang->LanguageName, Lang->PrintableLanguageName); +#else + swprintf (Line, L"#langdef %s \"%s\"", Lang->LanguageName, Lang->PrintableLanguageName); +#endif + fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + // + // Now the strings (in double-quotes) for this language. Write + // #string STR_NAME #language eng "string" + // + for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) { + // + // Print the internal flags for debug + // +#ifdef USE_VC8 + swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"// flags=0x%02X", (UINT32) StrList->Flags); +#else + swprintf (Line, L"// flags=0x%02X", (UINT32) StrList->Flags); +#endif + fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + // + // Print the scope if changed + // + if ((Scope == NULL) || (wcscmp (Scope, StrList->Scope) != 0)) { +#ifdef USE_VC8 + swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"#scope %s", StrList->Scope); +#else + swprintf (Line, L"#scope %s", StrList->Scope); +#endif + fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + Scope = StrList->Scope; + } + +#ifdef USE_VC8 + swprintf ( + Line, + wcslen(Line) * sizeof (WCHAR), + L"#string %-50.50s #language %s \"", + StrList->StringName, + Lang->LanguageName + ); +#else + swprintf ( + Line, + L"#string %-50.50s #language %s \"", + StrList->StringName, + Lang->LanguageName + ); +#endif + fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr); + fwrite (StrList->Str, StrList->Size - sizeof (WCHAR), 1, OutFptr); +#ifdef USE_VC8 + swprintf (Line, wcslen(Line) * sizeof (WCHAR), L"\""); +#else + swprintf (Line, L"\""); +#endif + fwrite (Line, wcslen (Line) * sizeof (WCHAR), 1, OutFptr); + fwrite (&CrLf, sizeof (CrLf), 1, OutFptr); + } + } + + fclose (OutFptr); + return STATUS_SUCCESS; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Given a primary language, a string identifier number, and a list of + languages, find a secondary string. + +Arguments: + + LanguageName - primary language, like "spa" + StringId - string index value + LanguageList - linked list of "eng", "spa+cat",... + +Returns: + + Pointer to a secondary string if found. NULL otherwise. + +Notes: + + Given: LanguageName "spa" and LanguageList "spa+cat", match the + "spa" and extract the "cat" and see if there is a string defined + for "cat".StringId. + +--*/ +static +STATUS +StringDBWriteStringIdentifier ( + FILE *DBFptr, + UINT16 StringId, + UINT16 Flags, + WCHAR *IdentifierName + ) +{ + DB_DATA_ITEM_HEADER Hdr; + memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER)); + Hdr.DataType = DB_DATA_TYPE_STRING_IDENTIFIER; + if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write string to output database file", NULL); + return STATUS_ERROR; + } + + if (fwrite (&StringId, sizeof (StringId), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write StringId to output database", NULL); + return STATUS_ERROR; + } + + if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write StringId flags to output database", NULL); + return STATUS_ERROR; + } + + if (StringDBWriteGenericString (DBFptr, IdentifierName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} + +static +STATUS +StringDBReadStringIdentifier ( + FILE *DBFptr + ) +{ + WCHAR *IdentifierName; + UINT16 Flags; + UINT16 StringId; + UINT16 Size; + + if (fread (&StringId, sizeof (StringId), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to read StringId from database", NULL); + return STATUS_ERROR; + } + + if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to read StringId flags from database", NULL); + return STATUS_ERROR; + } + + if (StringDBReadGenericString (DBFptr, &Size, &IdentifierName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + StringDBAddStringIdentifier (IdentifierName, &StringId, Flags); + // + // printf ("STRID: 0x%04X %S\n", (UINT32)StringId, IdentifierName); + // + FREE (IdentifierName); + return STATUS_SUCCESS; +} + +static +STATUS +StringDBWriteString ( + FILE *DBFptr, + UINT16 Flags, + WCHAR *Language, + WCHAR *StringName, + WCHAR *Scope, + WCHAR *Str + ) +{ + DB_DATA_ITEM_HEADER Hdr; + memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER)); + Hdr.DataType = DB_DATA_TYPE_STRING_DEFINITION; + if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write string header to output database file", NULL); + return STATUS_ERROR; + } + + if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write string flags to output database", NULL); + return STATUS_ERROR; + } + + if (StringDBWriteGenericString (DBFptr, Language) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBWriteGenericString (DBFptr, StringName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBWriteGenericString (DBFptr, Scope) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBWriteGenericString (DBFptr, Str) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + // + // printf ("DBWriteString: %S.%S.%S\n", Language, StringName, Scope); + // + return STATUS_SUCCESS; +} + +static +STATUS +StringDBReadString ( + FILE *DBFptr + ) +{ + UINT16 Flags; + UINT16 Size; + WCHAR *Language; + WCHAR *StringName; + WCHAR *Scope; + WCHAR *Str; + + if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to read string flags from database", NULL); + return STATUS_ERROR; + } + + if (StringDBReadGenericString (DBFptr, &Size, &Language) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBReadGenericString (DBFptr, &Size, &StringName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBReadGenericString (DBFptr, &Size, &Scope) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBReadGenericString (DBFptr, &Size, &Str) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + // + // If the first or second string (language name and printable language name), + // then skip them. They're added via language definitions data items in + // the database. + // + if (StringName[0] != L'$') { + StringDBAddString (Language, StringName, Scope, Str, FALSE, Flags); + } + // + // printf ("DBReadString: %S.%S.%S\n", Language, StringName, Scope); + // + FREE (Language); + FREE (StringName); + if (Str != NULL) { + FREE (Str); + } + + if (Scope != NULL) { + FREE (Scope); + } + + return STATUS_SUCCESS; +} + +static +STATUS +StringDBWriteLanguageDefinition ( + FILE *DBFptr, + WCHAR *LanguageName, + WCHAR *PrintableLanguageName + ) +{ + DB_DATA_ITEM_HEADER Hdr; + memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER)); + Hdr.DataType = DB_DATA_TYPE_LANGUAGE_DEFINITION; + if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write string to output database file", NULL); + return STATUS_ERROR; + } + + if (StringDBWriteGenericString (DBFptr, LanguageName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBWriteGenericString (DBFptr, PrintableLanguageName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} + +static +STATUS +StringDBReadLanguageDefinition ( + FILE *DBFptr + ) +{ + WCHAR *LanguageName; + WCHAR *PrintableLanguageName; + UINT16 Size; + STATUS Status; + + if (StringDBReadGenericString (DBFptr, &Size, &LanguageName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + + if (StringDBReadGenericString (DBFptr, &Size, &PrintableLanguageName) != STATUS_SUCCESS) { + return STATUS_ERROR; + } + // + // printf("LANG: %S %S\n", LanguageName, PrintableLanguageName); + // + Status = StringDBAddLanguage (LanguageName, PrintableLanguageName); + FREE (LanguageName); + FREE (PrintableLanguageName); + return Status; +} +// +// All unicode strings in the database consist of a UINT16 length +// field, followed by the string itself. This routine reads one +// of those and returns the info. +// +static +STATUS +StringDBReadGenericString ( + FILE *DBFptr, + UINT16 *Size, + WCHAR **Str + ) +{ + UINT16 LSize; + UINT16 Flags; + WCHAR *LStr; + + if (fread (&LSize, sizeof (UINT16), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to read a string length field from the database", NULL); + return STATUS_ERROR; + } + + if (fread (&Flags, sizeof (UINT16), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to read a string flags field from the database", NULL); + return STATUS_ERROR; + } + + LStr = MALLOC (LSize); + if (LStr == NULL) { + Error (__FILE__, __LINE__, 0, "memory allocation failed reading the database", NULL); + return STATUS_ERROR; + } + + if (fread (LStr, sizeof (WCHAR), (UINT32) LSize / sizeof (WCHAR), DBFptr) != (UINT32) LSize / sizeof (WCHAR)) { + Error (NULL, 0, 0, "failed to read string from database", NULL); + Error (NULL, 0, 0, "database read failure", "offset 0x%X", ftell (DBFptr)); + free (LStr); + return STATUS_ERROR; + } + // + // printf ("DBR: %S\n", LStr); + // + // If the flags field indicated we were asked to write a NULL string, then + // return them a NULL pointer. + // + if (Flags & STRING_FLAGS_UNDEFINED) { + *Size = 0; + *Str = NULL; + } else { + *Size = LSize; + *Str = LStr; + } + + return STATUS_SUCCESS; +} + +static +STATUS +StringDBWriteGenericString ( + FILE *DBFptr, + WCHAR *Str + ) +{ + UINT16 Size; + UINT16 Flags; + WCHAR ZeroString[1]; + // + // Strings in the database consist of a size UINT16 followed + // by the string itself. + // + if (Str == NULL) { + ZeroString[0] = 0; + Str = ZeroString; + Size = sizeof (ZeroString); + Flags = STRING_FLAGS_UNDEFINED; + } else { + Flags = 0; + Size = (UINT16) ((wcslen (Str) + 1) * sizeof (WCHAR)); + } + + if (fwrite (&Size, sizeof (UINT16), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write string size to database", NULL); + return STATUS_ERROR; + } + + if (fwrite (&Flags, sizeof (UINT16), 1, DBFptr) != 1) { + Error (NULL, 0, 0, "failed to write string flags to database", NULL); + return STATUS_ERROR; + } + + if (fwrite (Str, sizeof (WCHAR), Size / sizeof (WCHAR), DBFptr) != Size / sizeof (WCHAR)) { + Error (NULL, 0, 0, "failed to write string to database", NULL); + return STATUS_ERROR; + } + + return STATUS_SUCCESS; +} + +static +STRING_LIST * +StringDBFindString ( + WCHAR *LanguageName, + WCHAR *StringName, + WCHAR *Scope, + WCHAR_STRING_LIST *LanguagesOfInterest, + WCHAR_MATCHING_STRING_LIST *IndirectionList + ) +{ + LANGUAGE_LIST *Lang; + STRING_LIST *CurrString; + WCHAR_MATCHING_STRING_LIST *IndListPtr; + WCHAR TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN + 1]; + WCHAR *WCharPtr; + + // + // If we were given an indirection list, then see if one was specified for this + // string identifier. That is to say, if the indirection says "STR_ID_MY_FAVORITE MyScope", + // then if this string name matches one in the list, then do a lookup with the + // specified scope and return that value. + // + if (IndirectionList != NULL) { + for (IndListPtr = IndirectionList; IndListPtr != NULL; IndListPtr = IndListPtr->Next) { + if (wcscmp (StringName, IndListPtr->Str1) == 0) { + CurrString = StringDBFindString (LanguageName, StringName, IndListPtr->Str2, LanguagesOfInterest, NULL); + if (CurrString != NULL) { + return CurrString; + } + } + } + } + // + // First look for exact match language.stringname + // + for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) { + if (wcscmp (LanguageName, Lang->LanguageName) == 0) { + // + // Found language match. Try to find string name match + // + for (CurrString = Lang->String; CurrString != NULL; CurrString = CurrString->Next) { + if (wcscmp (StringName, CurrString->StringName) == 0) { + // + // Found a string name match. See if we're supposed to find + // a scope match. + // + if (Scope != NULL) { + if (wcscmp (CurrString->Scope, Scope) == 0) { + return CurrString; + } + } else { + return CurrString; + } + } + } + } + } + // + // If we got here, then we didn't find a match. Look for secondary string + // matches. That is to say, if we're processing "spa", and they requested + // "spa+cat", then recursively call with "cat" + // + while (LanguagesOfInterest != NULL) { + // + // If this is the language we're looking for, then process the + // languages of interest list for it. + // + if (wcsncmp (LanguageName, LanguagesOfInterest->Str, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) { + WCharPtr = LanguagesOfInterest->Str + LANGUAGE_IDENTIFIER_NAME_LEN; + while (*WCharPtr) { + // + // Double-check the length, though it should have been checked on the + // command line. + // + if (wcslen (WCharPtr) < LANGUAGE_IDENTIFIER_NAME_LEN) { + Error (NULL, 0, 0, "malformed alternate language list", "%S", LanguagesOfInterest->Str); + return NULL; + } + + wcsncpy (TempLangName, WCharPtr, LANGUAGE_IDENTIFIER_NAME_LEN); + TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN] = 0; + CurrString = StringDBFindString (TempLangName, StringName, NULL, NULL, IndirectionList); + if (CurrString != NULL) { + return CurrString; + } + + WCharPtr += LANGUAGE_IDENTIFIER_NAME_LEN; + } + } + + LanguagesOfInterest = LanguagesOfInterest->Next; + } + + return NULL; +} + +STATUS +StringDBSetScope ( + WCHAR *Scope + ) +{ + // + // Free up existing scope memory. + // + if (mDBData.CurrentScope != NULL) { + FREE (mDBData.CurrentScope); + } + + mDBData.CurrentScope = DuplicateString (Scope); + return STATUS_SUCCESS; +} +// +// We typically don't assign index values to string identifiers +// until we're ready to write out files. To reduce the size of +// the output file, re-order the string identifiers to move any +// unreferenced ones to the end. Then we'll walk the list +// again to assign string indexes, keeping track of the last +// one referenced. +// +static +void +StringDBAssignStringIndexes ( + VOID + ) +{ + STRING_IDENTIFIER *StrId; + STRING_IDENTIFIER *FirstUsed; + STRING_IDENTIFIER *LastUsed; + STRING_IDENTIFIER *FirstUnused; + STRING_IDENTIFIER *LastUnused; + UINT32 Index; + UINT32 MaxReferenced; + + // + // Create two lists -- used and unused. Then put them together with + // the unused ones on the end. + // + FirstUsed = NULL; + LastUsed = NULL; + FirstUnused = NULL; + LastUnused = NULL; + StrId = mDBData.StringIdentifier; + while (StrId != NULL) { + if ((StrId->Flags & STRING_FLAGS_REFERENCED) == 0) { + // + // Put it on the unused list + // + if (FirstUnused == NULL) { + FirstUnused = StrId; + } else { + LastUnused->Next = StrId; + } + + LastUnused = StrId; + StrId = StrId->Next; + LastUnused->Next = NULL; + } else { + // + // Put it on the used list + // + if (FirstUsed == NULL) { + FirstUsed = StrId; + } else { + LastUsed->Next = StrId; + } + + LastUsed = StrId; + StrId = StrId->Next; + LastUsed->Next = NULL; + } + } + // + // Join the lists + // + if (FirstUsed != NULL) { + mDBData.StringIdentifier = FirstUsed; + LastUsed->Next = FirstUnused; + } else { + mDBData.StringIdentifier = FirstUnused; + } + + MaxReferenced = 0; + Index = 0; + for (StrId = mDBData.StringIdentifier; StrId != NULL; StrId = StrId->Next) { + StrId->Index = Index; + Index++; + if (StrId->Flags & STRING_FLAGS_REFERENCED) { + mDBData.NumStringIdentifiersReferenced = Index; + } + } + + mDBData.NumStringIdentifiers = Index; +} + +static +WCHAR * +DuplicateString ( + WCHAR *Str + ) +{ + WCHAR *NewStr; + if (Str == NULL) { + return NULL; + } + + NewStr = MALLOC ((wcslen (Str) + 1) * sizeof (WCHAR)); + if (NewStr == NULL) { + Error (NULL, 0, 0, "memory allocation failure", NULL); + return NULL; + } + + wcscpy (NewStr, Str); + return NewStr; +} + +static +WCHAR * +AsciiToWchar ( + INT8 *Str + ) +{ + UINT32 Len; + WCHAR *NewStr; + WCHAR *Ptr; + + Len = strlen (Str) + 1; + NewStr = (WCHAR *) malloc (Len * sizeof (WCHAR)); + for (Ptr = NewStr; *Str != 0; Str++, Ptr++) { + *Ptr = (UINT16) (UINT8) *Str; + } + + *Ptr = 0; + return NewStr; +} + +/*****************************************************************************/ + +/*++ + +Routine Description: + + Create an HII export string pack for the strings in our database. + +Arguments: + + FileName - name of the output file to write + +Returns: + + STATUS + + +--*/ +STATUS +StringDBCreateHiiExportPack ( + INT8 *FileName + ) +{ + FILE *Fptr; + LANGUAGE_LIST *Lang; + STRING_LIST *CurrString; + STRING_LIST EmptyString; + UINT32 Offset; + UINT32 StringIndex; + UINT32 TempIndex; + EFI_HII_STRING_PACK_HEADER StringPack; + UINT32 Len; + WCHAR ZeroString[1]; + WCHAR *TempStringPtr; + WCHAR *LangName; + STRING_IDENTIFIER *StringIdentifier; + + if ((Fptr = fopen (FileName, "wb")) == NULL) { + Error (NULL, 0, 0, FileName, "failed to open output HII export file"); + return STATUS_ERROR; + } + // + // Assign index values to the string identifiers + // + StringDBAssignStringIndexes (); + // + // If a given string is not defined, then we'll use this one. + // + memset (&EmptyString, 0, sizeof (EmptyString)); + EmptyString.Size = sizeof (ZeroString); + EmptyString.Str = ZeroString; + // + // Process each language, then each string for each langage + // + ZeroString[0] = 0; + for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) { + // + // Process each string for this language. We have to make 3 passes on the strings: + // Pass1: computes sizes and fill in the string pack header + // Pass2: write the array of offsets + // Pass3: write the strings + // + // + // PASS 1: Fill in and print the HII string pack header + // + // Compute the size for this language package and write + // the header out. Each string package contains: + // Header + // Offset[] -- an array of offsets to strings, of type RELOFST each + // String[] -- the actual strings themselves + // + memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER)); + StringPack.Header.Type = EFI_HII_STRING; + StringPack.NumStringPointers = (UINT16) mDBData.NumStringIdentifiersReferenced; + LangName = Lang->LanguageName; + // + // First string is the language name. If we're printing all languages, then + // it's just the "spa". If we were given a list of languages to print, then it's + // the "spacat" string. Compute its offset and fill in + // the info in the header. Since we know the language name string's length, + // and the printable language name follows it, use that info to fill in the + // entry for the printable language name as well. + // + StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK_HEADER) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET))); + StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (wcslen (LangName) + 1) * sizeof (WCHAR)); + // + // Add up the size of all strings so we can fill in our header. + // + Len = 0; + for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) { + // + // For the first string (language name), we print out the "spacat" if they + // requested it. We set LangName to point to the proper language name string above. + // + if (StringIndex == STRING_ID_LANGUAGE_NAME) { + Len += (wcslen (LangName) + 1) * sizeof (WCHAR); + } else { + // + // Find a string with this language.stringname + // + StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex); + if (StringIdentifier == NULL) { + Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex); + return STATUS_ERROR; + } + // + // Find a matching string if this string identifier was referenced + // + EmptyString.Flags = STRING_FLAGS_UNDEFINED; + CurrString = NULL; + if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) { + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, + NULL, // LanguagesOfInterest, + NULL + ); + // + // IndirectionList); + // + if (NULL == CurrString) { + // + // If string for Lang->LanguageName is not found, try to get an English version + // + CurrString = StringDBFindString ( + L"eng", + StringIdentifier->StringName, + NULL, + NULL, // LanguagesOfInterest, + NULL + ); + // + // IndirectionList); + // + } + } + + if (CurrString == NULL) { + CurrString = &EmptyString; + EmptyString.Flags |= StringIdentifier->Flags; + } + + Len += CurrString->Size; + } + } + StringPack.Header.Length = sizeof (EFI_HII_STRING_PACK_HEADER) + + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) + + Len; + // + // Write out the string pack header + // + fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr); + // + // PASS2 : write the offsets + // + // Traverse the list of strings again and write the array of offsets. The + // offset to the first string is the size of the string pack header + // plus the size of the offsets array. The other strings follow it. + // + StringIndex = 0; + Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET); + for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) { + // + // Write the offset + // + fwrite (&Offset, sizeof (STRING_OFFSET), 1, Fptr); + // + // Find the string name + // + StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex); + if (StringIdentifier == NULL) { + Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex); + return STATUS_ERROR; + } + // + // For the first string (language name), we print out the "spacat" if they + // requested it. We set LangName to point to the proper language name string above. + // + if (StringIndex == STRING_ID_LANGUAGE_NAME) { + Offset += (wcslen (LangName) + 1) * sizeof (WCHAR); + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, // scope + NULL, + NULL + ); + } else { + // + // Find a matching string + // + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, // scope + NULL, // LanguagesOfInterest, + NULL + ); + // + // IndirectionList); + // + if (NULL == CurrString) { + CurrString = StringDBFindString ( + L"eng", + StringIdentifier->StringName, + NULL, // scope + NULL, // LanguagesOfInterest, + NULL + ); + // + // IndirectionList); + // + } + + EmptyString.LanguageName = Lang->LanguageName; + if (CurrString == NULL) { + CurrString = &EmptyString; + EmptyString.Flags = STRING_FLAGS_UNDEFINED; + } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) { + CurrString = &EmptyString; + EmptyString.Flags = 0; + } + + Offset += CurrString->Size; + } + } + + // + // PASS 3: write the strings themselves. + // + Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET); + for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) { + StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex); + if (StringIdentifier == NULL) { + Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex); + return STATUS_ERROR; + } + // + // For the first string (language name), we print out the "spacat" if they + // requested it. We set LangName to point to the proper language name string above. + // + if (StringIndex == STRING_ID_LANGUAGE_NAME) { + TempStringPtr = LangName; + } else { + // + // Find a matching string if this string identifier was referenced + // + CurrString = NULL; + if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) { + CurrString = StringDBFindString ( + Lang->LanguageName, + StringIdentifier->StringName, + NULL, // scope + NULL, // LanguagesOfInterest, + NULL + ); + // + // IndirectionList); + // + if (NULL == CurrString) { + CurrString = StringDBFindString ( + L"eng", + StringIdentifier->StringName, + NULL, // scope + NULL, // LanguagesOfInterest, + NULL + ); + // + // IndirectionList); + // + } + } + + if (CurrString == NULL) { + CurrString = &EmptyString; + } + + TempStringPtr = CurrString->Str; + } + + for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) { + fwrite (&TempStringPtr[TempIndex], sizeof (CHAR16), 1, Fptr); + Offset += 2; + } + // + // Print NULL WCHAR at the end of this string. + // + TempIndex = 0; + fwrite (&TempIndex, sizeof (CHAR16), 1, Fptr); + Offset += 2; + } + // + // Sanity check the offset. Make sure our running offset is what we put in the + // string pack header. + // + if (StringPack.Header.Length != Offset) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "stringpack size 0x%X does not match final size 0x%X", + StringPack.Header.Length, + Offset + ); + } + } + // + // Print terminator string pack, closing brace and close the file. + // The size of 0 triggers to the consumer that this is the end. + // + memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER)); + StringPack.Header.Type = EFI_HII_STRING; + fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr); + fclose (Fptr); + return STATUS_SUCCESS; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h new file mode 100644 index 0000000000..4dc05a3642 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h @@ -0,0 +1,136 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + StringDB.h + +Abstract: + + Common defines and prototypes for string database management + +--*/ + +#ifndef _STRING_DB_H_ +#define _STRING_DB_H_ + +#define LANGUAGE_NAME_STRING_NAME L"$LANGUAGE_NAME" +#define PRINTABLE_LANGUAGE_NAME_STRING_NAME L"$PRINTABLE_LANGUAGE_NAME" + +void +StringDBConstructor ( + void + ) +; +void +StringDBDestructor ( + void + ) +; + +STATUS +StringDBAddString ( + WCHAR *LanguageName, + WCHAR *StringIdentifier, + WCHAR *Scope, + WCHAR *String, + BOOLEAN Format, + UINT16 Flags + ) +; + +STATUS +StringDBSetScope ( + WCHAR *Scope + ) +; + +#define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere +#define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes +#define STRING_FLAGS_INDEX_ASSIGNED 0x0004 // so don't change the index value +#define STRING_ID_INVALID 0xFFFF +#define STRING_ID_LANGUAGE_NAME 0x0000 +#define STRING_ID_PRINTABLE_LANGUAGE_NAME 0x0001 + +STATUS +StringDBAddStringIdentifier ( + WCHAR *StringIdentifier, + UINT16 *NewId, + UINT16 Flags + ) +; + +STATUS +StringDBReadDatabase ( + INT8 *DBFileName, + BOOLEAN IgnoreIfNotExist, + BOOLEAN Verbose + ) +; + +STATUS +StringDBWriteDatabase ( + INT8 *DBFileName, + BOOLEAN Verbose + ) +; + +STATUS +StringDBDumpDatabase ( + INT8 *DBFileName, + INT8 *OutputFileName, + BOOLEAN Verbose + ) +; + +STATUS +StringDBAddLanguage ( + WCHAR *LanguageName, + WCHAR *PrintableLanguageName + ) +; + +STATUS +StringDBDumpCStrings ( + INT8 *FileName, + INT8 *BaseName, + WCHAR_STRING_LIST *LanguagesOfInterest, + WCHAR_MATCHING_STRING_LIST *IndirectionList + ) +; + +STATUS +StringDBDumpStringDefines ( + INT8 *FileName, + INT8 *BaseName + ) +; + +STATUS +StringDBSetCurrentLanguage ( + WCHAR *LanguageName + ) +; + +STATUS +StringDBSetStringReferenced ( + INT8 *StringIdentifierName, + BOOLEAN IgnoreNotFound + ) +; + +void +StringDBFormatString ( + WCHAR *String + ) +; + +#endif // #ifndef _STRING_DB_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c b/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c new file mode 100644 index 0000000000..32f1c33b8c --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/VcCheck.c @@ -0,0 +1,121 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VcCheck.c + +Abstract: + + We have found problems with the Visual C++ SP4 and the /O1 flag. + If this tests ask a question you have the wrong version of Visual C++ + on your system + + This test assumes the tools are being compiled with the same complier + as the Tiano code. + + Please see $(EFI_SOURCE)\EFI2.0 Developer's Manual.doc to get the + correct version of Visual C++ + +--*/ + +#include + +_int16 gGloba16; + +int +CheckLostCode ( + int Value + ) +/*++ + +Routine Description: + This routine is used to test for compiler isseus with /O1. + If the /O1 compiler option, and C2.dll is got from Visual C++ SP5 + (version: 6.00.8168.0), the assember codes after default branch will be + losted. (Execute "cl Visual Ccheck.c /O1 /FAsc" to get detail information) + +Arguments: + Value - Test case + +Returns: + Test to see if comiler error is present. + +--*/ +{ + switch (Value) { + case 0: + break; + + default: + _asm + { + mov bx, 1 + mov gGloba16, bx + } + + return 1; + } + + _asm + { + mov bx, 0 + mov gGloba16, bx + } + + return 0; +} + +int +main ( + void + ) +/*++ + +Routine Description: + This utility is checking for a known Visual C++ compiler issues. To remove this + question from the build follow the steps in the developers manual. + +Arguments: + NONE + +Returns: + 0 - Compiler version is O.K. + 1 - Compiler version is Bad + +--*/ +{ + int result; + char select; + + gGloba16 = 0xFF; + result = 0; + + CheckLostCode (0); + result += (gGloba16 == 0) ? 0 : 1; + + CheckLostCode (1); + result += (gGloba16 == 1) ? 0 : 1; + + if (result != 0) { + printf ("Warning: C2.dll is incorrect.\n Please see $(EFI_SOURCE)\\EFI2.0 Developer's Manual.doc for corrective action.\n"); + printf ("Would you want to continue?(Y/N)"); + + scanf ("%c", &select); + if ((select == 'Y') || (select == 'y')) { + return 0; + } else { + return 1; + } + } + + return 0; +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/makefile new file mode 100644 index 0000000000..d0a680c978 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/VcCheck/makefile @@ -0,0 +1,92 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: makefile +# +# Abstract: +# +# This file is used to build the EFI utility. +# +#--*/ + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +# +# Define some macros we use here. Should get rid of them someday and +# get rid of the extra level of indirection. +# +COMMON_SOURCE = $(EDK_TOOLS_COMMON) + +# +# Common information +# + +INC=$(INC) + +# +# Target specific information +# + +TARGET_NAME=VcCheck + +TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) + +TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe + +TARGET_EXE_SOURCE = "$(TARGET_SOURCE_DIR)\VcCheck.c" +TARGET_EXE_INCLUDE = +OBJECTS = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Replace /Od with "" to fix the Command line warning D4025 +# +C_FLAGS = $(C_FLAGS:/Od=) /O1 + +# +# Build targets +# + +all: $(TARGET_EXE) + +# +# Build EXE +# + +$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj: $(TARGET_EXE_SOURCE) $(TARGET_EXE_INCLUDE) + $(CC) $(C_FLAGS) $(INC) $(TARGET_EXE_SOURCE) /Fo$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).obj + +# +# Add Binary Build description for this tools. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h new file mode 100644 index 0000000000..d6862119db --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h @@ -0,0 +1,178 @@ +/*++ + +Copyright (c) 2004 - 2005, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + EfiVfr.h + +Abstract: + + Defines and prototypes for the EFI internal forms representation + setup protocol and drivers + +--*/ + +#ifndef _EFI_VFR_H_ +#define _EFI_VFR_H_ + +#include "Tiano.h" +#include "EfiInternalFormRepresentation.h" +#include + +// +// This number should be incremented with each change to the VFR compiler. +// We write the version to the output list file for debug purposes. +// +#define VFR_COMPILER_VERSION "1.88" + +// +// Maximum file path for filenames +// +#define MAX_PATH 255 +#define MAX_QUEUE_COUNT 255 +#define MAX_LINE_LEN 1024 +#define PROGRAM_NAME "VfrCompile" + +// +// We parse C-style structure definitions which can then be referenced +// in VFR statements. +// We need to define an internal structure that can be used to +// track the fields in a structure definition, and another structure +// to keep track of the structure name and subfields. +// +typedef struct _STRUCT_FIELD_DEFINITION { + struct _STRUCT_FIELD_DEFINITION *Next; + int DataSize; + int Offset; // from the start of the structure + int ArrayLength; + char IsArray; + char *Name; +} STRUCT_FIELD_DEFINITION; + +typedef struct _STRUCT_DEFINITION { + struct _STRUCT_DEFINITION *Next; + int Size; + int LineNum; // line number where the structure was defined + int IsNonNV; // if this is the non-NV data structure definition + int Referenced; // if it's referenced anywhere in the VFR + int VarStoreIdValid; // found a 'varstore' statement for it in the VFR + unsigned short VarStoreId; // key from a varstore IFR statement + int VarStoreLineNum; // line number where VARSTORE was defined + char *Name; + STRUCT_FIELD_DEFINITION *Field; + STRUCT_FIELD_DEFINITION *LastField; +} STRUCT_DEFINITION; + +// +// For the IdEqValList variable list of UINT16's, keep track of them using +// a linked list until we know how many there are. +// We also use a linked list of these to keep track of labels used in +// the VFR script so we can catch duplicates. +// We'll also use it to keep track of defined varstore id's so we can +// detect duplicate definitions. +// +typedef struct _UINT16_LIST { + struct _UINT16_LIST *Next; + UINT16 Value; + UINT32 LineNum; +} UINT16_LIST; + +typedef struct _GOTO_REFERENCE { + struct _GOTO_REFERENCE *Next; + UINT32 RefLineNum; // line number of source file where referenced + UINT16 Value; +} GOTO_REFERENCE; + +typedef struct _FORM_ID_VALUE { + struct _FORM_ID_VALUE *Next; + UINT32 LineNum; + UINT16 Value; +} FORM_ID_VALUE; + +// +// We keep track in the parser of all "#line 4 "x.y"" strings so we +// can cross-reference the line numbers in the preprocessor output .i file +// to the original input files. +// +typedef struct _PARSER_LINE_DEFINITION { + struct _PARSER_LINE_DEFINITION *Next; + UINT32 HashLineNum; // from the #line stmt + UINT32 TokenLineNum; // line number in the .i file + INT8 *FileName; // from the #line stmt +} PARSER_LINE_DEFINITION; + +extern PARSER_LINE_DEFINITION *gLineDefinition; +extern PARSER_LINE_DEFINITION *gLastLineDefinition; + +extern +char * +ConvertLineNumber ( + UINT32 *LineNum + ) +/*++ + +Routine Description: + Given the line number in the preprocessor-output file, use the line number + information we've saved to determine the source file name and line number + where the code originally came from. This is required for error reporting. + +Arguments: + LineNum - the line number in the preprocessor-output file. + +Returns: + Returns a pointer to the source file name. Also returns the line number + in the provided LineNum argument + +--*/ +; + +typedef struct _IFR_BYTE { + struct _IFR_BYTE *Next; + UINT32 LineNum; + UINT8 OpcodeByte; + UINT8 KeyByte; +} IFR_BYTE; + +typedef struct { + INT8 VfrFileName[MAX_PATH]; + INT8 VfrListFileName[MAX_PATH]; + INT8 CreateListFile; + INT8 CreateIfrBinFile; + INT8 IfrOutputFileName[MAX_PATH]; + INT8 OutputDirectory[MAX_PATH]; + INT8 PreprocessorOutputFileName[MAX_PATH]; + INT8 VfrBaseFileName[MAX_PATH]; // name of input VFR file with no path or extension + INT8 *IncludePaths; + INT8 *CPreprocessorOptions; +} OPTIONS; + +extern OPTIONS gOptions; + +VOID +WriteStandardFileHeader ( + FILE *OutFptr + ) +/*++ + +Routine Description: + This function is invoked to emit a standard header to an + output text file. + +Arguments: + OutFptr - file to write the header to + +Returns: + None + +--*/ +; + +#endif // #ifndef _EFI_VFR_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g new file mode 100644 index 0000000000..cba6fa6a6a --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g @@ -0,0 +1,3463 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VfrCompile.g + +Abstract: + + PCCTS parser and lexer definitions for the EFI VFR forms compiler + +--*/ + +#header<< + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" +#include "EfiVfr.h" +#include "VfrServices.h" +#include EFI_PROTOCOL_DEFINITION (Hii) + +#include +#include +#include // for spawn functions + +>> + +<< + +// +// Base info for DLG-generated scanner +// +#include "DLexerBase.h" + +// +// Include the scanner file generated by DLG +// +#include "DLGLexer.h" + +class DLGLexerVfr : public DLGLexer +{ +public: + DLGLexerVfr (DLGFileInput *F) : DLGLexer (F) {}; + INT32 errstd (char *Text) + { + printf ("unrecognized input '%s'\n", Text); + } +}; + +// +// Base token definitions for ANTLR +// +#include "AToken.h" + +// +// This is how we invoke the C preprocessor on the VFR source file +// to resolve #defines, #includes, etc. To make C source files +// shareable between VFR and drivers, define VFRCOMPILE so that +// #ifdefs can be used in shared .h files. +// +#define PREPROCESSOR_COMMAND "cl.exe " +#define PREPROCESSOR_OPTIONS "/nologo /E /TC /DVFRCOMPILE " + +typedef ANTLRCommonToken ANTLRToken; + +// +// Specify the filename extensions for the files we generate. +// +#define VFR_BINARY_FILENAME_EXTENSION ".c" +#define VFR_LIST_FILENAME_EXTENSION ".lst" +#define VFR_PREPROCESS_FILENAME_EXTENSION ".i" + +static +VOID +Usage (); + +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ); + +static +VOID +Cleanup (); + +// +// Globals +// +OPTIONS gOptions; + +int +main ( + int argc, + char **argv + ) +/*++ + +Routine Description: + Application entry point function. Parse command-line arguments, + invoke the parser, clean up, and return. + +Arguments: + argc - standard argc passed to main() per C conventions + argv - standard argv passed to main() per C conventions + +Returns: + STATUS_SUCCESS - program executed with no errors or warnings + STATUS_WARNING - program executed with warnings + STATUS_ERROR - non-recoverable errors encountered while processing + +--*/ +{ + FILE *VfrFptr; + char *Cmd; + char *Cptr; + int Len; + STATUS Status; + + // + // Set our program name for the error printing routines. + // Then set printing limits. + // + SetUtilityName (PROGRAM_NAME); + SetPrintLimits (20, 20, 30); + // + // Process the command-line arguments + // + if (ProcessArgs (argc, argv) != STATUS_SUCCESS) { + Usage (); + Cleanup(); + return STATUS_ERROR; + } + VfrFptr = NULL; + // + // Verify the VFR script file exists + // + if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) { + Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file"); + Cleanup(); + return STATUS_ERROR; + } + // + // Now close the file and make a system call to run the preprocessor + // on it. + // + fclose (VfrFptr); + Len = strlen (PREPROCESSOR_OPTIONS) + strlen (gOptions.VfrFileName) + 10 + + strlen (PREPROCESSOR_COMMAND) + strlen (gOptions.PreprocessorOutputFileName); + if (gOptions.CPreprocessorOptions != NULL) { + Len += strlen (gOptions.CPreprocessorOptions) + 1; + } + if (gOptions.IncludePaths != NULL) { + Len += strlen (gOptions.IncludePaths) + 1; + } + Cmd = (char *)malloc (Len); + if (Cmd == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory"); + Cleanup(); + return STATUS_ERROR; + } + strcpy (Cmd, PREPROCESSOR_COMMAND PREPROCESSOR_OPTIONS); + if (gOptions.IncludePaths != NULL) { + strcat (Cmd, gOptions.IncludePaths); + strcat (Cmd, " "); + } + if (gOptions.CPreprocessorOptions != NULL) { + strcat (Cmd, gOptions.CPreprocessorOptions); + strcat (Cmd, " "); + } + strcat (Cmd, gOptions.VfrFileName); + strcat (Cmd, " > "); + strcat (Cmd, gOptions.PreprocessorOutputFileName); + Status = system (Cmd); + if (Status != 0) { + Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file"); + printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd); + Cleanup(); + return STATUS_ERROR; + } + free (Cmd); + // + // Open the preprocessor output file + // + if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) { + Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file", + gOptions.PreprocessorOutputFileName); + Cleanup(); + return STATUS_ERROR; + } + // + // Define input VFR file + // + DLGFileInput InputFile (VfrFptr); + // + // Define an instance of the scanner + // + DLGLexerVfr Scanner (&InputFile); + // + // Define token buffer between scanner and parser + // + ANTLRTokenBuffer Pipe (&Scanner); + // + // Create a token to use as a model + // + ANTLRToken Tok; + // + // Tell the scanner what type the token is + // + Scanner.setToken (&Tok); + // + // Create an instance of our parser + // + EfiVfrParser Parser (&Pipe); + // + // Initialize the parser + // + Parser.init (); + Status = GetUtilityStatus (); + if (Status != STATUS_SUCCESS) { + Cleanup(); + return Status; + } + // + // Start the first rule + // + Parser.program (); + // + // Close the input script file + // + fclose (VfrFptr); + Parser.WriteIfrBytes (); + // + // Call cleanup, which does some extra checking of the script + // + Parser.Cleanup (); + Cleanup(); + // + // If we had an error somewhere, delete our output files so that + // a subsequent build will rebuild them. + // + Status = GetUtilityStatus (); + if (Status == STATUS_ERROR) { + remove (gOptions.IfrOutputFileName); + } + return Status; +} +static +VOID +Cleanup () +/*++ + +Routine Description: + Free up memory allocated during parsing. + +Arguments: + None + +Returns: + None + +--*/ +{ + // + // Free up our string we allocated to track the include paths + // + if (gOptions.IncludePaths != NULL) { + free (gOptions.IncludePaths); + gOptions.IncludePaths = NULL; + } + // + // Free up our string we allocated to track preprocessor options + // + if (gOptions.CPreprocessorOptions != NULL) { + free (gOptions.CPreprocessorOptions); + gOptions.CPreprocessorOptions = NULL; + } +} + +static +STATUS +ProcessArgs ( + int Argc, + char *Argv[] + ) +/*++ + +Routine Description: + Process the command-line arguments. + +Arguments: + Argc - standard argc passed to main() + Argv - standard argv passed to main() + +Returns: + STATUS_SUCCESS - program should continue (all args ok) + +--*/ +{ + char *IncludePaths; + char *CPreprocessorOptions; + int Len; + char CopyStr[MAX_PATH]; + char *Cptr; + + // + // Put options in known state. + // + memset ((char *)&gOptions, 0, sizeof (OPTIONS)); + // + // Go through all the arguments that start with '-' + // + Argc--; + Argv++; + while ((Argc > 0) && (Argv[0][0] == '-')) { + // + // -? or -h help option -- return an error for printing usage + // + if ((_stricmp (Argv[0], "-?") == 0) || (_stricmp (Argv[0], "-h") == 0)) { + return STATUS_ERROR; + break; + // + // -l to create a listing output file + // + } else if (_stricmp (Argv[0], "-l") == 0) { + gOptions.CreateListFile = 1; + // + // -I include_path option for finding include files. We'll pass this + // to the preprocessor. Turn them all into a single include string. + // + } else if (_stricmp (Argv[0], "-i") == 0) { + if ((Argc < 2) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument"); + return STATUS_ERROR; + } + Argc--; + Argv++; + Len = strlen (" -I "); + Len += strlen (Argv[0]) + 2; + if (gOptions.IncludePaths != NULL) { + Len += strlen (gOptions.IncludePaths); + } + IncludePaths = (INT8 *)malloc (Len); + if (IncludePaths == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + IncludePaths[0] = 0; + if (gOptions.IncludePaths != NULL) { + strcpy (IncludePaths, gOptions.IncludePaths); + free (gOptions.IncludePaths); + } + strcat (IncludePaths, " -I "); + strcat (IncludePaths, Argv[0]); + gOptions.IncludePaths = IncludePaths; + // + // -od OutputDirectory to define a common directory for output files + // + } else if (_stricmp (Argv[0], "-od") == 0) { + if ((Argc < 2) || (Argv[1][0] == '-')) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name"); + return STATUS_ERROR; + } + Argc--; + Argv++; + strcpy (gOptions.OutputDirectory, Argv[0]); + } else if (_stricmp (Argv[0], "-ibin") == 0) { + gOptions.CreateIfrBinFile = 1; + } else if (_stricmp (Argv[0], "-nostrings") == 0) { + // deprecated option + // + // -ppflag C-preprocessor-flag option for passing options to the C preprocessor. + // Turn them all into a single string. + // + } else if (_stricmp (Argv[0], "-ppflag") == 0) { + if (Argc < 2) { + Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument"); + return STATUS_ERROR; + } + Argc--; + Argv++; + Len = strlen (Argv[0]) + 2; + if (gOptions.CPreprocessorOptions != NULL) { + Len += strlen (gOptions.CPreprocessorOptions); + } + CPreprocessorOptions = (INT8 *)malloc (Len); + if (CPreprocessorOptions == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return STATUS_ERROR; + } + CPreprocessorOptions[0] = 0; + if (gOptions.CPreprocessorOptions != NULL) { + strcpy (CPreprocessorOptions, gOptions.CPreprocessorOptions); + free (gOptions.CPreprocessorOptions); + } + strcat (CPreprocessorOptions, " "); + strcat (CPreprocessorOptions, Argv[0]); + gOptions.CPreprocessorOptions = CPreprocessorOptions; + } else { + Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option"); + return STATUS_ERROR; + } + Argc--; + Argv++; + } + // + // Must specify at least the vfr file name + // + if (Argc > 1) { + Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name"); + return STATUS_ERROR; + } else if (Argc < 1) { + Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name"); + return STATUS_ERROR; + } + strcpy (gOptions.VfrFileName, Argv[0]); + + strcpy (CopyStr, gOptions.VfrFileName); + Cptr = CopyStr + strlen (CopyStr) - 1; + for (;(Cptr > CopyStr) && (*Cptr != '\\') && (*Cptr != ':'); Cptr--); + if (Cptr == CopyStr) { + strcpy (gOptions.VfrBaseFileName, Cptr); + } else { + strcpy (gOptions.VfrBaseFileName, Cptr+1); + } + // + // Terminate the vfr file basename at the extension + // + for (Cptr = gOptions.VfrBaseFileName; *Cptr && (*Cptr != '.'); Cptr++) { + } + *Cptr = 0; + // + // If they defined an output directory, prepend all output files + // with the working directory. Output files of interest: + // VfrListFileName -- list file + // IfrOutputFileName -- IFR bytes + // StringOutputFileName -- string bytes + // StringListFileName -- not used + // StringDefineFileName -- #defines of string identifiers + // + // We have two cases: + // 1. Output directory (-od) not specified, in which case output files + // go to the current working directory. + // 2. Output directory specified, in which case the output files + // go directly to the specified directory. + // + if (gOptions.OutputDirectory[0] == 0) { + CopyStr[0] = 0; + _getcwd (CopyStr, sizeof (CopyStr)); + strcpy (gOptions.OutputDirectory, CopyStr); + } + // + // Make sure output directory has a trailing backslash + // + if (gOptions.OutputDirectory[strlen (gOptions.OutputDirectory) - 1] != '\\') { + strcat (gOptions.OutputDirectory, "\\"); + } + // + // Create the base output file name as: path\base, copy it to all the output + // filenames, and then add the appropriate extension to each. + // + strcpy (gOptions.VfrListFileName, gOptions.OutputDirectory); + strcat (gOptions.VfrListFileName, gOptions.VfrBaseFileName); + strcpy (gOptions.IfrOutputFileName, gOptions.VfrListFileName); + strcpy (gOptions.PreprocessorOutputFileName, gOptions.VfrListFileName); + strcat (gOptions.VfrListFileName, VFR_LIST_FILENAME_EXTENSION); + strcat (gOptions.IfrOutputFileName, VFR_BINARY_FILENAME_EXTENSION); + strcat (gOptions.PreprocessorOutputFileName, VFR_PREPROCESS_FILENAME_EXTENSION); + + // + // We set a default list file name, so if they do not + // want a list file, null out the name now. + // + if (gOptions.CreateListFile == 0) { + gOptions.VfrListFileName[0] = 0; + } + return STATUS_SUCCESS; +} +static +VOID +Usage () +/*++ + +Routine Description: + Print utility usage instructions + +Arguments: + None + +Returns: + None + +--*/ +{ + int Index; + const char *Help[] = { + " ", + "VfrCompile version " VFR_COMPILER_VERSION, + " ", + " Usage: VfrCompile {options} [VfrFile]", + " ", + " where options include:", + " -? or -h prints this help", + " -l create an output IFR listing file", + " -i IncPath add IncPath to the search path for VFR included files", + " -od OutputDir deposit all output files to directory OutputDir (default=cwd)", + " -ibin create an IFR HII pack file", + " where parameters include:", + " VfrFile name of the input VFR script file", + " ", + NULL + }; + for (Index = 0; Help[Index] != NULL; Index++) { + fprintf (stdout, "%s\n", Help[Index]); + } +} + +>> + + +#lexaction +<< + +#include "EfiVfr.h" + +PARSER_LINE_DEFINITION *gLineDefinition = NULL; +PARSER_LINE_DEFINITION *gLastLineDefinition = NULL; + +VOID +AddFileLine ( + char *TokenString, + UINT32 TokenLine + ) +/*++ + +Routine Description: + During the lexer phase, if we encounter a #line statement output by + the preprocessor, this function gets called. We'll save off the info + for error reporting purposes. The preprocessor line information has the + form: + + #line 3 "FileName.c" + +Arguments: + TokenString - the parsed string as shown above + TokenLine - the line number in the preprocessed output file + +Returns: + NA + +--*/ +{ + PARSER_LINE_DEFINITION *LineDef; + INT8 *Cptr; + + // + // Allocate a structure in which we can keep track of this line information. + // + LineDef = (PARSER_LINE_DEFINITION *)malloc (sizeof (PARSER_LINE_DEFINITION)); + memset ((char *)LineDef, 0, sizeof (PARSER_LINE_DEFINITION)); + LineDef->TokenLineNum = TokenLine; + LineDef->HashLineNum = atoi (TokenString + 6); + // + // Find the quotes in the filename, then allocate space in the line + // def structure for a copy of the filename. Finally, copy it without + // quotes to the line def. + // + for (Cptr = TokenString + 7; *Cptr && (*Cptr != '"'); Cptr++); + if (*Cptr == '"') { + LineDef->FileName = (INT8 *)malloc (strlen (Cptr)); + Cptr++; + strcpy (LineDef->FileName, Cptr); + for (Cptr = LineDef->FileName; *Cptr && (*Cptr != '"'); Cptr++); + *Cptr = 0; + // + // Now add this new one to the list + // + if (gLineDefinition == NULL) { + gLineDefinition = LineDef; + } else { + gLastLineDefinition->Next = LineDef; + } + gLastLineDefinition = LineDef; + } else { + Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString); + free (LineDef); + return; + } +} +char * +ConvertLineNumber ( + UINT32 *LineNum + ) +/*++ + +Routine Description: + Given the line number in the preprocessor-output file, use the line number + information we've saved to determine the source file name and line number + where the code originally came from. This is required for error reporting. + +Arguments: + LineNum - the line number in the preprocessor-output file. + +Returns: + Returns a pointer to the source file name. Also returns the line number + in the provided LineNum argument + +--*/ +{ + PARSER_LINE_DEFINITION *LineDef; + // + // Step through our linked list of #line information we saved off. + // For each one, look at its line number, and the line number of the + // next record, and see if the passed-in line number is in the range. + // If it is, then convert the line number to the appropriate line number + // of the original source file. + // + for (LineDef = gLineDefinition; LineDef != NULL; LineDef = LineDef->Next) { + // + // The given LineNum is the line number from the .i file. + // Find a line definition whose range includes this line number, + // convert the line number, and return the filename. + // + if (LineDef->TokenLineNum <= *LineNum) { + if (LineDef->Next != NULL) { + if (LineDef->Next->TokenLineNum > *LineNum) { + *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum; + return LineDef->FileName; + } + } else { + // + // Last one in the list of line definitions, so has to be right + // + *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum; + return LineDef->FileName; + } + } + } + return NULL; +} + +>> + +// +// Define a lexical class for parsing quoted strings. Basically +// starts with a double quote, and ends with a double quote that +// is not preceeded with a backslash. +// +#lexclass QUOTED_STRING +#token TheString "~[\"]*\"" << mode (START); >> + +// +// Define a lexical class for parsing "#pragma pack" statements. +// We do this just for convenience (since we skip them here) so +// that users can include some minimal .h files. +// +#lexclass PRAGMA_PACK +#token "pack" << skip (); >> +#token "[\ \t]" << skip (); >> +#token "\(" << skip (); >> +#token "[0-9]*" << skip (); >> +#token "\)" << skip (); mode (START); >> + +// +// Define a lexclass for skipping over C++ style comments +// +#lexclass CPP_COMMENT +#token "~[\n]*" << skip (); >> +#token "\n" << skip (); mode (START); newline (); >> + +// +// Standard lexclass is START +// +#lexclass START + +// +// Find start of C++ style comments +// +#token "//" << skip (); mode (CPP_COMMENT); >> + +// +// Skip whitespace +// +#token "[\ \t]" << skip (); >> + +// +// Skip over newlines, but count them +// +#token "\n" << skip (); newline (); >> + +// +// Skip pragma pack statements +// +#token "\#pragma" << skip (); mode(PRAGMA_PACK); >> + +// +// Skip over 'extern' in any included .H file +// +#token "extern" << skip (); >> + +// +// Tokens for the different keywords. Syntax is: +// TokenName("ErrorMessageText") "TokenString" +// where: +// TokenName is the token name (must be capitalized) that is used in the rules +// ErrorMessageText is the string the compiler emits when it detects a syntax error +// TokenString is the actual matching string used in the user script +// +#token LineDefinition "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << AddFileLine (begexpr (), line ()); skip (); >> +#token FormSet("formset") "formset" +#token EndFormSet("endformset") "endformset" +#token Title("title") "title" +#token FormId("formid") "formid" +#token OneOf("oneof") "oneof" +#token Prompt("prompt") "prompt" +#token OrderedList("orderedlist") "orderedlist" +#token EndList("endlist") "endlist" +#token EndForm("endform") "endform" +#token EndOneOf("endoneof") "endoneof" +#token Form("form") "form" +#token Subtitle("subtitle") "subtitle" +#token Help("help") "help" +#token VarId("varid") "varid" +#token Text("text") "text" +#token Option("option") "option" +#token Value("value") "value" +#token Flags("flags") "flags" +#token Date("date") "date" +#token EndDate("enddate") "enddate" +#token Year("year") "year" +#token Month("month") "month" +#token Day("day") "day" +#token Time("time") "time" +#token EndTime("endtime") "endtime" +#token Hour("hour") "hour" +#token Minute("minute") "minute" +#token Second("second") "second" +#token AND("AND") "AND" +#token OR("OR") "OR" +#token GrayOutIf("grayoutif") "grayoutif" +#token NOT("NOT") "NOT" +#token Label("label") "label" +#token Timeout("timeout") "timeout" +#token Inventory("inventory") "inventory" +#token StringToken("STRING_TOKEN") "STRING_TOKEN" +#token NonNvDataMap("_NON_NV_DATA_MAP") "_NON_NV_DATA_MAP" +#token Struct("struct") "struct" +#token Uint64("UINT64") "UINT64" +#token Uint32("UINT32") "UINT32" +#token Uint16("UINT16") "UINT16" +#token Char16("CHAR16") "CHAR16" +#token Uint8("UINT8") "UINT8" +#token Guid("guid") "guid" +#token CheckBox("checkbox") "checkbox" +#token EndCheckBox("endcheckbox") "endcheckbox" +#token Numeric("numeric") "numeric" +#token EndNumeric("endnumeric") "endnumeric" +#token Minimum("minimum") "minimum" +#token Maximum("maximum") "maximum" +#token Step("step") "step" +#token Default("default") "default" +#token Password("password") "password" +#token EndPassword("endpassword") "endpassword" +#token String("string") "string" +#token EndString("endstring") "endstring" +#token MinSize("minsize") "minsize" +#token MaxSize("maxsize") "maxsize" +#token Encoding("encoding") "encoding" +#token SuppressIf("suppressif") "suppressif" +#token Hidden("hidden") "hidden" +#token Goto("goto") "goto" +#token InconsistentIf "inconsistentif" +#token EndIf("endif") "endif" +#token IdEqId("ideqid") "ideqid" +#token IdEqVal("ideqval") "ideqval" +#token VarEqVal("vareqval") "vareqval" +#token Var("var") "var" +#token IdEqValList("ideqvallist") "ideqvallist" +#token Length("length") "length" +#token Values("values") "values" +#token Key("key") "key" +#token DefaultFlag("DEFAULT") "DEFAULT" +#token ManufacturingFlag("MANUFACTURING") "MANUFACTURING" +#token InteractiveFlag("INTERACTIVE") "INTERACTIVE" +#token NVAccessFlag("NV_ACCESS") "NV_ACCESS" +#token ResetRequiredFlag("RESET_REQUIRED") "RESET_REQUIRED" +#token LateCheckFlag("LATE_CHECK") "LATE_CHECK" +#token Class("class") "class" +#token Subclass("subclass") "subclass" +#token TypeDef("typedef") "typedef" +#token Restore("restore") "restore" +#token Save("save") "save" +#token Defaults("defaults") "defaults" +#token Banner("banner") "banner" +#token Align("align") "align" +#token Left("left") "left" +#token Right("right") "right" +#token Center("center") "center" +#token Line("line") "line" +#token VarStore("varstore") "varstore" +#token Name("name") "name" +#token Oem("oem") "oem" +#token True("TRUE") "TRUE" +#token False("FALSE") "FALSE" +#token GreaterThan(">") ">" +#token GreaterEqual(">=") ">=" +#token LessThan("<") "<" +#token LessEqual("<=") "<=" + +// +// Define the class and subclass tokens +// +#token ClassNonDevice("NONDEVICE") "NON_DEVICE" +#token ClassDiskDevice("DISK_DEVICE") "DISK_DEVICE" +#token ClassVideoDevice("VIDEO_DEVICE") "VIDEO_DEVICE" +#token ClassNetworkDevice("NETWORK_DEVICE") "NETWORK_DEVICE" +#token ClassInputDevice("INPUT_DEVICE") "INPUT_DEVICE" +#token ClassOnBoardDevice("ONBOARD_DEVICE") "ONBOARD_DEVICE" +#token ClassOtherDevice("OTHER_DEVICE") "OTHER_DEVICE" + +#token SubclassSetupApplication("SETUP_APPLICATION") "SETUP_APPLICATION" +#token SubclassGeneralApplication("GENERAL_APPLICATION") "GENERAL_APPLICATION" +#token SubclassFrontPage("FRONT_PAGE") "FRONT_PAGE" +#token SubclassSingleUse("SINGLE_USE") "SINGLE_USE" + +#token LanguageIdentifier("language identifier") "[a-z][a-z][a-z]" // 3 lowercase characters +#token StringIdentifier("string identifier") "[A-Za-z_][A-Za-z_0-9]*" +#token Number("numeric value") "(0x[0-9A-Fa-f]+) | [0-9]+" +#token OpenBrace("{") "\{" +#token CloseBrace("}") "\}" +#token OpenParen("(") "\(" +#token CloseParen(")") "\)" +#token OpenBracket("[") "\[" +#token CloseBracket("]") "\]" + +// +// Define all other invalid characters so that they get through the lexical phase +// and we can catch them during the parse phase. We get much better error +// messages then. +// +#token InvalidCharacters("invalid characters") "~[;:=,\.\|]" + +// +// This is the overall definition of a VFR form definition script. +// +program : + ( dataStructDefinition )* + formSetStatement + ( vfrStatementVarStore )* + ( formDefinition )* + EFS:EndFormSet ";" << WriteOpByte (EFS->getLine(), EFI_IFR_END_FORM_SET_OP); >> + "@" // end of file + ; + +formSetStatement : + FS:FormSet << WriteOpByte (FS->getLine(), EFI_IFR_FORM_SET_OP); >> + Guid "=" + OpenBrace + G1:Number "," + G2:Number "," + G3:Number "," + G4:Number "," + G5:Number "," + G6:Number "," + G7:Number "," + G8:Number "," + G9:Number "," + G10:Number "," + G11:Number + CloseBrace << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (), + G4->getText (), G5->getText (), G6->getText (), G7->getText (), + G8->getText (), G9->getText (), G10->getText (), G11->getText () + ); + >> + "," + Title "=" getStringId "," + Help "=" getStringId "," + // + // insert padding for an EFI_PHYSICAL_ADDRESS (UINT64) + // + << WriteDWord (0, 0); WriteDWord (0, 0); >> + Class "=" CVAL:classDefinition "," << WriteClass (); >> + Subclass "=" SVAL:subclassDefinition "," << WriteSubclass (); >> + << WriteWord (mNvDataStructSize); >> + ; + +// +// A form can be of multiple classes, thus allow CLASS_A | CLASS_B | CLASS_C +// +classDefinition : + validClassNames ( "\|" validClassNames )* + ; + +validClassNames : + CND:ClassNonDevice << SetClass (CND->getLine(), EFI_NON_DEVICE_CLASS); >> + | CDD:ClassDiskDevice << SetClass (CDD->getLine(), EFI_DISK_DEVICE_CLASS); >> + | CVD:ClassVideoDevice << SetClass (CVD->getLine(), EFI_VIDEO_DEVICE_CLASS); >> + | CNW:ClassNetworkDevice << SetClass (CNW->getLine(), EFI_NETWORK_DEVICE_CLASS); >> + | CID:ClassInputDevice << SetClass (CID->getLine(), EFI_INPUT_DEVICE_CLASS); >> + | COB:ClassOnBoardDevice << SetClass (COB->getLine(), EFI_ON_BOARD_DEVICE_CLASS); >> + | COD:ClassOtherDevice << SetClass (COD->getLine(), EFI_OTHER_DEVICE_CLASS); >> + | CNUM:Number << SetClass (CNUM->getLine(), GetNumber (CNUM->getText(), CNUM->getLine(), 4)); >> + ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid class"); >> + +// +// A form can only be of one subclass type. +// +subclassDefinition : + SSA:SubclassSetupApplication << SetSubclass (SSA->getLine(), EFI_SETUP_APPLICATION_SUBCLASS); >> + | SGA:SubclassGeneralApplication << SetSubclass (SGA->getLine(), EFI_GENERAL_APPLICATION_SUBCLASS); >> + | SFP:SubclassFrontPage << SetSubclass (SFP->getLine(), EFI_FRONT_PAGE_SUBCLASS); >> + | SSU:SubclassSingleUse << SetSubclass (SSU->getLine(), EFI_SINGLE_USE_SUBCLASS); >> + | SNUM:Number << SetSubclass (SNUM->getLine(), GetNumber (SNUM->getText(), SNUM->getLine(), 4)); >> + ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid subclass"); >> + +// +// Parse a C type data structure for storing VFR setup data. Allow: +// typedef struct _XXX_ { +// (fields) +// } MY_NV_DATA; +// +dataStructDefinition : + << int IsNonNV = 0; >> + { TypeDef } + S:Struct + ( + NonNvDataMap << IsNonNV = 1; >> + | + { StringIdentifier } + ) << StartStructDefinition (IsNonNV, S->getLine()); >> + OpenBrace + dataStructFields + CloseBrace NAME:StringIdentifier << EndStructDefinition (NAME->getText(), NAME->getLine()); >> + ";" + ; + +dataStructFields : + ( dataStructField64 | dataStructField32 | dataStructField16 | dataStructField8 ) * + ; + +//***************************************************************************** +// +// PARSE: +// UINT64 Name[4]; +// UINT64 Name; +// +// Used while parsing the NV data map structures. +// +dataStructField64 : + << int ArrayLength = 1; char IsArray = 0; >> + "UINT64" + NAME:StringIdentifier + ( ";" | OpenBracket IVal:Number CloseBracket ";" << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) + << AddStructField (NAME->getText(), NAME->getLine(), 8, ArrayLength, IsArray); >> + ; + +//***************************************************************************** +// +// PARSE: +// UINT32 Name[4]; +// UINT32 Name; +// +// Used while parsing the NV data map structures. +// +dataStructField32 : + << int ArrayLength = 1; char IsArray = 0; >> + "UINT32" + NAME:StringIdentifier + ( ";" | OpenBracket IVal:Number CloseBracket ";" << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) + << AddStructField (NAME->getText(), NAME->getLine(), 4, ArrayLength, IsArray); >> + ; + +//***************************************************************************** +// +// PARSE: +// UINT16 Name[4]; +// UINT16 Name; +// +// Used while parsing the NV data map structures. +// +dataStructField16 : + << int ArrayLength = 1; char IsArray = 0; >> + ( "UINT16" | "CHAR16" ) + NAME:StringIdentifier + ( ";" | OpenBracket IVal:Number CloseBracket ";" << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) + << AddStructField (NAME->getText(), NAME->getLine(), 2, ArrayLength, IsArray); >> + ; + +//***************************************************************************** +// +// PARSE: +// UINT8 Name[4]; +// UINT8 Name; +// +// Used while parsing the NV data map structures. +// +dataStructField8 : + << int ArrayLength = 1; char IsArray = 0; >> + "UINT8" + NAME:StringIdentifier + ( ";" | OpenBracket IVal:Number CloseBracket ";" << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) + << AddStructField (NAME->getText(), NAME->getLine(), 1, ArrayLength, IsArray); >> + ; + +//***************************************************************************** +// +// PARSE: +// form formid = 1, +// title = STRING_TOKEN(STR_FORM_TITLE); +// -- form statements -- +// endform; +// +// The Form ID cannot be 0 +// +formDefinition : + FRM:Form FormId << WriteOpByte (FRM->getLine(), EFI_IFR_FORM_OP); >> + "=" + VAL:Number << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); AddFormId (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine()); >> + "," + Title "=" getStringId ";" // writes string identifier + ( vfrStatements )* + ENDF:EndForm ";" << WriteOpByte (ENDF->getLine(), EFI_IFR_END_FORM_OP); >> + ; + +// +// VFR statements in a formset +// +vfrStatements : + vfrStatementSubTitle | + vfrStatementOneOf | + vfrStatementTextText | + vfrStatementCheckBox | + vfrStatementNumeric | + vfrStatementDate | + vfrStatementTime | + vfrStatementPassword | + vfrStatementString | + vfrStatementSuppressIf | + vfrStatementHidden | + vfrStatementGoto | + vfrStatementGrayOutIf | + vfrStatementInconsistentIf | + vfrStatementLabel | + vfrStatementBanner | + vfrStatementInventory | + vfrStatementOrderedList | + vfrStatementOem | + vfrStatementSaveRestoreDefaults + ; + +//***************************************************************************** +// +// PARSE: +// label 100; +// +vfrStatementLabel : + OPID:Label << WriteOpByte (OPID->getLine(), EFI_IFR_LABEL_OP); >> + VAL:Number << + WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); + AddLabel (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine()); + >> + ";" + ; + +//***************************************************************************** +// +// PARSE: +// oem 0x12, 0x34, 0x56; +// +vfrStatementOem : + OPID:Oem << WriteOpByte (OPID->getLine(), EFI_IFR_OEM_DEFINED_OP); >> + ( VAL1:Number << WriteByte (GetNumber (VAL1->getText(), VAL1->getLine(), 1), 0); >> ) + ( "," VAL2:Number << WriteByte (GetNumber (VAL2->getText(), VAL2->getLine(), 1), 0); >> )* + ";" + ; + +//***************************************************************************** +// +// PARSE: +// inconsistentif NOT .... AND NOT .... OR ... endif; +// +vfrStatementInconsistentIf : + << ResetFlags (); >> + IIFOP:InconsistentIf << WriteOpByte (IIFOP->getLine(), EFI_IFR_INCONSISTENT_IF_OP); >> + Prompt "=" getStringId "," + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," + } + << WriteFlags (); >> // write the flags field + vfrBooleanExpression + EOP:EndIf ";" << WriteOpByte (EOP->getLine(), EFI_IFR_END_IF_OP); >> + ; + +//***************************************************************************** +// +// PARSE: +// TRUE AND (ideqval SomeStruct.SomeMember >= 0x10 OR +// ideqid SomeStruct.SomeMember < SomeStruct.SomeOtherMember) AND +// (ideqlist SomeStruct.SomeOtherMember == 0x10, 0x20, 0x30 OR +// vareqval var(VAR_EQ_TEST_NAME) == 0x1) +// +// For supporting complex express, divide the vfrBooleanExpression to two parts +// so that pred-LL(k) parser can parse incrementally. +// +vfrBooleanExpression : + leftPartVfrBooleanExp { rightPartVfrBooleanExp } + ; + +leftPartVfrBooleanExp : + OpenParen vfrBooleanExpression CloseParen | + (ideqval | ideqid | ideqvallist | vareqval | truefalse) | + NOPID:NOT leftPartVfrBooleanExp << WriteOpByte (NOPID->getLine(), EFI_IFR_NOT_OP); >> + ; + +rightPartVfrBooleanExp : + AOPID:AND vfrBooleanExpression << WriteOpByte (AOPID->getLine(), EFI_IFR_AND_OP); >> | + OOPID:OR vfrBooleanExpression << WriteOpByte (OOPID->getLine(), EFI_IFR_OR_OP); >> + ; + +//***************************************************************************** +// +// PARSE: +// TRUE +// +truefalse : + TOPID:True << WriteOpByte (TOPID->getLine(), EFI_IFR_TRUE_OP); >> | + FOPID:False << WriteOpByte (FOPID->getLine(), EFI_IFR_FALSE_OP); >> + ; + +//***************************************************************************** +// +// PARSE: +// varstore MY_STRUCT_NAME, key = 0x1234, name = "MyVariableName", guid = {...}; +// +vfrStatementVarStore : + OP:VarStore << WriteOpByte (OP->getLine(), EFI_IFR_VARSTORE_OP); >> + STRUCT_NAME:StringIdentifier "," + Key "=" KNUM:Number "," + Name "=" VAR_NAME:StringIdentifier "," + Guid "=" + OpenBrace + G1:Number "," + G2:Number "," + G3:Number "," + G4:Number "," + G5:Number "," + G6:Number "," + G7:Number "," + G8:Number "," + G9:Number "," + G10:Number "," + G11:Number + CloseBrace << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (), + G4->getText (), G5->getText (), G6->getText (), G7->getText (), + G8->getText (), G9->getText (), G10->getText (), G11->getText () + ); + WriteWord (GetNumber (KNUM->getText(), KNUM->getLine(), 2)); + AddVarStore (STRUCT_NAME->getText(), VAR_NAME->getText(), GetNumber (KNUM->getText(), KNUM->getLine(), 2), STRUCT_NAME->getLine()); + >> + + ";" + ; + +//***************************************************************************** +// +// PARSE: +// vareqval var(0x100) == 0x20 +// +vareqval : + OPID:VarEqVal << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_VAR_VAL_OP); >> + Var OpenParen + VAR:Number << WriteWord (GetNumber (VAR->getText(), VAR->getLine(), 2)); >> + CloseParen + compareNumber + ; + +ideqval : + OPID:IdEqVal << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_VAL_OP); >> + vfrStructFieldName[0] + compareNumber + ; + +//***************************************************************************** +// +// PARSE: +// ideqid MyNVData3.Field16A == MyNVData3.Field16B +// +// NOTE: Before processing the second variable store in the ideqid statement, set a global flag +// so that when we parse the second variable we set the secondary variable store id. +// +ideqid : + OPID:IdEqId << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_ID_OP); >> + vfrStructFieldName[0] + compareVfrStructFieldNameNL0 + ; + +//***************************************************************************** +// +// compareNumber is the combination of compare operation and Number +// +compareNumber : + ( + "==" + VAL1:Number << WriteWord (GetNumber (VAL1->getText(), VAL1->getLine(), 2)); >> + ) | + ( + GTOPID:GreaterThan + VAL2:Number << WriteWord (GetNumber (VAL2->getText(), VAL2->getLine(), 2)); + WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >> + ) | + ( + GEOPID:GreaterEqual + VAL3:Number << WriteWord (GetNumber (VAL3->getText(), VAL3->getLine(), 2)); + WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >> + ) | + ( + LTOPID:LessThan + VAL4:Number << WriteWord (GetNumber (VAL4->getText(), VAL4->getLine(), 2)); + WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP); + WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >> + ) | + ( + LEOPID:LessEqual + VAL5:Number << WriteWord (GetNumber (VAL5->getText(), VAL5->getLine(), 2)); + WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP); + WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >> + ) + ; + +//***************************************************************************** +// +// compareVfrStructFieldNameNL0 is the combination of compare operation and vfrStructFieldNameNL[0] +// +compareVfrStructFieldNameNL0 : + ( + "==" << mIdEqIdStmt = 1; >> + vfrStructFieldNameNL[0] << mIdEqIdStmt = 0; >> + ) | + ( + GTOPID:GreaterThan << mIdEqIdStmt = 1; >> + vfrStructFieldNameNL[0] << mIdEqIdStmt = 0; + WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >> + ) | + ( + GEOPID:GreaterEqual << mIdEqIdStmt = 1; >> + vfrStructFieldNameNL[0] << mIdEqIdStmt = 0; + WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >> + ) | + ( + LTOPID:LessThan << mIdEqIdStmt = 1; >> + vfrStructFieldNameNL[0] << mIdEqIdStmt = 0; + WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP); + WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >> + ) | + ( + LEOPID:LessEqual << mIdEqIdStmt = 1; >> + vfrStructFieldNameNL[0] << mIdEqIdStmt = 0; + WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP); + WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >> + ) + ; + + +ideqvallist : + OPID:IdEqValList << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_LIST_OP); >> + vfrStructFieldName[0] + "==" + ( VAL:Number << QueueIdEqValList (GetNumber (VAL->getText(), VAL->getLine(), 2)); >> ) + + << FlushQueueIdEqValList(); >> + ; + +vfrStatementGoto : + << UINT32 LineNum, KeyValue = 0; ResetFlags (); >> + IDG:Goto << WriteOpByte (IDG->getLine(), EFI_IFR_REF_OP); >> + VAL:Number "," << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); + AddGotoReference (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine()); + >> + KP:Prompt "=" getStringId "," << LineNum = KP->getLine(); >> + Help "=" getStringId + { + "," + FF:Flags "=" flagsField ( "\|" flagsField )* << LineNum = FF->getLine(); >> + } + { + "," Key "=" KNUM:Number << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >> + } + << WriteFlagsKey (KeyValue, LineNum); >> + ";" + ; + +vfrStatementHidden : + IDH:Hidden << WriteOpByte (IDH->getLine(), EFI_IFR_HIDDEN_OP); >> + Value "=" + VAL:Number "," << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); >> + Key "=" + KVAL:Number << WriteWord (GetNumber (KVAL->getText(), KVAL->getLine(), 2)); >> + ";" + ; + +//***************************************************************************** +// +// PARSE: +// suppressif { grayoutif } + endif; +// Note: +// You can have: suppressif:grayoutif:statements:endif +// suppressif:grayoutif:endif -- serves no purpose +// suppressif:statements:endif +// suppressif:endif -- serves no purpose +// +vfrStatementSuppressIf : + << ResetFlags (); >> + OPID:SuppressIf << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," + } + << WriteFlags (); >> // write the flags field + vfrBooleanExpression + ";" + { suppressIfGrayOutIf } ( suppressIfAndGrayoutIfSubstatements )+ + ENDOP:EndIf ";" << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >> + ; + +// +// This is the form for a grayoutif nested in a suppressif statement +// +suppressIfGrayOutIf : + << ResetFlags (); >> + OPID:GrayOutIf << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," + } + << WriteFlags (); >> // write the flags field + vfrBooleanExpression + ";" + ; + +//***************************************************************************** +// +// PARSE: +// grayoutif { flags = n, } endif; +// Note: +// You can have: grayoutif:suppressif:statements:endif +// grayoutif:statements:endif +// +// +vfrStatementGrayOutIf : + << ResetFlags (); >> + OPID:GrayOutIf << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," + } + << WriteFlags (); >> // write the flags field + vfrBooleanExpression + ";" + { grayoutIfSuppressIf } ( suppressIfAndGrayoutIfSubstatements )+ + ENDOP:EndIf ";" << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >> + ; + +// +// This is the format for a suppressif nested in a grayoutif +// +grayoutIfSuppressIf : + << ResetFlags (); >> + OPID:SuppressIf << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," + } + << WriteFlags (); >> // write the flags field + vfrBooleanExpression + ";" + ; + +// +// These are the VFR statements that are valid inside a suppressif or grayoutif statement. +// +suppressIfAndGrayoutIfSubstatements : + vfrStatementOneOf | + vfrStatementTextText | + vfrStatementCheckBox | + vfrStatementNumeric | + vfrStatementDate | + vfrStatementTime | + vfrStatementPassword | + vfrStatementString | + vfrStatementHidden | + vfrStatementGoto | + vfrStatementLabel | + vfrStatementInventory | + vfrStatementOrderedList | + vfrStatementSaveRestoreDefaults + ; + +//***************************************************************************** +// +// PARSE: +// +// password varid = MyNvData.Password, +// prompt = STRING_TOKEN(STR_PASSWORD_PROMPT), +// help = STRING_TOKEN(STR_PASSWORD_HELP), +// minsize = 6, +// maxsize = 20, +// encoding = 1, +// endpassword; + +vfrStatementPassword : + << UINT32 KeyValue = 0; UINT32 LineNum; ResetFlags (); >> + IDPW:Password << WriteOpByte (IDPW->getLine(), EFI_IFR_PASSWORD_OP); >> + VarId "=" vfrStructFieldNameArray[0] "," + Prompt "=" getStringId "," + KH:Help "=" getStringId "," << LineNum = KH->getLine(); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," << LineNum = FF->getLine(); >> + } + { + Key "=" KNUM:Number "," << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >> + } + << WriteFlagsKey (KeyValue, LineNum); >> + MinSize "=" MIN:Number "," << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0); >> + MaxSize "=" MAX:Number "," << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >> + Encoding "=" ENC:Number "," << WriteWord (GetNumber (ENC->getText(), ENC->getLine(), 2)); >> + EndPassword ";" + ; + +//***************************************************************************** +// +// PARSE: +// +// string varid = MyNv.String, +// prompt = STRING_TOKEN(STR_STRING_PROMPT), +// help = STRING_TOKEN(STR_STRING_HELP), +// flags = INTERACTIVE, +// key = 0x1234, +// minsize = 6, +// maxsize = 0x14, +// endstring; +// +// Since flags and key are optional, we can't use Flags->getLine(). Therefore for error +// reporting we save the line number of the "help" keyword. +// +vfrStatementString : + << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >> + IDS:String << WriteOpByte (IDS->getLine(), EFI_IFR_STRING_OP); >> + VarId "=" vfrStructFieldNameArray[0] "," + Prompt "=" getStringId "," + KH:Help "=" getStringId "," << LineNum = KH->getLine(); >> + { + FF:Flags "=" + flagsField ( "\|" flagsField )* << LineNum = FF->getLine(); >> + "," + } + { + Key "=" KNUM:Number "," << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >> + } + << WriteFlagsKey (KeyValue, LineNum); >> + MinSize "=" MIN:Number "," << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0); >> + MaxSize "=" MAX:Number "," << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >> + EndString ";" + ; + +//***************************************************************************** +// +// PARSE: +// numeric varid = MyIfrNVData.HowOldAreYouInYears, +// prompt = STRING_TOKEN(STR_NUMERIC_PROMPT), +// help = STRING_TOKEN(STR_NUMERIC_HELP), +// flags = INTERACTIVE, // flags is optional +// key = 0x1234, // key is optional if (flags & INTERACTIVE = 0) +// minimum = 0x0, +// maximum = 0xf0, +// step = 1, // step is option, and step=1 if not specified +// default = 0; // default is optional, and default=minimum if not specified +// endnumeric; +// +// Make flags and key optional. However if flags includes INTERACTIVE, then a key is required. +// That check is done in WriteFlagsKey() function. +// +vfrStatementNumeric : + << UINT32 LineNum, KeyValue = 0; ResetFlags (); >> + IDN:Numeric << WriteOpByte (IDN->getLine(), EFI_IFR_NUMERIC_OP); >> + VarId "=" vfrStructFieldName[2] "," + Prompt "=" getStringId "," + KH:Help "=" getStringId "," << LineNum = KH->getLine(); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," << LineNum = FF->getLine (); >> + } + { + Key "=" KNUM:Number "," << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >> + } + << WriteFlagsKey (KeyValue, LineNum); >> + minMaxStepDefault + EndNumeric ";" << WriteMinMaxStepDefault (); >> + ; + +// +// Parse minimum/maximum/step/default statements. Special cases: +// - if step not specified, then the value is 1 +// - if default not specified, then the value is the min value specified +// - if max < min, print a warning and swap the values (changes default too) +// +minMaxStepDefault : + << InitMinMaxStepDefault (); >> + Minimum "=" MIN:Number "," << SetMinMaxStepDefault (GetNumber (MIN->getText(), MIN->getLine(), 2), 0, MIN->getLine()); >> + Maximum "=" MAX:Number "," << SetMinMaxStepDefault (GetNumber (MAX->getText(), MAX->getLine(), 2), 1, MAX->getLine()); >> + { Step "=" STEP:Number "," << SetMinMaxStepDefault (GetNumber (STEP->getText(), STEP->getLine(), 2), 2, STEP->getLine()); >> } + { Default "=" DEF:Number "," << SetMinMaxStepDefault (GetNumber (DEF->getText(), DEF->getLine(), 2), 3, DEF->getLine()); >> } + ; + + +//***************************************************************************** +// +// PARSE: +// +// date year varid = Date.Year, // "Date.Year" is a special case we recognize +// prompt = STRING_TOKEN(STR_DATE_PROMPT), +// help = STRING_TOKEN(STR_DATE_YEAR_HELP), +// minimum = 1939, +// maximum = 2101, +// step = 1, +// default = 1964, +// +// month varid = Date.Month, +// prompt = STRING_TOKEN(STR_DATE_PROMPT), +// help = STRING_TOKEN(STR_DATE_MONTH_HELP), +// minimum = 1, +// maximum = 12, +// step = 1, +// default = 1, +// +// day varid = Date.Day, +// prompt = STRING_TOKEN(STR_DATE_PROMPT), +// help = STRING_TOKEN(STR_DATE_DAY_HELP), +// minimum = 1, +// maximum = 31, +// step = 0x1, +// default = 1, +// +// enddate; +// +vfrStatementDate : + Date + IDY:Year VarId "=" << WriteOpByte (IDY->getLine(), EFI_IFR_DATE_OP); >> + vfrStructFieldName[2] "," + dateTimeSubStatement + IDM:Month VarId "=" << WriteOpByte (IDM->getLine(), EFI_IFR_DATE_OP); >> + vfrStructFieldName[2] "," + dateTimeSubStatement + IDD:Day VarId "=" << WriteOpByte (IDD->getLine(), EFI_IFR_DATE_OP); >> + vfrStructFieldName[2] "," + dateTimeSubStatement + EndDate ";" + ; + +vfrStatementTime : + Time + IDH:Hour VarId "=" << WriteOpByte (IDH->getLine(), EFI_IFR_TIME_OP); >> + vfrStructFieldName[2] "," + dateTimeSubStatement + IDM:Minute VarId "=" << WriteOpByte (IDM->getLine(), EFI_IFR_TIME_OP); >> + vfrStructFieldName[2] "," + dateTimeSubStatement + IDS:Second VarId "=" << WriteOpByte (IDS->getLine(), EFI_IFR_TIME_OP); >> + vfrStructFieldName[2] "," + dateTimeSubStatement + EndTime ";" + ; + +//***************************************************************************** +// +// PARSE: +// +// text text = STRING_ID; +// text text = STRING_ID, text = STRING_ID; +// text text = STRING_ID, text = STRING_ID, flags = x, key = y; +// +vfrStatementTextText : + << ResetFlags (); >> + IDT:Text << WriteOpByte (IDT->getLine(), EFI_IFR_TEXT_OP); >> + Help "=" getStringId "," + Text "=" + getStringId // writes string identifier + { "," Text "=" getStringId + "," Flags "=" flagsField ( "\|" flagsField )* << WriteFlags (); >> + "," + Key "=" KNUM:Number << WriteWord (GetNumber(KNUM->getText(), KNUM->getLine(), 2)); >> + } + ";" + ; + +//***************************************************************************** +// +// PARSE: +// +// inventory help = ID, text = ID; +// inventory help = ID, text = id, text = ID; +// +vfrStatementInventory : + IDI:Inventory << WriteOpByte (IDI->getLine(), EFI_IFR_INVENTORY_OP); >> + Help "=" getStringId "," + Text "=" getStringId // writes string identifier + { "," Text "=" getStringId + } + ";" + ; + +//***************************************************************************** +// +// PARSE: +// +// restore defaults, +// formid = 4, +// prompt = STRING_TOKEN(STR_RESTORE_DEFAULTS_PROMPT), +// help = STRING_TOKEN(STR_RESTORE_DEFAULTS_HELP), +// flags = 0, +// key = 0; +// +// save defaults, +// formid = 4, +// prompt = STRING_TOKEN(STR_SAVE_DEFAULTS_PROMPT), +// help = STRING_TOKEN(STR_SAVE_DEFAULTS_HELP), +// flags = 0, +// key = 0; +// +vfrStatementSaveRestoreDefaults : + << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >> + ( IDS:Save << WriteOpByte (IDS->getLine(), EFI_IFR_SAVE_DEFAULTS_OP); >> + | IDR:Restore << WriteOpByte (IDR->getLine(), EFI_IFR_RESTORE_DEFAULTS_OP); >> + ) + Defaults "," + FormId "=" FRMID:Number "," << WriteWord (GetNumber (FRMID->getText(), FRMID->getLine(), 2)); + AddGotoReference (GetNumber (FRMID->getText(), FRMID->getLine(), 2), FRMID->getLine()); + >> + Prompt "=" getStringId "," + KH:Help "=" getStringId << LineNum = KH->getLine(); >> + { + "," FF:Flags "=" flagsField ( "\|" flagsField )* << LineNum = FF->getLine(); >> + } + { + "," Key "=" KNUM:Number << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >> + } + << WriteFlagsKey (KeyValue, LineNum); >> + ";" + ; + +//***************************************************************************** +// +// PARSE: +// +// flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK +// +// +flagsField : + VAL:Number << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >> + | IF:InteractiveFlag << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine()); >> + | MF:ManufacturingFlag << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine()); >> + | DF:DefaultFlag << SetFlags (EFI_IFR_FLAG_DEFAULT, DF->getLine()); >> + | NV:NVAccessFlag << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine()); >> + | RR:ResetRequiredFlag << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >> + | LC:LateCheckFlag << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine()); >> + ; + +dateTimeSubStatement : + Prompt "=" getStringId "," + Help "=" getStringId "," + << WriteByte (0, 0); WriteWord (0); >> // bogus flags and key + minMaxStepDefault << WriteMinMaxStepDefault (); >> + ; + +vfrStatementCheckBox : + << UINT32 LineNum, KeyValue = 0; ResetFlags (); >> + IDCB:CheckBox << WriteOpByte (IDCB->getLine(), EFI_IFR_CHECKBOX_OP); >> + VarId "=" vfrStructFieldName[1] "," + Prompt "=" getStringId "," + Help "=" getStringId "," + FF:Flags "=" flagsField ( "\|" flagsField )* "," << LineNum = FF->getLine(); >> + { + Key "=" KV:Number "," << LineNum = KV->getLine(); KeyValue = GetNumber(KV->getText(), LineNum, 2); >> + } + << WriteFlagsKey (KeyValue, LineNum); >> + EndCheckBox ";" + ; + +vfrStatementSubTitle : + IDS:Subtitle Text "=" << WriteOpByte (IDS->getLine(), EFI_IFR_SUBTITLE_OP); >> + getStringId // writes string indentifier + ";" + ; + +//***************************************************************************** +// +// PARSE: +// banner +// title = STRING_TOKEN(STR_BANNER_TITLE), +// line 1, +// align center; // or left or right +// +// banner, +// title = STRING_TOKEN(STR_BANNER_TITLE), timeout = 100; +// +vfrStatementBanner : + IDB:Banner { "," } << WriteOpByte (IDB->getLine(), EFI_IFR_BANNER_OP); >> + Title "=" getStringId "," + ( + Line VAL:Number "," << WriteWord (GetNumber(VAL->getText(), VAL->getLine(), 2)); >> + Align + ( Left << WriteByte (EFI_IFR_BANNER_ALIGN_LEFT, 0); >> + | Center << WriteByte (EFI_IFR_BANNER_ALIGN_CENTER, 0); >> + | Right << WriteByte (EFI_IFR_BANNER_ALIGN_RIGHT, 0); >> + ) ";" + | + Timeout "=" TO:Number ";" << WriteWord (GetNumber(TO->getText(), TO->getLine(), 2)); >> + << WriteByte (EFI_IFR_BANNER_TIMEOUT, 0); >> + ) + ; + +//***************************************************************************** +// +// PARSE: +// oneof varid = MyNv.OneOfData, +// prompt = STRING_TOKEN(STR_ONE_OF_PROMPT), +// help = STRING_TOKEN(STR_ONE_OF_HELP), +// option text = STRING_TOKEN(STR_ONE_OF_TEXT), +// value = 0, +// flags = DEFAULT | INTERACTIVE; +// +// supressif/grayoutif are supported inside oneof stmt. +// We do not restrict the number of oneOfOptionText to >=2, but >=1. +// The situation that all oneOfOptionText are suppressed is also possiable. +// +vfrStatementOneOf : + << ResetFlags (); >> + IDOO:OneOf << WriteOpByte (IDOO->getLine(), EFI_IFR_ONE_OF_OP); >> + VarId "=" vfrStructFieldName[2] "," + Prompt "=" getStringId "," // writes string identifier + Help "=" getStringId "," // writes string identifier + ( oneOfOptionText )+ // there must be at least 1 option to be choosed, not 2. + IDEOO:EndOneOf ";" << TestOneOfFlags (IDEOO->getLine()); WriteOpByte (IDEOO->getLine(), EFI_IFR_END_ONE_OF_OP); >> + ; + +//***************************************************************************** +// +// PARSE: +// +// orderedlist varid = MyNv.OrderedListData, +// prompt = STRING_TOKEN(STR_ORDERED_LIST_PROMPT), +// help = STRING_TOKEN(STR_ORDERED_LIST_HELP), +// option text = STRING_TOKEN(STR_ORDERED_LIST_TEXT), value = 0, flags = INTERACTIVE; +// -- additional option text -- +// endlist; +// +vfrStatementOrderedList : + << ResetFlags (); InitOrderedList(); >> + IDOL:OrderedList << WriteOpByte (IDOL->getLine(), EFI_IFR_ORDERED_LIST_OP); >> + VarId "=" vfrStructFieldNameArray[1] "," + Prompt "=" getStringId "," // writes string identifier + Help "=" getStringId "," // writes string identifier + orderedListOptionText ( orderedListOptionText )+ + IDEOL:EndList ";" << WriteOpByte (IDEOL->getLine(), EFI_IFR_END_OP); EndOrderedList(IDEOL->getLine()); >> + ; + +//***************************************************************************** +// +// PARSE: +// +// option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99; +// +// Differs from the oneOfOptionText in that we don't allow the DEFAULT flag to +// be set, and value cannot be 0. +// +orderedListOptionText : + << UINT32 KeyValue = 0; >> + IDO:Option << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >> + Text "=" getStringId "," // writes string identifier + Value "=" WVAL:Number "," << + if (GetNumber(WVAL->getText(), WVAL->getLine(), 2) == 0) { + PrintErrorMessage (WVAL->getLine(), "value=0 is invalid for ordered lists", NULL); + } else { + WriteWord (GetNumber(WVAL->getText(), WVAL->getLine(), 2)); + } + >> + FF:Flags "=" orderedListFlagsField + ("\|" orderedListFlagsField )* + { + "," Key "=" KV:Number << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> + } + << WriteFlagsKey (KeyValue, FF->getLine()); >> + ";" << mOptionCount++; >> + ; + +//***************************************************************************** +// +// PARSE: +// +// flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK +// +// The ordered list flags field cannot have a default. +// +orderedListFlagsField : + VAL:Number << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >> + | IF:InteractiveFlag << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine()); >> + | MF:ManufacturingFlag << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine()); >> + | NV:NVAccessFlag << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine()); >> + | RR:ResetRequiredFlag << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >> + | LC:LateCheckFlag << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine()); >> + | DF:DefaultFlag << PrintWarningMessage (DF->getLine(), "DEFAULT flag not valid for ordered lists", NULL); >> + ; + +// +// Parse references to VFR structure field names of form "MyNvStructure.Field". +// This implementation is specific to strings, passwords, and references in an +// ordered list statement because we want to specify the size of the entire +// field, rather than just one element. Then call a function to write out its +// offset and length. +// +vfrStructFieldNameArray[int FieldWidth] : + << int ArrayIndex = 1; char IsArrayIndex = 0; >> + SName:StringIdentifier + "." + SFieldName:StringIdentifier + { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> } + << + WriteFieldOffset (1, + SName->getText(), + SName->getLine(), + SFieldName->getText(), + SFieldName->getLine(), + ArrayIndex, + IsArrayIndex, + FieldWidth, + 1 + ); + >> + ; + +// +// Parse references to VFR structure field names of form "MyNvStructure.Field", +// then call a function to write out its offset and length. +// +vfrStructFieldName[int FieldWidth] : + << int ArrayIndex = 1; char IsArrayIndex = 0; >> + SName:StringIdentifier + "." + SFieldName:StringIdentifier + { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> } + << + WriteFieldOffset (1, + SName->getText(), + SName->getLine(), + SFieldName->getText(), + SFieldName->getLine(), + ArrayIndex, + IsArrayIndex, + FieldWidth, + 0 + ); + >> + ; + +//***************************************************************************** +// +// PARSE: +// +// MyNvStructure.FieldName[4] +// +// Parse references to VFR structure field names of form "MyNvStructure.Field", +// then call a function to write out the offset with no length. +// +vfrStructFieldNameNL[int FieldWidth] : + << int ArrayIndex = 1; char IsArrayIndex = 0; >> + SName:StringIdentifier + "." + SFieldName:StringIdentifier + { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> } + << + WriteFieldOffset (0, + SName->getText(), + SName->getLine(), + SFieldName->getText(), + SFieldName->getLine(), + ArrayIndex, + IsArrayIndex, + FieldWidth, + 0 + ); + >> + ; + +//***************************************************************************** +// +// PARSE: +// suppressif TRUE OR FALSE; +// grayoutif FALSE OR TRUE; +// option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99; +// option text = STRING_TOKEN(STRING_ID2), value = 1 flags = 98; +// endif; +// +oneOfOptionText : + suppressIfOptionText | + grayOutIfOptionText | + commonOptionText + ; + +suppressIfOptionText : + << ResetFlags (); >> + OPID:SuppressIf << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," + } + << WriteFlags (); >> // write the flags field + vfrBooleanExpression + ";" + { suppressIfGrayOutIf } ( commonOptionText )+ + ENDOP:EndIf ";" << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >> + ; + +grayOutIfOptionText : + << ResetFlags (); >> + OPID:GrayOutIf << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >> + { + FF:Flags "=" flagsField ( "\|" flagsField )* "," + } + << WriteFlags (); >> // write the flags field + vfrBooleanExpression + ";" + { grayoutIfSuppressIf } ( commonOptionText )+ + ENDOP:EndIf ";" << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >> + ; + +commonOptionText : + << UINT32 KeyValue = 0; >> + IDO:Option << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >> + Text "=" getStringId "," // writes string identifier + Value "=" WVal:Number "," << WriteWord (GetNumber(WVal->getText(), WVal->getLine(), 2)); >> + FF:Flags "=" flagsField ("\|" flagsField )* + { + "," Key "=" KV:Number << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> + } + << WriteFlagsKey (KeyValue, FF->getLine()); >> + ";" << mOptionCount++; >> + ; + +// +// Gets a string identifier. It must be a numeric value of form: +// +// STRING_TOKEN(100) +// +getStringId : + << unsigned short StrId; >> + StringToken OpenParen + IdVal:Number << StrId = GetNumber (IdVal->getText(), IdVal->getLine(), 2); WriteStringIdWord (StrId); >> + CloseParen + ; + +//****************************************************************************** +// +// Parser class definition. +// +class EfiVfrParser { +<< +// +// Parser definitions go here +// +private: + STRUCT_DEFINITION *mFirstStructDefinition; + STRUCT_DEFINITION *mLastStructDefinition; + INT32 mNvDataStructSize; + INT32 mNonNvDataStructSize; + // + // Flag to indicate that we're processing a ideqid VFR statement so that + // we can do late checks on the statement. + // + INT32 mIdEqIdStmt; + INT32 mLastNVVariableDataSize; + GOTO_REFERENCE *mGotoReferences; + FORM_ID_VALUE *mFormIdValues; + VfrOpcodeHandler mOpcodeHandler; + UINT16_LIST *mUint16List; + UINT16_LIST *mLastUint16; + UINT16_LIST *mDefinedLabels; + UINT16_LIST *mDefinedVarStoreId; + UINT16_LIST *mLastDefinedVarStoreId; + UINT32 mMinimumValue, mMaximumValue, mStepValue, mDefaultValue; + UINT32 mStmtFlags; + UINT32 mSubStmtFlags; + UINT32 mSubStmtFlagsLineNum; + EFI_GUID mFormSetGuid; + UINT8 mNvDataStructDefined; + UINT16 mClass, mSubclass; + UINT32 mIfStart; + UINT32 mOptionCount; // how many "option" fields in a given statement + UINT32 mLastVarIdSize; + UINT8 mOutput; +public: + +VOID +EfiVfrParser::SetIfStart ( + UINT32 LineNum + ) +/*++ + +Routine Description: + Invoked during VFR parsing when an "if" is encountered. Save the + source line number so we can point to it if we don't find a + corresponding endif later. + +Arguments: + LineNum - source line number where the "if" was parsed. + +Returns: + None + +--*/ +{ + mIfStart = LineNum; +} +VOID +EfiVfrParser::SetClass ( + UINT32 LineNum, + UINT32 Value + ) +/*++ + +Routine Description: + Invoked during VFR parsing when a "class" statement is found. Check the + range on the class value and save it for later. + +Arguments: + LineNum - source line number where the class statement was parsed. + Value - the class value + +Returns: + None + +--*/ +{ + if (Value & 0xFFFF0000) { + PrintWarningMessage (LineNum, NULL, "class value exceeds maximum allowed"); + } + mClass |= (UINT16)Value; +} +VOID +EfiVfrParser::SetSubclass ( + UINT32 LineNum, + UINT32 Value + ) +/*++ + +Routine Description: + Invoked during VFR parsing when a subclass statement is found. Check the + range on the value and save it for later. + +Arguments: + LineNum - source line number where the class statement was parsed. + Value - the subclass value from the VFR statement + +Returns: + None + +--*/ +{ + if (Value & 0xFFFF0000) { + PrintWarningMessage (LineNum, NULL, "subclass value exceeds maximum allowed"); + } + mSubclass |= (UINT16)Value; +} +VOID EfiVfrParser::WriteClass () +{ + WriteWord (mClass); + mClass = 0; +} +VOID EfiVfrParser::WriteSubclass () +{ + WriteWord (mSubclass); + mSubclass = 0; +} +VOID EfiVfrParser::WriteIfrBytes () +{ + mOpcodeHandler.WriteIfrBytes (); +} +VOID +EfiVfrParser::WriteFlagsKey ( + UINT32 KeyValue, + UINT32 LineNum + ) +/*++ + +Routine Description: + Write out the flags and key values from the previous VFR statement. + Many statements take a flags/key pair. If not specified, then 0 + values are written out. However do not allow an interactive flags field + to be specified if no key value is specified. Also, if NV_ACCESS flag + is set but INTERACTIVE is not, then set interactive and issue a warning. + +Arguments: + KeyValue - the key value from the VFR statement + LineNum - source line number where the statement was parsed + +Returns: + None + +--*/ +{ + if ((mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE) && (KeyValue == 0)) { + PrintErrorMessage (LineNum, NULL, "invalid or missing key value - required with INTERACTIVE"); + } + if ((mSubStmtFlags & EFI_IFR_FLAG_NV_ACCESS) && !(mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE)) { + PrintWarningMessage (LineNum, NULL, "NV_ACCESS without INTERACTIVE has no effect -- setting INTERACTIVE"); + mSubStmtFlags |= EFI_IFR_FLAG_INTERACTIVE; + } + WriteFlags (); + WriteWord (KeyValue); +} +VOID +EfiVfrParser::InitOrderedList () +{ + mOptionCount = 0; +} +VOID +EfiVfrParser::EndOrderedList ( + UINT32 LineNum + ) +{ + if (mLastVarIdSize < mOptionCount) { + PrintErrorMessage (LineNum, NULL, "number of options exceeds the variable store size"); + } +} +VOID +EfiVfrParser::ResetFlags () +/*++ + +Routine Description: + + Flags are set for each substatement in a given one-of statement. + To make sure there are no conflicts, for example setting DEFAULT on + more than one substatement, we keep track of the flags at a statement + level and a substatement level. This function resets the flags so + we get a fresh start. + +Arguments: + None + +Returns: + None + +--*/ +{ + mStmtFlags = 0; + mSubStmtFlagsLineNum = 0; + mSubStmtFlags = 0; +} +// +// Test validity of flags value for a one-of statement. +// +VOID +EfiVfrParser::TestOneOfFlags ( + UINT32 LineNum + ) +{ + // + // One of the fields must have had the default bit set + // + if ((mStmtFlags & EFI_IFR_FLAG_DEFAULT) == 0) { + PrintWarningMessage (LineNum, "default value must be specified", NULL); + } +} +VOID +EfiVfrParser::SetFlags ( + UINT32 Flags, + UINT32 LineNum + ) +{ + // + // Check for redefinitions and invalid combinations + // + if (mStmtFlags & Flags & EFI_IFR_FLAG_MANUFACTURING) { + PrintErrorMessage (LineNum, "MANUFACTURING", "a field with this flag already defined"); + } + if (mStmtFlags & Flags & EFI_IFR_FLAG_DEFAULT) { + PrintErrorMessage (LineNum, "DEFAULT", "a field with this flag already defined"); + } + mSubStmtFlags |= Flags; + mSubStmtFlagsLineNum = LineNum; +} +VOID +EfiVfrParser::WriteFlags () +{ + // + // Check value for validity + // + if (mSubStmtFlags & ~(EFI_IFR_FLAG_DEFAULT | + EFI_IFR_FLAG_MANUFACTURING | + EFI_IFR_FLAG_INTERACTIVE | + EFI_IFR_FLAG_NV_ACCESS | + EFI_IFR_FLAG_RESET_REQUIRED | + EFI_IFR_FLAG_LATE_CHECK )) { + PrintWarningMessage (mSubStmtFlagsLineNum, "invalid bits defined in flag", NULL); + } + WriteByte ((UINT8)mSubStmtFlags, 'F'); + // + // We can now clear the substatement flags + // + mStmtFlags |= mSubStmtFlags; + mSubStmtFlags = 0; +} +// +// When we parse a min/max/step/default sequence, save off the values for +// later use. Call this first to init the values. +// +VOID +EfiVfrParser::InitMinMaxStepDefault () +{ + mMinimumValue = 0; + mMaximumValue = 0; + mStepValue = 1; + mDefaultValue = 0; +} +VOID +EfiVfrParser::WriteMinMaxStepDefault () +{ + WriteWord (mMinimumValue); + WriteWord (mMaximumValue); + WriteWord (mStepValue); + WriteWord (mDefaultValue); +} +VOID +EfiVfrParser::SetMinMaxStepDefault ( + UINT16 Value, + INT32 MMSD, + INT32 LineNum + ) +{ + UINT16 TempValue; + // + // Min specified + // + if (MMSD == 0) { + mMinimumValue = Value; + mDefaultValue = Value; + // + // Max specified + // + } else if (MMSD == 1) { + mMaximumValue = Value; + // + // If min > max, then swap the values. That includes resetting the default + // value as well. + // + if (mMinimumValue > mMaximumValue) { + PrintWarningMessage (LineNum, NULL, "maximum < minimum"); + TempValue = Value; + mMaximumValue = mMinimumValue; + mMinimumValue = TempValue; + mDefaultValue = mMinimumValue; + } + // + // Step specified + // + } else if (MMSD == 2) { + mStepValue = Value; + // + // Default specified. Make sure min <= default <= max. + // + } else if (MMSD == 3) { + mDefaultValue = Value; + if (mMinimumValue > Value) { + PrintErrorMessage (LineNum, NULL, "default value < minimum value"); + } else if (Value > mMaximumValue) { + PrintErrorMessage (LineNum, NULL, "default value > maximum value"); + } + } else { + PrintErrorMessage (LineNum, "application error", "internal MMSD error"); + } +} +VOID +EfiVfrParser::AddLabel ( + UINT32 LabelNumber, + UINT32 LineNum + ) +{ + UINT16_LIST *Label; + + // + // Added a label from the user VFR script. Make sure they haven't already + // defined the same label elsewhere + // + for (Label = mDefinedLabels; Label != NULL; Label = Label->Next) { + if (Label->Value == LabelNumber) { + PrintErrorMessage (LineNum, NULL, "label already defined"); + PrintErrorMessage (Label->LineNum, NULL, "previous definition of redefined label"); + break; + } + } + Label = (UINT16_LIST *)malloc (sizeof (UINT16_LIST)); + if (Label == NULL) { + PrintErrorMessage (0, NULL, "memory allocation error"); + return; + } + memset ((char *)Label, 0, sizeof (UINT16_LIST)); + Label->Value = LabelNumber; + Label->LineNum = LineNum; + Label->Next = mDefinedLabels; + mDefinedLabels = Label; +} +VOID +EfiVfrParser::QueueIdEqValList ( + UINT16 Value + ) +{ + UINT16_LIST *U16; + + U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST)); + if (U16 == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed"); + } else { + memset ((char *)U16, 0, sizeof (UINT16_LIST)); + U16->Value = Value; + if (mUint16List == NULL) { + mUint16List = U16; + } else { + mLastUint16->Next = U16; + } + mLastUint16 = U16; + } +} +VOID +EfiVfrParser::FlushQueueIdEqValList () +{ + UINT32 Count; + + // + // We queued up a list of IdEqValList items. The IFR requires a count + // followed by the actual values. Do it. + // + Count = 0; + mLastUint16 = mUint16List; + while (mLastUint16 != NULL) { + Count++; + mLastUint16 = mLastUint16->Next; + } + // BUGBUG -- check for more than 16K items? + WriteWord (Count); + // + // Now write the values. + // + mLastUint16 = mUint16List; + while (mLastUint16 != NULL) { + WriteWord ((UINT32)mLastUint16->Value); + mLastUint16 = mLastUint16->Next; + } + // + // Free up the list + // + mLastUint16 = mUint16List; + while (mUint16List != NULL) { + mLastUint16 = mUint16List->Next; + free (mUint16List); + mUint16List = mLastUint16; + } +} +VOID +EfiVfrParser::PrintErrorMessage ( + UINT32 LineNum, + INT8 *Msg1, + INT8 *Msg2 + ) +{ + char *FileName; + + if (LineNum != 0) { + FileName = ConvertLineNumber ((UINT32 *)&LineNum); + Error (FileName, LineNum, 0, Msg1, Msg2); + } else { + Error (PROGRAM_NAME, 0, 0, Msg1, Msg2); + } +} +VOID +EfiVfrParser::PrintWarningMessage ( + UINT32 LineNum, + INT8 *Msg1, + INT8 *Msg2 + ) +{ + char *FileName; + + if (LineNum != 0) { + FileName = ConvertLineNumber ((UINT32 *)&LineNum); + Warning (FileName, LineNum, 0, Msg1, Msg2); + } else { + Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2); + } +} +VOID +EfiVfrParser::syn ( + ANTLRAbstractToken *Tok, + ANTLRChar *Egroup, + SetWordType *Eset, + ANTLRTokenType ETok, + INT32 Huh + ) +/*++ + +Routine Description: + Called by the parser base class as a result of parse syntax errors. + +Arguments: + Tok - token that caused the error + Egroup - not sure + Eset - index in token table of the expected token + Huh - not sure + +Returns: + NA + +--*/ +{ + char *FileName; + UINT32 LineNum; + + LineNum = Tok->getLine (); + FileName = ConvertLineNumber ((UINT32 *)&LineNum); + // + // Sometimes the token number is 0, in which case I don't know what to + // print. + // + if (ETok == 0) { + Error (FileName, LineNum, 0, Tok->getText (), "unexpected token"); + } else { + // + // If we were expecting an endif, then report the line where the corresponding + // IF began. + // + if ((strcmp (_token_tbl[ETok], "endif") == 0) && (mIfStart != 0)) { + LineNum = mIfStart; + FileName = ConvertLineNumber (&LineNum); + Error (FileName, LineNum, 0, "statement missing corresponding endif", NULL); + } else { + Error (FileName, LineNum, 0, Tok->getText (), "expected %s", _token_tbl[ETok]); + } + } +} + +VOID +EfiVfrParser::init() +/*++ + +Routine Description: + Initializations function for our parser. + +Arguments: + None. + +Returns: + None. + +--*/ +{ + ANTLRParser::init(); + + // + // Used for queuing a variable list of UINT16's + // + mUint16List = NULL; + mLastUint16 = NULL; + mFirstStructDefinition = NULL; + mLastStructDefinition = NULL; + mNvDataStructSize = 0; + mNonNvDataStructSize = 0; + mNvDataStructDefined = 0; + mGotoReferences = NULL; + mFormIdValues = NULL; + mDefinedLabels = NULL; + mClass = 0; + mSubclass = 0; + mIfStart = 0; + mDefinedVarStoreId = NULL; + mLastDefinedVarStoreId = NULL; + mIdEqIdStmt = 0; + mLastNVVariableDataSize = 0; + + memset ((char *)&mFormSetGuid, 0, sizeof (EFI_GUID)); +} +// +// Destructor for the parser. +// +EfiVfrParser::~EfiVfrParser(VOID) +{ + Cleanup(); +} +VOID +EfiVfrParser::Cleanup (VOID) +/*++ + +Routine Description: + Free memory allocated during parsing + +Arguments: + None. + +Returns: + None. + +--*/ +{ + STRUCT_DEFINITION *NextStruct; + STRUCT_FIELD_DEFINITION *NextField; + UINT8 Buff[6]; + UINT16_LIST *NextU16List; + + // + // Free up the structure definitions if any + // + while (mFirstStructDefinition != NULL) { + // + // Free up all the fields for this struct + // + while (mFirstStructDefinition->Field != NULL) { + NextField = mFirstStructDefinition->Field->Next; + free (mFirstStructDefinition->Field->Name); + free (mFirstStructDefinition->Field); + mFirstStructDefinition->Field = NextField; + } + NextStruct = mFirstStructDefinition->Next; + free (mFirstStructDefinition->Name); + free (mFirstStructDefinition); + mFirstStructDefinition = NextStruct; + } + // + // Free up the goto references and form id defines + // + FreeGotoReferences (); + // + // Free up label list + // + while (mDefinedLabels != NULL) { + NextU16List = mDefinedLabels->Next; + delete (mDefinedLabels); + mDefinedLabels = NextU16List; + } + // + // Free up the list of defined variable storage IDs + // + while (mDefinedVarStoreId != NULL) { + NextU16List = mDefinedVarStoreId->Next; + delete (mDefinedVarStoreId); + mDefinedVarStoreId = NextU16List; + } +} + +INT32 +EfiVfrParser::AtoX ( + INT8 *HexString, + INT32 NumBytes, + UINT32 *HexValue + ) +/*++ + +Routine Description: + Given a pointer to a ascii hex string, convert to a number with the given + number of bytes. + +Arguments: + HexString - pointer to a string of format 30BCA + Size - number of bytes to convert + HexValue - return result + +Returns: + The number of bytes converted. + +--*/ +{ + INT32 Count; + INT32 Value; + + *HexValue = 0; + Count = 0; + while (Count < NumBytes) { + if ((*HexString >= '0') && (*HexString <= '9')) { + Value = *HexString - '0'; + } else if ((*HexString >= 'a') && (*HexString <= 'f')) { + Value = *HexString - 'a' + 10; + } else if ((*HexString >= 'A') && (*HexString <= 'F')) { + Value = *HexString - 'A' + 10; + } else { + return Count; + } + HexString++; + *HexValue = (*HexValue << 4) | Value; + if ((*HexString >= '0') && (*HexString <= '9')) { + Value = *HexString - '0'; + } else if ((*HexString >= 'a') && (*HexString <= 'f')) { + Value = *HexString - 'a' + 10; + } else if ((*HexString >= 'A') && (*HexString <= 'F')) { + Value = *HexString - 'A' + 10; + } else { + return Count; + } + *HexValue = (*HexValue << 4) | Value; + HexString++; + Count++; + } + return Count; +} +VOID +EfiVfrParser::WriteGuidValue ( + UINT32 TokenLineNum, + INT8 *G1, + INT8 *G2, + INT8 *G3, + INT8 *G4, + INT8 *G5, + INT8 *G6, + INT8 *G7, + INT8 *G8, + INT8 *G9, + INT8 *G10, + INT8 *G11 + ) +/*++ + +Routine Description: + A Guid was parsed, likely of format: + #define MY_GUID { 0x12345678, 0xAABB, 0xCCDD, 0xEE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } + + Write out the value. + +Arguments: + TokenLineNum - line number where the guid was used + G1-G11 - the 11 fields of the guid value + +Returns: + None. + +--*/ +{ + UINT32 Value; + INT32 Loop; + INT8 *Cptr; + + mFormSetGuid.Data1 = GetNumber (G1, TokenLineNum, 4); + mFormSetGuid.Data2 = (UINT16)GetNumber (G2, TokenLineNum, 2); + mFormSetGuid.Data3 = (UINT16)GetNumber (G3, TokenLineNum, 2); + mFormSetGuid.Data4[0] = (UINT8)GetNumber (G4, TokenLineNum, 1); + mFormSetGuid.Data4[1] = (UINT8)GetNumber (G5, TokenLineNum, 1); + mFormSetGuid.Data4[2] = (UINT8)GetNumber (G6, TokenLineNum, 1); + mFormSetGuid.Data4[3] = (UINT8)GetNumber (G7, TokenLineNum, 1); + mFormSetGuid.Data4[4] = (UINT8)GetNumber (G8, TokenLineNum, 1); + mFormSetGuid.Data4[5] = (UINT8)GetNumber (G9, TokenLineNum, 1); + mFormSetGuid.Data4[6] = (UINT8)GetNumber (G10, TokenLineNum, 1); + mFormSetGuid.Data4[7] = (UINT8)GetNumber (G11, TokenLineNum, 1); + + WriteDWord (mFormSetGuid.Data1, 'G'); + WriteWord (mFormSetGuid.Data2); + WriteWord (mFormSetGuid.Data3); + WriteByte (mFormSetGuid.Data4[0], 0); + WriteByte (mFormSetGuid.Data4[1], 0); + WriteByte (mFormSetGuid.Data4[2], 0); + WriteByte (mFormSetGuid.Data4[3], 0); + WriteByte (mFormSetGuid.Data4[4], 0); + WriteByte (mFormSetGuid.Data4[5], 0); + WriteByte (mFormSetGuid.Data4[6], 0); + WriteByte (mFormSetGuid.Data4[7], 0); +} +VOID +EfiVfrParser::WriteFieldOffset ( + INT8 WriteLength, + INT8 *StructName, + INT32 LineNum1, + INT8 *FieldName, + INT32 LineNum2, + INT32 ArrayIndex, + INT8 IsArrayIndex, + INT32 FieldWidth, + INT8 WriteArraySize + ) +/*++ + +Routine Description: + A VFR script referenced the NV store structure. Given the structure's name + and the field's name, write the offset of the field to the output file. + +Arguments: + WriteLength - write the field length byte out + StructName - name of the NV store structure + LineNum1 - line number in the VFR where we are (for error printing) + FieldName - the name of the field within the NV store structure + LineNum2 - line number in the VFR where FieldName is referenced + ArrayIndex - the index specified, for example NV_DATA.Field[ArrayIndex] + IsArrayIndex - non-zero if an array index was specified + FieldWidth - expected size for the Field (1 byte? 2 bytes?) + WriteArraySize - write the size of the entire field, not the size of a single element + +Returns: + None. + +--*/ +{ + STRUCT_DEFINITION *StructDef; + STRUCT_FIELD_DEFINITION *FieldDef; + UINT32 Offset; + UINT32 VarSize; + INT8 Msg[100]; + // + // If we're writing an array size, then they better have referenced the field without an + // index. + // + if (WriteArraySize && IsArrayIndex) { + sprintf (Msg, "array index specified where an array is required"); + PrintErrorMessage (LineNum2, FieldName, Msg); + return; + } + + // + // The reference index starts at 1 not 0 + // + if (IsArrayIndex && (ArrayIndex < 1)) { + printf ("WARNING: array index shouldn't be less than 1"); + } + // + // Look through our list of known structures for a match + // + for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) { + // + // Check for matching structure name + // + if (strcmp (StructDef->Name, StructName) == 0) { + // + // Mark it as referenced (for debug purposes only). Check the + // flag that indicates that we have already found a varstore VFR + // statement for it. + // + StructDef->Referenced++; + if (StructDef->VarStoreIdValid == 0) { + // + // Set it valid so we don't flag it multiple times, then emit the error + // + StructDef->VarStoreIdValid = 1; + PrintErrorMessage (LineNum1, StructName, "varstore statement missing for this variable store"); + } + // + // Let the opcode-handler know which variable storage we're now using + // + if (mIdEqIdStmt) { + mOpcodeHandler.SetSecondaryVarStoreId (StructDef->VarStoreId); + } else { + mOpcodeHandler.SetVarStoreId (StructDef->VarStoreId); + } + // + // Found matching structure name. Now find the matching field name + // + for (FieldDef = StructDef->Field; FieldDef != NULL; FieldDef = FieldDef->Next) { + if (strcmp (FieldDef->Name, FieldName) == 0) { + // + // Make sure the variable size is valid + // + if ((FieldWidth != 0) && (FieldDef->DataSize > FieldWidth)) { + sprintf (Msg, "field width exceeds %d byte%c", FieldWidth, FieldWidth == 1 ? ' ' : 's'); + PrintErrorMessage (LineNum2, FieldName, Msg); + } + // + // If they specified an index (MyVfrData.FieldX[10]), then make sure that the + // data structure was declared as an array, and that the index is in bounds. + // If they did not specify an index, then we'll assume 0. This is required for + // strings. + // + if (IsArrayIndex) { + VarSize = FieldDef->DataSize; + if (FieldDef->IsArray == 0) { + PrintErrorMessage (LineNum2, FieldName, "field is not declared as an array"); + return; + } + if (FieldDef->ArrayLength < ArrayIndex) { + PrintErrorMessage (LineNum2, FieldName, "array index exceeds declared size of field"); + return; + } + } else { + if (FieldDef->IsArray) { + VarSize = FieldDef->DataSize * FieldDef->ArrayLength; + } else { + VarSize = FieldDef->DataSize; + } + } + // + // If we're in the middle of a ideqid VFR statement, then this is the second + // variable ID that we're now processing. Make sure that its size is the same + // as the first variable. + // + if (mIdEqIdStmt) { + if (mLastVarIdSize != VarSize) { + PrintErrorMessage (LineNum2, FieldName, "variables must have the same size"); + return; + } + } + mLastVarIdSize = VarSize; + // + // If we're supposed to write an array size, then require it to be an array + // + if (WriteArraySize && !FieldDef->IsArray) { + PrintErrorMessage (LineNum2, FieldName, "array required"); + return; + } + // + // Write the variable offset and size. If we're in the non-NV structure, then + // set the offset beyond the NV data structure size. + // + Offset = FieldDef->Offset + FieldDef->DataSize * (ArrayIndex - 1); + if (StructDef->IsNonNV) Offset += mNvDataStructSize; + WriteWord (Offset); + if (WriteLength) { + if (WriteArraySize) { + if (FieldDef->DataSize * FieldDef->ArrayLength > 255) { + PrintErrorMessage (LineNum2, FieldName, "array size exceeds 255 maximum encoding limit"); + return; + } + WriteByte (FieldDef->DataSize * FieldDef->ArrayLength, 0); + } else { + WriteByte (FieldDef->DataSize, 0); + } + } + return; + } + } + sprintf (Msg, "structure %s does not have a field named '%s'", StructName, FieldName); + PrintErrorMessage (LineNum2, Msg, NULL); + PrintErrorMessage (StructDef->LineNum, "see structure definition", NULL); + return; + } + } + // + // The structure was not found in the defined list. See if it's the "Date" structure + // + if (strcmp (StructName, "Date") == 0) { + // + // BUGBUG -- remove support for Date and Time as valid structure + // names. They should use the NON_NV_DATA_MAP structure for this. + // + // Someone specified Date.Years|Months|Days + // BUGBUG -- define some constants for the IDs used here + // Length == 0 implies that this is not user NV data storage. + // + if (strcmp (FieldName, "Year") == 0) { + // + // Write ID (offset), ID, and size + // + WriteWord (mNvDataStructSize + mNonNvDataStructSize + 0); + if (WriteLength) { + WriteByte (0, 0); + } + } else if (strcmp (FieldName, "Month") == 0) { + // + // Write ID (offset), ID, and size + // + WriteWord (mNvDataStructSize + mNonNvDataStructSize + 2); + if (WriteLength) { + WriteByte (0, 0); + } + } else if (strcmp (FieldName, "Day") == 0) { + // + // Write ID (offset), ID, and size + // + WriteWord (mNvDataStructSize + mNonNvDataStructSize + 4); + if (WriteLength) { + WriteByte (0, 0); + } + } else { + PrintErrorMessage (LineNum1, FieldName, "expected valid field name TheYear/TheMonth/TheDay"); + } + return; + } else if (strcmp (StructName, "Time") == 0) { + // + // Someone specified Time.Hours|Minutes|Seconds + // BUGBUG -- define some constants for the IDs used here + // + if (strcmp (FieldName, "Hours") == 0) { + // + // Write ID (offset), ID, and size + // + WriteWord (mNvDataStructSize + mNonNvDataStructSize + 6); + if (WriteLength) { + WriteByte (0, 0); + } + } else if (strcmp (FieldName, "Minutes") == 0) { + // + // Write ID (offset), ID, and size + // + WriteWord (mNvDataStructSize + mNonNvDataStructSize + 8); + if (WriteLength) { + WriteByte (0, 0); + } + } else if (strcmp (FieldName, "Seconds") == 0) { + // + // Write ID (offset), ID, and size + // + WriteWord (mNvDataStructSize + mNonNvDataStructSize + 10); + if (WriteLength) { + WriteByte (0, 0); + } + } else { + PrintErrorMessage (LineNum1, FieldName, "expected valid field name Hours/Minutes/Seconds"); + } + return; + } else { + PrintErrorMessage (LineNum1, StructName, "undefined structure"); + return; + } +} +VOID +EfiVfrParser::StartStructDefinition ( + INT32 IsNonNV, + INT32 LineNum + ) +/*++ + +Routine Description: + Called when we encounter a new "struct _MY_STRUCT..." statement while parsing. + Initialize internal data and structures for parsing the fields of the structure. + +Arguments: + LineNum - line number in the source file (for error reporting purposes) + IsNonNv - flag indicating (if nonzero) that the variable referred to is not in + the standard NV store. +Returns: + None + +--*/ +{ + STRUCT_DEFINITION *StructDef; + // + // Allocate memory for the structure record + // + StructDef = (STRUCT_DEFINITION *)malloc (sizeof (STRUCT_DEFINITION)); + memset (StructDef, 0, sizeof (STRUCT_DEFINITION)); + StructDef->LineNum = LineNum; + // + // Set flag indicating non-NV data structure or not + // + StructDef->IsNonNV = IsNonNV; + // + // Add it to the end of our linked list. If it's the first one + // defined, then it's the default varstore ID, so set it valid. + // + if (mFirstStructDefinition == NULL) { + mFirstStructDefinition = StructDef; + StructDef->VarStoreIdValid = 1; + } else { + mLastStructDefinition->Next = StructDef; + } + mLastStructDefinition = StructDef; +} +VOID +EfiVfrParser::EndStructDefinition ( + INT8 *StructName, + INT32 LineNum + ) +{ + STRUCT_DEFINITION *StructDef; + STRUCT_FIELD_DEFINITION *FieldDef; + UINT32 Offset; + // + // Make sure they have not already defined a structure with this name + // + for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) { + if ((StructDef->Name != NULL) && (strcmp (StructDef->Name, StructName) == 0)) { + PrintErrorMessage (LineNum, StructName, "structure with this name already defined"); + // + // Fall through and fill in the rest of the structure information. We do + // this because the structure has already been added to our global list, + // so will be used elsewhere, so we want it to contain valid fields. + // + } + } + // + // Allocate memory for the structure name + // + mLastStructDefinition->Name = (char *)malloc (strlen (StructName) + 1); + strcpy (mLastStructDefinition->Name, StructName); + // + // Compute the structure size, and the offsets to each field + // + Offset = 0; + for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) { + FieldDef->Offset = Offset; + Offset += FieldDef->ArrayLength * FieldDef->DataSize; + } + mLastStructDefinition->Size = Offset; + // + // Go through all the structure we have so far and figure out (if we can) + // the size of the non-NV storage. We also assume that the first structure + // definition is the primary/default storage for the VFR form. + // + if (mNonNvDataStructSize == 0) { + for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) { + if (StructDef->IsNonNV) { + mNonNvDataStructSize = StructDef->Size; + break; + } + } + } + if (mNvDataStructSize == 0) { + for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) { + if (StructDef->IsNonNV == 0) { + mNvDataStructSize = StructDef->Size; + break; + } + } + } +} +VOID +EfiVfrParser::AddStructField ( + INT8 *FieldName, + INT32 LineNum, + INT32 DataSize, + INT32 ArrayLength, + INT8 IsArray + ) +/*++ + +Routine Description: + We're parsing the VFR structure definition. Add another defined field to + our definition. + +Arguments: + FieldName - name of the field in the structure. + LineNum - the line number from the input (preprocessor output) file + DataSize - the size of the field (1, 2, or 4 bytes) + ArrayLength - the number of elements (for array) + IsArray - non-zero if the field is an array + +Returns: + None. + +--*/ +{ + STRUCT_FIELD_DEFINITION *FieldDef; + STRUCT_FIELD_DEFINITION *Temp; + // + // Make sure we don't already have a field of this name in our structure + // + for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) { + if (strcmp (FieldDef->Name, FieldName) == 0) { + PrintErrorMessage (LineNum, FieldName, "field with this name already defined"); + return; + } + } + // + // If it's an array, then they better not have a size of 0. For example: + // UINT8 MyBytes[0]; + // + if (IsArray && (ArrayLength <= 0)) { + PrintErrorMessage (LineNum, FieldName, "invalid array size"); + return; + } + // + // Allocate memory for a new structure field definition + // + FieldDef = (STRUCT_FIELD_DEFINITION *)malloc (sizeof (STRUCT_FIELD_DEFINITION)); + memset ((char *)FieldDef, 0, sizeof (STRUCT_FIELD_DEFINITION)); + FieldDef->ArrayLength = ArrayLength; + FieldDef->DataSize = DataSize; + FieldDef->IsArray = IsArray; + FieldDef->Name = (char *)malloc (strlen (FieldName) + 1); + strcpy (FieldDef->Name, FieldName); + // + // Add it to the end of the field list for the currently active structure + // + if (mLastStructDefinition->Field == NULL) { + mLastStructDefinition->Field = FieldDef; + } else { + mLastStructDefinition->LastField->Next = FieldDef; + } + mLastStructDefinition->LastField = FieldDef; +} +VOID +EfiVfrParser::AddVarStore ( + INT8 *StructName, // actual name of the structure + INT8 *VarName, // actual NV variable name + UINT16 VarStoreId, // key value + INT32 LineNum // parse line number (for error reporting) + ) +/*++ + +Routine Description: + Called while parsing a varstore statement. Add the variable store + to our linked list. + +Arguments: + StructName - the name of the typedef'ed structure to use + VarName - the NV variable name as specified in the varstore statement + VarStoreId - the variable store ID as specified in the varstore statememt + LineNum - the line number from the input (preprocessor output) file + +Returns: + None. + +--*/ +{ + STRUCT_DEFINITION *StructDef; + UINT16_LIST *L16Ptr; + // + // Go through our list of previously-defined variable store IDs and + // make sure this one is not a duplicate in name or key value. + // + for (L16Ptr = mDefinedVarStoreId; L16Ptr != NULL; L16Ptr = L16Ptr->Next) { + if (L16Ptr->Value == VarStoreId) { + PrintErrorMessage (LineNum, "variable storage key already used", NULL); + PrintErrorMessage (L16Ptr->LineNum, "previous usage of storage key", NULL); + } + } + // + // Key value of 0 is invalid since that's assigned by default to the default + // variable store (the first structure parsed). + // + if (VarStoreId == 0) { + PrintErrorMessage (LineNum, "variable storage key of 0 is invalid", NULL); + } + // + // Create a new element to add to the list + // + L16Ptr = (UINT16_LIST *)malloc(sizeof (UINT16_LIST)); + memset (L16Ptr, 0, sizeof (UINT16_LIST)); + L16Ptr->LineNum = LineNum; + L16Ptr->Value = VarStoreId; + if (mDefinedVarStoreId == NULL) { + mDefinedVarStoreId = L16Ptr; + } else { + mLastDefinedVarStoreId->Next = L16Ptr; + } + mLastDefinedVarStoreId = L16Ptr; + // + // Find the structure definition with this name + // + for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) { + if (strcmp (StructDef->Name, StructName) == 0) { + // + // Make sure they did not already define a variable storage ID + // for this structure. + // + if (StructDef->VarStoreId != 0) { + PrintErrorMessage (LineNum, StructName, "variable storage already defined for this structure"); + PrintErrorMessage (StructDef->VarStoreLineNum, StructName, "previous definition for variable storage"); + } + StructDef->VarStoreId = VarStoreId; + StructDef->VarStoreIdValid = 1; + StructDef->VarStoreLineNum = LineNum; + WriteWord (StructDef->Size); + while (*VarName) { + WriteByte(*VarName, 0); + VarName++; + } + WriteByte(0,0); + return; + } + } + PrintErrorMessage (LineNum, StructName, "structure with this name not defined"); +} +VOID +EfiVfrParser::WriteDWord ( + UINT32 Value, + UINT8 KeyByte + ) +/*++ + +Routine Description: + During parsing, we came upon some code that requires a 32-bit value be + written to the VFR binary file. Queue up the 4 bytes. + +Arguments: + Value - the 32-bit value to write + KeyByte - a single character which gets written out beside the first byte. + This is used to tag the data in the output file so that during + debug you have an idea what the value is. + +Returns: + None. + +--*/ +{ + // + // Write 4 bytes, little endian. Specify a key byte only on the first one + // + mOpcodeHandler.AddByte ((UINT8)Value, KeyByte); + Value \>>= 8; + mOpcodeHandler.AddByte ((UINT8)Value, 0); + Value \>>= 8; + mOpcodeHandler.AddByte ((UINT8)Value, 0); + Value \>>= 8; + mOpcodeHandler.AddByte ((UINT8)Value, 0); +} +VOID +EfiVfrParser::WriteOpByte ( + UINT32 LineNum, + UINT8 ByteValue + ) +/*++ + +Routine Description: + + During parsing, we came upon a new VFR opcode. At this point we flush + the output queue and then queue up this byte (with 'O' for opcode tag). + +Arguments: + + ByteValue - opcode value + +Returns: + + None. + +--*/ +{ + mOpcodeHandler.AddOpcodeByte (ByteValue, LineNum); +} +VOID +EfiVfrParser::WriteByte ( + UINT8 ByteValue, + UINT8 Key + ) +/*++ + +Routine Description: + + During parsing of the VFR we spoonfeed this function with bytes to write to + the output VFR binary file. This function simply queues up the bytes, and + the queue gets flushed each time a new VFR opcode is encountered. + +Arguments: + + ByteValue - raw byte to write + Key - character to tag the byte with when we write ByteValue to the + output file. + +Returns: + + None. + +--*/ +{ + mOpcodeHandler.AddByte (ByteValue, Key); +} +VOID +EfiVfrParser::WriteWord ( + UINT32 Value + ) +/*++ + +Routine Description: + During VFR parsing we came upon a case where we need to write out a + 16-bit value. Queue it up. + +Arguments: + Value - value to write. + +Returns: + None. + +--*/ +{ + mOpcodeHandler.AddByte ((UINT8)Value, 0); + mOpcodeHandler.AddByte ((UINT8)((Value \>> 8) & 0xFF), 0); +} +VOID +EfiVfrParser::WriteStringIdWord ( + UINT16 WordValue + ) +{ + mOpcodeHandler.AddByte ((UINT8)WordValue, 'S'); + mOpcodeHandler.AddByte ((UINT8)((WordValue \>> 8) & 0xFF), 0); +} +VOID +EfiVfrParser::FreeGotoReferences () +/*++ + +Routine Description: + Called during cleanup to free up the memory we allocated when + keeping track of VFR goto statements. + +Arguments: + None + +Returns: + None + +--*/ +{ + GOTO_REFERENCE *CurrRef; + GOTO_REFERENCE *NextRef; + FORM_ID_VALUE *CurrFormId; + FORM_ID_VALUE *NextFormId; + UINT8 Found; + INT8 Name[20]; + + // + // Go through all the "goto" references and make sure there was a + // form ID of that value defined. + // + for (CurrRef = mGotoReferences; CurrRef != NULL; CurrRef = CurrRef->Next) { + Found = 0; + for (CurrFormId = mFormIdValues; CurrFormId != NULL; CurrFormId = CurrFormId->Next) { + if (CurrRef->Value == CurrFormId->Value) { + Found = 1; + break; + } + } + if (!Found) { + sprintf (Name, "%d", (UINT32)CurrRef->Value); + PrintErrorMessage (CurrRef->RefLineNum, Name, "undefined form ID"); + } + } + // + // Now free up the form id and goto references + // + CurrFormId = mFormIdValues; + while (CurrFormId != NULL) { + NextFormId = CurrFormId->Next; + free (CurrFormId); + CurrFormId = NextFormId; + } + mFormIdValues = NULL; + CurrRef = mGotoReferences; + while (CurrRef != NULL) { + NextRef = CurrRef->Next; + free (CurrRef); + CurrRef = NextRef; + } + mGotoReferences = NULL; +} +VOID +EfiVfrParser::AddGotoReference ( + UINT32 GotoNumber, + UINT32 LineNum + ) +/*++ + +Routine Description: + During VFR parsing we came upon a goto statement. Since we support + forward references, save the referenced label and at the end of parsing + we'll check that the label was actually defined somewhere. + +Arguments: + GotoNumber - the label number referenced + LineNum - the line number where the reference was made (used for + error reporting) + +Returns: + None + +--*/ +{ + GOTO_REFERENCE *NewRef; + + NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE)); + if (NewRef == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return; + } + memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE)); + NewRef->Value = (UINT16)GotoNumber; + NewRef->RefLineNum = LineNum; + NewRef->Next = mGotoReferences; + mGotoReferences = NewRef; +} +VOID +EfiVfrParser::AddFormId ( + INT32 FormIdValue, + UINT32 LineNum + ) +/*++ + +Routine Description: + This function is called when we parse "form formid = 3" statements. + We save the form ID valud so we can verify that duplicates are not + defined. Also, these are the targets of goto statements, so when we're + done parsing the script we also go through all the goto statements to + check that there was a target FormId defined as referenced by each + goto statement. + + Note that formid = 0 is invalid. + +Arguments: + FormIdValue - the parsed value for the Form ID + LineNum - line number of the source file we're parsing + +Returns: + NA + +--*/ +{ + FORM_ID_VALUE *NewFormId; + char *FileName; + char *FileName2; + UINT32 LineNum2; + // + // Verify that FormId != 0 + // + if (FormIdValue == 0) { + FileName = ConvertLineNumber (&LineNum); + Error (FileName, LineNum, 0, "form ID cannot be 0", NULL); + return; + } + // + // First go through all previously defined form IDs and make sure they have not defined + // duplicates. + // + for (NewFormId = mFormIdValues; NewFormId != NULL; NewFormId = NewFormId->Next) { + if ((UINT16)FormIdValue == NewFormId->Value) { + FileName = ConvertLineNumber (&LineNum); + LineNum2 = NewFormId->LineNum; + FileName2 = ConvertLineNumber (&LineNum2); + Error (FileName, LineNum, 0, NULL, "form ID %d already defined", FormIdValue); + Error (FileName2, LineNum2, 0, NULL, "form ID %d previous definition", FormIdValue); + return; + } + } + // + // Allocate memory for a new one + // + NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE)); + if (NewFormId == NULL) { + Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure"); + return; + } + memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE)); + NewFormId->LineNum = LineNum; + NewFormId->Next = mFormIdValues; + NewFormId->Value = (UINT16)FormIdValue; + mFormIdValues = NewFormId; +} +UINT32 +EfiVfrParser::GetNumber ( + INT8 *NumStr, + UINT32 LineNum, + UINT32 NumBytes + ) +{ + UINT32 Value; + + if ((NumStr[0] == '0') && (NumStr[1] == 'x')) { + AtoX (NumStr + 2, 4, &Value); + } else { + Value = (UINT32)atoi (NumStr); + } + // + // Check range + // + if ((NumBytes < 4) && (Value & ((UINT32)0xFFFFFFFF << (NumBytes * 8)))) { + PrintErrorMessage (LineNum, NumStr, "value out of range"); + return 0; + } + return Value; +} + +>> + +} // end grammar class + + diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp new file mode 100644 index 0000000000..e9c54d3387 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp @@ -0,0 +1,754 @@ +/*++ + +Copyright (c) 2004 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VfrServices.cpp + +Abstract: + + Support routines for the VFR compiler + +--*/ + +#include // for FILE routines +#include // for malloc() and free() + +#include "Tiano.h" +#include "EfiUtilityMsgs.h" +#include "EfiVfr.h" +#include "VfrServices.h" + +#include EFI_PROTOCOL_DEFINITION (Hii) + +static const char *mSourceFileHeader[] = { + "//", + "// DO NOT EDIT -- auto-generated file", + "//", + "// This file is generated by the VFR compiler.", + "//", + NULL +}; + +typedef struct { + INT8 *Name; + INT32 Size; +} IFR_OPCODE_SIZES; + +// +// Create a table that can be used to do internal checking on the IFR +// bytes we emit. +// +static const IFR_OPCODE_SIZES mOpcodeSizes[] = { + { 0, 0 }, // invalid + { "EFI_IFR_FORM", sizeof (EFI_IFR_FORM) }, + { "EFI_IFR_SUBTITLE", sizeof (EFI_IFR_SUBTITLE) }, + { "EFI_IFR_TEXT", -6 }, //sizeof (EFI_IFR_TEXT) }, + { "unused 0x04 opcode", 0 }, // EFI_IFR_GRAPHIC_OP + { "EFI_IFR_ONE_OF", sizeof (EFI_IFR_ONE_OF) }, + { "EFI_IFR_CHECK_BOX", sizeof (EFI_IFR_CHECK_BOX) }, + { "EFI_IFR_NUMERIC", sizeof (EFI_IFR_NUMERIC) }, + { "EFI_IFR_PASSWORD", sizeof (EFI_IFR_PASSWORD) }, + { "EFI_IFR_ONE_OF_OPTION", sizeof (EFI_IFR_ONE_OF_OPTION) }, + { "EFI_IFR_SUPPRESS", sizeof (EFI_IFR_SUPPRESS) }, + { "EFI_IFR_END_FORM", sizeof (EFI_IFR_END_FORM) }, + { "EFI_IFR_HIDDEN", sizeof (EFI_IFR_HIDDEN) }, + { "EFI_IFR_END_FORM_SET", sizeof (EFI_IFR_END_FORM_SET) }, + { "EFI_IFR_FORM_SET", sizeof (EFI_IFR_FORM_SET) }, + { "EFI_IFR_REF", sizeof (EFI_IFR_REF) }, + { "EFI_IFR_END_ONE_OF", sizeof (EFI_IFR_END_ONE_OF) }, + { "EFI_IFR_INCONSISTENT", sizeof (EFI_IFR_INCONSISTENT) }, + { "EFI_IFR_EQ_ID_VAL", sizeof (EFI_IFR_EQ_ID_VAL) }, + { "EFI_IFR_EQ_ID_ID", sizeof (EFI_IFR_EQ_ID_ID) }, + { "EFI_IFR_EQ_ID_LIST", -sizeof (EFI_IFR_EQ_ID_LIST) }, + { "EFI_IFR_AND", sizeof (EFI_IFR_AND) }, + { "EFI_IFR_OR", sizeof (EFI_IFR_OR) }, + { "EFI_IFR_NOT", sizeof (EFI_IFR_NOT) }, + { "EFI_IFR_END_IF", sizeof (EFI_IFR_END_IF) }, + { "EFI_IFR_GRAYOUT", sizeof (EFI_IFR_GRAYOUT) }, + { "EFI_IFR_DATE", sizeof (EFI_IFR_DATE) / 3 }, + { "EFI_IFR_TIME", sizeof (EFI_IFR_TIME) / 3 }, + { "EFI_IFR_STRING", sizeof (EFI_IFR_STRING) }, + { "EFI_IFR_LABEL", sizeof (EFI_IFR_LABEL) }, + { "EFI_IFR_SAVE_DEFAULTS", sizeof (EFI_IFR_SAVE_DEFAULTS) }, + { "EFI_IFR_RESTORE_DEFAULTS", sizeof (EFI_IFR_RESTORE_DEFAULTS) }, + { "EFI_IFR_BANNER", sizeof (EFI_IFR_BANNER) }, + { "EFI_IFR_INVENTORY", sizeof (EFI_IFR_INVENTORY) }, + { "EFI_IFR_EQ_VAR_VAL_OP", sizeof (EFI_IFR_EQ_VAR_VAL) }, + { "EFI_IFR_ORDERED_LIST_OP", sizeof (EFI_IFR_ORDERED_LIST) }, + { "EFI_IFR_VARSTORE_OP", -sizeof (EFI_IFR_VARSTORE) }, + { "EFI_IFR_VARSTORE_SELECT_OP", sizeof (EFI_IFR_VARSTORE_SELECT) }, + { "EFI_IFR_VARSTORE_SELECT_PAIR_OP", sizeof (EFI_IFR_VARSTORE_SELECT_PAIR) }, + { "EFI_IFR_TRUE", sizeof (EFI_IFR_TRUE)}, + { "EFI_IFR_FALSE", sizeof (EFI_IFR_FALSE)}, + { "EFI_IFR_GT", sizeof (EFI_IFR_GT)}, + { "EFI_IFR_GE", sizeof (EFI_IFR_GE)}, + { "EFI_IFR_OEM_DEFINED_OP", -2 }, +}; + + +VfrOpcodeHandler::VfrOpcodeHandler ( + ) +/*++ + +Routine Description: + Constructor for the VFR opcode handling class. + +Arguments: + None + +Returns: + None + +--*/ +{ + mIfrBytes = NULL; + mLastIfrByte = NULL; + mBytesWritten = 0; + mQueuedByteCount = 0; + mQueuedOpcodeByteValid = 0; + mPrimaryVarStoreId = 0; + mSecondaryVarStoreId = 0; + mSecondaryVarStoreIdSet = 0; + mPrimaryVarStoreIdSet = 0; + mDefaultVarStoreId = 0; +} + +VOID +VfrOpcodeHandler::SetVarStoreId ( + UINT16 VarStoreId + ) +/*++ + +Routine Description: + This function is invoked by the parser when a variable is referenced in the + VFR. Save the variable store (and set a flag) so that we can later determine + if we need to emit a varstore-select or varstore-select-pair opcode. + +Arguments: + VarStoreId - ID of the variable store referenced in the VFR + +Returns: + None + +--*/ +{ + mPrimaryVarStoreId = VarStoreId; + mPrimaryVarStoreIdSet = 1; +} + +VOID +VfrOpcodeHandler::SetSecondaryVarStoreId ( + UINT16 VarStoreId + ) +/*++ + +Routine Description: + This function is invoked by the parser when a secondary variable is + referenced in the VFR. Save the variable store (and set a flag) so + that we can later determine if we need to emit a varstore-select or + varstore-pair opcode. + +Arguments: + VarStoreId - ID of the variable store referenced in the VFR + +Returns: + None + +--*/ +{ + mSecondaryVarStoreId = VarStoreId; + mSecondaryVarStoreIdSet = 1; +} + +VOID +VfrOpcodeHandler::WriteIfrBytes ( + ) +/*++ + +Routine Description: + This function is invoked at the end of parsing. Its purpose + is to write out all the IFR bytes that were queued up while + parsing. + +Arguments: + None + +Returns: + None + +--*/ +{ + IFR_BYTE *Curr; + IFR_BYTE *Next; + UINT32 Count; + UINT32 LineCount; + UINT32 PoundLines; + UINT32 ByteCount; + INT8 Line[MAX_LINE_LEN]; + INT8 *Cptr; + FILE *InFptr; + FILE *OutFptr; + UINT32 ListFile; + EFI_HII_IFR_PACK_HEADER IfrHeader; + UINT8 *Ptr; + FILE *IfrBinFptr; + UINT32 BytesLeftThisOpcode; + // + // If someone added a new opcode and didn't update our opcode sizes structure, error out. + // + if (sizeof(mOpcodeSizes) / sizeof (mOpcodeSizes[0]) != EFI_IFR_LAST_OPCODE + 1) { + Error (__FILE__, __LINE__, 0, "application error", "internal IFR binary table size is incorrect"); + return; + } + // + // Flush the queue + // + FlushQueue (); + // + // If there have been any errors to this point, then skip dumping the IFR + // binary data. This way doing an nmake again will try to build it again, and + // the build will fail if they did not fix the problem. + // + if (GetUtilityStatus () != STATUS_ERROR) { + if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) { + Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing"); + return; + } + // + // Write the standard file header to the output file + // + WriteStandardFileHeader (IfrBinFptr); + // + // Write the structure header + // + fprintf (IfrBinFptr, "\nunsigned char %sBin[] = {", gOptions.VfrBaseFileName); + // + // Write the header + // + memset ((char *)&IfrHeader, 0, sizeof (IfrHeader)); + IfrHeader.Header.Type = EFI_HII_IFR; + IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader); + Ptr = (UINT8 *)&IfrHeader; + for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) { + if ((Count & 0x03) == 0) { + fprintf (IfrBinFptr, "\n "); + } + fprintf (IfrBinFptr, "0x%02X, ", *Ptr); + } + // + // + // Write all the IFR bytes + // + fprintf (IfrBinFptr, "\n // start of IFR data"); + Curr = mIfrBytes; + Count = 0; + while (Curr != NULL) { + if ((Count & 0x0F) == 0) { + fprintf (IfrBinFptr, "\n "); + } + if (Curr->KeyByte != 0) { + fprintf (IfrBinFptr, "/*%c*/ ", Curr->KeyByte); + } + fprintf (IfrBinFptr, "0x%02X, ", Curr->OpcodeByte); + Count++; + Curr = Curr->Next; + } + fprintf (IfrBinFptr, "\n};\n\n"); + // + // + // Close the file + // + fclose (IfrBinFptr); + IfrBinFptr = NULL; + } + // + // Write the bytes as binary data if the user specified to do so + // + if ((GetUtilityStatus () != STATUS_ERROR) && (gOptions.CreateIfrBinFile != 0)) { + // + // Use the Ifr output file name with a ".hpk" extension. + // + for (Cptr = gOptions.IfrOutputFileName + strlen (gOptions.IfrOutputFileName) - 1; + (*Cptr != '.') && (Cptr > gOptions.IfrOutputFileName) && (*Cptr != '\\'); + Cptr--) { + // + // do nothing + // + } + if (*Cptr == '.') { + strcpy (Cptr, ".hpk"); + } else { + strcat (gOptions.IfrOutputFileName, ".hpk"); + } + if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) { + Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing"); + return; + } + // + // Write the structure header + // + memset ((char *)&IfrHeader, 0, sizeof (IfrHeader)); + IfrHeader.Header.Type = EFI_HII_IFR; + IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader); + Ptr = (UINT8 *)&IfrHeader; + for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) { + fwrite (Ptr, 1, 1, IfrBinFptr); + } + // + // + // Write all the IFR bytes + // + Curr = mIfrBytes; + Count = 0; + while (Curr != NULL) { + fwrite (&Curr->OpcodeByte, 1, 1, IfrBinFptr); + Curr = Curr->Next; + } + // + // + // Close the file + // + fclose (IfrBinFptr); + IfrBinFptr = NULL; + } + // + // If creating a listing file, then open the input and output files + // + ListFile = 0; + if (gOptions.CreateListFile) { + // + // Open the input VFR file and the output list file + // + if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) { + Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file"); + } else { + if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) { + Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing"); + fclose (InFptr); + InFptr = NULL; + } else { + LineCount = 0; + ListFile = 1; + PoundLines = 0; + ByteCount = 0; + } + } + } + // + // Write the list file + // + if (ListFile) { + // + // Write out the VFR compiler version + // + fprintf (OutFptr, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n"); + Curr = mIfrBytes; + while (Curr != NULL) { + // + // Print lines until we reach the line of the current opcode + // + while (LineCount < PoundLines + Curr->LineNum) { + if (fgets (Line, sizeof (Line), InFptr) != NULL) { + // + // We should check for line length exceeded on the fgets(). Otherwise it + // throws the listing file output off. Future enhancement perhaps. + // + fprintf (OutFptr, "%s", Line); + if (strncmp (Line, "#line", 5) == 0) { + PoundLines++; + } + } + LineCount++; + } + // + // Print all opcodes with line numbers less than where we are now + // + BytesLeftThisOpcode = 0; + while ((Curr != NULL) && ((Curr->LineNum == 0) || (LineCount >= PoundLines + Curr->LineNum))) { + if (BytesLeftThisOpcode == 0) { + fprintf (OutFptr, ">%08X: ", ByteCount); + if (Curr->Next != NULL) { + BytesLeftThisOpcode = (UINT32)Curr->Next->OpcodeByte; + } + } + fprintf (OutFptr, "%02X ", (UINT32)Curr->OpcodeByte); + ByteCount++; + BytesLeftThisOpcode--; + if (BytesLeftThisOpcode == 0) { + fprintf (OutFptr, "\n"); + } + Curr = Curr->Next; + } + } + // + // Dump any remaining lines from the input file + // + while (fgets (Line, sizeof (Line), InFptr) != NULL) { + fprintf (OutFptr, "%s", Line); + } + fclose (InFptr); + fclose (OutFptr); + } + // + // Debug code to make sure that each opcode we write out has as many + // bytes as the IFR structure requires. If there were errors, then + // don't do this step. + // + if (GetUtilityStatus () != STATUS_ERROR) { + Curr = mIfrBytes; + ByteCount = 0; + while (Curr != NULL) { + // + // First byte is the opcode, second byte is the length + // + if (Curr->Next == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "last opcode written does not contain a length byte"); + break; + } + Count = (UINT32)Curr->Next->OpcodeByte; + if (Count == 0) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "opcode with 0 length specified in output at offset 0x%X", + ByteCount + ); + break; + } + // + // Check the length + // + if ((Curr->OpcodeByte > EFI_IFR_LAST_OPCODE) || (Curr->OpcodeByte == 0)) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "invalid opcode 0x%X in output at offset 0x%X", + (UINT32) Curr->OpcodeByte, ByteCount + ); + } else if (mOpcodeSizes[Curr->OpcodeByte].Size < 0) { + // + // For those cases where the length is variable, the size is negative, and indicates + // the miniumum size. + // + if ((mOpcodeSizes[Curr->OpcodeByte].Size * -1) > Count) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "insufficient number of bytes written for %s at offset 0x%X", + mOpcodeSizes[Curr->OpcodeByte].Name, + ByteCount + ); + } + } else { + // + // Check for gaps + // + if (mOpcodeSizes[Curr->OpcodeByte].Size == 0) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "invalid opcode 0x%X in output at offset 0x%X", + (UINT32)Curr->OpcodeByte, + ByteCount + ); + } else { + // + // Check size + // + if (mOpcodeSizes[Curr->OpcodeByte].Size != Count) { + Error ( + __FILE__, + __LINE__, + 0, + "application error", + "invalid number of bytes (%d written s/b %d) written for %s at offset 0x%X", + Count, + mOpcodeSizes[Curr->OpcodeByte].Size, + mOpcodeSizes[Curr->OpcodeByte].Name, + ByteCount + ); + } + } + } + // + // Skip to next opcode + // + while (Count > 0) { + ByteCount++; + if (Curr == NULL) { + Error (__FILE__, __LINE__, 0, "application error", "last opcode written has invalid length"); + break; + } + Curr = Curr->Next; + Count--; + } + } + } +} + +VfrOpcodeHandler::~VfrOpcodeHandler( + ) +/*++ + +Routine Description: + Destructor for the VFR opcode handler. Free up memory allocated + while parsing the VFR script. + +Arguments: + None + +Returns: + None + +--*/ +{ + IFR_BYTE *Curr; + IFR_BYTE *Next; + // + // Free up the IFR bytes + // + Curr = mIfrBytes; + while (Curr != NULL) { + Next = Curr->Next; + free (Curr); + Curr = Next; + } +} + +int +VfrOpcodeHandler::AddOpcodeByte ( + UINT8 OpcodeByte, + UINT32 LineNum + ) +/*++ + +Routine Description: + This function is invoked by the parser when a new IFR + opcode should be emitted. + +Arguments: + OpcodeByte - the IFR opcode + LineNum - the line number from the source file that resulted + in the opcode being emitted. + +Returns: + 0 always + +--*/ +{ + UINT32 Count; + + FlushQueue(); + // + // Now add this new byte + // + mQueuedOpcodeByte = OpcodeByte; + mQueuedLineNum = LineNum; + mQueuedOpcodeByteValid = 1; + return 0; +} + +VOID +VfrOpcodeHandler::AddByte ( + UINT8 ByteVal, + UINT8 KeyByte + ) +/*++ + +Routine Description: + This function is invoked by the parser when it determines + that more raw IFR bytes should be emitted to the output stream. + Here we just queue them up into an output buffer. + +Arguments: + ByteVal - the raw byte to emit to the output IFR stream + KeyByte - a value that can be used for debug. + +Returns: + None + +--*/ +{ + // + // Check for buffer overflow + // + if (mQueuedByteCount >= MAX_QUEUE_COUNT) { + Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow"); + } else { + mQueuedBytes[mQueuedByteCount] = ByteVal; + mQueuedKeyBytes[mQueuedByteCount] = KeyByte; + mQueuedByteCount++; + } +} + +int +VfrOpcodeHandler::FlushQueue ( + ) +/*++ + +Routine Description: + This function is invoked to flush the internal IFR buffer. + +Arguments: + None + +Returns: + 0 always + +--*/ +{ + UINT32 Count; + UINT32 EmitNoneOnePair; + + EmitNoneOnePair = 0; + // + // If the secondary varstore was specified, then we have to emit + // a varstore-select-pair opcode, which only applies to the following + // statement. + // + if (mSecondaryVarStoreIdSet) { + mSecondaryVarStoreIdSet = 0; + // + // If primary and secondary are the same as the current default + // varstore, then we don't have to do anything. + // Note that the varstore-select-pair only applies to the following + // opcode. + // + if ((mPrimaryVarStoreId != mSecondaryVarStoreId) || (mPrimaryVarStoreId != mDefaultVarStoreId)) { + IAddByte (EFI_IFR_VARSTORE_SELECT_PAIR_OP, 'O', mQueuedLineNum); + IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT_PAIR), 'L', 0); + IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0); + IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0); + IAddByte ((UINT8)mSecondaryVarStoreId, 0, 0); + IAddByte ((UINT8)(mSecondaryVarStoreId >> 8), 0, 0); + } + } else if (mPrimaryVarStoreIdSet != 0) { + mPrimaryVarStoreIdSet = 0; + if (mDefaultVarStoreId != mPrimaryVarStoreId) { + // + // The VFR statement referenced a different variable store + // than the last one we reported. Insert a new varstore select + // statement. + // + IAddByte (EFI_IFR_VARSTORE_SELECT_OP, 'O', mQueuedLineNum); + IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT), 'L', 0); + IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0); + IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0); + mDefaultVarStoreId = mPrimaryVarStoreId; + } + } + // + // Likely a new opcode is being added. Since each opcode item in the IFR has + // a header that specifies the size of the opcode item (which we don't + // know until we find the next opcode in the VFR), we queue up bytes + // until we know the size. Then we write them out. So flush the queue + // now. + // + if (mQueuedOpcodeByteValid != 0) { + // + // Add the previous opcode byte, the length byte, and the binary + // data. + // + IAddByte (mQueuedOpcodeByte, 'O', mQueuedLineNum); + IAddByte ((UINT8)(mQueuedByteCount + 2), 'L', 0); + for (Count = 0; Count < mQueuedByteCount; Count++) { + IAddByte (mQueuedBytes[Count], mQueuedKeyBytes[Count], 0); + } + mQueuedByteCount = 0; + mQueuedOpcodeByteValid = 0; + } + return 0; +} + +int +VfrOpcodeHandler::IAddByte ( + UINT8 ByteVal, + UINT8 KeyByte, + UINT32 LineNum + ) +/*++ + +Routine Description: + This internal function is used to add actual IFR bytes to + the output stream. Most other functions queue up the bytes + in an internal buffer. Once they come here, there's no + going back. + + +Arguments: + ByteVal - value to write to output + KeyByte - key value tied to the byte -- useful for debug + LineNum - line number from source file the byte resulted from + +Returns: + 0 - if successful + 1 - failed due to memory allocation failure + +--*/ +{ + IFR_BYTE *NewByte; + NewByte = (IFR_BYTE *)malloc (sizeof (IFR_BYTE)); + if (NewByte == NULL) { + return 1; + } + memset ((char *)NewByte, 0, sizeof (IFR_BYTE)); + NewByte->OpcodeByte = ByteVal; + NewByte->KeyByte = KeyByte; + NewByte->LineNum = LineNum; + // + // Add to the list + // + if (mIfrBytes == NULL) { + mIfrBytes = NewByte; + } else { + mLastIfrByte->Next = NewByte; + } + mLastIfrByte = NewByte; + mBytesWritten++; + return 0; +} + +VOID +WriteStandardFileHeader ( + FILE *OutFptr + ) +/*++ + +Routine Description: + This function is invoked to emit a standard header to an + output text file. + +Arguments: + OutFptr - file to write the header to + +Returns: + None + +--*/ +{ + UINT32 TempIndex; + for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) { + fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]); + } + // + // Write out the VFR compiler version + // + fprintf (OutFptr, "// VFR compiler version " VFR_COMPILER_VERSION "\n//\n"); +} diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h new file mode 100644 index 0000000000..6b8c560d63 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h @@ -0,0 +1,227 @@ +/*++ + +Copyright (c) 2004, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + VfrServices.h + +Abstract: + + Prototypes and defines for routines and classes used by the + EFI VFR compiler. + +--*/ + +#ifndef _VFR_SERVICES_H_ +#define _VFR_SERVICES_H_ + +class VfrOpcodeHandler +{ +public: + VfrOpcodeHandler ( + VOID + ) + /*++ + +Routine Description: + Constructor for the VFR opcode handling class. + +Arguments: + None + +Returns: + None + +--*/ + ; + ~VfrOpcodeHandler ( + VOID + ) + /*++ + +Routine Description: + Destructor for the VFR opcode handler. Free up memory allocated + while parsing the VFR script. + +Arguments: + None + +Returns: + None + +--*/ + ; + void + WriteIfrBytes ( + VOID + ) + /*++ + +Routine Description: + This function is invoked at the end of parsing. Its purpose + is to write out all the IFR bytes that were queued up while + parsing. + +Arguments: + None + +Returns: + None + +--*/ + ; + int + AddOpcodeByte ( + UINT8 OpcodeByte, + UINT32 LineNum + ) + /*++ + +Routine Description: + This function is invoked by the parser when a new IFR + opcode should be emitted. + +Arguments: + OpcodeByte - the IFR opcode + LineNum - the line number from the source file that resulted + in the opcode being emitted. + +Returns: + 0 always + +--*/ + ; + void + AddByte ( + UINT8 ByteVal, + UINT8 KeyByte + ) + /*++ + +Routine Description: + This function is invoked by the parser when it determines + that more raw IFR bytes should be emitted to the output stream. + Here we just queue them up into an output buffer. + +Arguments: + ByteVal - the raw byte to emit to the output IFR stream + KeyByte - a value that can be used for debug. + +Returns: + None + +--*/ + ; + void + SetVarStoreId ( + UINT16 VarStoreId + ) + /*++ + +Routine Description: + This function is invoked by the parser when a variable is referenced in the + VFR. Save the variable store (and set a flag) so that we can later determine + if we need to emit a varstore-select or varstore-select-pair opcode. + +Arguments: + VarStoreId - ID of the variable store referenced in the VFR + +Returns: + None + +--*/ + ; + void + SetSecondaryVarStoreId ( + UINT16 VarStoreId + ) + /*++ + +Routine Description: + This function is invoked by the parser when a secondary variable is + referenced in the VFR. Save the variable store (and set a flag) so + that we can later determine if we need to emit a varstore-select or + varstore-pair opcode. + +Arguments: + VarStoreId - ID of the variable store referenced in the VFR + +Returns: + None + +--*/ + ; + +/* */ +private: + int + FlushQueue ( + VOID + ) + /*++ + +Routine Description: + This function is invoked to flush the internal IFR buffer. + +Arguments: + None + +Returns: + 0 always + +--*/ + ; + int + IAddByte ( + UINT8 ByteVal, + UINT8 KeyByte, + UINT32 LineNum + ) + /*++ + +Routine Description: + This internal function is used to add actual IFR bytes to + the output stream. Most other functions queue up the bytes + in an internal buffer. Once they come here, there's no + going back. + + +Arguments: + ByteVal - value to write to output + KeyByte - key value tied to the byte -- useful for debug + LineNum - line number from source file the byte resulted from + +Returns: + 0 - if successful + 1 - failed due to memory allocation failure + +--*/ + ; + +/* */ +private: + IFR_BYTE *mIfrBytes; + IFR_BYTE *mLastIfrByte; + UINT32 mQueuedByteCount; + UINT32 mBytesWritten; + UINT32 mQueuedLineNum; + UINT8 mQueuedBytes[MAX_QUEUE_COUNT]; + UINT8 mQueuedKeyBytes[MAX_QUEUE_COUNT]; + UINT8 mQueuedOpcodeByte; + UINT32 mQueuedOpcodeByteValid; + UINT16 mPrimaryVarStoreId; + UINT8 mPrimaryVarStoreIdSet; + UINT16 mSecondaryVarStoreId; + UINT8 mSecondaryVarStoreIdSet; + UINT16 mDefaultVarStoreId; +}; + +#endif // #ifndef _VFR_SERVICES_H_ diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile new file mode 100644 index 0000000000..d703b02f31 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile @@ -0,0 +1,172 @@ +#/*++ +# +# Copyright (c) 2004 - 2007, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# makefile +# +# Abstract: +# +# Makefile for building the EFI VFR compiler +# +#--*/ + + +!IFNDEF EDK_SOURCE +!ERROR EDK_SOURCE environmental variable not set +!ENDIF + +# +# Do this if you want to compile from this directory +# +!IFNDEF TOOLCHAIN +TOOLCHAIN = TOOLCHAIN_MSVC +!ENDIF + +!INCLUDE $(BUILD_DIR)\PlatformTools.env + +.SUFFIXES : + +TARGET_NAME = VfrCompile +ANTLR_H = $(PCCTS_DIR)\h +C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) +C_FLAGS_PCCTS = $(C_FLAGS_PCCTS) + +LINK_FLAGS_PCCTS = +LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib" + +# +# Define the EFI output and source directories. +# +ETO = $(EDK_TOOLS_OUTPUT) +SRC = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME) +TARGET_EXE = $(ETO)\$(TARGET_NAME).exe + +# +# Add deeper lookahead with -ck 3 +# +ANTLR_FLAGS = -CC -e3 -ck 3 +DLG_FLAGS = -C2 -i -CC + +# +# Define paths for include files +# +INC = -I $(SRC) +INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include\Ia32 +INC = $(INC) -I $(EDK_SOURCE)\Foundation\Efi\Include +INC = $(INC) -I $(EDK_SOURCE)\Foundation\Framework\Include +INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include\IndustryStandard +INC = $(INC) -I $(EDK_SOURCE)\Foundation\ \ + -I $(EDK_SOURCE)\Foundation\Core\Dxe \ + -I $(EDK_SOURCE)\Foundation\Efi \ + -I $(EDK_SOURCE)\Foundation\Framework +INC = $(INC) -I $(EDK_TOOLS_SOURCE)\Common +INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include + +DLG_FILE = Parser.dlg +SCAN_FILE = DLGLexer +PARSER_FILE = EfiVfrParser + +# +# Create a list of include dependencies +# +INC_DEPS = $(INC_DEPS) $(SRC)\EfiVfr.h +INC_DEPS = $(INC_DEPS) $(EDK_SOURCE)\Foundation\Framework\Include\EfiInternalFormRepresentation.h + +# +# This is the grammer file for our project +# +GRAMMER_FILE = $(SRC)\$(TARGET_NAME).g + +# +# If we utilize a separate token file, define it here. +# +#TOKEN_FILE = + + +OBJECTS = $(ETO)\$(TARGET_NAME).obj \ + $(ETO)\$(PARSER_FILE).obj \ + $(ETO)\AParser.obj \ + $(ETO)\DLexerBase.obj \ + $(ETO)\ATokenBuffer.obj \ + $(ETO)\$(SCAN_FILE).obj \ + $(ETO)\VfrServices.obj + +# +# Per the Language Translation Using PCCTS and C++ Reference Guide, page 109, +# these are the outputs of ANTLR and DLG +# +ANTLR_SPAWN = $(ETO)\$(TARGET_NAME).cpp \ + $(ETO)\$(PARSER_FILE).cpp \ + $(ETO)\$(PARSER_FILE).h \ + $(ETO)\$(DLG_FILE) \ + $(ETO)\tokens.h + +DLG_SPAWN = $(ETO)\$(SCAN_FILE).cpp \ + $(ETO)\$(SCAN_FILE).h + + +# +# Default target +# +all : $(TARGET_EXE) + +# +# All antlr-generated files depend on the .g grammer file. Use the -o +# option to emit them to the appropriate output directory. +# +$(ANTLR_SPAWN) : $(GRAMMER_FILE) $(INC_DEPS) + $(ANTLR) $(ANTLR_FLAGS) -o $(ETO) $(GRAMMER_FILE) + +$(ETO)\$(TARGET_NAME).obj : $(ETO)\$(TARGET_NAME).cpp $(DLG_SPAWN) $(INC_DEPS) + $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(TARGET_NAME).cpp + +$(ETO)\$(SCAN_FILE).obj : $(ETO)\$(SCAN_FILE).cpp $(DLG_SPAWN) $(INC_DEPS) + $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(SCAN_FILE).cpp + +$(ETO)\$(PARSER_FILE).obj : $(ETO)\$(PARSER_FILE).cpp $(ETO)\$(PARSER_FILE).h $(DLG_SPAWN) $(INC_DEPS) + $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(PARSER_FILE).cpp + +$(DLG_SPAWN) : $(ETO)\$(DLG_FILE) $(INC_DEPS) + $(DLG) $(DLG_FLAGS) -o $(ETO) $(ETO)\$(DLG_FILE) + +$(ETO)\AParser.obj : $(ANTLR_H)/AParser.cpp + $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/AParser.cpp + +$(ETO)\ATokenBuffer.obj : $(ANTLR_H)/ATokenBuffer.cpp + $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/ATokenBuffer.cpp + +$(ETO)\DLexerBase.obj : $(ANTLR_H)/DLexerBase.cpp + $(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/DLexerBase.cpp + +$(ETO)\VfrServices.obj : $(SRC)\VfrServices.cpp $(SRC)\VfrServices.h $(INC_DEPS) + $(CC) -c $(C_FLAGS_PCCTS) $(INC) /Fo$@ $(SRC)\VfrServices.cpp + +# +# Add Binary Build description for this tools. +# + +!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe)) +$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y + if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \ + copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y +!ELSE +$(TARGET_EXE) : $(OBJECTS) $(LIBS) + $(LINK) $(MSVS_LINK_LIBPATHS) $(LIBS) /DEBUG /OUT:$(TARGET_EXE) $(LINK_FLAGS_PCCTS) $(OBJECTS) /PDB:$*.pdb + if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools + if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y + if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \ + copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y +!ENDIF + +clean: + diff --git a/EdkCompatibilityPkg/Sample/Version.env b/EdkCompatibilityPkg/Sample/Version.env new file mode 100644 index 0000000000..dde7a7d067 --- /dev/null +++ b/EdkCompatibilityPkg/Sample/Version.env @@ -0,0 +1,34 @@ +#/*++ +# +# Copyright (c) 2006, Intel Corporation +# All rights reserved. This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# Version.env +# +# Abstract: +# +# This file is used to define EDK related version info. +# +#--*/ + +!IF "$(UEFI_MODE)" == "YES" +EFI_SPECIFICATION_VERSION = 0x00020000 +!ELSE +EFI_SPECIFICATION_VERSION = 0x0001000A +!ENDIF + +!IF "$(PI_MODE)" == "YES" +PI_SPECIFICATION_VERSION = 0x00010000 +!ELSE +PI_SPECIFICATION_VERSION = 0x00000009 +!ENDIF + +TIANO_RELEASE_VERSION = 0x00080006 -- 2.39.2